@styleframe/core 3.2.0 → 3.3.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.
- package/CHANGELOG.md +18 -0
- package/dist/styleframe.d.ts +3 -1
- package/dist/styleframe.js +134 -122
- package/dist/styleframe.umd.cjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @styleframe/core
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#164](https://github.com/styleframe-dev/styleframe/pull/164) [`efd99f7`](https://github.com/styleframe-dev/styleframe/commit/efd99f70a30f9a42c6e1793ed777b1565fb47a82) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add className support for compound variants in recipes
|
|
8
|
+
- Add optional `className` field to compound variants, appended to output when conditions match
|
|
9
|
+
- Make `css` optional on compound variants, allowing className-only compound variants
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#175](https://github.com/styleframe-dev/styleframe/pull/175) [`b506ea5`](https://github.com/styleframe-dev/styleframe/commit/b506ea5c3c36fa24fea19a69ee3fef7035397dda) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Add Skeleton recipe with pulse animation and supporting utilities
|
|
14
|
+
- Add `useSkeletonRecipe` with size (`xs`, `sm`, `md`, `lg`, `xl`) and rounded (`true`, `false`) variants, pulse animation, and dark mode support
|
|
15
|
+
- Add granular animation utilities: `useAnimationNameUtility`, `useAnimationDurationUtility`, `useAnimationTimingFunctionUtility`, `useAnimationIterationCountUtility`
|
|
16
|
+
- Switch `useWidthUtility` and `useHeightUtility` to `createUseSpacingUtility` for `@N` multiplier support
|
|
17
|
+
- Add compound keyframe selector support in core engine (e.g. `"0%, 100%"`)
|
|
18
|
+
- Add Skeleton storybook component, grid previews, and stories
|
|
19
|
+
- Add Skeleton documentation page
|
|
20
|
+
|
|
3
21
|
## 3.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/styleframe.d.ts
CHANGED
|
@@ -433,7 +433,8 @@ export declare type Recipe<Name extends string = string, Variants extends Varian
|
|
|
433
433
|
match: {
|
|
434
434
|
[K in keyof Variants]?: keyof Variants[K] & string;
|
|
435
435
|
};
|
|
436
|
-
css
|
|
436
|
+
css?: VariantDeclarationsBlock;
|
|
437
|
+
className?: string;
|
|
437
438
|
}>;
|
|
438
439
|
_runtime?: RecipeRuntime<Variants>;
|
|
439
440
|
_exportName?: string;
|
|
@@ -454,6 +455,7 @@ export declare type RecipeRuntime<Variants extends VariantsBase = VariantsBase>
|
|
|
454
455
|
[K in keyof Variants]?: keyof Variants[K] & string;
|
|
455
456
|
};
|
|
456
457
|
css?: RuntimeVariantDeclarationsBlock;
|
|
458
|
+
className?: string;
|
|
457
459
|
}>;
|
|
458
460
|
};
|
|
459
461
|
|
package/dist/styleframe.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function
|
|
1
|
+
function x(e) {
|
|
2
2
|
return typeof e == "object" && e !== null;
|
|
3
3
|
}
|
|
4
4
|
function g(e, t) {
|
|
5
|
-
return
|
|
5
|
+
return x(e) && "type" in e && e.type === t;
|
|
6
6
|
}
|
|
7
7
|
function H(e) {
|
|
8
8
|
return g(e, "variable");
|
|
@@ -16,41 +16,41 @@ function _e(e) {
|
|
|
16
16
|
function te(e) {
|
|
17
17
|
return g(e, "at-rule");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Ne(e) {
|
|
20
20
|
return g(e, "utility");
|
|
21
21
|
}
|
|
22
22
|
function ne(e) {
|
|
23
23
|
return g(e, "modifier");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function T(e) {
|
|
26
26
|
return g(e, "css");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Oe(e) {
|
|
29
29
|
return g(e, "theme");
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function $(e) {
|
|
32
32
|
return g(e, "root");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function Se(e) {
|
|
35
35
|
return g(e, "recipe");
|
|
36
36
|
}
|
|
37
37
|
function re(e) {
|
|
38
38
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
39
39
|
}
|
|
40
40
|
function B(e) {
|
|
41
|
-
return re(e) || A(e) ||
|
|
41
|
+
return re(e) || A(e) || T(e) || Array.isArray(e) && e.every(B);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
43
|
+
function Te(e) {
|
|
44
|
+
return x(e) && "id" in e && "children" in e && "declarations" in e && "variables" in e;
|
|
45
45
|
}
|
|
46
46
|
function L(e) {
|
|
47
|
-
return
|
|
47
|
+
return x(e) && "children" in e && "declarations" in e && "variables" in e;
|
|
48
48
|
}
|
|
49
49
|
function ie(e) {
|
|
50
50
|
return typeof e == "string" && e.startsWith("@");
|
|
51
51
|
}
|
|
52
52
|
function Be(e) {
|
|
53
|
-
return
|
|
53
|
+
return x(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && $(e.root);
|
|
54
54
|
}
|
|
55
55
|
function se(e) {
|
|
56
56
|
let t = 5381;
|
|
@@ -64,7 +64,7 @@ function G(e) {
|
|
|
64
64
|
let i = o, f;
|
|
65
65
|
if (typeof i == "string" && i[0] === "@") {
|
|
66
66
|
const c = i.slice(1), a = s.find(
|
|
67
|
-
(
|
|
67
|
+
(y) => c === y || c.startsWith(`${y}.`)
|
|
68
68
|
);
|
|
69
69
|
let l, u;
|
|
70
70
|
a ? (l = c, u = c.startsWith(`${a}.`) ? c.slice(a.length + 1) : c) : s.length > 0 ? (l = `${s[0]}.${c}`, u = c) : (l = c, u = c), f = r(u), i = {
|
|
@@ -203,8 +203,8 @@ function ae(e) {
|
|
|
203
203
|
function n(i, f) {
|
|
204
204
|
const c = Object.keys(i), a = Array.from({ length: c.length });
|
|
205
205
|
for (let l = 0; l < c.length; l++) {
|
|
206
|
-
const u = c[l],
|
|
207
|
-
typeof
|
|
206
|
+
const u = c[l], y = i[u];
|
|
207
|
+
typeof y != "object" || y === null ? a[u] = y : y.constructor !== Object && (r = t.get(y.constructor)) ? a[u] = r(y, f) : ArrayBuffer.isView(y) ? a[u] = j(y) : a[u] = f(y);
|
|
208
208
|
}
|
|
209
209
|
return a;
|
|
210
210
|
}
|
|
@@ -249,17 +249,17 @@ function ue(e) {
|
|
|
249
249
|
return e.proto ? f : i;
|
|
250
250
|
function o(c, a) {
|
|
251
251
|
const l = Object.keys(c), u = Array.from({ length: l.length });
|
|
252
|
-
for (let
|
|
253
|
-
const
|
|
254
|
-
if (typeof
|
|
255
|
-
u[
|
|
256
|
-
else if (
|
|
257
|
-
u[
|
|
258
|
-
else if (ArrayBuffer.isView(
|
|
259
|
-
u[
|
|
252
|
+
for (let y = 0; y < l.length; y++) {
|
|
253
|
+
const d = l[y], m = c[d];
|
|
254
|
+
if (typeof m != "object" || m === null)
|
|
255
|
+
u[d] = m;
|
|
256
|
+
else if (m.constructor !== Object && (s = n.get(m.constructor)))
|
|
257
|
+
u[d] = s(m, a);
|
|
258
|
+
else if (ArrayBuffer.isView(m))
|
|
259
|
+
u[d] = j(m);
|
|
260
260
|
else {
|
|
261
|
-
const h = t.indexOf(
|
|
262
|
-
h !== -1 ? u[
|
|
261
|
+
const h = t.indexOf(m);
|
|
262
|
+
h !== -1 ? u[d] = r[h] : u[d] = a(m);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
return u;
|
|
@@ -281,8 +281,8 @@ function ue(e) {
|
|
|
281
281
|
else if (ArrayBuffer.isView(u))
|
|
282
282
|
a[l] = j(u);
|
|
283
283
|
else {
|
|
284
|
-
const
|
|
285
|
-
|
|
284
|
+
const y = t.indexOf(u);
|
|
285
|
+
y !== -1 ? a[l] = r[y] : a[l] = i(u);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
return t.pop(), r.pop(), a;
|
|
@@ -303,14 +303,14 @@ function ue(e) {
|
|
|
303
303
|
else if (ArrayBuffer.isView(u))
|
|
304
304
|
a[l] = j(u);
|
|
305
305
|
else {
|
|
306
|
-
const
|
|
307
|
-
|
|
306
|
+
const y = t.indexOf(u);
|
|
307
|
+
y !== -1 ? a[l] = r[y] : a[l] = f(u);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
return t.pop(), r.pop(), a;
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
const
|
|
313
|
+
const M = ae();
|
|
314
314
|
function b(e, t = 8) {
|
|
315
315
|
const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
316
316
|
let n = "";
|
|
@@ -340,24 +340,24 @@ function le(e, t) {
|
|
|
340
340
|
throw new Error(`Modifier "${t}" not found`);
|
|
341
341
|
return r;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function N(e, t) {
|
|
344
344
|
if (e === t) return !0;
|
|
345
345
|
if (typeof e != typeof t) return !1;
|
|
346
346
|
if (e === null || t === null) return e === t;
|
|
347
347
|
if (typeof e != "object" || typeof t != "object") return !1;
|
|
348
348
|
if (Array.isArray(e) && Array.isArray(t))
|
|
349
|
-
return e.length !== t.length ? !1 : e.every((r, n) =>
|
|
349
|
+
return e.length !== t.length ? !1 : e.every((r, n) => N(r, t[n]));
|
|
350
350
|
if ("type" in e && "type" in t) {
|
|
351
351
|
if (e.type !== t.type) return !1;
|
|
352
352
|
if (A(e) && A(t))
|
|
353
|
-
return e.name === t.name &&
|
|
354
|
-
if (
|
|
355
|
-
return
|
|
353
|
+
return e.name === t.name && N(e.fallback, t.fallback);
|
|
354
|
+
if (T(e) && T(t))
|
|
355
|
+
return N(e.value, t.value);
|
|
356
356
|
}
|
|
357
357
|
return !1;
|
|
358
358
|
}
|
|
359
359
|
const X = "__licenseRequired";
|
|
360
|
-
function
|
|
360
|
+
function ye(e) {
|
|
361
361
|
P(e) || Object.defineProperty(e, X, {
|
|
362
362
|
value: !0,
|
|
363
363
|
writable: !1,
|
|
@@ -368,7 +368,7 @@ function de(e) {
|
|
|
368
368
|
function P(e) {
|
|
369
369
|
return Object.prototype.hasOwnProperty.call(e, X);
|
|
370
370
|
}
|
|
371
|
-
function
|
|
371
|
+
function de(e, t) {
|
|
372
372
|
const r = [...e];
|
|
373
373
|
for (const n of t) {
|
|
374
374
|
const s = r.find(
|
|
@@ -378,7 +378,7 @@ function ye(e, t) {
|
|
|
378
378
|
}
|
|
379
379
|
return r;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function me(e, t) {
|
|
382
382
|
const r = [...e];
|
|
383
383
|
for (const n of t) {
|
|
384
384
|
const s = r.find(
|
|
@@ -393,7 +393,7 @@ function pe(e, t) {
|
|
|
393
393
|
}
|
|
394
394
|
function Y(e, t) {
|
|
395
395
|
return Object.keys(e).reduce(
|
|
396
|
-
(r, n) => (n === "variables" ? r.variables =
|
|
396
|
+
(r, n) => (n === "variables" ? r.variables = de(e.variables, t.variables) : n === "declarations" ? r.declarations = { ...e.declarations, ...t.declarations } : n === "themes" && $(r) && $(e) && $(t) ? r.themes = me(e.themes, t.themes) : Array.isArray(e[n]) && (r[n] = e[n].concat(
|
|
397
397
|
t[n]
|
|
398
398
|
)), r),
|
|
399
399
|
{
|
|
@@ -406,7 +406,7 @@ function U(e, t) {
|
|
|
406
406
|
for (const r of e)
|
|
407
407
|
"id" in r && typeof r.id == "string" && (t._registry.set(r.id, r), "children" in r && U(r.children, t));
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function pe(e) {
|
|
410
410
|
e._registry = /* @__PURE__ */ new Map(), e._registry.set(e.id, e), U(e.children, e);
|
|
411
411
|
for (const t of e.themes)
|
|
412
412
|
e._registry.set(t.id, t), U(t.children, e);
|
|
@@ -417,7 +417,7 @@ function Ke(e, ...t) {
|
|
|
417
417
|
...r,
|
|
418
418
|
root: Y(r.root, n.root)
|
|
419
419
|
};
|
|
420
|
-
return
|
|
420
|
+
return pe(s.root), (P(r) || P(n)) && ye(s), s;
|
|
421
421
|
}, e);
|
|
422
422
|
}
|
|
423
423
|
function I(e, t) {
|
|
@@ -433,8 +433,8 @@ function I(e, t) {
|
|
|
433
433
|
children: []
|
|
434
434
|
};
|
|
435
435
|
t._registry.set(i.id, i);
|
|
436
|
-
const f =
|
|
437
|
-
return typeof o == "function" ? i.declarations = o(f) ?? {} : L(o) ? (i.variables = o.variables, i.declarations = o.declarations, i.children = o.children) : o && (i.declarations = o),
|
|
436
|
+
const f = v(i, t);
|
|
437
|
+
return typeof o == "function" ? i.declarations = o(f) ?? {} : L(o) ? (i.variables = o.variables, i.declarations = o.declarations, i.children = o.children) : o && (i.declarations = o), E(
|
|
438
438
|
i.declarations,
|
|
439
439
|
f,
|
|
440
440
|
i,
|
|
@@ -466,8 +466,8 @@ function be(e, t) {
|
|
|
466
466
|
children: []
|
|
467
467
|
};
|
|
468
468
|
t._registry.set(o.id, o);
|
|
469
|
-
const i =
|
|
470
|
-
return typeof s == "function" ? o.declarations = s(i) ?? {} : L(s) ? (o.variables = s.variables, o.declarations = s.declarations, o.children = s.children) : o.declarations = s,
|
|
469
|
+
const i = v(o, t);
|
|
470
|
+
return typeof s == "function" ? o.declarations = s(i) ?? {} : L(s) ? (o.variables = s.variables, o.declarations = s.declarations, o.children = s.children) : o.declarations = s, E(
|
|
471
471
|
o.declarations,
|
|
472
472
|
i,
|
|
473
473
|
o,
|
|
@@ -496,7 +496,7 @@ function Ae(e, t) {
|
|
|
496
496
|
return e.variables.push(l), l;
|
|
497
497
|
};
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function v(e, t) {
|
|
500
500
|
const r = Ae(e, t), n = be(e, t), s = I(e, t), o = ge(t, t), i = he(e, t), f = q(t, t), c = fe(t, t);
|
|
501
501
|
return {
|
|
502
502
|
variable: r,
|
|
@@ -508,7 +508,7 @@ function w(e, t) {
|
|
|
508
508
|
css: c
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function E(e, t, r, n) {
|
|
512
512
|
for (const o in e)
|
|
513
513
|
if (o.startsWith("@")) {
|
|
514
514
|
const i = e[o];
|
|
@@ -516,7 +516,7 @@ function x(e, t, r, n) {
|
|
|
516
516
|
const f = o.replace(/^@(\w+).*/, "$1"), c = o.replace(`@${f}`, "").trim();
|
|
517
517
|
t.atRule(f, c, i), delete e[o];
|
|
518
518
|
}
|
|
519
|
-
} else if (/^[.&:]/.test(o) ||
|
|
519
|
+
} else if (/^[.&:]/.test(o) || /^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(o)) {
|
|
520
520
|
const i = e[o];
|
|
521
521
|
typeof i == "object" && (t.selector(o, i), delete e[o]);
|
|
522
522
|
}
|
|
@@ -530,7 +530,7 @@ function x(e, t, r, n) {
|
|
|
530
530
|
}
|
|
531
531
|
return e;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function ve(e, t, r) {
|
|
534
534
|
const n = {
|
|
535
535
|
...e,
|
|
536
536
|
id: b("ut-"),
|
|
@@ -542,20 +542,20 @@ function we(e, t, r) {
|
|
|
542
542
|
};
|
|
543
543
|
if (t._registry.set(n.id, n), r.size > 0) {
|
|
544
544
|
const s = [...r.values()];
|
|
545
|
-
let o =
|
|
545
|
+
let o = M(e.declarations);
|
|
546
546
|
n.declarations = {}, n.variables = [], n.children = [];
|
|
547
547
|
for (let f = s.length - 1; f >= 0; f--) {
|
|
548
|
-
const c =
|
|
548
|
+
const c = v(n, t), a = s[f]?.factory({
|
|
549
549
|
...c,
|
|
550
|
-
declarations:
|
|
551
|
-
variables:
|
|
552
|
-
children:
|
|
550
|
+
declarations: M(o),
|
|
551
|
+
variables: M(e.variables),
|
|
552
|
+
children: M(e.children)
|
|
553
553
|
});
|
|
554
554
|
a && (o = a);
|
|
555
555
|
}
|
|
556
556
|
n.declarations = o;
|
|
557
|
-
const i =
|
|
558
|
-
|
|
557
|
+
const i = v(n, t);
|
|
558
|
+
E(
|
|
559
559
|
n.declarations,
|
|
560
560
|
i,
|
|
561
561
|
n,
|
|
@@ -564,7 +564,7 @@ function we(e, t, r) {
|
|
|
564
564
|
}
|
|
565
565
|
return n;
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function we(e, t) {
|
|
568
568
|
return function(n, s) {
|
|
569
569
|
const o = {
|
|
570
570
|
type: "modifier",
|
|
@@ -605,7 +605,7 @@ function Ve(e, t) {
|
|
|
605
605
|
name: s
|
|
606
606
|
}
|
|
607
607
|
};
|
|
608
|
-
} else
|
|
608
|
+
} else {
|
|
609
609
|
for (const i of e) {
|
|
610
610
|
const f = `${i}.${s}`;
|
|
611
611
|
if (t.variables.some((c) => c.name === f))
|
|
@@ -616,6 +616,14 @@ function Ve(e, t) {
|
|
|
616
616
|
}
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
|
+
if (t.variables.some((i) => i.name === s))
|
|
620
|
+
return {
|
|
621
|
+
[s]: {
|
|
622
|
+
type: "reference",
|
|
623
|
+
name: s
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
619
627
|
return r(n);
|
|
620
628
|
}
|
|
621
629
|
return r(n);
|
|
@@ -654,39 +662,42 @@ function ke(e, t) {
|
|
|
654
662
|
if (Array.isArray(c)) {
|
|
655
663
|
l = {};
|
|
656
664
|
for (const u of c) {
|
|
657
|
-
const
|
|
665
|
+
const y = f.autogenerate(u);
|
|
658
666
|
l = {
|
|
659
667
|
...l,
|
|
660
|
-
...
|
|
668
|
+
...y
|
|
661
669
|
};
|
|
662
670
|
}
|
|
663
671
|
}
|
|
664
|
-
for (const [u,
|
|
665
|
-
let
|
|
666
|
-
if (typeof
|
|
667
|
-
const
|
|
668
|
-
!Array.isArray(l) &&
|
|
672
|
+
for (const [u, y] of Object.entries(l)) {
|
|
673
|
+
let d = y;
|
|
674
|
+
if (typeof y == "string" && y[0] === "@") {
|
|
675
|
+
const p = y.slice(1);
|
|
676
|
+
!Array.isArray(l) && p in l && (d = l[p]);
|
|
669
677
|
}
|
|
670
|
-
if (f.namespace && A(
|
|
671
|
-
if (t.variables.some((
|
|
672
|
-
|
|
678
|
+
if (f.namespace && A(y))
|
|
679
|
+
if (t.variables.some((p) => p.name === y.name))
|
|
680
|
+
d = y;
|
|
673
681
|
else {
|
|
674
|
-
const
|
|
675
|
-
let
|
|
676
|
-
for (const
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
679
|
-
|
|
682
|
+
const p = Array.isArray(f.namespace) ? f.namespace : [f.namespace];
|
|
683
|
+
let k = !1;
|
|
684
|
+
for (const V of p) {
|
|
685
|
+
const w = `${V}.${u}`;
|
|
686
|
+
if (w !== y.name && t.variables.some((R) => R.name === w)) {
|
|
687
|
+
d = {
|
|
680
688
|
type: "reference",
|
|
681
|
-
name:
|
|
682
|
-
},
|
|
689
|
+
name: w
|
|
690
|
+
}, k = !0;
|
|
683
691
|
break;
|
|
684
692
|
}
|
|
685
693
|
}
|
|
686
|
-
|
|
694
|
+
k || (t.variables.some((V) => V.name === u) ? d = {
|
|
695
|
+
type: "reference",
|
|
696
|
+
name: u
|
|
697
|
+
} : d = u);
|
|
687
698
|
}
|
|
688
|
-
const
|
|
689
|
-
(
|
|
699
|
+
const m = f.values.find(
|
|
700
|
+
(p) => p.key === u && p.modifiers.length === 0
|
|
690
701
|
), h = {
|
|
691
702
|
type: "utility",
|
|
692
703
|
id: b("ut-"),
|
|
@@ -699,37 +710,37 @@ function ke(e, t) {
|
|
|
699
710
|
modifiers: []
|
|
700
711
|
};
|
|
701
712
|
t._registry.set(h.id, h);
|
|
702
|
-
const K =
|
|
713
|
+
const K = v(
|
|
703
714
|
h,
|
|
704
715
|
t
|
|
705
716
|
);
|
|
706
717
|
if (h.declarations = s({
|
|
707
718
|
...K,
|
|
708
|
-
value:
|
|
709
|
-
}) ?? {},
|
|
719
|
+
value: d
|
|
720
|
+
}) ?? {}, E(
|
|
710
721
|
h.declarations,
|
|
711
722
|
K,
|
|
712
723
|
h,
|
|
713
724
|
t
|
|
714
|
-
),
|
|
725
|
+
), m || (f.values.push({
|
|
715
726
|
key: u,
|
|
716
|
-
value:
|
|
727
|
+
value: d,
|
|
717
728
|
modifiers: []
|
|
718
729
|
}), e.children.push(h)), a && a.length > 0)
|
|
719
|
-
for (const
|
|
720
|
-
const
|
|
721
|
-
for (const
|
|
722
|
-
const
|
|
730
|
+
for (const p of a) {
|
|
731
|
+
const k = Array.isArray(p) ? p : [p], V = Re(k);
|
|
732
|
+
for (const w of V) {
|
|
733
|
+
const R = [...w.keys()];
|
|
723
734
|
f.values.find(
|
|
724
|
-
(F) => F.key === u && F.modifiers.length ===
|
|
725
|
-
(Q, ee) => Q ===
|
|
735
|
+
(F) => F.key === u && F.modifiers.length === R.length && F.modifiers.every(
|
|
736
|
+
(Q, ee) => Q === R[ee]
|
|
726
737
|
)
|
|
727
738
|
) || (f.values.push({
|
|
728
739
|
key: u,
|
|
729
|
-
value:
|
|
730
|
-
modifiers:
|
|
740
|
+
value: d,
|
|
741
|
+
modifiers: R
|
|
731
742
|
}), e.children.push(
|
|
732
|
-
|
|
743
|
+
ve(h, t, w)
|
|
733
744
|
));
|
|
734
745
|
}
|
|
735
746
|
}
|
|
@@ -751,7 +762,7 @@ function Me(e, t) {
|
|
|
751
762
|
children: []
|
|
752
763
|
};
|
|
753
764
|
o || (t._registry.set(i.id, i), t.themes.push(i));
|
|
754
|
-
const f =
|
|
765
|
+
const f = v(i, t);
|
|
755
766
|
return s && s(f), i;
|
|
756
767
|
};
|
|
757
768
|
}
|
|
@@ -768,7 +779,7 @@ function W(e, t) {
|
|
|
768
779
|
const r = e.autogenerate(t);
|
|
769
780
|
return Object.keys(r)[0] ?? "default";
|
|
770
781
|
}
|
|
771
|
-
function
|
|
782
|
+
function O(e, t) {
|
|
772
783
|
const r = {};
|
|
773
784
|
for (const [n, s] of Object.entries(e))
|
|
774
785
|
if (Z(s)) {
|
|
@@ -799,14 +810,14 @@ function S(e, t) {
|
|
|
799
810
|
}
|
|
800
811
|
function xe(e, t) {
|
|
801
812
|
const r = {};
|
|
802
|
-
if (e.base && (r.base =
|
|
813
|
+
if (e.base && (r.base = O(e.base, t)), e.variants) {
|
|
803
814
|
const n = {};
|
|
804
815
|
for (const [s, o] of Object.entries(e.variants)) {
|
|
805
816
|
const i = {};
|
|
806
817
|
for (const [f, c] of Object.entries(
|
|
807
818
|
o
|
|
808
819
|
))
|
|
809
|
-
c == null ? i[f] = null : i[f] =
|
|
820
|
+
c == null ? i[f] = null : i[f] = O(
|
|
810
821
|
c,
|
|
811
822
|
t
|
|
812
823
|
);
|
|
@@ -816,7 +827,8 @@ function xe(e, t) {
|
|
|
816
827
|
}
|
|
817
828
|
return e.defaultVariants && (r.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (r.compoundVariants = e.compoundVariants.map((n) => ({
|
|
818
829
|
match: { ...n.match },
|
|
819
|
-
css:
|
|
830
|
+
...n.css ? { css: O(n.css, t) } : {},
|
|
831
|
+
...n.className ? { className: n.className } : {}
|
|
820
832
|
}))), r;
|
|
821
833
|
}
|
|
822
834
|
function Z(e) {
|
|
@@ -825,7 +837,7 @@ function Z(e) {
|
|
|
825
837
|
function J(e) {
|
|
826
838
|
return e.startsWith("&::") ? e.slice(3) : e.startsWith("&:") ? e.slice(2) : e;
|
|
827
839
|
}
|
|
828
|
-
function
|
|
840
|
+
function S(e, t) {
|
|
829
841
|
const r = (n, s, o) => {
|
|
830
842
|
let i = t.get(n);
|
|
831
843
|
i || (i = [], t.set(n, i)), i.push({ value: s, modifiers: o });
|
|
@@ -847,16 +859,16 @@ function D(e, t) {
|
|
|
847
859
|
}
|
|
848
860
|
function Ee(e, t) {
|
|
849
861
|
const r = /* @__PURE__ */ new Map();
|
|
850
|
-
if (e.base &&
|
|
862
|
+
if (e.base && S(e.base, r), e.variants)
|
|
851
863
|
for (const s of Object.values(e.variants))
|
|
852
864
|
for (const o of Object.values(s))
|
|
853
|
-
|
|
865
|
+
S(
|
|
854
866
|
o,
|
|
855
867
|
r
|
|
856
868
|
);
|
|
857
869
|
if (e.compoundVariants)
|
|
858
870
|
for (const s of e.compoundVariants)
|
|
859
|
-
s.css &&
|
|
871
|
+
s.css && S(s.css, r);
|
|
860
872
|
const n = /* @__PURE__ */ new Map();
|
|
861
873
|
for (const [s, o] of r) {
|
|
862
874
|
const i = D(t, s);
|
|
@@ -886,7 +898,7 @@ function Ee(e, t) {
|
|
|
886
898
|
}
|
|
887
899
|
}
|
|
888
900
|
function We(e) {
|
|
889
|
-
const t = b("sf-"), r = je(), n = { ...e }, s = ke(r, r), o =
|
|
901
|
+
const t = b("sf-"), r = je(), n = { ...e }, s = ke(r, r), o = we(r, r), i = $e(r, r), f = Me(r, r), { variable: c, selector: a, atRule: l, keyframes: u, media: y, ref: d, css: m } = v(r, r);
|
|
890
902
|
return {
|
|
891
903
|
id: t,
|
|
892
904
|
root: r,
|
|
@@ -898,22 +910,22 @@ function We(e) {
|
|
|
898
910
|
theme: f,
|
|
899
911
|
atRule: l,
|
|
900
912
|
keyframes: u,
|
|
901
|
-
media:
|
|
902
|
-
ref:
|
|
903
|
-
css:
|
|
913
|
+
media: y,
|
|
914
|
+
ref: d,
|
|
915
|
+
css: m,
|
|
904
916
|
options: n
|
|
905
917
|
};
|
|
906
918
|
}
|
|
907
919
|
export {
|
|
908
|
-
|
|
920
|
+
ve as applyModifiers,
|
|
909
921
|
Ue as capitalizeFirst,
|
|
910
922
|
De as classNameToCssSelector,
|
|
911
923
|
I as createAtRuleFunction,
|
|
912
924
|
fe as createCssFunction,
|
|
913
|
-
|
|
925
|
+
v as createDeclarationsCallbackContext,
|
|
914
926
|
ge as createKeyframesFunction,
|
|
915
927
|
he as createMediaFunction,
|
|
916
|
-
|
|
928
|
+
we as createModifierFunction,
|
|
917
929
|
C as createPropertyValueResolver,
|
|
918
930
|
$e as createRecipeFunction,
|
|
919
931
|
q as createRefFunction,
|
|
@@ -922,7 +934,7 @@ export {
|
|
|
922
934
|
Me as createThemeFunction,
|
|
923
935
|
ke as createUtilityFunction,
|
|
924
936
|
Ae as createVariableFunction,
|
|
925
|
-
|
|
937
|
+
M as deepClone,
|
|
926
938
|
Pe as defaultUtilitySelectorFn,
|
|
927
939
|
oe as findVariableInScope,
|
|
928
940
|
b as generateRandomId,
|
|
@@ -932,32 +944,32 @@ export {
|
|
|
932
944
|
Ce as getVariable,
|
|
933
945
|
se as hashValue,
|
|
934
946
|
te as isAtRule,
|
|
935
|
-
|
|
936
|
-
|
|
947
|
+
T as isCSS,
|
|
948
|
+
Te as isContainer,
|
|
937
949
|
L as isContainerInput,
|
|
938
950
|
ie as isKeyReferenceValue,
|
|
939
951
|
ne as isModifier,
|
|
940
|
-
|
|
952
|
+
x as isObject,
|
|
941
953
|
re as isPrimitiveTokenValue,
|
|
942
|
-
|
|
954
|
+
Se as isRecipe,
|
|
943
955
|
A as isRef,
|
|
944
|
-
|
|
956
|
+
$ as isRoot,
|
|
945
957
|
_e as isSelector,
|
|
946
958
|
Be as isStyleframe,
|
|
947
|
-
|
|
959
|
+
Oe as isTheme,
|
|
948
960
|
g as isToken,
|
|
949
|
-
|
|
961
|
+
N as isTokenEqual,
|
|
950
962
|
B as isTokenValue,
|
|
951
|
-
|
|
963
|
+
Ne as isUtility,
|
|
952
964
|
H as isVariable,
|
|
953
965
|
Ke as merge,
|
|
954
966
|
Y as mergeContainers,
|
|
955
|
-
|
|
956
|
-
|
|
967
|
+
me as mergeThemesArray,
|
|
968
|
+
de as mergeVariablesArray,
|
|
957
969
|
z as parseAtReferences,
|
|
958
|
-
|
|
970
|
+
E as parseDeclarationsBlock,
|
|
959
971
|
Ee as processRecipeUtilities,
|
|
960
|
-
|
|
972
|
+
pe as rebuildRegistry,
|
|
961
973
|
ae as rfdc,
|
|
962
974
|
We as styleframe,
|
|
963
975
|
G as transformUtilityKey,
|
package/dist/styleframe.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(u=typeof globalThis<"u"?globalThis:u||self,A(u.styleframe={}))})(this,(function(u){"use strict";function A(e){return typeof e=="object"&&e!==null}function g(e,t){return A(e)&&"type"in e&&e.type===t}function U(e){return g(e,"variable")}function w(e){return g(e,"reference")}function ke(e){return g(e,"selector")}function Y(e){return g(e,"at-rule")}function Me(e){return g(e,"utility")}function Z(e){return g(e,"modifier")}function T(e){return g(e,"css")}function Fe(e){return g(e,"theme")}function k(e){return g(e,"root")}function $e(e){return g(e,"recipe")}function J(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function S(e){return J(e)||w(e)||T(e)||Array.isArray(e)&&e.every(S)}function Te(e){return A(e)&&"id"in e&&"children"in e&&"declarations"in e&&"variables"in e}function N(e){return A(e)&&"children"in e&&"declarations"in e&&"variables"in e}function Q(e){return typeof e=="string"&&e.startsWith("@")}function Se(e){return A(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&k(e.root)}function x(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)&4294967295;return(t>>>0).toString(16).padStart(7,"0").slice(0,7)}function P(e){const t=typeof e=="function"?{replacer:e}:e??{},{replacer:r=c=>c,namespace:n}=t,s=Array.isArray(n)?n:n?[n]:[];return c=>{let i=c,a;if(typeof i=="string"&&i[0]==="@"){const o=i.slice(1),f=s.find(y=>o===y||o.startsWith(`${y}.`));let d,l;f?(d=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):s.length>0?(d=`${s[0]}.${o}`,l=o):(d=o,l=o),a=r(l),i={type:"reference",name:d}}else if(w(i)){let o=i.name;for(const f of s)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=r(o)}else{const o=String(c).trim();/\s/.test(o)?a=x(o):a=`[${o}]`}return{[a]:i}}}const Ee=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`,B=/@([\w.-]+)/g;function D(e){const t=[];let r=0,n;for(B.lastIndex=0;(n=B.exec(e))!==null;)t.push(e.slice(r,n.index)),t.push({type:"reference",name:n[1]}),r=B.lastIndex;return t.push(e.slice(r)),t}function ee(e,t,r){let n=t;for(;n;){if(n.variables.some(s=>s.name===e))return!0;if(n.parentId)n=r._registry.get(n.parentId);else break}return!1}function te(e,t,r){if(!ee(e,t,r))throw new Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function E(e,t){return function(n){if(typeof n!="string"||!n.includes("@"))return n;if(Q(n)&&/^@[\w.-]+$/.test(n)){const i=n.slice(1);return te(i,e,t),{type:"reference",name:i}}const s=D(n);return s.some(i=>w(i))?{type:"css",value:s}:n}}function I(e,t){return function(n,s){const c=E(e,t),i=s!=null?c(s):s;if(U(n))return{type:"reference",name:n.name,fallback:i};if(n==null)throw new Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return{type:"reference",name:n,fallback:i}}}function ne(e,t){const r=I(e,t);return function(s,...c){return{type:"css",value:s.reduce((a,o,f)=>{if(a.push(...D(o)),f<c.length){const d=c[f];U(d)?a.push(r(d)):Y(d)?a.push(d.rule):a.push(d)}return a},[])}}}function _e(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oe(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function R(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function re(e){if(e=e||{},e.circular)return Ce(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,a)=>new Map(n(Array.from(i),a))),t.set(Set,(i,a)=>new Set(n(Array.from(i),a))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let r;return e.proto?c:s;function n(i,a){const o=Object.keys(i),f=Array.from({length:o.length});for(let d=0;d<o.length;d++){const l=o[d],y=i[l];typeof y!="object"||y===null?f[l]=y:y.constructor!==Object&&(r=t.get(y.constructor))?f[l]=r(y,a):ArrayBuffer.isView(y)?f[l]=R(y):f[l]=a(y)}return f}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,s);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,s);const a={};for(const o in i){if(Object.hasOwnProperty.call(i,o)===!1)continue;const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,s):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=s(f)}return a}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,c);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,c);const a={};for(const o in i){const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,c):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=c(f)}return a}}function Ce(e){const t=[],r=[],n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,f)=>new Map(c(Array.from(o),f))),n.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)n.set(o[0],o[1]);let s;return e.proto?a:i;function c(o,f){const d=Object.keys(o),l=Array.from({length:d.length});for(let y=0;y<d.length;y++){const m=d[y],h=o[m];if(typeof h!="object"||h===null)l[m]=h;else if(h.constructor!==Object&&(s=n.get(h.constructor)))l[m]=s(h,f);else if(ArrayBuffer.isView(h))l[m]=R(h);else{const b=t.indexOf(h);b!==-1?l[m]=r[b]:l[m]=f(h)}}return l}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,i);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,i);const f={};t.push(o),r.push(f);for(const d in o){if(Object.hasOwnProperty.call(o,d)===!1)continue;const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,i);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=i(l)}}return t.pop(),r.pop(),f}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,a);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,a);const f={};t.push(o),r.push(f);for(const d in o){const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,a);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=a(l)}}return t.pop(),r.pop(),f}}const M=re();function v(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let s=0;s<t;s++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}function Ue(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function Ne(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function ie(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}function _(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>_(r,t[n]));if("type"in e&&"type"in t){if(e.type!==t.type)return!1;if(w(e)&&w(t))return e.name===t.name&&_(e.fallback,t.fallback);if(T(e)&&T(t))return _(e.value,t.value)}return!1}const se="__licenseRequired";function Pe(e){K(e)||Object.defineProperty(e,se,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function K(e){return Object.prototype.hasOwnProperty.call(e,se)}function ce(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?s.value=n.value:r.push(n)}return r}function oe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?Object.assign(s,W(s,n)):r.push(n)}return r}function W(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=ce(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&k(r)&&k(e)&&k(t)?r.themes=oe(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function H(e,t){for(const r of e)"id"in r&&typeof r.id=="string"&&(t._registry.set(r.id,r),"children"in r&&H(r.children,t))}function ae(e){e._registry=new Map,e._registry.set(e.id,e),H(e.children,e);for(const t of e.themes)e._registry.set(t.id,t),H(t.children,e)}function Be(e,...t){return t.reduce((r,n)=>{const s={...r,root:W(r.root,n.root)};return ae(s.root),(K(r)||K(n))&&Pe(s),s},e)}function O(e,t){return function(n,s,c){const i={type:"at-rule",id:v("ar-"),parentId:e.id,identifier:n,rule:s,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);const a=V(i,t);return typeof c=="function"?i.declarations=c(a)??{}:N(c)?(i.variables=c.variables,i.declarations=c.declarations,i.children=c.children):c&&(i.declarations=c),F(i.declarations,a,i,t),e.children.push(i),i}}function fe(e,t){const r=O(e,t);return function(s,c){return r("media",s,c)}}function ue(e,t){const r=O(e,t);return function(s,c){return r("keyframes",s,c)}}function le(e,t){return function(n,s){const c={type:"selector",id:v("sel-"),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(c.id,c);const i=V(c,t);return typeof s=="function"?c.declarations=s(i)??{}:N(s)?(c.variables=s.variables,c.declarations=s.declarations,c.children=s.children):c.declarations=s,F(c.declarations,i,c,t),e.children.push(c),c}}function de(e,t){return function(n,s,c={default:!1}){const i=typeof n=="string"?n:n.name,o=E(e,t)(s),f=e.variables.find(l=>l.name===i);if(c.default&&f)return f;if(f)return f.value=o,f;const d={type:"variable",id:v("var-"),parentId:e.id,name:i,value:o};return e.variables.push(d),d}}function V(e,t){const r=de(e,t),n=le(e,t),s=O(e,t),c=ue(t,t),i=fe(e,t),a=I(t,t),o=ne(t,t);return{variable:r,selector:n,keyframes:c,atRule:s,media:i,ref:a,css:o}}function F(e,t,r,n){for(const c in e)if(c.startsWith("@")){const i=e[c];if(typeof i=="object"&&i!==null&&!S(i)){const a=c.replace(/^@(\w+).*/,"$1"),o=c.replace(`@${a}`,"").trim();t.atRule(a,o,i),delete e[c]}}else if(/^[.&:]/.test(c)||/^\d+%$/.test(c)||c==="from"||c==="to"){const i=e[c];typeof i=="object"&&(t.selector(c,i),delete e[c])}const s=E(r,n);for(const c in e){const i=e[c];if(S(i)){const a=s(i);a!==i&&(e[c]=a)}}return e}function ye(e,t,r){const n={...e,id:v("ut-"),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...r.keys()]};if(t._registry.set(n.id,n),r.size>0){const s=[...r.values()];let c=M(e.declarations);n.declarations={},n.variables=[],n.children=[];for(let a=s.length-1;a>=0;a--){const o=V(n,t),f=s[a]?.factory({...o,declarations:M(c),variables:M(e.variables),children:M(e.children)});f&&(c=f)}n.declarations=c;const i=V(n,t);F(n.declarations,i,n,t)}return n}function me(e,t){return function(n,s){const c={type:"modifier",key:Array.isArray(n)?n:[n],factory:s};return t.modifiers.push(c),c}}function he(){const e={type:"root",id:v("rt-"),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map};return e._registry.set(e.id,e),e}function De(e,t){const r=P({namespace:e});return n=>{if(typeof n=="string"&&n[0]==="@"){const s=n.slice(1),c=e.find(i=>s===i||s.startsWith(`${i}.`));if(c){const i=s.slice(c.length+1)||s;if(t.variables.some(a=>a.name===s))return{[i]:{type:"reference",name:s}}}else for(const i of e){const a=`${i}.${s}`;if(t.variables.some(o=>o.name===a))return{[s]:{type:"reference",name:a}}}return r(n)}return r(n)}}function Ie(e){let t=[new Map];for(const r of e){if(!Z(r))continue;const n=[];for(const s of r.key)for(const c of t){const i=new Map(c);i.set(s,r),n.push(i)}t=n}return t.filter(r=>r.size>0)}function pe(e,t){return function(n,s,c={}){const i=t.utilities.find(o=>o.name===n);if(i)return i.create;const a={type:"utility",name:n,factory:s,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?De(c.namespace,t):P(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(o,f=[])=>{let d=o;if(Array.isArray(o)){d={};for(const l of o){const y=a.autogenerate(l);d={...d,...y}}}for(const[l,y]of Object.entries(d)){let m=y;if(typeof y=="string"&&y[0]==="@"){const p=y.slice(1);!Array.isArray(d)&&p in d&&(m=d[p])}if(a.namespace&&w(y))if(t.variables.some(p=>p.name===y.name))m=y;else{const p=Array.isArray(a.namespace)?a.namespace:[a.namespace];let C=!1;for(const q of p){const j=`${q}.${l}`;if(j!==y.name&&t.variables.some($=>$.name===j)){m={type:"reference",name:j},C=!0;break}}C||(m=l)}const h=a.values.find(p=>p.key===l&&p.modifiers.length===0),b={type:"utility",id:v("ut-"),parentId:e.id,name:n,value:l,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(b.id,b);const je=V(b,t);if(b.declarations=s({...je,value:m})??{},F(b.declarations,je,b,t),h||(a.values.push({key:l,value:m,modifiers:[]}),e.children.push(b)),f&&f.length>0)for(const p of f){const C=Array.isArray(p)?p:[p],q=Ie(C);for(const j of q){const $=[...j.keys()];a.values.find(X=>X.key===l&&X.modifiers.length===$.length&&X.modifiers.every((We,He)=>We===$[He]))||(a.values.push({key:l,value:m,modifiers:$}),e.children.push(ye(b,t,j)))}}}}};return t.utilities.push(a),a.create}}function ge(e,t){return function(n,s){const c=t.themes.find(o=>o.name===n),i=c??{type:"theme",id:v("th-"),parentId:t.id,name:n,declarations:{},variables:[],children:[]};c||(t._registry.set(i.id,i),t.themes.push(i));const a=V(i,t);return s&&s(a),i}}function be(e,t){return function(n){const s={type:"recipe",...n};return s._runtime=ve(s,t),Re(s,t),t.recipes.push(s),s}}function Ae(e,t){const r=e.autogenerate(t);return Object.keys(r)[0]??"default"}function L(e,t){const r={};for(const[n,s]of Object.entries(e))if(we(s)){const c={};for(const[i,a]of Object.entries(s)){const o=G(t,i);if(!o)throw new Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);c[i]=Ae(o,a)}r[Ve(n)]=c}else if(typeof s=="boolean")r[n]=s;else{const c=G(t,n);if(!c)throw new Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);r[n]=Ae(c,s)}return r}function ve(e,t){const r={};if(e.base&&(r.base=L(e.base,t)),e.variants){const n={};for(const[s,c]of Object.entries(e.variants)){const i={};for(const[a,o]of Object.entries(c))o==null?i[a]=null:i[a]=L(o,t);n[s]=i}r.variants=n}return e.defaultVariants&&(r.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(r.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},css:L(n.css,t)}))),r}function we(e){return!w(e)&&typeof e=="object"&&e!==null}function Ve(e){return e.startsWith("&::")?e.slice(3):e.startsWith("&:")?e.slice(2):e}function z(e,t){const r=(n,s,c)=>{let i=t.get(n);i||(i=[],t.set(n,i)),i.push({value:s,modifiers:c})};for(const[n,s]of Object.entries(e))if(we(s)){const c=Ve(n).split(":");for(const[i,a]of Object.entries(s))r(i,a,c)}else r(n,s,[])}function G(e,t){const r=e.utilities.find(s=>s.name===t);if(r)return r;const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return e.utilities.find(s=>s.name===n)}function Re(e,t){const r=new Map;if(e.base&&z(e.base,r),e.variants)for(const s of Object.values(e.variants))for(const c of Object.values(s))z(c,r);if(e.compoundVariants)for(const s of e.compoundVariants)s.css&&z(s.css,r);const n=new Map;for(const[s,c]of r){const i=G(t,s);if(!i)throw new Error(`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(const a of c){const o=[];for(const f of a.modifiers){if(!n.has(f))try{n.set(f,ie(t,f))}catch{throw new Error(`[styleframe] Modifier "${f}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}const d=n.get(f);d&&o.push(d)}i.create([a.value],o.length>0?o.length>1?[o]:o:void 0)}}}function Ke(e){const t=v("sf-"),r=he(),n={...e},s=pe(r,r),c=me(r,r),i=be(r,r),a=ge(r,r),{variable:o,selector:f,atRule:d,keyframes:l,media:y,ref:m,css:h}=V(r,r);return{id:t,root:r,variable:o,selector:f,utility:s,modifier:c,recipe:i,theme:a,atRule:d,keyframes:l,media:y,ref:m,css:h,options:n}}u.applyModifiers=ye,u.capitalizeFirst=_e,u.classNameToCssSelector=Oe,u.createAtRuleFunction=O,u.createCssFunction=ne,u.createDeclarationsCallbackContext=V,u.createKeyframesFunction=ue,u.createMediaFunction=fe,u.createModifierFunction=me,u.createPropertyValueResolver=E,u.createRecipeFunction=be,u.createRefFunction=I,u.createRoot=he,u.createSelectorFunction=le,u.createThemeFunction=ge,u.createUtilityFunction=pe,u.createVariableFunction=de,u.deepClone=M,u.defaultUtilitySelectorFn=Ee,u.findVariableInScope=ee,u.generateRandomId=v,u.generateRecipeRuntime=ve,u.getModifier=ie,u.getUtility=Ne,u.getVariable=Ue,u.hashValue=x,u.isAtRule=Y,u.isCSS=T,u.isContainer=Te,u.isContainerInput=N,u.isKeyReferenceValue=Q,u.isModifier=Z,u.isObject=A,u.isPrimitiveTokenValue=J,u.isRecipe=$e,u.isRef=w,u.isRoot=k,u.isSelector=ke,u.isStyleframe=Se,u.isTheme=Fe,u.isToken=g,u.isTokenEqual=_,u.isTokenValue=S,u.isUtility=Me,u.isVariable=U,u.merge=Be,u.mergeContainers=W,u.mergeThemesArray=oe,u.mergeVariablesArray=ce,u.parseAtReferences=D,u.parseDeclarationsBlock=F,u.processRecipeUtilities=Re,u.rebuildRegistry=ae,u.rfdc=re,u.styleframe=Ke,u.transformUtilityKey=P,u.validateReference=te,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(u,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(u=typeof globalThis<"u"?globalThis:u||self,A(u.styleframe={}))})(this,(function(u){"use strict";function A(e){return typeof e=="object"&&e!==null}function g(e,t){return A(e)&&"type"in e&&e.type===t}function U(e){return g(e,"variable")}function w(e){return g(e,"reference")}function ke(e){return g(e,"selector")}function Y(e){return g(e,"at-rule")}function Me(e){return g(e,"utility")}function Z(e){return g(e,"modifier")}function S(e){return g(e,"css")}function Fe(e){return g(e,"theme")}function k(e){return g(e,"root")}function $e(e){return g(e,"recipe")}function J(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function E(e){return J(e)||w(e)||S(e)||Array.isArray(e)&&e.every(E)}function Te(e){return A(e)&&"id"in e&&"children"in e&&"declarations"in e&&"variables"in e}function P(e){return A(e)&&"children"in e&&"declarations"in e&&"variables"in e}function Q(e){return typeof e=="string"&&e.startsWith("@")}function Se(e){return A(e)&&"id"in e&&"root"in e&&"variable"in e&&"selector"in e&&"recipe"in e&&typeof e.id=="string"&&k(e.root)}function x(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)&4294967295;return(t>>>0).toString(16).padStart(7,"0").slice(0,7)}function B(e){const t=typeof e=="function"?{replacer:e}:e??{},{replacer:r=c=>c,namespace:n}=t,s=Array.isArray(n)?n:n?[n]:[];return c=>{let i=c,a;if(typeof i=="string"&&i[0]==="@"){const o=i.slice(1),f=s.find(y=>o===y||o.startsWith(`${y}.`));let d,l;f?(d=o,l=o.startsWith(`${f}.`)?o.slice(f.length+1):o):s.length>0?(d=`${s[0]}.${o}`,l=o):(d=o,l=o),a=r(l),i={type:"reference",name:d}}else if(w(i)){let o=i.name;for(const f of s)if(o.startsWith(`${f}.`)){o=o.slice(f.length+1);break}a=r(o)}else{const o=String(c).trim();/\s/.test(o)?a=x(o):a=`[${o}]`}return{[a]:i}}}const Ee=({name:e,value:t,modifiers:r})=>`_${[...r,e,...t==="default"?[]:[t]].filter(Boolean).join(":")}`,D=/@([\w.-]+)/g;function I(e){const t=[];let r=0,n;for(D.lastIndex=0;(n=D.exec(e))!==null;)t.push(e.slice(r,n.index)),t.push({type:"reference",name:n[1]}),r=D.lastIndex;return t.push(e.slice(r)),t}function ee(e,t,r){let n=t;for(;n;){if(n.variables.some(s=>s.name===e))return!0;if(n.parentId)n=r._registry.get(n.parentId);else break}return!1}function te(e,t,r){if(!ee(e,t,r))throw new Error(`[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`)}function N(e,t){return function(n){if(typeof n!="string"||!n.includes("@"))return n;if(Q(n)&&/^@[\w.-]+$/.test(n)){const i=n.slice(1);return te(i,e,t),{type:"reference",name:i}}const s=I(n);return s.some(i=>w(i))?{type:"css",value:s}:n}}function K(e,t){return function(n,s){const c=N(e,t),i=s!=null?c(s):s;if(U(n))return{type:"reference",name:n.name,fallback:i};if(n==null)throw new Error(`[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`);return{type:"reference",name:n,fallback:i}}}function ne(e,t){const r=K(e,t);return function(s,...c){return{type:"css",value:s.reduce((a,o,f)=>{if(a.push(...I(o)),f<c.length){const d=c[f];U(d)?a.push(r(d)):Y(d)?a.push(d.rule):a.push(d)}return a},[])}}}function Ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function _e(e){return`.${e.replace(/[[\].#()%,:/]/g,"\\$&")}`}function R(e){if(e instanceof Buffer)return Buffer.from(e);const t=e.constructor;return new t(e.buffer.slice(0),e.byteOffset,e.byteLength/e.BYTES_PER_ELEMENT||1)}function re(e){if(e=e||{},e.circular)return Oe(e);const t=new Map;if(t.set(Date,i=>new Date(i)),t.set(Map,(i,a)=>new Map(n(Array.from(i),a))),t.set(Set,(i,a)=>new Set(n(Array.from(i),a))),e.constructorHandlers)for(const i of e.constructorHandlers)t.set(i[0],i[1]);let r;return e.proto?c:s;function n(i,a){const o=Object.keys(i),f=Array.from({length:o.length});for(let d=0;d<o.length;d++){const l=o[d],y=i[l];typeof y!="object"||y===null?f[l]=y:y.constructor!==Object&&(r=t.get(y.constructor))?f[l]=r(y,a):ArrayBuffer.isView(y)?f[l]=R(y):f[l]=a(y)}return f}function s(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,s);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,s);const a={};for(const o in i){if(Object.hasOwnProperty.call(i,o)===!1)continue;const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,s):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=s(f)}return a}function c(i){if(typeof i!="object"||i===null)return i;if(Array.isArray(i))return n(i,c);if(i.constructor!==Object&&(r=t.get(i.constructor)))return r(i,c);const a={};for(const o in i){const f=i[o];typeof f!="object"||f===null?a[o]=f:f.constructor!==Object&&(r=t.get(f.constructor))?a[o]=r(f,c):ArrayBuffer.isView(f)?a[o]=R(f):a[o]=c(f)}return a}}function Oe(e){const t=[],r=[],n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,f)=>new Map(c(Array.from(o),f))),n.set(Set,(o,f)=>new Set(c(Array.from(o),f))),e.constructorHandlers)for(const o of e.constructorHandlers)n.set(o[0],o[1]);let s;return e.proto?a:i;function c(o,f){const d=Object.keys(o),l=Array.from({length:d.length});for(let y=0;y<d.length;y++){const m=d[y],h=o[m];if(typeof h!="object"||h===null)l[m]=h;else if(h.constructor!==Object&&(s=n.get(h.constructor)))l[m]=s(h,f);else if(ArrayBuffer.isView(h))l[m]=R(h);else{const b=t.indexOf(h);b!==-1?l[m]=r[b]:l[m]=f(h)}}return l}function i(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,i);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,i);const f={};t.push(o),r.push(f);for(const d in o){if(Object.hasOwnProperty.call(o,d)===!1)continue;const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,i);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=i(l)}}return t.pop(),r.pop(),f}function a(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,a);if(o.constructor!==Object&&(s=n.get(o.constructor)))return s(o,a);const f={};t.push(o),r.push(f);for(const d in o){const l=o[d];if(typeof l!="object"||l===null)f[d]=l;else if(l.constructor!==Object&&(s=n.get(l.constructor)))f[d]=s(l,a);else if(ArrayBuffer.isView(l))f[d]=R(l);else{const y=t.indexOf(l);y!==-1?f[d]=r[y]:f[d]=a(l)}}return t.pop(),r.pop(),f}}const M=re();function v(e,t=8){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let s=0;s<t;s++){const c=Math.floor(Math.random()*r.length);n+=r[c]}return e?`${e}${n}`:n}function Ce(e,t){const r=e.variables.find(n=>n.name===t);if(!r)throw new Error(`Variable "${t}" not found`);return r}function Ue(e,t){const r=e.utilities.find(n=>n.name===t);if(!r)throw new Error(`Utility "${t}" not found`);return r}function ie(e,t){const r=e.modifiers.find(n=>n.key.includes(t));if(!r)throw new Error(`Modifier "${t}" not found`);return r}function _(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>_(r,t[n]));if("type"in e&&"type"in t){if(e.type!==t.type)return!1;if(w(e)&&w(t))return e.name===t.name&&_(e.fallback,t.fallback);if(S(e)&&S(t))return _(e.value,t.value)}return!1}const se="__licenseRequired";function Pe(e){W(e)||Object.defineProperty(e,se,{value:!0,writable:!1,configurable:!1,enumerable:!0})}function W(e){return Object.prototype.hasOwnProperty.call(e,se)}function ce(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?s.value=n.value:r.push(n)}return r}function oe(e,t){const r=[...e];for(const n of t){const s=r.find(c=>c.name===n.name);s?Object.assign(s,H(s,n)):r.push(n)}return r}function H(e,t){return Object.keys(e).reduce((r,n)=>(n==="variables"?r.variables=ce(e.variables,t.variables):n==="declarations"?r.declarations={...e.declarations,...t.declarations}:n==="themes"&&k(r)&&k(e)&&k(t)?r.themes=oe(e.themes,t.themes):Array.isArray(e[n])&&(r[n]=e[n].concat(t[n])),r),{...e,...t})}function L(e,t){for(const r of e)"id"in r&&typeof r.id=="string"&&(t._registry.set(r.id,r),"children"in r&&L(r.children,t))}function ae(e){e._registry=new Map,e._registry.set(e.id,e),L(e.children,e);for(const t of e.themes)e._registry.set(t.id,t),L(t.children,e)}function Be(e,...t){return t.reduce((r,n)=>{const s={...r,root:H(r.root,n.root)};return ae(s.root),(W(r)||W(n))&&Pe(s),s},e)}function O(e,t){return function(n,s,c){const i={type:"at-rule",id:v("ar-"),parentId:e.id,identifier:n,rule:s,declarations:{},variables:[],children:[]};t._registry.set(i.id,i);const a=V(i,t);return typeof c=="function"?i.declarations=c(a)??{}:P(c)?(i.variables=c.variables,i.declarations=c.declarations,i.children=c.children):c&&(i.declarations=c),F(i.declarations,a,i,t),e.children.push(i),i}}function fe(e,t){const r=O(e,t);return function(s,c){return r("media",s,c)}}function ue(e,t){const r=O(e,t);return function(s,c){return r("keyframes",s,c)}}function le(e,t){return function(n,s){const c={type:"selector",id:v("sel-"),parentId:e.id,query:n,declarations:{},variables:[],children:[]};t._registry.set(c.id,c);const i=V(c,t);return typeof s=="function"?c.declarations=s(i)??{}:P(s)?(c.variables=s.variables,c.declarations=s.declarations,c.children=s.children):c.declarations=s,F(c.declarations,i,c,t),e.children.push(c),c}}function de(e,t){return function(n,s,c={default:!1}){const i=typeof n=="string"?n:n.name,o=N(e,t)(s),f=e.variables.find(l=>l.name===i);if(c.default&&f)return f;if(f)return f.value=o,f;const d={type:"variable",id:v("var-"),parentId:e.id,name:i,value:o};return e.variables.push(d),d}}function V(e,t){const r=de(e,t),n=le(e,t),s=O(e,t),c=ue(t,t),i=fe(e,t),a=K(t,t),o=ne(t,t);return{variable:r,selector:n,keyframes:c,atRule:s,media:i,ref:a,css:o}}function F(e,t,r,n){for(const c in e)if(c.startsWith("@")){const i=e[c];if(typeof i=="object"&&i!==null&&!E(i)){const a=c.replace(/^@(\w+).*/,"$1"),o=c.replace(`@${a}`,"").trim();t.atRule(a,o,i),delete e[c]}}else if(/^[.&:]/.test(c)||/^(\d+%|from|to)(\s*,\s*(\d+%|from|to))*$/.test(c)){const i=e[c];typeof i=="object"&&(t.selector(c,i),delete e[c])}const s=N(r,n);for(const c in e){const i=e[c];if(E(i)){const a=s(i);a!==i&&(e[c]=a)}}return e}function ye(e,t,r){const n={...e,id:v("ut-"),parentId:e.parentId,declarations:{...e.declarations},variables:[...e.variables],children:[...e.children],modifiers:[...r.keys()]};if(t._registry.set(n.id,n),r.size>0){const s=[...r.values()];let c=M(e.declarations);n.declarations={},n.variables=[],n.children=[];for(let a=s.length-1;a>=0;a--){const o=V(n,t),f=s[a]?.factory({...o,declarations:M(c),variables:M(e.variables),children:M(e.children)});f&&(c=f)}n.declarations=c;const i=V(n,t);F(n.declarations,i,n,t)}return n}function me(e,t){return function(n,s){const c={type:"modifier",key:Array.isArray(n)?n:[n],factory:s};return t.modifiers.push(c),c}}function he(){const e={type:"root",id:v("rt-"),declarations:{},utilities:[],modifiers:[],recipes:[],variables:[],children:[],themes:[],_registry:new Map};return e._registry.set(e.id,e),e}function De(e,t){const r=B({namespace:e});return n=>{if(typeof n=="string"&&n[0]==="@"){const s=n.slice(1),c=e.find(i=>s===i||s.startsWith(`${i}.`));if(c){const i=s.slice(c.length+1)||s;if(t.variables.some(a=>a.name===s))return{[i]:{type:"reference",name:s}}}else{for(const i of e){const a=`${i}.${s}`;if(t.variables.some(o=>o.name===a))return{[s]:{type:"reference",name:a}}}if(t.variables.some(i=>i.name===s))return{[s]:{type:"reference",name:s}}}return r(n)}return r(n)}}function Ie(e){let t=[new Map];for(const r of e){if(!Z(r))continue;const n=[];for(const s of r.key)for(const c of t){const i=new Map(c);i.set(s,r),n.push(i)}t=n}return t.filter(r=>r.size>0)}function pe(e,t){return function(n,s,c={}){const i=t.utilities.find(o=>o.name===n);if(i)return i.create;const a={type:"utility",name:n,factory:s,values:[],autogenerate:c.autogenerate??(Array.isArray(c.namespace)?De(c.namespace,t):B(c.namespace?{namespace:c.namespace}:void 0)),namespace:c.namespace,create:(o,f=[])=>{let d=o;if(Array.isArray(o)){d={};for(const l of o){const y=a.autogenerate(l);d={...d,...y}}}for(const[l,y]of Object.entries(d)){let m=y;if(typeof y=="string"&&y[0]==="@"){const p=y.slice(1);!Array.isArray(d)&&p in d&&(m=d[p])}if(a.namespace&&w(y))if(t.variables.some(p=>p.name===y.name))m=y;else{const p=Array.isArray(a.namespace)?a.namespace:[a.namespace];let C=!1;for(const $ of p){const j=`${$}.${l}`;if(j!==y.name&&t.variables.some(T=>T.name===j)){m={type:"reference",name:j},C=!0;break}}C||(t.variables.some($=>$.name===l)?m={type:"reference",name:l}:m=l)}const h=a.values.find(p=>p.key===l&&p.modifiers.length===0),b={type:"utility",id:v("ut-"),parentId:e.id,name:n,value:l,declarations:{},variables:[],children:[],modifiers:[]};t._registry.set(b.id,b);const je=V(b,t);if(b.declarations=s({...je,value:m})??{},F(b.declarations,je,b,t),h||(a.values.push({key:l,value:m,modifiers:[]}),e.children.push(b)),f&&f.length>0)for(const p of f){const C=Array.isArray(p)?p:[p],$=Ie(C);for(const j of $){const T=[...j.keys()];a.values.find(X=>X.key===l&&X.modifiers.length===T.length&&X.modifiers.every((We,He)=>We===T[He]))||(a.values.push({key:l,value:m,modifiers:T}),e.children.push(ye(b,t,j)))}}}}};return t.utilities.push(a),a.create}}function ge(e,t){return function(n,s){const c=t.themes.find(o=>o.name===n),i=c??{type:"theme",id:v("th-"),parentId:t.id,name:n,declarations:{},variables:[],children:[]};c||(t._registry.set(i.id,i),t.themes.push(i));const a=V(i,t);return s&&s(a),i}}function be(e,t){return function(n){const s={type:"recipe",...n};return s._runtime=ve(s,t),Re(s,t),t.recipes.push(s),s}}function Ae(e,t){const r=e.autogenerate(t);return Object.keys(r)[0]??"default"}function z(e,t){const r={};for(const[n,s]of Object.entries(e))if(we(s)){const c={};for(const[i,a]of Object.entries(s)){const o=q(t,i);if(!o)throw new Error(`[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`);c[i]=Ae(o,a)}r[Ve(n)]=c}else if(typeof s=="boolean")r[n]=s;else{const c=q(t,n);if(!c)throw new Error(`[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`);r[n]=Ae(c,s)}return r}function ve(e,t){const r={};if(e.base&&(r.base=z(e.base,t)),e.variants){const n={};for(const[s,c]of Object.entries(e.variants)){const i={};for(const[a,o]of Object.entries(c))o==null?i[a]=null:i[a]=z(o,t);n[s]=i}r.variants=n}return e.defaultVariants&&(r.defaultVariants={...e.defaultVariants}),e.compoundVariants&&(r.compoundVariants=e.compoundVariants.map(n=>({match:{...n.match},...n.css?{css:z(n.css,t)}:{},...n.className?{className:n.className}:{}}))),r}function we(e){return!w(e)&&typeof e=="object"&&e!==null}function Ve(e){return e.startsWith("&::")?e.slice(3):e.startsWith("&:")?e.slice(2):e}function G(e,t){const r=(n,s,c)=>{let i=t.get(n);i||(i=[],t.set(n,i)),i.push({value:s,modifiers:c})};for(const[n,s]of Object.entries(e))if(we(s)){const c=Ve(n).split(":");for(const[i,a]of Object.entries(s))r(i,a,c)}else r(n,s,[])}function q(e,t){const r=e.utilities.find(s=>s.name===t);if(r)return r;const n=t.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return e.utilities.find(s=>s.name===n)}function Re(e,t){const r=new Map;if(e.base&&G(e.base,r),e.variants)for(const s of Object.values(e.variants))for(const c of Object.values(s))G(c,r);if(e.compoundVariants)for(const s of e.compoundVariants)s.css&&G(s.css,r);const n=new Map;for(const[s,c]of r){const i=q(t,s);if(!i)throw new Error(`[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`);for(const a of c){const o=[];for(const f of a.modifiers){if(!n.has(f))try{n.set(f,ie(t,f))}catch{throw new Error(`[styleframe] Modifier "${f}" not found in registry. Make sure the modifier is registered before using it in a recipe.`)}const d=n.get(f);d&&o.push(d)}i.create([a.value],o.length>0?o.length>1?[o]:o:void 0)}}}function Ke(e){const t=v("sf-"),r=he(),n={...e},s=pe(r,r),c=me(r,r),i=be(r,r),a=ge(r,r),{variable:o,selector:f,atRule:d,keyframes:l,media:y,ref:m,css:h}=V(r,r);return{id:t,root:r,variable:o,selector:f,utility:s,modifier:c,recipe:i,theme:a,atRule:d,keyframes:l,media:y,ref:m,css:h,options:n}}u.applyModifiers=ye,u.capitalizeFirst=Ne,u.classNameToCssSelector=_e,u.createAtRuleFunction=O,u.createCssFunction=ne,u.createDeclarationsCallbackContext=V,u.createKeyframesFunction=ue,u.createMediaFunction=fe,u.createModifierFunction=me,u.createPropertyValueResolver=N,u.createRecipeFunction=be,u.createRefFunction=K,u.createRoot=he,u.createSelectorFunction=le,u.createThemeFunction=ge,u.createUtilityFunction=pe,u.createVariableFunction=de,u.deepClone=M,u.defaultUtilitySelectorFn=Ee,u.findVariableInScope=ee,u.generateRandomId=v,u.generateRecipeRuntime=ve,u.getModifier=ie,u.getUtility=Ue,u.getVariable=Ce,u.hashValue=x,u.isAtRule=Y,u.isCSS=S,u.isContainer=Te,u.isContainerInput=P,u.isKeyReferenceValue=Q,u.isModifier=Z,u.isObject=A,u.isPrimitiveTokenValue=J,u.isRecipe=$e,u.isRef=w,u.isRoot=k,u.isSelector=ke,u.isStyleframe=Se,u.isTheme=Fe,u.isToken=g,u.isTokenEqual=_,u.isTokenValue=E,u.isUtility=Me,u.isVariable=U,u.merge=Be,u.mergeContainers=H,u.mergeThemesArray=oe,u.mergeVariablesArray=ce,u.parseAtReferences=I,u.parseDeclarationsBlock=F,u.processRecipeUtilities=Re,u.rebuildRegistry=ae,u.rfdc=re,u.styleframe=Ke,u.transformUtilityKey=B,u.validateReference=te,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|