@usethrottle/builder-schema 0.2.0 → 0.2.1
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 +85 -77
- package/dist/index.d.cts +6 -18
- package/dist/index.d.ts +6 -18
- package/dist/index.js +85 -77
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1847,6 +1847,7 @@ var themeSchema = import_zod3.z.object({
|
|
|
1847
1847
|
colorScheme: import_zod3.z.enum(["light", "dark", "auto"]).default("auto"),
|
|
1848
1848
|
/** The merchant's own CSS, checked by the widget CSS sanitizer and scoped under `[data-b-root]`. */
|
|
1849
1849
|
customCss: import_zod3.z.string().max(THEME_CSS_MAX_CHARS).superRefine((css, ctx) => {
|
|
1850
|
+
if (css.length > THEME_CSS_MAX_CHARS) return;
|
|
1850
1851
|
const result = sanitizeThemeCss(css);
|
|
1851
1852
|
if (!result.ok) {
|
|
1852
1853
|
for (const found of result.issues) {
|
|
@@ -1966,7 +1967,14 @@ var spacingValueSchema = import_zod4.z.union([
|
|
|
1966
1967
|
import_zod4.z.enum(SPACING_TOKENS),
|
|
1967
1968
|
import_zod4.z.number().min(0).max(400)
|
|
1968
1969
|
]);
|
|
1969
|
-
var COMMON_SETTING_KEYS = [
|
|
1970
|
+
var COMMON_SETTING_KEYS = [
|
|
1971
|
+
"hidden",
|
|
1972
|
+
"anchor",
|
|
1973
|
+
"spacingTop",
|
|
1974
|
+
"spacingBottom",
|
|
1975
|
+
"entrance",
|
|
1976
|
+
"entranceDelayMs"
|
|
1977
|
+
];
|
|
1970
1978
|
var ANCHOR_RE = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
1971
1979
|
var anchorSchema = import_zod4.z.string().regex(ANCHOR_RE);
|
|
1972
1980
|
var ENTRANCES = ["none", "fade", "slide-up", "slide-left", "zoom"];
|
|
@@ -2394,6 +2402,33 @@ var size = (fallback) => field({
|
|
|
2394
2402
|
default: fallback
|
|
2395
2403
|
});
|
|
2396
2404
|
var link = (label = "Link") => field({ key: "link", label, tab: "content", output: "markup", control: "link", default: null });
|
|
2405
|
+
var ENTRANCE_WIDGET_SETTINGS = [
|
|
2406
|
+
field({
|
|
2407
|
+
key: "entrance",
|
|
2408
|
+
label: "Entrance animation",
|
|
2409
|
+
tab: "advanced",
|
|
2410
|
+
output: "markup",
|
|
2411
|
+
control: "select",
|
|
2412
|
+
options: [
|
|
2413
|
+
{ value: "none", label: "None" },
|
|
2414
|
+
{ value: "fade", label: "Fade in" },
|
|
2415
|
+
{ value: "slide-up", label: "Slide up" },
|
|
2416
|
+
{ value: "slide-left", label: "Slide in from the left" },
|
|
2417
|
+
{ value: "zoom", label: "Zoom in" }
|
|
2418
|
+
],
|
|
2419
|
+
default: "none"
|
|
2420
|
+
}),
|
|
2421
|
+
field({
|
|
2422
|
+
key: "entranceDelayMs",
|
|
2423
|
+
label: "Entrance delay (ms)",
|
|
2424
|
+
tab: "advanced",
|
|
2425
|
+
output: "markup",
|
|
2426
|
+
control: "number",
|
|
2427
|
+
min: 0,
|
|
2428
|
+
max: 2e3,
|
|
2429
|
+
default: 0
|
|
2430
|
+
})
|
|
2431
|
+
];
|
|
2397
2432
|
var COMMON_WIDGET_SETTINGS = [
|
|
2398
2433
|
field({
|
|
2399
2434
|
key: "hidden",
|
|
@@ -2427,39 +2462,10 @@ var COMMON_WIDGET_SETTINGS = [
|
|
|
2427
2462
|
output: "css",
|
|
2428
2463
|
control: "spacing",
|
|
2429
2464
|
default: "none"
|
|
2430
|
-
})
|
|
2431
|
-
];
|
|
2432
|
-
var ENTRANCE_WIDGET_SETTINGS = [
|
|
2433
|
-
field({
|
|
2434
|
-
key: "entrance",
|
|
2435
|
-
label: "Entrance animation",
|
|
2436
|
-
tab: "advanced",
|
|
2437
|
-
output: "markup",
|
|
2438
|
-
control: "select",
|
|
2439
|
-
options: [
|
|
2440
|
-
{ value: "none", label: "None" },
|
|
2441
|
-
{ value: "fade", label: "Fade in" },
|
|
2442
|
-
{ value: "slide-up", label: "Slide up" },
|
|
2443
|
-
{ value: "slide-left", label: "Slide in from the left" },
|
|
2444
|
-
{ value: "zoom", label: "Zoom in" }
|
|
2445
|
-
],
|
|
2446
|
-
default: "none"
|
|
2447
2465
|
}),
|
|
2448
|
-
field({
|
|
2449
|
-
key: "entranceDelayMs",
|
|
2450
|
-
label: "Entrance delay (ms)",
|
|
2451
|
-
tab: "advanced",
|
|
2452
|
-
output: "markup",
|
|
2453
|
-
control: "number",
|
|
2454
|
-
min: 0,
|
|
2455
|
-
max: 2e3,
|
|
2456
|
-
default: 0
|
|
2457
|
-
})
|
|
2458
|
-
];
|
|
2459
|
-
var ACCEPTED_COMMON_SETTINGS = [
|
|
2460
|
-
...COMMON_WIDGET_SETTINGS,
|
|
2461
2466
|
...ENTRANCE_WIDGET_SETTINGS
|
|
2462
2467
|
];
|
|
2468
|
+
var ACCEPTED_COMMON_SETTINGS = COMMON_WIDGET_SETTINGS;
|
|
2463
2469
|
function basic(slug, title, icon, description, settings) {
|
|
2464
2470
|
return {
|
|
2465
2471
|
type: `basic.${slug}`,
|
|
@@ -2472,6 +2478,51 @@ function basic(slug, title, icon, description, settings) {
|
|
|
2472
2478
|
migrations: {}
|
|
2473
2479
|
};
|
|
2474
2480
|
}
|
|
2481
|
+
var COUNTDOWN_WIDGET_DEFINITION = basic(
|
|
2482
|
+
"countdown",
|
|
2483
|
+
"Countdown",
|
|
2484
|
+
"clock",
|
|
2485
|
+
"A countdown to a date and time.",
|
|
2486
|
+
[
|
|
2487
|
+
field({
|
|
2488
|
+
key: "target",
|
|
2489
|
+
label: "Ends at",
|
|
2490
|
+
tab: "content",
|
|
2491
|
+
output: "markup",
|
|
2492
|
+
control: "datetime",
|
|
2493
|
+
default: null
|
|
2494
|
+
}),
|
|
2495
|
+
...["Days", "Hours", "Minutes", "Seconds"].flatMap((unit) => [
|
|
2496
|
+
field({
|
|
2497
|
+
key: `show${unit}`,
|
|
2498
|
+
label: `Show ${unit.toLowerCase()}`,
|
|
2499
|
+
tab: "content",
|
|
2500
|
+
output: "markup",
|
|
2501
|
+
control: "toggle",
|
|
2502
|
+
default: true
|
|
2503
|
+
}),
|
|
2504
|
+
translatableText(`label${unit}`, `${unit} label`, unit, { maxLength: 40 })
|
|
2505
|
+
]),
|
|
2506
|
+
translatableText("expiredText", "Text when it ends", "This offer has ended", {
|
|
2507
|
+
maxLength: 200
|
|
2508
|
+
}),
|
|
2509
|
+
field({
|
|
2510
|
+
key: "expiredBehavior",
|
|
2511
|
+
label: "When it ends",
|
|
2512
|
+
tab: "content",
|
|
2513
|
+
output: "markup",
|
|
2514
|
+
control: "select",
|
|
2515
|
+
options: [
|
|
2516
|
+
{ value: "text", label: "Show the text" },
|
|
2517
|
+
{ value: "hide", label: "Hide the countdown" }
|
|
2518
|
+
],
|
|
2519
|
+
default: "text"
|
|
2520
|
+
}),
|
|
2521
|
+
align("center"),
|
|
2522
|
+
size("l"),
|
|
2523
|
+
color()
|
|
2524
|
+
]
|
|
2525
|
+
);
|
|
2475
2526
|
var BASIC_WIDGET_DEFINITIONS = [
|
|
2476
2527
|
basic("heading", "Heading", "heading", "A heading of level 1 to 6.", [
|
|
2477
2528
|
translatableText("text", "Text", "Heading"),
|
|
@@ -2726,53 +2777,9 @@ var BASIC_WIDGET_DEFINITIONS = [
|
|
|
2726
2777
|
align("center"),
|
|
2727
2778
|
color(),
|
|
2728
2779
|
size("s")
|
|
2729
|
-
])
|
|
2780
|
+
]),
|
|
2781
|
+
COUNTDOWN_WIDGET_DEFINITION
|
|
2730
2782
|
];
|
|
2731
|
-
var COUNTDOWN_WIDGET_DEFINITION = basic(
|
|
2732
|
-
"countdown",
|
|
2733
|
-
"Countdown",
|
|
2734
|
-
"clock",
|
|
2735
|
-
"A countdown to a date and time.",
|
|
2736
|
-
[
|
|
2737
|
-
field({
|
|
2738
|
-
key: "target",
|
|
2739
|
-
label: "Ends at",
|
|
2740
|
-
tab: "content",
|
|
2741
|
-
output: "markup",
|
|
2742
|
-
control: "datetime",
|
|
2743
|
-
default: null
|
|
2744
|
-
}),
|
|
2745
|
-
...["Days", "Hours", "Minutes", "Seconds"].flatMap((unit) => [
|
|
2746
|
-
field({
|
|
2747
|
-
key: `show${unit}`,
|
|
2748
|
-
label: `Show ${unit.toLowerCase()}`,
|
|
2749
|
-
tab: "content",
|
|
2750
|
-
output: "markup",
|
|
2751
|
-
control: "toggle",
|
|
2752
|
-
default: true
|
|
2753
|
-
}),
|
|
2754
|
-
translatableText(`label${unit}`, `${unit} label`, unit, { maxLength: 40 })
|
|
2755
|
-
]),
|
|
2756
|
-
translatableText("expiredText", "Text when it ends", "This offer has ended", {
|
|
2757
|
-
maxLength: 200
|
|
2758
|
-
}),
|
|
2759
|
-
field({
|
|
2760
|
-
key: "expiredBehavior",
|
|
2761
|
-
label: "When it ends",
|
|
2762
|
-
tab: "content",
|
|
2763
|
-
output: "markup",
|
|
2764
|
-
control: "select",
|
|
2765
|
-
options: [
|
|
2766
|
-
{ value: "text", label: "Show the text" },
|
|
2767
|
-
{ value: "hide", label: "Hide the countdown" }
|
|
2768
|
-
],
|
|
2769
|
-
default: "text"
|
|
2770
|
-
}),
|
|
2771
|
-
align("center"),
|
|
2772
|
-
size("l"),
|
|
2773
|
-
color()
|
|
2774
|
-
]
|
|
2775
|
-
);
|
|
2776
2783
|
|
|
2777
2784
|
// src/widgets.ts
|
|
2778
2785
|
var WIDGET_GROUPS = ["layout", "basic", "catalog", "commerce", "custom"];
|
|
@@ -3847,6 +3854,7 @@ function upgradeNodes(doc, registry) {
|
|
|
3847
3854
|
return result.node;
|
|
3848
3855
|
};
|
|
3849
3856
|
const section = (node) => {
|
|
3857
|
+
if (node.type === "saved-section") return node;
|
|
3850
3858
|
const columns = mapShared(node.columns, (column) => {
|
|
3851
3859
|
const children = mapShared(
|
|
3852
3860
|
column.children,
|
package/dist/index.d.cts
CHANGED
|
@@ -67,7 +67,7 @@ declare const spacingValueSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
67
67
|
* do not count against the 40-setting cap. `COMMON_WIDGET_SETTINGS` (basics.ts)
|
|
68
68
|
* holds their fields.
|
|
69
69
|
*/
|
|
70
|
-
declare const COMMON_SETTING_KEYS: readonly ["hidden", "anchor", "spacingTop", "spacingBottom"];
|
|
70
|
+
declare const COMMON_SETTING_KEYS: readonly ["hidden", "anchor", "spacingTop", "spacingBottom", "entrance", "entranceDelayMs"];
|
|
71
71
|
/** An id-safe anchor, on every node and on the `anchor` setting of widgets. */
|
|
72
72
|
declare const ANCHOR_RE: RegExp;
|
|
73
73
|
/** How a block appears when it scrolls into view (a common prop of every node but a saved-section reference). */
|
|
@@ -5360,27 +5360,15 @@ interface WidgetRegistry {
|
|
|
5360
5360
|
*/
|
|
5361
5361
|
declare function createRegistry(defs: readonly WidgetDefinition[], sources: readonly DataSourceDescriptor[], custom?: readonly (CustomWidgetSnapshot | CodeWidgetSnapshotLive)[]): WidgetRegistry;
|
|
5362
5362
|
|
|
5363
|
-
/**
|
|
5364
|
-
declare const COMMON_WIDGET_SETTINGS: readonly SettingField[];
|
|
5365
|
-
/**
|
|
5366
|
-
* The entrance animation props every widget accepts (agent v2). They are common
|
|
5367
|
-
* props like the four above, but kept out of `COMMON_WIDGET_SETTINGS` (and so out
|
|
5368
|
-
* of every released definition's `settings`) until Task 11 of the agent v2 plan moves them
|
|
5369
|
-
* there (builder-schema 0.2.1, released with the renderers): a definition lists a
|
|
5370
|
-
* setting only once the renderer honours it. Validation
|
|
5371
|
-
* accepts them on every widget today (`ACCEPTED_COMMON_SETTINGS`).
|
|
5372
|
-
*/
|
|
5363
|
+
/** The entrance animation props every widget accepts (agent v2): common props, listed on every definition. */
|
|
5373
5364
|
declare const ENTRANCE_WIDGET_SETTINGS: readonly SettingField[];
|
|
5365
|
+
/** Every widget has these (spec §8.2): hide per device, an anchor, its margins and its entrance animation (agent v2). */
|
|
5366
|
+
declare const COMMON_WIDGET_SETTINGS: readonly SettingField[];
|
|
5374
5367
|
/** Every common prop a widget node may carry, whether or not its definition lists it. */
|
|
5375
5368
|
declare const ACCEPTED_COMMON_SETTINGS: readonly SettingField[];
|
|
5376
|
-
|
|
5377
|
-
/**
|
|
5378
|
-
* `basic.countdown` (agent v2). Defined here, but not yet in `BASIC_WIDGET_DEFINITIONS`.
|
|
5379
|
-
* Task 11 adds it to that list in builder-schema itself (released as 0.2.1 together with
|
|
5380
|
-
* builder-react 0.4.0 and the renderers), so a store never meets a widget type its
|
|
5381
|
-
* renderer cannot draw.
|
|
5382
|
-
*/
|
|
5369
|
+
/** `basic.countdown` (agent v2): a countdown to a date and time. Listed in `BASIC_WIDGET_DEFINITIONS`. */
|
|
5383
5370
|
declare const COUNTDOWN_WIDGET_DEFINITION: WidgetDefinition;
|
|
5371
|
+
declare const BASIC_WIDGET_DEFINITIONS: WidgetDefinition[];
|
|
5384
5372
|
|
|
5385
5373
|
/** Where a document lives. A part or slot may refuse some widgets. */
|
|
5386
5374
|
type DocumentKind = 'page' | 'part:header' | 'part:footer' | 'slot';
|
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ declare const spacingValueSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
67
67
|
* do not count against the 40-setting cap. `COMMON_WIDGET_SETTINGS` (basics.ts)
|
|
68
68
|
* holds their fields.
|
|
69
69
|
*/
|
|
70
|
-
declare const COMMON_SETTING_KEYS: readonly ["hidden", "anchor", "spacingTop", "spacingBottom"];
|
|
70
|
+
declare const COMMON_SETTING_KEYS: readonly ["hidden", "anchor", "spacingTop", "spacingBottom", "entrance", "entranceDelayMs"];
|
|
71
71
|
/** An id-safe anchor, on every node and on the `anchor` setting of widgets. */
|
|
72
72
|
declare const ANCHOR_RE: RegExp;
|
|
73
73
|
/** How a block appears when it scrolls into view (a common prop of every node but a saved-section reference). */
|
|
@@ -5360,27 +5360,15 @@ interface WidgetRegistry {
|
|
|
5360
5360
|
*/
|
|
5361
5361
|
declare function createRegistry(defs: readonly WidgetDefinition[], sources: readonly DataSourceDescriptor[], custom?: readonly (CustomWidgetSnapshot | CodeWidgetSnapshotLive)[]): WidgetRegistry;
|
|
5362
5362
|
|
|
5363
|
-
/**
|
|
5364
|
-
declare const COMMON_WIDGET_SETTINGS: readonly SettingField[];
|
|
5365
|
-
/**
|
|
5366
|
-
* The entrance animation props every widget accepts (agent v2). They are common
|
|
5367
|
-
* props like the four above, but kept out of `COMMON_WIDGET_SETTINGS` (and so out
|
|
5368
|
-
* of every released definition's `settings`) until Task 11 of the agent v2 plan moves them
|
|
5369
|
-
* there (builder-schema 0.2.1, released with the renderers): a definition lists a
|
|
5370
|
-
* setting only once the renderer honours it. Validation
|
|
5371
|
-
* accepts them on every widget today (`ACCEPTED_COMMON_SETTINGS`).
|
|
5372
|
-
*/
|
|
5363
|
+
/** The entrance animation props every widget accepts (agent v2): common props, listed on every definition. */
|
|
5373
5364
|
declare const ENTRANCE_WIDGET_SETTINGS: readonly SettingField[];
|
|
5365
|
+
/** Every widget has these (spec §8.2): hide per device, an anchor, its margins and its entrance animation (agent v2). */
|
|
5366
|
+
declare const COMMON_WIDGET_SETTINGS: readonly SettingField[];
|
|
5374
5367
|
/** Every common prop a widget node may carry, whether or not its definition lists it. */
|
|
5375
5368
|
declare const ACCEPTED_COMMON_SETTINGS: readonly SettingField[];
|
|
5376
|
-
|
|
5377
|
-
/**
|
|
5378
|
-
* `basic.countdown` (agent v2). Defined here, but not yet in `BASIC_WIDGET_DEFINITIONS`.
|
|
5379
|
-
* Task 11 adds it to that list in builder-schema itself (released as 0.2.1 together with
|
|
5380
|
-
* builder-react 0.4.0 and the renderers), so a store never meets a widget type its
|
|
5381
|
-
* renderer cannot draw.
|
|
5382
|
-
*/
|
|
5369
|
+
/** `basic.countdown` (agent v2): a countdown to a date and time. Listed in `BASIC_WIDGET_DEFINITIONS`. */
|
|
5383
5370
|
declare const COUNTDOWN_WIDGET_DEFINITION: WidgetDefinition;
|
|
5371
|
+
declare const BASIC_WIDGET_DEFINITIONS: WidgetDefinition[];
|
|
5384
5372
|
|
|
5385
5373
|
/** Where a document lives. A part or slot may refuse some widgets. */
|
|
5386
5374
|
type DocumentKind = 'page' | 'part:header' | 'part:footer' | 'slot';
|
package/dist/index.js
CHANGED
|
@@ -1702,6 +1702,7 @@ var themeSchema = z3.object({
|
|
|
1702
1702
|
colorScheme: z3.enum(["light", "dark", "auto"]).default("auto"),
|
|
1703
1703
|
/** The merchant's own CSS, checked by the widget CSS sanitizer and scoped under `[data-b-root]`. */
|
|
1704
1704
|
customCss: z3.string().max(THEME_CSS_MAX_CHARS).superRefine((css, ctx) => {
|
|
1705
|
+
if (css.length > THEME_CSS_MAX_CHARS) return;
|
|
1705
1706
|
const result = sanitizeThemeCss(css);
|
|
1706
1707
|
if (!result.ok) {
|
|
1707
1708
|
for (const found of result.issues) {
|
|
@@ -1821,7 +1822,14 @@ var spacingValueSchema = z4.union([
|
|
|
1821
1822
|
z4.enum(SPACING_TOKENS),
|
|
1822
1823
|
z4.number().min(0).max(400)
|
|
1823
1824
|
]);
|
|
1824
|
-
var COMMON_SETTING_KEYS = [
|
|
1825
|
+
var COMMON_SETTING_KEYS = [
|
|
1826
|
+
"hidden",
|
|
1827
|
+
"anchor",
|
|
1828
|
+
"spacingTop",
|
|
1829
|
+
"spacingBottom",
|
|
1830
|
+
"entrance",
|
|
1831
|
+
"entranceDelayMs"
|
|
1832
|
+
];
|
|
1825
1833
|
var ANCHOR_RE = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
1826
1834
|
var anchorSchema = z4.string().regex(ANCHOR_RE);
|
|
1827
1835
|
var ENTRANCES = ["none", "fade", "slide-up", "slide-left", "zoom"];
|
|
@@ -2249,6 +2257,33 @@ var size = (fallback) => field({
|
|
|
2249
2257
|
default: fallback
|
|
2250
2258
|
});
|
|
2251
2259
|
var link = (label = "Link") => field({ key: "link", label, tab: "content", output: "markup", control: "link", default: null });
|
|
2260
|
+
var ENTRANCE_WIDGET_SETTINGS = [
|
|
2261
|
+
field({
|
|
2262
|
+
key: "entrance",
|
|
2263
|
+
label: "Entrance animation",
|
|
2264
|
+
tab: "advanced",
|
|
2265
|
+
output: "markup",
|
|
2266
|
+
control: "select",
|
|
2267
|
+
options: [
|
|
2268
|
+
{ value: "none", label: "None" },
|
|
2269
|
+
{ value: "fade", label: "Fade in" },
|
|
2270
|
+
{ value: "slide-up", label: "Slide up" },
|
|
2271
|
+
{ value: "slide-left", label: "Slide in from the left" },
|
|
2272
|
+
{ value: "zoom", label: "Zoom in" }
|
|
2273
|
+
],
|
|
2274
|
+
default: "none"
|
|
2275
|
+
}),
|
|
2276
|
+
field({
|
|
2277
|
+
key: "entranceDelayMs",
|
|
2278
|
+
label: "Entrance delay (ms)",
|
|
2279
|
+
tab: "advanced",
|
|
2280
|
+
output: "markup",
|
|
2281
|
+
control: "number",
|
|
2282
|
+
min: 0,
|
|
2283
|
+
max: 2e3,
|
|
2284
|
+
default: 0
|
|
2285
|
+
})
|
|
2286
|
+
];
|
|
2252
2287
|
var COMMON_WIDGET_SETTINGS = [
|
|
2253
2288
|
field({
|
|
2254
2289
|
key: "hidden",
|
|
@@ -2282,39 +2317,10 @@ var COMMON_WIDGET_SETTINGS = [
|
|
|
2282
2317
|
output: "css",
|
|
2283
2318
|
control: "spacing",
|
|
2284
2319
|
default: "none"
|
|
2285
|
-
})
|
|
2286
|
-
];
|
|
2287
|
-
var ENTRANCE_WIDGET_SETTINGS = [
|
|
2288
|
-
field({
|
|
2289
|
-
key: "entrance",
|
|
2290
|
-
label: "Entrance animation",
|
|
2291
|
-
tab: "advanced",
|
|
2292
|
-
output: "markup",
|
|
2293
|
-
control: "select",
|
|
2294
|
-
options: [
|
|
2295
|
-
{ value: "none", label: "None" },
|
|
2296
|
-
{ value: "fade", label: "Fade in" },
|
|
2297
|
-
{ value: "slide-up", label: "Slide up" },
|
|
2298
|
-
{ value: "slide-left", label: "Slide in from the left" },
|
|
2299
|
-
{ value: "zoom", label: "Zoom in" }
|
|
2300
|
-
],
|
|
2301
|
-
default: "none"
|
|
2302
2320
|
}),
|
|
2303
|
-
field({
|
|
2304
|
-
key: "entranceDelayMs",
|
|
2305
|
-
label: "Entrance delay (ms)",
|
|
2306
|
-
tab: "advanced",
|
|
2307
|
-
output: "markup",
|
|
2308
|
-
control: "number",
|
|
2309
|
-
min: 0,
|
|
2310
|
-
max: 2e3,
|
|
2311
|
-
default: 0
|
|
2312
|
-
})
|
|
2313
|
-
];
|
|
2314
|
-
var ACCEPTED_COMMON_SETTINGS = [
|
|
2315
|
-
...COMMON_WIDGET_SETTINGS,
|
|
2316
2321
|
...ENTRANCE_WIDGET_SETTINGS
|
|
2317
2322
|
];
|
|
2323
|
+
var ACCEPTED_COMMON_SETTINGS = COMMON_WIDGET_SETTINGS;
|
|
2318
2324
|
function basic(slug, title, icon, description, settings) {
|
|
2319
2325
|
return {
|
|
2320
2326
|
type: `basic.${slug}`,
|
|
@@ -2327,6 +2333,51 @@ function basic(slug, title, icon, description, settings) {
|
|
|
2327
2333
|
migrations: {}
|
|
2328
2334
|
};
|
|
2329
2335
|
}
|
|
2336
|
+
var COUNTDOWN_WIDGET_DEFINITION = basic(
|
|
2337
|
+
"countdown",
|
|
2338
|
+
"Countdown",
|
|
2339
|
+
"clock",
|
|
2340
|
+
"A countdown to a date and time.",
|
|
2341
|
+
[
|
|
2342
|
+
field({
|
|
2343
|
+
key: "target",
|
|
2344
|
+
label: "Ends at",
|
|
2345
|
+
tab: "content",
|
|
2346
|
+
output: "markup",
|
|
2347
|
+
control: "datetime",
|
|
2348
|
+
default: null
|
|
2349
|
+
}),
|
|
2350
|
+
...["Days", "Hours", "Minutes", "Seconds"].flatMap((unit) => [
|
|
2351
|
+
field({
|
|
2352
|
+
key: `show${unit}`,
|
|
2353
|
+
label: `Show ${unit.toLowerCase()}`,
|
|
2354
|
+
tab: "content",
|
|
2355
|
+
output: "markup",
|
|
2356
|
+
control: "toggle",
|
|
2357
|
+
default: true
|
|
2358
|
+
}),
|
|
2359
|
+
translatableText(`label${unit}`, `${unit} label`, unit, { maxLength: 40 })
|
|
2360
|
+
]),
|
|
2361
|
+
translatableText("expiredText", "Text when it ends", "This offer has ended", {
|
|
2362
|
+
maxLength: 200
|
|
2363
|
+
}),
|
|
2364
|
+
field({
|
|
2365
|
+
key: "expiredBehavior",
|
|
2366
|
+
label: "When it ends",
|
|
2367
|
+
tab: "content",
|
|
2368
|
+
output: "markup",
|
|
2369
|
+
control: "select",
|
|
2370
|
+
options: [
|
|
2371
|
+
{ value: "text", label: "Show the text" },
|
|
2372
|
+
{ value: "hide", label: "Hide the countdown" }
|
|
2373
|
+
],
|
|
2374
|
+
default: "text"
|
|
2375
|
+
}),
|
|
2376
|
+
align("center"),
|
|
2377
|
+
size("l"),
|
|
2378
|
+
color()
|
|
2379
|
+
]
|
|
2380
|
+
);
|
|
2330
2381
|
var BASIC_WIDGET_DEFINITIONS = [
|
|
2331
2382
|
basic("heading", "Heading", "heading", "A heading of level 1 to 6.", [
|
|
2332
2383
|
translatableText("text", "Text", "Heading"),
|
|
@@ -2581,53 +2632,9 @@ var BASIC_WIDGET_DEFINITIONS = [
|
|
|
2581
2632
|
align("center"),
|
|
2582
2633
|
color(),
|
|
2583
2634
|
size("s")
|
|
2584
|
-
])
|
|
2635
|
+
]),
|
|
2636
|
+
COUNTDOWN_WIDGET_DEFINITION
|
|
2585
2637
|
];
|
|
2586
|
-
var COUNTDOWN_WIDGET_DEFINITION = basic(
|
|
2587
|
-
"countdown",
|
|
2588
|
-
"Countdown",
|
|
2589
|
-
"clock",
|
|
2590
|
-
"A countdown to a date and time.",
|
|
2591
|
-
[
|
|
2592
|
-
field({
|
|
2593
|
-
key: "target",
|
|
2594
|
-
label: "Ends at",
|
|
2595
|
-
tab: "content",
|
|
2596
|
-
output: "markup",
|
|
2597
|
-
control: "datetime",
|
|
2598
|
-
default: null
|
|
2599
|
-
}),
|
|
2600
|
-
...["Days", "Hours", "Minutes", "Seconds"].flatMap((unit) => [
|
|
2601
|
-
field({
|
|
2602
|
-
key: `show${unit}`,
|
|
2603
|
-
label: `Show ${unit.toLowerCase()}`,
|
|
2604
|
-
tab: "content",
|
|
2605
|
-
output: "markup",
|
|
2606
|
-
control: "toggle",
|
|
2607
|
-
default: true
|
|
2608
|
-
}),
|
|
2609
|
-
translatableText(`label${unit}`, `${unit} label`, unit, { maxLength: 40 })
|
|
2610
|
-
]),
|
|
2611
|
-
translatableText("expiredText", "Text when it ends", "This offer has ended", {
|
|
2612
|
-
maxLength: 200
|
|
2613
|
-
}),
|
|
2614
|
-
field({
|
|
2615
|
-
key: "expiredBehavior",
|
|
2616
|
-
label: "When it ends",
|
|
2617
|
-
tab: "content",
|
|
2618
|
-
output: "markup",
|
|
2619
|
-
control: "select",
|
|
2620
|
-
options: [
|
|
2621
|
-
{ value: "text", label: "Show the text" },
|
|
2622
|
-
{ value: "hide", label: "Hide the countdown" }
|
|
2623
|
-
],
|
|
2624
|
-
default: "text"
|
|
2625
|
-
}),
|
|
2626
|
-
align("center"),
|
|
2627
|
-
size("l"),
|
|
2628
|
-
color()
|
|
2629
|
-
]
|
|
2630
|
-
);
|
|
2631
2638
|
|
|
2632
2639
|
// src/widgets.ts
|
|
2633
2640
|
var WIDGET_GROUPS = ["layout", "basic", "catalog", "commerce", "custom"];
|
|
@@ -3702,6 +3709,7 @@ function upgradeNodes(doc, registry) {
|
|
|
3702
3709
|
return result.node;
|
|
3703
3710
|
};
|
|
3704
3711
|
const section = (node) => {
|
|
3712
|
+
if (node.type === "saved-section") return node;
|
|
3705
3713
|
const columns = mapShared(node.columns, (column) => {
|
|
3706
3714
|
const children = mapShared(
|
|
3707
3715
|
column.children,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/builder-schema",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Throttle Builder page document, site settings, responsive rules, limits and basic widget definitions. Pure TypeScript plus zod, no React and no I/O.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|