@epoch32/visage 1.1.2 → 1.1.4

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 (52) hide show
  1. package/dist/api/index.js +55 -4085
  2. package/dist/charts/index.js +48 -2806
  3. package/dist/devtools/index.js +18 -4766
  4. package/dist/dom/index.js +32 -1639
  5. package/dist/form/index.js +13 -1498
  6. package/dist/index-061jf06a.js +848 -0
  7. package/dist/index-0madxn60.js +442 -0
  8. package/dist/index-1xtrtz1t.js +256 -0
  9. package/dist/index-2zz0g2n2.js +212 -0
  10. package/dist/index-5s255b3w.js +303 -0
  11. package/dist/index-6kfe1nr4.js +1179 -0
  12. package/dist/index-8czhpea8.js +338 -0
  13. package/dist/index-8x8xz80v.js +727 -0
  14. package/dist/index-921pn75b.js +0 -0
  15. package/dist/index-965ryh36.js +537 -0
  16. package/dist/index-9fvarkrx.js +98 -0
  17. package/dist/index-a4xns6cc.js +219 -0
  18. package/dist/index-b5wc752a.js +1696 -0
  19. package/dist/index-df5e614s.js +334 -0
  20. package/dist/index-dyvgtp43.js +1094 -0
  21. package/dist/index-grhdtcb5.js +234 -0
  22. package/dist/index-h6tjqk6e.js +158 -0
  23. package/dist/index-js199er4.js +101 -0
  24. package/dist/index-x2rs3vab.js +124 -0
  25. package/dist/index-y9bq7h9g.js +1162 -0
  26. package/dist/index-zr6cvset.js +2092 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +458 -11915
  29. package/dist/jsx-runtime/index.js +13 -1719
  30. package/dist/query/index.js +47 -2505
  31. package/dist/router/index.js +25 -1945
  32. package/dist/rpc/index.js +39 -3567
  33. package/dist/server/index.js +11 -1256
  34. package/dist/signals/index.js +52 -1160
  35. package/dist/style/index.js +77 -2429
  36. package/dist/template/index.js +7 -1232
  37. package/dist/ui/index.d.ts +1 -1
  38. package/dist/ui/index.js +150 -4244
  39. package/dist/ui/tabs.d.ts +23 -1
  40. package/dist/virtual/index.js +12 -2044
  41. package/dist/vite/index.js +5 -744
  42. package/package.json +2 -2
  43. package/src/dom/render.ts +20 -7
  44. package/src/index.ts +2 -0
  45. package/src/signals/computed.ts +19 -12
  46. package/src/signals/context.ts +1 -2
  47. package/src/signals/effect.ts +7 -7
  48. package/src/signals/signal.ts +16 -12
  49. package/src/signals/system.ts +50 -21
  50. package/src/ui/index.ts +2 -0
  51. package/src/ui/tabs.tsx +211 -5
  52. package/src/ui/utils.ts +1 -3
@@ -0,0 +1,442 @@
1
+ import {
2
+ cx2,
3
+ formatStyleProp2,
4
+ onCleanup2,
5
+ effect2
6
+ } from "./index-6kfe1nr4.js";
7
+
8
+ // src/style/hash.ts
9
+ function hashString2(str) {
10
+ let hash = 2166136261;
11
+ for (let i = 0;i < str.length; i++) {
12
+ hash ^= str.charCodeAt(i);
13
+ hash = Math.imul(hash, 16777619);
14
+ }
15
+ return (hash >>> 0).toString(36);
16
+ }
17
+ function getScopeId2(css, prefix = "v") {
18
+ const hash = hashString2(css.trim());
19
+ return `${prefix}-${hash}`;
20
+ }
21
+
22
+ // src/style/manager.ts
23
+ class StyleManager2 {
24
+ _styles = new Map;
25
+ _ssrStyles = new Set;
26
+ inject(id, css) {
27
+ let entry = this._styles.get(id);
28
+ if (!entry) {
29
+ entry = { id, css, count: 0 };
30
+ this._styles.set(id, entry);
31
+ if (typeof document !== "undefined") {
32
+ const target = document.head || document.documentElement || document.body;
33
+ if (target) {
34
+ const styleEl = document.createElement("style");
35
+ styleEl.id = `visage-style-${id}`;
36
+ styleEl.setAttribute("data-visage-scope", id);
37
+ styleEl.textContent = css;
38
+ target.appendChild(styleEl);
39
+ entry.element = styleEl;
40
+ }
41
+ }
42
+ this._ssrStyles.add(css);
43
+ }
44
+ entry.count++;
45
+ return () => {
46
+ if (!entry)
47
+ return;
48
+ entry.count--;
49
+ if (entry.count <= 0) {
50
+ if (entry.element?.parentNode) {
51
+ entry.element.parentNode.removeChild(entry.element);
52
+ }
53
+ this._styles.delete(id);
54
+ }
55
+ };
56
+ }
57
+ has(id) {
58
+ return this._styles.has(id);
59
+ }
60
+ extractSSRStyles() {
61
+ return Array.from(this._ssrStyles).join(`
62
+ `);
63
+ }
64
+ clear() {
65
+ for (const entry of this._styles.values()) {
66
+ if (entry.element?.parentNode) {
67
+ entry.element.parentNode.removeChild(entry.element);
68
+ }
69
+ }
70
+ this._styles.clear();
71
+ this._ssrStyles.clear();
72
+ }
73
+ }
74
+ var styleManager2 = new StyleManager2;
75
+ function extractStyleTags2() {
76
+ const css = styleManager2.extractSSRStyles();
77
+ return css ? `<style data-visage-ssr="true">${css}</style>` : "";
78
+ }
79
+
80
+ // src/style/parser.ts
81
+ function scopeSelector2(selector, options) {
82
+ const { scopeId, passToChildren = false } = options;
83
+ const scopeAttr = `[data-${scopeId}]`;
84
+ const parts = splitSelectorList(selector);
85
+ return parts.map((part) => {
86
+ const trimmed = part.trim();
87
+ if (!trimmed)
88
+ return "";
89
+ if (trimmed.includes(":global(") || trimmed.includes("::v-global(")) {
90
+ return trimmed.replace(/(.*?)(?:::v-global|:global)\(([^)]+)\)(.*)/g, (_match, before, globalTarget, after) => {
91
+ const prefix = before.trim();
92
+ const scopedPrefix = prefix ? scopeCompoundSelector(prefix, scopeAttr) : "";
93
+ if (scopedPrefix) {
94
+ return `${scopedPrefix} ${globalTarget.trim()}${after}`;
95
+ }
96
+ return `${globalTarget.trim()}${after}`;
97
+ }).trim();
98
+ }
99
+ if (trimmed.includes(":deep(") || trimmed.includes("::v-deep(")) {
100
+ return trimmed.replace(/(.*?)(?:::v-deep|:deep)\(([^)]+)\)(.*)/g, (_match, before, deepTarget, after) => {
101
+ const prefix = before.trim();
102
+ const scopedPrefix = prefix ? scopeCompoundSelector(prefix, scopeAttr) : scopeAttr;
103
+ return `${scopedPrefix} ${deepTarget.trim()}${after}`;
104
+ }).trim();
105
+ }
106
+ if (passToChildren) {
107
+ const compound = scopeCompoundSelector(trimmed, scopeAttr);
108
+ return `${scopeAttr} ${trimmed}, ${compound}`;
109
+ }
110
+ return scopeCompoundSelector(trimmed, scopeAttr);
111
+ }).filter(Boolean).join(", ");
112
+ }
113
+ function scopeCompoundSelector(selector, scopeAttr) {
114
+ const combinatorRegex = /([ >+~]+)/;
115
+ const tokens = selector.split(combinatorRegex);
116
+ const scopedTokens = tokens.map((token, index) => {
117
+ if (index % 2 === 1)
118
+ return token;
119
+ const piece = token.trim();
120
+ if (!piece || piece === "*")
121
+ return piece ? `${piece}${scopeAttr}` : "";
122
+ const pseudoElemIdx = piece.indexOf("::");
123
+ if (pseudoElemIdx !== -1) {
124
+ const base = piece.slice(0, pseudoElemIdx);
125
+ const pseudo = piece.slice(pseudoElemIdx);
126
+ return `${base}${scopeAttr}${pseudo}`;
127
+ }
128
+ const pseudoClassIdx = piece.indexOf(":");
129
+ if (pseudoClassIdx !== -1) {
130
+ const base = piece.slice(0, pseudoClassIdx);
131
+ const pseudo = piece.slice(pseudoClassIdx);
132
+ return `${base}${scopeAttr}${pseudo}`;
133
+ }
134
+ return `${piece}${scopeAttr}`;
135
+ });
136
+ return scopedTokens.join("");
137
+ }
138
+ function splitSelectorList(selectorList) {
139
+ const result = [];
140
+ let depth = 0;
141
+ let current = "";
142
+ for (let i = 0;i < selectorList.length; i++) {
143
+ const char = selectorList[i];
144
+ if (char === "(") {
145
+ depth++;
146
+ current += char;
147
+ } else if (char === ")") {
148
+ depth = Math.max(0, depth - 1);
149
+ current += char;
150
+ } else if (char === "," && depth === 0) {
151
+ if (current.trim())
152
+ result.push(current.trim());
153
+ current = "";
154
+ } else {
155
+ current += char;
156
+ }
157
+ }
158
+ if (current.trim())
159
+ result.push(current.trim());
160
+ return result;
161
+ }
162
+ function scopeCSS2(css, options) {
163
+ const { scopeId } = options;
164
+ const keyframeNames = new Set;
165
+ const keyframeRegex = /@(?:-webkit-)?keyframes\s+([a-zA-Z0-9_-]+)/g;
166
+ let kMatch = keyframeRegex.exec(css);
167
+ while (kMatch !== null) {
168
+ if (kMatch[1]) {
169
+ keyframeNames.add(kMatch[1]);
170
+ }
171
+ kMatch = keyframeRegex.exec(css);
172
+ }
173
+ let processed = css;
174
+ for (const name of keyframeNames) {
175
+ const scopedName = `${scopeId}-${name}`;
176
+ const defRegex = new RegExp(`(@(?:-webkit-)?keyframes\\s+)${name}\\b`, "g");
177
+ processed = processed.replace(defRegex, `$1${scopedName}`);
178
+ }
179
+ if (keyframeNames.size > 0) {
180
+ for (const name of keyframeNames) {
181
+ const scopedName = `${scopeId}-${name}`;
182
+ const animRegex = new RegExp(`(animation(?:-name)?\\s*:[^;}]*?)\\b${name}\\b([^;}]*)`, "g");
183
+ processed = processed.replace(animRegex, `$1${scopedName}$2`);
184
+ }
185
+ }
186
+ return transformRules(processed, options);
187
+ }
188
+ function transformRules(css, options) {
189
+ let output = "";
190
+ let i = 0;
191
+ const len = css.length;
192
+ while (i < len) {
193
+ while (i < len && /\s/.test(css[i])) {
194
+ output += css[i];
195
+ i++;
196
+ }
197
+ if (i >= len)
198
+ break;
199
+ if (css[i] === "/" && css[i + 1] === "*") {
200
+ const endComment = css.indexOf("*/", i + 2);
201
+ if (endComment === -1) {
202
+ output += css.slice(i);
203
+ break;
204
+ }
205
+ output += css.slice(i, endComment + 2);
206
+ i = endComment + 2;
207
+ continue;
208
+ }
209
+ const openBrace = css.indexOf("{", i);
210
+ if (openBrace === -1) {
211
+ output += css.slice(i);
212
+ break;
213
+ }
214
+ const header = css.slice(i, openBrace).trim();
215
+ if (header.startsWith("@")) {
216
+ if (header.startsWith("@media") || header.startsWith("@supports") || header.startsWith("@container")) {
217
+ const closeBrace = findMatchingBrace(css, openBrace);
218
+ const innerContent = css.slice(openBrace + 1, closeBrace);
219
+ const transformedInner = transformRules(innerContent, options);
220
+ output += `${header} {
221
+ ${transformedInner}
222
+ }`;
223
+ i = closeBrace + 1;
224
+ continue;
225
+ }
226
+ if (header.includes("keyframes") || header.startsWith("@font-face")) {
227
+ const closeBrace = findMatchingBrace(css, openBrace);
228
+ output += css.slice(i, closeBrace + 1);
229
+ i = closeBrace + 1;
230
+ continue;
231
+ }
232
+ }
233
+ const closeBrace = css.indexOf("}", openBrace);
234
+ if (closeBrace === -1) {
235
+ output += css.slice(i);
236
+ break;
237
+ }
238
+ const body = css.slice(openBrace + 1, closeBrace);
239
+ const scopedSelector = scopeSelector2(header, options);
240
+ output += `${scopedSelector} {${body}}`;
241
+ i = closeBrace + 1;
242
+ }
243
+ return output;
244
+ }
245
+ function findMatchingBrace(str, openIndex) {
246
+ let depth = 0;
247
+ for (let i = openIndex;i < str.length; i++) {
248
+ if (str[i] === "{")
249
+ depth++;
250
+ else if (str[i] === "}") {
251
+ depth--;
252
+ if (depth === 0)
253
+ return i;
254
+ }
255
+ }
256
+ return str.length - 1;
257
+ }
258
+
259
+ // src/style/create-style.ts
260
+ function formatCSSValue(prop, val) {
261
+ return formatStyleProp2(prop, val);
262
+ }
263
+ function objectToCSS2(classes) {
264
+ let css = "";
265
+ for (const [selector, rules] of Object.entries(classes)) {
266
+ if (typeof rules !== "object" || rules === null)
267
+ continue;
268
+ const sel = selector.startsWith(".") || selector.startsWith("@") || selector.startsWith(":") || selector.includes(" ") || selector === "*" ? selector : `.${selector}`;
269
+ let mainRules = "";
270
+ let nestedRules = "";
271
+ for (const [prop, val] of Object.entries(rules)) {
272
+ if (typeof val === "object" && val !== null) {
273
+ const nestedSel = prop.startsWith("&") ? prop.replace(/&/g, sel) : prop.startsWith(":") ? `${sel}${prop}` : `${sel} ${prop}`;
274
+ nestedRules += `${nestedSel} {
275
+ `;
276
+ for (const [np, nv] of Object.entries(val)) {
277
+ if (nv !== undefined && nv !== null) {
278
+ const kebab = np.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
279
+ nestedRules += ` ${kebab}: ${formatCSSValue(np, nv)};
280
+ `;
281
+ }
282
+ }
283
+ nestedRules += `}
284
+ `;
285
+ } else if (val !== undefined && val !== null) {
286
+ const kebab = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
287
+ mainRules += ` ${kebab}: ${formatCSSValue(prop, val)};
288
+ `;
289
+ }
290
+ }
291
+ if (mainRules) {
292
+ css += `${sel} {
293
+ ${mainRules}}
294
+ `;
295
+ }
296
+ if (nestedRules) {
297
+ css += nestedRules;
298
+ }
299
+ }
300
+ return css;
301
+ }
302
+ function createStyle2(templateOrObject, ...valuesOrOptions) {
303
+ let cssInput = "";
304
+ let options;
305
+ if (typeof templateOrObject === "object" && !Array.isArray(templateOrObject)) {
306
+ cssInput = objectToCSS2(templateOrObject);
307
+ options = valuesOrOptions[0];
308
+ } else if (typeof templateOrObject === "string") {
309
+ cssInput = templateOrObject;
310
+ options = valuesOrOptions[0];
311
+ } else {
312
+ const template = templateOrObject;
313
+ for (let i = 0;i < template.length; i++) {
314
+ cssInput += template[i];
315
+ if (i < valuesOrOptions.length) {
316
+ cssInput += String(valuesOrOptions[i]);
317
+ }
318
+ }
319
+ }
320
+ const scopeId = options?.id ?? getScopeId2(cssInput);
321
+ const scopeAttr = `data-${scopeId}`;
322
+ const classMap = {};
323
+ const classRegex = /\.([a-zA-Z0-9_-]+)/g;
324
+ let match = classRegex.exec(cssInput);
325
+ while (match !== null) {
326
+ const className = match[1];
327
+ if (className && !classMap[className]) {
328
+ classMap[className] = `${className}_${scopeId}`;
329
+ }
330
+ match = classRegex.exec(cssInput);
331
+ }
332
+ let transformedCSS = cssInput;
333
+ for (const [orig, scoped] of Object.entries(classMap)) {
334
+ const replaceRegex = new RegExp(`\\.${orig}\\b`, "g");
335
+ transformedCSS = transformedCSS.replace(replaceRegex, `.${scoped}`);
336
+ }
337
+ const finalScopedCSS = scopeCSS2(transformedCSS, {
338
+ scopeId,
339
+ passToChildren: options?.passToChildren ?? false
340
+ });
341
+ styleManager2.inject(scopeId, finalScopedCSS);
342
+ const result = {
343
+ ...classMap,
344
+ scope: scopeId,
345
+ scopeAttr,
346
+ css: finalScopedCSS,
347
+ cx: (...args) => cx2(...args)
348
+ };
349
+ return result;
350
+ }
351
+ function css2(strings, ...values) {
352
+ let rawCSS = "";
353
+ for (let i = 0;i < strings.length; i++) {
354
+ rawCSS += strings[i];
355
+ if (i < values.length) {
356
+ rawCSS += String(values[i]);
357
+ }
358
+ }
359
+ const scopeId = getScopeId2(rawCSS, "cls");
360
+ const className = `visage_${scopeId}`;
361
+ const fullCSS = rawCSS.includes("&") ? rawCSS.replace(/&/g, `.${className}`) : `.${className} { ${rawCSS} }`;
362
+ const scoped = scopeCSS2(fullCSS, { scopeId });
363
+ styleManager2.inject(scopeId, scoped);
364
+ return className;
365
+ }
366
+ function useStyle2(cssInput, options) {
367
+ const getRaw = () => {
368
+ const val = typeof cssInput === "function" ? cssInput() : cssInput;
369
+ return typeof val === "object" ? objectToCSS2(val) : val;
370
+ };
371
+ const raw = getRaw();
372
+ const scopeId = options?.id ?? getScopeId2(raw);
373
+ const scopedCSS = scopeCSS2(raw, {
374
+ scopeId,
375
+ passToChildren: options?.passToChildren ?? false
376
+ });
377
+ const cleanup = styleManager2.inject(scopeId, scopedCSS);
378
+ onCleanup2(() => {
379
+ cleanup();
380
+ });
381
+ return scopeId;
382
+ }
383
+
384
+ // src/style/component.tsx
385
+ function Style2(props) {
386
+ const getRawCSS = () => {
387
+ if (props.classes) {
388
+ const cls = typeof props.classes === "function" ? props.classes() : props.classes;
389
+ return objectToCSS2(cls);
390
+ }
391
+ if (props.children) {
392
+ const ch = typeof props.children === "function" ? props.children() : props.children;
393
+ return typeof ch === "object" ? objectToCSS2(ch) : ch;
394
+ }
395
+ return "";
396
+ };
397
+ const rawCSS = getRawCSS();
398
+ const scopeId = props.id ?? getScopeId2(rawCSS);
399
+ const scopeAttr = `data-${scopeId}`;
400
+ if (typeof document !== "undefined") {
401
+ const marker = document.createTextNode("");
402
+ let unsubscribe = null;
403
+ effect2(() => {
404
+ const currentCSS = getRawCSS();
405
+ const currentScopeId = props.id ?? getScopeId2(currentCSS);
406
+ const scoped = scopeCSS2(currentCSS, {
407
+ scopeId: currentScopeId,
408
+ passToChildren: props.passToChildren ?? true
409
+ });
410
+ if (unsubscribe) {
411
+ unsubscribe();
412
+ }
413
+ unsubscribe = styleManager2.inject(currentScopeId, scoped);
414
+ const attachScope = () => {
415
+ const parent = marker.parentElement || marker.parentNode;
416
+ if (parent && typeof parent.setAttribute === "function") {
417
+ parent.setAttribute(`data-${currentScopeId}`, "");
418
+ }
419
+ };
420
+ attachScope();
421
+ queueMicrotask(attachScope);
422
+ });
423
+ onCleanup2(() => {
424
+ if (unsubscribe) {
425
+ unsubscribe();
426
+ }
427
+ const parent = marker.parentElement || marker.parentNode;
428
+ if (parent && typeof parent.removeAttribute === "function") {
429
+ parent.removeAttribute(scopeAttr);
430
+ }
431
+ });
432
+ return marker;
433
+ }
434
+ const scoped = scopeCSS2(rawCSS, {
435
+ scopeId,
436
+ passToChildren: props.passToChildren ?? true
437
+ });
438
+ styleManager2.inject(scopeId, scoped);
439
+ return null;
440
+ }
441
+
442
+ export { hashString2, getScopeId2, StyleManager2, styleManager2, extractStyleTags2, scopeSelector2, scopeCSS2, objectToCSS2, createStyle2, css2, useStyle2, Style2 };
@@ -0,0 +1,256 @@
1
+ import {
2
+ space2,
3
+ resolveDimension2
4
+ } from "./index-6kfe1nr4.js";
5
+ import {
6
+ jsx2
7
+ } from "./index-9fvarkrx.js";
8
+
9
+ // src/style/layout.tsx
10
+ var ALIGN_MAP = {
11
+ start: "flex-start",
12
+ center: "center",
13
+ end: "flex-end",
14
+ stretch: "stretch",
15
+ baseline: "baseline"
16
+ };
17
+ var JUSTIFY_MAP = {
18
+ start: "flex-start",
19
+ center: "center",
20
+ end: "flex-end",
21
+ between: "space-between",
22
+ around: "space-around",
23
+ evenly: "space-evenly",
24
+ stretch: "stretch"
25
+ };
26
+ function resolveBaseStyles(props) {
27
+ const s = {
28
+ boxSizing: "border-box"
29
+ };
30
+ if (props.gap !== undefined)
31
+ s.gap = space2(props.gap);
32
+ if (props.p !== undefined)
33
+ s.padding = space2(props.p);
34
+ if (props.px !== undefined) {
35
+ s.paddingLeft = space2(props.px);
36
+ s.paddingRight = space2(props.px);
37
+ }
38
+ if (props.py !== undefined) {
39
+ s.paddingTop = space2(props.py);
40
+ s.paddingBottom = space2(props.py);
41
+ }
42
+ if (props.pt !== undefined)
43
+ s.paddingTop = space2(props.pt);
44
+ if (props.pb !== undefined)
45
+ s.paddingBottom = space2(props.pb);
46
+ if (props.pl !== undefined)
47
+ s.paddingLeft = space2(props.pl);
48
+ if (props.pr !== undefined)
49
+ s.paddingRight = space2(props.pr);
50
+ if (props.m !== undefined)
51
+ s.margin = space2(props.m);
52
+ if (props.mx !== undefined) {
53
+ s.marginLeft = space2(props.mx);
54
+ s.marginRight = space2(props.mx);
55
+ }
56
+ if (props.my !== undefined) {
57
+ s.marginTop = space2(props.my);
58
+ s.marginBottom = space2(props.my);
59
+ }
60
+ if (props.mt !== undefined)
61
+ s.marginTop = space2(props.mt);
62
+ if (props.mb !== undefined)
63
+ s.marginBottom = space2(props.mb);
64
+ if (props.ml !== undefined)
65
+ s.marginLeft = space2(props.ml);
66
+ if (props.mr !== undefined)
67
+ s.marginRight = space2(props.mr);
68
+ if (props.w !== undefined)
69
+ s.width = resolveDimension2(props.w);
70
+ if (props.h !== undefined)
71
+ s.height = resolveDimension2(props.h);
72
+ if (props.minW !== undefined)
73
+ s.minWidth = resolveDimension2(props.minW);
74
+ if (props.maxW !== undefined)
75
+ s.maxWidth = resolveDimension2(props.maxW);
76
+ if (props.minH !== undefined)
77
+ s.minHeight = resolveDimension2(props.minH);
78
+ if (props.maxH !== undefined)
79
+ s.maxHeight = resolveDimension2(props.maxH);
80
+ return s;
81
+ }
82
+ function mergeStyles(base, userStyle) {
83
+ if (!userStyle)
84
+ return base;
85
+ if (typeof userStyle === "string") {
86
+ const baseStr = Object.entries(base).map(([k, v]) => `${k.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${v}`).join("; ");
87
+ return `${baseStr}; ${userStyle}`;
88
+ }
89
+ if (typeof userStyle === "object") {
90
+ return { ...base, ...userStyle };
91
+ }
92
+ return base;
93
+ }
94
+ function cleanProps(props, excludeKeys) {
95
+ const result = {};
96
+ for (const k in props) {
97
+ if (!excludeKeys.has(k)) {
98
+ result[k] = props[k];
99
+ }
100
+ }
101
+ return result;
102
+ }
103
+ var COMMON_EXCLUDE = new Set([
104
+ "as",
105
+ "gap",
106
+ "p",
107
+ "px",
108
+ "py",
109
+ "pt",
110
+ "pb",
111
+ "pl",
112
+ "pr",
113
+ "m",
114
+ "mx",
115
+ "my",
116
+ "mt",
117
+ "mb",
118
+ "ml",
119
+ "mr",
120
+ "w",
121
+ "h",
122
+ "minW",
123
+ "maxW",
124
+ "minH",
125
+ "maxH"
126
+ ]);
127
+ var STACK_EXCLUDE = new Set([
128
+ ...COMMON_EXCLUDE,
129
+ "align",
130
+ "justify",
131
+ "direction",
132
+ "reversed",
133
+ "wrap",
134
+ "inline"
135
+ ]);
136
+ function Stack2(props) {
137
+ const { as = "div", children, ...rest } = props;
138
+ const layoutStyles = resolveBaseStyles(props);
139
+ layoutStyles.display = props.inline ? "inline-flex" : "flex";
140
+ layoutStyles.flexDirection = props.direction === "horizontal" ? props.reversed ? "row-reverse" : "row" : props.reversed ? "column-reverse" : "column";
141
+ if (props.align && ALIGN_MAP[props.align]) {
142
+ layoutStyles.alignItems = ALIGN_MAP[props.align];
143
+ }
144
+ if (props.justify && JUSTIFY_MAP[props.justify]) {
145
+ layoutStyles.justifyContent = JUSTIFY_MAP[props.justify];
146
+ }
147
+ if (props.wrap) {
148
+ layoutStyles.flexWrap = props.wrap === true ? "wrap" : props.wrap;
149
+ }
150
+ const domProps = cleanProps(rest, STACK_EXCLUDE);
151
+ domProps.style = mergeStyles(layoutStyles, props.style);
152
+ domProps.children = children;
153
+ return jsx2(as, domProps);
154
+ }
155
+ var ROW_EXCLUDE = new Set([...COMMON_EXCLUDE, "align", "justify", "reversed", "wrap", "inline"]);
156
+ function Row2(props) {
157
+ const { as = "div", children, ...rest } = props;
158
+ const layoutStyles = resolveBaseStyles(props);
159
+ layoutStyles.display = props.inline ? "inline-flex" : "flex";
160
+ layoutStyles.flexDirection = props.reversed ? "row-reverse" : "row";
161
+ layoutStyles.alignItems = props.align ? ALIGN_MAP[props.align] ?? props.align : "center";
162
+ if (props.justify && JUSTIFY_MAP[props.justify]) {
163
+ layoutStyles.justifyContent = JUSTIFY_MAP[props.justify];
164
+ }
165
+ if (props.wrap) {
166
+ layoutStyles.flexWrap = props.wrap === true ? "wrap" : props.wrap;
167
+ }
168
+ const domProps = cleanProps(rest, ROW_EXCLUDE);
169
+ domProps.style = mergeStyles(layoutStyles, props.style);
170
+ domProps.children = children;
171
+ return jsx2(as, domProps);
172
+ }
173
+ var CENTER_EXCLUDE = new Set([...COMMON_EXCLUDE, "inline"]);
174
+ function Center2(props) {
175
+ const { as = "div", children, ...rest } = props;
176
+ const layoutStyles = resolveBaseStyles(props);
177
+ layoutStyles.display = props.inline ? "inline-flex" : "flex";
178
+ layoutStyles.alignItems = "center";
179
+ layoutStyles.justifyContent = "center";
180
+ const domProps = cleanProps(rest, CENTER_EXCLUDE);
181
+ domProps.style = mergeStyles(layoutStyles, props.style);
182
+ domProps.children = children;
183
+ return jsx2(as, domProps);
184
+ }
185
+ var GRID_EXCLUDE = new Set([
186
+ ...COMMON_EXCLUDE,
187
+ "columns",
188
+ "minChildWidth",
189
+ "rows",
190
+ "rowGap",
191
+ "colGap",
192
+ "align",
193
+ "justify",
194
+ "inline"
195
+ ]);
196
+ function Grid2(props) {
197
+ const { as = "div", children, ...rest } = props;
198
+ const layoutStyles = resolveBaseStyles(props);
199
+ layoutStyles.display = props.inline ? "inline-grid" : "grid";
200
+ if (props.minChildWidth !== undefined) {
201
+ const minW = resolveDimension2(props.minChildWidth);
202
+ layoutStyles.gridTemplateColumns = `repeat(auto-fit, minmax(min(100%, ${minW}), 1fr))`;
203
+ } else if (props.columns !== undefined) {
204
+ if (typeof props.columns === "number") {
205
+ layoutStyles.gridTemplateColumns = `repeat(${props.columns}, minmax(0, 1fr))`;
206
+ } else {
207
+ layoutStyles.gridTemplateColumns = String(props.columns);
208
+ }
209
+ }
210
+ if (props.rows !== undefined) {
211
+ if (typeof props.rows === "number") {
212
+ layoutStyles.gridTemplateRows = `repeat(${props.rows}, minmax(0, 1fr))`;
213
+ } else {
214
+ layoutStyles.gridTemplateRows = String(props.rows);
215
+ }
216
+ }
217
+ if (props.rowGap !== undefined)
218
+ layoutStyles.rowGap = space2(props.rowGap);
219
+ if (props.colGap !== undefined)
220
+ layoutStyles.columnGap = space2(props.colGap);
221
+ if (props.align) {
222
+ layoutStyles.alignItems = ALIGN_MAP[props.align] ?? props.align;
223
+ }
224
+ if (props.justify) {
225
+ layoutStyles.justifyItems = props.justify;
226
+ }
227
+ const domProps = cleanProps(rest, GRID_EXCLUDE);
228
+ domProps.style = mergeStyles(layoutStyles, props.style);
229
+ domProps.children = children;
230
+ return jsx2(as, domProps);
231
+ }
232
+ var SPACER_EXCLUDE = new Set([...COMMON_EXCLUDE, "size", "x", "y", "flex"]);
233
+ function Spacer2(props) {
234
+ const { as = "div", ...rest } = props;
235
+ const layoutStyles = resolveBaseStyles(props);
236
+ if (props.size !== undefined) {
237
+ const s = space2(props.size);
238
+ layoutStyles.width = s;
239
+ layoutStyles.height = s;
240
+ layoutStyles.flexShrink = "0";
241
+ } else if (props.x !== undefined || props.y !== undefined) {
242
+ if (props.x !== undefined)
243
+ layoutStyles.width = space2(props.x);
244
+ if (props.y !== undefined)
245
+ layoutStyles.height = space2(props.y);
246
+ layoutStyles.flexShrink = "0";
247
+ } else {
248
+ layoutStyles.flex = typeof props.flex === "number" ? String(props.flex) : "1 1 0%";
249
+ layoutStyles.alignSelf = "stretch";
250
+ }
251
+ const domProps = cleanProps(rest, SPACER_EXCLUDE);
252
+ domProps.style = mergeStyles(layoutStyles, props.style);
253
+ return jsx2(as, domProps);
254
+ }
255
+
256
+ export { Stack2, Row2, Center2, Grid2, Spacer2 };