@animus-ui/system 0.1.0-next.18 → 0.1.0-next.23
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/SystemBuilder.d.ts.map +1 -1
- package/dist/compose.d.ts +21 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/groups/index.d.ts +1 -0
- package/dist/groups/index.d.ts.map +1 -1
- package/dist/groups/index.js +2 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +192 -45
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/theme/createTheme.d.ts +50 -34
- package/dist/theme/createTheme.d.ts.map +1 -1
- package/dist/theme/serializeTokens.d.ts +2 -2
- package/dist/theme/serializeTokens.d.ts.map +1 -1
- package/dist/types/component.d.ts +102 -1
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/config.d.ts +13 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/props.d.ts +13 -25
- package/dist/types/props.d.ts.map +1 -1
- package/dist/types/theme.d.ts +36 -8
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemBuilder.d.ts","sourceRoot":"","sources":["../src/SystemBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"SystemBuilder.d.ts","sourceRoot":"","sources":["../src/SystemBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAA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AI,gBAAgB,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAqDD,wBAAgB,YAAY,0BAE3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnimusComponent, ComposedFamily, SharedConfig } from './types/component';
|
|
2
|
+
type AnyAnimusComponent = AnimusComponent<any, any, any, any, any, any, any, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Compose independently-authored Animus components into a sealed,
|
|
5
|
+
* namespaced component family with shared variant propagation via
|
|
6
|
+
* React context.
|
|
7
|
+
*
|
|
8
|
+
* - **Enforce**: TypeScript ensures shared keys exist on Root (the
|
|
9
|
+
* provider). Non-Root slots that have the key consume it from
|
|
10
|
+
* context; slots without the key are unaffected.
|
|
11
|
+
* - **Wire**: Root provides shared variant values via context.
|
|
12
|
+
* Child slots consume from context. Direct props override context.
|
|
13
|
+
* - **Seal**: Output components are plain ForwardRefExoticComponent —
|
|
14
|
+
* no `.extend()`, no builder methods. One-way door from builder-land
|
|
15
|
+
* to component-land.
|
|
16
|
+
*/
|
|
17
|
+
export declare function compose<Slots extends Record<string, AnyAnimusComponent>, const Shared extends SharedConfig<Slots>>(slots: Slots, options: {
|
|
18
|
+
shared: Shared;
|
|
19
|
+
}): ComposedFamily<Slots>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,KAAK,kBAAkB,GAAG,eAAe,CACvC,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAAC;AAIF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CACrB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAChD,KAAK,CAAC,MAAM,SAAS,YAAY,CAAC,KAAK,CAAC,EACxC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAAC,KAAK,CAAC,CAmElE"}
|
package/dist/groups/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/groups/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/groups/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBR,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwHT,CAAC;AA8BX,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQP,CAAC;AAWX,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCP,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUb,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAed,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAIV,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CT,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBb,CAAC;AAwCX,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGR,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;AAEX,eAAO,MAAM,IAAI;;;;;CAEP,CAAC;AAEX,eAAO,MAAM,IAAI;;;;CAEP,CAAC"}
|
package/dist/groups/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Animus, AnimusWithAll } from './Animus';
|
|
2
2
|
export { AnimusExtended, AnimusExtendedWithAll } from './AnimusExtended';
|
|
3
|
+
export { compose } from './compose';
|
|
3
4
|
export { PropertyBuilder } from './PropertyBuilder';
|
|
4
5
|
export { createComponent } from './runtime';
|
|
5
6
|
export { createClassResolver } from './runtime/createClassResolver';
|
|
@@ -12,10 +13,10 @@ export { borderShorthand } from './transforms/border';
|
|
|
12
13
|
export { createTransform, type NamedTransform, type TransformFn, } from './transforms/createTransform';
|
|
13
14
|
export { gridItem, gridItemRatio } from './transforms/grid';
|
|
14
15
|
export { percentageOrAbsolute, size } from './transforms/size';
|
|
15
|
-
export type { AnimusComponent, AnimusWrappedComponent, } from './types/component';
|
|
16
|
+
export type { AnimusComponent, AnimusWrappedComponent, ComposedFamily, ComposedRoot, ComposedSlot, SharedConfig, SharedVariantKeys, VariantPropsOf, } from './types/component';
|
|
16
17
|
export type { AbstractParser, CompoundEntry, CSSPropMap, CSSProps, Parser, ParserProps, Prop, PropertyValues, Scale, ScaleValue, SystemProps, ThemedCSSPropMap, ThemedCSSProps, ThemedScale, ThemedScaleValue, VariantConfig, } from './types/config';
|
|
17
|
-
export type { AbstractProps,
|
|
18
|
+
export type { AbstractProps, MediaQueryMap, ResponsiveProp, ThemeProps, } from './types/props';
|
|
18
19
|
export type { ArrayScale, MapScale } from './types/scales';
|
|
19
20
|
export type { CSSObject } from './types/shared';
|
|
20
|
-
export type { AbstractTheme, BaseTheme,
|
|
21
|
+
export type { AbstractTheme, BaseTheme, CSSColorValue, EmittedScales, EmittedTokenPaths, ScaleTokenRef, Theme, ThemeManifest, TokenScales, } from './types/theme';
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,MAAM,EACN,uBAAuB,EACvB,eAAe,EACf,QAAQ,EACR,aAAa,EACb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K,EACL,UAAU,EACV,IAAI,EACJ,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,WAAW,GACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE/D,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,IAAI,EACJ,cAAc,EACd,KAAK,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,YAAY,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as borderShorthand, c as numericOrStringScale, i as gridItemRatio, l as numericScale, n as size, o as createTransform, r as gridItem, s as createScale, t as percentageOrAbsolute, u as stringScale } from "./size-Dge_rsuz.js";
|
|
2
|
-
import { createElement, forwardRef, useRef } from "react";
|
|
2
|
+
import { createContext, createElement, forwardRef, useContext, useRef } from "react";
|
|
3
3
|
//#region src/runtime/resolveClasses.ts
|
|
4
4
|
/**
|
|
5
5
|
* CSS properties that accept unitless numeric values.
|
|
@@ -204,6 +204,7 @@ function createComponent(element, className, config, systemPropMap, dynamicPropC
|
|
|
204
204
|
return createElement(renderElement, domProps);
|
|
205
205
|
});
|
|
206
206
|
Component.displayName = className;
|
|
207
|
+
Component.__variantKeys = new Set(variantProps);
|
|
207
208
|
return Object.assign(Component, { extend: () => {
|
|
208
209
|
throw new Error(`Cannot extend extracted component "${className}" at runtime. Extensions must be authored in source code using the builder API (e.g. import the original component and call .extend() there) so the extraction pipeline can resolve them at build time.`);
|
|
209
210
|
} });
|
|
@@ -461,6 +462,67 @@ var Animus = class extends AnimusWithBase {
|
|
|
461
462
|
}
|
|
462
463
|
};
|
|
463
464
|
//#endregion
|
|
465
|
+
//#region src/compose.ts
|
|
466
|
+
const EMPTY_SHARED = {};
|
|
467
|
+
/**
|
|
468
|
+
* Compose independently-authored Animus components into a sealed,
|
|
469
|
+
* namespaced component family with shared variant propagation via
|
|
470
|
+
* React context.
|
|
471
|
+
*
|
|
472
|
+
* - **Enforce**: TypeScript ensures shared keys exist on Root (the
|
|
473
|
+
* provider). Non-Root slots that have the key consume it from
|
|
474
|
+
* context; slots without the key are unaffected.
|
|
475
|
+
* - **Wire**: Root provides shared variant values via context.
|
|
476
|
+
* Child slots consume from context. Direct props override context.
|
|
477
|
+
* - **Seal**: Output components are plain ForwardRefExoticComponent —
|
|
478
|
+
* no `.extend()`, no builder methods. One-way door from builder-land
|
|
479
|
+
* to component-land.
|
|
480
|
+
*/
|
|
481
|
+
function compose(slots, options) {
|
|
482
|
+
const sharedKeys = Object.keys(options.shared);
|
|
483
|
+
const FamilyContext = createContext(EMPTY_SHARED);
|
|
484
|
+
const rootSlot = slots.Root ?? slots.root;
|
|
485
|
+
const familyName = rootSlot?.displayName ? rootSlot.displayName.replace(/[-_].*$/, "") : "Composed";
|
|
486
|
+
const result = {};
|
|
487
|
+
for (const [name, SourceComponent] of Object.entries(slots)) {
|
|
488
|
+
const capitalizedName = name.charAt(0).toUpperCase() + name.slice(1);
|
|
489
|
+
if (name.toLowerCase() === "root") {
|
|
490
|
+
const RootWrapper = forwardRef((props, ref) => {
|
|
491
|
+
const sharedValues = {};
|
|
492
|
+
for (const key of sharedKeys) if (key in props) sharedValues[key] = props[key];
|
|
493
|
+
return createElement(FamilyContext.Provider, { value: sharedKeys.length > 0 ? sharedValues : EMPTY_SHARED }, createElement(SourceComponent, {
|
|
494
|
+
...props,
|
|
495
|
+
ref
|
|
496
|
+
}));
|
|
497
|
+
});
|
|
498
|
+
RootWrapper.displayName = `${familyName}.${capitalizedName}`;
|
|
499
|
+
result[capitalizedName] = RootWrapper;
|
|
500
|
+
} else {
|
|
501
|
+
const knownKeys = SourceComponent.__variantKeys;
|
|
502
|
+
const ChildWrapper = forwardRef((props, ref) => {
|
|
503
|
+
const shared = useContext(FamilyContext);
|
|
504
|
+
let merged;
|
|
505
|
+
if (knownKeys && sharedKeys.length > 0) {
|
|
506
|
+
const filtered = {};
|
|
507
|
+
for (const key of sharedKeys) if (knownKeys.has(key) && key in shared) filtered[key] = shared[key];
|
|
508
|
+
merged = {
|
|
509
|
+
...filtered,
|
|
510
|
+
...props,
|
|
511
|
+
ref
|
|
512
|
+
};
|
|
513
|
+
} else merged = {
|
|
514
|
+
...props,
|
|
515
|
+
ref
|
|
516
|
+
};
|
|
517
|
+
return createElement(SourceComponent, merged);
|
|
518
|
+
});
|
|
519
|
+
ChildWrapper.displayName = `${familyName}.${capitalizedName}`;
|
|
520
|
+
result[capitalizedName] = ChildWrapper;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
464
526
|
//#region src/PropertyBuilder.ts
|
|
465
527
|
var PropertyBuilder = class PropertyBuilder {
|
|
466
528
|
#props;
|
|
@@ -527,6 +589,7 @@ function serializeInstance(propRegistry, groupRegistry, globalStyles) {
|
|
|
527
589
|
transforms[name] = fn;
|
|
528
590
|
}
|
|
529
591
|
}
|
|
592
|
+
if (entry.currentVar) s.currentVar = entry.currentVar;
|
|
530
593
|
serialized[propName] = s;
|
|
531
594
|
}
|
|
532
595
|
const result = {
|
|
@@ -797,46 +860,44 @@ function validateColors(colors) {
|
|
|
797
860
|
for (const [key, value] of Object.entries(colors)) if (isObject(value)) validateColors(value);
|
|
798
861
|
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.`);
|
|
799
862
|
}
|
|
800
|
-
var ThemeBuilder = class {
|
|
863
|
+
var ThemeBuilder = class ThemeBuilder {
|
|
801
864
|
#theme = {};
|
|
865
|
+
#emittedScales = /* @__PURE__ */ new Set();
|
|
866
|
+
#contextualVars = /* @__PURE__ */ new Map();
|
|
802
867
|
constructor(baseTheme) {
|
|
868
|
+
if (baseTheme.breakpoints) {
|
|
869
|
+
for (const [key, value] of Object.entries(baseTheme.breakpoints)) if (typeof value !== "number" || value < 0) throw new Error(`createTheme: breakpoint '${key}' must be a non-negative number, got ${JSON.stringify(value)}`);
|
|
870
|
+
}
|
|
803
871
|
this.#theme = baseTheme;
|
|
804
872
|
}
|
|
805
|
-
/**
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
const { variables, tokens } = serializeTokens(this.#theme[key], key, this.#theme);
|
|
812
|
-
this.#theme = merge({}, this.#theme, {
|
|
813
|
-
[key]: tokens,
|
|
814
|
-
_variables: { [key]: variables },
|
|
815
|
-
_tokens: { [key]: this.#theme[key] }
|
|
816
|
-
});
|
|
817
|
-
return this;
|
|
873
|
+
/** Create a new builder checkpoint, carrying forward emittedScales and contextualVars state. */
|
|
874
|
+
#checkpoint(nextTheme) {
|
|
875
|
+
const next = new ThemeBuilder(nextTheme);
|
|
876
|
+
for (const s of this.#emittedScales) next.#emittedScales.add(s);
|
|
877
|
+
for (const [scale, vars] of this.#contextualVars) next.#contextualVars.set(scale, [...vars]);
|
|
878
|
+
return next;
|
|
818
879
|
}
|
|
819
880
|
/**
|
|
820
|
-
*
|
|
821
|
-
* @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
|
|
881
|
+
* @param colors A map of color tokens. Immediately converted to CSS variables `--color-${key}`.
|
|
822
882
|
* @example .addColors({ navy: 'navy', hyper: 'purple' })
|
|
823
883
|
*/
|
|
824
884
|
addColors(colors) {
|
|
825
885
|
validateColors(colors);
|
|
826
886
|
const flatColors = flattenScale(colors);
|
|
827
887
|
const { variables, tokens } = serializeTokens(flatColors, "color", this.#theme);
|
|
828
|
-
|
|
888
|
+
const nextTheme = merge({}, this.#theme, {
|
|
829
889
|
colors: tokens,
|
|
830
890
|
_variables: { root: variables },
|
|
831
891
|
_tokens: { colors: flatColors }
|
|
832
892
|
});
|
|
833
|
-
|
|
893
|
+
const next = this.#checkpoint(nextTheme);
|
|
894
|
+
next.#emittedScales.add("colors");
|
|
895
|
+
return next;
|
|
834
896
|
}
|
|
835
897
|
/**
|
|
836
|
-
*
|
|
837
|
-
* @param
|
|
838
|
-
* @
|
|
839
|
-
* @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
|
|
898
|
+
* @param initialMode Default color mode key.
|
|
899
|
+
* @param modeConfig Map of color modes with semantic aliases pointing to palette keys.
|
|
900
|
+
* @example .addColorModes('dark', { dark: { primary: 'ember' }, light: { primary: 'void' } })
|
|
840
901
|
*/
|
|
841
902
|
addColorModes(initialMode, modeConfig) {
|
|
842
903
|
const availableColors = this.#theme._tokens?.colors ? Object.keys(this.#theme._tokens.colors) : Object.keys(this.#theme.colors || {});
|
|
@@ -845,7 +906,7 @@ var ThemeBuilder = class {
|
|
|
845
906
|
const modes = mapValues(modeConfig, (mode) => flattenScale(mode));
|
|
846
907
|
const { tokens: colors, variables } = serializeTokens(mapValues(merge({}, this.#theme.modes?.[initialMode], modes[initialMode]), (color) => this.#theme.colors[color]), "color", this.#theme);
|
|
847
908
|
const getColorValue = (color) => this.#theme._tokens?.colors?.[color];
|
|
848
|
-
|
|
909
|
+
const nextTheme = merge({}, this.#theme, {
|
|
849
910
|
colors,
|
|
850
911
|
modes,
|
|
851
912
|
mode: initialMode,
|
|
@@ -853,40 +914,77 @@ var ThemeBuilder = class {
|
|
|
853
914
|
_variables: { mode: variables },
|
|
854
915
|
_tokens: { modes: mapValues(modes, (mode) => mapValues(mode, getColorValue)) }
|
|
855
916
|
});
|
|
856
|
-
return this;
|
|
917
|
+
return this.#checkpoint(nextTheme);
|
|
857
918
|
}
|
|
858
919
|
/**
|
|
920
|
+
* Add a named scale to the theme.
|
|
921
|
+
*
|
|
922
|
+
* @param config.name - Scale name (e.g. 'space', 'sizes')
|
|
923
|
+
* @param config.values - Scale value map
|
|
924
|
+
* @param config.emit - When true, generates CSS variables (default: false)
|
|
859
925
|
*
|
|
860
|
-
* @
|
|
861
|
-
*
|
|
862
|
-
*
|
|
926
|
+
* @example
|
|
927
|
+
* .addScale({ name: 'space', values: { 0: '0', 8: '0.5rem', 16: '1rem' } })
|
|
928
|
+
* .addScale({ name: 'sizes', emit: true, values: { navHeight: '48px' } })
|
|
863
929
|
*/
|
|
864
|
-
addScale(
|
|
865
|
-
|
|
866
|
-
|
|
930
|
+
addScale(config) {
|
|
931
|
+
const { name, values, emit } = config;
|
|
932
|
+
const flattened = flattenScale(values);
|
|
933
|
+
let nextTheme;
|
|
934
|
+
if (emit) {
|
|
935
|
+
const { variables, tokens } = serializeTokens(flattened, name, this.#theme);
|
|
936
|
+
nextTheme = merge({}, this.#theme, {
|
|
937
|
+
[name]: tokens,
|
|
938
|
+
_variables: { [name]: variables },
|
|
939
|
+
_tokens: { [name]: flattened }
|
|
940
|
+
});
|
|
941
|
+
} else nextTheme = merge({}, this.#theme, { [name]: flattened });
|
|
942
|
+
const next = this.#checkpoint(nextTheme);
|
|
943
|
+
if (emit) next.#emittedScales.add(name);
|
|
944
|
+
return next;
|
|
867
945
|
}
|
|
868
946
|
/**
|
|
947
|
+
* Declare contextual CSS variables as phantom members of their scales.
|
|
948
|
+
* These names appear in the scale's type but resolve to CSS custom properties
|
|
949
|
+
* (`--{name}`) instead of token values. They cascade through the DOM like `currentColor`.
|
|
950
|
+
*
|
|
951
|
+
* @param vars - Object mapping scale names to arrays of contextual var names.
|
|
869
952
|
*
|
|
870
|
-
* @
|
|
871
|
-
*
|
|
872
|
-
*
|
|
953
|
+
* @example
|
|
954
|
+
* .addContextualVars({
|
|
955
|
+
* colors: ['current-bg', 'current-border-color'],
|
|
956
|
+
* })
|
|
873
957
|
*/
|
|
874
|
-
|
|
875
|
-
this.#theme
|
|
876
|
-
|
|
958
|
+
addContextualVars(vars) {
|
|
959
|
+
for (const scale of Object.keys(vars)) if (!(scale in this.#theme)) throw new Error(`addContextualVars: scale '${scale}' not found — call addColors or addScale first`);
|
|
960
|
+
const next = this.#checkpoint(this.#theme);
|
|
961
|
+
for (const [scale, names] of Object.entries(vars)) {
|
|
962
|
+
const existing = next.#contextualVars.get(scale) || [];
|
|
963
|
+
next.#contextualVars.set(scale, [...existing, ...names]);
|
|
964
|
+
}
|
|
965
|
+
return next;
|
|
877
966
|
}
|
|
878
967
|
/**
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
* The returned theme object also has a non-enumerable `.manifest` property containing
|
|
883
|
-
* a structured ThemeManifest for plugin consumption.
|
|
968
|
+
* @param key A current key of theme to update with computed values.
|
|
969
|
+
* @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `${basic}, Montserrat` }))
|
|
884
970
|
*/
|
|
971
|
+
updateScale(key, updateFn) {
|
|
972
|
+
const nextTheme = merge({}, this.#theme, { [key]: updateFn(this.#theme[key]) });
|
|
973
|
+
return this.#checkpoint(nextTheme);
|
|
974
|
+
}
|
|
975
|
+
/** Finalize the theme build. Returns the theme with a non-enumerable `.manifest` property. */
|
|
885
976
|
build() {
|
|
977
|
+
resolveThemeTokenRefs(this.#theme, this.#emittedScales);
|
|
886
978
|
const { variables } = serializeTokens(mapValues(this.#theme.breakpoints, (val) => `${val}px`), "breakpoint", this.#theme);
|
|
979
|
+
let contextualVarsSerialized;
|
|
980
|
+
if (this.#contextualVars.size > 0) {
|
|
981
|
+
contextualVarsSerialized = {};
|
|
982
|
+
for (const [scale, vars] of this.#contextualVars) contextualVarsSerialized[scale] = vars;
|
|
983
|
+
}
|
|
887
984
|
const theme = merge({}, this.#theme, {
|
|
888
985
|
_variables: { breakpoints: variables },
|
|
889
|
-
_tokens: {}
|
|
986
|
+
_tokens: {},
|
|
987
|
+
...contextualVarsSerialized ? { _contextualVars: contextualVarsSerialized } : {}
|
|
890
988
|
});
|
|
891
989
|
const manifest = assembleManifest(theme);
|
|
892
990
|
Object.defineProperty(theme, "manifest", {
|
|
@@ -901,6 +999,54 @@ var ThemeBuilder = class {
|
|
|
901
999
|
function createTheme(base) {
|
|
902
1000
|
return new ThemeBuilder(base);
|
|
903
1001
|
}
|
|
1002
|
+
/** Token ref pattern: {scale.key} */
|
|
1003
|
+
const TOKEN_REF_RE = /\{([^}]+)\}/g;
|
|
1004
|
+
/**
|
|
1005
|
+
* Resolve token refs ({scale.key}) in all scale values.
|
|
1006
|
+
* Only refs to emitted scales (those with CSS variables) are valid.
|
|
1007
|
+
* Runs once at build() time after all scales have been collected.
|
|
1008
|
+
*/
|
|
1009
|
+
function resolveThemeTokenRefs(theme, emittedScales) {
|
|
1010
|
+
for (const [scaleName, scaleValue] of Object.entries(theme)) {
|
|
1011
|
+
if (scaleName.startsWith("_")) continue;
|
|
1012
|
+
if (scaleName === "breakpoints" || scaleName === "mode" || scaleName === "modes") continue;
|
|
1013
|
+
if (typeof scaleValue === "function") continue;
|
|
1014
|
+
if (!isObject(scaleValue)) continue;
|
|
1015
|
+
for (const [key, value] of Object.entries(scaleValue)) {
|
|
1016
|
+
if (typeof value !== "string") continue;
|
|
1017
|
+
if (!value.includes("{")) continue;
|
|
1018
|
+
const resolved = value.replace(TOKEN_REF_RE, (match, ref) => {
|
|
1019
|
+
const dotIdx = ref.indexOf(".");
|
|
1020
|
+
if (dotIdx === -1) return match;
|
|
1021
|
+
const refScale = ref.slice(0, dotIdx);
|
|
1022
|
+
const refKey = ref.slice(dotIdx + 1);
|
|
1023
|
+
if (refScale === scaleName) {
|
|
1024
|
+
console.warn(`[animus] Self-referential token ref {${ref}} in scale '${scaleName}' — skipped`);
|
|
1025
|
+
return match;
|
|
1026
|
+
}
|
|
1027
|
+
const targetScale = theme[refScale];
|
|
1028
|
+
if (!targetScale || !isObject(targetScale)) {
|
|
1029
|
+
console.warn(`[animus] Token ref {${ref}} references unknown scale '${refScale}'`);
|
|
1030
|
+
return match;
|
|
1031
|
+
}
|
|
1032
|
+
const resolvedValue = targetScale[refKey];
|
|
1033
|
+
if (resolvedValue === void 0) {
|
|
1034
|
+
console.warn(`[animus] Token ref {${ref}} — key '${refKey}' not found in scale '${refScale}'`);
|
|
1035
|
+
return match;
|
|
1036
|
+
}
|
|
1037
|
+
return String(resolvedValue);
|
|
1038
|
+
});
|
|
1039
|
+
if (resolved !== value) {
|
|
1040
|
+
scaleValue[key] = resolved;
|
|
1041
|
+
if (theme._tokens?.[scaleName]) theme._tokens[scaleName][key] = resolved;
|
|
1042
|
+
if (theme._variables?.[scaleName]) {
|
|
1043
|
+
const varName = `--${scaleName}-${key.replace("$", "")}`;
|
|
1044
|
+
if (theme._variables[scaleName][varName] !== void 0) theme._variables[scaleName][varName] = resolved;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
904
1050
|
/**
|
|
905
1051
|
* Assemble a ThemeManifest from the built theme object.
|
|
906
1052
|
*
|
|
@@ -927,7 +1073,8 @@ function assembleManifest(theme) {
|
|
|
927
1073
|
tokenMap,
|
|
928
1074
|
variableMap,
|
|
929
1075
|
modes,
|
|
930
|
-
variableCss: buildManifestVariableCss(theme)
|
|
1076
|
+
variableCss: buildManifestVariableCss(theme),
|
|
1077
|
+
contextualVars: theme._contextualVars && typeof theme._contextualVars === "object" && Object.keys(theme._contextualVars).length > 0 ? theme._contextualVars : void 0
|
|
931
1078
|
};
|
|
932
1079
|
}
|
|
933
1080
|
/** Flatten a scale into tokenMap and extract variable references into variableMap. */
|
|
@@ -979,4 +1126,4 @@ function flattenModeTokensCss(lines, obj, prefix) {
|
|
|
979
1126
|
}
|
|
980
1127
|
}
|
|
981
1128
|
//#endregion
|
|
982
|
-
export { Animus, AnimusExtended, AnimusExtendedWithAll, AnimusWithAll, PropertyBuilder, SystemBuilder, ThemeBuilder, borderShorthand, createClassResolver, createComponent, createScale, createSystem, createTheme, createTransform, flattenScale, gridItem, gridItemRatio, numericOrStringScale, numericScale, percentageOrAbsolute, serializeTokens, size, stringScale };
|
|
1129
|
+
export { Animus, AnimusExtended, AnimusExtendedWithAll, AnimusWithAll, PropertyBuilder, SystemBuilder, ThemeBuilder, borderShorthand, compose, createClassResolver, createComponent, createScale, createSystem, createTheme, createTransform, flattenScale, gridItem, gridItemRatio, numericOrStringScale, numericScale, percentageOrAbsolute, serializeTokens, size, stringScale };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,UAAU,EAAU,MAAM,OAAO,CAAC;AAE1D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,UAAU,eAAgB,SAAQ,mBAAmB;CAAG;AAIxD,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;AAEF;;;;;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,UAAU,EAAU,MAAM,OAAO,CAAC;AAE1D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEtB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,UAAU,eAAgB,SAAQ,mBAAmB;CAAG;AAIxD,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;AAEF;;;;;;;;;;;;;;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,CAoFjB"}
|
|
@@ -2,61 +2,77 @@ 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';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Validate token refs in scale values at the type level.
|
|
7
|
+
* Accepts `{scale.key}` for any emitted scale, plus `{colors.key/${number}}` opacity syntax.
|
|
8
|
+
*/
|
|
9
|
+
type ValidateScaleRef<V, ValidPaths extends string> = V extends string ? V extends `${string}{${infer Path}}${string}` ? Path extends ValidPaths ? V : Path extends `${infer Base}/${number}` ? Base extends ValidPaths & `colors.${string}` ? V : `{${Path}} is not a valid token ref` : `{${Path}} is not a valid token ref` : V : V;
|
|
10
|
+
/** Walk a values record and validate each value's token refs. */
|
|
11
|
+
type ValidateScaleValues<V extends Record<string | number, unknown>, ValidPaths extends string> = {
|
|
12
|
+
[K in keyof V]: V[K] extends Record<string, unknown> ? ValidateScaleValues<V[K], ValidPaths> : ValidateScaleRef<V[K], ValidPaths>;
|
|
13
|
+
};
|
|
14
|
+
export declare class ThemeBuilder<T extends AbstractTheme, Emitted extends string = never> {
|
|
6
15
|
#private;
|
|
7
16
|
constructor(baseTheme: T);
|
|
8
17
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param key A key of the current theme to transform into CSS Variables and Variable References
|
|
11
|
-
* @example .createScaleVariables('fontSize')
|
|
12
|
-
*/
|
|
13
|
-
createScaleVariables<Key extends keyof Omit<T, 'breakpoints'> & string>(key: Key): ThemeBuilder<MergeTheme<T, PrivateThemeKeys, Record<Key, Record<Key, KeyAsVariable<T[Key], Key>>>>>;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param colors A map of color tokens to add to the theme. These tokens are immediately converted to CSS Variables `--color-${key}`.
|
|
18
|
+
* @param colors A map of color tokens. Immediately converted to CSS variables `--color-${key}`.
|
|
17
19
|
* @example .addColors({ navy: 'navy', hyper: 'purple' })
|
|
18
20
|
*/
|
|
19
|
-
addColors<Colors extends Record<string, CSSColorValue | Record<string, CSSColorValue>>, NextColors extends LiteralPaths<Colors, '-'>>(colors: Colors): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, Record<
|
|
21
|
+
addColors<Colors extends Record<string, CSSColorValue | Record<string, CSSColorValue>>, NextColors extends LiteralPaths<Colors, '-'>>(colors: Colors): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, Record<"colors", KeyAsVariable<NextColors, "color">>>, "colors" | Emitted>;
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
24
|
-
* @example .addColorModes('light', { light: { primary: 'hyper' }, { dark: { primary: 'navy' } } })
|
|
23
|
+
* @param initialMode Default color mode key.
|
|
24
|
+
* @param modeConfig Map of color modes with semantic aliases pointing to palette keys.
|
|
25
|
+
* @example .addColorModes('dark', { dark: { primary: 'ember' }, light: { primary: 'void' } })
|
|
25
26
|
*/
|
|
26
27
|
addColorModes<Modes extends string, InitialMode extends keyof Config, Colors extends keyof T['colors'], ModeColors extends ColorModeConfig<Colors>, Config extends Record<Modes, ModeColors>, ColorAliases extends {
|
|
27
28
|
[K in keyof Config]: LiteralPaths<Config[K], '-', '_'>;
|
|
28
29
|
}>(initialMode: InitialMode, modeConfig: Config): ThemeBuilder<MergeTheme<T & PrivateThemeKeys, {
|
|
29
|
-
colors: KeyAsVariable<LiteralPaths<Config[keyof Config],
|
|
30
|
-
modes: Merge<T[
|
|
30
|
+
colors: KeyAsVariable<LiteralPaths<Config[keyof Config], "-", "_">, "colors"> & T["colors"];
|
|
31
|
+
modes: Merge<T["modes"], ColorAliases>;
|
|
31
32
|
mode: keyof Config;
|
|
32
|
-
_getColorValue: (color: keyof T[
|
|
33
|
-
}
|
|
33
|
+
_getColorValue: (color: keyof T["colors"]) => string;
|
|
34
|
+
}>, Emitted>;
|
|
34
35
|
/**
|
|
36
|
+
* Add a named scale to the theme.
|
|
37
|
+
*
|
|
38
|
+
* @param config.name - Scale name (e.g. 'space', 'sizes')
|
|
39
|
+
* @param config.values - Scale value map
|
|
40
|
+
* @param config.emit - When true, generates CSS variables (default: false)
|
|
35
41
|
*
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
38
|
-
*
|
|
42
|
+
* @example
|
|
43
|
+
* .addScale({ name: 'space', values: { 0: '0', 8: '0.5rem', 16: '1rem' } })
|
|
44
|
+
* .addScale({ name: 'sizes', emit: true, values: { navHeight: '48px' } })
|
|
39
45
|
*/
|
|
40
|
-
addScale<Key extends string,
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
addScale<Key extends string, const Values extends Record<string | number, string | number | Record<string, string | number>>, Emit extends boolean = false, NewScale extends LiteralPaths<Values, '-'> = LiteralPaths<Values, '-'>, ValidPaths extends string = keyof LiteralPaths<Pick<T, Extract<Emitted | 'colors', keyof T>>, '.'> & string>(config: {
|
|
47
|
+
name: Key;
|
|
48
|
+
values: Values & ValidateScaleValues<Values, ValidPaths>;
|
|
49
|
+
emit?: Emit;
|
|
50
|
+
}): ThemeBuilder<{ [K in keyof MergeTheme<T, Record<Key, Emit extends true ? KeyAsVariable<NewScale, Key> : NewScale>>]: MergeTheme<T, Record<Key, Emit extends true ? KeyAsVariable<NewScale, Key> : NewScale>>[K]; }, Emit extends true ? Emitted | Key : Emitted>;
|
|
43
51
|
/**
|
|
52
|
+
* Declare contextual CSS variables as phantom members of their scales.
|
|
53
|
+
* These names appear in the scale's type but resolve to CSS custom properties
|
|
54
|
+
* (`--{name}`) instead of token values. They cascade through the DOM like `currentColor`.
|
|
44
55
|
*
|
|
45
|
-
* @param
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
56
|
+
* @param vars - Object mapping scale names to arrays of contextual var names.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* .addContextualVars({
|
|
60
|
+
* colors: ['current-bg', 'current-border-color'],
|
|
61
|
+
* })
|
|
48
62
|
*/
|
|
49
|
-
|
|
63
|
+
addContextualVars<const Vars extends Partial<{
|
|
64
|
+
[K in keyof T & string]: readonly string[];
|
|
65
|
+
}>>(vars: Vars): ThemeBuilder<{ [K in keyof T]: K extends keyof Vars ? Vars[K] extends readonly string[] ? T[K] & Record<Vars[K][number], `var(--${string})`> : T[K] : T[K]; }, Emitted>;
|
|
50
66
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* The returned theme object also has a non-enumerable `.manifest` property containing
|
|
55
|
-
* a structured ThemeManifest for plugin consumption.
|
|
67
|
+
* @param key A current key of theme to update with computed values.
|
|
68
|
+
* @example .updateScale('fonts', ({ basic }) => ({ basicFallback: `${basic}, Montserrat` }))
|
|
56
69
|
*/
|
|
70
|
+
updateScale<Key extends keyof T, Fn extends (tokens: T[Key]) => Record<string | number, unknown>>(key: Key, updateFn: Fn): ThemeBuilder<T & Record<Key, T[Key] & ReturnType<Fn>>, Emitted>;
|
|
71
|
+
/** Finalize the theme build. Returns the theme with a non-enumerable `.manifest` property. */
|
|
57
72
|
build(): {
|
|
58
73
|
[K in keyof (T & PrivateThemeKeys)]: (T & PrivateThemeKeys)[K];
|
|
59
74
|
};
|
|
60
75
|
}
|
|
61
|
-
export declare function createTheme<T extends AbstractTheme>(base: T): ThemeBuilder<T>;
|
|
76
|
+
export declare function createTheme<T extends AbstractTheme>(base: T): ThemeBuilder<T, never>;
|
|
77
|
+
export {};
|
|
62
78
|
//# sourceMappingURL=createTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,E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C,EAC7C,GAAG,CACJ,GACC,MAAM,EACR,MAAM,EAAE;QACR,IAAI,EAAE,GAAG,CAAC;QACV,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,EAAE,IAAI,CAAC;KACb,mBA4BgB,CAAC;IAQlB;;;;;;;;;;;OAWG;IACH,iBAAiB,CACf,KAAK,CAAC,IAAI,SAAS,OAAO,CAAC;SACxB,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE;KAC3C,CAAC,EACF,IAAI,EAAE,IAAI,mBAaP,CAAC;IAkBN;;;OAGG;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,EAC/D,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE;IAUxB,8FAA8F;IAC9F,KAAK,IAAI;SAAG,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;KAAE;CAsC5E;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,CAAC,0BAE3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSObject } from '../types/theme';
|
|
2
2
|
/**
|
|
3
3
|
* Returns an type of any object with { key: 'var(--key) }
|
|
4
4
|
*/
|
|
@@ -6,7 +6,7 @@ export type KeyAsVariable<T extends Record<string, any>, Prefix extends string>
|
|
|
6
6
|
[V in keyof T]: `var(--${Prefix}-${SanitizeKey<Extract<V, string>>})`;
|
|
7
7
|
};
|
|
8
8
|
export type SanitizeKey<T extends string> = T extends `${'$'}${infer Y}` ? Y : T;
|
|
9
|
-
type ThemeWithBreakpoints =
|
|
9
|
+
type ThemeWithBreakpoints = {
|
|
10
10
|
breakpoints: Record<string, string | number>;
|
|
11
11
|
};
|
|
12
12
|
type SerializedTokensInput = Record<string, string | number | CSSObject | SerializedTokensInputRecursive>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeTokens.d.ts","sourceRoot":"","sources":["../../src/theme/serializeTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"serializeTokens.d.ts","sourceRoot":"","sources":["../../src/theme/serializeTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,MAAM,MAAM,aAAa,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,MAAM,SAAS,MAAM,IACnB;KACD,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG;CACtE,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,GACpE,CAAC,GACD,CAAC,CAAC;AAEN,KAAK,oBAAoB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;CAAE,CAAC;AA6B7E,KAAK,qBAAqB,GAAG,MAAM,CACjC,MAAM,EACN,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,8BAA8B,CAC7D,CAAC;AAEF,UAAU,8BAA8B;IACtC,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;IACnC,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACpC;AAED,eAAO,MAAM,eAAe,GAC1B,CAAC,SAAS,qBAAqB,EAC/B,MAAM,SAAS,MAAM,EAErB,QAAQ,CAAC,EACT,QAAQ,MAAM,EACd,OAAO,oBAAoB,GAAG,SAAS,KACtC;IACD,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;CAgBtB,CAAC"}
|
|
@@ -40,8 +40,18 @@ type VariantProps<V> = string extends keyof V ? {} : {
|
|
|
40
40
|
type StateProps<S> = string extends keyof S ? {} : {
|
|
41
41
|
[K in keyof S]?: boolean;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Union of all prop keys that Animus manages. These override HTML attributes
|
|
45
|
+
* of the same name — the type-level equivalent of shouldForwardProp / isPropValid.
|
|
46
|
+
* The runtime (filterProps in createComponent) already strips these before
|
|
47
|
+
* forwarding to the DOM element; this ensures the types match.
|
|
48
|
+
*
|
|
49
|
+
* Computed from each source individually (not keyof an intersection) to
|
|
50
|
+
* avoid TS2590 "union type too complex" during declaration emit.
|
|
51
|
+
*/
|
|
52
|
+
type AnimusManagedKeys<PR extends Record<string, Prop>, GR extends Record<string, (keyof PR)[]>, V, S, AG, CP extends Record<string, Prop>> = ActiveGroupPropNames<PR, GR, AG> | keyof VariantProps<V> | keyof StateProps<S> | keyof CP | 'as' | 'className' | 'children';
|
|
43
53
|
/** Component type for .asElement() — HTML element tag with full Animus props. */
|
|
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
|
|
54
|
+
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<Omit<ComponentPropsWithRef<El>, AnimusManagedKeys<PR, GR, V, S, AG, CP>> & GroupProps<PR, GR, AG> & VariantProps<V> & StateProps<S> & CustomPropValues<CP> & {
|
|
45
55
|
as?: keyof JSX.IntrinsicElements | ComponentType<{
|
|
46
56
|
className?: string;
|
|
47
57
|
}>;
|
|
@@ -56,5 +66,96 @@ export type AnimusWrappedComponent<PR extends Record<string, Prop>, GR extends R
|
|
|
56
66
|
className?: string;
|
|
57
67
|
children?: ReactNode;
|
|
58
68
|
}> & ExtendFn<PR, GR, BS, V, S, AG, CP>;
|
|
69
|
+
/**
|
|
70
|
+
* Strip string index signatures from a type, keeping only
|
|
71
|
+
* explicitly-declared keys. Needed because ExtendFn widens V
|
|
72
|
+
* with `& Record<string, VariantConfig>`.
|
|
73
|
+
*/
|
|
74
|
+
type StripStringIndex<T> = {
|
|
75
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Extract the raw variant config (V generic) from an AnimusComponent.
|
|
79
|
+
* Routes through extend()'s return type → .variants field, then
|
|
80
|
+
* strips the string index signature added by ExtendFn's intersection.
|
|
81
|
+
*/
|
|
82
|
+
export type ExtractVariantsConfig<C> = C extends {
|
|
83
|
+
extend: () => {
|
|
84
|
+
variants: infer V;
|
|
85
|
+
};
|
|
86
|
+
} ? StripStringIndex<V> : {};
|
|
87
|
+
/**
|
|
88
|
+
* Extract consumer-facing variant props from an AnimusComponent.
|
|
89
|
+
* Returns { size?: 'sm' | 'lg', variant?: 'fill' | 'ghost', ... }
|
|
90
|
+
*/
|
|
91
|
+
export type VariantPropsOf<C> = VariantProps<ExtractVariantsConfig<C>>;
|
|
92
|
+
/**
|
|
93
|
+
* Union of all variant prop keys across all slots.
|
|
94
|
+
*/
|
|
95
|
+
type AllVariantKeys<Slots extends Record<string, unknown>> = keyof VariantPropsOf<Slots[keyof Slots]>;
|
|
96
|
+
/**
|
|
97
|
+
* Extract the Root slot component from a Slots record.
|
|
98
|
+
* Convention: the key 'root' or 'Root' (case-insensitive match).
|
|
99
|
+
*/
|
|
100
|
+
type RootSlot<Slots extends Record<string, unknown>> = {
|
|
101
|
+
[K in keyof Slots]: Lowercase<K & string> extends 'root' ? Slots[K] : never;
|
|
102
|
+
}[keyof Slots];
|
|
103
|
+
/**
|
|
104
|
+
* Variant keys that exist on the Root slot.
|
|
105
|
+
* Only Root variant keys are valid as shared keys — Root is the
|
|
106
|
+
* provider and must accept the prop to pass it through context.
|
|
107
|
+
*/
|
|
108
|
+
type RootVariantKeys<Slots extends Record<string, unknown>> = keyof VariantPropsOf<RootSlot<Slots>> & string;
|
|
109
|
+
/**
|
|
110
|
+
* Configuration object for shared variant propagation.
|
|
111
|
+
* Keys are variant names from Root. Value is `true` to share.
|
|
112
|
+
* Non-Root slots that have matching variant keys receive the
|
|
113
|
+
* value from context. Slots without the key are unaffected.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* compose(slots, { shared: { density: true, intent: true } })
|
|
117
|
+
*/
|
|
118
|
+
export type SharedConfig<Slots extends Record<string, unknown>> = {
|
|
119
|
+
[K in RootVariantKeys<Slots>]?: true;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated Use SharedConfig instead. SharedVariantKeys required
|
|
123
|
+
* every shared key to exist on ALL slots. SharedConfig only requires
|
|
124
|
+
* the key to exist on Root.
|
|
125
|
+
*/
|
|
126
|
+
export type SharedVariantKeys<Slots extends Record<string, unknown>> = {
|
|
127
|
+
[K in AllVariantKeys<Slots> & string]: keyof Slots extends infer S ? S extends keyof Slots ? K extends keyof VariantPropsOf<Slots[S]> ? true : false : never : never extends false ? never : K;
|
|
128
|
+
}[AllVariantKeys<Slots> & string];
|
|
129
|
+
/**
|
|
130
|
+
* Extract the component props from a ForwardRefExoticComponent,
|
|
131
|
+
* including AnimusComponent (which extends it).
|
|
132
|
+
*/
|
|
133
|
+
type PropsOf<C> = C extends ForwardRefExoticComponent<infer P> ? P : never;
|
|
134
|
+
/**
|
|
135
|
+
* Sealed child slot — accepts source component's own props.
|
|
136
|
+
* Shared variant values come from context as defaults;
|
|
137
|
+
* direct props override context. Slots that don't have a
|
|
138
|
+
* shared variant key simply ignore it.
|
|
139
|
+
*/
|
|
140
|
+
export type ComposedSlot<C> = ForwardRefExoticComponent<Omit<PropsOf<C>, 'extend'> & {
|
|
141
|
+
className?: string;
|
|
142
|
+
children?: ReactNode;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* Sealed Root slot — KEEPS shared variant props (it's the provider).
|
|
146
|
+
* Also accepts children for the Provider wrapper.
|
|
147
|
+
*/
|
|
148
|
+
export type ComposedRoot<C> = ForwardRefExoticComponent<Omit<PropsOf<C>, 'extend'> & {
|
|
149
|
+
className?: string;
|
|
150
|
+
children?: ReactNode;
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* The output of compose() — a record of capitalized slot names mapped
|
|
154
|
+
* to sealed React components. Root gets ComposedRoot (keeps shared props),
|
|
155
|
+
* all other slots get ComposedSlot (own props, context defaults).
|
|
156
|
+
*/
|
|
157
|
+
export type ComposedFamily<Slots extends Record<string, unknown>> = {
|
|
158
|
+
[K in keyof Slots as Capitalize<K & string>]: Lowercase<K & string> extends 'root' ? ComposedRoot<Slots[K]> : ComposedSlot<Slots[K]>;
|
|
159
|
+
};
|
|
59
160
|
export {};
|
|
60
161
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,yBAAyB,EACzB,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,KAAK,QAAQ,CACX,EAA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AY,CAAC,CAAC,IAAI,yBAAyB,CACrD,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;KACjE,CAAC,IAAI,MAAM,KAAK,IAAI,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,SAAS,CACrD,CAAC,GAAG,MAAM,CACX,SAAS,MAAM,GACZ,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GACtB,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC3B,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export interface Prop extends BaseProperty {
|
|
|
12
12
|
scale?: string | MapScale | ArrayScale;
|
|
13
13
|
variable?: string;
|
|
14
14
|
negative?: boolean;
|
|
15
|
+
/** When false, scale-bound props accept arbitrary strings alongside scale keys via (string & {}). Default: true (strict). */
|
|
16
|
+
strict?: boolean;
|
|
17
|
+
currentVar?: string;
|
|
15
18
|
transform?: (val: string | number, prop?: string, props?: AbstractProps) => string | number | CSSObject;
|
|
16
19
|
}
|
|
17
20
|
export interface AbstractParser {
|
|
@@ -20,6 +23,12 @@ export interface AbstractParser {
|
|
|
20
23
|
config: Record<string, Prop>;
|
|
21
24
|
}
|
|
22
25
|
type IsEmpty<T> = [] extends T ? true : false | {} extends T ? true : false;
|
|
26
|
+
/**
|
|
27
|
+
* When `strict: false`, always include globals ((string & {}) | 0) for typeahead
|
|
28
|
+
* with escape hatch, regardless of whether the scale has values.
|
|
29
|
+
* When strict is omitted or true, fall back to IsEmpty (current behavior).
|
|
30
|
+
*/
|
|
31
|
+
type StrictOrEmpty<Config extends Prop, Scale> = Config['strict'] extends false ? true : IsEmpty<Scale>;
|
|
23
32
|
/**
|
|
24
33
|
* Negate numeric literal types.
|
|
25
34
|
* `NegateKeys<4 | 8 | 16>` → `-4 | -8 | -16`
|
|
@@ -37,7 +46,7 @@ export type PropertyValues<Property extends Prop, IncludeGlobals = false> = Excl
|
|
|
37
46
|
* 4. Otherwise → raw CSS property values
|
|
38
47
|
*/
|
|
39
48
|
type NegativeOf<Config extends Prop, Keys> = Config['negative'] extends true ? NegateKeys<Extract<Keys, number>> : never;
|
|
40
|
-
export type ScaleValue<Config extends Prop, T extends BaseTheme> = Config['scale'] extends keyof TokenScales<T> ? keyof TokenScales<T>[Config['scale']] | NegativeOf<Config, keyof TokenScales<T>[Config['scale']]> | PropertyValues<Config,
|
|
49
|
+
export type ScaleValue<Config extends Prop, T extends BaseTheme> = Config['scale'] extends keyof TokenScales<T> ? keyof TokenScales<T>[Config['scale']] | NegativeOf<Config, keyof TokenScales<T>[Config['scale']]> | PropertyValues<Config, StrictOrEmpty<Config, TokenScales<T>[Config['scale']]>> : Config['scale'] extends MapScale ? keyof Config['scale'] | NegativeOf<Config, keyof Config['scale']> | PropertyValues<Config, StrictOrEmpty<Config, Config['scale']>> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<Config, StrictOrEmpty<Config, Config['scale']>> : PropertyValues<Config, true>;
|
|
41
50
|
export type Scale<Config extends Prop, T extends BaseTheme> = ResponsiveProp<ScaleValue<Config, T>>;
|
|
42
51
|
export type ParserProps<Config extends Record<string, Prop>, T extends BaseTheme> = ThemeProps<{
|
|
43
52
|
[P in keyof Config]?: Scale<Config[P], T>;
|
|
@@ -55,7 +64,9 @@ export type SystemProps<P extends AbstractParser, SafeProps = Omit<Arg<P>, 'them
|
|
|
55
64
|
* instead of a generic T. This enables type-safe CSS object constraints
|
|
56
65
|
* without threading T through the entire class hierarchy.
|
|
57
66
|
*/
|
|
58
|
-
|
|
67
|
+
/** Colors-only: accept `{colors.key/number}` opacity syntax in component styles. */
|
|
68
|
+
type ColorOpacityRef<Config extends Prop> = Config['scale'] extends 'colors' ? 'colors' extends keyof TokenScales<Theme> ? `{colors.${keyof TokenScales<Theme>[Config['scale'] & keyof TokenScales<Theme>] & string}/${number}}` : never : never;
|
|
69
|
+
export type ThemedScaleValue<Config extends Prop> = Config['scale'] extends keyof TokenScales<Theme> ? keyof TokenScales<Theme>[Config['scale']] | NegativeOf<Config, keyof TokenScales<Theme>[Config['scale']]> | PropertyValues<Config, StrictOrEmpty<Config, TokenScales<Theme>[Config['scale']]>> | ColorOpacityRef<Config> : Config['scale'] extends MapScale ? keyof Config['scale'] | NegativeOf<Config, keyof Config['scale']> | PropertyValues<Config, StrictOrEmpty<Config, Config['scale']>> : Config['scale'] extends ArrayScale ? Config['scale'][number] | PropertyValues<Config, StrictOrEmpty<Config, Config['scale']>> : PropertyValues<Config, true>;
|
|
59
70
|
export type ThemedScale<Config extends Prop> = ResponsiveProp<ThemedScaleValue<Config>>;
|
|
60
71
|
/**
|
|
61
72
|
* Theme-aware CSS props — uses the augmentable Theme interface
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,aAAa,CAAC,EAAE,CAAC;CAC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,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;CAChE,CAAC"}
|
package/dist/types/props.d.ts
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
import { BaseTheme } from './theme';
|
|
1
|
+
import { BaseTheme, Theme } from './theme';
|
|
2
2
|
export type AbstractProps = ThemeProps<Record<string, unknown>, BaseTheme>;
|
|
3
|
-
interface MediaQueryByKey<T = string> {
|
|
4
|
-
xs: T;
|
|
5
|
-
sm: T;
|
|
6
|
-
md: T;
|
|
7
|
-
lg: T;
|
|
8
|
-
xl: T;
|
|
9
|
-
}
|
|
10
3
|
export interface MediaQueryCache {
|
|
11
|
-
map:
|
|
4
|
+
map: Record<string, string>;
|
|
12
5
|
array: string[];
|
|
13
6
|
}
|
|
14
7
|
export type ThemeProps<Props = {}, T extends BaseTheme = BaseTheme> = Props & {
|
|
15
8
|
theme?: T;
|
|
16
9
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
4?: T;
|
|
23
|
-
5?: T;
|
|
24
|
-
}
|
|
25
|
-
export interface MediaQueryMap<T> {
|
|
10
|
+
type ThemeBreakpoints = Theme extends {
|
|
11
|
+
breakpoints: infer B;
|
|
12
|
+
} ? B : Record<string, number>;
|
|
13
|
+
type BreakpointKeys = keyof ThemeBreakpoints;
|
|
14
|
+
export type MediaQueryMap<T> = {
|
|
26
15
|
_?: T;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type ResponsiveProp<T> = T | MediaQueryMap<T> | MediaQueryArray<T>;
|
|
16
|
+
} & (string extends BreakpointKeys ? {
|
|
17
|
+
[key: string]: T | undefined;
|
|
18
|
+
} : {
|
|
19
|
+
[K in BreakpointKeys]?: T;
|
|
20
|
+
});
|
|
21
|
+
export type ResponsiveProp<T> = T | MediaQueryMap<T>;
|
|
34
22
|
export {};
|
|
35
23
|
//# sourceMappingURL=props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/types/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/types/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;AAE3E,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,CAAC,KAAK,GAAG,EAAE,EAAE,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,KAAK,GAAG;IAC5E,KAAK,CAAC,EAAE,CAAC,CAAC;CACX,CAAC;AAEF,KAAK,gBAAgB,GAAG,KAAK,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC,CAAA;CAAE,GAC1D,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3B,KAAK,cAAc,GAAG,MAAM,gBAAgB,CAAC;AAE7C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,CAAC,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,MAAM,SAAS,cAAc,GACrE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAA;CAAE,GAChC;KAAG,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC;CAAE,CAAC,CAAC;AAEnC,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
+
import type { LiteralPaths } from '../theme/flattenScale';
|
|
1
2
|
export type { CSSObject } from './shared';
|
|
2
|
-
export interface Breakpoints<T = number> {
|
|
3
|
-
xs: T;
|
|
4
|
-
sm: T;
|
|
5
|
-
md: T;
|
|
6
|
-
lg: T;
|
|
7
|
-
xl: T;
|
|
8
|
-
}
|
|
9
3
|
export interface BaseTheme {
|
|
10
|
-
breakpoints: Breakpoints;
|
|
11
4
|
}
|
|
12
5
|
export interface AbstractTheme extends BaseTheme {
|
|
6
|
+
breakpoints: Record<string, number>;
|
|
13
7
|
readonly [key: string]: any;
|
|
14
8
|
}
|
|
15
9
|
/**
|
|
@@ -30,6 +24,10 @@ export type TokenScales<T> = Omit<T, '_variables' | '_tokens' | 'mode' | '_getCo
|
|
|
30
24
|
* When augmented, CSS object values like `fontSize` become constrained to
|
|
31
25
|
* the theme's scale keys (e.g. `11 | 12 | 13 | 14 | 16 | ...`).
|
|
32
26
|
* When NOT augmented, values fall back to standard CSS property types.
|
|
27
|
+
*
|
|
28
|
+
* BaseTheme uses an open index signature so that module augmentation can
|
|
29
|
+
* provide a concrete breakpoints type (e.g. `{ sm: number; lg: number }`)
|
|
30
|
+
* without conflicting with a fixed Breakpoints interface.
|
|
33
31
|
*/
|
|
34
32
|
export interface Theme extends BaseTheme {
|
|
35
33
|
}
|
|
@@ -39,6 +37,34 @@ export interface Theme extends BaseTheme {
|
|
|
39
37
|
* (string & {}) escape hatch allows future CSS color functions without blocking.
|
|
40
38
|
*/
|
|
41
39
|
export type CSSColorValue = `#${string}` | `rgb(${string})` | `rgba(${string})` | `hsl(${string})` | `hsla(${string})` | `oklch(${string})` | `oklab(${string})` | `lch(${string})` | `lab(${string})` | `color-mix(${string})` | `color(${string})` | 'transparent' | 'currentColor' | (string & {});
|
|
40
|
+
/**
|
|
41
|
+
* Extract scale names from a built theme whose values are CSS variable references.
|
|
42
|
+
* These are scales that were emitted via `addScale({ emit: true })` or `addColors()`.
|
|
43
|
+
*
|
|
44
|
+
* Use with `TokenScales<T>` to pick emitted vs non-emitted subsets:
|
|
45
|
+
* ```ts
|
|
46
|
+
* type Emitted = Pick<TokenScales<T>, EmittedScales<T>>;
|
|
47
|
+
* type Static = Omit<TokenScales<T>, EmittedScales<T>>;
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export type EmittedScales<T> = {
|
|
51
|
+
[K in keyof TokenScales<T>]: TokenScales<T>[K] extends Record<string, `var(--${string})`> ? K : never;
|
|
52
|
+
}[keyof TokenScales<T>];
|
|
53
|
+
/**
|
|
54
|
+
* All valid token ref paths for emitted scales in a theme.
|
|
55
|
+
* Uses LiteralPaths to enumerate `scale.key` paths from emitted scale entries.
|
|
56
|
+
*
|
|
57
|
+
* ```ts
|
|
58
|
+
* type Refs = EmittedTokenPaths<typeof tokens>;
|
|
59
|
+
* // → 'colors.primary' | 'colors.bg' | 'sizes.navHeight' | ...
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export type EmittedTokenPaths<T> = keyof LiteralPaths<Pick<TokenScales<T>, EmittedScales<T>>, '.'>;
|
|
63
|
+
/**
|
|
64
|
+
* Token ref pattern type for referencing emitted scales.
|
|
65
|
+
* Constrains the scale name portion of `{scale.key}` to only emitted scales.
|
|
66
|
+
*/
|
|
67
|
+
export type ScaleTokenRef<E extends string> = `${string}{${E}.${string}}${string}`;
|
|
42
68
|
/** Structured manifest emitted by ThemeBuilder.build() for plugin consumption. */
|
|
43
69
|
export interface ThemeManifest {
|
|
44
70
|
/** Flat token key → raw value (e.g. 'space.8' → '0.5rem', 'colors.ember' → '#FF2800') */
|
|
@@ -49,5 +75,7 @@ export interface ThemeManifest {
|
|
|
49
75
|
modes: Record<string, Record<string, string>>;
|
|
50
76
|
/** Pre-built CSS string with :root and [data-color-mode] blocks */
|
|
51
77
|
variableCss: string;
|
|
78
|
+
/** Contextual vars registry: scale_name → [var_name] for --current-{name} side-effects */
|
|
79
|
+
contextualVars?: Record<string, string[]>;
|
|
52
80
|
}
|
|
53
81
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,SAAS;CAAG;AAE7B,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,IAAI,CAC/B,CAAC,EACD,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,gBAAgB,GAAG,aAAa,GAAG,OAAO,CAC/E,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,KAAM,SAAQ,SAAS;CAAG;AAE3C;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,IAAI,MAAM,EAAE,GACZ,OAAO,MAAM,GAAG,GAChB,QAAQ,MAAM,GAAG,GACjB,OAAO,MAAM,GAAG,GAChB,QAAQ,MAAM,GAAG,GACjB,SAAS,MAAM,GAAG,GAClB,SAAS,MAAM,GAAG,GAClB,OAAO,MAAM,GAAG,GAChB,OAAO,MAAM,GAAG,GAChB,aAAa,MAAM,GAAG,GACtB,SAAS,MAAM,GAAG,GAClB,aAAa,GACb,cAAc,GACd,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KA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