@mun-ui/web 0.0.0-stage → 0.2.1

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