@yahoo/uds 3.156.1 → 3.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automated-config/dist/generated/autoVariants.cjs +9 -4
- package/dist/automated-config/dist/generated/autoVariants.d.cts +2 -1
- package/dist/automated-config/dist/generated/autoVariants.d.ts +2 -1
- package/dist/automated-config/dist/generated/autoVariants.js +9 -4
- package/dist/automated-config/dist/generated/generatedConfigs.cjs +3011 -3038
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +143 -140
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +143 -140
- package/dist/automated-config/dist/generated/generatedConfigs.js +3011 -3038
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +1227 -501
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +1227 -501
- package/dist/automated-config/dist/properties.cjs +1 -1
- package/dist/automated-config/dist/properties.d.cts +15 -0
- package/dist/automated-config/dist/properties.d.ts +15 -0
- package/dist/automated-config/dist/properties.js +1 -1
- package/dist/automated-config/dist/types/ComponentConfig.d.cts +77 -4
- package/dist/automated-config/dist/types/ComponentConfig.d.ts +77 -4
- package/dist/automated-config/dist/types/ConfigSchema.d.cts +14 -2
- package/dist/automated-config/dist/types/ConfigSchema.d.ts +14 -2
- package/dist/automated-config/dist/types/StateAxis.cjs +90 -0
- package/dist/automated-config/dist/types/StateAxis.d.cts +70 -0
- package/dist/automated-config/dist/types/StateAxis.d.ts +70 -0
- package/dist/automated-config/dist/types/StateAxis.js +84 -0
- package/dist/automated-config/dist/utils/buildConfigSchema.cjs +98 -82
- package/dist/automated-config/dist/utils/buildConfigSchema.d.cts +32 -10
- package/dist/automated-config/dist/utils/buildConfigSchema.d.ts +32 -10
- package/dist/automated-config/dist/utils/buildConfigSchema.js +99 -83
- package/dist/automated-config/dist/utils/canonicalizeStateKey.cjs +32 -0
- package/dist/automated-config/dist/utils/canonicalizeStateKey.d.cts +48 -0
- package/dist/automated-config/dist/utils/canonicalizeStateKey.d.ts +48 -0
- package/dist/automated-config/dist/utils/canonicalizeStateKey.js +31 -0
- package/dist/automated-config/dist/utils/getConfigComponentVariant.d.cts +8 -0
- package/dist/automated-config/dist/utils/getConfigComponentVariant.d.ts +8 -0
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.cts +3 -3
- package/dist/automated-config/dist/utils/getConfigVariantProperties.d.ts +3 -3
- package/dist/automated-config/dist/utils/getConfigVariantPseudoStates.cjs +12 -5
- package/dist/automated-config/dist/utils/getConfigVariantPseudoStates.d.cts +8 -1
- package/dist/automated-config/dist/utils/getConfigVariantPseudoStates.d.ts +8 -1
- package/dist/automated-config/dist/utils/getConfigVariantPseudoStates.js +12 -5
- package/dist/automated-config/dist/utils/getPaginationControlWidthPx.cjs +1 -1
- package/dist/automated-config/dist/utils/getPaginationControlWidthPx.js +1 -1
- package/dist/automated-config/dist/utils/index.cjs +407 -97
- package/dist/automated-config/dist/utils/index.d.cts +66 -16
- package/dist/automated-config/dist/utils/index.d.ts +66 -16
- package/dist/automated-config/dist/utils/index.js +408 -99
- package/dist/automated-config/dist/utils/pseudoStateSelectors.cjs +122 -0
- package/dist/automated-config/dist/utils/pseudoStateSelectors.d.cts +80 -0
- package/dist/automated-config/dist/utils/pseudoStateSelectors.d.ts +80 -0
- package/dist/automated-config/dist/utils/pseudoStateSelectors.js +120 -0
- package/dist/automated-config/dist/utils/resolvePropertyStates.cjs +131 -0
- package/dist/automated-config/dist/utils/resolvePropertyStates.d.cts +49 -0
- package/dist/automated-config/dist/utils/resolvePropertyStates.d.ts +49 -0
- package/dist/automated-config/dist/utils/resolvePropertyStates.js +130 -0
- package/dist/automated-config/dist/utils/resolveSlotByCascade.cjs +118 -0
- package/dist/automated-config/dist/utils/resolveSlotByCascade.d.cts +68 -0
- package/dist/automated-config/dist/utils/resolveSlotByCascade.d.ts +68 -0
- package/dist/automated-config/dist/utils/resolveSlotByCascade.js +117 -0
- package/dist/automated-config/dist/utils/variantConfigGuards.d.cts +13 -0
- package/dist/automated-config/dist/utils/variantConfigGuards.d.ts +13 -0
- package/dist/components/client/Input/Input.cjs +42 -6
- package/dist/components/client/Input/Input.d.cts +13 -0
- package/dist/components/client/Input/Input.d.ts +13 -0
- package/dist/components/client/Input/Input.js +42 -6
- package/dist/config/dist/index.cjs +221 -550
- package/dist/config/dist/index.js +221 -550
- package/dist/css/dist/commands/css.cjs +1 -0
- package/dist/css/dist/commands/css.helpers.cjs +6 -0
- package/dist/css/dist/commands/css.helpers.js +6 -0
- package/dist/css/dist/commands/css.js +1 -0
- package/dist/css/dist/css/generate.cjs +4 -2
- package/dist/css/dist/css/generate.d.cts +28 -0
- package/dist/css/dist/css/generate.d.ts +28 -0
- package/dist/css/dist/css/generate.helpers.cjs +5 -1
- package/dist/css/dist/css/generate.helpers.js +6 -2
- package/dist/css/dist/css/generate.js +4 -2
- package/dist/css/dist/css/postcss.cjs +81 -0
- package/dist/css/dist/css/postcss.helpers.cjs +60 -0
- package/dist/css/dist/css/postcss.helpers.js +59 -1
- package/dist/css/dist/css/postcss.js +82 -2
- package/dist/css/dist/css/runner.cjs +12 -2
- package/dist/css/dist/css/runner.js +12 -2
- package/dist/css/dist/css/theme.d.cts +6 -0
- package/dist/css/dist/css/theme.d.ts +6 -0
- package/dist/css/dist/packages/automated-config/dist/properties.cjs +1 -1
- package/dist/css/dist/packages/automated-config/dist/properties.js +1 -1
- package/dist/css/dist/packages/automated-config/dist/utils/index.d.cts +6 -0
- package/dist/css/dist/packages/automated-config/dist/utils/index.d.ts +6 -0
- package/dist/css/dist/packages/config/dist/index.cjs +221 -550
- package/dist/css/dist/packages/config/dist/index.js +221 -550
- package/dist/css/dist/utils/optimizeCSS.cjs +59 -0
- package/dist/css/dist/utils/optimizeCSS.js +59 -0
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +9 -2
- package/dist/styles/styler.d.cts +14 -13
- package/dist/styles/styler.d.ts +14 -13
- package/dist/styles/variants.d.cts +9 -4
- package/dist/styles/variants.d.ts +9 -4
- package/dist/tailwind-internal/dist/packages/automated-config/dist/generated/generatedConfigs.cjs +3011 -3038
- package/dist/tailwind-internal/dist/packages/automated-config/dist/generated/generatedConfigs.js +3011 -3038
- package/dist/tailwind-internal/dist/packages/automated-config/dist/properties.cjs +1 -1
- package/dist/tailwind-internal/dist/packages/automated-config/dist/properties.js +1 -1
- package/dist/tailwind-internal/dist/packages/automated-config/dist/types/StateAxis.cjs +81 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/types/StateAxis.js +76 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/canonicalizeStateKey.cjs +33 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/canonicalizeStateKey.js +32 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/componentStatePseudoStates.cjs +0 -7
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/componentStatePseudoStates.js +1 -7
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/index.cjs +354 -97
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/index.d.cts +6 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/index.d.ts +6 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/index.js +355 -98
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/pseudoStateSelectors.cjs +122 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/pseudoStateSelectors.js +121 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/resolvePropertyStates.cjs +132 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/resolvePropertyStates.js +131 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/resolveSlotByCascade.cjs +95 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/resolveSlotByCascade.js +95 -0
- package/dist/tailwind-internal/dist/packages/config/dist/index.cjs +221 -550
- package/dist/tailwind-internal/dist/packages/config/dist/index.js +221 -550
- package/dist/tailwind-internal/dist/plugins/components.cjs +28 -24
- package/dist/tailwind-internal/dist/plugins/components.js +28 -24
- package/dist/tailwind-internal/dist/utils/composeTailwindPlugins.d.cts +3 -0
- package/dist/tailwind-internal/dist/utils/composeTailwindPlugins.d.ts +3 -0
- package/dist/tokens/automation/index.cjs +25 -0
- package/dist/tokens/automation/index.d.cts +9 -2
- package/dist/tokens/automation/index.d.ts +9 -2
- package/dist/tokens/automation/index.js +9 -2
- package/dist/tokens/index.cjs +25 -0
- package/dist/tokens/index.d.cts +10 -3
- package/dist/tokens/index.d.ts +10 -3
- package/dist/tokens/index.js +9 -2
- package/dist/tokens/types.d.cts +1 -1
- package/dist/tokens/types.d.ts +1 -1
- package/dist/uds/generated/componentData.cjs +2010 -2008
- package/dist/uds/generated/componentData.js +2010 -2008
- package/dist/uds/generated/migrationSchemaVersion.cjs +1 -1
- package/dist/uds/generated/migrationSchemaVersion.js +1 -1
- package/dist/uds/generated/tailwindPurge.cjs +79 -78
- package/dist/uds/generated/tailwindPurge.js +79 -78
- package/generated/componentData.json +2553 -2551
- package/generated/migrationSchemaVersion.ts +1 -1
- package/generated/tailwindPurge.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
//#region ../automated-config/dist/types/StateAxis.js
|
|
3
|
+
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
4
|
+
/**
|
|
5
|
+
* Atomic-state taxonomy.
|
|
6
|
+
*
|
|
7
|
+
* Every interactive component reacts to a fixed set of "atomic" states, each
|
|
8
|
+
* belonging to one axis:
|
|
9
|
+
*
|
|
10
|
+
* - `interactive` — pointer/keyboard focus signals. At runtime at most one of
|
|
11
|
+
* these is meaningfully "active" at a time on a given element (you can't
|
|
12
|
+
* simultaneously hover and press distinctly enough to style separately, etc.).
|
|
13
|
+
*
|
|
14
|
+
* - `modifier` — semantic flags that can stack independently of each other and
|
|
15
|
+
* of the interactive state. An input can be `invalid` AND `readonly` at the
|
|
16
|
+
* same time, optionally also `hover`ed.
|
|
17
|
+
*
|
|
18
|
+
* Compound states (`'invalid&hover'`, `'invalid&readonly&hover'`, etc.) are
|
|
19
|
+
* built by listing 0..N modifiers followed by 0..1 interactive. The
|
|
20
|
+
* `canonicalizeStateKey` helper enforces this ordering so that, e.g.,
|
|
21
|
+
* `['hover', 'invalid']` and `['invalid', 'hover']` resolve to the same key.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Interactive atomics:
|
|
25
|
+
*
|
|
26
|
+
* - `hover`/`pressed` for pointer interaction.
|
|
27
|
+
* - `focus-within` for containers that wrap a focusable child (e.g. an input
|
|
28
|
+
* wrapper).
|
|
29
|
+
* - `focus-visible` for keyboard-only focus rings on focusable elements.
|
|
30
|
+
*/
|
|
31
|
+
const INTERACTIVE_ATOMICS = [
|
|
32
|
+
"hover",
|
|
33
|
+
"pressed",
|
|
34
|
+
"focus-within",
|
|
35
|
+
"focus-visible"
|
|
36
|
+
];
|
|
37
|
+
const MODIFIER_ATOMICS = [
|
|
38
|
+
"invalid",
|
|
39
|
+
"readonly",
|
|
40
|
+
"placeholder-shown",
|
|
41
|
+
"autofill",
|
|
42
|
+
"visited"
|
|
43
|
+
];
|
|
44
|
+
const INTERACTIVE_ATOMIC_SET = new Set(INTERACTIVE_ATOMICS);
|
|
45
|
+
const MODIFIER_ATOMIC_SET = new Set(MODIFIER_ATOMICS);
|
|
46
|
+
function isInteractiveAtomic(state) {
|
|
47
|
+
return INTERACTIVE_ATOMIC_SET.has(state);
|
|
48
|
+
}
|
|
49
|
+
function isModifierAtomic(state) {
|
|
50
|
+
return MODIFIER_ATOMIC_SET.has(state);
|
|
51
|
+
}
|
|
52
|
+
function isAtomicState(state) {
|
|
53
|
+
return isInteractiveAtomic(state) || isModifierAtomic(state);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Maximum number of modifiers that may appear in a single compound state.
|
|
57
|
+
* The resolver enumerates compounds up to `M^MAX_MODIFIERS_PER_COMPOUND × I`
|
|
58
|
+
* (with the interactive slot optional), the docs-class enumeration matches,
|
|
59
|
+
* and the StateBuilder picker prevents users from selecting more than this
|
|
60
|
+
* many modifier checkboxes. Keeping all three in lock-step means there's
|
|
61
|
+
* exactly one compound depth supported end-to-end.
|
|
62
|
+
*/
|
|
63
|
+
const MAX_MODIFIERS_PER_COMPOUND = 3;
|
|
64
|
+
const STATE_PRIORITY_INDEX = new Map([
|
|
65
|
+
"visited",
|
|
66
|
+
"placeholder-shown",
|
|
67
|
+
"autofill",
|
|
68
|
+
"focus-within",
|
|
69
|
+
"focus-visible",
|
|
70
|
+
"hover",
|
|
71
|
+
"pressed",
|
|
72
|
+
"invalid",
|
|
73
|
+
"readonly"
|
|
74
|
+
].map((atom, i) => [atom, i]));
|
|
75
|
+
/**
|
|
76
|
+
* Comparator usable with `Array.prototype.sort`. Atoms not in `STATE_PRIORITY`
|
|
77
|
+
* sort to the front (weakest) — this only triggers for unknown strings; every
|
|
78
|
+
* known `AtomicState` is in the priority array.
|
|
79
|
+
*/
|
|
80
|
+
function comparePriority(a, b) {
|
|
81
|
+
return (STATE_PRIORITY_INDEX.get(a) ?? -1) - (STATE_PRIORITY_INDEX.get(b) ?? -1);
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { INTERACTIVE_ATOMICS, MAX_MODIFIERS_PER_COMPOUND, MODIFIER_ATOMICS, comparePriority, isAtomicState, isInteractiveAtomic, isModifierAtomic };
|
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_componentStatePseudoStates = require("./componentStatePseudoStates.cjs");
|
|
3
3
|
const require_generateSchemaKey = require("./generateSchemaKey.cjs");
|
|
4
|
+
const require_resolvePropertyStates = require("./resolvePropertyStates.cjs");
|
|
4
5
|
const require_variantConfigGuards = require("./variantConfigGuards.cjs");
|
|
5
6
|
const require_util = require("../../../fixtures/src/util.cjs");
|
|
6
7
|
//#region ../automated-config/dist/utils/buildConfigSchema.js
|
|
7
8
|
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
9
|
+
/**
|
|
10
|
+
* Builds the per-state schema entries for one property on one variant option.
|
|
11
|
+
* Each state slot (rest, hover, invalid&hover, ...) gets the property's
|
|
12
|
+
* default value as a starting point so the Configurator UI has something to
|
|
13
|
+
* render before users tweak.
|
|
14
|
+
*
|
|
15
|
+
* Per-state CSS emission depends on the emit mode (`exhaustive` by default,
|
|
16
|
+
* `selective` opt-in) and on the `isEnabled` flag this builder writes:
|
|
17
|
+
* - `rest` always emits in both modes (no flag needed; CSS gen treats rest
|
|
18
|
+
* as enabled).
|
|
19
|
+
* - Under EXHAUSTIVE (the default) on `atomicStates` layers, every declared
|
|
20
|
+
* non-rest state emits a rule regardless of `isEnabled`; its value is
|
|
21
|
+
* cascade-resolved (see `resolveSlotByCascade`), so there are no gaps.
|
|
22
|
+
* `isEnabled` there only selects which value a state resolves to, not
|
|
23
|
+
* whether it emits.
|
|
24
|
+
* - Under SELECTIVE (and legacy `pseudoStates`) emission, non-rest slots
|
|
25
|
+
* emit only when `isEnabled === true`.
|
|
26
|
+
* - `skipRestState` properties have no rest fallback, so every populated
|
|
27
|
+
* state slot must emit; we set `isEnabled: true` on each.
|
|
28
|
+
* - Otherwise, auto-populated non-rest slots ship with no flag — under
|
|
29
|
+
* selective they're off until a designer enables them via the
|
|
30
|
+
* configurator's per-property checkbox (which sets or clears this flag
|
|
31
|
+
* through the setter); under exhaustive they still emit via the cascade.
|
|
32
|
+
*/
|
|
33
|
+
function buildPropertyStateMap(layer, property, variantOption, excludedStates = []) {
|
|
34
|
+
const stateMap = {};
|
|
35
|
+
const excluded = new Set(excludedStates);
|
|
36
|
+
const states = require_resolvePropertyStates.resolvePropertyStates(layer, property);
|
|
37
|
+
const fixtureType = findFixtureType(property, variantOption);
|
|
38
|
+
const value = property.defaults[variantOption];
|
|
39
|
+
const skipRestState = property.skipRestState === true;
|
|
40
|
+
const isTextVariant = propertyVariesOnlyAtRest(property);
|
|
41
|
+
for (const state of states) {
|
|
42
|
+
if (excluded.has(state)) continue;
|
|
43
|
+
if (isTextVariant && state !== "rest") continue;
|
|
44
|
+
stateMap[state] = skipRestState ? {
|
|
45
|
+
type: fixtureType,
|
|
46
|
+
valueType: "alias",
|
|
47
|
+
value,
|
|
48
|
+
isEnabled: true
|
|
49
|
+
} : {
|
|
50
|
+
type: fixtureType,
|
|
51
|
+
valueType: "alias",
|
|
52
|
+
value
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return stateMap;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether a property's non-rest slots are stored SPARSELY — never pre-populated
|
|
59
|
+
* by the schema builder, only persisted when a designer authors an explicit
|
|
60
|
+
* per-state override (resolved via the cascade otherwise). `textVariant` is the
|
|
61
|
+
* only such property today: its non-rest "Emphasized" overrides are created
|
|
62
|
+
* lazily in the configurator rather than seeded for every state.
|
|
63
|
+
*
|
|
64
|
+
* Consulted by the schema builder ({@link buildPropertyStateMap}) to keep the
|
|
65
|
+
* stored config compact. CSS emission does NOT special-case these properties:
|
|
66
|
+
* exhaustive emission walks every declared state and resolves each through the
|
|
67
|
+
* cascade (`resolveSlotByCascade`), so an authored non-rest override emits a
|
|
68
|
+
* rule that renders while unauthored states resolve back to rest.
|
|
69
|
+
*/
|
|
70
|
+
function propertyVariesOnlyAtRest(property) {
|
|
71
|
+
return property.name === "textVariant";
|
|
72
|
+
}
|
|
8
73
|
/** Resolves the fixture type by finding which value set contains the given value */
|
|
9
74
|
function findFixtureTypeForValue(property, value) {
|
|
10
75
|
const index = property.values.findIndex((arr) => arr.includes(value));
|
|
@@ -17,13 +82,29 @@ function findFixtureTypeForValue(property, value) {
|
|
|
17
82
|
function findFixtureType(property, variantKey) {
|
|
18
83
|
return findFixtureTypeForValue(property, property.defaults[variantKey]);
|
|
19
84
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Walk a set of layers and emit schema entries keyed by layer (no
|
|
87
|
+
* component-state segment). Shared between `VariantConfigWithProperties` and
|
|
88
|
+
* the optional top-level `layers` field on `VariantConfigWithComponentStates`.
|
|
89
|
+
*/
|
|
90
|
+
function emitUniversalLayerSchema(result, layers, variantKey, variantOption, subComponentName) {
|
|
91
|
+
for (const layerKey in layers) {
|
|
92
|
+
const layer = layers[layerKey];
|
|
93
|
+
const schemaKey = require_generateSchemaKey.generateSchemaKey({
|
|
94
|
+
variantKey,
|
|
95
|
+
variantValue: variantOption,
|
|
96
|
+
layer: layerKey,
|
|
97
|
+
subComponentName
|
|
98
|
+
});
|
|
99
|
+
result.variables[schemaKey] = {};
|
|
100
|
+
for (const propertyKey in layer.properties) {
|
|
101
|
+
const property = layer.properties[propertyKey];
|
|
102
|
+
result.variables[schemaKey] = {
|
|
103
|
+
...result.variables[schemaKey],
|
|
104
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
27
108
|
}
|
|
28
109
|
/** Builds component schema from ComponentConfig at runtime */
|
|
29
110
|
function buildConfigSchema(config) {
|
|
@@ -35,6 +116,7 @@ function buildConfigSchema(config) {
|
|
|
35
116
|
for (const variantKey in config.variants) {
|
|
36
117
|
const variantConfig = config.variants[variantKey];
|
|
37
118
|
for (const variantOption of variantConfig.options) if (require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) {
|
|
119
|
+
if (variantConfig.layers) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption);
|
|
38
120
|
const componentStates = variantConfig.componentStates;
|
|
39
121
|
for (const componentStateKey in componentStates) {
|
|
40
122
|
const componentState = componentStates[componentStateKey];
|
|
@@ -50,16 +132,9 @@ function buildConfigSchema(config) {
|
|
|
50
132
|
result.variables[schemaKey] = {};
|
|
51
133
|
for (const propertyKey in layer.properties) {
|
|
52
134
|
const property = layer.properties[propertyKey];
|
|
53
|
-
const variableObject = { [propertyKey]: {} };
|
|
54
|
-
if (property?.skipRestState !== true) variableObject[propertyKey] = { rest: {
|
|
55
|
-
type: findFixtureType(property, variantOption),
|
|
56
|
-
valueType: "alias",
|
|
57
|
-
value: property.defaults[variantOption]
|
|
58
|
-
} };
|
|
59
|
-
appendPseudoStateVariables(variableObject, propertyKey, property, variantOption, require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption));
|
|
60
135
|
result.variables[schemaKey] = {
|
|
61
136
|
...result.variables[schemaKey],
|
|
62
|
-
|
|
137
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption, require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption))
|
|
63
138
|
};
|
|
64
139
|
}
|
|
65
140
|
}
|
|
@@ -70,43 +145,16 @@ function buildConfigSchema(config) {
|
|
|
70
145
|
result.variables[variantSchemaKey] = result.variables[variantSchemaKey] ?? {};
|
|
71
146
|
for (const propertyKey in variantConfig.variantProperties) {
|
|
72
147
|
const property = variantConfig.variantProperties[propertyKey];
|
|
73
|
-
const variableObject = { [propertyKey]: {} };
|
|
74
|
-
if (property?.skipRestState !== true) variableObject[propertyKey] = { rest: {
|
|
75
|
-
type: findFixtureType(property, variantOption),
|
|
76
|
-
valueType: "alias",
|
|
77
|
-
value: property.defaults[variantOption]
|
|
78
|
-
} };
|
|
79
|
-
appendPseudoStateVariables(variableObject, propertyKey, property, variantOption);
|
|
80
148
|
result.variables[variantSchemaKey] = {
|
|
81
149
|
...result.variables[variantSchemaKey],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const layers = variantConfig.layers;
|
|
87
|
-
for (const layerKey in layers) {
|
|
88
|
-
const layer = layers[layerKey];
|
|
89
|
-
const schemaKey = require_generateSchemaKey.generateSchemaKey({
|
|
90
|
-
variantKey,
|
|
91
|
-
variantValue: variantOption,
|
|
92
|
-
layer: layerKey
|
|
93
|
-
});
|
|
94
|
-
result.variables[schemaKey] = {};
|
|
95
|
-
for (const propertyKey in layer.properties) {
|
|
96
|
-
const property = layer.properties[propertyKey];
|
|
97
|
-
const variableObject = { [propertyKey]: {} };
|
|
98
|
-
if (property?.skipRestState !== true) variableObject[propertyKey] = { rest: {
|
|
99
|
-
type: findFixtureType(property, variantOption),
|
|
100
|
-
valueType: "alias",
|
|
101
|
-
value: property.defaults[variantOption]
|
|
102
|
-
} };
|
|
103
|
-
appendPseudoStateVariables(variableObject, propertyKey, property, variantOption);
|
|
104
|
-
result.variables[schemaKey] = {
|
|
105
|
-
...result.variables[schemaKey],
|
|
106
|
-
...variableObject
|
|
150
|
+
[propertyKey]: buildPropertyStateMap({
|
|
151
|
+
label: "",
|
|
152
|
+
properties: {}
|
|
153
|
+
}, property, variantOption)
|
|
107
154
|
};
|
|
108
155
|
}
|
|
109
156
|
}
|
|
157
|
+
emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption);
|
|
110
158
|
}
|
|
111
159
|
}
|
|
112
160
|
if (config.subComponents) {
|
|
@@ -115,6 +163,7 @@ function buildConfigSchema(config) {
|
|
|
115
163
|
const variantConfig = subComponents[subComponentKey].variants[variantKey];
|
|
116
164
|
result.defaults[variantKey] = variantConfig.default;
|
|
117
165
|
for (const variantOption of variantConfig.options) if (require_variantConfigGuards.isVariantConfigWithComponentStates(variantConfig)) {
|
|
166
|
+
if (variantConfig.layers) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption, subComponentKey);
|
|
118
167
|
const componentStates = variantConfig.componentStates;
|
|
119
168
|
for (const componentStateKey in componentStates) {
|
|
120
169
|
const componentState = componentStates[componentStateKey];
|
|
@@ -131,47 +180,14 @@ function buildConfigSchema(config) {
|
|
|
131
180
|
result.variables[schemaKey] = {};
|
|
132
181
|
for (const propertyKey in layer.properties) {
|
|
133
182
|
const property = layer.properties[propertyKey];
|
|
134
|
-
const variableObject = { [propertyKey]: {} };
|
|
135
|
-
if (property?.skipRestState !== true) variableObject[propertyKey] = { rest: {
|
|
136
|
-
type: findFixtureType(property, variantOption),
|
|
137
|
-
valueType: "alias",
|
|
138
|
-
value: property.defaults[variantOption]
|
|
139
|
-
} };
|
|
140
|
-
appendPseudoStateVariables(variableObject, propertyKey, property, variantOption, require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption));
|
|
141
183
|
result.variables[schemaKey] = {
|
|
142
184
|
...result.variables[schemaKey],
|
|
143
|
-
|
|
185
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption, require_componentStatePseudoStates.getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption))
|
|
144
186
|
};
|
|
145
187
|
}
|
|
146
188
|
}
|
|
147
189
|
}
|
|
148
|
-
} else if (require_variantConfigGuards.isVariantConfigWithProperties(variantConfig))
|
|
149
|
-
const layers = variantConfig.layers;
|
|
150
|
-
for (const layerKey in layers) {
|
|
151
|
-
const layer = layers[layerKey];
|
|
152
|
-
const schemaKey = require_generateSchemaKey.generateSchemaKey({
|
|
153
|
-
variantKey,
|
|
154
|
-
variantValue: variantOption,
|
|
155
|
-
layer: layerKey,
|
|
156
|
-
subComponentName: subComponentKey
|
|
157
|
-
});
|
|
158
|
-
result.variables[schemaKey] = {};
|
|
159
|
-
for (const propertyKey in layer.properties) {
|
|
160
|
-
const property = layer.properties[propertyKey];
|
|
161
|
-
const variableObject = { [propertyKey]: {} };
|
|
162
|
-
if (property?.skipRestState !== true) variableObject[propertyKey] = { rest: {
|
|
163
|
-
type: findFixtureType(property, variantOption),
|
|
164
|
-
valueType: "alias",
|
|
165
|
-
value: property.defaults[variantOption]
|
|
166
|
-
} };
|
|
167
|
-
appendPseudoStateVariables(variableObject, propertyKey, property, variantOption);
|
|
168
|
-
result.variables[schemaKey] = {
|
|
169
|
-
...result.variables[schemaKey],
|
|
170
|
-
...variableObject
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
190
|
+
} else if (require_variantConfigGuards.isVariantConfigWithProperties(variantConfig)) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption, subComponentKey);
|
|
175
191
|
}
|
|
176
192
|
}
|
|
177
193
|
return result;
|
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
|
|
2
|
+
import { AtomicState } from "../types/StateAxis.cjs";
|
|
2
3
|
import { BannerInnerShadowOption, ElevationAlias, ShadowVariant, ShadowVariantConfig, ShadowVariantWithInvert } from "../../../types/dist/index.cjs";
|
|
3
4
|
import { ArbitraryFixtures, InferArbitraryType } from "../../../fixtures/dist/index.cjs";
|
|
5
|
+
import { ConfigurablePropertiesName, SelectedConfigurableProperty } from "../properties.cjs";
|
|
4
6
|
import { AllPossibleProperties, ComponentConfig, ComponentStateConfig, LayerConfig, PossibleStates, VariantConfig, VariantConfigWithComponentStates, VariantConfigWithProperties } from "../types/ComponentConfig.cjs";
|
|
5
7
|
import { SchemaStateValue } from "../types/ConfigSchema.cjs";
|
|
6
|
-
import { ConfigurablePropertiesName, SelectedConfigurableProperty } from "../properties.cjs";
|
|
7
8
|
import { OmitIndexSignature, SimplifyDeep, UnionToIntersection, WritableDeep } from "type-fest";
|
|
8
9
|
|
|
9
10
|
//#region ../automated-config/dist/utils/buildConfigSchema.d.ts
|
|
10
|
-
//#region src/utils/buildConfigSchema.d.ts
|
|
11
11
|
/** Infers default option values from all component variants */
|
|
12
12
|
type InferredDefaults<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? { [VarKey in keyof C['variants']]: C['variants'][VarKey]['options'][number] } : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: { [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: C['subComponents'][SubCompKey]['variants'][VarKey]['options'][number] } }[keyof C['subComponents']]> : {});
|
|
13
13
|
/** Infers type-safe schema value structure for a configurable property */
|
|
14
14
|
type InferredPropertySchema<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>> = {
|
|
15
15
|
type: Prop['typeOfFixture'][number];
|
|
16
|
-
valueType: 'alias' | 'custom';
|
|
16
|
+
valueType: 'alias' | 'custom'; /** See SchemaStateValue.isEnabled — opt-in flag for non-rest CSS emission. */
|
|
17
|
+
isEnabled?: boolean;
|
|
17
18
|
value: Prop['name'] extends 'shadow' ? ShadowVariant | ShadowVariantConfig | ElevationAlias : Prop['name'] extends 'insetShadow' ? ShadowVariantWithInvert | ShadowVariantConfig : Prop['name'] extends 'bannerInnerShadow' ? BannerInnerShadowOption : Prop['values'][number][number] | (Extract<Prop['typeOfFixture'][number], ArbitraryFixtures> extends never ? never : InferArbitraryType<Extract<Prop['typeOfFixture'][number], ArbitraryFixtures>>);
|
|
18
19
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Infers state-to-schema mappings for a property: rest plus every state the
|
|
22
|
+
* resolver will produce. Sources are additive:
|
|
23
|
+
*
|
|
24
|
+
* - Per-property `pseudoStates` (legacy).
|
|
25
|
+
* - Per-layer `atomicStates` (new). Each declared atom yields a required
|
|
26
|
+
* entry; auto-generated compounds (modifier × interactive, modifier ×
|
|
27
|
+
* modifier × interactive, etc.) yield optional entries because the resolver
|
|
28
|
+
* skips incompatible pairs. Marking compounds optional lets the data —
|
|
29
|
+
* which contains exactly the canonical, non-skipped subset — satisfy the
|
|
30
|
+
* wider type.
|
|
31
|
+
*
|
|
32
|
+
* `textVariant` is special-cased: only `rest` is required. Non-rest slots are
|
|
33
|
+
* optional because the configurator only stores them when the designer
|
|
34
|
+
* explicitly enables a per-state override; otherwise they're absent and the
|
|
35
|
+
* value resolves via the CSS cascade. See `buildPropertyStateMap` for the
|
|
36
|
+
* runtime mirror of this typing.
|
|
37
|
+
*/
|
|
38
|
+
type InferredPropertyStates<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>, Layer = unknown> = (Prop['skipRestState'] extends true ? {} : {
|
|
21
39
|
rest: InferredPropertySchema<Prop>;
|
|
22
|
-
}) & (
|
|
40
|
+
}) & (Layer extends {
|
|
41
|
+
atomicStates: infer AS extends readonly AtomicState[];
|
|
42
|
+
} ? { [K in AS[number]]?: InferredPropertySchema<Prop> } & { [K in `${string}&${string}`]?: InferredPropertySchema<Prop> } : Prop extends {
|
|
23
43
|
pseudoStates: infer PS extends PossibleStates[];
|
|
24
|
-
} ? { [K in PS[number]]: InferredPropertySchema<Prop> } : {});
|
|
44
|
+
} ? Prop['name'] extends 'textVariant' ? { [K in PS[number]]?: InferredPropertySchema<Prop> } : { [K in PS[number]]: InferredPropertySchema<Prop> } : {});
|
|
25
45
|
type GetExcludedPseudoStatesForOption<StateConfig extends ComponentStateConfig, StateOption extends string> = StateConfig extends {
|
|
26
46
|
excludePseudoStatesForOptions?: infer Exclusions extends Partial<Record<string, readonly PossibleStates[]>>;
|
|
27
47
|
} ? StateOption extends keyof Exclusions ? Exclusions[StateOption] : undefined : undefined;
|
|
@@ -30,11 +50,11 @@ type InferredPropertyStatesForOption<Prop extends SelectedConfigurableProperty<C
|
|
|
30
50
|
rest: InferredPropertySchema<Prop>;
|
|
31
51
|
}) & (Prop extends {
|
|
32
52
|
pseudoStates: infer PS extends PossibleStates[];
|
|
33
|
-
} ? { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]: InferredPropertySchema<Prop> } : {});
|
|
53
|
+
} ? Prop['name'] extends 'textVariant' ? { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]?: InferredPropertySchema<Prop> } : { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]: InferredPropertySchema<Prop> } : {});
|
|
34
54
|
/** Infers property-to-states mappings for a layer's properties */
|
|
35
55
|
type InferredLayerProperties<Layer> = Layer extends LayerConfig ? Layer extends {
|
|
36
56
|
properties: infer Props extends LayerConfig['properties'];
|
|
37
|
-
} ? { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey]> } : {} : {};
|
|
57
|
+
} ? { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey], Layer> } : {} : {};
|
|
38
58
|
type InferredLayerPropertiesForOption<Layer, ExcludedPseudoStates extends readonly PossibleStates[] | undefined> = Layer extends LayerConfig ? Layer extends {
|
|
39
59
|
properties: infer Props extends LayerConfig['properties'];
|
|
40
60
|
} ? { [PropKey in keyof Props]: InferredPropertyStatesForOption<Props[PropKey], ExcludedPseudoStates> } : {} : {};
|
|
@@ -45,7 +65,9 @@ type InferredVariantPropertiesMap<VarKey extends string, VarConfig extends Varia
|
|
|
45
65
|
variantProperties: infer Props extends Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, string>>;
|
|
46
66
|
} ? { [Option in VarConfig['options'][number] as `${Prefix}${VarKey}/${Option}`]: InferredVariantLevelProperties<Props> } : {};
|
|
47
67
|
/** Routes to appropriate schema map generator based on variant configuration type */
|
|
48
|
-
type InferredVariablesFilter<VarKey extends string, VarConfig extends VariantConfig, Prefix extends string = ''> = VarConfig extends VariantConfigWithComponentStates ? InferredSchemaMap<VarKey, VarConfig, VarConfig['componentStates'], Prefix>
|
|
68
|
+
type InferredVariablesFilter<VarKey extends string, VarConfig extends VariantConfig, Prefix extends string = ''> = VarConfig extends VariantConfigWithComponentStates ? InferredSchemaMap<VarKey, VarConfig, VarConfig['componentStates'], Prefix> & (VarConfig extends {
|
|
69
|
+
layers: infer L;
|
|
70
|
+
} ? L extends NonNullable<VariantConfigWithProperties['layers']> ? InferredSchemaMap<VarKey, VarConfig, L, Prefix> : {} : {}) : VarConfig extends VariantConfigWithProperties ? InferredSchemaMap<VarKey, VarConfig, VarConfig['layers'], Prefix> & InferredVariantPropertiesMap<VarKey, VarConfig, Prefix> : {};
|
|
49
71
|
/** Collects all schema mappings from component variants and subComponents */
|
|
50
72
|
type InferredVariables<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? UnionToIntersection<{ [VarKey in keyof C['variants']]: InferredVariablesFilter<VarKey & string, C['variants'][VarKey]> }[keyof C['variants']]> : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: UnionToIntersection<{ [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: InferredVariablesFilter<VarKey & string, C['subComponents'][SubCompKey]['variants'][VarKey], `${SubCompKey & string}/`> }[keyof C['subComponents'][SubCompKey]['variants']]> }[keyof C['subComponents']]> : {});
|
|
51
73
|
/** Component schema with inferred defaults and variable schema mappings */
|
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
|
|
2
|
+
import { AtomicState } from "../types/StateAxis.js";
|
|
2
3
|
import { BannerInnerShadowOption, ElevationAlias, ShadowVariant, ShadowVariantConfig, ShadowVariantWithInvert } from "../../../types/dist/index.js";
|
|
3
4
|
import { ArbitraryFixtures, InferArbitraryType } from "../../../fixtures/dist/index.js";
|
|
5
|
+
import { ConfigurablePropertiesName, SelectedConfigurableProperty } from "../properties.js";
|
|
4
6
|
import { AllPossibleProperties, ComponentConfig, ComponentStateConfig, LayerConfig, PossibleStates, VariantConfig, VariantConfigWithComponentStates, VariantConfigWithProperties } from "../types/ComponentConfig.js";
|
|
5
7
|
import { SchemaStateValue } from "../types/ConfigSchema.js";
|
|
6
|
-
import { ConfigurablePropertiesName, SelectedConfigurableProperty } from "../properties.js";
|
|
7
8
|
import { OmitIndexSignature, SimplifyDeep, UnionToIntersection, WritableDeep } from "type-fest";
|
|
8
9
|
|
|
9
10
|
//#region ../automated-config/dist/utils/buildConfigSchema.d.ts
|
|
10
|
-
//#region src/utils/buildConfigSchema.d.ts
|
|
11
11
|
/** Infers default option values from all component variants */
|
|
12
12
|
type InferredDefaults<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? { [VarKey in keyof C['variants']]: C['variants'][VarKey]['options'][number] } : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: { [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: C['subComponents'][SubCompKey]['variants'][VarKey]['options'][number] } }[keyof C['subComponents']]> : {});
|
|
13
13
|
/** Infers type-safe schema value structure for a configurable property */
|
|
14
14
|
type InferredPropertySchema<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>> = {
|
|
15
15
|
type: Prop['typeOfFixture'][number];
|
|
16
|
-
valueType: 'alias' | 'custom';
|
|
16
|
+
valueType: 'alias' | 'custom'; /** See SchemaStateValue.isEnabled — opt-in flag for non-rest CSS emission. */
|
|
17
|
+
isEnabled?: boolean;
|
|
17
18
|
value: Prop['name'] extends 'shadow' ? ShadowVariant | ShadowVariantConfig | ElevationAlias : Prop['name'] extends 'insetShadow' ? ShadowVariantWithInvert | ShadowVariantConfig : Prop['name'] extends 'bannerInnerShadow' ? BannerInnerShadowOption : Prop['values'][number][number] | (Extract<Prop['typeOfFixture'][number], ArbitraryFixtures> extends never ? never : InferArbitraryType<Extract<Prop['typeOfFixture'][number], ArbitraryFixtures>>);
|
|
18
19
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Infers state-to-schema mappings for a property: rest plus every state the
|
|
22
|
+
* resolver will produce. Sources are additive:
|
|
23
|
+
*
|
|
24
|
+
* - Per-property `pseudoStates` (legacy).
|
|
25
|
+
* - Per-layer `atomicStates` (new). Each declared atom yields a required
|
|
26
|
+
* entry; auto-generated compounds (modifier × interactive, modifier ×
|
|
27
|
+
* modifier × interactive, etc.) yield optional entries because the resolver
|
|
28
|
+
* skips incompatible pairs. Marking compounds optional lets the data —
|
|
29
|
+
* which contains exactly the canonical, non-skipped subset — satisfy the
|
|
30
|
+
* wider type.
|
|
31
|
+
*
|
|
32
|
+
* `textVariant` is special-cased: only `rest` is required. Non-rest slots are
|
|
33
|
+
* optional because the configurator only stores them when the designer
|
|
34
|
+
* explicitly enables a per-state override; otherwise they're absent and the
|
|
35
|
+
* value resolves via the CSS cascade. See `buildPropertyStateMap` for the
|
|
36
|
+
* runtime mirror of this typing.
|
|
37
|
+
*/
|
|
38
|
+
type InferredPropertyStates<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>, Layer = unknown> = (Prop['skipRestState'] extends true ? {} : {
|
|
21
39
|
rest: InferredPropertySchema<Prop>;
|
|
22
|
-
}) & (
|
|
40
|
+
}) & (Layer extends {
|
|
41
|
+
atomicStates: infer AS extends readonly AtomicState[];
|
|
42
|
+
} ? { [K in AS[number]]?: InferredPropertySchema<Prop> } & { [K in `${string}&${string}`]?: InferredPropertySchema<Prop> } : Prop extends {
|
|
23
43
|
pseudoStates: infer PS extends PossibleStates[];
|
|
24
|
-
} ? { [K in PS[number]]: InferredPropertySchema<Prop> } : {});
|
|
44
|
+
} ? Prop['name'] extends 'textVariant' ? { [K in PS[number]]?: InferredPropertySchema<Prop> } : { [K in PS[number]]: InferredPropertySchema<Prop> } : {});
|
|
25
45
|
type GetExcludedPseudoStatesForOption<StateConfig extends ComponentStateConfig, StateOption extends string> = StateConfig extends {
|
|
26
46
|
excludePseudoStatesForOptions?: infer Exclusions extends Partial<Record<string, readonly PossibleStates[]>>;
|
|
27
47
|
} ? StateOption extends keyof Exclusions ? Exclusions[StateOption] : undefined : undefined;
|
|
@@ -30,11 +50,11 @@ type InferredPropertyStatesForOption<Prop extends SelectedConfigurableProperty<C
|
|
|
30
50
|
rest: InferredPropertySchema<Prop>;
|
|
31
51
|
}) & (Prop extends {
|
|
32
52
|
pseudoStates: infer PS extends PossibleStates[];
|
|
33
|
-
} ? { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]: InferredPropertySchema<Prop> } : {});
|
|
53
|
+
} ? Prop['name'] extends 'textVariant' ? { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]?: InferredPropertySchema<Prop> } : { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]: InferredPropertySchema<Prop> } : {});
|
|
34
54
|
/** Infers property-to-states mappings for a layer's properties */
|
|
35
55
|
type InferredLayerProperties<Layer> = Layer extends LayerConfig ? Layer extends {
|
|
36
56
|
properties: infer Props extends LayerConfig['properties'];
|
|
37
|
-
} ? { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey]> } : {} : {};
|
|
57
|
+
} ? { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey], Layer> } : {} : {};
|
|
38
58
|
type InferredLayerPropertiesForOption<Layer, ExcludedPseudoStates extends readonly PossibleStates[] | undefined> = Layer extends LayerConfig ? Layer extends {
|
|
39
59
|
properties: infer Props extends LayerConfig['properties'];
|
|
40
60
|
} ? { [PropKey in keyof Props]: InferredPropertyStatesForOption<Props[PropKey], ExcludedPseudoStates> } : {} : {};
|
|
@@ -45,7 +65,9 @@ type InferredVariantPropertiesMap<VarKey extends string, VarConfig extends Varia
|
|
|
45
65
|
variantProperties: infer Props extends Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, string>>;
|
|
46
66
|
} ? { [Option in VarConfig['options'][number] as `${Prefix}${VarKey}/${Option}`]: InferredVariantLevelProperties<Props> } : {};
|
|
47
67
|
/** Routes to appropriate schema map generator based on variant configuration type */
|
|
48
|
-
type InferredVariablesFilter<VarKey extends string, VarConfig extends VariantConfig, Prefix extends string = ''> = VarConfig extends VariantConfigWithComponentStates ? InferredSchemaMap<VarKey, VarConfig, VarConfig['componentStates'], Prefix>
|
|
68
|
+
type InferredVariablesFilter<VarKey extends string, VarConfig extends VariantConfig, Prefix extends string = ''> = VarConfig extends VariantConfigWithComponentStates ? InferredSchemaMap<VarKey, VarConfig, VarConfig['componentStates'], Prefix> & (VarConfig extends {
|
|
69
|
+
layers: infer L;
|
|
70
|
+
} ? L extends NonNullable<VariantConfigWithProperties['layers']> ? InferredSchemaMap<VarKey, VarConfig, L, Prefix> : {} : {}) : VarConfig extends VariantConfigWithProperties ? InferredSchemaMap<VarKey, VarConfig, VarConfig['layers'], Prefix> & InferredVariantPropertiesMap<VarKey, VarConfig, Prefix> : {};
|
|
49
71
|
/** Collects all schema mappings from component variants and subComponents */
|
|
50
72
|
type InferredVariables<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? UnionToIntersection<{ [VarKey in keyof C['variants']]: InferredVariablesFilter<VarKey & string, C['variants'][VarKey]> }[keyof C['variants']]> : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: UnionToIntersection<{ [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: InferredVariablesFilter<VarKey & string, C['subComponents'][SubCompKey]['variants'][VarKey], `${SubCompKey & string}/`> }[keyof C['subComponents'][SubCompKey]['variants']]> }[keyof C['subComponents']]> : {});
|
|
51
73
|
/** Component schema with inferred defaults and variable schema mappings */
|