@perkyzz/emvb 1.0.0 → 1.2.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.
Files changed (142) hide show
  1. package/README.md +9 -0
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/package.json +10 -9
  4. package/src/admin/agents-api.ts +5 -1
  5. package/src/admin/bulk-api.ts +67 -0
  6. package/src/admin/content-api.ts +39 -6
  7. package/src/admin/copy-rich-text.ts +119 -0
  8. package/src/admin/dialog-tab-wrap.ts +78 -0
  9. package/src/admin/editor/A11yCopilot.tsx +2 -0
  10. package/src/admin/editor/Editor.tsx +24 -7
  11. package/src/admin/editor/ScheduleDialog.tsx +167 -0
  12. package/src/admin/editor/Timeline.tsx +6 -2
  13. package/src/admin/editor/TopBar.tsx +60 -8
  14. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  15. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  16. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  17. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  18. package/src/admin/editor/dnd/new-element.ts +68 -0
  19. package/src/admin/editor/editor-chrome.tsx +16 -5
  20. package/src/admin/editor/editor-commands.ts +10 -4
  21. package/src/admin/editor/editor-css.ts +2 -1
  22. package/src/admin/editor/element-chrome.ts +22 -0
  23. package/src/admin/editor/panels/ElementPanel.tsx +34 -17
  24. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  25. package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
  26. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  27. package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
  28. package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
  29. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  30. package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
  31. package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
  32. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  33. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  34. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  35. package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
  36. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  37. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  38. package/src/admin/editor/panels/style-target.ts +17 -4
  39. package/src/admin/editor/section-templates.ts +26 -4
  40. package/src/admin/editor/store.ts +15 -3
  41. package/src/admin/editor/useEditorCommands.ts +7 -5
  42. package/src/admin/editor/useEditorData.ts +4 -0
  43. package/src/admin/editor/useNodeActions.ts +4 -2
  44. package/src/admin/editor/useSave.ts +47 -3
  45. package/src/admin/export-api.ts +238 -0
  46. package/src/admin/index.tsx +6 -1
  47. package/src/admin/menus-api.ts +113 -0
  48. package/src/admin/pages/ExportDialog.tsx +395 -0
  49. package/src/admin/pages/ImportElementorDialog.tsx +25 -1
  50. package/src/admin/pages/PageList.tsx +67 -2
  51. package/src/admin/pages/ThemePartList.tsx +37 -1
  52. package/src/admin/pages/bulk.tsx +303 -0
  53. package/src/admin/search.ts +20 -0
  54. package/src/admin/theme-api.ts +4 -0
  55. package/src/admin/ui.ts +11 -2
  56. package/src/admin/widgets/CanvasField.tsx +8 -0
  57. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  58. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  59. package/src/admin/widgets/convert-body.ts +73 -2
  60. package/src/astro/EmVBPage.astro +3 -0
  61. package/src/astro/render.ts +47 -22
  62. package/src/astro/request-data.ts +3 -0
  63. package/src/astro/resolve-theme.ts +88 -51
  64. package/src/astro/tabs/runtime.ts +16 -6
  65. package/src/astro/visitor.ts +23 -4
  66. package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
  67. package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
  68. package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
  69. package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
  70. package/src/astro/widgets/alerts.ts +37 -0
  71. package/src/astro/widgets/carousel.ts +167 -0
  72. package/src/astro/widgets/index.ts +1 -0
  73. package/src/astro/widgets/lightbox.ts +123 -0
  74. package/src/constants.ts +1 -1
  75. package/src/core/a11y/audit.ts +103 -3
  76. package/src/core/arrange.ts +57 -1
  77. package/src/core/bounded-array.ts +16 -13
  78. package/src/core/contract.ts +26 -3
  79. package/src/core/css/generate.ts +83 -21
  80. package/src/core/css/scope.ts +10 -2
  81. package/src/core/css/trace.ts +33 -8
  82. package/src/core/design/classes.ts +25 -5
  83. package/src/core/design/devices.ts +78 -2
  84. package/src/core/design/variables.ts +14 -1
  85. package/src/core/elements/icon-svg.ts +135 -0
  86. package/src/core/elements/index.ts +33 -127
  87. package/src/core/elements/widgets.ts +907 -0
  88. package/src/core/export/runtimes.generated.ts +12 -0
  89. package/src/core/export/site.ts +579 -0
  90. package/src/core/export/zip.ts +95 -0
  91. package/src/core/extensions/schema.ts +2 -1
  92. package/src/core/geo-trust.ts +18 -0
  93. package/src/core/history/diff.ts +25 -0
  94. package/src/core/icons/social.generated.ts +29 -0
  95. package/src/core/image-edit/schema.ts +2 -1
  96. package/src/core/import/elementor/atomic.ts +22 -9
  97. package/src/core/import/elementor/context.ts +18 -0
  98. package/src/core/import/elementor/index.ts +72 -11
  99. package/src/core/import/elementor/style.ts +21 -1
  100. package/src/core/import/elementor/widgets.ts +394 -133
  101. package/src/core/index.ts +14 -0
  102. package/src/core/issue-cap.ts +19 -0
  103. package/src/core/json-schema.ts +8 -1
  104. package/src/core/limits.ts +6 -0
  105. package/src/core/loop-collections.ts +33 -0
  106. package/src/core/perf/meter.ts +37 -19
  107. package/src/core/portable-text-export.ts +243 -0
  108. package/src/core/proposals.ts +8 -2
  109. package/src/core/public-attributes.ts +30 -0
  110. package/src/core/render/index.ts +115 -13
  111. package/src/core/render/tabs.ts +18 -11
  112. package/src/core/render/vnode.ts +44 -6
  113. package/src/core/sanitize/css.ts +26 -0
  114. package/src/core/sanitize/svg-upload.ts +276 -23
  115. package/src/core/sanitize/svg.ts +3 -3
  116. package/src/core/schema/descriptors.ts +4 -0
  117. package/src/core/schema/design.ts +8 -7
  118. package/src/core/schema/layout.ts +406 -18
  119. package/src/core/schema/style.ts +49 -1
  120. package/src/core/search-text.ts +70 -0
  121. package/src/core/shadowing-ids.ts +41 -0
  122. package/src/core/theme/conditions.ts +2 -1
  123. package/src/core/theme/float.ts +1 -0
  124. package/src/core/theme/parse-doc.ts +10 -5
  125. package/src/core/theme/popup-rules.ts +16 -0
  126. package/src/core/theme/triggers.ts +3 -2
  127. package/src/core/validate.ts +3 -2
  128. package/src/index.ts +23 -2
  129. package/src/mcp/ports.ts +18 -7
  130. package/src/mcp/proposals.ts +36 -11
  131. package/src/mcp/read.ts +2 -3
  132. package/src/mcp/tools.ts +1 -1
  133. package/src/server/agent-settings.ts +12 -1
  134. package/src/server/hooks.ts +41 -6
  135. package/src/server/icon-routes.ts +52 -12
  136. package/src/server/mcp-routes.ts +11 -5
  137. package/src/server/plugin.ts +27 -2
  138. package/src/server/presence.ts +5 -1
  139. package/src/server/proposals.ts +16 -4
  140. package/src/server/requests.ts +60 -11
  141. package/src/server/site-origin.ts +13 -0
  142. package/src/server/targets.ts +26 -0
@@ -1,4 +1,4 @@
1
- import type { PasteMode, Device, WrapType } from "../../core/index.ts";
1
+ import type { PasteMode, EditorDevice, WrapType } from "../../core/index.ts";
2
2
 
3
3
  /** Where an editor command is offered. Shortcuts call `runCommand` for the same ids. */
4
4
  export type CommandSurface = "palette" | "layers" | "overlay" | "device";
@@ -39,7 +39,7 @@ export type CommandRunners = {
39
39
  openTimeline?: () => void;
40
40
  openShare?: () => void;
41
41
  openWeight?: () => void;
42
- setDevice?: (device: Device) => void;
42
+ setDevice?: (device: EditorDevice) => void;
43
43
  openShortcuts?: () => void;
44
44
  rename?: () => void;
45
45
  /** Opens Save as section for an element (W-876). */
@@ -53,7 +53,7 @@ export type CommandInput = {
53
53
  targetId: string | null;
54
54
  isRoot: boolean;
55
55
  isParent: boolean;
56
- device: Device;
56
+ device: EditorDevice;
57
57
  /** Duplicate and wrap. False on the root and when nothing is selected. */
58
58
  canDuplicate: boolean;
59
59
  /** Delete and the sibling moves. False on the root. */
@@ -184,6 +184,7 @@ const SPECS: readonly Spec[] = [
184
184
  keywords: "performance budget size speed",
185
185
  surfaces: ["palette"],
186
186
  },
187
+ { id: "device-wide", labels: { palette: "View on wide screen" }, surfaces: ["palette"] },
187
188
  { id: "device-desktop", labels: { palette: "View on desktop" }, surfaces: ["palette"] },
188
189
  { id: "device-laptop", labels: { palette: "View on laptop" }, surfaces: ["palette"] },
189
190
  { id: "device-tablet", labels: { palette: "View on tablet" }, surfaces: ["palette"] },
@@ -232,6 +233,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
232
233
  "timeline",
233
234
  "share",
234
235
  "weight",
236
+ "device-wide",
235
237
  "device-desktop",
236
238
  "device-laptop",
237
239
  "device-tablet",
@@ -267,7 +269,8 @@ function blocked(id: string, input: CommandInput): boolean {
267
269
  }
268
270
 
269
271
  function labelFor(spec: Spec, input: CommandInput): string {
270
- if (spec.id === "hide-on-device") return `Hide on ${input.device}`;
272
+ if (spec.id === "hide-on-device")
273
+ return `Hide on ${input.device === "wide" ? "wide screen" : input.device}`;
271
274
  return spec.labels[input.surface] ?? spec.id;
272
275
  }
273
276
 
@@ -369,6 +372,9 @@ export function runCommand(runners: CommandRunners, id: string, targetId: string
369
372
  case "weight":
370
373
  runners.openWeight?.();
371
374
  return;
375
+ case "device-wide":
376
+ runners.setDevice?.("wide");
377
+ return;
372
378
  case "device-desktop":
373
379
  runners.setDevice?.("desktop");
374
380
  return;
@@ -502,7 +502,8 @@ iframe[data-emvb-canvas-focus="keyboard"] { outline: 2px solid var(--color-kumo-
502
502
  font-family: var(--font-sans); font-size: 12px; line-height: 16px;
503
503
  }
504
504
  .emvb-chip:hover { background: var(--color-kumo-recessed); }
505
- .emvb-chip[data-active="true"] { background: var(--color-kumo-brand); color: #fff; }
505
+ /* W-976: white on the plain brand blue was 4.48:1 (#076eff); a darker mix keeps it over 4.5:1. */
506
+ .emvb-chip[data-active="true"] { background: color-mix(in oklch, var(--color-kumo-brand), black 18%); color: #fff; }
506
507
  .emvb-chip[data-missing] { background: transparent; box-shadow: inset 0 0 0 1px var(--color-kumo-danger); }
507
508
  .emvb-chip[data-missing] .emvb-chip-main { cursor: default; }
508
509
  .emvb-chip-main {
@@ -5,6 +5,8 @@ import {
5
5
  BrowserIcon,
6
6
  BrowsersIcon,
7
7
  CalendarBlankIcon,
8
+ CardsIcon,
9
+ SlideshowIcon,
8
10
  CaretCircleDoubleDownIcon,
9
11
  CaretCircleDownIcon,
10
12
  CaretDownIcon,
@@ -12,9 +14,12 @@ import {
12
14
  CheckSquareIcon,
13
15
  ColumnsIcon,
14
16
  CursorClickIcon,
17
+ FrameCornersIcon,
15
18
  GraphIcon,
16
19
  GridFourIcon,
17
20
  ImageIcon,
21
+ ImagesIcon,
22
+ ImageSquareIcon,
18
23
  LinkIcon,
19
24
  ListBulletsIcon,
20
25
  ListIcon,
@@ -23,13 +28,18 @@ import {
23
28
  MinusIcon,
24
29
  NotePencilIcon,
25
30
  PaperPlaneRightIcon,
31
+ QuotesIcon,
26
32
  RadioButtonIcon,
27
33
  RepeatIcon,
28
34
  RowsIcon,
35
+ LinkSimpleIcon,
36
+ ShareNetworkIcon,
29
37
  SmileyIcon,
30
38
  SquareIcon,
31
39
  SquaresFourIcon,
40
+ SquareHalfBottomIcon,
32
41
  StackIcon,
42
+ StarIcon,
33
43
  TextAaIcon,
34
44
  TextAlignLeftIcon,
35
45
  TextboxIcon,
@@ -37,6 +47,7 @@ import {
37
47
  TextTIcon,
38
48
  UserIcon,
39
49
  VideoCameraIcon,
50
+ WarningCircleIcon,
40
51
  type Icon,
41
52
  } from "@phosphor-icons/react";
42
53
  import { ELEMENT_DESCRIPTORS } from "../../core/index.ts";
@@ -76,6 +87,17 @@ export const ELEMENT_ICONS: Record<string, Icon> = {
76
87
  "menu-item": CaretDownIcon,
77
88
  toc: ListNumbersIcon,
78
89
  "language-switcher": TranslateIcon,
90
+ rating: StarIcon,
91
+ alert: WarningCircleIcon,
92
+ "icon-box": SquareHalfBottomIcon,
93
+ "image-box": ImageSquareIcon,
94
+ testimonial: QuotesIcon,
95
+ "social-icons": ShareNetworkIcon,
96
+ "social-link": LinkSimpleIcon,
97
+ gallery: ImagesIcon,
98
+ "gallery-image": FrameCornersIcon,
99
+ carousel: SlideshowIcon,
100
+ "carousel-slide": CardsIcon,
79
101
  video: VideoCameraIcon,
80
102
  form: ArticleIcon,
81
103
  "text-input": TextboxIcon,
@@ -37,6 +37,7 @@ import {
37
37
  inheritedStyle,
38
38
  type LayoutNode,
39
39
  type Device,
40
+ type EditorDevice,
40
41
  type ResponsiveDevice,
41
42
  classStylesInListOrder,
42
43
  iconHasAdjustableStroke,
@@ -151,6 +152,14 @@ const NORMAL_ONLY_KEYS = new Set<StyleKey>([
151
152
  "scrollMotion",
152
153
  ]);
153
154
 
155
+ /** UX-063: which device is being edited and what it overrides (W-956 Laptop, W-959 Wide screen). */
156
+ const DEVICE_NOTE: Record<Exclude<EditorDevice, "desktop">, string> = {
157
+ wide: "Editing Wide screen (2400 px and up). These styles override Desktop.",
158
+ laptop: "Editing Laptop. These styles override Desktop.",
159
+ tablet: "Editing Tablet. These styles override Laptop and Desktop.",
160
+ mobile: "Editing Mobile. These styles override Tablet, Laptop and Desktop.",
161
+ };
162
+
154
163
  const JUMP_HELP: Record<Exclude<StyleStateChoice, "normal">, string> = {
155
164
  hover: "Changing size or position on hover can make the page jump.",
156
165
  focus: "Changing size or position on focus can make the page jump.",
@@ -220,7 +229,7 @@ type Props = {
220
229
  /** The chosen style state, for the canvas preview (W-089). */
221
230
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
222
231
  /** Tablet and mobile edit overrides. Desktop edits `style` (W-096). */
223
- device?: Device;
232
+ device?: EditorDevice;
224
233
  /** Add, move and delete for Accordion items and Tabs panels (W-130). */
225
234
  items?: ItemActions;
226
235
  /** The theme part being edited, if any, for the H1 warning (W-208). */
@@ -440,14 +449,18 @@ function KnownElementPanel({
440
449
  onStyleState?.(node.id, tab === "style" ? styleState : "normal");
441
450
  }, [node.id, styleState, tab, onStyleState]);
442
451
  // W-925: the rows read the flat motion keys; applyStylePatch nests them again.
443
- const normal = flattenMotion(cls ? cls.style : node.style);
452
+ // W-959: the own style's `wide` record is Wide screen's, not a Desktop value.
453
+ const { wide: storedWide, ...ownDesktop } = (cls ? cls.style : node.style) ?? {};
454
+ const normal = flattenMotion(cls || node.style ? ownDesktop : undefined);
444
455
  const states = cls ? cls.states : node.states;
445
- const responsive: ResponsiveDevice | null = device === "desktop" ? null : device;
456
+ const responsive: ResponsiveDevice | "wide" | null = device === "desktop" ? null : device;
446
457
  const storedDevices = cls ? cls.devices : node.devices;
447
- const ownerDevices = storedDevices && {
448
- laptop: flattenMotion(storedDevices.laptop),
449
- tablet: flattenMotion(storedDevices.tablet),
450
- mobile: flattenMotion(storedDevices.mobile),
458
+ const { hidden: _wideHidden, ...wideValues } = storedWide ?? {};
459
+ const ownerDevices = (storedDevices || storedWide) && {
460
+ wide: flattenMotion(storedWide ? wideValues : undefined),
461
+ laptop: flattenMotion(storedDevices?.laptop),
462
+ tablet: flattenMotion(storedDevices?.tablet),
463
+ mobile: flattenMotion(storedDevices?.mobile),
451
464
  };
452
465
  const style = responsive
453
466
  ? ownerDevices?.[responsive]
@@ -457,8 +470,9 @@ function KnownElementPanel({
457
470
  const ownInherited = responsive
458
471
  ? {
459
472
  ...normal,
460
- // W-956: each device inherits the wider ones: Laptop, then Tablet.
461
- ...(responsive !== "laptop" ? ownerDevices?.laptop : undefined),
473
+ // W-956: each device inherits the wider ones: Laptop, then Tablet. W-959: Wide screen
474
+ // builds on Desktop only.
475
+ ...(responsive !== "laptop" && responsive !== "wide" ? ownerDevices?.laptop : undefined),
462
476
  ...(responsive === "mobile" ? ownerDevices?.tablet : undefined),
463
477
  }
464
478
  : styleState === "normal"
@@ -497,6 +511,8 @@ function KnownElementPanel({
497
511
  !singleColorOffered &&
498
512
  node.props.singleColor !== true &&
499
513
  ownColors;
514
+ // Field values have no laptop or wide screen setting: those devices edit Desktop's.
515
+ const fieldDevice: Device = device === "laptop" || device === "wide" ? "desktop" : device;
500
516
  const patchStyle = (patch: Partial<FlatStyleProps>) => {
501
517
  const written = applyStylePatch({
502
518
  node,
@@ -592,7 +608,7 @@ function KnownElementPanel({
592
608
  />
593
609
  {tab === "content" && (
594
610
  <div className="emvb-panel-body" data-emvb-tab="content">
595
- {hasItemList(node.type) ? (
611
+ {hasItemList(node.type) && descriptor.fields.length === 0 ? (
596
612
  <ItemList node={node} onChange={onChange} onSelect={onSelect} actions={items} />
597
613
  ) : descriptor.fields.length === 0 ? (
598
614
  <p className="emvb-helper">
@@ -602,7 +618,7 @@ function KnownElementPanel({
602
618
  </p>
603
619
  ) : (
604
620
  pairFields(
605
- descriptor.fields.filter((field) => fieldShown(field.key, node, device)),
621
+ descriptor.fields.filter((field) => fieldShown(field.key, node, fieldDevice)),
606
622
  ).map((row) => {
607
623
  const controls = row.map((field) => (
608
624
  <React.Fragment key={field.key}>
@@ -615,8 +631,7 @@ function KnownElementPanel({
615
631
  duplicateName={
616
632
  field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
617
633
  }
618
- // Field values have no laptop setting: Laptop edits the desktop value.
619
- device={device === "laptop" ? "desktop" : device}
634
+ device={fieldDevice}
620
635
  />
621
636
  </React.Fragment>
622
637
  ));
@@ -629,6 +644,10 @@ function KnownElementPanel({
629
644
  );
630
645
  })
631
646
  )}
647
+ {/* W-1024: an element with its own settings lists its items after them. */}
648
+ {hasItemList(node.type) && descriptor.fields.length > 0 && (
649
+ <ItemList node={node} onChange={onChange} onSelect={onSelect} actions={items} />
650
+ )}
632
651
  <BindingsEditor node={node} onChange={onChange} post={SAMPLE_POST} />
633
652
  <AudienceEditor node={node} isRoot={layout?.root.id === node.id} onChange={onChange} />
634
653
  <VariantEditor
@@ -709,10 +728,8 @@ function KnownElementPanel({
709
728
  ) : (
710
729
  // UX-063: say which device is being edited, as states say "Editing Hover".
711
730
  <p className="emvb-helper" data-emvb-device-note={device}>
712
- {device === "mobile"
713
- ? "Editing Mobile. These styles override Tablet and Desktop."
714
- : "Editing Tablet. These styles override Desktop."}{" "}
715
- Hover, Focus and Active are set on Desktop and apply on every device.
731
+ {DEVICE_NOTE[device]} Hover, Focus and Active are set on Desktop and apply on every
732
+ device.
716
733
  </p>
717
734
  )}
718
735
  {!cls && <StyleSources node={node} design={design} device={device} state={styleState} />}
@@ -1,6 +1,6 @@
1
1
  import type * as React from "react";
2
2
  import type { Deletion } from "../restore-deleted.ts";
3
- import type { DesignSystem, LayoutNode, Device } from "../../../core/index.ts";
3
+ import type { DesignSystem, LayoutNode, EditorDevice } from "../../../core/index.ts";
4
4
  import type { Fetcher } from "../../api.ts";
5
5
  import type { EditorAction, EditorState } from "../store.ts";
6
6
  import { ElementPanel } from "./ElementPanel.tsx";
@@ -54,7 +54,7 @@ export function SettingsPanel({
54
54
  /** The Style tab's chosen state, for the canvas preview (W-089). */
55
55
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
56
56
  /** Which device's styles the Style tab edits (W-096). */
57
- device?: Device;
57
+ device?: EditorDevice;
58
58
  /** Accordion and Tabs item actions (W-130). */
59
59
  items?: ItemActions;
60
60
  }) {
@@ -32,7 +32,7 @@ function CommitInput({
32
32
  label: string;
33
33
  className: string;
34
34
  description?: string;
35
- inputMode?: "numeric";
35
+ inputMode?: "numeric" | "decimal";
36
36
  fieldKey: string;
37
37
  draft: string;
38
38
  error: string | null;
@@ -174,6 +174,38 @@ export function DraftTextField({
174
174
  );
175
175
  }
176
176
 
177
+ if (field.kind === "decimal") {
178
+ // W-1023: a plain number such as 4.5; its maximum may come from another prop (Stars).
179
+ const min = field.min ?? 0;
180
+ const fromProp = field.maxProp ? props[field.maxProp] : undefined;
181
+ const max = typeof fromProp === "number" ? fromProp : field.max;
182
+ const commit = () => {
183
+ if (commitClearable()) return;
184
+ const value = fieldNumber(draft);
185
+ if (!Number.isFinite(value) || value < min || (max !== undefined && value > max)) {
186
+ setError(
187
+ field.message ??
188
+ (max === undefined ? `Enter ${min} or more.` : `Enter a number from ${min} to ${max}.`),
189
+ );
190
+ return;
191
+ }
192
+ setError(null);
193
+ onChange(withProp(node, field.key, value));
194
+ };
195
+ return (
196
+ <CommitInput
197
+ label={field.label}
198
+ className={`${FIELD} emvb-mono`}
199
+ inputMode="decimal"
200
+ fieldKey={field.key}
201
+ draft={draft}
202
+ error={error}
203
+ setDraft={setDraft}
204
+ commit={commit}
205
+ />
206
+ );
207
+ }
208
+
177
209
  if (field.kind === "int" || field.kind === "number") {
178
210
  const integer = field.kind === "int";
179
211
  const unit =
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Button, Select } from "@cloudflare/kumo";
3
- import { PlusIcon } from "@phosphor-icons/react";
3
+ import { PencilSimpleIcon, PlusIcon } from "@phosphor-icons/react";
4
4
  import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
5
5
  import { BUTTON, FIELD } from "../../../ui.ts";
6
6
  import { ColorControl } from "../ColorControl.tsx";
@@ -12,6 +12,57 @@ type Transition = NonNullable<FlatStyleProps["transition"]>;
12
12
  type Entrance = NonNullable<FlatStyleProps["entrance"]>;
13
13
 
14
14
  /** DESIGN.md: Add shadow starts at 0 4 12 0, 18 % black. */
15
+ /**
16
+ * W-969: a composite style (shadow, entrance, transition, drop shadow) that is unset here but
17
+ * inherited (from a wider device, the Normal state, a class or the Site styles default) says what
18
+ * it inherits, and Edit here starts from that value instead of the default.
19
+ */
20
+ export function InheritedStart({
21
+ summary,
22
+ label,
23
+ onEdit,
24
+ }: {
25
+ summary: string;
26
+ label: string;
27
+ onEdit: () => void;
28
+ }) {
29
+ return (
30
+ <>
31
+ <p className="emvb-helper" data-emvb-inherited-note="">
32
+ Inherited: {summary}.
33
+ </p>
34
+ <Button
35
+ type="button"
36
+ variant="secondary"
37
+ className={`${BUTTON} emvb-add-shadow`}
38
+ icon={<PencilSimpleIcon aria-hidden="true" />}
39
+ onClick={onEdit}
40
+ aria-label={`Edit ${label} here`}
41
+ >
42
+ Edit here
43
+ </Button>
44
+ </>
45
+ );
46
+ }
47
+
48
+ const hexOf = (color: unknown) =>
49
+ typeof color === "string"
50
+ ? color
51
+ : color && typeof color === "object" && "var" in color
52
+ ? `variable ${String((color as { var: unknown }).var)}`
53
+ : "";
54
+
55
+ export const shadowSummary = (s: {
56
+ x: number;
57
+ y: number;
58
+ blur: number;
59
+ spread?: number;
60
+ color?: unknown;
61
+ }) =>
62
+ [`${s.x} ${s.y} ${s.blur}${s.spread !== undefined ? ` ${s.spread}` : ""} px`, hexOf(s.color)]
63
+ .filter(Boolean)
64
+ .join(", ");
65
+
15
66
  const NEW_SHADOW: Shadow = { x: 0, y: 4, blur: 12, spread: 0, color: "#0000002e" };
16
67
 
17
68
  const OFFSET: NumberSpec = { min: -1000, max: 1000, example: "4" };
@@ -27,12 +78,14 @@ const SHADOW_FIELDS: ReadonlyArray<
27
78
  /** One box shadow: Add shadow when unset; X, Y, blur, spread, colour and inset when set. */
28
79
  export function ShadowControl({
29
80
  value,
81
+ inherited,
30
82
  design,
31
83
  onChange,
32
84
  onDesignChange,
33
85
  reset,
34
86
  }: {
35
87
  value: Shadow | undefined;
88
+ inherited?: Shadow | undefined;
36
89
  design: DesignSystem;
37
90
  onChange: (next: Shadow | undefined) => void;
38
91
  onDesignChange: (design: DesignSystem) => Promise<void>;
@@ -49,6 +102,7 @@ export function ShadowControl({
49
102
  className="emvb-style-row"
50
103
  data-emvb-style="boxShadow"
51
104
  data-set={value ? "true" : undefined}
105
+ data-inherited={!value && inherited ? "true" : undefined}
52
106
  >
53
107
  <div className="emvb-field-group emvb-shadow">
54
108
  <span className="emvb-var-field-label">Box shadow</span>
@@ -88,6 +142,12 @@ export function ShadowControl({
88
142
  ))}
89
143
  </div>
90
144
  </>
145
+ ) : inherited ? (
146
+ <InheritedStart
147
+ summary={shadowSummary(inherited)}
148
+ label="box shadow"
149
+ onEdit={() => onChange({ ...inherited })}
150
+ />
91
151
  ) : (
92
152
  <Button
93
153
  type="button"
@@ -335,10 +395,12 @@ const ENTRANCE_TYPES: { value: Entrance["type"]; label: string }[] = [
335
395
  /** Plays once on load (W-101, Normal only). Add entrance starts at Fade, 400 ms. */
336
396
  export function EntranceControl({
337
397
  value,
398
+ inherited,
338
399
  onChange,
339
400
  reset,
340
401
  }: {
341
402
  value: Entrance | undefined;
403
+ inherited?: Entrance | undefined;
342
404
  onChange: (next: Entrance | undefined) => void;
343
405
  reset: React.ReactNode;
344
406
  }) {
@@ -347,6 +409,7 @@ export function EntranceControl({
347
409
  className="emvb-style-row"
348
410
  data-emvb-style="entrance"
349
411
  data-set={value ? "true" : undefined}
412
+ data-inherited={!value && inherited ? "true" : undefined}
350
413
  >
351
414
  <div className="emvb-field-group emvb-transition">
352
415
  <span className="emvb-var-field-label">Entrance</span>
@@ -385,6 +448,12 @@ export function EntranceControl({
385
448
  }
386
449
  />
387
450
  </>
451
+ ) : inherited ? (
452
+ <InheritedStart
453
+ summary={`${ENTRANCE_TYPES.find((t) => t.value === inherited.type)?.label ?? inherited.type}, ${inherited.duration} ms`}
454
+ label="entrance"
455
+ onEdit={() => onChange({ ...inherited })}
456
+ />
388
457
  ) : (
389
458
  <Button
390
459
  type="button"
@@ -405,10 +474,12 @@ export function EntranceControl({
405
474
  /** One transition (W-089, Normal only): Add transition when unset; duration, delay, easing, property when set. */
406
475
  export function TransitionControl({
407
476
  value,
477
+ inherited,
408
478
  onChange,
409
479
  reset,
410
480
  }: {
411
481
  value: Transition | undefined;
482
+ inherited?: Transition | undefined;
412
483
  onChange: (next: Transition | undefined) => void;
413
484
  reset: React.ReactNode;
414
485
  }) {
@@ -423,6 +494,7 @@ export function TransitionControl({
423
494
  className="emvb-style-row"
424
495
  data-emvb-style="transition"
425
496
  data-set={value ? "true" : undefined}
497
+ data-inherited={!value && inherited ? "true" : undefined}
426
498
  >
427
499
  <div className="emvb-field-group emvb-transition">
428
500
  <span className="emvb-var-field-label">Transition</span>
@@ -457,6 +529,12 @@ export function TransitionControl({
457
529
  onChange={(property) => patch({ property })}
458
530
  />
459
531
  </>
532
+ ) : inherited ? (
533
+ <InheritedStart
534
+ summary={`${inherited.duration} ms, ${EASINGS.find((e) => e.value === inherited.easing)?.label ?? inherited.easing}`}
535
+ label="transition"
536
+ onEdit={() => onChange({ ...inherited })}
537
+ />
460
538
  ) : (
461
539
  <Button
462
540
  type="button"
@@ -120,7 +120,12 @@ export function FieldBindControl({
120
120
  return field ? fieldLabel(field) : CHOOSE;
121
121
  }}
122
122
  >
123
- {!known && <Select.Option value={MANUAL}>{CHOOSE}</Select.Option>}
123
+ {/* W-994: always listed (disabled once a field is picked). Kumo 2.15's Select maps a
124
+ click to an option by its index, so an option that came and went picked the wrong
125
+ field. */}
126
+ <Select.Option value={MANUAL} disabled={known}>
127
+ {CHOOSE}
128
+ </Select.Option>
124
129
  {fields.map((field) => (
125
130
  <Select.Option key={field.name} value={field.name}>
126
131
  {fieldLabel(field)}
@@ -103,7 +103,15 @@ export function FieldControl({
103
103
  }
104
104
 
105
105
  if (field.kind === "icon") {
106
- return <IconPicker key={field.key} node={node} fetcher={fetcher} onChange={onChange} />;
106
+ return (
107
+ <IconPicker
108
+ key={field.key}
109
+ node={node}
110
+ fetcher={fetcher}
111
+ onChange={onChange}
112
+ optional={field.optional === true}
113
+ />
114
+ );
107
115
  }
108
116
 
109
117
  if (field.kind === "marks") {
@@ -294,6 +302,7 @@ export const IMPLEMENTED_FIELD_KINDS = [
294
302
  "textarea",
295
303
  "number",
296
304
  "int",
305
+ "decimal",
297
306
  "select",
298
307
  "boolean",
299
308
  "href",
@@ -10,6 +10,7 @@ import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
10
10
  import { BUTTON, FIELD } from "../../../ui.ts";
11
11
  import { ColorControl } from "../ColorControl.tsx";
12
12
  import { radioGroupKeys } from "./ChoiceGroup.tsx";
13
+ import { InheritedStart, shadowSummary } from "./EffectsControls.tsx";
13
14
  import { NumberField, ResetButton, type NumberSpec } from "./NumberRow.tsx";
14
15
  import { HintedSwitch } from "./HintedSwitch.tsx";
15
16
 
@@ -146,11 +147,14 @@ const ICON_SHADOW_FIELDS: ReadonlyArray<[key: "x" | "y" | "blur", label: string,
146
147
 
147
148
  export function IconShadowControl({
148
149
  value,
150
+ inherited,
149
151
  design,
150
152
  onChange,
151
153
  onDesignChange,
152
154
  }: {
153
155
  value: IconShadow | undefined;
156
+ /** W-969: the drop shadow this device or state inherits, shown and used by Edit here. */
157
+ inherited?: IconShadow | undefined;
154
158
  design: DesignSystem;
155
159
  onChange: (next: IconShadow | undefined) => void;
156
160
  onDesignChange: (design: DesignSystem) => Promise<void>;
@@ -166,6 +170,7 @@ export function IconShadowControl({
166
170
  className="emvb-style-row"
167
171
  data-emvb-style="iconShadow"
168
172
  data-set={value ? "true" : undefined}
173
+ data-inherited={!value && inherited ? "true" : undefined}
169
174
  >
170
175
  <div className="emvb-field-group emvb-shadow">
171
176
  <span className="emvb-var-field-label">Drop shadow</span>
@@ -191,6 +196,12 @@ export function IconShadowControl({
191
196
  ))}
192
197
  </div>
193
198
  </>
199
+ ) : inherited ? (
200
+ <InheritedStart
201
+ summary={shadowSummary(inherited)}
202
+ label="drop shadow"
203
+ onEdit={() => onChange({ ...inherited })}
204
+ />
194
205
  ) : (
195
206
  <Button
196
207
  type="button"
@@ -87,11 +87,14 @@ export function IconPicker({
87
87
  node,
88
88
  fetcher,
89
89
  onChange,
90
+ optional = node.type === "button",
90
91
  }: {
91
92
  node: LayoutNode;
92
93
  /** Enables My uploads in the library (W-239). */
93
94
  fetcher?: Fetcher;
94
95
  onChange: (node: LayoutNode) => void;
96
+ /** W-1020: only an optional icon (a Button's) can be removed; an Icon box needs one. */
97
+ optional?: boolean;
95
98
  }) {
96
99
  const props = propsOf(node);
97
100
  const current = typeof props.iconId === "string" ? props.iconId : "";
@@ -124,7 +127,7 @@ export function IconPicker({
124
127
  onChange(withProps(node, patch));
125
128
  };
126
129
  // W-387: a Button's icon is optional, so it can be taken off again.
127
- const removable = node.type !== "icon" && (current !== "" || typeof props.iconSvg === "string");
130
+ const removable = optional && (current !== "" || typeof props.iconSvg === "string");
128
131
  const remove = () => {
129
132
  const { iconId: _id, iconSvg: _svg, ...rest } = propsOf(node);
130
133
  onChange({ ...node, props: rest } as LayoutNode);
@@ -7,9 +7,22 @@ import {
7
7
  PlusIcon,
8
8
  TrashIcon,
9
9
  } from "@phosphor-icons/react";
10
- import { MAX_TABS, type FieldDescriptor, type LayoutNode } from "../../../../core/index.ts";
10
+ import {
11
+ MAX_CAROUSEL_SLIDES,
12
+ MAX_GALLERY_IMAGES,
13
+ MAX_SOCIAL_LINKS,
14
+ MAX_TABS,
15
+ type FieldDescriptor,
16
+ type LayoutNode,
17
+ } from "../../../../core/index.ts";
11
18
  import { BUTTON } from "../../../ui.ts";
12
- import { newAccordionItem, newTabPanel } from "../../dnd/new-element.ts";
19
+ import {
20
+ newAccordionItem,
21
+ newCarouselSlide,
22
+ newGalleryImage,
23
+ newSocialLink,
24
+ newTabPanel,
25
+ } from "../../dnd/new-element.ts";
13
26
  import { DraftTextField } from "./DraftTextField.tsx";
14
27
 
15
28
  /** Layout operations the list runs through the editor, so limits, history and Restore apply. */
@@ -39,6 +52,27 @@ const KINDS: Record<string, Kind> = {
39
52
  make: (n) => newTabPanel(n),
40
53
  max: MAX_TABS,
41
54
  },
55
+ // W-1024: each row edits the link's address; its network and name are in its own panel.
56
+ "social-icons": {
57
+ noun: "link",
58
+ field: (n) => ({ key: "href", kind: "href", label: `Link ${n} address` }),
59
+ make: (n) => newSocialLink(n),
60
+ max: MAX_SOCIAL_LINKS,
61
+ },
62
+ // W-1019: each row edits the picture's alt text; the picture itself is chosen in its panel.
63
+ gallery: {
64
+ noun: "picture",
65
+ field: (n) => ({ key: "alt", kind: "text", label: `Picture ${n} alt text` }),
66
+ make: () => newGalleryImage(),
67
+ max: MAX_GALLERY_IMAGES,
68
+ },
69
+ // W-1018: each row names a slide; its content is edited on the canvas.
70
+ carousel: {
71
+ noun: "slide",
72
+ field: (n) => ({ key: "label", kind: "text", label: `Slide ${n} name`, optional: true }),
73
+ make: (n) => newCarouselSlide(n),
74
+ max: MAX_CAROUSEL_SLIDES,
75
+ },
42
76
  };
43
77
 
44
78
  /** True for the elements whose Content tab is a list of their items (W-130). */