⌘K

Utils

Methods


findWindowSizeClass(prop:)

Determines the window size class based on the screen width, returning the appropriate value for mobile, tablet, or desktop.

@Composable
fun findWindowSizeClass(prop: NativeBlockPropertyModel?): String?

Parameters

  • prop: The NativeBlockPropertyModel containing values for mobile, tablet, and desktop.

Returns

The value for the current device's window size class (mobile, tablet, or desktop), or null if not found.


fontFamilyMapper(textFontFamily:)

Maps a string to a FontFamily for Compose.

fun fontFamilyMapper(textFontFamily: String?): FontFamily

Parameters

  • textFontFamily: The font family name as a string.

Returns

The corresponding FontFamily, or FontFamily.Default if not found.


blockHasSlot(blocks:slot:)

Checks if any block in the given map contains the specified slot.

fun blockHasSlot(
    blocks: Map<String, NativeBlockModel>,
    slot: String
): Boolean

Parameters

  • blocks: A map of block identifiers to their corresponding NativeBlockModel instances.
  • slot: The slot identifier to check for.

Returns

true if any block contains the specified slot, false otherwise.


blockProvideSlot(blockProps:slots:slotType:)

Provides the NativeBlockSlotModel for the specified slot type if the block supports it.

fun blockProvideSlot(
    blockProps: BlockProps,
    slots: Map<String, NativeBlockSlotModel>,
    slotType: String,
): NativeBlockSlotModel?

Parameters

  • blockProps: The properties of the block, including its sub-blocks.
  • slots: A map of slot identifiers to their corresponding NativeBlockSlotModel instances.
  • slotType: The type of slot to check and provide.

Returns

The NativeBlockSlotModel for the specified slot type if supported, or null otherwise.


blockProvideEvent(blockProps:eventType:)

Provides an event handler (callback) for a specific event type if the block supports it.

fun blockProvideEvent(
    blockProps: BlockProps,
    eventType: String
): (() -> Unit)?

Parameters

  • blockProps: The properties of the block, including its event handling logic.
  • eventType: The type of event to provide a handler for.

Returns

A closure representing the event handler if supported, null otherwise.


blockHandleEvent(blockProps:eventAction:eventType:)

Handles an event for a block by invoking the appropriate action handler.

fun blockHandleEvent(
    blockProps: BlockProps,
    eventAction: NativeActionModel,
    eventType: String
)

Parameters

  • blockProps: The properties of the block, including event handling logic.
  • eventAction: The NativeActionModel representing the event.
  • eventType: The type of event to handle.

blockHandleVariableValue(blockProps:variable:)

Processes a variable value by resolving placeholders using the provided block properties.

suspend fun blockHandleVariableValue(
    blockProps: BlockProps,
    variable: NativeVariableModel?
): String?

Parameters

  • blockProps: The properties containing available variables and hierarchy context.
  • variable: The variable model containing the raw value to process.

Supported Formats:

  • {var:variable-key}: Replaces with the value of the variable.
  • {local:localization-key}: Replaces with a localized value.
  • {index}: The list item index.
  • {index:block-key}: The position of a block hierarchy.
  • #SCRIPT #ENDSCRIPT: Replaces JavaScript code snippets within #SCRIPT and #ENDSCRIPT with evaluated results.

Returns

The processed and resolved variable string, or null if variable is null.


blockHandleVariableValue(blockProps:value:)

Processes a variable value by resolving placeholders using block properties.

suspend fun blockHandleVariableValue(
    blockProps: BlockProps,
    value: String?
): String?

Parameters

  • blockProps: The properties containing available variables and hierarchy context.
  • value: The string value containing variable placeholders.

Supported Formats:

  • {var:variable-key}: Replaces with the value of the variable.
  • {local:localization-key}: Replaces with a localized value.
  • {index}: The list item index.
  • {index:block-key}: The position of a block hierarchy.
  • #SCRIPT #ENDSCRIPT: Replaces JavaScript code snippets within #SCRIPT and #ENDSCRIPT tags with evaluated results.

Returns

The processed string with all resolved values, or null if value is null.


actionHandleVariableValue(actionProps:variable:)

Processes a variable value by resolving placeholders using action properties.

suspend fun actionHandleVariableValue(
    actionProps: ActionProps,
    variable: NativeVariableModel?
): String?

Parameters

  • actionProps: The properties containing available variables.
  • variable: The variable model containing the raw value to process.

Supported Formats:

  • {var:variable-key}: Replaces with the value of the variable.
  • {index}: The list item index.
  • #SCRIPT #ENDSCRIPT: Replaces JavaScript code snippets within #SCRIPT and #ENDSCRIPT with evaluated results.

Returns

The processed string with all resolved values, or null if variable is null.


actionHandleVariableValue(actionProps:value:)

Processes a variable value by resolving placeholders using action properties.

suspend fun actionHandleVariableValue(
    actionProps: ActionProps,
    value: String?
): String?

Parameters

  • actionProps: The properties containing available variables.
  • value: The string value containing variable placeholders.

Supported Formats:

  • {var:variable-key}: Replaces with the value of the variable.
  • {index}: The list item index.
  • #SCRIPT #ENDSCRIPT: Replaces JavaScript code snippets within #SCRIPT and #ENDSCRIPT tags with evaluated results.

Returns

The processed string with all resolved values, or null if value is null.