@rulecms/widget-svelte 0.3.0 → 0.5.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/dist/index.cjs +13 -10
- package/dist/index.d.ts +157 -1
- package/dist/index.js +2505 -2245
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,45 @@ export declare const buildCloudinaryBackgroundUrl: ({ publicId, cloudName, trans
|
|
|
124
124
|
width?: number;
|
|
125
125
|
}) => string;
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* One layer's box: out of flow so it cannot inflate the stack it is measuring
|
|
129
|
+
* itself against, stretched to that stack's padding box, and sized in border-box
|
|
130
|
+
* so a layer's own border or padding stays inside the base's footprint.
|
|
131
|
+
*/
|
|
132
|
+
export declare function buildOverlayLayerBoxStyles({ zIndex, pointerEvents, }: {
|
|
133
|
+
zIndex: number;
|
|
134
|
+
pointerEvents?: string;
|
|
135
|
+
}): {
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The stack wrapper: containing block for every layer, and the element whose
|
|
141
|
+
* used width and height the layers resolve their `100%` against.
|
|
142
|
+
*
|
|
143
|
+
* It takes its size from the base in normal flow, so it carries no size of its
|
|
144
|
+
* own beyond the height default it adopts from the vertical container — the page
|
|
145
|
+
* root is full height, a collection is content height. `baseDeclaresOwnHeight`
|
|
146
|
+
* drops even that, because a base pinned to an authored height has to be the
|
|
147
|
+
* thing the layers match.
|
|
148
|
+
*
|
|
149
|
+
* `isolation: isolate` keeps the layer numbers a private matter between the base
|
|
150
|
+
* and its layers. Without it they would be sorted against the host page, where
|
|
151
|
+
* beating a sticky header was never the point.
|
|
152
|
+
*
|
|
153
|
+
* A non-zero base z-index lands here too, on the widget's outermost box, which
|
|
154
|
+
* is the one the host page sorts. Nothing is emitted for the default 0: an
|
|
155
|
+
* unpositioned stack already paints under its own layers, and staying out of the
|
|
156
|
+
* host's stacking order is the better default.
|
|
157
|
+
*/
|
|
158
|
+
export declare function buildOverlayStackStyles({ isWithinCollection, baseDeclaresOwnHeight, baseZIndex, }: {
|
|
159
|
+
isWithinCollection: boolean;
|
|
160
|
+
baseDeclaresOwnHeight: boolean;
|
|
161
|
+
baseZIndex: number;
|
|
162
|
+
}): {
|
|
163
|
+
[key: string]: any;
|
|
164
|
+
};
|
|
165
|
+
|
|
127
166
|
/**
|
|
128
167
|
* Builds the widget fetch URL. Development tokens (`dev.…`) hit the uncached
|
|
129
168
|
* draft endpoint with `widgetKey`; everything else uses the published API.
|
|
@@ -339,6 +378,9 @@ export declare type CssVariableValue = {
|
|
|
339
378
|
cssVariable: CssVariableName;
|
|
340
379
|
};
|
|
341
380
|
|
|
381
|
+
/** Base z-index when the author set none. */
|
|
382
|
+
export declare const DEFAULT_BASE_Z_INDEX = 0;
|
|
383
|
+
|
|
342
384
|
/** The cloud that hosts both team uploads and the shared RuleCMS library. */
|
|
343
385
|
export declare const DEFAULT_CLOUDINARY_CLOUD_NAME = "rulecms";
|
|
344
386
|
|
|
@@ -776,6 +818,16 @@ export declare const getNameFromWidgetKey: (widgetKey: string) => {
|
|
|
776
818
|
errorMessage?: string;
|
|
777
819
|
};
|
|
778
820
|
|
|
821
|
+
/**
|
|
822
|
+
* Where a layer sits above a base at `baseZIndex`: the first layer takes
|
|
823
|
+
* `baseZIndex + 1`, the second `baseZIndex + 2`, and so on.
|
|
824
|
+
*
|
|
825
|
+
* Derived from the position in the array, never from the layer itself, so a
|
|
826
|
+
* layer that renders nothing — hidden at this width, or with no rows — leaves
|
|
827
|
+
* its number unused rather than pulling the layers above it down.
|
|
828
|
+
*/
|
|
829
|
+
export declare function getOverlayLayerZIndex(baseZIndex: number, layerIndex: number): number;
|
|
830
|
+
|
|
779
831
|
export declare interface GetRuleCMSWidgetResponse {
|
|
780
832
|
success: boolean;
|
|
781
833
|
data: {
|
|
@@ -784,6 +836,11 @@ export declare interface GetRuleCMSWidgetResponse {
|
|
|
784
836
|
[key: string]: ChildCollection;
|
|
785
837
|
};
|
|
786
838
|
libraries?: ConfigLibrariesMap;
|
|
839
|
+
/**
|
|
840
|
+
* Project CSS variable catalog joined at GET time. Omitted when empty or
|
|
841
|
+
* when emission is off.
|
|
842
|
+
*/
|
|
843
|
+
cssVariables?: ProjectCssVariableDefinitions;
|
|
787
844
|
};
|
|
788
845
|
}
|
|
789
846
|
|
|
@@ -831,6 +888,9 @@ export declare const hasInvalidCssVariable: (leaf: unknown) => boolean;
|
|
|
831
888
|
|
|
832
889
|
export declare const hasItems: (items: Items | undefined) => boolean | undefined;
|
|
833
890
|
|
|
891
|
+
/** True when this Items asks for at least one layer over its rows. */
|
|
892
|
+
export declare function hasOverlayLayers(items: Items | undefined): boolean;
|
|
893
|
+
|
|
834
894
|
export declare const HIDE_WIDGET_ATTRIBUTE_NAME = "hide-component-3-resolutions";
|
|
835
895
|
|
|
836
896
|
/**
|
|
@@ -868,6 +928,16 @@ export declare const isLineHeightValue: (value: unknown) => value is LineHeightV
|
|
|
868
928
|
|
|
869
929
|
export declare const isOpacityValue: (value: unknown) => value is OpacityValue;
|
|
870
930
|
|
|
931
|
+
/**
|
|
932
|
+
* True when a layer has nothing to put on screen at this width, so its box is
|
|
933
|
+
* not worth emitting. Its z-index slot still goes unclaimed — see
|
|
934
|
+
* getOverlayLayerZIndex.
|
|
935
|
+
*/
|
|
936
|
+
export declare function isOverlayLayerEmptyForDevice({ layer, deviceDisplayType, }: {
|
|
937
|
+
layer: Items;
|
|
938
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
939
|
+
}): boolean;
|
|
940
|
+
|
|
871
941
|
export declare function isRowHiddenForDevice({ row, deviceDisplayType, }: {
|
|
872
942
|
row: DisplayItemRow;
|
|
873
943
|
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
@@ -894,6 +964,12 @@ export declare type Items = {
|
|
|
894
964
|
containerAttributes?: {
|
|
895
965
|
[key: string]: any;
|
|
896
966
|
};
|
|
967
|
+
/**
|
|
968
|
+
* Layers drawn over the rows above, each covering exactly the box the rows
|
|
969
|
+
* occupy. Absent for the overwhelming majority of configs. Honoured in
|
|
970
|
+
* preview and every published render; the composer canvas ignores it.
|
|
971
|
+
*/
|
|
972
|
+
overlayLayers?: WidgetOverlayLayers;
|
|
897
973
|
};
|
|
898
974
|
|
|
899
975
|
/** Column flex layout — matches row Horizontal Alignment options. */
|
|
@@ -1054,9 +1130,20 @@ export declare const PageViewTypes: {
|
|
|
1054
1130
|
|
|
1055
1131
|
export declare const phoneModeWidth = "500px";
|
|
1056
1132
|
|
|
1133
|
+
export declare const POINTER_EVENTS_ATTRIBUTE_NAME = "pointer-events-3-resolutions";
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Whether an element takes pointer input. `none` passes clicks through to
|
|
1137
|
+
* whatever sits behind, which is what an overlay layer covering the base needs;
|
|
1138
|
+
* a descendant can take input back with `auto`, since the property inherits.
|
|
1139
|
+
*/
|
|
1140
|
+
export declare const pointerEventsAllowlist: readonly ["auto", "none"];
|
|
1141
|
+
|
|
1057
1142
|
/** Transform raw widget API data into render-ready displayItemList + collections. */
|
|
1058
1143
|
export declare function prepareRuleCMSWidgetData(raw: RuleCMSWidgetRawData): RuleCMSWidgetData;
|
|
1059
1144
|
|
|
1145
|
+
declare type ProjectCssVariableDefinitions = Record<string, string>;
|
|
1146
|
+
|
|
1060
1147
|
/**
|
|
1061
1148
|
* Character used to join environmentId and resource key when generating published keys
|
|
1062
1149
|
*/
|
|
@@ -1081,6 +1168,17 @@ export declare interface RenderComponentPlugins {
|
|
|
1081
1168
|
sourceComponents?: SourceComponentsPlugin;
|
|
1082
1169
|
}
|
|
1083
1170
|
|
|
1171
|
+
/**
|
|
1172
|
+
* The base's z-index for this device, or 0 when unset or unusable. Accepts the
|
|
1173
|
+
* number and the numeric string, since hand-authored JSON produces both.
|
|
1174
|
+
*/
|
|
1175
|
+
export declare function resolveBaseZIndex({ containerAttributes, deviceDisplayType, }: {
|
|
1176
|
+
containerAttributes: {
|
|
1177
|
+
[key: string]: any;
|
|
1178
|
+
} | undefined;
|
|
1179
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
1180
|
+
}): number;
|
|
1181
|
+
|
|
1084
1182
|
/**
|
|
1085
1183
|
* Maps a component's (libraryId, type) pair to its key in the composed
|
|
1086
1184
|
* components map. The default library keeps bare (unnamespaced) keys so
|
|
@@ -1099,6 +1197,23 @@ export declare interface ResolveLibrariesParams {
|
|
|
1099
1197
|
|
|
1100
1198
|
export declare type ResolveNoContainer = (context: NoContainerResolverContext) => boolean;
|
|
1101
1199
|
|
|
1200
|
+
/**
|
|
1201
|
+
* A layer's `pointer-events` for this device, lifted from the layer's own
|
|
1202
|
+
* container settings. `undefined` leaves the property off the box entirely.
|
|
1203
|
+
*
|
|
1204
|
+
* The layer box covers the whole base, so this has to land there rather than on
|
|
1205
|
+
* the container nested inside it: `none` on an inner element still leaves the
|
|
1206
|
+
* box itself intercepting every click aimed at the base underneath. Because the
|
|
1207
|
+
* property inherits, one `none` on the layer also frees the layer's own content,
|
|
1208
|
+
* which can take input back with `auto` on the column that needs it.
|
|
1209
|
+
*/
|
|
1210
|
+
export declare function resolveOverlayLayerPointerEvents({ containerAttributes, deviceDisplayType, }: {
|
|
1211
|
+
containerAttributes: {
|
|
1212
|
+
[key: string]: any;
|
|
1213
|
+
} | undefined;
|
|
1214
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
1215
|
+
}): string | undefined;
|
|
1216
|
+
|
|
1102
1217
|
export declare type ResolveRendersOwnElement = (context: NoContainerResolverContext) => boolean;
|
|
1103
1218
|
|
|
1104
1219
|
/**
|
|
@@ -1194,6 +1309,11 @@ export declare interface RuleCMSWidgetData {
|
|
|
1194
1309
|
[key: string]: WidgetCollection;
|
|
1195
1310
|
};
|
|
1196
1311
|
libraries?: ConfigLibrariesMap;
|
|
1312
|
+
/**
|
|
1313
|
+
* Project CSS variable catalog joined onto the widget GET. Optional; omit
|
|
1314
|
+
* or `{}` when the project has none. Not stored on itemList.
|
|
1315
|
+
*/
|
|
1316
|
+
cssVariables?: ProjectCssVariableDefinitions;
|
|
1197
1317
|
}
|
|
1198
1318
|
|
|
1199
1319
|
export declare interface RuleCMSWidgetRawData {
|
|
@@ -1202,6 +1322,7 @@ export declare interface RuleCMSWidgetRawData {
|
|
|
1202
1322
|
[key: string]: ChildCollection;
|
|
1203
1323
|
};
|
|
1204
1324
|
libraries?: ConfigLibrariesMap;
|
|
1325
|
+
cssVariables?: ProjectCssVariableDefinitions;
|
|
1205
1326
|
}
|
|
1206
1327
|
|
|
1207
1328
|
export declare interface SourceComponentsPlugin {
|
|
@@ -1286,8 +1407,11 @@ export declare function warnUnmatchedComponentProps({ componentProps, displayIte
|
|
|
1286
1407
|
* Flex layout, gap, colors, typography, opacity and CSS classes are absent
|
|
1287
1408
|
* deliberately: they change how the canvas looks without taking away the room
|
|
1288
1409
|
* or the affordances the author needs to keep working.
|
|
1410
|
+
*
|
|
1411
|
+
* `pointer-events` is here for the same reason as hiding: `none` would leave the
|
|
1412
|
+
* author with a widget they cannot click or drag at all.
|
|
1289
1413
|
*/
|
|
1290
|
-
export declare const WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE: readonly ["width-3-resolutions", "min-width-3-resolutions", "max-width-3-resolutions", "height-3-resolutions", "min-height-3-resolutions", "max-height-3-resolutions", "margin-3-resolutions", "padding-3-resolutions", "border-3-resolutions", "border-radius-3-resolutions", "box-shadow-3-resolutions", "overflow-3-resolutions", "overflow-x-3-resolutions", "overflow-y-3-resolutions", "hide-component-3-resolutions"];
|
|
1414
|
+
export declare const WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE: readonly ["width-3-resolutions", "min-width-3-resolutions", "max-width-3-resolutions", "height-3-resolutions", "min-height-3-resolutions", "max-height-3-resolutions", "margin-3-resolutions", "padding-3-resolutions", "border-3-resolutions", "border-radius-3-resolutions", "box-shadow-3-resolutions", "overflow-3-resolutions", "overflow-x-3-resolutions", "overflow-y-3-resolutions", "hide-component-3-resolutions", "pointer-events-3-resolutions"];
|
|
1291
1415
|
|
|
1292
1416
|
/** Published (cached) API host. */
|
|
1293
1417
|
export declare const WIDGET_CACHE_API_ORIGIN = "https://widget-cache.rulecms.com";
|
|
@@ -1332,6 +1456,17 @@ export declare interface WidgetData {
|
|
|
1332
1456
|
lastPublishedAt: string;
|
|
1333
1457
|
}
|
|
1334
1458
|
|
|
1459
|
+
/**
|
|
1460
|
+
* True when the author gave the widget a height of its own, through either the
|
|
1461
|
+
* structured setting or the legacy raw container CSS.
|
|
1462
|
+
*/
|
|
1463
|
+
export declare function widgetDeclaresOwnHeight({ containerAttributes, widgetContainerStyles, }: {
|
|
1464
|
+
containerAttributes: {
|
|
1465
|
+
[key: string]: any;
|
|
1466
|
+
} | undefined;
|
|
1467
|
+
widgetContainerStyles: WidgetContainerStyles;
|
|
1468
|
+
}): boolean;
|
|
1469
|
+
|
|
1335
1470
|
/**
|
|
1336
1471
|
* Extra props a host application supplies for one component instance, handed
|
|
1337
1472
|
* to the component as `widgetInstanceProps`. Opaque to widget-react: it
|
|
@@ -1342,4 +1477,25 @@ export declare type WidgetInstanceProps = {
|
|
|
1342
1477
|
[key: string]: any;
|
|
1343
1478
|
};
|
|
1344
1479
|
|
|
1480
|
+
/**
|
|
1481
|
+
* An object rather than a bare array so the stacking contract has somewhere to
|
|
1482
|
+
* grow without another breaking shape change.
|
|
1483
|
+
*/
|
|
1484
|
+
export declare type WidgetOverlayLayers = {
|
|
1485
|
+
/**
|
|
1486
|
+
* Each layer is a full `Items` — its own rows, columns, collections and
|
|
1487
|
+
* container settings — so a layer renders through the same recursion as the
|
|
1488
|
+
* base and needs no separate vocabulary. Order is paint order: later
|
|
1489
|
+
* entries sit above earlier ones.
|
|
1490
|
+
*/
|
|
1491
|
+
layers: Items[];
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* The base's own place in the stack. Read here rather than through
|
|
1496
|
+
* objectStyleAttributeRegistry on purpose: the registry is shared with rows and
|
|
1497
|
+
* columns, and z-index is only meaningful to the widget wrapper for now.
|
|
1498
|
+
*/
|
|
1499
|
+
export declare const Z_INDEX_WIDGET_ATTRIBUTE_NAME = "z-index-3-resolutions";
|
|
1500
|
+
|
|
1345
1501
|
export { }
|