@lightspeed/crane-api 2.3.3-rc.0 → 2.4.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/README.md +81 -5
- package/dist/index.d.mts +391 -84
- package/dist/index.d.ts +391 -84
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Reactive, ComputedRef, Component, App, Ref } from 'vue';
|
|
2
|
+
import { Reactive, ComputedRef, Component, App, Ref, CSSProperties, StyleValue } from 'vue';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1686,7 +1686,7 @@ interface InternalColor {
|
|
|
1686
1686
|
*
|
|
1687
1687
|
* @see {@link asStructuredColor}
|
|
1688
1688
|
*/
|
|
1689
|
-
declare class Color implements InternalColor {
|
|
1689
|
+
declare class Color$1 implements InternalColor {
|
|
1690
1690
|
readonly type: "STRUCTURED_COLOR";
|
|
1691
1691
|
readonly raw: string;
|
|
1692
1692
|
readonly hex: string;
|
|
@@ -1710,7 +1710,7 @@ declare class Color implements InternalColor {
|
|
|
1710
1710
|
* // structured?.type === 'STRUCTURED_COLOR'
|
|
1711
1711
|
* ```
|
|
1712
1712
|
*/
|
|
1713
|
-
declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefined): Color | undefined;
|
|
1713
|
+
declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefined): Color$1 | undefined;
|
|
1714
1714
|
/**
|
|
1715
1715
|
* Solid color configuration.
|
|
1716
1716
|
*
|
|
@@ -1718,7 +1718,7 @@ declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefine
|
|
|
1718
1718
|
*/
|
|
1719
1719
|
interface SolidColor {
|
|
1720
1720
|
/** The solid color value (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1721
|
-
color: Color | undefined;
|
|
1721
|
+
color: Color$1 | undefined;
|
|
1722
1722
|
}
|
|
1723
1723
|
/**
|
|
1724
1724
|
* Gradient color configuration.
|
|
@@ -1727,9 +1727,9 @@ interface SolidColor {
|
|
|
1727
1727
|
*/
|
|
1728
1728
|
interface GradientColor {
|
|
1729
1729
|
/** Gradient start color (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1730
|
-
fromColor: Color | undefined;
|
|
1730
|
+
fromColor: Color$1 | undefined;
|
|
1731
1731
|
/** Gradient end color (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1732
|
-
toColor: Color | undefined;
|
|
1732
|
+
toColor: Color$1 | undefined;
|
|
1733
1733
|
}
|
|
1734
1734
|
interface SolidColorTransformed {
|
|
1735
1735
|
color: InternalColor | undefined;
|
|
@@ -6062,6 +6062,23 @@ interface BackgroundTransformed {
|
|
|
6062
6062
|
/** Gradient color configuration */
|
|
6063
6063
|
gradient: GradientColorTransformed | undefined;
|
|
6064
6064
|
}
|
|
6065
|
+
/**
|
|
6066
|
+
* Options for `useBackgroundStyle` and `getBackgroundStyle` utils.
|
|
6067
|
+
*
|
|
6068
|
+
* @see {@link BackgroundDesignData}
|
|
6069
|
+
*/
|
|
6070
|
+
interface BackgroundStyleOptions {
|
|
6071
|
+
/**
|
|
6072
|
+
* Direction of the gradient
|
|
6073
|
+
* @default 'to right'
|
|
6074
|
+
*/
|
|
6075
|
+
direction?: 'to bottom' | 'to right' | 'to left' | 'to top' | string;
|
|
6076
|
+
/**
|
|
6077
|
+
* Fallback color if no background is defined
|
|
6078
|
+
* @default ''
|
|
6079
|
+
*/
|
|
6080
|
+
fallbackColor?: string;
|
|
6081
|
+
}
|
|
6065
6082
|
|
|
6066
6083
|
/** Button fill style */
|
|
6067
6084
|
type ButtonAppearance = 'solid-button' | 'outline-button' | 'text-link';
|
|
@@ -6079,7 +6096,7 @@ type ButtonStyle = 'round-corner' | 'rectangle' | 'pill';
|
|
|
6079
6096
|
* @see {@link ButtonSize}
|
|
6080
6097
|
* @see {@link ButtonStyle}
|
|
6081
6098
|
*/
|
|
6082
|
-
interface ButtonDesignData {
|
|
6099
|
+
interface ButtonDesignData$1 {
|
|
6083
6100
|
/** Button fill style: 'solid-button', 'outline-button', or 'text-link' */
|
|
6084
6101
|
appearance: ButtonAppearance | undefined;
|
|
6085
6102
|
/** Font family name (resolved from global reference) */
|
|
@@ -6089,10 +6106,32 @@ interface ButtonDesignData {
|
|
|
6089
6106
|
/** Button shape: 'round-corner', 'rectangle', or 'pill' */
|
|
6090
6107
|
style: ButtonStyle | undefined;
|
|
6091
6108
|
/** Button color */
|
|
6092
|
-
color: Color | undefined;
|
|
6109
|
+
color: Color$1 | undefined;
|
|
6093
6110
|
/** `true` if button should be displayed */
|
|
6094
6111
|
visible: boolean;
|
|
6095
6112
|
}
|
|
6113
|
+
/**
|
|
6114
|
+
* Size style configuration for a single button size.
|
|
6115
|
+
*
|
|
6116
|
+
* @see {@link UseButtonStylesOptions}
|
|
6117
|
+
*/
|
|
6118
|
+
interface ButtonSizeStyles {
|
|
6119
|
+
fontSize: string;
|
|
6120
|
+
padding: string;
|
|
6121
|
+
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Options for `useButtonStyles` helper composable.
|
|
6124
|
+
*
|
|
6125
|
+
* @see {@link ButtonDesignData}
|
|
6126
|
+
* @see {@link ButtonSizeStyles}
|
|
6127
|
+
*/
|
|
6128
|
+
interface UseButtonStylesOptions {
|
|
6129
|
+
/**
|
|
6130
|
+
* Custom size styles for each button size.
|
|
6131
|
+
* Override defaults for specific sizes or provide all three.
|
|
6132
|
+
*/
|
|
6133
|
+
sizes?: Partial<Record<ButtonSize, ButtonSizeStyles>>;
|
|
6134
|
+
}
|
|
6096
6135
|
|
|
6097
6136
|
type AccordionItem = z.infer<typeof AccordionDesignItemSchema>;
|
|
6098
6137
|
type ShowcaseAccordionItem = z.infer<typeof AccordionShowcaseItemSchema>;
|
|
@@ -6192,7 +6231,7 @@ interface TextDesignData$1 {
|
|
|
6192
6231
|
/** `true` if text should be italic */
|
|
6193
6232
|
italic: boolean | undefined;
|
|
6194
6233
|
/** Text color */
|
|
6195
|
-
color: Color | undefined;
|
|
6234
|
+
color: Color$1 | undefined;
|
|
6196
6235
|
/** `true` if element should be displayed */
|
|
6197
6236
|
visible: boolean;
|
|
6198
6237
|
}
|
|
@@ -6208,6 +6247,33 @@ interface TextareaDesignData$1 extends TextDesignData$1 {
|
|
|
6208
6247
|
/** Always 'pre-wrap' to preserve line breaks */
|
|
6209
6248
|
readonly whiteSpace: string;
|
|
6210
6249
|
}
|
|
6250
|
+
/**
|
|
6251
|
+
* Options for `createTextStyle` helper utility.
|
|
6252
|
+
*
|
|
6253
|
+
* @see {@link TextDesignData}
|
|
6254
|
+
*/
|
|
6255
|
+
interface TextStyleOptions {
|
|
6256
|
+
/**
|
|
6257
|
+
* Default font family if not specified in design
|
|
6258
|
+
* @default 'inherit'
|
|
6259
|
+
*/
|
|
6260
|
+
defaultFont?: string;
|
|
6261
|
+
/**
|
|
6262
|
+
* Default font size in pixels if not specified in design
|
|
6263
|
+
* @default 16
|
|
6264
|
+
*/
|
|
6265
|
+
defaultSize?: number;
|
|
6266
|
+
/**
|
|
6267
|
+
* Default color if not specified in design
|
|
6268
|
+
* @default '#000000'
|
|
6269
|
+
*/
|
|
6270
|
+
defaultColor?: string;
|
|
6271
|
+
/**
|
|
6272
|
+
* Default font weight if not bold
|
|
6273
|
+
* @default 'normal'
|
|
6274
|
+
*/
|
|
6275
|
+
defaultWeight?: string;
|
|
6276
|
+
}
|
|
6211
6277
|
|
|
6212
6278
|
/**
|
|
6213
6279
|
* Return type for `useToggleElementDesign` composable.
|
|
@@ -6266,7 +6332,7 @@ interface LogoDesignData$1 {
|
|
|
6266
6332
|
/** `true` if text should be italic */
|
|
6267
6333
|
italic: boolean | undefined;
|
|
6268
6334
|
/** Text/logo color */
|
|
6269
|
-
color: Color | undefined;
|
|
6335
|
+
color: Color$1 | undefined;
|
|
6270
6336
|
/** `true` if logo should be displayed */
|
|
6271
6337
|
visible: boolean | undefined;
|
|
6272
6338
|
/** Letter spacing value */
|
|
@@ -15951,6 +16017,17 @@ type TemplateConfiguration = z.infer<typeof TemplateConfigurationSchema>;
|
|
|
15951
16017
|
|
|
15952
16018
|
type TranslationSettings = Record<string, Record<string, string>>;
|
|
15953
16019
|
|
|
16020
|
+
/**
|
|
16021
|
+
* Return type for `useCurrentLanguage` composable.
|
|
16022
|
+
*/
|
|
16023
|
+
interface UseCurrentLanguageReturn {
|
|
16024
|
+
/**
|
|
16025
|
+
* Current language code (e.g., 'en', 'nl', 'fr').
|
|
16026
|
+
* Falls back to main language, then to 'en' if no language is selected.
|
|
16027
|
+
*/
|
|
16028
|
+
currentLanguage: ComputedRef<Language['code']>;
|
|
16029
|
+
}
|
|
16030
|
+
|
|
15954
16031
|
interface AppBaseContext {
|
|
15955
16032
|
readonly appName: string;
|
|
15956
16033
|
readonly blockName: string;
|
|
@@ -15985,72 +16062,6 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
15985
16062
|
};
|
|
15986
16063
|
};
|
|
15987
16064
|
|
|
15988
|
-
interface InstantsiteTilePromise {
|
|
15989
|
-
add(callback: (id: string) => void): void;
|
|
15990
|
-
}
|
|
15991
|
-
interface InstantsiteJSAPI {
|
|
15992
|
-
/**
|
|
15993
|
-
* Retrieves the current site ID.
|
|
15994
|
-
*
|
|
15995
|
-
* @returns {number} The site ID.
|
|
15996
|
-
*/
|
|
15997
|
-
getSiteId: () => number;
|
|
15998
|
-
/**
|
|
15999
|
-
* Retrieves the public token for a given app.
|
|
16000
|
-
*
|
|
16001
|
-
* @param {string} appId - The ID of the app.
|
|
16002
|
-
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
16003
|
-
*/
|
|
16004
|
-
getAppPublicToken: (appId: string) => string | undefined;
|
|
16005
|
-
/**
|
|
16006
|
-
* Retrieves the public configuration for a given app.
|
|
16007
|
-
*
|
|
16008
|
-
* @param {string} appId - The ID of the app.
|
|
16009
|
-
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
16010
|
-
*/
|
|
16011
|
-
getAppPublicConfig: (appId: string) => string | undefined;
|
|
16012
|
-
/**
|
|
16013
|
-
* An event that triggers when a tile is loaded.
|
|
16014
|
-
*
|
|
16015
|
-
* @type {InstantsiteTilePromise}
|
|
16016
|
-
*
|
|
16017
|
-
* @example
|
|
16018
|
-
* ```ts
|
|
16019
|
-
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
16020
|
-
*
|
|
16021
|
-
* tileLoadedPromise?.add((tileId) => {
|
|
16022
|
-
* console.log('Tile loaded:', tileId);
|
|
16023
|
-
* });
|
|
16024
|
-
* ```
|
|
16025
|
-
*/
|
|
16026
|
-
onTileLoaded: InstantsiteTilePromise;
|
|
16027
|
-
/**
|
|
16028
|
-
* An event that triggers when a tile is unloaded.
|
|
16029
|
-
*
|
|
16030
|
-
* @type {InstantsiteTilePromise}
|
|
16031
|
-
*
|
|
16032
|
-
* @example
|
|
16033
|
-
* ```ts
|
|
16034
|
-
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
16035
|
-
*
|
|
16036
|
-
* tileUnloadedPromise?.add((tileId) => {
|
|
16037
|
-
* console.log('Tile unloaded:', tileId);
|
|
16038
|
-
* });
|
|
16039
|
-
* ```
|
|
16040
|
-
*/
|
|
16041
|
-
onTileUnloaded: InstantsiteTilePromise;
|
|
16042
|
-
/**
|
|
16043
|
-
* Opens the search page with the specified keyword.
|
|
16044
|
-
*
|
|
16045
|
-
* @param {string | undefined} keyword - The keyword to search for.
|
|
16046
|
-
* @returns {void}
|
|
16047
|
-
*/
|
|
16048
|
-
openSearchPage: (keyword: string | undefined) => void;
|
|
16049
|
-
}
|
|
16050
|
-
|
|
16051
|
-
/** Composable for Instantsite JS API. Returns `window.instantsite` for platform interaction. */
|
|
16052
|
-
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
16053
|
-
|
|
16054
16065
|
declare function createLayoutApp<C, D>(component: Component): {
|
|
16055
16066
|
component: Component;
|
|
16056
16067
|
initState(app: App<Element>, content: C, design: D, defaults: Record<string, unknown>): void;
|
|
@@ -16058,11 +16069,11 @@ declare function createLayoutApp<C, D>(component: Component): {
|
|
|
16058
16069
|
};
|
|
16059
16070
|
|
|
16060
16071
|
interface GlobalColors {
|
|
16061
|
-
title?: Color;
|
|
16062
|
-
body?: Color;
|
|
16063
|
-
button?: Color;
|
|
16064
|
-
link?: Color;
|
|
16065
|
-
background?: Color;
|
|
16072
|
+
title?: Color$1;
|
|
16073
|
+
body?: Color$1;
|
|
16074
|
+
button?: Color$1;
|
|
16075
|
+
link?: Color$1;
|
|
16076
|
+
background?: Color$1;
|
|
16066
16077
|
}
|
|
16067
16078
|
interface GlobalFonts {
|
|
16068
16079
|
title: string;
|
|
@@ -16123,6 +16134,302 @@ declare function createVueServerApp<C, D>(appComponent: Component, extensions?:
|
|
|
16123
16134
|
};
|
|
16124
16135
|
};
|
|
16125
16136
|
|
|
16137
|
+
/**
|
|
16138
|
+
* Color Utilities
|
|
16139
|
+
*
|
|
16140
|
+
* Utilities for working with Crane Color objects and color calculations.
|
|
16141
|
+
* Includes hex extraction and contrast color calculation.
|
|
16142
|
+
*/
|
|
16143
|
+
/**
|
|
16144
|
+
* Safely extracts hex color from a Color object or string
|
|
16145
|
+
*
|
|
16146
|
+
* Handles multiple input types:
|
|
16147
|
+
* - Color object with hex property
|
|
16148
|
+
* - String (returned as-is)
|
|
16149
|
+
* - undefined/null (returns fallback)
|
|
16150
|
+
*
|
|
16151
|
+
* @param color - The color value (Color object, string, or undefined)
|
|
16152
|
+
* @param fallback - Fallback color if extraction fails
|
|
16153
|
+
* @returns Hex color string
|
|
16154
|
+
*
|
|
16155
|
+
* @example
|
|
16156
|
+
* ```typescript
|
|
16157
|
+
* // With Color object
|
|
16158
|
+
* const hex = getColorHex(titleDesign.color, '#FFFFFF')
|
|
16159
|
+
*
|
|
16160
|
+
* // With string
|
|
16161
|
+
* const hex = getColorHex('#FF0000', '#000000') // Returns '#FF0000'
|
|
16162
|
+
*
|
|
16163
|
+
* // With undefined
|
|
16164
|
+
* const hex = getColorHex(undefined, '#000000') // Returns '#000000'
|
|
16165
|
+
* ```
|
|
16166
|
+
*/
|
|
16167
|
+
declare function getColorHex(color: Color | string | undefined | null, fallback?: string): string;
|
|
16168
|
+
/**
|
|
16169
|
+
* Returns true if background color is dark enough to require light text.
|
|
16170
|
+
* Uses WCAG relative luminance formula for accurate contrast calculation.
|
|
16171
|
+
*
|
|
16172
|
+
* @param backgroundColor - Hex color string (e.g., '#FF0000')
|
|
16173
|
+
* @returns `true` for dark colors, `false` for light colors
|
|
16174
|
+
*/
|
|
16175
|
+
declare function isColorDark(backgroundColor: string): boolean;
|
|
16176
|
+
/**
|
|
16177
|
+
* Returns the best contrast text color for a given background.
|
|
16178
|
+
*
|
|
16179
|
+
* @param backgroundColorHex - Hex color string
|
|
16180
|
+
* @param darkTextColorHex - Color used on light backgrounds
|
|
16181
|
+
* @param lightTextColorHex - Color used on dark backgrounds
|
|
16182
|
+
*/
|
|
16183
|
+
declare function getContrastTextColor(backgroundColorHex: string, darkTextColorHex?: string, lightTextColorHex?: string): string;
|
|
16184
|
+
|
|
16185
|
+
/**
|
|
16186
|
+
* Text Style Utilities
|
|
16187
|
+
*
|
|
16188
|
+
* Utilities for creating CSS styles from Crane TextDesignData.
|
|
16189
|
+
*/
|
|
16190
|
+
|
|
16191
|
+
/**
|
|
16192
|
+
* Creates CSS properties from Crane TextDesignData
|
|
16193
|
+
*
|
|
16194
|
+
* Handles:
|
|
16195
|
+
* - Font family
|
|
16196
|
+
* - Font size (number to px conversion)
|
|
16197
|
+
* - Color (Color object to hex)
|
|
16198
|
+
* - Bold/Italic styles
|
|
16199
|
+
* - Visibility (returns display: none if not visible)
|
|
16200
|
+
*
|
|
16201
|
+
* @param design - TextDesignData from useTextElementDesign
|
|
16202
|
+
* @param options - Default values for missing design properties
|
|
16203
|
+
* @returns CSS properties object for Vue style binding
|
|
16204
|
+
*
|
|
16205
|
+
* @example
|
|
16206
|
+
* ```typescript
|
|
16207
|
+
* import { createTextStyle } from '@lightspeed/crane-api'
|
|
16208
|
+
* import { useTextElementDesign } from '@lightspeed/crane-api'
|
|
16209
|
+
*
|
|
16210
|
+
* const titleDesign = useTextElementDesign<Design>('title')
|
|
16211
|
+
* const titleStyle = computed(() => createTextStyle(titleDesign, {
|
|
16212
|
+
* defaultFont: 'Inter',
|
|
16213
|
+
* defaultSize: 24,
|
|
16214
|
+
* defaultColor: '#333333',
|
|
16215
|
+
* }))
|
|
16216
|
+
*
|
|
16217
|
+
* // In template:
|
|
16218
|
+
* // <h1 :style="titleStyle">{{ title }}</h1>
|
|
16219
|
+
* ```
|
|
16220
|
+
*/
|
|
16221
|
+
declare function createTextStyle(design: TextDesignData | undefined, options?: TextStyleOptions): CSSProperties;
|
|
16222
|
+
|
|
16223
|
+
/**
|
|
16224
|
+
* useBackgroundStyle Composable
|
|
16225
|
+
*
|
|
16226
|
+
* Creates reactive CSS background styles from Crane BackgroundDesignData.
|
|
16227
|
+
* Supports solid colors and gradients.
|
|
16228
|
+
*
|
|
16229
|
+
* @example
|
|
16230
|
+
* ```typescript
|
|
16231
|
+
* import { useBackgroundStyle } from '@lightspeed/crane-api'
|
|
16232
|
+
* import { useBackgroundElementDesign } from '@lightspeed/crane-api'
|
|
16233
|
+
*
|
|
16234
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16235
|
+
* const backgroundStyle = useBackgroundStyle(backgroundDesign)
|
|
16236
|
+
*
|
|
16237
|
+
* // In template:
|
|
16238
|
+
* // <div :style="backgroundStyle">...</div>
|
|
16239
|
+
* ```
|
|
16240
|
+
*/
|
|
16241
|
+
|
|
16242
|
+
/**
|
|
16243
|
+
* Extracts background styles from BackgroundDesignData.
|
|
16244
|
+
*
|
|
16245
|
+
* Returns a style object suitable for CSS `:style` bindings.
|
|
16246
|
+
*
|
|
16247
|
+
* **Gradient fallback behaviour:**
|
|
16248
|
+
* When `background.type === 'gradient'`, each of `fromColor` and `toColor` is resolved
|
|
16249
|
+
* independently via `getColorHex`. If a color is missing/undefined and `fallbackColor` is
|
|
16250
|
+
* an empty string (the default), `getColorHex` returns `''` and the whole style object is
|
|
16251
|
+
* returned as `{}`. If `fallbackColor` is a non-empty string, the missing color is replaced
|
|
16252
|
+
* by that fallback, which may result in a gradient where both stops are the same colour
|
|
16253
|
+
* (e.g. `linear-gradient(to right, #FFFFFF, #FFFFFF)`). This is valid CSS and visually
|
|
16254
|
+
* equivalent to a solid colour, but it is worth being aware of when debugging gradient output.
|
|
16255
|
+
*
|
|
16256
|
+
* @param backgroundDesign - BackgroundDesignData from useBackgroundElementDesign
|
|
16257
|
+
* @param options - Configuration options
|
|
16258
|
+
* @returns CSS background style object
|
|
16259
|
+
*
|
|
16260
|
+
* @example
|
|
16261
|
+
* ```typescript
|
|
16262
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16263
|
+
* const bgStyle = getBackgroundStyle(backgroundDesign, { fallbackColor: '#FFFFFF' })
|
|
16264
|
+
* // Returns: { backgroundColor: '#FF0000' } or { backgroundImage: 'linear-gradient(...)' }
|
|
16265
|
+
* // If one gradient colour is missing and fallbackColor is '#FFFFFF':
|
|
16266
|
+
* // Returns: { backgroundImage: 'linear-gradient(to right, #FFFFFF, #FFFFFF)' }
|
|
16267
|
+
* ```
|
|
16268
|
+
*/
|
|
16269
|
+
declare function getBackgroundStyle(backgroundDesign: BackgroundDesignData | undefined, options?: BackgroundStyleOptions): StyleValue;
|
|
16270
|
+
/**
|
|
16271
|
+
* Creates reactive background styles from Crane BackgroundDesignData
|
|
16272
|
+
*
|
|
16273
|
+
* Supports solid colors and gradients. Returns a computed style object
|
|
16274
|
+
* that can be bound directly to :style attribute.
|
|
16275
|
+
*
|
|
16276
|
+
* @param backgroundDesign - Reactive BackgroundDesignData from useBackgroundElementDesign.
|
|
16277
|
+
* Must be a reactive object (not a plain snapshot) for changes to be tracked.
|
|
16278
|
+
* @param options - Configuration options
|
|
16279
|
+
* @returns Computed style object with backgroundColor or backgroundImage
|
|
16280
|
+
*
|
|
16281
|
+
* @example
|
|
16282
|
+
* ```typescript
|
|
16283
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16284
|
+
* const backgroundStyle = useBackgroundStyle(backgroundDesign)
|
|
16285
|
+
*
|
|
16286
|
+
* // In template:
|
|
16287
|
+
* // <div :style="backgroundStyle">...</div>
|
|
16288
|
+
* ```
|
|
16289
|
+
*/
|
|
16290
|
+
declare function useBackgroundStyle(backgroundDesign: Reactive<BackgroundDesignData> | BackgroundDesignData | undefined, options?: BackgroundStyleOptions): ComputedRef<StyleValue>;
|
|
16291
|
+
|
|
16292
|
+
/**
|
|
16293
|
+
* useButtonStyles Composable
|
|
16294
|
+
*
|
|
16295
|
+
* Generates dynamic button styles based on Crane's ButtonDesignData.
|
|
16296
|
+
* Handles size, appearance, shape, and automatic contrast text color.
|
|
16297
|
+
*
|
|
16298
|
+
* @example
|
|
16299
|
+
* ```typescript
|
|
16300
|
+
* import { useButtonStyles } from '@lightspeed/crane-api'
|
|
16301
|
+
* import { useButtonElementDesign } from '@lightspeed/crane-api'
|
|
16302
|
+
*
|
|
16303
|
+
* const ctaButtonDesign = useButtonElementDesign<Design>('cta_button')
|
|
16304
|
+
* const ctaButtonStyle = useButtonStyles(ctaButtonDesign)
|
|
16305
|
+
*
|
|
16306
|
+
* // In template:
|
|
16307
|
+
* // <button :style="ctaButtonStyle">Click me</button>
|
|
16308
|
+
* ```
|
|
16309
|
+
*/
|
|
16310
|
+
|
|
16311
|
+
/**
|
|
16312
|
+
* Generates dynamic button styles based on Crane's button design data
|
|
16313
|
+
*
|
|
16314
|
+
* Handles:
|
|
16315
|
+
* - Size: 'small', 'medium', 'large' (configurable via options)
|
|
16316
|
+
* - Appearance: 'solid-button', 'outline-button', 'text-link'
|
|
16317
|
+
* - Style (shape): 'rectangle', 'round-corner', 'pill'
|
|
16318
|
+
*
|
|
16319
|
+
* @param buttonDesign - Reactive button design data from useButtonElementDesign.
|
|
16320
|
+
* Must be a reactive object (not a plain snapshot) for changes to be tracked.
|
|
16321
|
+
* @param options - Optional configuration (e.g., custom size styles)
|
|
16322
|
+
* @returns Computed style object for inline application
|
|
16323
|
+
*/
|
|
16324
|
+
declare function useButtonStyles(buttonDesign: Reactive<ButtonDesignData> | Partial<ButtonDesignData> | undefined, options?: UseButtonStylesOptions): ComputedRef<Record<string, string>>;
|
|
16325
|
+
|
|
16326
|
+
/**
|
|
16327
|
+
* useCurrentLanguage Composable
|
|
16328
|
+
*
|
|
16329
|
+
* Provides access to the current language from site context.
|
|
16330
|
+
* Useful for i18n, API calls with language parameter, and conditional rendering.
|
|
16331
|
+
*
|
|
16332
|
+
* @example
|
|
16333
|
+
* ```typescript
|
|
16334
|
+
* import { useCurrentLanguage } from '@lightspeed/crane-api'
|
|
16335
|
+
*
|
|
16336
|
+
* const { currentLanguage } = useCurrentLanguage()
|
|
16337
|
+
*
|
|
16338
|
+
* // Use in API calls
|
|
16339
|
+
* fetchProducts({ lang: currentLanguage.value })
|
|
16340
|
+
*
|
|
16341
|
+
* // Use in computed
|
|
16342
|
+
* const greeting = computed(() =>
|
|
16343
|
+
* currentLanguage.value === 'fr' ? 'Bonjour' : 'Hello'
|
|
16344
|
+
* )
|
|
16345
|
+
* ```
|
|
16346
|
+
*/
|
|
16347
|
+
|
|
16348
|
+
/**
|
|
16349
|
+
* Get current selected language code from site languages.
|
|
16350
|
+
*
|
|
16351
|
+
* Fallback chain: selected language → main language → 'en'.
|
|
16352
|
+
*
|
|
16353
|
+
* @param languages - Array of available languages from site content (global Language type)
|
|
16354
|
+
* @returns Current language code (e.g., 'en', 'nl', 'fr')
|
|
16355
|
+
*/
|
|
16356
|
+
declare function getCurrentLanguageCode(languages: Language[] | undefined): Language['code'];
|
|
16357
|
+
/**
|
|
16358
|
+
* Composable to get current language from site context.
|
|
16359
|
+
*
|
|
16360
|
+
* Uses the global Language type from types.d.ts.
|
|
16361
|
+
* Fallback chain: selected language → main language → 'en'.
|
|
16362
|
+
*
|
|
16363
|
+
* @returns Object containing currentLanguage computed ref
|
|
16364
|
+
*/
|
|
16365
|
+
declare function useCurrentLanguage(): UseCurrentLanguageReturn;
|
|
16366
|
+
|
|
16367
|
+
interface InstantsiteTilePromise {
|
|
16368
|
+
add(callback: (id: string) => void): void;
|
|
16369
|
+
}
|
|
16370
|
+
interface InstantsiteJSAPI {
|
|
16371
|
+
/**
|
|
16372
|
+
* Retrieves the current site ID.
|
|
16373
|
+
*
|
|
16374
|
+
* @returns {number} The site ID.
|
|
16375
|
+
*/
|
|
16376
|
+
getSiteId: () => number;
|
|
16377
|
+
/**
|
|
16378
|
+
* Retrieves the public token for a given app.
|
|
16379
|
+
*
|
|
16380
|
+
* @param {string} appId - The ID of the app.
|
|
16381
|
+
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
16382
|
+
*/
|
|
16383
|
+
getAppPublicToken: (appId: string) => string | undefined;
|
|
16384
|
+
/**
|
|
16385
|
+
* Retrieves the public configuration for a given app.
|
|
16386
|
+
*
|
|
16387
|
+
* @param {string} appId - The ID of the app.
|
|
16388
|
+
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
16389
|
+
*/
|
|
16390
|
+
getAppPublicConfig: (appId: string) => string | undefined;
|
|
16391
|
+
/**
|
|
16392
|
+
* An event that triggers when a tile is loaded.
|
|
16393
|
+
*
|
|
16394
|
+
* @type {InstantsiteTilePromise}
|
|
16395
|
+
*
|
|
16396
|
+
* @example
|
|
16397
|
+
* ```ts
|
|
16398
|
+
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
16399
|
+
*
|
|
16400
|
+
* tileLoadedPromise?.add((tileId) => {
|
|
16401
|
+
* console.log('Tile loaded:', tileId);
|
|
16402
|
+
* });
|
|
16403
|
+
* ```
|
|
16404
|
+
*/
|
|
16405
|
+
onTileLoaded: InstantsiteTilePromise;
|
|
16406
|
+
/**
|
|
16407
|
+
* An event that triggers when a tile is unloaded.
|
|
16408
|
+
*
|
|
16409
|
+
* @type {InstantsiteTilePromise}
|
|
16410
|
+
*
|
|
16411
|
+
* @example
|
|
16412
|
+
* ```ts
|
|
16413
|
+
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
16414
|
+
*
|
|
16415
|
+
* tileUnloadedPromise?.add((tileId) => {
|
|
16416
|
+
* console.log('Tile unloaded:', tileId);
|
|
16417
|
+
* });
|
|
16418
|
+
* ```
|
|
16419
|
+
*/
|
|
16420
|
+
onTileUnloaded: InstantsiteTilePromise;
|
|
16421
|
+
/**
|
|
16422
|
+
* Opens the search page with the specified keyword.
|
|
16423
|
+
*
|
|
16424
|
+
* @param {string | undefined} keyword - The keyword to search for.
|
|
16425
|
+
* @returns {void}
|
|
16426
|
+
*/
|
|
16427
|
+
openSearchPage: (keyword: string | undefined) => void;
|
|
16428
|
+
}
|
|
16429
|
+
|
|
16430
|
+
/** Composable for Instantsite JS API. Returns `window.instantsite` for platform interaction. */
|
|
16431
|
+
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
16432
|
+
|
|
16126
16433
|
/**
|
|
16127
16434
|
* Composable for accessing BUTTON content with action link.
|
|
16128
16435
|
*
|
|
@@ -16694,7 +17001,7 @@ declare function useBackgroundElementDesign<DESIGN>(elementName: keyof DESIGN):
|
|
|
16694
17001
|
* </button>
|
|
16695
17002
|
* ```
|
|
16696
17003
|
*/
|
|
16697
|
-
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData>;
|
|
17004
|
+
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData$1>;
|
|
16698
17005
|
|
|
16699
17006
|
/**
|
|
16700
17007
|
* Composable for accessing IMAGE design settings.
|
|
@@ -17764,5 +18071,5 @@ declare const translation: {
|
|
|
17764
18071
|
readonly init: (config: TranslationSettings) => TranslationSettings;
|
|
17765
18072
|
};
|
|
17766
18073
|
|
|
17767
|
-
export { ActionLinkTypeEnum, BackgroundStyleEnum, ButtonAppearanceEnum, ButtonShapeEnum, ButtonSizeEnum, ButtonTypeEnum, CatalogLayoutSlot, CategoryLayoutSlot, Color, ConfigTypeEnum, DesignEditorType, EditorTypes, ImageSet, InstantsiteJsEvent, LogoTypeEnum, OverlayType, OverlayTypeEnum, PluginTypeEnum, ProductLayoutSlot, SectionTypeEnum, TemplateCategoriesList, ValidationTypeEnum, asStructuredColor, collection, content, createLayoutApp, createVueClientApp, createVueServerApp, design, layout, section, showcase, template, translation, useAccordionElementDesign, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useCategorySelectorElementContent, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useLogoElementContent, useLogoElementDesign, useMenuElementContent, useNavigationMenuElementContent, useProductSelectorElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useTranslation, useVueBaseProps };
|
|
17768
|
-
export type { AccordionDesignData, AccordionDesignEditor, AccordionDesignEditorDefaults, AccordionDesignItemData, AccordionItem, AccordionShowcaseDesignEditorDefaults, ActionLink, AppBaseContext, AppBaseData, AppBaseState, Background, BackgroundDesignData$1 as BackgroundDesignData, BackgroundDesignEditor, BackgroundDesignEditorDefaults, BackgroundDesignEditorDefaultsTransformed, BackgroundTransformed, BackgroundType, ButtonAppearance, ButtonContentData, ButtonContentEditor, ButtonContentEditorDefaults, ButtonDesignData, ButtonDesignEditor, ButtonDesignEditorDefaults, ButtonDesignEditorDefaultsTransformed, ButtonSize, ButtonStyle, CapitalizationType, Card, CategorySelectorContent, CategorySelectorContentEditor, CategorySelectorContentEditorDefaults, CategorySelectorData, CollectionDescriptor, CollectionDescriptorContent, CollectionDescriptorMetadata, ColorPickerDesignEditor, ColorPickerDesignEditorDefaults, ColorPickerDesignEditorDefaultsTransformed, ContentEditor, ContentEditorDefaults, ContentSettings, CustomSection, Deck, DeckContent, DeckContentEditor, DefaultSection, DesignEditor, DesignEditorDefaults, DesignEditorDefaultsTransformed, DesignSettings, DividerContentEditor, DividerContentEditorDefaults, DividerDesignEditor, Font, Frame, GlobalColorsString, GlobalDesign$1 as GlobalDesign, GlobalFontsString, GlobalTextSizeString, GradientColor, GradientColorTransformed, HSLColor, ImageBorderInfoData, ImageContent, ImageContentData, ImageContentEditor, ImageContentEditorDefaults, ImageDesignData$1 as ImageDesignData, ImageDesignEditor, ImageDesignEditorDefaults, ImageDesignEditorDefaultsTransformed, ImageInfoData, InfoContentEditor, InfoContentEditorDefaults, InfoDesignEditor, InfoDesignEditorDefaults, InputBoxContent, InputboxContentEditor, InputboxContentEditorDefaults, InstantsiteJSAPI$1 as InstantsiteJSAPI, InstantsiteTilePromise$1 as InstantsiteTilePromise, InternalColor, LayoutDesignData, LayoutDesignOverride, LayoutSettings, LogoContent, LogoContentData, LogoContentEditor, LogoContentEditorDefaults, LogoDesignData$1 as LogoDesignData, LogoDesignEditor, LogoDesignEditorDefaults, LogoDesignEditorDefaultsTransformed, LogoType, MandatoryContentSettings, MandatoryDesignSettings, Manifest, MenuContent, MenuContentData, MenuContentEditor, MenuItem, NavigationMenuContentEditor, Overlay, OverlayTransformed, ProductSelectorContent, ProductSelectorContentEditor, ProductSelectorContentEditorDefaults, ProductSelectorData, RGBAColor, Section, SelectBoxContent, SelectboxContentEditor, SelectboxContentEditorDefaults, SelectboxContentOption, SelectboxDesignData, SelectboxDesignEditor, SelectboxDesignEditorDefaults, SelectboxDesignEditorDefaultsTransformed, Showcase, ShowcaseAccordionItem, ShowcaseContentEditorsDefaults, ShowcaseDeckContentEditorDefaults, ShowcaseImageContentEditorDefaults, ShowcaseInputboxContentEditorDefaults, ShowcaseLogoContentEditorDefaults, ShowcaseMenuContentEditorDefaults, ShowcaseNavigationMenuContentEditorDefaults, ShowcaseOverride, ShowcaseTextareaContentEditorDefaults, SolidColor, SolidColorTransformed, StorePageConfiguration, StorefrontSection, StorefrontSectionId, Template, TemplateConfiguration, TemplateConfigurationSection, TemplateCustomSection, TemplateDefaultSection, TemplateMetadata, TemplatePage, TemplatePageNamed, TemplateStorefrontSection, TextAreaContent, TextDesignData$1 as TextDesignData, TextDesignEditor, TextDesignEditorDefaults, TextDesignEditorDefaultsTransformed, TextSize, TextareaContentEditor, TextareaContentEditorDefaults, TextareaDesignData$1 as TextareaDesignData, ToggleContent, ToggleContentData, ToggleContentEditor, ToggleContentEditorDefaults, ToggleDesignData, ToggleDesignEditor, ToggleDesignEditorDefaults, ToggleDesignEditorDefaultsTransformed, TransformedFrame, TranslationSettings, VuegaPageId };
|
|
18074
|
+
export { ActionLinkTypeEnum, BackgroundStyleEnum, ButtonAppearanceEnum, ButtonShapeEnum, ButtonSizeEnum, ButtonTypeEnum, CatalogLayoutSlot, CategoryLayoutSlot, Color$1 as Color, ConfigTypeEnum, DesignEditorType, EditorTypes, ImageSet, InstantsiteJsEvent, LogoTypeEnum, OverlayType, OverlayTypeEnum, PluginTypeEnum, ProductLayoutSlot, SectionTypeEnum, TemplateCategoriesList, ValidationTypeEnum, asStructuredColor, collection, content, createLayoutApp, createTextStyle, createVueClientApp, createVueServerApp, design, getBackgroundStyle, getColorHex, getContrastTextColor, getCurrentLanguageCode, isColorDark, layout, section, showcase, template, translation, useAccordionElementDesign, useBackgroundElementDesign, useBackgroundStyle, useButtonElementContent, useButtonElementDesign, useButtonStyles, useCategorySelectorElementContent, useCurrentLanguage, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useLogoElementContent, useLogoElementDesign, useMenuElementContent, useNavigationMenuElementContent, useProductSelectorElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useTranslation, useVueBaseProps };
|
|
18075
|
+
export type { AccordionDesignData, AccordionDesignEditor, AccordionDesignEditorDefaults, AccordionDesignItemData, AccordionItem, AccordionShowcaseDesignEditorDefaults, ActionLink, AppBaseContext, AppBaseData, AppBaseState, Background, BackgroundDesignData$1 as BackgroundDesignData, BackgroundDesignEditor, BackgroundDesignEditorDefaults, BackgroundDesignEditorDefaultsTransformed, BackgroundStyleOptions, BackgroundTransformed, BackgroundType, ButtonAppearance, ButtonContentData, ButtonContentEditor, ButtonContentEditorDefaults, ButtonDesignData$1 as ButtonDesignData, ButtonDesignEditor, ButtonDesignEditorDefaults, ButtonDesignEditorDefaultsTransformed, ButtonSize, ButtonSizeStyles, ButtonStyle, CapitalizationType, Card, CategorySelectorContent, CategorySelectorContentEditor, CategorySelectorContentEditorDefaults, CategorySelectorData, CollectionDescriptor, CollectionDescriptorContent, CollectionDescriptorMetadata, ColorPickerDesignEditor, ColorPickerDesignEditorDefaults, ColorPickerDesignEditorDefaultsTransformed, ContentEditor, ContentEditorDefaults, ContentSettings, CustomSection, Deck, DeckContent, DeckContentEditor, DefaultSection, DesignEditor, DesignEditorDefaults, DesignEditorDefaultsTransformed, DesignSettings, DividerContentEditor, DividerContentEditorDefaults, DividerDesignEditor, Font, Frame, GlobalColorsString, GlobalDesign$1 as GlobalDesign, GlobalFontsString, GlobalTextSizeString, GradientColor, GradientColorTransformed, HSLColor, ImageBorderInfoData, ImageContent, ImageContentData, ImageContentEditor, ImageContentEditorDefaults, ImageDesignData$1 as ImageDesignData, ImageDesignEditor, ImageDesignEditorDefaults, ImageDesignEditorDefaultsTransformed, ImageInfoData, InfoContentEditor, InfoContentEditorDefaults, InfoDesignEditor, InfoDesignEditorDefaults, InputBoxContent, InputboxContentEditor, InputboxContentEditorDefaults, InstantsiteJSAPI$1 as InstantsiteJSAPI, InstantsiteTilePromise$1 as InstantsiteTilePromise, InternalColor, LayoutDesignData, LayoutDesignOverride, LayoutSettings, LogoContent, LogoContentData, LogoContentEditor, LogoContentEditorDefaults, LogoDesignData$1 as LogoDesignData, LogoDesignEditor, LogoDesignEditorDefaults, LogoDesignEditorDefaultsTransformed, LogoType, MandatoryContentSettings, MandatoryDesignSettings, Manifest, MenuContent, MenuContentData, MenuContentEditor, MenuItem, NavigationMenuContentEditor, Overlay, OverlayTransformed, ProductSelectorContent, ProductSelectorContentEditor, ProductSelectorContentEditorDefaults, ProductSelectorData, RGBAColor, Section, SelectBoxContent, SelectboxContentEditor, SelectboxContentEditorDefaults, SelectboxContentOption, SelectboxDesignData, SelectboxDesignEditor, SelectboxDesignEditorDefaults, SelectboxDesignEditorDefaultsTransformed, Showcase, ShowcaseAccordionItem, ShowcaseContentEditorsDefaults, ShowcaseDeckContentEditorDefaults, ShowcaseImageContentEditorDefaults, ShowcaseInputboxContentEditorDefaults, ShowcaseLogoContentEditorDefaults, ShowcaseMenuContentEditorDefaults, ShowcaseNavigationMenuContentEditorDefaults, ShowcaseOverride, ShowcaseTextareaContentEditorDefaults, SolidColor, SolidColorTransformed, StorePageConfiguration, StorefrontSection, StorefrontSectionId, Template, TemplateConfiguration, TemplateConfigurationSection, TemplateCustomSection, TemplateDefaultSection, TemplateMetadata, TemplatePage, TemplatePageNamed, TemplateStorefrontSection, TextAreaContent, TextDesignData$1 as TextDesignData, TextDesignEditor, TextDesignEditorDefaults, TextDesignEditorDefaultsTransformed, TextSize, TextStyleOptions, TextareaContentEditor, TextareaContentEditorDefaults, TextareaDesignData$1 as TextareaDesignData, ToggleContent, ToggleContentData, ToggleContentEditor, ToggleContentEditorDefaults, ToggleDesignData, ToggleDesignEditor, ToggleDesignEditorDefaults, ToggleDesignEditorDefaultsTransformed, TransformedFrame, TranslationSettings, UseButtonStylesOptions, UseCurrentLanguageReturn, VuegaPageId };
|