Feature class
đ Descriptionâ
The Feature class defines a feature in a Features collection. Features are used in Tripetto to create panels for managing the properties of elements like blocks. Each feature can control a single Card.
For some examples of built-in features, see the EditorOrchestrator class.
See the Block editor guide for more information about editor panels.
đ constructorâ
Creates a new Feature instance.
Signatureâ
constructor(features: Features, properties: IFeature): Feature
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
features | Features | No | Reference to the features collection. |
properties | IFeature | No | Specifies the properties for the feature. |
Return valueâ
Returns a reference to the new Feature instance.
đī¸ Fieldsâ
đˇī¸ cardâ
Retrieves the card.
Typeâ
Card | undefined
đˇī¸ elementâ
Retrieves a reference to the feature element.
Typeâ
Element | undefined
đˇī¸ featuresâ
Retrieves a reference to the Features collection.
Typeâ
đˇī¸ isActivatedâ
Sets or retrieves if the feature is activated.
Typeâ
boolean
đˇī¸ isAwaitingâ
Sets or retrieves if the feature validation is awaiting.
Typeâ
boolean
đˇī¸ isDisabledâ
Sets or retrieves if the feature is disabled.
Typeâ
boolean
đˇī¸ isFailedâ
Sets or retrieves if the feature validation has failed.
Typeâ
boolean
đˇī¸ isInvalidâ
Sets or retrieves if the feature validation is invalid.
Typeâ
boolean
đˇī¸ isLockedâ
Sets or retrieves if the feature is locked.
Typeâ
boolean
đˇī¸ isPassedâ
Sets or retrieves if the feature validation has passed.
Typeâ
boolean
đˇī¸ isVisibleâ
Sets or retrieves if the feature is visible.
Typeâ
boolean
đˇī¸ nameâ
Sets or retrieves the feature name.
Typeâ
string
đˇī¸ typeâ
Retrieves the feature type.
Typeâ
"card" | "toggle" | "static"
đˇī¸ validationâ
Sets or retrieves the validation state of the feature.
Typeâ
"unknown" | "fail" | "invalid" | "pass" | "await"
âļī¸ Methodsâ
đ§ activateâ
Activates the feature.
Signatureâ
activate(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ activatedâ
Sets the feature state.
Signatureâ
activated(activated?: boolean): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
activated | boolean | Yes | Specifies if the feature is activated (default is true). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ deactivateâ
Deactivate the feature.
Signatureâ
deactivate(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ disableâ
Disables the feature.
Signatureâ
disable(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ disabledâ
Sets the feature disabled state.
Signatureâ
disabled(disabled?: boolean): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
disabled | boolean | Yes | Specifies if the feature is disabled (default is true). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ enableâ
Enables the feature.
Signatureâ
enable(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ focusâ
Sets focus to the feature.
Signatureâ
focus(): boolean
Return valueâ
boolean
đ§ hideâ
Hides the feature.
Signatureâ
hide(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ lockâ
Locks the feature.
Signatureâ
lock(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ lockedâ
Sets the feature locking state.
Signatureâ
locked(locked?: boolean): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
locked | boolean | Yes | Specifies if the feature is locked (default is true). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ onDisableâ
Attaches an OnDisable function to the feature. This function is invoked when the disabled state of the feature changes.
Signatureâ
onDisable(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
fn | (feature: Feature) => void | No | Specifies the callback function. |
mode | "synchronous" | "asynchronous" | Yes | Specifies the callback mode (default is synchronous). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ onLockâ
Attaches an OnLock function to the feature. This function is invoked when the lock state of the feature changes.
Signatureâ
onLock(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
fn | (feature: Feature) => void | No | Specifies the callback function. |
mode | "synchronous" | "asynchronous" | Yes | Specifies the callback mode (default is synchronous). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ onToggleâ
Attaches an OnToggle function to the feature. This function is invoked when the toggle state of the feature changes.
Signatureâ
onToggle(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
fn | (feature: Feature) => void | No | Specifies the callback function. |
mode | "synchronous" | "asynchronous" | Yes | Specifies the callback mode (default is synchronous). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ onVisibleâ
Attaches an OnVisible function to the feature. This function is invoked when the visibility of the feature changes.
Signatureâ
onVisible(fn: (feature: Feature) => void, mode?: "synchronous" | "asynchronous"): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
fn | (feature: Feature) => void | No | Specifies the callback function. |
mode | "synchronous" | "asynchronous" | Yes | Specifies the callback mode (default is synchronous). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ scrollIntoViewâ
Scrolls the feature into view.
Signatureâ
scrollIntoView(): void
đ§ showâ
Shows the feature.
Signatureâ
show(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ styleâ
Applies styles to the feature.
Signatureâ
style(style: IStyles): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
style | IStyles | No | Specifies the styles. |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ unlockâ
Unlocks the feature.
Signatureâ
unlock(): this
Return valueâ
Returns a reference to the Feature instance to allow chaining.
đ§ visibleâ
Sets the feature visibility.
Signatureâ
visible(visible?: boolean): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
visible | boolean | Yes | Specifies if the feature is visible (default is true). |
Return valueâ
Returns a reference to the Feature instance to allow chaining.
âī¸ Interfacesâ
đ IFeatureâ
Defines the feature properties.
Type declarationâ
interface IFeature { type: "card" | "toggle" | "static"; option: boolean; name: string; card?: Card;Optional }
đˇī¸ cardâ
Reference to the Card that is controlled by the feature.
Typeâ
đˇī¸ nameâ
Specifies the feature name.
Typeâ
string
đˇī¸ optionâ
Specifies if the feature is an option.
Typeâ
boolean
đˇī¸ typeâ
Specifies the feature type.
Typeâ
"card" | "toggle" | "static"