@rulecms/widget-svelte 0.2.0 → 0.4.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/README.md +14 -0
- package/dist/index.cjs +10 -10
- package/dist/index.d.ts +159 -1
- package/dist/index.js +2415 -2186
- 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: {
|
|
@@ -831,6 +883,9 @@ export declare const hasInvalidCssVariable: (leaf: unknown) => boolean;
|
|
|
831
883
|
|
|
832
884
|
export declare const hasItems: (items: Items | undefined) => boolean | undefined;
|
|
833
885
|
|
|
886
|
+
/** True when this Items asks for at least one layer over its rows. */
|
|
887
|
+
export declare function hasOverlayLayers(items: Items | undefined): boolean;
|
|
888
|
+
|
|
834
889
|
export declare const HIDE_WIDGET_ATTRIBUTE_NAME = "hide-component-3-resolutions";
|
|
835
890
|
|
|
836
891
|
/**
|
|
@@ -868,6 +923,16 @@ export declare const isLineHeightValue: (value: unknown) => value is LineHeightV
|
|
|
868
923
|
|
|
869
924
|
export declare const isOpacityValue: (value: unknown) => value is OpacityValue;
|
|
870
925
|
|
|
926
|
+
/**
|
|
927
|
+
* True when a layer has nothing to put on screen at this width, so its box is
|
|
928
|
+
* not worth emitting. Its z-index slot still goes unclaimed — see
|
|
929
|
+
* getOverlayLayerZIndex.
|
|
930
|
+
*/
|
|
931
|
+
export declare function isOverlayLayerEmptyForDevice({ layer, deviceDisplayType, }: {
|
|
932
|
+
layer: Items;
|
|
933
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
934
|
+
}): boolean;
|
|
935
|
+
|
|
871
936
|
export declare function isRowHiddenForDevice({ row, deviceDisplayType, }: {
|
|
872
937
|
row: DisplayItemRow;
|
|
873
938
|
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
@@ -894,6 +959,12 @@ export declare type Items = {
|
|
|
894
959
|
containerAttributes?: {
|
|
895
960
|
[key: string]: any;
|
|
896
961
|
};
|
|
962
|
+
/**
|
|
963
|
+
* Layers drawn over the rows above, each covering exactly the box the rows
|
|
964
|
+
* occupy. Absent for the overwhelming majority of configs. Honoured in
|
|
965
|
+
* preview and every published render; the composer canvas ignores it.
|
|
966
|
+
*/
|
|
967
|
+
overlayLayers?: WidgetOverlayLayers;
|
|
897
968
|
};
|
|
898
969
|
|
|
899
970
|
/** Column flex layout — matches row Horizontal Alignment options. */
|
|
@@ -937,6 +1008,12 @@ export declare interface LibraryCardInputs {
|
|
|
937
1008
|
};
|
|
938
1009
|
className?: string;
|
|
939
1010
|
widgetInstanceProps?: WidgetInstanceProps;
|
|
1011
|
+
/**
|
|
1012
|
+
* Host-supplied map of mount name → Svelte component. Only `r-mount`
|
|
1013
|
+
* reads this. Absent in the composer, and absent whenever the host
|
|
1014
|
+
* passed no `mounts` on `RuleCMSWidget`.
|
|
1015
|
+
*/
|
|
1016
|
+
mounts?: MountsMap;
|
|
940
1017
|
}
|
|
941
1018
|
|
|
942
1019
|
export declare type LibraryComponentEntry = {
|
|
@@ -962,6 +1039,15 @@ export declare type LineHeightValue = ({
|
|
|
962
1039
|
value: number;
|
|
963
1040
|
} & CssVariableCarrier) | SpacingSideValue;
|
|
964
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* Host-app components `r-mount` can render, keyed by the name an author
|
|
1044
|
+
* types in the composer. The name is a map lookup, not a string that
|
|
1045
|
+
* becomes code. A miss is a placeholder.
|
|
1046
|
+
*/
|
|
1047
|
+
export declare type MountsMap = {
|
|
1048
|
+
[name: string]: Component;
|
|
1049
|
+
};
|
|
1050
|
+
|
|
965
1051
|
export declare type NoContainerResolverContext = {
|
|
966
1052
|
componentAttributes?: {
|
|
967
1053
|
[key: string]: any;
|
|
@@ -1039,6 +1125,15 @@ export declare const PageViewTypes: {
|
|
|
1039
1125
|
|
|
1040
1126
|
export declare const phoneModeWidth = "500px";
|
|
1041
1127
|
|
|
1128
|
+
export declare const POINTER_EVENTS_ATTRIBUTE_NAME = "pointer-events-3-resolutions";
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Whether an element takes pointer input. `none` passes clicks through to
|
|
1132
|
+
* whatever sits behind, which is what an overlay layer covering the base needs;
|
|
1133
|
+
* a descendant can take input back with `auto`, since the property inherits.
|
|
1134
|
+
*/
|
|
1135
|
+
export declare const pointerEventsAllowlist: readonly ["auto", "none"];
|
|
1136
|
+
|
|
1042
1137
|
/** Transform raw widget API data into render-ready displayItemList + collections. */
|
|
1043
1138
|
export declare function prepareRuleCMSWidgetData(raw: RuleCMSWidgetRawData): RuleCMSWidgetData;
|
|
1044
1139
|
|
|
@@ -1066,6 +1161,17 @@ export declare interface RenderComponentPlugins {
|
|
|
1066
1161
|
sourceComponents?: SourceComponentsPlugin;
|
|
1067
1162
|
}
|
|
1068
1163
|
|
|
1164
|
+
/**
|
|
1165
|
+
* The base's z-index for this device, or 0 when unset or unusable. Accepts the
|
|
1166
|
+
* number and the numeric string, since hand-authored JSON produces both.
|
|
1167
|
+
*/
|
|
1168
|
+
export declare function resolveBaseZIndex({ containerAttributes, deviceDisplayType, }: {
|
|
1169
|
+
containerAttributes: {
|
|
1170
|
+
[key: string]: any;
|
|
1171
|
+
} | undefined;
|
|
1172
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
1173
|
+
}): number;
|
|
1174
|
+
|
|
1069
1175
|
/**
|
|
1070
1176
|
* Maps a component's (libraryId, type) pair to its key in the composed
|
|
1071
1177
|
* components map. The default library keeps bare (unnamespaced) keys so
|
|
@@ -1084,6 +1190,23 @@ export declare interface ResolveLibrariesParams {
|
|
|
1084
1190
|
|
|
1085
1191
|
export declare type ResolveNoContainer = (context: NoContainerResolverContext) => boolean;
|
|
1086
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* A layer's `pointer-events` for this device, lifted from the layer's own
|
|
1195
|
+
* container settings. `undefined` leaves the property off the box entirely.
|
|
1196
|
+
*
|
|
1197
|
+
* The layer box covers the whole base, so this has to land there rather than on
|
|
1198
|
+
* the container nested inside it: `none` on an inner element still leaves the
|
|
1199
|
+
* box itself intercepting every click aimed at the base underneath. Because the
|
|
1200
|
+
* property inherits, one `none` on the layer also frees the layer's own content,
|
|
1201
|
+
* which can take input back with `auto` on the column that needs it.
|
|
1202
|
+
*/
|
|
1203
|
+
export declare function resolveOverlayLayerPointerEvents({ containerAttributes, deviceDisplayType, }: {
|
|
1204
|
+
containerAttributes: {
|
|
1205
|
+
[key: string]: any;
|
|
1206
|
+
} | undefined;
|
|
1207
|
+
deviceDisplayType: keyof typeof DeviceDisplayTypes;
|
|
1208
|
+
}): string | undefined;
|
|
1209
|
+
|
|
1087
1210
|
export declare type ResolveRendersOwnElement = (context: NoContainerResolverContext) => boolean;
|
|
1088
1211
|
|
|
1089
1212
|
/**
|
|
@@ -1271,8 +1394,11 @@ export declare function warnUnmatchedComponentProps({ componentProps, displayIte
|
|
|
1271
1394
|
* Flex layout, gap, colors, typography, opacity and CSS classes are absent
|
|
1272
1395
|
* deliberately: they change how the canvas looks without taking away the room
|
|
1273
1396
|
* or the affordances the author needs to keep working.
|
|
1397
|
+
*
|
|
1398
|
+
* `pointer-events` is here for the same reason as hiding: `none` would leave the
|
|
1399
|
+
* author with a widget they cannot click or drag at all.
|
|
1274
1400
|
*/
|
|
1275
|
-
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"];
|
|
1401
|
+
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"];
|
|
1276
1402
|
|
|
1277
1403
|
/** Published (cached) API host. */
|
|
1278
1404
|
export declare const WIDGET_CACHE_API_ORIGIN = "https://widget-cache.rulecms.com";
|
|
@@ -1317,6 +1443,17 @@ export declare interface WidgetData {
|
|
|
1317
1443
|
lastPublishedAt: string;
|
|
1318
1444
|
}
|
|
1319
1445
|
|
|
1446
|
+
/**
|
|
1447
|
+
* True when the author gave the widget a height of its own, through either the
|
|
1448
|
+
* structured setting or the legacy raw container CSS.
|
|
1449
|
+
*/
|
|
1450
|
+
export declare function widgetDeclaresOwnHeight({ containerAttributes, widgetContainerStyles, }: {
|
|
1451
|
+
containerAttributes: {
|
|
1452
|
+
[key: string]: any;
|
|
1453
|
+
} | undefined;
|
|
1454
|
+
widgetContainerStyles: WidgetContainerStyles;
|
|
1455
|
+
}): boolean;
|
|
1456
|
+
|
|
1320
1457
|
/**
|
|
1321
1458
|
* Extra props a host application supplies for one component instance, handed
|
|
1322
1459
|
* to the component as `widgetInstanceProps`. Opaque to widget-react: it
|
|
@@ -1327,4 +1464,25 @@ export declare type WidgetInstanceProps = {
|
|
|
1327
1464
|
[key: string]: any;
|
|
1328
1465
|
};
|
|
1329
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* An object rather than a bare array so the stacking contract has somewhere to
|
|
1469
|
+
* grow without another breaking shape change.
|
|
1470
|
+
*/
|
|
1471
|
+
export declare type WidgetOverlayLayers = {
|
|
1472
|
+
/**
|
|
1473
|
+
* Each layer is a full `Items` — its own rows, columns, collections and
|
|
1474
|
+
* container settings — so a layer renders through the same recursion as the
|
|
1475
|
+
* base and needs no separate vocabulary. Order is paint order: later
|
|
1476
|
+
* entries sit above earlier ones.
|
|
1477
|
+
*/
|
|
1478
|
+
layers: Items[];
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* The base's own place in the stack. Read here rather than through
|
|
1483
|
+
* objectStyleAttributeRegistry on purpose: the registry is shared with rows and
|
|
1484
|
+
* columns, and z-index is only meaningful to the widget wrapper for now.
|
|
1485
|
+
*/
|
|
1486
|
+
export declare const Z_INDEX_WIDGET_ATTRIBUTE_NAME = "z-index-3-resolutions";
|
|
1487
|
+
|
|
1330
1488
|
export { }
|