@lightspeed/crane-api 2.3.2 → 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 +6 -0
- package/README.md +81 -5
- package/dist/index.d.mts +394 -84
- package/dist/index.d.ts +394 -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;
|
|
@@ -5988,9 +5988,11 @@ interface TextDesignEditorDefaultsTransformed {
|
|
|
5988
5988
|
readonly size?: TextSize | string;
|
|
5989
5989
|
readonly bold?: boolean;
|
|
5990
5990
|
readonly italic?: boolean;
|
|
5991
|
+
readonly visible?: boolean;
|
|
5991
5992
|
}
|
|
5992
5993
|
interface ImageDesignEditorDefaultsTransformed {
|
|
5993
5994
|
readonly overlay: OverlayTransformed;
|
|
5995
|
+
readonly visible?: boolean;
|
|
5994
5996
|
}
|
|
5995
5997
|
interface ColorPickerDesignEditorDefaultsTransformed {
|
|
5996
5998
|
readonly color?: InternalColor;
|
|
@@ -6015,6 +6017,7 @@ interface LogoDesignEditorDefaultsTransformed {
|
|
|
6015
6017
|
readonly italic?: boolean;
|
|
6016
6018
|
readonly spacing?: number;
|
|
6017
6019
|
readonly capitalization?: CapitalizationType;
|
|
6020
|
+
readonly visible?: boolean;
|
|
6018
6021
|
}
|
|
6019
6022
|
interface SelectboxDesignEditorDefaultsTransformed {
|
|
6020
6023
|
readonly value?: string;
|
|
@@ -6060,6 +6063,23 @@ interface BackgroundTransformed {
|
|
|
6060
6063
|
/** Gradient color configuration */
|
|
6061
6064
|
gradient: GradientColorTransformed | undefined;
|
|
6062
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
|
+
}
|
|
6063
6083
|
|
|
6064
6084
|
/** Button fill style */
|
|
6065
6085
|
type ButtonAppearance = 'solid-button' | 'outline-button' | 'text-link';
|
|
@@ -6077,7 +6097,7 @@ type ButtonStyle = 'round-corner' | 'rectangle' | 'pill';
|
|
|
6077
6097
|
* @see {@link ButtonSize}
|
|
6078
6098
|
* @see {@link ButtonStyle}
|
|
6079
6099
|
*/
|
|
6080
|
-
interface ButtonDesignData {
|
|
6100
|
+
interface ButtonDesignData$1 {
|
|
6081
6101
|
/** Button fill style: 'solid-button', 'outline-button', or 'text-link' */
|
|
6082
6102
|
appearance: ButtonAppearance | undefined;
|
|
6083
6103
|
/** Font family name (resolved from global reference) */
|
|
@@ -6087,10 +6107,32 @@ interface ButtonDesignData {
|
|
|
6087
6107
|
/** Button shape: 'round-corner', 'rectangle', or 'pill' */
|
|
6088
6108
|
style: ButtonStyle | undefined;
|
|
6089
6109
|
/** Button color */
|
|
6090
|
-
color: Color | undefined;
|
|
6110
|
+
color: Color$1 | undefined;
|
|
6091
6111
|
/** `true` if button should be displayed */
|
|
6092
6112
|
visible: boolean;
|
|
6093
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
|
+
}
|
|
6094
6136
|
|
|
6095
6137
|
type AccordionItem = z.infer<typeof AccordionDesignItemSchema>;
|
|
6096
6138
|
type ShowcaseAccordionItem = z.infer<typeof AccordionShowcaseItemSchema>;
|
|
@@ -6190,7 +6232,7 @@ interface TextDesignData$1 {
|
|
|
6190
6232
|
/** `true` if text should be italic */
|
|
6191
6233
|
italic: boolean | undefined;
|
|
6192
6234
|
/** Text color */
|
|
6193
|
-
color: Color | undefined;
|
|
6235
|
+
color: Color$1 | undefined;
|
|
6194
6236
|
/** `true` if element should be displayed */
|
|
6195
6237
|
visible: boolean;
|
|
6196
6238
|
}
|
|
@@ -6206,6 +6248,33 @@ interface TextareaDesignData$1 extends TextDesignData$1 {
|
|
|
6206
6248
|
/** Always 'pre-wrap' to preserve line breaks */
|
|
6207
6249
|
readonly whiteSpace: string;
|
|
6208
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
|
+
}
|
|
6209
6278
|
|
|
6210
6279
|
/**
|
|
6211
6280
|
* Return type for `useToggleElementDesign` composable.
|
|
@@ -6264,7 +6333,7 @@ interface LogoDesignData$1 {
|
|
|
6264
6333
|
/** `true` if text should be italic */
|
|
6265
6334
|
italic: boolean | undefined;
|
|
6266
6335
|
/** Text/logo color */
|
|
6267
|
-
color: Color | undefined;
|
|
6336
|
+
color: Color$1 | undefined;
|
|
6268
6337
|
/** `true` if logo should be displayed */
|
|
6269
6338
|
visible: boolean | undefined;
|
|
6270
6339
|
/** Letter spacing value */
|
|
@@ -15949,6 +16018,17 @@ type TemplateConfiguration = z.infer<typeof TemplateConfigurationSchema>;
|
|
|
15949
16018
|
|
|
15950
16019
|
type TranslationSettings = Record<string, Record<string, string>>;
|
|
15951
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
|
+
|
|
15952
16032
|
interface AppBaseContext {
|
|
15953
16033
|
readonly appName: string;
|
|
15954
16034
|
readonly blockName: string;
|
|
@@ -15983,72 +16063,6 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
15983
16063
|
};
|
|
15984
16064
|
};
|
|
15985
16065
|
|
|
15986
|
-
interface InstantsiteTilePromise {
|
|
15987
|
-
add(callback: (id: string) => void): void;
|
|
15988
|
-
}
|
|
15989
|
-
interface InstantsiteJSAPI {
|
|
15990
|
-
/**
|
|
15991
|
-
* Retrieves the current site ID.
|
|
15992
|
-
*
|
|
15993
|
-
* @returns {number} The site ID.
|
|
15994
|
-
*/
|
|
15995
|
-
getSiteId: () => number;
|
|
15996
|
-
/**
|
|
15997
|
-
* Retrieves the public token for a given app.
|
|
15998
|
-
*
|
|
15999
|
-
* @param {string} appId - The ID of the app.
|
|
16000
|
-
* @returns {string | undefined} The app's public token, or `undefined` if not found.
|
|
16001
|
-
*/
|
|
16002
|
-
getAppPublicToken: (appId: string) => string | undefined;
|
|
16003
|
-
/**
|
|
16004
|
-
* Retrieves the public configuration for a given app.
|
|
16005
|
-
*
|
|
16006
|
-
* @param {string} appId - The ID of the app.
|
|
16007
|
-
* @returns {string | undefined} The app's public configuration, or `undefined` if not found.
|
|
16008
|
-
*/
|
|
16009
|
-
getAppPublicConfig: (appId: string) => string | undefined;
|
|
16010
|
-
/**
|
|
16011
|
-
* An event that triggers when a tile is loaded.
|
|
16012
|
-
*
|
|
16013
|
-
* @type {InstantsiteTilePromise}
|
|
16014
|
-
*
|
|
16015
|
-
* @example
|
|
16016
|
-
* ```ts
|
|
16017
|
-
* const tileLoadedPromise = instantsiteJsApi?.onTileLoaded;
|
|
16018
|
-
*
|
|
16019
|
-
* tileLoadedPromise?.add((tileId) => {
|
|
16020
|
-
* console.log('Tile loaded:', tileId);
|
|
16021
|
-
* });
|
|
16022
|
-
* ```
|
|
16023
|
-
*/
|
|
16024
|
-
onTileLoaded: InstantsiteTilePromise;
|
|
16025
|
-
/**
|
|
16026
|
-
* An event that triggers when a tile is unloaded.
|
|
16027
|
-
*
|
|
16028
|
-
* @type {InstantsiteTilePromise}
|
|
16029
|
-
*
|
|
16030
|
-
* @example
|
|
16031
|
-
* ```ts
|
|
16032
|
-
* const tileUnloadedPromise = instantsiteJsApi?.onTileUnloaded;
|
|
16033
|
-
*
|
|
16034
|
-
* tileUnloadedPromise?.add((tileId) => {
|
|
16035
|
-
* console.log('Tile unloaded:', tileId);
|
|
16036
|
-
* });
|
|
16037
|
-
* ```
|
|
16038
|
-
*/
|
|
16039
|
-
onTileUnloaded: InstantsiteTilePromise;
|
|
16040
|
-
/**
|
|
16041
|
-
* Opens the search page with the specified keyword.
|
|
16042
|
-
*
|
|
16043
|
-
* @param {string | undefined} keyword - The keyword to search for.
|
|
16044
|
-
* @returns {void}
|
|
16045
|
-
*/
|
|
16046
|
-
openSearchPage: (keyword: string | undefined) => void;
|
|
16047
|
-
}
|
|
16048
|
-
|
|
16049
|
-
/** Composable for Instantsite JS API. Returns `window.instantsite` for platform interaction. */
|
|
16050
|
-
declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
|
|
16051
|
-
|
|
16052
16066
|
declare function createLayoutApp<C, D>(component: Component): {
|
|
16053
16067
|
component: Component;
|
|
16054
16068
|
initState(app: App<Element>, content: C, design: D, defaults: Record<string, unknown>): void;
|
|
@@ -16056,11 +16070,11 @@ declare function createLayoutApp<C, D>(component: Component): {
|
|
|
16056
16070
|
};
|
|
16057
16071
|
|
|
16058
16072
|
interface GlobalColors {
|
|
16059
|
-
title?: Color;
|
|
16060
|
-
body?: Color;
|
|
16061
|
-
button?: Color;
|
|
16062
|
-
link?: Color;
|
|
16063
|
-
background?: Color;
|
|
16073
|
+
title?: Color$1;
|
|
16074
|
+
body?: Color$1;
|
|
16075
|
+
button?: Color$1;
|
|
16076
|
+
link?: Color$1;
|
|
16077
|
+
background?: Color$1;
|
|
16064
16078
|
}
|
|
16065
16079
|
interface GlobalFonts {
|
|
16066
16080
|
title: string;
|
|
@@ -16121,6 +16135,302 @@ declare function createVueServerApp<C, D>(appComponent: Component, extensions?:
|
|
|
16121
16135
|
};
|
|
16122
16136
|
};
|
|
16123
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
|
+
|
|
16124
16434
|
/**
|
|
16125
16435
|
* Composable for accessing BUTTON content with action link.
|
|
16126
16436
|
*
|
|
@@ -16692,7 +17002,7 @@ declare function useBackgroundElementDesign<DESIGN>(elementName: keyof DESIGN):
|
|
|
16692
17002
|
* </button>
|
|
16693
17003
|
* ```
|
|
16694
17004
|
*/
|
|
16695
|
-
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData>;
|
|
17005
|
+
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): Reactive<ButtonDesignData$1>;
|
|
16696
17006
|
|
|
16697
17007
|
/**
|
|
16698
17008
|
* Composable for accessing IMAGE design settings.
|
|
@@ -17762,5 +18072,5 @@ declare const translation: {
|
|
|
17762
18072
|
readonly init: (config: TranslationSettings) => TranslationSettings;
|
|
17763
18073
|
};
|
|
17764
18074
|
|
|
17765
|
-
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 };
|
|
17766
|
-
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 };
|