@rulecms/widget-svelte 0.3.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/dist/index.cjs +10 -10
- package/dist/index.d.ts +144 -1
- package/dist/index.js +2395 -2191
- 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. */
|
|
@@ -1054,6 +1125,15 @@ export declare const PageViewTypes: {
|
|
|
1054
1125
|
|
|
1055
1126
|
export declare const phoneModeWidth = "500px";
|
|
1056
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
|
+
|
|
1057
1137
|
/** Transform raw widget API data into render-ready displayItemList + collections. */
|
|
1058
1138
|
export declare function prepareRuleCMSWidgetData(raw: RuleCMSWidgetRawData): RuleCMSWidgetData;
|
|
1059
1139
|
|
|
@@ -1081,6 +1161,17 @@ export declare interface RenderComponentPlugins {
|
|
|
1081
1161
|
sourceComponents?: SourceComponentsPlugin;
|
|
1082
1162
|
}
|
|
1083
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
|
+
|
|
1084
1175
|
/**
|
|
1085
1176
|
* Maps a component's (libraryId, type) pair to its key in the composed
|
|
1086
1177
|
* components map. The default library keeps bare (unnamespaced) keys so
|
|
@@ -1099,6 +1190,23 @@ export declare interface ResolveLibrariesParams {
|
|
|
1099
1190
|
|
|
1100
1191
|
export declare type ResolveNoContainer = (context: NoContainerResolverContext) => boolean;
|
|
1101
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
|
+
|
|
1102
1210
|
export declare type ResolveRendersOwnElement = (context: NoContainerResolverContext) => boolean;
|
|
1103
1211
|
|
|
1104
1212
|
/**
|
|
@@ -1286,8 +1394,11 @@ export declare function warnUnmatchedComponentProps({ componentProps, displayIte
|
|
|
1286
1394
|
* Flex layout, gap, colors, typography, opacity and CSS classes are absent
|
|
1287
1395
|
* deliberately: they change how the canvas looks without taking away the room
|
|
1288
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.
|
|
1289
1400
|
*/
|
|
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"];
|
|
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"];
|
|
1291
1402
|
|
|
1292
1403
|
/** Published (cached) API host. */
|
|
1293
1404
|
export declare const WIDGET_CACHE_API_ORIGIN = "https://widget-cache.rulecms.com";
|
|
@@ -1332,6 +1443,17 @@ export declare interface WidgetData {
|
|
|
1332
1443
|
lastPublishedAt: string;
|
|
1333
1444
|
}
|
|
1334
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
|
+
|
|
1335
1457
|
/**
|
|
1336
1458
|
* Extra props a host application supplies for one component instance, handed
|
|
1337
1459
|
* to the component as `widgetInstanceProps`. Opaque to widget-react: it
|
|
@@ -1342,4 +1464,25 @@ export declare type WidgetInstanceProps = {
|
|
|
1342
1464
|
[key: string]: any;
|
|
1343
1465
|
};
|
|
1344
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
|
+
|
|
1345
1488
|
export { }
|