@animus-ui/system 0.1.0-next.10 → 0.1.0-next.16
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/dist/Animus.d.ts +37 -27
- package/dist/Animus.d.ts.map +1 -1
- package/dist/AnimusExtended.d.ts +33 -24
- package/dist/AnimusExtended.d.ts.map +1 -1
- package/dist/SystemBuilder.d.ts +1 -2
- package/dist/SystemBuilder.d.ts.map +1 -1
- package/dist/groups/index.d.ts +50 -26
- package/dist/groups/index.d.ts.map +1 -1
- package/dist/groups/index.js +50 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +351 -26
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/theme/createTheme.d.ts +5 -2
- package/dist/theme/createTheme.d.ts.map +1 -1
- package/dist/transforms/createTransform.d.ts +3 -1
- package/dist/transforms/createTransform.d.ts.map +1 -1
- package/dist/types/component.d.ts +13 -14
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/config.d.ts +6 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/theme.d.ts +17 -0
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -118,6 +118,17 @@ function createComponent(element, className, config, systemPropMap, dynamicPropC
|
|
|
118
118
|
const value = props[prop] ?? vc.default;
|
|
119
119
|
if (value != null) classes.push(`${className}--${prop}-${value}`);
|
|
120
120
|
}
|
|
121
|
+
if (config.compounds) for (const compound of config.compounds) {
|
|
122
|
+
let match = true;
|
|
123
|
+
for (const [prop, expected] of Object.entries(compound.conditions)) {
|
|
124
|
+
const current = props[prop] ?? config.variants?.[prop]?.default;
|
|
125
|
+
if (Array.isArray(expected) ? !expected.includes(current) : current !== expected) {
|
|
126
|
+
match = false;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (match) classes.push(compound.className);
|
|
131
|
+
}
|
|
121
132
|
if (config.states) {
|
|
122
133
|
for (const state of config.states) if (props[state]) classes.push(`${className}--${state}`);
|
|
123
134
|
}
|
|
@@ -207,7 +218,8 @@ var AnimusExtendedWithAll = class {
|
|
|
207
218
|
variants = {};
|
|
208
219
|
activeGroups = {};
|
|
209
220
|
custom = {};
|
|
210
|
-
|
|
221
|
+
compounds = [];
|
|
222
|
+
constructor(props, groups, base, variants, states, activeGroups, custom, compounds = []) {
|
|
211
223
|
this.propRegistry = props;
|
|
212
224
|
this.groupRegistry = groups;
|
|
213
225
|
this.baseStyles = base;
|
|
@@ -215,9 +227,10 @@ var AnimusExtendedWithAll = class {
|
|
|
215
227
|
this.statesConfig = states;
|
|
216
228
|
this.activeGroups = activeGroups;
|
|
217
229
|
this.custom = custom;
|
|
230
|
+
this.compounds = compounds;
|
|
218
231
|
}
|
|
219
232
|
extend() {
|
|
220
|
-
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
233
|
+
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom, this.compounds);
|
|
221
234
|
}
|
|
222
235
|
asElement(component) {
|
|
223
236
|
const Component = createComponent(component, "", this._buildComponentConfig());
|
|
@@ -252,32 +265,46 @@ var AnimusExtendedWithAll = class {
|
|
|
252
265
|
};
|
|
253
266
|
var AnimusExtendedWithSystem = class extends AnimusExtendedWithAll {
|
|
254
267
|
props(config) {
|
|
255
|
-
return new AnimusExtendedWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, deepMerge$1({}, config));
|
|
268
|
+
return new AnimusExtendedWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, deepMerge$1({}, config), this.compounds);
|
|
256
269
|
}
|
|
257
270
|
};
|
|
258
271
|
var AnimusExtendedWithStates = class extends AnimusExtendedWithSystem {
|
|
259
272
|
groups(config) {
|
|
260
|
-
return new AnimusExtendedWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, deepMerge$1(this.activeGroups, config), this.custom);
|
|
273
|
+
return new AnimusExtendedWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, deepMerge$1(this.activeGroups, config), this.custom, this.compounds);
|
|
261
274
|
}
|
|
262
275
|
};
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
var AnimusExtendedWithCompounds = class AnimusExtendedWithCompounds extends AnimusExtendedWithStates {
|
|
277
|
+
compound(condition, styles) {
|
|
278
|
+
return new AnimusExtendedWithCompounds(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom, [...this.compounds, {
|
|
279
|
+
condition,
|
|
280
|
+
styles
|
|
281
|
+
}]);
|
|
267
282
|
}
|
|
268
283
|
states(config) {
|
|
269
|
-
return new AnimusExtendedWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, deepMerge$1(this.statesConfig, config), this.activeGroups, this.custom);
|
|
284
|
+
return new AnimusExtendedWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, deepMerge$1(this.statesConfig, config), this.activeGroups, this.custom, this.compounds);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var AnimusExtendedWithVariants = class AnimusExtendedWithVariants extends AnimusExtendedWithCompounds {
|
|
288
|
+
compound(condition, styles) {
|
|
289
|
+
return new AnimusExtendedWithCompounds(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom, [...this.compounds, {
|
|
290
|
+
condition,
|
|
291
|
+
styles
|
|
292
|
+
}]);
|
|
293
|
+
}
|
|
294
|
+
variant(options) {
|
|
295
|
+
const prop = options.prop || "variant";
|
|
296
|
+
return new AnimusExtendedWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge$1(this.variants, { [prop]: options }), this.statesConfig, this.activeGroups, this.custom, this.compounds);
|
|
270
297
|
}
|
|
271
298
|
};
|
|
272
299
|
var AnimusExtendedWithBase = class extends AnimusExtendedWithVariants {
|
|
273
300
|
variant(options) {
|
|
274
301
|
const prop = options.prop || "variant";
|
|
275
|
-
return new AnimusExtendedWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge$1(this.variants, { [prop]: options }), this.statesConfig, this.activeGroups, this.custom);
|
|
302
|
+
return new AnimusExtendedWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge$1(this.variants, { [prop]: options }), this.statesConfig, this.activeGroups, this.custom, this.compounds);
|
|
276
303
|
}
|
|
277
304
|
};
|
|
278
305
|
var AnimusExtended = class extends AnimusExtendedWithBase {
|
|
279
306
|
styles(config) {
|
|
280
|
-
return new AnimusExtendedWithBase(this.propRegistry, this.groupRegistry, deepMerge$1(this.baseStyles, config), this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
307
|
+
return new AnimusExtendedWithBase(this.propRegistry, this.groupRegistry, deepMerge$1(this.baseStyles, config), this.variants, this.statesConfig, this.activeGroups, this.custom, this.compounds);
|
|
281
308
|
}
|
|
282
309
|
};
|
|
283
310
|
//#endregion
|
|
@@ -299,7 +326,8 @@ var AnimusWithAll = class {
|
|
|
299
326
|
variants = {};
|
|
300
327
|
activeGroups = {};
|
|
301
328
|
custom = {};
|
|
302
|
-
|
|
329
|
+
compounds = [];
|
|
330
|
+
constructor(props, groups, base, variants, states, activeGroups, custom, compounds = []) {
|
|
303
331
|
this.propRegistry = props;
|
|
304
332
|
this.groupRegistry = groups;
|
|
305
333
|
this.baseStyles = base;
|
|
@@ -307,9 +335,10 @@ var AnimusWithAll = class {
|
|
|
307
335
|
this.statesConfig = states;
|
|
308
336
|
this.activeGroups = activeGroups;
|
|
309
337
|
this.custom = custom;
|
|
338
|
+
this.compounds = compounds;
|
|
310
339
|
}
|
|
311
340
|
extend() {
|
|
312
|
-
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom);
|
|
341
|
+
return new AnimusExtended(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, this.custom, this.compounds);
|
|
313
342
|
}
|
|
314
343
|
asElement(component) {
|
|
315
344
|
const Component = createComponent(component, "", this._buildComponentConfig());
|
|
@@ -343,31 +372,48 @@ var AnimusWithAll = class {
|
|
|
343
372
|
}
|
|
344
373
|
};
|
|
345
374
|
var AnimusWithSystem = class extends AnimusWithAll {
|
|
346
|
-
constructor(props, groups, base, variants, states, activeGroups) {
|
|
347
|
-
super(props, groups, base, variants, states, activeGroups, {});
|
|
375
|
+
constructor(props, groups, base, variants, states, activeGroups, compounds = []) {
|
|
376
|
+
super(props, groups, base, variants, states, activeGroups, {}, compounds);
|
|
348
377
|
}
|
|
349
378
|
props(config) {
|
|
350
|
-
return new AnimusWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, config);
|
|
379
|
+
return new AnimusWithAll(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, this.activeGroups, config, this.compounds);
|
|
351
380
|
}
|
|
352
381
|
};
|
|
353
382
|
var AnimusWithStates = class extends AnimusWithSystem {
|
|
354
|
-
constructor(props, groups, base, variants, states) {
|
|
355
|
-
super(props, groups, base, variants, states, {});
|
|
383
|
+
constructor(props, groups, base, variants, states, compounds = []) {
|
|
384
|
+
super(props, groups, base, variants, states, {}, compounds);
|
|
356
385
|
}
|
|
357
386
|
groups(config) {
|
|
358
|
-
return new AnimusWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, config);
|
|
387
|
+
return new AnimusWithSystem(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, this.statesConfig, config, this.compounds);
|
|
359
388
|
}
|
|
360
389
|
};
|
|
361
|
-
var
|
|
362
|
-
constructor(props, groups, base, variants) {
|
|
363
|
-
super(props, groups, base, variants, {});
|
|
390
|
+
var AnimusWithCompounds = class AnimusWithCompounds extends AnimusWithStates {
|
|
391
|
+
constructor(props, groups, base, variants, compounds = []) {
|
|
392
|
+
super(props, groups, base, variants, {}, compounds);
|
|
393
|
+
}
|
|
394
|
+
compound(condition, styles) {
|
|
395
|
+
return new AnimusWithCompounds(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, [...this.compounds, {
|
|
396
|
+
condition,
|
|
397
|
+
styles
|
|
398
|
+
}]);
|
|
364
399
|
}
|
|
365
400
|
states(config) {
|
|
366
|
-
return new AnimusWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, config);
|
|
401
|
+
return new AnimusWithStates(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, config, this.compounds);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var AnimusWithVariants = class AnimusWithVariants extends AnimusWithCompounds {
|
|
405
|
+
constructor(props, groups, base, variants, compounds = []) {
|
|
406
|
+
super(props, groups, base, variants, compounds);
|
|
407
|
+
}
|
|
408
|
+
compound(condition, styles) {
|
|
409
|
+
return new AnimusWithCompounds(this.propRegistry, this.groupRegistry, this.baseStyles, this.variants, [...this.compounds, {
|
|
410
|
+
condition,
|
|
411
|
+
styles
|
|
412
|
+
}]);
|
|
367
413
|
}
|
|
368
414
|
variant(options) {
|
|
369
415
|
const prop = options.prop || "variant";
|
|
370
|
-
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }));
|
|
416
|
+
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }), this.compounds);
|
|
371
417
|
}
|
|
372
418
|
};
|
|
373
419
|
var AnimusWithBase = class extends AnimusWithVariants {
|
|
@@ -376,7 +422,7 @@ var AnimusWithBase = class extends AnimusWithVariants {
|
|
|
376
422
|
}
|
|
377
423
|
variant(options) {
|
|
378
424
|
const prop = options.prop || "variant";
|
|
379
|
-
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }));
|
|
425
|
+
return new AnimusWithVariants(this.propRegistry, this.groupRegistry, this.baseStyles, deepMerge(this.variants, { [prop]: options }), this.compounds);
|
|
380
426
|
}
|
|
381
427
|
};
|
|
382
428
|
var Animus = class extends AnimusWithBase {
|
|
@@ -537,6 +583,193 @@ const serializeTokens = (tokens, prefix, theme) => {
|
|
|
537
583
|
};
|
|
538
584
|
//#endregion
|
|
539
585
|
//#region src/theme/createTheme.ts
|
|
586
|
+
const CSS_NAMED_COLORS = new Set([
|
|
587
|
+
"aliceblue",
|
|
588
|
+
"antiquewhite",
|
|
589
|
+
"aqua",
|
|
590
|
+
"aquamarine",
|
|
591
|
+
"azure",
|
|
592
|
+
"beige",
|
|
593
|
+
"bisque",
|
|
594
|
+
"black",
|
|
595
|
+
"blanchedalmond",
|
|
596
|
+
"blue",
|
|
597
|
+
"blueviolet",
|
|
598
|
+
"brown",
|
|
599
|
+
"burlywood",
|
|
600
|
+
"cadetblue",
|
|
601
|
+
"chartreuse",
|
|
602
|
+
"chocolate",
|
|
603
|
+
"coral",
|
|
604
|
+
"cornflowerblue",
|
|
605
|
+
"cornsilk",
|
|
606
|
+
"crimson",
|
|
607
|
+
"cyan",
|
|
608
|
+
"darkblue",
|
|
609
|
+
"darkcyan",
|
|
610
|
+
"darkgoldenrod",
|
|
611
|
+
"darkgray",
|
|
612
|
+
"darkgreen",
|
|
613
|
+
"darkgrey",
|
|
614
|
+
"darkkhaki",
|
|
615
|
+
"darkmagenta",
|
|
616
|
+
"darkolivegreen",
|
|
617
|
+
"darkorange",
|
|
618
|
+
"darkorchid",
|
|
619
|
+
"darkred",
|
|
620
|
+
"darksalmon",
|
|
621
|
+
"darkseagreen",
|
|
622
|
+
"darkslateblue",
|
|
623
|
+
"darkslategray",
|
|
624
|
+
"darkslategrey",
|
|
625
|
+
"darkturquoise",
|
|
626
|
+
"darkviolet",
|
|
627
|
+
"deeppink",
|
|
628
|
+
"deepskyblue",
|
|
629
|
+
"dimgray",
|
|
630
|
+
"dimgrey",
|
|
631
|
+
"dodgerblue",
|
|
632
|
+
"firebrick",
|
|
633
|
+
"floralwhite",
|
|
634
|
+
"forestgreen",
|
|
635
|
+
"fuchsia",
|
|
636
|
+
"gainsboro",
|
|
637
|
+
"ghostwhite",
|
|
638
|
+
"gold",
|
|
639
|
+
"goldenrod",
|
|
640
|
+
"gray",
|
|
641
|
+
"green",
|
|
642
|
+
"greenyellow",
|
|
643
|
+
"grey",
|
|
644
|
+
"honeydew",
|
|
645
|
+
"hotpink",
|
|
646
|
+
"indianred",
|
|
647
|
+
"indigo",
|
|
648
|
+
"ivory",
|
|
649
|
+
"khaki",
|
|
650
|
+
"lavender",
|
|
651
|
+
"lavenderblush",
|
|
652
|
+
"lawngreen",
|
|
653
|
+
"lemonchiffon",
|
|
654
|
+
"lightblue",
|
|
655
|
+
"lightcoral",
|
|
656
|
+
"lightcyan",
|
|
657
|
+
"lightgoldenrodyellow",
|
|
658
|
+
"lightgray",
|
|
659
|
+
"lightgreen",
|
|
660
|
+
"lightgrey",
|
|
661
|
+
"lightpink",
|
|
662
|
+
"lightsalmon",
|
|
663
|
+
"lightseagreen",
|
|
664
|
+
"lightskyblue",
|
|
665
|
+
"lightslategray",
|
|
666
|
+
"lightslategrey",
|
|
667
|
+
"lightsteelblue",
|
|
668
|
+
"lightyellow",
|
|
669
|
+
"lime",
|
|
670
|
+
"limegreen",
|
|
671
|
+
"linen",
|
|
672
|
+
"magenta",
|
|
673
|
+
"maroon",
|
|
674
|
+
"mediumaquamarine",
|
|
675
|
+
"mediumblue",
|
|
676
|
+
"mediumorchid",
|
|
677
|
+
"mediumpurple",
|
|
678
|
+
"mediumseagreen",
|
|
679
|
+
"mediumslateblue",
|
|
680
|
+
"mediumspringgreen",
|
|
681
|
+
"mediumturquoise",
|
|
682
|
+
"mediumvioletred",
|
|
683
|
+
"midnightblue",
|
|
684
|
+
"mintcream",
|
|
685
|
+
"mistyrose",
|
|
686
|
+
"moccasin",
|
|
687
|
+
"navajowhite",
|
|
688
|
+
"navy",
|
|
689
|
+
"oldlace",
|
|
690
|
+
"olive",
|
|
691
|
+
"olivedrab",
|
|
692
|
+
"orange",
|
|
693
|
+
"orangered",
|
|
694
|
+
"orchid",
|
|
695
|
+
"palegoldenrod",
|
|
696
|
+
"palegreen",
|
|
697
|
+
"paleturquoise",
|
|
698
|
+
"palevioletred",
|
|
699
|
+
"papayawhip",
|
|
700
|
+
"peachpuff",
|
|
701
|
+
"peru",
|
|
702
|
+
"pink",
|
|
703
|
+
"plum",
|
|
704
|
+
"powderblue",
|
|
705
|
+
"purple",
|
|
706
|
+
"rebeccapurple",
|
|
707
|
+
"red",
|
|
708
|
+
"rosybrown",
|
|
709
|
+
"royalblue",
|
|
710
|
+
"saddlebrown",
|
|
711
|
+
"salmon",
|
|
712
|
+
"sandybrown",
|
|
713
|
+
"seagreen",
|
|
714
|
+
"seashell",
|
|
715
|
+
"sienna",
|
|
716
|
+
"silver",
|
|
717
|
+
"skyblue",
|
|
718
|
+
"slateblue",
|
|
719
|
+
"slategray",
|
|
720
|
+
"slategrey",
|
|
721
|
+
"snow",
|
|
722
|
+
"springgreen",
|
|
723
|
+
"steelblue",
|
|
724
|
+
"tan",
|
|
725
|
+
"teal",
|
|
726
|
+
"thistle",
|
|
727
|
+
"tomato",
|
|
728
|
+
"turquoise",
|
|
729
|
+
"violet",
|
|
730
|
+
"wheat",
|
|
731
|
+
"white",
|
|
732
|
+
"whitesmoke",
|
|
733
|
+
"yellow",
|
|
734
|
+
"yellowgreen"
|
|
735
|
+
]);
|
|
736
|
+
const COLOR_FUNCTION_PREFIXES = [
|
|
737
|
+
"rgb(",
|
|
738
|
+
"rgba(",
|
|
739
|
+
"hsl(",
|
|
740
|
+
"hsla(",
|
|
741
|
+
"oklch(",
|
|
742
|
+
"oklab(",
|
|
743
|
+
"lch(",
|
|
744
|
+
"lab(",
|
|
745
|
+
"color(",
|
|
746
|
+
"color-mix("
|
|
747
|
+
];
|
|
748
|
+
/** Validate that a value is a valid CSS <color>. */
|
|
749
|
+
function isValidCSSColor(value) {
|
|
750
|
+
if (typeof value !== "string") return false;
|
|
751
|
+
const v = value.trim();
|
|
752
|
+
if (v === "") return false;
|
|
753
|
+
if (v === "transparent" || v === "currentColor" || v === "currentcolor") return true;
|
|
754
|
+
if (v.startsWith("#") && /^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v)) return true;
|
|
755
|
+
for (const prefix of COLOR_FUNCTION_PREFIXES) if (v.startsWith(prefix) && v.endsWith(")")) return true;
|
|
756
|
+
if (CSS_NAMED_COLORS.has(v.toLowerCase())) return true;
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
/** Validate that mode aliases reference existing color keys. */
|
|
760
|
+
function validateModeAliases(modeName, aliases, colorSet, availableColors, prefix) {
|
|
761
|
+
for (const [key, value] of Object.entries(aliases)) {
|
|
762
|
+
const aliasPath = prefix ? `${prefix}-${key}` : key;
|
|
763
|
+
if (typeof value === "string") {
|
|
764
|
+
if (!colorSet.has(value)) throw new Error(`addColorModes: mode '${modeName}' references unknown color '${value}' for alias '${aliasPath}'. Available colors: ${availableColors.slice(0, 10).join(", ")}${availableColors.length > 10 ? ", ..." : ""}`);
|
|
765
|
+
} else if (isObject(value)) validateModeAliases(modeName, value, colorSet, availableColors, aliasPath);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
/** Validate all color entries, throwing on invalid values. */
|
|
769
|
+
function validateColors(colors) {
|
|
770
|
+
for (const [key, value] of Object.entries(colors)) if (isObject(value)) validateColors(value);
|
|
771
|
+
else if (!isValidCSSColor(value)) throw new Error(`addColors: '${String(value)}' is not a valid CSS <color> value for key '${key}'. Expected hex (#fff), rgb(), hsl(), oklch(), named color, transparent, or currentColor.`);
|
|
772
|
+
}
|
|
540
773
|
var ThemeBuilder = class {
|
|
541
774
|
#theme = {};
|
|
542
775
|
constructor(baseTheme) {
|
|
@@ -562,6 +795,7 @@ var ThemeBuilder = class {
|
|
|
562
795
|
* @example .addColors({ navy: 'navy', hyper: 'purple' })
|
|
563
796
|
*/
|
|
564
797
|
addColors(colors) {
|
|
798
|
+
validateColors(colors);
|
|
565
799
|
const flatColors = flattenScale(colors);
|
|
566
800
|
const { variables, tokens } = serializeTokens(flatColors, "color", this.#theme);
|
|
567
801
|
this.#theme = merge({}, this.#theme, {
|
|
@@ -578,6 +812,9 @@ var ThemeBuilder = class {
|
|
|
578
812
|
* @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
|
|
579
813
|
*/
|
|
580
814
|
addColorModes(initialMode, modeConfig) {
|
|
815
|
+
const availableColors = this.#theme._tokens?.colors ? Object.keys(this.#theme._tokens.colors) : Object.keys(this.#theme.colors || {});
|
|
816
|
+
const colorSet = new Set(availableColors);
|
|
817
|
+
for (const [modeName, modeAliases] of Object.entries(modeConfig)) validateModeAliases(modeName, modeAliases, colorSet, availableColors, "");
|
|
581
818
|
const modes = mapValues(modeConfig, (mode) => flattenScale(mode));
|
|
582
819
|
const { tokens: colors, variables } = serializeTokens(mapValues(merge({}, this.#theme.modes?.[initialMode], modes[initialMode]), (color) => this.#theme.colors[color]), "color", this.#theme);
|
|
583
820
|
const getColorValue = (color) => this.#theme._tokens?.colors?.[color];
|
|
@@ -614,17 +851,105 @@ var ThemeBuilder = class {
|
|
|
614
851
|
/**
|
|
615
852
|
* This finalizes the theme build and returns the final theme and variables to be provided.
|
|
616
853
|
* Simplify flattens the deeply nested MergeTheme chain into a shallow object type.
|
|
854
|
+
*
|
|
855
|
+
* The returned theme object also has a non-enumerable `.manifest` property containing
|
|
856
|
+
* a structured ThemeManifest for plugin consumption.
|
|
617
857
|
*/
|
|
618
858
|
build() {
|
|
619
859
|
const { variables } = serializeTokens(mapValues(this.#theme.breakpoints, (val) => `${val}px`), "breakpoint", this.#theme);
|
|
620
|
-
|
|
860
|
+
const theme = merge({}, this.#theme, {
|
|
621
861
|
_variables: { breakpoints: variables },
|
|
622
862
|
_tokens: {}
|
|
623
863
|
});
|
|
864
|
+
const manifest = assembleManifest(theme);
|
|
865
|
+
Object.defineProperty(theme, "manifest", {
|
|
866
|
+
value: manifest,
|
|
867
|
+
enumerable: false,
|
|
868
|
+
configurable: false,
|
|
869
|
+
writable: false
|
|
870
|
+
});
|
|
871
|
+
return theme;
|
|
624
872
|
}
|
|
625
873
|
};
|
|
626
874
|
function createTheme(base) {
|
|
627
875
|
return new ThemeBuilder(base);
|
|
628
876
|
}
|
|
877
|
+
/**
|
|
878
|
+
* Assemble a ThemeManifest from the built theme object.
|
|
879
|
+
*
|
|
880
|
+
* This is the single source of truth for the plugin — no string-matching
|
|
881
|
+
* or re-flattening needed downstream.
|
|
882
|
+
*/
|
|
883
|
+
function assembleManifest(theme) {
|
|
884
|
+
const tokenMap = {};
|
|
885
|
+
const variableMap = {};
|
|
886
|
+
for (const [scaleName, scaleValue] of Object.entries(theme)) {
|
|
887
|
+
if (scaleName.startsWith("_")) continue;
|
|
888
|
+
if (scaleName === "breakpoints" || scaleName === "mode" || scaleName === "modes") continue;
|
|
889
|
+
if (typeof scaleValue === "function") continue;
|
|
890
|
+
if (isObject(scaleValue)) flattenTokens(tokenMap, variableMap, scaleName, scaleValue);
|
|
891
|
+
}
|
|
892
|
+
const modes = {};
|
|
893
|
+
if (theme._tokens?.modes && isObject(theme._tokens.modes)) for (const [modeName, modeTokens] of Object.entries(theme._tokens.modes)) {
|
|
894
|
+
if (!isObject(modeTokens)) continue;
|
|
895
|
+
const modeMap = {};
|
|
896
|
+
flattenModeEntries(modeMap, modeTokens, "");
|
|
897
|
+
modes[modeName] = modeMap;
|
|
898
|
+
}
|
|
899
|
+
return {
|
|
900
|
+
tokenMap,
|
|
901
|
+
variableMap,
|
|
902
|
+
modes,
|
|
903
|
+
variableCss: buildManifestVariableCss(theme)
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/** Flatten a scale into tokenMap and extract variable references into variableMap. */
|
|
907
|
+
function flattenTokens(tokenMap, variableMap, prefix, obj, parentKey = "") {
|
|
908
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
909
|
+
const fullKey = parentKey ? `${parentKey}-${key}` : key;
|
|
910
|
+
if (isObject(value)) flattenTokens(tokenMap, variableMap, prefix, value, fullKey);
|
|
911
|
+
else {
|
|
912
|
+
const tokenPath = `${prefix}.${fullKey}`;
|
|
913
|
+
const strValue = String(value);
|
|
914
|
+
tokenMap[tokenPath] = strValue;
|
|
915
|
+
if (strValue.startsWith("var(") && strValue.endsWith(")")) variableMap[tokenPath] = strValue.slice(4, -1);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/** Flatten mode token entries (resolved values) into a flat key→value map. */
|
|
920
|
+
function flattenModeEntries(modeMap, obj, prefix) {
|
|
921
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
922
|
+
const namePart = key === "_" ? prefix : prefix ? `${prefix}-${key}` : key;
|
|
923
|
+
if (typeof value === "string" || typeof value === "number") modeMap[`colors.${namePart}`] = String(value);
|
|
924
|
+
else if (isObject(value)) flattenModeEntries(modeMap, value, namePart);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
/** Build CSS variable blocks from theme._variables and _tokens.modes. */
|
|
928
|
+
function buildManifestVariableCss(theme) {
|
|
929
|
+
const parts = [];
|
|
930
|
+
if (theme._variables && isObject(theme._variables)) {
|
|
931
|
+
const rootLines = [];
|
|
932
|
+
for (const categoryValue of Object.values(theme._variables)) {
|
|
933
|
+
if (!isObject(categoryValue)) continue;
|
|
934
|
+
for (const [cssVar, cssValue] of Object.entries(categoryValue)) if (typeof cssValue === "string") rootLines.push(` ${cssVar}: ${cssValue};`);
|
|
935
|
+
}
|
|
936
|
+
if (rootLines.length > 0) parts.push(`:root {\n${rootLines.join("\n")}\n}`);
|
|
937
|
+
}
|
|
938
|
+
if (theme._tokens?.modes && isObject(theme._tokens.modes)) for (const [modeName, modeTokens] of Object.entries(theme._tokens.modes)) {
|
|
939
|
+
if (!isObject(modeTokens)) continue;
|
|
940
|
+
const modeLines = [];
|
|
941
|
+
flattenModeTokensCss(modeLines, modeTokens, "");
|
|
942
|
+
if (modeLines.length > 0) parts.push(`[data-color-mode="${modeName}"] {\n${modeLines.join("\n")}\n}`);
|
|
943
|
+
}
|
|
944
|
+
return parts.join("\n\n");
|
|
945
|
+
}
|
|
946
|
+
/** Recursively flatten mode tokens into CSS variable declaration lines. */
|
|
947
|
+
function flattenModeTokensCss(lines, obj, prefix) {
|
|
948
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
949
|
+
const namePart = key === "_" ? prefix : prefix ? `${prefix}-${key}` : key;
|
|
950
|
+
if (typeof value === "string" || typeof value === "number") lines.push(` --color-${namePart}: ${value};`);
|
|
951
|
+
else if (isObject(value)) flattenModeTokensCss(lines, value, namePart);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
629
954
|
//#endregion
|
|
630
955
|
export { Animus, AnimusExtended, AnimusExtendedWithAll, AnimusWithAll, PropertyBuilder, SystemBuilder, ThemeBuilder, borderShorthand, createComponent, createScale, createSystem, createTheme, createTransform, flattenScale, gridItem, gridItemRatio, numericOrStringScale, numericScale, percentageOrAbsolute, serializeTokens, size, stringScale };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -3,8 +3,13 @@ interface VariantConfig {
|
|
|
3
3
|
options: string[];
|
|
4
4
|
default?: string;
|
|
5
5
|
}
|
|
6
|
+
interface CompoundConfig {
|
|
7
|
+
conditions: Record<string, string | string[]>;
|
|
8
|
+
className: string;
|
|
9
|
+
}
|
|
6
10
|
interface ComponentConfig {
|
|
7
11
|
variants?: Record<string, VariantConfig>;
|
|
12
|
+
compounds?: CompoundConfig[];
|
|
8
13
|
states?: string[];
|
|
9
14
|
systemPropNames?: string[];
|
|
10
15
|
customPropMap?: Record<string, Record<string, string>>;
|
|
@@ -1 +1 @@
|
|
|
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IF,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAErD,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG;IACrD,MAAM,EAAE,MAAM,KAAK,CAAC;CACrB,CAAC;AAwHF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,aAAa,EAC7B,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,eAAe,CAuLjB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractTheme,
|
|
1
|
+
import { AbstractTheme, CSSColorValue } from '../types/theme';
|
|
2
2
|
import { LiteralPaths } from './flattenScale';
|
|
3
3
|
import { KeyAsVariable } from './serializeTokens';
|
|
4
4
|
import { ColorModeConfig, Merge, MergeTheme, PrivateThemeKeys } from './types';
|
|
@@ -16,7 +16,7 @@ export declare class ThemeBuilder<T extends AbstractTheme> {
|
|
|
16
16
|
* @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
|
|
17
17
|
* @example .addColors({ navy: 'navy', hyper: 'purple' })
|
|
18
18
|
*/
|
|
19
|
-
addColors<Colors extends Record<string,
|
|
19
|
+
addColors<Colors extends Record<string, CSSColorValue | Record<string, CSSColorValue>>, NextColors extends LiteralPaths<Colors, '-'>>(colors: Colors): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, Record<'colors', KeyAsVariable<NextColors, 'color'>>>>;
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
* @param initialMode A key of the object passed for modes. This sets the default state for the theme and transforms the correct variables.
|
|
@@ -50,6 +50,9 @@ export declare class ThemeBuilder<T extends AbstractTheme> {
|
|
|
50
50
|
/**
|
|
51
51
|
* This finalizes the theme build and returns the final theme and variables to be provided.
|
|
52
52
|
* Simplify flattens the deeply nested MergeTheme chain into a shallow object type.
|
|
53
|
+
*
|
|
54
|
+
* The returned theme object also has a non-enumerable `.manifest` property containing
|
|
55
|
+
* a structured ThemeManifest for plugin consumption.
|
|
53
56
|
*/
|
|
54
57
|
build(): {
|
|
55
58
|
[K in keyof (T & PrivateThemeKeys)]: (T & PrivateThemeKeys)[K];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAgB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAmB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgP/E,qBAAa,YAAY,CAAC,CAAC,SAAS,aAAa;;gBAGnC,SAAS,EAAE,CAAC;IAGxB;;;;OAIG;IACH,oBAAoB,CAAC,GAAG,SAAS,MAAM,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,GAAG,MAAM,EACpE,GAAG,EAAE,GAAG,GACP,YAAY,CACb,UAAU,CACR,CAAC,EACD,gBAAgB,EAChB,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CACrD,CACF;IAkBD;;;;OAIG;IACH,SAAS,CACP,MAAM,SAAS,MAAM,CACnB,MAAM,EACN,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAC9C,EACD,UAAU,SAAS,YAAY,CAAC,MAAM,EAAE,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AC,UAAU,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAElD,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,EAAE,GACd,YAAY,CAAC;SACb,CAAC,IAAI,MAAM,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,UAAU,CAC3D,CAAC,EACD,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CACtB,CAAC,CAAC,CAAC;KACL,CAAC;IAOF;;;;;OAKG;IACH,WAAW,CACT,GAAG,SAAS,MAAM,CAAC,EACnB,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAE/D,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,EAAE,GACX,YAAY,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IAMzD;;;;;;OAMG;IACH,KAAK,IAAI;SAAG,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;KAAE;CAuB5E;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,CAAC,mBAE3D"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { AbstractProps } from '../types/props';
|
|
2
|
+
import type { CSSObject } from '../types/shared';
|
|
3
|
+
export type TransformFn = (value: string | number, property?: string, props?: AbstractProps) => string | number | CSSObject;
|
|
2
4
|
export type NamedTransform = TransformFn & {
|
|
3
5
|
transformName: string;
|
|
4
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransform.d.ts","sourceRoot":"","sources":["../../src/transforms/createTransform.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"createTransform.d.ts","sourceRoot":"","sources":["../../src/transforms/createTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,aAAa,KAClB,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,cAAc,CAK7E"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef, ComponentType, ForwardRefExoticComponent, ReactNode } from 'react';
|
|
2
2
|
import type { AnimusExtended } from '../AnimusExtended';
|
|
3
|
-
import type { AbstractParser, CSSPropMap, CSSProps, Prop,
|
|
3
|
+
import type { AbstractParser, CSSPropMap, CSSProps, Prop, SystemProps, ThemedScale, VariantConfig } from './config';
|
|
4
4
|
import type { AbstractProps } from './props';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
extend: () => AnimusExtended<T, PR, GR, BS & CSSProps<AbstractProps, SystemProps<AbstractParser>>, V & Record<string, VariantConfig>, S & CSSPropMap<AbstractProps, SystemProps<AbstractParser>>, AG & Record<string, true>, CP & Record<string, Prop>>;
|
|
5
|
+
type ExtendFn<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP> = {
|
|
6
|
+
extend: () => AnimusExtended<PR, GR, BS & CSSProps<AbstractProps, SystemProps<AbstractParser>>, V & Record<string, VariantConfig>, S & CSSPropMap<AbstractProps, SystemProps<AbstractParser>>, AG & Record<string, true>, CP & Record<string, Prop>>;
|
|
8
7
|
};
|
|
9
8
|
/**
|
|
10
9
|
* Compute the group prop names from active groups.
|
|
@@ -14,17 +13,17 @@ type ExtendFn<T extends BaseTheme, PR extends Record<string, Prop>, GR extends R
|
|
|
14
13
|
type ActiveGroupPropNames<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, AG> = GR[Extract<keyof AG, keyof GR>][number];
|
|
15
14
|
/**
|
|
16
15
|
* Compute the group system props — each active group prop accepts its scale-resolved type.
|
|
17
|
-
*
|
|
16
|
+
* Uses the augmented Theme interface via ThemedScale (no generic T needed).
|
|
18
17
|
*/
|
|
19
|
-
type GroupProps<
|
|
20
|
-
[K in ActiveGroupPropNames<PR, GR, AG> as K extends string ? K : never]?:
|
|
18
|
+
type GroupProps<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, AG> = {
|
|
19
|
+
[K in ActiveGroupPropNames<PR, GR, AG> as K extends string ? K : never]?: ThemedScale<PR[K & keyof PR]>;
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
22
|
* Compute custom prop types from .props() config.
|
|
24
|
-
* Each key K in CP maps to
|
|
23
|
+
* Each key K in CP maps to ThemedScale<CP[K]>.
|
|
25
24
|
*/
|
|
26
|
-
type CustomPropValues<CP extends Record<string, Prop
|
|
27
|
-
[K in keyof CP]?:
|
|
25
|
+
type CustomPropValues<CP extends Record<string, Prop>> = {
|
|
26
|
+
[K in keyof CP]?: ThemedScale<CP[K]>;
|
|
28
27
|
};
|
|
29
28
|
/**
|
|
30
29
|
* Compute variant props — each variant key accepts one of its variant values.
|
|
@@ -42,20 +41,20 @@ type StateProps<S> = string extends keyof S ? {} : {
|
|
|
42
41
|
[K in keyof S]?: boolean;
|
|
43
42
|
};
|
|
44
43
|
/** Component type for .asElement() — HTML element tag with full Animus props. */
|
|
45
|
-
export type AnimusComponent<El extends keyof JSX.IntrinsicElements,
|
|
44
|
+
export type AnimusComponent<El extends keyof JSX.IntrinsicElements, PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP extends Record<string, Prop>> = ForwardRefExoticComponent<ComponentPropsWithRef<El> & GroupProps<PR, GR, AG> & VariantProps<V> & StateProps<S> & CustomPropValues<CP> & {
|
|
46
45
|
as?: keyof JSX.IntrinsicElements | ComponentType<{
|
|
47
46
|
className?: string;
|
|
48
47
|
}>;
|
|
49
48
|
className?: string;
|
|
50
49
|
children?: ReactNode;
|
|
51
|
-
}> & ExtendFn<
|
|
50
|
+
}> & ExtendFn<PR, GR, BS, V, S, AG, CP>;
|
|
52
51
|
/** Component type for .asComponent() — wraps an existing React component. */
|
|
53
|
-
export type AnimusWrappedComponent<
|
|
52
|
+
export type AnimusWrappedComponent<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, BS, V, S, AG, CP> = ForwardRefExoticComponent<Record<string, any> & GroupProps<PR, GR, {}> & VariantProps<V> & StateProps<S> & {
|
|
54
53
|
as?: keyof JSX.IntrinsicElements | ComponentType<{
|
|
55
54
|
className?: string;
|
|
56
55
|
}>;
|
|
57
56
|
className?: string;
|
|
58
57
|
children?: ReactNode;
|
|
59
|
-
}> & ExtendFn<
|
|
58
|
+
}> & ExtendFn<PR, GR, BS, V, S, AG, CP>;
|
|
60
59
|
export {};
|
|
61
60
|
//# sourceMappingURL=component.d.ts.map
|