@perkyzz/emvb 0.0.0-stage → 0.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 (217) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/THIRD_PARTY_NOTICES.md +32 -0
  4. package/licenses/fontawesome-free.LICENSE +165 -0
  5. package/licenses/lucide-static.LICENSE +43 -0
  6. package/licenses/remixicon.LICENSE +201 -0
  7. package/licenses/tabler-icons.LICENSE +21 -0
  8. package/package.json +76 -4
  9. package/src/admin/access/RequireEditor.tsx +39 -0
  10. package/src/admin/access/role.ts +36 -0
  11. package/src/admin/access/sidebar-shim.ts +108 -0
  12. package/src/admin/api.ts +75 -0
  13. package/src/admin/content-api.ts +210 -0
  14. package/src/admin/editor/Editor.tsx +532 -0
  15. package/src/admin/editor/EditorOverlay.tsx +66 -0
  16. package/src/admin/editor/ShortcutsDialog.tsx +30 -0
  17. package/src/admin/editor/SmallScreenNotice.tsx +21 -0
  18. package/src/admin/editor/TopBar.tsx +243 -0
  19. package/src/admin/editor/canvas/CanvasFrame.tsx +536 -0
  20. package/src/admin/editor/canvas/CanvasTextEdit.tsx +87 -0
  21. package/src/admin/editor/canvas/DeviceBar.tsx +91 -0
  22. package/src/admin/editor/canvas/EmptyCanvas.tsx +49 -0
  23. package/src/admin/editor/canvas/SelectionOverlay.tsx +239 -0
  24. package/src/admin/editor/canvas/canvas-events.ts +245 -0
  25. package/src/admin/editor/canvas/state-preview.ts +19 -0
  26. package/src/admin/editor/canvas/tab-reveal.ts +101 -0
  27. package/src/admin/editor/canvas/vnode-react.tsx +69 -0
  28. package/src/admin/editor/clipboard-store.ts +44 -0
  29. package/src/admin/editor/dialogs.tsx +164 -0
  30. package/src/admin/editor/dnd/drag-stash.ts +27 -0
  31. package/src/admin/editor/dnd/drop-target.ts +148 -0
  32. package/src/admin/editor/dnd/new-element.ts +107 -0
  33. package/src/admin/editor/editor-css.ts +625 -0
  34. package/src/admin/editor/exit.ts +27 -0
  35. package/src/admin/editor/host.ts +30 -0
  36. package/src/admin/editor/icons/IconLibraryDialog.tsx +850 -0
  37. package/src/admin/editor/icons/library.ts +243 -0
  38. package/src/admin/editor/icons/set-format.ts +29 -0
  39. package/src/admin/editor/icons/sets/fontawesome.json +1 -0
  40. package/src/admin/editor/icons/sets/lucide.json +1 -0
  41. package/src/admin/editor/icons/sets/remix.json +1 -0
  42. package/src/admin/editor/icons/sets/tabler.json +1 -0
  43. package/src/admin/editor/panels/AddPanel.tsx +146 -0
  44. package/src/admin/editor/panels/ClassesSection.tsx +372 -0
  45. package/src/admin/editor/panels/ColorControl.tsx +477 -0
  46. package/src/admin/editor/panels/ConditionsEditor.tsx +201 -0
  47. package/src/admin/editor/panels/ElementPanel.tsx +773 -0
  48. package/src/admin/editor/panels/LayersPanel.tsx +573 -0
  49. package/src/admin/editor/panels/LeftPanel.tsx +81 -0
  50. package/src/admin/editor/panels/PageSettings.tsx +255 -0
  51. package/src/admin/editor/panels/SettingsPanel.tsx +113 -0
  52. package/src/admin/editor/panels/SiteStylesDrawer.tsx +548 -0
  53. package/src/admin/editor/panels/TriggerSettings.tsx +132 -0
  54. package/src/admin/editor/panels/TriggersEditor.tsx +214 -0
  55. package/src/admin/editor/panels/VariableSection.tsx +530 -0
  56. package/src/admin/editor/panels/color-space.ts +195 -0
  57. package/src/admin/editor/panels/settings/AdvancedFields.tsx +119 -0
  58. package/src/admin/editor/panels/settings/BackgroundControls.tsx +418 -0
  59. package/src/admin/editor/panels/settings/BackgroundFill.tsx +221 -0
  60. package/src/admin/editor/panels/settings/BoxControl.tsx +271 -0
  61. package/src/admin/editor/panels/settings/ChoiceGroup.tsx +138 -0
  62. package/src/admin/editor/panels/settings/ClassChip.tsx +167 -0
  63. package/src/admin/editor/panels/settings/ClassChipInput.tsx +451 -0
  64. package/src/admin/editor/panels/settings/DraftTextField.tsx +242 -0
  65. package/src/admin/editor/panels/settings/EffectsControls.tsx +354 -0
  66. package/src/admin/editor/panels/settings/FieldBindControl.tsx +119 -0
  67. package/src/admin/editor/panels/settings/FieldControl.tsx +270 -0
  68. package/src/admin/editor/panels/settings/FormBindControl.tsx +106 -0
  69. package/src/admin/editor/panels/settings/IconControls.tsx +438 -0
  70. package/src/admin/editor/panels/settings/IconPicker.tsx +170 -0
  71. package/src/admin/editor/panels/settings/ItemList.tsx +199 -0
  72. package/src/admin/editor/panels/settings/LengthRow.tsx +217 -0
  73. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +130 -0
  74. package/src/admin/editor/panels/settings/MediaPicker.tsx +220 -0
  75. package/src/admin/editor/panels/settings/NumberRow.tsx +154 -0
  76. package/src/admin/editor/panels/settings/StateSwitcher.tsx +87 -0
  77. package/src/admin/editor/panels/settings/StyleRow.tsx +563 -0
  78. package/src/admin/editor/panels/settings/VariableBinding.tsx +171 -0
  79. package/src/admin/editor/panels/settings/advanced-rules.ts +63 -0
  80. package/src/admin/editor/panels/settings/background-mode.ts +112 -0
  81. package/src/admin/editor/panels/settings/box-link-name.ts +38 -0
  82. package/src/admin/editor/panels/settings/box-sides.ts +153 -0
  83. package/src/admin/editor/panels/settings/button-url.ts +27 -0
  84. package/src/admin/editor/panels/settings/class-suggest.ts +53 -0
  85. package/src/admin/editor/panels/settings/form-names.ts +38 -0
  86. package/src/admin/editor/panels/settings/heading-warning.ts +25 -0
  87. package/src/admin/editor/panels/settings/image-alt.ts +25 -0
  88. package/src/admin/editor/panels/settings/length-units.ts +116 -0
  89. package/src/admin/editor/panels/settings/loop-context.ts +26 -0
  90. package/src/admin/editor/panels/settings/node-props.ts +11 -0
  91. package/src/admin/editor/panels/settings/style-sections.ts +394 -0
  92. package/src/admin/editor/panels/settings/svg-images.ts +14 -0
  93. package/src/admin/editor/panels/site-list.tsx +209 -0
  94. package/src/admin/editor/panels/variable-values.ts +73 -0
  95. package/src/admin/editor/restore-deleted.ts +80 -0
  96. package/src/admin/editor/section-templates.ts +50 -0
  97. package/src/admin/editor/shortcuts.ts +20 -0
  98. package/src/admin/editor/store.ts +240 -0
  99. package/src/admin/editor/useClipboardActions.ts +136 -0
  100. package/src/admin/editor/useEditorCommands.ts +203 -0
  101. package/src/admin/editor/useEditorData.ts +193 -0
  102. package/src/admin/editor/useEditorShortcuts.ts +180 -0
  103. package/src/admin/editor/useMediaQuery.ts +20 -0
  104. package/src/admin/editor/useNodeActions.ts +184 -0
  105. package/src/admin/editor/useSave.ts +242 -0
  106. package/src/admin/entry-status.ts +19 -0
  107. package/src/admin/forms-api.ts +73 -0
  108. package/src/admin/icon-uploads-api.ts +44 -0
  109. package/src/admin/index.tsx +20 -0
  110. package/src/admin/media-api.ts +68 -0
  111. package/src/admin/pages/CreateDialog.tsx +150 -0
  112. package/src/admin/pages/EditorPage.tsx +57 -0
  113. package/src/admin/pages/NewPageDialog.tsx +83 -0
  114. package/src/admin/pages/NewThemePartDialog.tsx +61 -0
  115. package/src/admin/pages/PageList.tsx +91 -0
  116. package/src/admin/pages/PagesPage.tsx +25 -0
  117. package/src/admin/pages/SetupShell.tsx +90 -0
  118. package/src/admin/pages/ThemeBuilderPage.tsx +25 -0
  119. package/src/admin/pages/ThemePartList.tsx +221 -0
  120. package/src/admin/pages/list-kit.tsx +125 -0
  121. package/src/admin/setup/plan.ts +150 -0
  122. package/src/admin/setup/run.ts +61 -0
  123. package/src/admin/setup/spec.ts +107 -0
  124. package/src/admin/setup/useSetupStatus.ts +62 -0
  125. package/src/admin/theme-api.ts +233 -0
  126. package/src/admin/ui.ts +244 -0
  127. package/src/admin/widgets/LayoutField.tsx +67 -0
  128. package/src/astro/EmVBPage.astro +63 -0
  129. package/src/astro/env.d.ts +5 -0
  130. package/src/astro/floats/EmVBFloatsRuntime.astro +9 -0
  131. package/src/astro/floats/index.ts +1 -0
  132. package/src/astro/floats/runtime.ts +78 -0
  133. package/src/astro/forms/EmVBFormsRuntime.astro +9 -0
  134. package/src/astro/forms/index.ts +1 -0
  135. package/src/astro/forms-definitions.ts +126 -0
  136. package/src/astro/index.ts +16 -0
  137. package/src/astro/menu/EmVBMenuRuntime.astro +9 -0
  138. package/src/astro/menu/index.ts +1 -0
  139. package/src/astro/menu/runtime.ts +37 -0
  140. package/src/astro/popups/EmVBPopupsRuntime.astro +9 -0
  141. package/src/astro/popups/index.ts +1 -0
  142. package/src/astro/popups/runtime.ts +296 -0
  143. package/src/astro/render.ts +108 -0
  144. package/src/astro/resolve-theme.ts +515 -0
  145. package/src/astro/resolve.ts +65 -0
  146. package/src/astro/tabs/EmVBTabsRuntime.astro +10 -0
  147. package/src/astro/tabs/index.ts +1 -0
  148. package/src/astro/tabs/runtime.ts +116 -0
  149. package/src/astro/theme-context.ts +89 -0
  150. package/src/astro/theme-posts.ts +84 -0
  151. package/src/constants.ts +12 -0
  152. package/src/core/arrange.ts +448 -0
  153. package/src/core/clipboard.ts +504 -0
  154. package/src/core/css/generate.ts +236 -0
  155. package/src/core/css/scope.ts +88 -0
  156. package/src/core/design/cascade.ts +28 -0
  157. package/src/core/design/classes.ts +224 -0
  158. package/src/core/design/devices.ts +56 -0
  159. package/src/core/design/states.ts +49 -0
  160. package/src/core/design/transfer.ts +132 -0
  161. package/src/core/design/variables.ts +359 -0
  162. package/src/core/elements/definition.ts +12 -0
  163. package/src/core/elements/dynamic-elements.ts +225 -0
  164. package/src/core/elements/field-id.ts +6 -0
  165. package/src/core/elements/form-elements.ts +219 -0
  166. package/src/core/elements/index.ts +960 -0
  167. package/src/core/elements/menu.ts +190 -0
  168. package/src/core/elements/plain-text.ts +32 -0
  169. package/src/core/forms/binding.ts +61 -0
  170. package/src/core/forms/definition.ts +45 -0
  171. package/src/core/forms/success-layout.ts +63 -0
  172. package/src/core/icons/catalog.ts +273 -0
  173. package/src/core/index.ts +380 -0
  174. package/src/core/limits.ts +9 -0
  175. package/src/core/migrate/index.ts +126 -0
  176. package/src/core/nesting.ts +51 -0
  177. package/src/core/render/context.ts +21 -0
  178. package/src/core/render/dynamic-post.ts +175 -0
  179. package/src/core/render/extras.ts +98 -0
  180. package/src/core/render/form.ts +235 -0
  181. package/src/core/render/index.ts +372 -0
  182. package/src/core/render/loop.ts +43 -0
  183. package/src/core/render/pagination.ts +76 -0
  184. package/src/core/render/section.ts +37 -0
  185. package/src/core/render/tabs.ts +76 -0
  186. package/src/core/render/vnode.ts +87 -0
  187. package/src/core/sanitize/css.ts +771 -0
  188. package/src/core/sanitize/embed-url.ts +160 -0
  189. package/src/core/sanitize/escape.ts +10 -0
  190. package/src/core/sanitize/href.ts +6 -0
  191. package/src/core/sanitize/media-url.ts +7 -0
  192. package/src/core/sanitize/svg-upload.ts +203 -0
  193. package/src/core/sanitize/svg.ts +374 -0
  194. package/src/core/sanitize/url.ts +31 -0
  195. package/src/core/schema/descriptors.ts +37 -0
  196. package/src/core/schema/design.ts +93 -0
  197. package/src/core/schema/layout.ts +1008 -0
  198. package/src/core/schema/state-names.ts +4 -0
  199. package/src/core/schema/style.ts +336 -0
  200. package/src/core/stats.ts +18 -0
  201. package/src/core/tabs/presence.ts +25 -0
  202. package/src/core/theme/conditions.ts +324 -0
  203. package/src/core/theme/dynamic.ts +143 -0
  204. package/src/core/theme/float.ts +113 -0
  205. package/src/core/theme/pagination.ts +97 -0
  206. package/src/core/theme/parse-doc.ts +36 -0
  207. package/src/core/theme/part-types.ts +81 -0
  208. package/src/core/theme/popup-markup.ts +41 -0
  209. package/src/core/theme/popup-rules.ts +62 -0
  210. package/src/core/theme/triggers.ts +104 -0
  211. package/src/core/tree-ops.ts +139 -0
  212. package/src/core/validate.ts +185 -0
  213. package/src/index.ts +18 -0
  214. package/src/server/design-routes.ts +125 -0
  215. package/src/server/hooks.ts +118 -0
  216. package/src/server/icon-routes.ts +79 -0
  217. package/src/server/plugin.ts +43 -0
@@ -0,0 +1,563 @@
1
+ import { Input, Select } from "@cloudflare/kumo";
2
+ import { isSafeFontStack, type DesignSystem, type StyleProps } from "../../../../core/index.ts";
3
+ import type { Fetcher } from "../../../api.ts";
4
+ import { FIELD } from "../../../ui.ts";
5
+ import { ColorControl } from "../ColorControl.tsx";
6
+ import { BackgroundFill } from "./BackgroundFill.tsx";
7
+ import { STYLE_LABELS, type StyleKey } from "./style-sections.ts";
8
+ import { ChoiceGroup, LAYOUT_CHOICES } from "./ChoiceGroup.tsx";
9
+ import { LengthRow } from "./LengthRow.tsx";
10
+ import {
11
+ EntranceControl,
12
+ FiltersControl,
13
+ ShadowControl,
14
+ TransitionControl,
15
+ } from "./EffectsControls.tsx";
16
+ import {
17
+ ICON_SCALE,
18
+ ICON_STROKE,
19
+ IconAnimationControl,
20
+ IconFlipRow,
21
+ IconRotateRow,
22
+ IconShadowControl,
23
+ } from "./IconControls.tsx";
24
+ import { NumberRow, ResetButton, type NumberSpec } from "./NumberRow.tsx";
25
+ import { boundRef, VariableButton, VariableChip } from "./VariableBinding.tsx";
26
+
27
+ const LENGTH_KEYS = new Set<StyleKey>([
28
+ "gap",
29
+ "width",
30
+ "minWidth",
31
+ "maxWidth",
32
+ "height",
33
+ "minHeight",
34
+ "maxHeight",
35
+ "paddingTop",
36
+ "paddingRight",
37
+ "paddingBottom",
38
+ "paddingLeft",
39
+ "marginTop",
40
+ "marginRight",
41
+ "marginBottom",
42
+ "marginLeft",
43
+ "top",
44
+ "right",
45
+ "bottom",
46
+ "left",
47
+ "fontSize",
48
+ "lineHeight",
49
+ "letterSpacing",
50
+ "borderWidth",
51
+ "borderTopWidth",
52
+ "borderRightWidth",
53
+ "borderBottomWidth",
54
+ "borderLeftWidth",
55
+ "borderRadius",
56
+ "borderTopLeftRadius",
57
+ "borderTopRightRadius",
58
+ "borderBottomRightRadius",
59
+ "borderBottomLeftRadius",
60
+ ]);
61
+
62
+ const Z_INDEX: NumberSpec = { min: -9999, max: 9999, integer: true, example: "10" };
63
+ const GRID_SPAN: NumberSpec = { min: 1, max: 12, integer: true, example: "2" };
64
+ const OPACITY: NumberSpec = { min: 0, max: 100, scale: 100, example: "50", suffix: "%" };
65
+
66
+ const COLOR_KEYS = new Set<StyleKey>(["color", "backgroundColor", "borderColor"]);
67
+
68
+ const SELECT_OPTIONS: Partial<Record<StyleKey, { value: string; label: string }[]>> = {
69
+ textAlign: [
70
+ { value: "left", label: "Left" },
71
+ { value: "center", label: "Center" },
72
+ { value: "right", label: "Right" },
73
+ { value: "justify", label: "Justify" },
74
+ ],
75
+ textTransform: [
76
+ { value: "none", label: "None" },
77
+ { value: "uppercase", label: "Uppercase" },
78
+ { value: "lowercase", label: "Lowercase" },
79
+ { value: "capitalize", label: "Capitalize" },
80
+ ],
81
+ textDecoration: [
82
+ { value: "none", label: "None" },
83
+ { value: "underline", label: "Underline" },
84
+ { value: "overline", label: "Overline" },
85
+ { value: "line-through", label: "Line-through" },
86
+ ],
87
+ position: [
88
+ { value: "static", label: "Static" },
89
+ { value: "relative", label: "Relative" },
90
+ { value: "absolute", label: "Absolute" },
91
+ { value: "fixed", label: "Fixed" },
92
+ { value: "sticky", label: "Sticky" },
93
+ ],
94
+ overflow: [
95
+ { value: "visible", label: "Visible" },
96
+ { value: "hidden", label: "Hidden" },
97
+ { value: "clip", label: "Clip" },
98
+ { value: "scroll", label: "Scroll" },
99
+ { value: "auto", label: "Auto" },
100
+ ],
101
+ aspectRatio: [
102
+ { value: "auto", label: "Auto" },
103
+ ...["1/1", "4/3", "3/2", "16/9", "21/9", "3/4", "2/3", "9/16"].map((ratio) => ({
104
+ value: ratio,
105
+ label: ratio.replace("/", ":"),
106
+ })),
107
+ ],
108
+ objectFit: [
109
+ { value: "fill", label: "Fill" },
110
+ { value: "contain", label: "Contain" },
111
+ { value: "cover", label: "Cover" },
112
+ { value: "none", label: "None" },
113
+ { value: "scale-down", label: "Scale down" },
114
+ ],
115
+ cursor: [
116
+ { value: "default", label: "Default" },
117
+ { value: "pointer", label: "Pointer" },
118
+ { value: "text", label: "Text" },
119
+ { value: "move", label: "Move" },
120
+ { value: "grab", label: "Grab" },
121
+ { value: "not-allowed", label: "Not allowed" },
122
+ { value: "help", label: "Help" },
123
+ { value: "crosshair", label: "Crosshair" },
124
+ { value: "zoom-in", label: "Zoom in" },
125
+ ],
126
+ borderStyle: [
127
+ { value: "none", label: "None" },
128
+ { value: "solid", label: "Solid" },
129
+ { value: "dashed", label: "Dashed" },
130
+ { value: "dotted", label: "Dotted" },
131
+ ],
132
+ backgroundSize: [
133
+ { value: "cover", label: "Cover" },
134
+ { value: "contain", label: "Contain" },
135
+ { value: "auto", label: "Auto" },
136
+ ],
137
+ backgroundPosition: [
138
+ { value: "center", label: "Center" },
139
+ { value: "top", label: "Top" },
140
+ { value: "bottom", label: "Bottom" },
141
+ { value: "left", label: "Left" },
142
+ { value: "right", label: "Right" },
143
+ { value: "top left", label: "Top left" },
144
+ { value: "top right", label: "Top right" },
145
+ { value: "bottom left", label: "Bottom left" },
146
+ { value: "bottom right", label: "Bottom right" },
147
+ ],
148
+ backgroundRepeat: [
149
+ { value: "no-repeat", label: "No repeat" },
150
+ { value: "repeat", label: "Repeat" },
151
+ { value: "repeat-x", label: "Repeat horizontally" },
152
+ { value: "repeat-y", label: "Repeat vertically" },
153
+ ],
154
+ // W-213: the full CSS weight range.
155
+ fontWeight: [
156
+ { value: "400", label: "Regular" },
157
+ { value: "100", label: "Thin" },
158
+ { value: "200", label: "Extra light" },
159
+ { value: "300", label: "Light" },
160
+ { value: "500", label: "Medium" },
161
+ { value: "600", label: "Semibold" },
162
+ { value: "700", label: "Bold" },
163
+ { value: "800", label: "Extra bold" },
164
+ { value: "900", label: "Black" },
165
+ ],
166
+ };
167
+
168
+ const isLengthLiteral = (value: unknown): value is { value: number; unit: string } =>
169
+ typeof value === "object" && value !== null && "value" in value && "unit" in value;
170
+
171
+ /** A value as placeholder text: a literal, a keyword, or the variable's name (W-089). */
172
+ export function placeholderOf(value: unknown, design: DesignSystem): string | undefined {
173
+ if (typeof value === "string" || typeof value === "number") return String(value);
174
+ if (isLengthLiteral(value)) return `${value.value}${value.unit}`;
175
+ if (typeof value === "object" && value !== null && "var" in value) {
176
+ const { colors, fonts, fontSizes, spacings } = design.variables;
177
+ const id = (value as { var: unknown }).var;
178
+ return [...colors, ...(fonts ?? []), ...(fontSizes ?? []), ...(spacings ?? [])].find(
179
+ (v) => v.id === id,
180
+ )?.name;
181
+ }
182
+ return undefined;
183
+ }
184
+
185
+ /** One Style property row: control, set marker, reset (W-021). */
186
+ const FILL_REST = new Set<StyleKey>([
187
+ "backgroundImage",
188
+ "backgroundSize",
189
+ "backgroundPosition",
190
+ "backgroundRepeat",
191
+ "gradient",
192
+ "overlay",
193
+ "backgroundVideo",
194
+ ]);
195
+
196
+ export function StyleRow({
197
+ styleKey,
198
+ style,
199
+ inherited,
200
+ design,
201
+ fetcher,
202
+ elementType = "container",
203
+ fillScope,
204
+ onPatch,
205
+ onDesignChange,
206
+ }: {
207
+ styleKey: StyleKey;
208
+ style: StyleProps | undefined;
209
+ /** The Normal styles while a state is edited (W-089): shown as placeholders, never saved. */
210
+ inherited?: StyleProps;
211
+ design: DesignSystem;
212
+ /** Present on an element, so a background image can use the media library. */
213
+ fetcher?: Fetcher;
214
+ /** Decides whether Image and Video are offered. A class editor passes a box. */
215
+ elementType?: string;
216
+ /** Which class and device the background fill memory belongs to (W-184). */
217
+ fillScope?: string;
218
+ onPatch: (patch: Partial<StyleProps>) => void;
219
+ onDesignChange: (design: DesignSystem) => Promise<void>;
220
+ }) {
221
+ const value = style?.[styleKey];
222
+ const set = value !== undefined;
223
+ const label = STYLE_LABELS[styleKey];
224
+ const normalValue = inherited?.[styleKey];
225
+ const placeholder = set ? undefined : placeholderOf(normalValue, design);
226
+ const inheriting = !set && normalValue !== undefined ? "true" : undefined;
227
+
228
+ const reset = (
229
+ <ResetButton label={label} set={set} onReset={() => onPatch({ [styleKey]: undefined })} />
230
+ );
231
+
232
+ if (styleKey === "backgroundColor") {
233
+ return (
234
+ <BackgroundFill
235
+ style={style}
236
+ elementType={elementType}
237
+ design={design}
238
+ fetcher={fetcher}
239
+ sizeOptions={SELECT_OPTIONS.backgroundSize ?? []}
240
+ positionOptions={SELECT_OPTIONS.backgroundPosition ?? []}
241
+ repeatOptions={SELECT_OPTIONS.backgroundRepeat ?? []}
242
+ onPatch={onPatch}
243
+ onDesignChange={onDesignChange}
244
+ memoryScope={fillScope}
245
+ reset={
246
+ <ResetButton
247
+ label="Background"
248
+ set={
249
+ style?.backgroundColor !== undefined ||
250
+ style?.gradient !== undefined ||
251
+ style?.backgroundImage !== undefined ||
252
+ style?.backgroundVideo !== undefined ||
253
+ style?.overlay !== undefined
254
+ }
255
+ onReset={() =>
256
+ onPatch({
257
+ backgroundColor: undefined,
258
+ backgroundImage: undefined,
259
+ backgroundSize: undefined,
260
+ backgroundPosition: undefined,
261
+ backgroundRepeat: undefined,
262
+ gradient: undefined,
263
+ overlay: undefined,
264
+ backgroundVideo: undefined,
265
+ })
266
+ }
267
+ />
268
+ }
269
+ />
270
+ );
271
+ }
272
+
273
+ if (FILL_REST.has(styleKey)) return null;
274
+
275
+ if (COLOR_KEYS.has(styleKey)) {
276
+ return (
277
+ <div
278
+ className="emvb-style-row"
279
+ data-emvb-style={styleKey}
280
+ data-set={set ? "true" : undefined}
281
+ data-inherited={inheriting}
282
+ >
283
+ <ColorControl
284
+ label={label}
285
+ value={value as StyleProps["color"]}
286
+ placeholder={placeholder}
287
+ design={design}
288
+ onChange={(color) => onPatch({ [styleKey]: color })}
289
+ onDesignChange={onDesignChange}
290
+ />
291
+ {reset}
292
+ </div>
293
+ );
294
+ }
295
+
296
+ const choices = LAYOUT_CHOICES[styleKey];
297
+ if (choices) {
298
+ return (
299
+ <div
300
+ className="emvb-style-row"
301
+ data-emvb-style={styleKey}
302
+ data-set={set ? "true" : undefined}
303
+ data-inherited={inheriting}
304
+ >
305
+ <ChoiceGroup
306
+ label={label}
307
+ value={typeof value === "string" ? value : undefined}
308
+ options={choices}
309
+ onChange={(next) => onPatch({ [styleKey]: next })}
310
+ />
311
+ {reset}
312
+ </div>
313
+ );
314
+ }
315
+
316
+ const options = SELECT_OPTIONS[styleKey];
317
+ if (options) {
318
+ const shown = value ?? normalValue;
319
+ const current =
320
+ styleKey === "fontWeight" && typeof shown === "number"
321
+ ? String(shown)
322
+ : ((shown as string | undefined) ?? options[0]?.value ?? "");
323
+ return (
324
+ <div
325
+ className="emvb-style-row"
326
+ data-emvb-style={styleKey}
327
+ data-set={set ? "true" : undefined}
328
+ data-inherited={inheriting}
329
+ >
330
+ <Select
331
+ label={label}
332
+ className={FIELD}
333
+ value={current}
334
+ onValueChange={(next) => {
335
+ if (styleKey === "fontWeight") {
336
+ const n = Number(next);
337
+ onPatch({
338
+ fontWeight: Number.isFinite(n)
339
+ ? (n as NonNullable<StyleProps["fontWeight"]>)
340
+ : undefined,
341
+ });
342
+ return;
343
+ }
344
+ onPatch({ [styleKey]: next === options[0]?.value && !set ? next : next });
345
+ }}
346
+ renderValue={(v: unknown) =>
347
+ options.find((o) => o.value === String(v))?.label ?? String(v)
348
+ }
349
+ >
350
+ {options.map((option) => (
351
+ <Select.Option key={option.value} value={option.value}>
352
+ {option.label}
353
+ </Select.Option>
354
+ ))}
355
+ </Select>
356
+ {reset}
357
+ </div>
358
+ );
359
+ }
360
+
361
+ if (styleKey === "fontFamily") {
362
+ const text = typeof value === "string" ? value : "";
363
+ const ref = boundRef(value, "font");
364
+ return (
365
+ <div
366
+ className="emvb-style-row"
367
+ data-emvb-style={styleKey}
368
+ data-set={set ? "true" : undefined}
369
+ data-inherited={inheriting}
370
+ >
371
+ {ref ? (
372
+ <VariableChip
373
+ label={label}
374
+ kind="font"
375
+ design={design}
376
+ id={ref.var}
377
+ onDetach={(literal) =>
378
+ onPatch({
379
+ fontFamily:
380
+ typeof literal === "string" && isSafeFontStack(literal) ? literal : undefined,
381
+ })
382
+ }
383
+ />
384
+ ) : (
385
+ <Input
386
+ label={label}
387
+ className={FIELD}
388
+ value={text}
389
+ placeholder={placeholder ?? "Noto Sans, system-ui, sans-serif"}
390
+ onChange={(event) => {
391
+ const next = event.target.value.trim();
392
+ onPatch({ fontFamily: next === "" ? undefined : next });
393
+ }}
394
+ />
395
+ )}
396
+ <VariableButton
397
+ label={label}
398
+ kind="font"
399
+ design={design}
400
+ current={ref?.var ?? null}
401
+ onBind={(next) => onPatch({ fontFamily: next as StyleProps["fontFamily"] })}
402
+ />
403
+ {reset}
404
+ </div>
405
+ );
406
+ }
407
+
408
+ if (
409
+ styleKey === "zIndex" ||
410
+ styleKey === "opacity" ||
411
+ styleKey === "gridColumnSpan" ||
412
+ styleKey === "gridRowSpan"
413
+ ) {
414
+ const spec = styleKey === "zIndex" ? Z_INDEX : styleKey === "opacity" ? OPACITY : GRID_SPAN;
415
+ return (
416
+ <NumberRow
417
+ rowKey={styleKey}
418
+ label={label}
419
+ value={typeof value === "number" ? value : undefined}
420
+ inherited={typeof normalValue === "number" ? normalValue : undefined}
421
+ spec={spec}
422
+ onCommit={(next) => onPatch({ [styleKey]: next })}
423
+ />
424
+ );
425
+ }
426
+
427
+ // W-237: the Icon section.
428
+ if (styleKey === "iconRotate") {
429
+ return (
430
+ <IconRotateRow
431
+ value={style?.iconRotate}
432
+ inherited={inherited?.iconRotate}
433
+ onChange={(iconRotate) => onPatch({ iconRotate })}
434
+ />
435
+ );
436
+ }
437
+ if (styleKey === "iconFlip") {
438
+ return (
439
+ <IconFlipRow
440
+ value={style?.iconFlip}
441
+ inherited={inherited?.iconFlip}
442
+ onChange={(iconFlip) => onPatch({ iconFlip })}
443
+ />
444
+ );
445
+ }
446
+ if (styleKey === "iconScale" || styleKey === "iconStrokeWidth") {
447
+ return (
448
+ <NumberRow
449
+ rowKey={styleKey}
450
+ label={label}
451
+ value={typeof value === "number" ? value : undefined}
452
+ inherited={typeof normalValue === "number" ? normalValue : undefined}
453
+ spec={styleKey === "iconScale" ? ICON_SCALE : ICON_STROKE}
454
+ onCommit={(next) => onPatch({ [styleKey]: next })}
455
+ />
456
+ );
457
+ }
458
+ if (styleKey === "iconShadow") {
459
+ return (
460
+ <IconShadowControl
461
+ value={style?.iconShadow}
462
+ design={design}
463
+ onChange={(iconShadow) => onPatch({ iconShadow })}
464
+ onDesignChange={onDesignChange}
465
+ />
466
+ );
467
+ }
468
+ if (styleKey === "iconAnimation") {
469
+ return (
470
+ <IconAnimationControl
471
+ value={style?.iconAnimation}
472
+ inherited={inherited?.iconAnimation}
473
+ onChange={(iconAnimation) => onPatch({ iconAnimation })}
474
+ />
475
+ );
476
+ }
477
+
478
+ if (styleKey === "boxShadow") {
479
+ return (
480
+ <ShadowControl
481
+ value={style?.boxShadow}
482
+ design={design}
483
+ onChange={(boxShadow) => onPatch({ boxShadow })}
484
+ onDesignChange={onDesignChange}
485
+ reset={reset}
486
+ />
487
+ );
488
+ }
489
+
490
+ if (styleKey === "entrance") {
491
+ return (
492
+ <EntranceControl
493
+ value={style?.entrance}
494
+ onChange={(entrance) => onPatch({ entrance })}
495
+ reset={reset}
496
+ />
497
+ );
498
+ }
499
+
500
+ if (styleKey === "transition") {
501
+ return (
502
+ <TransitionControl
503
+ value={style?.transition}
504
+ onChange={(transition) => onPatch({ transition })}
505
+ reset={reset}
506
+ />
507
+ );
508
+ }
509
+
510
+ if (styleKey === "filter") {
511
+ return (
512
+ <FiltersControl
513
+ value={style?.filter}
514
+ inherited={inherited?.filter}
515
+ onChange={(filter) => onPatch({ filter })}
516
+ />
517
+ );
518
+ }
519
+
520
+ if (LENGTH_KEYS.has(styleKey)) {
521
+ return (
522
+ <LengthRow
523
+ styleKey={styleKey}
524
+ label={label}
525
+ value={value}
526
+ design={design}
527
+ set={set}
528
+ placeholder={placeholder}
529
+ slider={styleKey === "gap"}
530
+ onPatch={onPatch}
531
+ reset={reset}
532
+ />
533
+ );
534
+ }
535
+
536
+ return null;
537
+ }
538
+
539
+ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
540
+ ...LENGTH_KEYS,
541
+ ...COLOR_KEYS,
542
+ "fontFamily",
543
+ "zIndex",
544
+ "gridColumnSpan",
545
+ "gridRowSpan",
546
+ "opacity",
547
+ "boxShadow",
548
+ "filter",
549
+ "entrance",
550
+ "transition",
551
+ "iconRotate",
552
+ "iconFlip",
553
+ "iconScale",
554
+ "iconStrokeWidth",
555
+ "iconShadow",
556
+ "iconAnimation",
557
+ "backgroundImage",
558
+ "backgroundVideo",
559
+ "gradient",
560
+ "overlay",
561
+ ...(Object.keys(SELECT_OPTIONS) as StyleKey[]),
562
+ ...(Object.keys(LAYOUT_CHOICES) as StyleKey[]),
563
+ ];