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"