@mun-ui/web 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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/dist/content-transition.d.ts +23 -0
  3. package/dist/content-transition.d.ts.map +1 -0
  4. package/dist/content-transition.js +780 -0
  5. package/dist/content-transition.js.map +1 -0
  6. package/dist/continuous-corners.d.ts +3 -0
  7. package/dist/continuous-corners.d.ts.map +1 -0
  8. package/dist/continuous-corners.js +71 -0
  9. package/dist/continuous-corners.js.map +1 -0
  10. package/dist/devtools.d.ts +50 -0
  11. package/dist/devtools.d.ts.map +1 -0
  12. package/dist/devtools.js +118 -0
  13. package/dist/devtools.js.map +1 -0
  14. package/dist/dom.d.ts +12 -0
  15. package/dist/dom.d.ts.map +1 -0
  16. package/dist/dom.js +5375 -0
  17. package/dist/dom.js.map +1 -0
  18. package/dist/element-motion.d.ts +29 -0
  19. package/dist/element-motion.d.ts.map +1 -0
  20. package/dist/element-motion.js +463 -0
  21. package/dist/element-motion.js.map +1 -0
  22. package/dist/focus.d.ts +3 -0
  23. package/dist/focus.d.ts.map +1 -0
  24. package/dist/focus.js +70 -0
  25. package/dist/focus.js.map +1 -0
  26. package/dist/gpu-island.d.ts +123 -0
  27. package/dist/gpu-island.d.ts.map +1 -0
  28. package/dist/gpu-island.js +1093 -0
  29. package/dist/gpu-island.js.map +1 -0
  30. package/dist/hydration.d.ts +18 -0
  31. package/dist/hydration.d.ts.map +1 -0
  32. package/dist/hydration.js +223 -0
  33. package/dist/hydration.js.map +1 -0
  34. package/dist/index.d.ts +7 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +5 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/lazy-index.d.ts +42 -0
  39. package/dist/lazy-index.d.ts.map +1 -0
  40. package/dist/lazy-index.js +136 -0
  41. package/dist/lazy-index.js.map +1 -0
  42. package/dist/motion.d.ts +49 -0
  43. package/dist/motion.d.ts.map +1 -0
  44. package/dist/motion.js +745 -0
  45. package/dist/motion.js.map +1 -0
  46. package/dist/patch-ir.d.ts +44 -0
  47. package/dist/patch-ir.d.ts.map +1 -0
  48. package/dist/patch-ir.js +221 -0
  49. package/dist/patch-ir.js.map +1 -0
  50. package/dist/path-interpolation.d.ts +29 -0
  51. package/dist/path-interpolation.d.ts.map +1 -0
  52. package/dist/path-interpolation.js +318 -0
  53. package/dist/path-interpolation.js.map +1 -0
  54. package/dist/presentation.d.ts +4 -0
  55. package/dist/presentation.d.ts.map +1 -0
  56. package/dist/presentation.js +198 -0
  57. package/dist/presentation.js.map +1 -0
  58. package/dist/props.d.ts +22 -0
  59. package/dist/props.d.ts.map +1 -0
  60. package/dist/props.js +663 -0
  61. package/dist/props.js.map +1 -0
  62. package/dist/shared.d.ts +73 -0
  63. package/dist/shared.d.ts.map +1 -0
  64. package/dist/shared.js +704 -0
  65. package/dist/shared.js.map +1 -0
  66. package/dist/ssr.d.ts +3 -0
  67. package/dist/ssr.d.ts.map +1 -0
  68. package/dist/ssr.js +287 -0
  69. package/dist/ssr.js.map +1 -0
  70. package/dist/transition.d.ts +12 -0
  71. package/dist/transition.d.ts.map +1 -0
  72. package/dist/transition.js +172 -0
  73. package/dist/transition.js.map +1 -0
  74. package/dist/ui-ir.d.ts +12 -0
  75. package/dist/ui-ir.d.ts.map +1 -0
  76. package/dist/ui-ir.js +324 -0
  77. package/dist/ui-ir.js.map +1 -0
  78. package/dist/url-policy.d.ts +2 -0
  79. package/dist/url-policy.d.ts.map +1 -0
  80. package/dist/url-policy.js +27 -0
  81. package/dist/url-policy.js.map +1 -0
  82. package/package.json +47 -3
  83. package/README.md +0 -3
package/dist/shared.js ADDED
@@ -0,0 +1,704 @@
1
+ import { animationCSSStyle, classNameOf, currentRenderTransaction, frameStyle, layoutLength, swiftUIAnimatableModifierNames } from "@mun-ui/core/compat";
2
+ import { APPLE_CONTINUOUS_CORNER_SMOOTHING } from "@mun-ui/core/corners";
3
+ import { ignoresSafeAreaStyle, paddingStyle, safeAreaPaddingStyle } from "@mun-ui/core/internal/runtime";
4
+ function alignmentCSSPosition(value, fallback = "center") {
5
+ switch (value) {
6
+ case "leading": return "left center";
7
+ case "trailing": return "right center";
8
+ case "top": return "center top";
9
+ case "bottom": return "center bottom";
10
+ case "topLeading": return "left top";
11
+ case "topTrailing": return "right top";
12
+ case "bottomLeading": return "left bottom";
13
+ case "bottomTrailing": return "right bottom";
14
+ case "center": return "center";
15
+ default: return fallback;
16
+ }
17
+ }
18
+ /** Event-handler prop names (`onClick`, `onpointerdown`). Hot in prop diffs, so avoid a regex. */
19
+ export function isEventPropName(key) {
20
+ if (key.length < 3 || key.charCodeAt(0) !== 111 || key.charCodeAt(1) !== 110)
21
+ return false;
22
+ const code = key.charCodeAt(2);
23
+ return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
24
+ }
25
+ export { classNameOf };
26
+ export function alignmentCSSPlace(value, fallback = "center") {
27
+ switch (value) {
28
+ case "leading": return "center start";
29
+ case "trailing": return "center end";
30
+ case "top": return "start center";
31
+ case "bottom": return "end center";
32
+ case "topLeading": return "start start";
33
+ case "topTrailing": return "start end";
34
+ case "bottomLeading": return "end start";
35
+ case "bottomTrailing": return "end end";
36
+ default: return fallback;
37
+ }
38
+ }
39
+ function finite(value, fallback) {
40
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
41
+ }
42
+ function point(value, second) {
43
+ if (typeof value === "number")
44
+ return { x: finite(value, 0), y: finite(second, 0) };
45
+ if (value && typeof value === "object") {
46
+ const candidate = value;
47
+ return { x: finite(candidate.x ?? candidate.width, 0), y: finite(candidate.y ?? candidate.height, 0) };
48
+ }
49
+ return { x: 0, y: 0 };
50
+ }
51
+ function fontWeight(value) {
52
+ if (typeof value === "number" && Number.isFinite(value))
53
+ return String(value);
54
+ const weights = { ultraLight: "100", thin: "200", light: "300", regular: "400", medium: "500", semibold: "600", bold: "700", heavy: "800", black: "900" };
55
+ return typeof value === "string" ? weights[value] ?? value : "inherit";
56
+ }
57
+ function fontFamilyForDesign(value) {
58
+ if (value === "serif")
59
+ return "ui-serif, Georgia, serif";
60
+ if (value === "rounded")
61
+ return "ui-rounded, system-ui, sans-serif";
62
+ if (value === "monospaced")
63
+ return "ui-monospace, SFMono-Regular, Menlo, monospace";
64
+ if (value === "default")
65
+ return "system-ui, -apple-system, sans-serif";
66
+ return undefined;
67
+ }
68
+ function fontStretchForWidth(value) {
69
+ if (value === "compressed")
70
+ return "50%";
71
+ if (value === "condensed")
72
+ return "75%";
73
+ if (value === "standard")
74
+ return "100%";
75
+ if (value === "expanded")
76
+ return "125%";
77
+ return undefined;
78
+ }
79
+ function blendMode(value) {
80
+ const aliases = { colorDodge: "color-dodge", colorBurn: "color-burn", softLight: "soft-light", hardLight: "hard-light", plusDarker: "darken", plusLighter: "plus-lighter" };
81
+ return typeof value === "string" ? aliases[value] ?? value : "normal";
82
+ }
83
+ const htmlAttributeAliases = Object.freeze({
84
+ allowFullScreen: "allowfullscreen",
85
+ autoFocus: "autofocus",
86
+ autoPlay: "autoplay",
87
+ className: "class",
88
+ contentEditable: "contenteditable",
89
+ formNoValidate: "formnovalidate",
90
+ htmlFor: "for",
91
+ itemScope: "itemscope",
92
+ noModule: "nomodule",
93
+ noValidate: "novalidate",
94
+ playsInline: "playsinline",
95
+ readOnly: "readonly",
96
+ spellCheck: "spellcheck",
97
+ tabIndex: "tabindex",
98
+ xlinkHref: "xlink:href",
99
+ xmlLang: "xml:lang",
100
+ xmlSpace: "xml:space",
101
+ // SVG presentation attributes are kebab-case in the DOM; the view layer uses camelCase like React.
102
+ strokeWidth: "stroke-width",
103
+ strokeLinecap: "stroke-linecap",
104
+ strokeLinejoin: "stroke-linejoin",
105
+ fillRule: "fill-rule",
106
+ clipRule: "clip-rule",
107
+ vectorEffect: "vector-effect",
108
+ });
109
+ const booleanHtmlAttributes = new Set([
110
+ "allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "defer",
111
+ "disabled", "formnovalidate", "hidden", "inert", "ismap", "itemscope", "loop", "multiple", "muted",
112
+ "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "selected",
113
+ ]);
114
+ const enumeratedBooleanAttributes = new Set(["contenteditable", "draggable", "spellcheck", "translate"]);
115
+ // DOM createElement/setAttribute validate names against the XML Name production.
116
+ const htmlNamePattern = /^(?:[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\u{10000}-\u{EFFFF}])(?:[:A-Z_a-z\-.0-9\u00B7\u0300-\u036F\u203F-\u2040\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\u{10000}-\u{EFFFF}])*$/u;
117
+ export function assertHtmlName(value, kind) {
118
+ if (!htmlNamePattern.test(value))
119
+ throw new TypeError(`Invalid HTML ${kind} name: ${JSON.stringify(value)}`);
120
+ return value;
121
+ }
122
+ export function htmlAttributeName(key) {
123
+ return htmlAttributeAliases[key] ?? key;
124
+ }
125
+ export function isBooleanHtmlAttribute(name) {
126
+ return booleanHtmlAttributes.has(name.toLowerCase());
127
+ }
128
+ export function isEnumeratedBooleanAttribute(name) {
129
+ return enumeratedBooleanAttributes.has(name.toLowerCase());
130
+ }
131
+ export function escape(value) {
132
+ return String(value)
133
+ .replaceAll("&", "&amp;")
134
+ .replaceAll("<", "&lt;")
135
+ .replaceAll(">", "&gt;")
136
+ .replaceAll('"', "&quot;");
137
+ }
138
+ export function styleOf(modifier, includeAnimationFallback = true) {
139
+ const value = modifier.arguments[0];
140
+ let style;
141
+ switch (modifier.name) {
142
+ case "padding":
143
+ style = Object.fromEntries(Object.entries(paddingStyle(value, modifier.arguments[1])).map(([key, item]) => [cssPropertyName(key), item]));
144
+ break;
145
+ case "margin":
146
+ style = { margin: layoutLength(value) ?? "" };
147
+ break;
148
+ case "gap":
149
+ style = { gap: layoutLength(value) ?? "" };
150
+ break;
151
+ case "font":
152
+ style = { font: String(value) };
153
+ break;
154
+ case "fontSize":
155
+ style = { "font-size": layoutLength(value) ?? "" };
156
+ break;
157
+ case "bold":
158
+ style = { "font-weight": value === false ? "normal" : "700" };
159
+ break;
160
+ case "fontWeight":
161
+ style = { "font-weight": fontWeight(value) };
162
+ break;
163
+ case "fontDesign":
164
+ style = { "font-family": fontFamilyForDesign(value) ?? "" };
165
+ break;
166
+ case "fontWidth":
167
+ style = { "font-stretch": fontStretchForWidth(value) ?? "" };
168
+ break;
169
+ case "italic":
170
+ style = { "font-style": value === false ? "normal" : "italic" };
171
+ break;
172
+ case "underline":
173
+ style = value === false ? { "text-decoration-line": "none" } : { "text-decoration-line": "underline", "text-decoration-style": String(modifier.arguments[1] ?? "solid"), ...(modifier.arguments[2] ? { "text-decoration-color": String(modifier.arguments[2]) } : {}) };
174
+ break;
175
+ case "strikethrough":
176
+ style = value === false ? { "text-decoration-line": "none" } : { "text-decoration-line": "line-through", "text-decoration-style": String(modifier.arguments[1] ?? "solid"), ...(modifier.arguments[2] ? { "text-decoration-color": String(modifier.arguments[2]) } : {}) };
177
+ break;
178
+ case "monospaced":
179
+ style = value === false ? {} : { "font-family": "ui-monospace, SFMono-Regular, Menlo, monospace" };
180
+ break;
181
+ case "monospacedDigit":
182
+ style = { "font-variant-numeric": "tabular-nums" };
183
+ break;
184
+ case "kerning":
185
+ style = { "font-kerning": "normal", "letter-spacing": `${finite(value, 0)}px` };
186
+ break;
187
+ case "tracking":
188
+ style = { "letter-spacing": `${finite(value, 0)}px` };
189
+ break;
190
+ case "baselineOffset":
191
+ style = { position: "relative", top: `${-finite(value, 0)}px` };
192
+ break;
193
+ case "lineSpacing":
194
+ style = { "line-height": `calc(1em + ${finite(value, 0)}px)` };
195
+ break;
196
+ case "lineLimit": {
197
+ const lines = typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : undefined;
198
+ style = lines ? { display: "-webkit-box", "-webkit-box-orient": "vertical", "-webkit-line-clamp": String(lines), overflow: "hidden", ...(modifier.arguments[1] ? { "min-height": `${lines}lh` } : {}) } : { "-webkit-line-clamp": "unset" };
199
+ break;
200
+ }
201
+ case "minimumScaleFactor":
202
+ style = { "--mun-minimum-scale-factor": String(Math.max(0, Math.min(1, finite(value, 1)))) };
203
+ break;
204
+ case "multilineTextAlignment":
205
+ style = { "text-align": value === "leading" ? "start" : value === "trailing" ? "end" : "center" };
206
+ break;
207
+ case "truncationMode":
208
+ style = { "text-overflow": "ellipsis", overflow: "hidden", "white-space": "nowrap", ...(value === "head" ? { direction: "rtl" } : {}) };
209
+ break;
210
+ case "textCase":
211
+ style = { "text-transform": value === "uppercase" ? "uppercase" : value === "lowercase" ? "lowercase" : "none" };
212
+ break;
213
+ case "allowsTightening":
214
+ style = { "--mun-allows-tightening": value === false ? "0" : "1" };
215
+ break;
216
+ case "foreground":
217
+ case "foregroundStyle":
218
+ style = { color: String(value), ...(modifier.arguments[1] !== undefined ? { "--mun-secondary-foreground": String(modifier.arguments[1]) } : {}), ...(modifier.arguments[2] !== undefined ? { "--mun-tertiary-foreground": String(modifier.arguments[2]) } : {}) };
219
+ break;
220
+ case "background":
221
+ style = typeof value === "string" ? { background: value, "background-position": alignmentCSSPosition(modifier.arguments[1]) } : {};
222
+ break;
223
+ case "opacity": {
224
+ const opacity = typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 1;
225
+ style = { opacity: String(opacity) };
226
+ break;
227
+ }
228
+ case "scaleEffect": {
229
+ let x = 1;
230
+ let y = 1;
231
+ if (typeof value === "number" && Number.isFinite(value)) {
232
+ x = value;
233
+ y = value;
234
+ }
235
+ else if (value && typeof value === "object") {
236
+ const scale = value;
237
+ const rawX = Number(scale.x ?? scale.width ?? 1);
238
+ const rawY = Number(scale.y ?? scale.height ?? 1);
239
+ x = Number.isFinite(rawX) ? rawX : 1;
240
+ y = Number.isFinite(rawY) ? rawY : 1;
241
+ }
242
+ // Keep transform components on separate CSS channels. This lets scale,
243
+ // rotation and translation run with independent motion plans instead of
244
+ // fighting over one monolithic `transform` string.
245
+ style = {
246
+ scale: x === y ? `${x}` : `${x} ${y}`,
247
+ "transform-origin": alignmentCSSPosition(modifier.arguments[1]),
248
+ };
249
+ break;
250
+ }
251
+ case "rotationEffect": {
252
+ const degrees = typeof value === "number" && Number.isFinite(value) ? value : 0;
253
+ style = { rotate: `${degrees}deg`, "transform-origin": alignmentCSSPosition(modifier.arguments[1]) };
254
+ break;
255
+ }
256
+ case "offset": {
257
+ const second = modifier.arguments[1];
258
+ let x = 0;
259
+ let y = 0;
260
+ if (typeof value === "number") {
261
+ x = value;
262
+ y = typeof second === "number" ? second : 0;
263
+ }
264
+ else if (value && typeof value === "object") {
265
+ const point = value;
266
+ x = Number(point.x ?? point.width ?? 0);
267
+ y = Number(point.y ?? point.height ?? 0);
268
+ }
269
+ style = { translate: `${Number.isFinite(x) ? x : 0}px ${Number.isFinite(y) ? y : 0}px` };
270
+ break;
271
+ }
272
+ case "aspectRatio": {
273
+ let ratio = typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
274
+ if (!ratio && value && typeof value === "object") {
275
+ const size = value;
276
+ const width = finite(size.width, 0);
277
+ const height = finite(size.height, 0);
278
+ if (width > 0 && height > 0)
279
+ ratio = width / height;
280
+ }
281
+ style = { ...(ratio ? { "aspect-ratio": String(ratio) } : {}), "object-fit": modifier.arguments[1] === "fill" ? "cover" : "contain" };
282
+ break;
283
+ }
284
+ case "scaledToFit":
285
+ style = { "object-fit": "contain", "max-width": "100%", "max-height": "100%" };
286
+ break;
287
+ case "scaledToFill":
288
+ style = { "object-fit": "cover", width: "100%", height: "100%" };
289
+ break;
290
+ case "fixedSize":
291
+ style = { ...(value !== false ? { width: "max-content" } : {}), ...(modifier.arguments[1] !== false ? { height: "max-content" } : {}) };
292
+ break;
293
+ case "layoutPriority":
294
+ style = { "flex-shrink": finite(value, 0) > 0 ? "0" : "1", "--mun-layout-priority": String(finite(value, 0)) };
295
+ break;
296
+ case "position": {
297
+ const resolved = point(value, modifier.arguments[1]);
298
+ style = { position: "absolute", left: `${resolved.x}px`, top: `${resolved.y}px`, transform: "translate(-50%, -50%)" };
299
+ break;
300
+ }
301
+ case "zIndex":
302
+ style = { "z-index": String(finite(value, 0)) };
303
+ break;
304
+ case "ignoresSafeArea":
305
+ style = Object.fromEntries(Object.entries(ignoresSafeAreaStyle(modifier.arguments[1])).map(([key, item]) => [cssPropertyName(key), item]));
306
+ break;
307
+ case "safeAreaPadding":
308
+ style = Object.fromEntries(Object.entries(safeAreaPaddingStyle(value, modifier.arguments[1])).map(([key, item]) => [cssPropertyName(key), item]));
309
+ break;
310
+ case "gridCellColumns":
311
+ style = { "grid-column": `span ${Math.max(1, Math.floor(finite(value, 1)))}` };
312
+ break;
313
+ case "gridCellUnsizedAxes":
314
+ style = { ...(value === "horizontal" || value === "all" ? { "min-width": "0", width: "auto" } : {}), ...(value === "vertical" || value === "all" ? { "min-height": "0", height: "auto" } : {}) };
315
+ break;
316
+ case "gridCellAnchor":
317
+ style = { "place-self": alignmentCSSPlace(value) };
318
+ break;
319
+ case "gridColumnAlignment":
320
+ style = { "justify-self": value === "leading" ? "start" : value === "trailing" ? "end" : "center" };
321
+ break;
322
+ case "transformEffect": {
323
+ const t = value && typeof value === "object" ? value : {};
324
+ style = { transform: `matrix(${finite(t.a, 1)}, ${finite(t.b, 0)}, ${finite(t.c, 0)}, ${finite(t.d, 1)}, ${finite(t.tx, 0)}, ${finite(t.ty, 0)})` };
325
+ break;
326
+ }
327
+ case "projectionEffect":
328
+ style = { transform: typeof value === "string" ? value : Array.isArray(value) && value.length === 16 ? `matrix3d(${value.map(item => finite(item, 0)).join(",")})` : "" };
329
+ break;
330
+ case "rotation3DEffect": {
331
+ const axis = modifier.arguments[1] && typeof modifier.arguments[1] === "object" ? modifier.arguments[1] : {};
332
+ const perspective = finite(modifier.arguments[4], 1);
333
+ style = { transform: `${perspective > 0 ? `perspective(${Math.max(1, 1000 / perspective)}px) ` : ""}rotate3d(${finite(axis.x, 0)}, ${finite(axis.y, 0)}, ${finite(axis.z, 1)}, ${finite(value, 0)}deg)`, "transform-origin": alignmentCSSPosition(modifier.arguments[2]) };
334
+ break;
335
+ }
336
+ case "mask": {
337
+ const props = modifier.props && typeof modifier.props === "object" && "style" in modifier.props ? modifier.props.style : undefined;
338
+ style = props && typeof props === "object" ? Object.fromEntries(Object.entries(props).map(([key, item]) => [cssPropertyName(key), String(item)])) : {};
339
+ break;
340
+ }
341
+ case "clipShape": {
342
+ const props = modifier.props && typeof modifier.props === "object" && "style" in modifier.props ? modifier.props.style : undefined;
343
+ style = props && typeof props === "object" ? Object.fromEntries(Object.entries(props).map(([key, item]) => [cssPropertyName(key), String(item)])) : {};
344
+ break;
345
+ }
346
+ case "clipped":
347
+ style = { overflow: "hidden" };
348
+ break;
349
+ case "cornerRadius":
350
+ style = { borderRadius: layoutLength(value) ?? "" };
351
+ break;
352
+ case "resizable":
353
+ style = { width: "100%", height: "100%" };
354
+ break;
355
+ case "border":
356
+ style = { border: `${layoutLength(modifier.arguments[1] ?? 1) ?? "1px"} solid ${String(value)}` };
357
+ break;
358
+ case "shadow":
359
+ style = { "box-shadow": `${finite(modifier.arguments[2], 0)}px ${finite(modifier.arguments[3], 0)}px ${Math.max(0, finite(modifier.arguments[1], 0))}px ${String(value)}` };
360
+ break;
361
+ case "blur":
362
+ style = { filter: `blur(${Math.max(0, finite(value, 0))}px)` };
363
+ break;
364
+ case "brightness":
365
+ style = { filter: `brightness(${Math.max(0, 1 + finite(value, 0))})` };
366
+ break;
367
+ case "contrast":
368
+ style = { filter: `contrast(${Math.max(0, finite(value, 1))})` };
369
+ break;
370
+ case "saturation":
371
+ style = { filter: `saturate(${Math.max(0, finite(value, 1))})` };
372
+ break;
373
+ case "grayscale":
374
+ style = { filter: `grayscale(${Math.max(0, Math.min(1, finite(value, 0)))})` };
375
+ break;
376
+ case "hueRotation":
377
+ style = { filter: `hue-rotate(${finite(value, 0)}deg)` };
378
+ break;
379
+ case "colorInvert":
380
+ style = { filter: "invert(1)" };
381
+ break;
382
+ case "colorMultiply":
383
+ style = { "--mun-color-multiply": String(value) };
384
+ break;
385
+ case "blendMode":
386
+ style = { "mix-blend-mode": blendMode(value) };
387
+ break;
388
+ case "compositingGroup":
389
+ style = { isolation: "isolate" };
390
+ break;
391
+ case "drawingGroup":
392
+ style = { isolation: "isolate", contain: "paint", ...(value === true ? { background: "Canvas" } : {}) };
393
+ break;
394
+ case "luminanceToAlpha":
395
+ style = { filter: "grayscale(1)", "--mun-luminance-to-alpha": "1" };
396
+ break;
397
+ case "tint":
398
+ style = value == null ? { "accent-color": "auto", "--mun-tint": "initial" } : { "accent-color": String(value), "--mun-tint": String(value) };
399
+ break;
400
+ case "backgroundStyle":
401
+ style = { "--mun-background-style": String(value), background: String(value) };
402
+ break;
403
+ case "dynamicTypeSize":
404
+ style = { "--mun-dynamic-type-size": String(value), "font-size": `var(--mun-dynamic-type-${String(value)}, inherit)` };
405
+ break;
406
+ case "hidden":
407
+ style = { visibility: "hidden" };
408
+ break;
409
+ case "allowsHitTesting":
410
+ style = value === false ? { "pointer-events": "none" } : { "pointer-events": "auto" };
411
+ break;
412
+ case "preferredColorScheme":
413
+ style = value === "light" || value === "dark" ? { "color-scheme": String(value) } : { "color-scheme": "normal" };
414
+ break;
415
+ case "controlSize":
416
+ style = { "--mun-control-size": String(value) };
417
+ break;
418
+ case "buttonStyle":
419
+ style = { "--mun-button-style": String(value) };
420
+ break;
421
+ case "toggleStyle":
422
+ style = { "--mun-toggle-style": String(value) };
423
+ break;
424
+ case "pickerStyle":
425
+ style = { "--mun-picker-style": String(value) };
426
+ break;
427
+ case "textFieldStyle":
428
+ style = { "--mun-text-field-style": String(value) };
429
+ break;
430
+ case "textEditorStyle":
431
+ style = { "--mun-text-editor-style": String(value) };
432
+ break;
433
+ case "listStyle":
434
+ style = { "--mun-list-style": String(value) };
435
+ break;
436
+ case "labelStyle":
437
+ style = { "--mun-label-style": String(value) };
438
+ break;
439
+ case "progressViewStyle":
440
+ style = { "--mun-progress-view-style": String(value) };
441
+ break;
442
+ case "scrollDisabled":
443
+ style = value === true ? { overflow: "hidden" } : {};
444
+ break;
445
+ case "scrollIndicators":
446
+ style = value === "hidden" ? { "scrollbar-width": "none", "--mun-scroll-indicators": "hidden" } : { "--mun-scroll-indicators": String(value) };
447
+ break;
448
+ case "scrollBounceBehavior":
449
+ style = { "overscroll-behavior": value === "basedOnSize" ? "auto" : value === "always" ? "auto" : "none" };
450
+ break;
451
+ case "scrollClipDisabled":
452
+ style = value === false ? {} : { overflow: "visible" };
453
+ break;
454
+ case "scrollDismissesKeyboard":
455
+ style = { "--mun-scroll-dismisses-keyboard": String(value) };
456
+ break;
457
+ case "listRowInsets":
458
+ style = Object.fromEntries(Object.entries(paddingStyle(value, modifier.arguments[1])).map(([key, item]) => [cssPropertyName(key), item]));
459
+ break;
460
+ case "listRowBackground":
461
+ style = typeof value === "string" ? { background: value } : {};
462
+ break;
463
+ case "listRowSeparator":
464
+ style = value === "hidden" ? { "border-block-style": "none" } : value === "visible" ? { "border-block-style": "solid" } : {};
465
+ break;
466
+ case "listSectionSeparator":
467
+ style = value === "hidden" ? { "border-block-style": "none" } : value === "visible" ? { "border-block-style": "solid" } : {};
468
+ break;
469
+ case "symbolRenderingMode":
470
+ style = { "--mun-symbol-rendering-mode": value == null ? "automatic" : String(value) };
471
+ break;
472
+ case "symbolVariant":
473
+ style = { "--mun-symbol-variant": String(value) };
474
+ break;
475
+ case "continuousCorners": {
476
+ const smoothing = typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : APPLE_CONTINUOUS_CORNER_SMOOTHING;
477
+ style = { "corner-shape": "squircle", "--mun-corner-style": "continuous", "--mun-corner-smoothing": String(smoothing), "--mun-corner-preserve-smoothing": "1" };
478
+ break;
479
+ }
480
+ case "frame": {
481
+ style = Object.fromEntries(Object.entries(frameStyle(value && typeof value === "object" ? value : {}))
482
+ .map(([key, item]) => [cssPropertyName(key), item ?? ""]));
483
+ break;
484
+ }
485
+ case "style":
486
+ style = typeof value === "object" && value !== null
487
+ ? normalizedStyle(value)
488
+ : {};
489
+ break;
490
+ case "animation": {
491
+ const animationStyle = includeAnimationFallback ? animationCSSStyle(value) : undefined;
492
+ style = animationStyle ? Object.fromEntries(Object.entries(animationStyle).map(([key, item]) => [cssPropertyName(key), item])) : {};
493
+ break;
494
+ }
495
+ default: style = {};
496
+ }
497
+ const transaction = currentRenderTransaction();
498
+ if (includeAnimationFallback && swiftUIAnimatableModifierNames.has(modifier.name) && !transaction.disablesAnimations && transaction.animation) {
499
+ const animationStyle = animationCSSStyle(transaction.animation);
500
+ if (animationStyle)
501
+ style = { ...style, ...Object.fromEntries(Object.entries(animationStyle).map(([key, item]) => [cssPropertyName(key), item])) };
502
+ }
503
+ return style;
504
+ }
505
+ export function propsOf(modifier) {
506
+ const [value] = modifier.arguments;
507
+ switch (modifier.name) {
508
+ case "className": return { class: classNameOf(value) };
509
+ case "withProps": {
510
+ const props = value && typeof value === "object" ? value : {};
511
+ if (Object.prototype.hasOwnProperty.call(props, "unsafeHTML"))
512
+ throw new TypeError("unsafeHTML must be supplied to Element, not withProps");
513
+ return props;
514
+ }
515
+ case "id": return { "data-mun-id": String(value) };
516
+ case "disabled": return value === true ? { disabled: true, inert: true, "aria-disabled": true } : { disabled: false, inert: false, "aria-disabled": false };
517
+ case "onTapGesture": {
518
+ const count = typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 1;
519
+ const action = modifier.arguments[1];
520
+ if (typeof action !== "function")
521
+ return {};
522
+ if (count === 1)
523
+ return { onClick: action };
524
+ if (count === 2)
525
+ return { onDoubleClick: action };
526
+ return { onClick(event) { if (event?.detail === count)
527
+ action(); } };
528
+ }
529
+ case "onLongPressGesture": {
530
+ const duration = Math.max(0, finite(value, 0.5)) * 1000;
531
+ const distance = Math.max(0, finite(modifier.arguments[1], 10));
532
+ const action = modifier.arguments[2];
533
+ const changed = modifier.arguments[3];
534
+ if (typeof action !== "function")
535
+ return {};
536
+ let timer;
537
+ let originX = 0;
538
+ let originY = 0;
539
+ let active = false;
540
+ const clear = () => { if (timer !== undefined)
541
+ clearTimeout(timer); timer = undefined; if (active && typeof changed === "function")
542
+ changed(false); active = false; };
543
+ return {
544
+ onPointerDown(event) {
545
+ clear();
546
+ active = true;
547
+ originX = finite(event?.clientX, 0);
548
+ originY = finite(event?.clientY, 0);
549
+ if (typeof changed === "function")
550
+ changed(true);
551
+ timer = setTimeout(() => { timer = undefined; action(); }, duration);
552
+ },
553
+ onPointerMove(event) {
554
+ if (!active)
555
+ return;
556
+ const dx = finite(event?.clientX, originX) - originX;
557
+ const dy = finite(event?.clientY, originY) - originY;
558
+ if (Math.hypot(dx, dy) > distance)
559
+ clear();
560
+ },
561
+ onPointerUp: clear,
562
+ onPointerCancel: clear,
563
+ onPointerLeave: clear,
564
+ };
565
+ }
566
+ case "onHover": return typeof value === "function" ? { onPointerEnter() { value(true); }, onPointerLeave() { value(false); } } : {};
567
+ case "onSubmit": return typeof value === "function" ? { onSubmit(event) { event?.preventDefault?.(); value(); } } : {};
568
+ case "focusable": {
569
+ const changed = modifier.arguments[1];
570
+ return value === false ? { tabIndex: -1 } : { tabIndex: 0, ...(typeof changed === "function" ? { onFocus() { changed(true); }, onBlur() { changed(false); } } : {}) };
571
+ }
572
+ case "draggable": return {
573
+ draggable: true,
574
+ onDragStart(event) {
575
+ let serialized;
576
+ try {
577
+ serialized = typeof value === "string" ? value : JSON.stringify(value);
578
+ }
579
+ catch {
580
+ serialized = String(value);
581
+ }
582
+ event?.dataTransfer?.setData?.("application/x-mun+json", serialized);
583
+ event?.dataTransfer?.setData?.("text/plain", serialized);
584
+ },
585
+ };
586
+ case "dropDestination": {
587
+ const action = modifier.arguments[1];
588
+ const targeted = modifier.arguments[2];
589
+ if (typeof action !== "function")
590
+ return {};
591
+ return {
592
+ onDragEnter(event) { event?.preventDefault?.(); if (typeof targeted === "function")
593
+ targeted(true); },
594
+ onDragOver(event) { event?.preventDefault?.(); },
595
+ onDragLeave() { if (typeof targeted === "function")
596
+ targeted(false); },
597
+ onDrop(event) {
598
+ event?.preventDefault?.();
599
+ if (typeof targeted === "function")
600
+ targeted(false);
601
+ const raw = event?.dataTransfer?.getData?.("application/x-mun+json") || event?.dataTransfer?.getData?.("text/plain") || "";
602
+ let item = raw;
603
+ try {
604
+ item = JSON.parse(raw);
605
+ }
606
+ catch { }
607
+ action([item], { x: finite(event?.clientX, 0), y: finite(event?.clientY, 0) });
608
+ },
609
+ };
610
+ }
611
+ case "scrollDismissesKeyboard": return value === "never" ? {} : { onScroll(event) { const active = event?.currentTarget?.ownerDocument?.activeElement; active?.blur?.(); } };
612
+ case "accessibilityLabel": return { "aria-label": String(value) };
613
+ case "accessibilityHint": return { "aria-description": String(value) };
614
+ case "accessibilityValue": return { "aria-valuetext": String(value) };
615
+ case "accessibilityHidden": return { "aria-hidden": Boolean(value) };
616
+ case "accessibilityIdentifier": return { "data-accessibility-id": String(value) };
617
+ case "accessibilityHeading": return { role: "heading", "aria-level": /^h([1-6])$/.test(String(value)) ? Number(String(value).slice(1)) : 2 };
618
+ case "accessibilitySortPriority": return { "data-accessibility-sort-priority": String(finite(value, 0)) };
619
+ case "accessibilityElement": return { role: value === "contain" ? "group" : undefined, "data-accessibility-children": String(value ?? "ignore") };
620
+ case "accessibilityAction": return typeof modifier.arguments[1] === "function" ? { "data-accessibility-action": String(value), onClick: modifier.arguments[1] } : {};
621
+ default: return {};
622
+ }
623
+ }
624
+ export function styleText(value) {
625
+ return Object.entries(value).filter(([, item]) => item !== "undefined" && item !== "").map(([key, item]) => `${key}:${item}`).join(";");
626
+ }
627
+ export function cssPropertyName(value) {
628
+ return value.startsWith("--") ? value : value.replace(/[A-Z]/g, character => `-${character.toLowerCase()}`);
629
+ }
630
+ function normalizedStyle(value) {
631
+ return Object.fromEntries(Object.entries(value).flatMap(([key, item]) => item === undefined || item === null ? [] : [[cssPropertyName(key), String(item)]]));
632
+ }
633
+ export function styleAttribute(value) {
634
+ if (typeof value !== "object" || value === null)
635
+ return typeof value === "string" ? value : undefined;
636
+ return styleText(normalizedStyle(value));
637
+ }
638
+ export function nativeElementProps(props) {
639
+ try {
640
+ const normalized = {};
641
+ for (const key of Reflect.ownKeys(props)) {
642
+ if (typeof key !== "string")
643
+ continue;
644
+ const descriptor = Object.getOwnPropertyDescriptor(props, key);
645
+ if (!descriptor || !("value" in descriptor))
646
+ continue;
647
+ const value = descriptor.value;
648
+ const primitive = value === undefined || value === null || typeof value === "string" || typeof value === "boolean"
649
+ || (typeof value === "number" && Number.isFinite(value));
650
+ if (primitive
651
+ || (key === "style" && typeof value === "object" && value !== null)
652
+ || (key === "ref" && (typeof value === "object" || typeof value === "function"))
653
+ || (isEventPropName(key) && typeof value === "function")) {
654
+ Object.defineProperty(normalized, key, { ...descriptor, configurable: true });
655
+ }
656
+ }
657
+ return normalized;
658
+ }
659
+ catch {
660
+ return {};
661
+ }
662
+ }
663
+ export function escapeAttribute(value) {
664
+ return escape(value).replaceAll("'", "&#39;");
665
+ }
666
+ export function normalizedTextAreaValue(value) {
667
+ return String(value).replace(/\r\n?/g, "\n");
668
+ }
669
+ export const rawTextHtmlElements = new Set(["script", "style"]);
670
+ export function normalizedRawTextValue(tag, value) {
671
+ const lowerTag = tag.toLowerCase();
672
+ const text = String(value).replace(/\r\n?/g, "\n").replaceAll("\0", "\uFFFD");
673
+ if (new RegExp(`</${lowerTag}`, "i").test(text)) {
674
+ throw new TypeError(`<${lowerTag}> text cannot contain its HTML closing-tag sequence`);
675
+ }
676
+ return text;
677
+ }
678
+ export function domContentContainer(element) {
679
+ const candidate = element;
680
+ return element.namespaceURI === "http://www.w3.org/1999/xhtml"
681
+ && element.localName.toLowerCase() === "template"
682
+ && candidate.content?.nodeType === 11
683
+ ? candidate.content
684
+ : element;
685
+ }
686
+ export const validTableChildElements = new Set(["caption", "colgroup", "thead", "tbody", "tfoot", "script", "template"]);
687
+ export const voidHtmlElements = new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
688
+ // Raw markup is a web-only escape hatch. Restrict host contexts to ordinary
689
+ // HTML containers; form controls, table/select syntax, SVG and raw-text elements
690
+ // have parser-specific ownership and cannot safely share this contract.
691
+ const unsafeHtmlHosts = new Set(['div', 'span', 'section', 'article', 'aside', 'main', 'header', 'footer', 'nav', 'blockquote', 'figure', 'figcaption']);
692
+ export function validateUnsafeHTML(tag, props, childCount) {
693
+ const value = props?.unsafeHTML;
694
+ if (value == null)
695
+ return undefined;
696
+ if (typeof value !== 'string')
697
+ throw new TypeError('unsafeHTML must be a string');
698
+ if (childCount)
699
+ throw new TypeError('unsafeHTML cannot be combined with children');
700
+ if (!unsafeHtmlHosts.has(tag.toLowerCase()))
701
+ throw new TypeError('unsafeHTML is not supported on this element');
702
+ return value;
703
+ }
704
+ //# sourceMappingURL=shared.js.map