@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.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="../types.d.ts" />
|
|
2
2
|
import * as vue from 'vue';
|
|
3
|
-
import { Reactive, ComputedRef, Component, App, Ref } from 'vue';
|
|
3
|
+
import { Reactive, ComputedRef, Component, App, Ref, CSSProperties, StyleValue } from 'vue';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1687,7 +1687,7 @@ interface InternalColor {
|
|
|
1687
1687
|
*
|
|
1688
1688
|
* @see {@link asStructuredColor}
|
|
1689
1689
|
*/
|
|
1690
|
-
declare class Color implements InternalColor {
|
|
1690
|
+
declare class Color$1 implements InternalColor {
|
|
1691
1691
|
readonly type: "STRUCTURED_COLOR";
|
|
1692
1692
|
readonly raw: string;
|
|
1693
1693
|
readonly hex: string;
|
|
@@ -1711,7 +1711,7 @@ declare class Color implements InternalColor {
|
|
|
1711
1711
|
* // structured?.type === 'STRUCTURED_COLOR'
|
|
1712
1712
|
* ```
|
|
1713
1713
|
*/
|
|
1714
|
-
declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefined): Color | undefined;
|
|
1714
|
+
declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefined): Color$1 | undefined;
|
|
1715
1715
|
/**
|
|
1716
1716
|
* Solid color configuration.
|
|
1717
1717
|
*
|
|
@@ -1719,7 +1719,7 @@ declare function asStructuredColor(color: Omit<InternalColor, 'type'> | undefine
|
|
|
1719
1719
|
*/
|
|
1720
1720
|
interface SolidColor {
|
|
1721
1721
|
/** The solid color value (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1722
|
-
color: Color | undefined;
|
|
1722
|
+
color: Color$1 | undefined;
|
|
1723
1723
|
}
|
|
1724
1724
|
/**
|
|
1725
1725
|
* Gradient color configuration.
|
|
@@ -1728,9 +1728,9 @@ interface SolidColor {
|
|
|
1728
1728
|
*/
|
|
1729
1729
|
interface GradientColor {
|
|
1730
1730
|
/** Gradient start color (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1731
|
-
fromColor: Color | undefined;
|
|
1731
|
+
fromColor: Color$1 | undefined;
|
|
1732
1732
|
/** Gradient end color (StructuredColor post-resolution, or GlobalColor pre-resolution) */
|
|
1733
|
-
toColor: Color | undefined;
|
|
1733
|
+
toColor: Color$1 | undefined;
|
|
1734
1734
|
}
|
|
1735
1735
|
interface SolidColorTransformed {
|
|
1736
1736
|
color: InternalColor | undefined;
|
|
@@ -6063,6 +6063,23 @@ interface BackgroundTransformed {
|
|
|
6063
6063
|
/** Gradient color configuration */
|
|
6064
6064
|
gradient: GradientColorTransformed | undefined;
|
|
6065
6065
|
}
|
|
6066
|
+
/**
|
|
6067
|
+
* Options for `useBackgroundStyle` and `getBackgroundStyle` utils.
|
|
6068
|
+
*
|
|
6069
|
+
* @see {@link BackgroundDesignData}
|
|
6070
|
+
*/
|
|
6071
|
+
interface BackgroundStyleOptions {
|
|
6072
|
+
/**
|
|
6073
|
+
* Direction of the gradient
|
|
6074
|
+
* @default 'to right'
|
|
6075
|
+
*/
|
|
6076
|
+
direction?: 'to bottom' | 'to right' | 'to left' | 'to top' | string;
|
|
6077
|
+
/**
|
|
6078
|
+
* Fallback color if no background is defined
|
|
6079
|
+
* @default ''
|
|
6080
|
+
*/
|
|
6081
|
+
fallbackColor?: string;
|
|
6082
|
+
}
|
|
6066
6083
|
|
|
6067
6084
|
/** Button fill style */
|
|
6068
6085
|
type ButtonAppearance = 'solid-button' | 'outline-button' | 'text-link';
|
|
@@ -6080,7 +6097,7 @@ type ButtonStyle = 'round-corner' | 'rectangle' | 'pill';
|
|
|
6080
6097
|
* @see {@link ButtonSize}
|
|
6081
6098
|
* @see {@link ButtonStyle}
|
|
6082
6099
|
*/
|
|
6083
|
-
interface ButtonDesignData {
|
|
6100
|
+
interface ButtonDesignData$1 {
|
|
6084
6101
|
/** Button fill style: 'solid-button', 'outline-button', or 'text-link' */
|
|
6085
6102
|
appearance: ButtonAppearance | undefined;
|
|
6086
6103
|
/** Font family name (resolved from global reference) */
|
|
@@ -6090,10 +6107,32 @@ interface ButtonDesignData {
|
|
|
6090
6107
|
/** Button shape: 'round-corner', 'rectangle', or 'pill' */
|
|
6091
6108
|
style: ButtonStyle | undefined;
|
|
6092
6109
|
/** Button color */
|
|
6093
|
-
color: Color | undefined;
|
|
6110
|
+
color: Color$1 | undefined;
|
|
6094
6111
|
/** `true` if button should be displayed */
|
|
6095
6112
|
visible: boolean;
|
|
6096
6113
|
}
|
|
6114
|
+
/**
|
|
6115
|
+
* Size style configuration for a single button size.
|
|
6116
|
+
*
|
|
6117
|
+
* @see {@link UseButtonStylesOptions}
|
|
6118
|
+
*/
|
|
6119
|
+
interface ButtonSizeStyles {
|
|
6120
|
+
fontSize: string;
|
|
6121
|
+
padding: string;
|
|
6122
|
+
}
|
|
6123
|
+
/**
|
|
6124
|
+
* Options for `useButtonStyles` helper composable.
|
|
6125
|
+
*
|
|
6126
|
+
* @see {@link ButtonDesignData}
|
|
6127
|
+
* @see {@link ButtonSizeStyles}
|
|
6128
|
+
*/
|
|
6129
|
+
interface UseButtonStylesOptions {
|
|
6130
|
+
/**
|
|
6131
|
+
* Custom size styles for each button size.
|
|
6132
|
+
* Override defaults for specific sizes or provide all three.
|
|
6133
|
+
*/
|
|
6134
|
+
sizes?: Partial<Record<ButtonSize, ButtonSizeStyles>>;
|
|
6135
|
+
}
|
|
6097
6136
|
|
|
6098
6137
|
type AccordionItem = z.infer<typeof AccordionDesignItemSchema>;
|
|
6099
6138
|
type ShowcaseAccordionItem = z.infer<typeof AccordionShowcaseItemSchema>;
|
|
@@ -6193,7 +6232,7 @@ interface TextDesignData$1 {
|
|
|
6193
6232
|
/** `true` if text should be italic */
|
|
6194
6233
|
italic: boolean | undefined;
|
|
6195
6234
|
/** Text color */
|
|
6196
|
-
color: Color | undefined;
|
|
6235
|
+
color: Color$1 | undefined;
|
|
6197
6236
|
/** `true` if element should be displayed */
|
|
6198
6237
|
visible: boolean;
|
|
6199
6238
|
}
|
|
@@ -6209,6 +6248,33 @@ interface TextareaDesignData$1 extends TextDesignData$1 {
|
|
|
6209
6248
|
/** Always 'pre-wrap' to preserve line breaks */
|
|
6210
6249
|
readonly whiteSpace: string;
|
|
6211
6250
|
}
|
|
6251
|
+
/**
|
|
6252
|
+
* Options for `createTextStyle` helper utility.
|
|
6253
|
+
*
|
|
6254
|
+
* @see {@link TextDesignData}
|
|
6255
|
+
*/
|
|
6256
|
+
interface TextStyleOptions {
|
|
6257
|
+
/**
|
|
6258
|
+
* Default font family if not specified in design
|
|
6259
|
+
* @default 'inherit'
|
|
6260
|
+
*/
|
|
6261
|
+
defaultFont?: string;
|
|
6262
|
+
/**
|
|
6263
|
+
* Default font size in pixels if not specified in design
|
|
6264
|
+
* @default 16
|
|
6265
|
+
*/
|
|
6266
|
+
defaultSize?: number;
|
|
6267
|
+
/**
|
|
6268
|
+
* Default color if not specified in design
|
|
6269
|
+
* @default '#000000'
|
|
6270
|
+
*/
|
|
6271
|
+
defaultColor?: string;
|
|
6272
|
+
/**
|
|
6273
|
+
* Default font weight if not bold
|
|
6274
|
+
* @default 'normal'
|
|
6275
|
+
*/
|
|
6276
|
+
defaultWeight?: string;
|
|
6277
|
+
}
|
|
6212
6278
|
|
|
6213
6279
|
/**
|
|
6214
6280
|
* Return type for `useToggleElementDesign` composable.
|
|
@@ -6267,7 +6333,7 @@ interface LogoDesignData$1 {
|
|
|
6267
6333
|
/** `true` if text should be italic */
|
|
6268
6334
|
italic: boolean | undefined;
|
|
6269
6335
|
/** Text/logo color */
|
|
6270
|
-
color: Color | undefined;
|
|
6336
|
+
color: Color$1 | undefined;
|
|
6271
6337
|
/** `true` if logo should be displayed */
|
|
6272
6338
|
visible: boolean | undefined;
|
|
6273
6339
|
/** Letter spacing value */
|
|
@@ -15952,6 +16018,17 @@ type TemplateConfiguration = z.infer<typeof TemplateConfigurationSchema>;
|
|
|
15952
16018
|
|
|
15953
16019
|
type TranslationSettings = Record<string, Record<string, string>>;
|
|
15954
16020
|
|
|
16021
|
+
/**
|
|
16022
|
+
* Return type for `useCurrentLanguage` composable.
|
|
16023
|
+
*/
|
|
16024
|
+
interface UseCurrentLanguageReturn {
|
|
16025
|
+
/**
|
|
16026
|
+
* Current language code (e.g., 'en', 'nl', 'fr').
|
|
16027
|
+
* Falls back to main language, then to 'en' if no language is selected.
|
|
16028
|
+
*/
|
|
16029
|
+
currentLanguage: ComputedRef<Language['code']>;
|
|
16030
|
+
}
|
|
16031
|
+
|
|
15955
16032
|
interface AppBaseContext {
|
|
15956
16033
|
readonly appName: string;
|
|
15957
16034
|
readonly blockName: string;
|
|
@@ -15986,72 +16063,6 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
15986
16063
|
};
|
|
15987
16064
|
};
|
|
15988
16065
|
|
|
15989
|
-
interface InstantsiteTilePromise {
|
|
15990
|
-
add(callback: (id: string) => void): void;
|
|
15991
|
-
}
|
|
15992
|
-
interface InstantsiteJSAPI {
|
|
15993
|
-
/**
|
|
15994
|
-
* Retrieves the current site ID.
|
|
15995
|
-
*
|
|
15996
|
-
* @returns {number} The site ID.
|
|
15997
|
-
*/
|
|
15998
|
-
getSiteId: () => number;
|
|
15999
|
-
/**
|
|
16000
|
-
* Retrieves the public token for a given app.
|
|
16001
|
-
*
|
|
16002
|
-
* @param {string} appId - The ID of the app.
|
|
16003
|
-
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
16004
|
-
*/
|
|
16005
|
-
getAppPublicToken: (appId: string) => string | undefined;
|
|
16006
|
-
/**
|
|
16007
|
-
* Retrieves the public configuration for a given app.
|
|
16008
|
-
*
|
|
16009
|
-
* @param {string} appId - The ID of the app.
|
|
16010
|
-
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
16011
|
-
*/
|
|
16012
|
-
getAppPublicConfig: (appId: string) => string | undefined;
|
|
16013
|
-
/**
|
|
16014
|
-
* An event that triggers when a tile is loaded.
|
|
16015
|
-
*
|
|
16016
|
-
* @type {InstantsiteTilePromise}
|
|
16017
|
-
*
|
|
16018
|
-
* @example
|
|
16019
|
-
* ```ts
|
|
16020
|
-
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
16021
|
-
*
|
|
16022
|
-
* tileLoadedPromise?.add((tileId) => {
|
|
16023
|
-
* console.log('Tile loaded:', tileId);
|
|
16024
|
-
* });
|
|
16025
|
-
* ```
|
|
16026
|
-
*/
|
|
16027
|
-
onTileLoaded: InstantsiteTilePromise;
|
|
16028
|
-
/**
|
|
16029
|
-
* An event that triggers when a tile is unloaded.
|
|
16030
|
-
*
|
|
16031
|
-
* @type {InstantsiteTilePromise}
|
|
16032
|
-
*
|
|
16033
|
-
* @example
|
|
16034
|
-
* ```ts
|
|
16035
|
-
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
16036
|
-
*
|
|
16037
|
-
* tileUnloadedPromise?.add((tileId) => {
|
|
16038
|
-
* console.log('Tile unloaded:', tileId);
|
|
16039
|
-
* });
|
|
16040
|
-
* ```
|
|
16041
|
-
*/
|
|
16042
|
-
onTileUnloaded: InstantsiteTilePromise;
|
|
16043
|
-
/**
|
|
16044
|
-
* Opens the search page with the specified keyword.
|
|
16045
|
-
*
|
|
16046
|
-
* @param {string | undefined} keyword - The keyword to search for.
|
|
16047
|
-
* @returns {void}
|
|
16048
|
-
*/
|
|
16049
|
-
openSearchPage: (keyword: string | undefined) => void;
|
|
16050
|
-
}
|
|
16051
|
-
|
|
16052
|
-
/** Composable for Instantsite JS API. Returns `window.instantsite` for platform interaction. */
|
|
16053
|
-
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
16054
|
-
|
|
16055
16066
|
declare function createLayoutApp<C, D>(component: Component): {
|
|
16056
16067
|
component: Component;
|
|
16057
16068
|
initState(app: App<Element>, content: C, design: D, defaults: Record<string, unknown>): void;
|
|
@@ -16059,11 +16070,11 @@ declare function createLayoutApp<C, D>(component: Component): {
|
|
|
16059
16070
|
};
|
|
16060
16071
|
|
|
16061
16072
|
interface GlobalColors {
|
|
16062
|
-
title?: Color;
|
|
16063
|
-
body?: Color;
|
|
16064
|
-
button?: Color;
|
|
16065
|
-
link?: Color;
|
|
16066
|
-
background?: Color;
|
|
16073
|
+
title?: Color$1;
|
|
16074
|
+
body?: Color$1;
|
|
16075
|
+
button?: Color$1;
|
|
16076
|
+
link?: Color$1;
|
|
16077
|
+
background?: Color$1;
|
|
16067
16078
|
}
|
|
16068
16079
|
interface GlobalFonts {
|
|
16069
16080
|
title: string;
|
|
@@ -16124,6 +16135,302 @@ declare function createVueServerApp<C, D>(appComponent: Component, extensions?:
|
|
|
16124
16135
|
};
|
|
16125
16136
|
};
|
|
16126
16137
|
|
|
16138
|
+
/**
|
|
16139
|
+
* Color Utilities
|
|
16140
|
+
*
|
|
16141
|
+
* Utilities for working with Crane Color objects and color calculations.
|
|
16142
|
+
* Includes hex extraction and contrast color calculation.
|
|
16143
|
+
*/
|
|
16144
|
+
/**
|
|
16145
|
+
* Safely extracts hex color from a Color object or string
|
|
16146
|
+
*
|
|
16147
|
+
* Handles multiple input types:
|
|
16148
|
+
* - Color object with hex property
|
|
16149
|
+
* - String (returned as-is)
|
|
16150
|
+
* - undefined/null (returns fallback)
|
|
16151
|
+
*
|
|
16152
|
+
* @param color - The color value (Color object, string, or undefined)
|
|
16153
|
+
* @param fallback - Fallback color if extraction fails
|
|
16154
|
+
* @returns Hex color string
|
|
16155
|
+
*
|
|
16156
|
+
* @example
|
|
16157
|
+
* ```typescript
|
|
16158
|
+
* // With Color object
|
|
16159
|
+
* const hex = getColorHex(titleDesign.color, '#FFFFFF')
|
|
16160
|
+
*
|
|
16161
|
+
* // With string
|
|
16162
|
+
* const hex = getColorHex('#FF0000', '#000000') // Returns '#FF0000'
|
|
16163
|
+
*
|
|
16164
|
+
* // With undefined
|
|
16165
|
+
* const hex = getColorHex(undefined, '#000000') // Returns '#000000'
|
|
16166
|
+
* ```
|
|
16167
|
+
*/
|
|
16168
|
+
declare function getColorHex(color: Color | string | undefined | null, fallback?: string): string;
|
|
16169
|
+
/**
|
|
16170
|
+
* Returns true if background color is dark enough to require light text.
|
|
16171
|
+
* Uses WCAG relative luminance formula for accurate contrast calculation.
|
|
16172
|
+
*
|
|
16173
|
+
* @param backgroundColor - Hex color string (e.g., '#FF0000')
|
|
16174
|
+
* @returns `true` for dark colors, `false` for light colors
|
|
16175
|
+
*/
|
|
16176
|
+
declare function isColorDark(backgroundColor: string): boolean;
|
|
16177
|
+
/**
|
|
16178
|
+
* Returns the best contrast text color for a given background.
|
|
16179
|
+
*
|
|
16180
|
+
* @param backgroundColorHex - Hex color string
|
|
16181
|
+
* @param darkTextColorHex - Color used on light backgrounds
|
|
16182
|
+
* @param lightTextColorHex - Color used on dark backgrounds
|
|
16183
|
+
*/
|
|
16184
|
+
declare function getContrastTextColor(backgroundColorHex: string, darkTextColorHex?: string, lightTextColorHex?: string): string;
|
|
16185
|
+
|
|
16186
|
+
/**
|
|
16187
|
+
* Text Style Utilities
|
|
16188
|
+
*
|
|
16189
|
+
* Utilities for creating CSS styles from Crane TextDesignData.
|
|
16190
|
+
*/
|
|
16191
|
+
|
|
16192
|
+
/**
|
|
16193
|
+
* Creates CSS properties from Crane TextDesignData
|
|
16194
|
+
*
|
|
16195
|
+
* Handles:
|
|
16196
|
+
* - Font family
|
|
16197
|
+
* - Font size (number to px conversion)
|
|
16198
|
+
* - Color (Color object to hex)
|
|
16199
|
+
* - Bold/Italic styles
|
|
16200
|
+
* - Visibility (returns display: none if not visible)
|
|
16201
|
+
*
|
|
16202
|
+
* @param design - TextDesignData from useTextElementDesign
|
|
16203
|
+
* @param options - Default values for missing design properties
|
|
16204
|
+
* @returns CSS properties object for Vue style binding
|
|
16205
|
+
*
|
|
16206
|
+
* @example
|
|
16207
|
+
* ```typescript
|
|
16208
|
+
* import { createTextStyle } from '@lightspeed/crane-api'
|
|
16209
|
+
* import { useTextElementDesign } from '@lightspeed/crane-api'
|
|
16210
|
+
*
|
|
16211
|
+
* const titleDesign = useTextElementDesign<Design>('title')
|
|
16212
|
+
* const titleStyle = computed(() => createTextStyle(titleDesign, {
|
|
16213
|
+
* defaultFont: 'Inter',
|
|
16214
|
+
* defaultSize: 24,
|
|
16215
|
+
* defaultColor: '#333333',
|
|
16216
|
+
* }))
|
|
16217
|
+
*
|
|
16218
|
+
* // In template:
|
|
16219
|
+
* // <h1 :style="titleStyle">{{ title }}</h1>
|
|
16220
|
+
* ```
|
|
16221
|
+
*/
|
|
16222
|
+
declare function createTextStyle(design: TextDesignData | undefined, options?: TextStyleOptions): CSSProperties;
|
|
16223
|
+
|
|
16224
|
+
/**
|
|
16225
|
+
* useBackgroundStyle Composable
|
|
16226
|
+
*
|
|
16227
|
+
* Creates reactive CSS background styles from Crane BackgroundDesignData.
|
|
16228
|
+
* Supports solid colors and gradients.
|
|
16229
|
+
*
|
|
16230
|
+
* @example
|
|
16231
|
+
* ```typescript
|
|
16232
|
+
* import { useBackgroundStyle } from '@lightspeed/crane-api'
|
|
16233
|
+
* import { useBackgroundElementDesign } from '@lightspeed/crane-api'
|
|
16234
|
+
*
|
|
16235
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16236
|
+
* const backgroundStyle = useBackgroundStyle(backgroundDesign)
|
|
16237
|
+
*
|
|
16238
|
+
* // In template:
|
|
16239
|
+
* // <div :style="backgroundStyle">...</div>
|
|
16240
|
+
* ```
|
|
16241
|
+
*/
|
|
16242
|
+
|
|
16243
|
+
/**
|
|
16244
|
+
* Extracts background styles from BackgroundDesignData.
|
|
16245
|
+
*
|
|
16246
|
+
* Returns a style object suitable for CSS `:style` bindings.
|
|
16247
|
+
*
|
|
16248
|
+
* **Gradient fallback behaviour:**
|
|
16249
|
+
* When `background.type === 'gradient'`, each of `fromColor` and `toColor` is resolved
|
|
16250
|
+
* independently via `getColorHex`. If a color is missing/undefined and `fallbackColor` is
|
|
16251
|
+
* an empty string (the default), `getColorHex` returns `''` and the whole style object is
|
|
16252
|
+
* returned as `{}`. If `fallbackColor` is a non-empty string, the missing color is replaced
|
|
16253
|
+
* by that fallback, which may result in a gradient where both stops are the same colour
|
|
16254
|
+
* (e.g. `linear-gradient(to right, #FFFFFF, #FFFFFF)`). This is valid CSS and visually
|
|
16255
|
+
* equivalent to a solid colour, but it is worth being aware of when debugging gradient output.
|
|
16256
|
+
*
|
|
16257
|
+
* @param backgroundDesign - BackgroundDesignData from useBackgroundElementDesign
|
|
16258
|
+
* @param options - Configuration options
|
|
16259
|
+
* @returns CSS background style object
|
|
16260
|
+
*
|
|
16261
|
+
* @example
|
|
16262
|
+
* ```typescript
|
|
16263
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16264
|
+
* const bgStyle = getBackgroundStyle(backgroundDesign, { fallbackColor: '#FFFFFF' })
|
|
16265
|
+
* // Returns: { backgroundColor: '#FF0000' } or { backgroundImage: 'linear-gradient(...)' }
|
|
16266
|
+
* // If one gradient colour is missing and fallbackColor is '#FFFFFF':
|
|
16267
|
+
* // Returns: { backgroundImage: 'linear-gradient(to right, #FFFFFF, #FFFFFF)' }
|
|
16268
|
+
* ```
|
|
16269
|
+
*/
|
|
16270
|
+
declare function getBackgroundStyle(backgroundDesign: BackgroundDesignData | undefined, options?: BackgroundStyleOptions): StyleValue;
|
|
16271
|
+
/**
|
|
16272
|
+
* Creates reactive background styles from Crane BackgroundDesignData
|
|
16273
|
+
*
|
|
16274
|
+
* Supports solid colors and gradients. Returns a computed style object
|
|
16275
|
+
* that can be bound directly to :style attribute.
|
|
16276
|
+
*
|
|
16277
|
+
* @param backgroundDesign - Reactive BackgroundDesignData from useBackgroundElementDesign.
|
|
16278
|
+
* Must be a reactive object (not a plain snapshot) for changes to be tracked.
|
|
16279
|
+
* @param options - Configuration options
|
|
16280
|
+
* @returns Computed style object with backgroundColor or backgroundImage
|
|
16281
|
+
*
|
|
16282
|
+
* @example
|
|
16283
|
+
* ```typescript
|
|
16284
|
+
* const backgroundDesign = useBackgroundElementDesign<Design>('background')
|
|
16285
|
+
* const backgroundStyle = useBackgroundStyle(backgroundDesign)
|
|
16286
|
+
*
|
|
16287
|
+
* // In template:
|
|
16288
|
+
* // <div :style="backgroundStyle">...</div>
|
|
16289
|
+
* ```
|
|
16290
|
+
*/
|
|
16291
|
+
declare function useBackgroundStyle(backgroundDesign: Reactive<BackgroundDesignData> | BackgroundDesignData | undefined, options?: BackgroundStyleOptions): ComputedRef<StyleValue>;
|
|
16292
|
+
|
|
16293
|
+
/**
|
|
16294
|
+
* useButtonStyles Composable
|
|
16295
|
+
*
|
|
16296
|
+
* Generates dynamic button styles based on Crane's ButtonDesignData.
|
|
16297
|
+
* Handles size, appearance, shape, and automatic contrast text color.
|
|
16298
|
+
*
|
|
16299
|
+
* @example
|
|
16300
|
+
* ```typescript
|
|
16301
|
+
* import { useButtonStyles } from '@lightspeed/crane-api'
|
|
16302
|
+
* import { useButtonElementDesign } from '@lightspeed/crane-api'
|
|
16303
|
+
*
|
|
16304
|
+
* const ctaButtonDesign = useButtonElementDesign<Design>('cta_button')
|
|
16305
|
+
* const ctaButtonStyle = useButtonStyles(ctaButtonDesign)
|
|
16306
|
+
*
|
|
16307
|
+
* // In template:
|
|
16308
|
+
* // <button :style="ctaButtonStyle">Click me</button>
|
|
16309
|
+
* ```
|
|
16310
|
+
*/
|
|
16311
|
+
|
|
16312
|
+
/**
|
|
16313
|
+
* Generates dynamic button styles based on Crane's button design data
|
|
16314
|
+
*
|
|
16315
|
+
* Handles:
|
|
16316
|
+
* - Size: 'small', 'medium', 'large' (configurable via options)
|
|
16317
|
+
* - Appearance: 'solid-button', 'outline-button', 'text-link'
|
|
16318
|
+
* - Style (shape): 'rectangle', 'round-corner', 'pill'
|
|
16319
|
+
*
|
|
16320
|
+
* @param buttonDesign - Reactive button design data from useButtonElementDesign.
|
|
16321
|
+
* Must be a reactive object (not a plain snapshot) for changes to be tracked.
|
|
16322
|
+
* @param options - Optional configuration (e.g., custom size styles)
|
|
16323
|
+
* @returns Computed style object for inline application
|
|
16324
|
+
*/
|
|
16325
|
+
declare function useButtonStyles(buttonDesign: Reactive<ButtonDesignData> | Partial<ButtonDesignData> | undefined, options?: UseButtonStylesOptions): ComputedRef<Record<string, string>>;
|
|
16326
|
+
|
|
16327
|
+
/**
|
|
16328
|
+
* useCurrentLanguage Composable
|
|
16329
|
+
*
|
|
16330
|
+
* Provides access to the current language from site context.
|
|
16331
|
+
* Useful for i18n, API calls with language parameter, and conditional rendering.
|
|
16332
|
+
*
|
|
16333
|
+
* @example
|
|
16334
|
+
* ```typescript
|
|
16335
|
+
* import { useCurrentLanguage } from '@lightspeed/crane-api'
|
|
16336
|
+
*
|
|
16337
|
+
* const { currentLanguage } = useCurrentLanguage()
|
|
16338
|
+
*
|
|
16339
|
+
* // Use in API calls
|
|
16340
|
+
* fetchProducts({ lang: currentLanguage.value })
|
|
16341
|
+
*
|
|
16342
|
+
* // Use in computed
|
|
16343
|
+
* const greeting = computed(() =>
|
|
16344
|
+
* currentLanguage.value === 'fr' ? 'Bonjour' : 'Hello'
|
|
16345
|
+
* )
|
|
16346
|
+
* ```
|
|
16347
|
+
*/
|
|
16348
|
+
|
|
16349
|
+
/**
|
|
16350
|
+
* Get current selected language code from site languages.
|
|
16351
|
+
*
|
|
16352
|
+
* Fallback chain: selected language → main language → 'en'.
|
|
16353
|
+
*
|
|
16354
|
+
* @param languages - Array of available languages from site content (global Language type)
|
|
16355
|
+
* @returns Current language code (e.g., 'en', 'nl', 'fr')
|
|
16356
|
+
*/
|
|
16357
|
+
declare function getCurrentLanguageCode(languages: Language[] | undefined): Language['code'];
|
|
16358
|
+
/**
|
|
16359
|
+
* Composable to get current language from site context.
|
|
16360
|
+
*
|
|
16361
|
+
* Uses the global Language type from types.d.ts.
|
|
16362
|
+
* Fallback chain: selected language → main language → 'en'.
|
|
16363
|
+
*
|
|
16364
|
+
* @returns Object containing currentLanguage computed ref
|
|
16365
|
+
*/
|
|
16366
|
+
declare function useCurrentLanguage(): UseCurrentLanguageReturn;
|
|
16367
|
+
|
|
16368
|
+
interface InstantsiteTilePromise {
|
|
16369
|
+
add(callback: (id: string) => void): void;
|
|
16370
|
+
}
|
|
16371
|
+
interface InstantsiteJSAPI {
|
|
16372
|
+
/**
|
|
16373
|
+
* Retrieves the current site ID.
|
|
16374
|
+
*
|
|
16375
|
+
* @returns {number} The site ID.
|
|
16376
|
+
*/
|
|
16377
|
+
getSiteId: () => number;
|
|
16378
|
+
/**
|
|
16379
|
+
* Retrieves the public token for a given app.
|
|
16380
|
+
*
|
|
16381
|
+
* @param {string} appId - The ID of the app.
|
|
16382
|
+
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
16383
|
+
*/
|
|
16384
|
+
getAppPublicToken: (appId: string) => string | undefined;
|
|
16385
|
+
/**
|
|
16386
|
+
* Retrieves the public configuration for a given app.
|
|
16387
|
+
*
|
|
16388
|
+
* @param {string} appId - The ID of the app.
|
|
16389
|
+
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
16390
|
+
*/
|
|
16391
|
+
getAppPublicConfig: (appId: string) => string | undefined;
|
|
16392
|
+
/**
|
|
16393
|
+
* An event that triggers when a tile is loaded.
|
|
16394
|
+
*
|
|
16395
|
+
* @type {InstantsiteTilePromise}
|
|
16396
|
+
*
|
|
16397
|
+
* @example
|
|
16398
|
+
* ```ts
|
|
16399
|
+
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
16400
|
+
*
|
|
16401
|
+
* tileLoadedPromise?.add((tileId) => {
|
|
16402
|
+
* console.log('Tile loaded:', tileId);
|
|
16403
|
+
* });
|
|
16404
|
+
* ```
|
|
16405
|
+
*/
|
|
16406
|
+
onTileLoaded: InstantsiteTilePromise;
|
|
16407
|
+
/**
|
|
16408
|
+
* An event that triggers when a tile is unloaded.
|
|
16409
|
+
*
|
|
16410
|
+
* @type {InstantsiteTilePromise}
|
|
16411
|
+
*
|
|
16412
|
+
* @example
|
|
16413
|
+
* ```ts
|
|
16414
|
+
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
16415
|
+
*
|
|
16416
|
+
* tileUnloadedPromise?.add((tileId) => {
|
|
16417
|
+
* console.log('Tile unloaded:', tileId);
|
|
16418
|
+
* });
|
|
16419
|
+
* ```
|
|
16420
|
+
*/
|
|
16421
|
+
onTileUnloaded: InstantsiteTilePromise;
|
|
16422
|
+
/**
|
|
16423
|
+
* Opens the search page with the specified keyword.
|
|
16424
|
+
*
|
|
16425
|
+
* @param {string | undefined} keyword - The keyword to search for.
|
|
16426
|
+
* @returns {void}
|
|
16427
|
+
*/
|
|
16428
|
+
openSearchPage: (keyword: string | undefined) => void;
|
|
16429
|
+
}
|
|
16430
|
+
|
|
16431
|
+
/** Composable for Instantsite JS API. Returns `window.instantsite` for platform interaction. */
|
|
16432
|
+
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
16433
|
+
|
|
16127
16434
|
/**
|
|
16128
16435
|
* Composable for accessing BUTTON content with action link.
|
|
16129
16436
|
*
|
|
@@ -16695,7 +17002,7 @@ declare function useBackgroundElementDesign<DESIGN>(elementName: keyof DESIGN):
|
|
|
16695
17002
|
* </button>
|
|
16696
17003
|
* ```
|
|
16697
17004
|
*/
|
|
16698
|
-
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData>;
|
|
17005
|
+
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData$1>;
|
|
16699
17006
|
|
|
16700
17007
|
/**
|
|
16701
17008
|
* Composable for accessing IMAGE design settings.
|
|
@@ -17765,5 +18072,5 @@ declare const translation: {
|
|
|
17765
18072
|
readonly init: (config: TranslationSettings) => TranslationSettings;
|
|
17766
18073
|
};
|
|
17767
18074
|
|
|
17768
|
-
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 };
|
|
17769
|
-
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 };
|
|
18075
|
+
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 };
|
|
18076
|
+
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 };
|