@yahoo/uds 3.156.2 → 3.157.1
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 +3078 -3089
- package/dist/automated-config/dist/generated/generatedConfigs.d.cts +158 -141
- package/dist/automated-config/dist/generated/generatedConfigs.d.ts +158 -141
- package/dist/automated-config/dist/generated/generatedConfigs.js +3078 -3089
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.cjs +1217 -491
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.cts +4 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.d.ts +4 -1
- package/dist/automated-config/dist/generated/universalTokensConfigAuto.js +1217 -491
- package/dist/automated-config/dist/properties.cjs +9 -2
- package/dist/automated-config/dist/properties.d.cts +23 -0
- package/dist/automated-config/dist/properties.d.ts +23 -0
- package/dist/automated-config/dist/properties.js +9 -2
- 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 +105 -82
- package/dist/automated-config/dist/utils/buildConfigSchema.d.cts +41 -12
- package/dist/automated-config/dist/utils/buildConfigSchema.d.ts +41 -12
- package/dist/automated-config/dist/utils/buildConfigSchema.js +106 -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/getButtonControlHeight.cjs +129 -0
- package/dist/automated-config/dist/utils/getButtonControlHeight.d.cts +133 -0
- package/dist/automated-config/dist/utils/getButtonControlHeight.d.ts +133 -0
- package/dist/automated-config/dist/utils/getButtonControlHeight.js +122 -0
- package/dist/automated-config/dist/utils/getButtonControlHeightPx.cjs +114 -0
- package/dist/automated-config/dist/utils/getButtonControlHeightPx.d.cts +78 -0
- package/dist/automated-config/dist/utils/getButtonControlHeightPx.d.ts +78 -0
- package/dist/automated-config/dist/utils/getButtonControlHeightPx.js +108 -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/iconButtonMatchButtonHeight.cjs +110 -0
- package/dist/automated-config/dist/utils/iconButtonMatchButtonHeight.d.cts +19 -0
- package/dist/automated-config/dist/utils/iconButtonMatchButtonHeight.d.ts +19 -0
- package/dist/automated-config/dist/utils/iconButtonMatchButtonHeight.js +108 -0
- package/dist/automated-config/dist/utils/index.cjs +478 -111
- package/dist/automated-config/dist/utils/index.d.cts +76 -15
- package/dist/automated-config/dist/utils/index.d.ts +76 -15
- package/dist/automated-config/dist/utils/index.js +479 -113
- package/dist/automated-config/dist/utils/isConfiguratorPropertyVisible.cjs +15 -0
- package/dist/automated-config/dist/utils/isConfiguratorPropertyVisible.d.cts +20 -0
- package/dist/automated-config/dist/utils/isConfiguratorPropertyVisible.d.ts +20 -0
- package/dist/automated-config/dist/utils/isConfiguratorPropertyVisible.js +15 -0
- 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/Button.cjs +3 -3
- package/dist/components/client/Button.js +3 -3
- 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/components/client/Menu/Menu.ItemCheckbox.d.cts +1 -1
- package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +1 -1
- package/dist/config/dist/index.cjs +224 -553
- package/dist/config/dist/index.js +224 -553
- 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 +9 -2
- package/dist/css/dist/packages/automated-config/dist/properties.js +9 -2
- 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 +224 -553
- package/dist/css/dist/packages/config/dist/index.js +224 -553
- package/dist/css/dist/utils/optimizeCSS.cjs +59 -0
- package/dist/css/dist/utils/optimizeCSS.js +59 -0
- package/dist/css-tokens/dist/index.cjs +2 -0
- package/dist/css-tokens/dist/index.d.cts +2 -1
- package/dist/css-tokens/dist/index.d.ts +2 -1
- package/dist/css-tokens/dist/index.js +2 -1
- package/dist/index.cjs +48 -0
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +14 -3
- package/dist/styles/styler.d.cts +8 -7
- package/dist/styles/styler.d.ts +8 -7
- 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 +3078 -3089
- package/dist/tailwind-internal/dist/packages/automated-config/dist/generated/generatedConfigs.js +3078 -3089
- package/dist/tailwind-internal/dist/packages/automated-config/dist/properties.cjs +9 -2
- package/dist/tailwind-internal/dist/packages/automated-config/dist/properties.js +9 -2
- 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/getButtonControlHeight.cjs +126 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/getButtonControlHeight.js +123 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/iconButtonMatchButtonHeight.cjs +20 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/iconButtonMatchButtonHeight.js +20 -0
- package/dist/tailwind-internal/dist/packages/automated-config/dist/utils/index.cjs +422 -111
- 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 +423 -112
- 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 +224 -553
- package/dist/tailwind-internal/dist/packages/config/dist/index.js +224 -553
- package/dist/tailwind-internal/dist/packages/css-tokens/dist/index.cjs +2 -0
- package/dist/tailwind-internal/dist/packages/css-tokens/dist/index.js +2 -1
- 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/tailwind-internal/dist/utils/getShadowStyles.d.cts +2 -2
- package/dist/tailwind-internal/dist/utils/getShadowStyles.d.ts +2 -2
- package/dist/tokens/automation/index.cjs +47 -0
- package/dist/tokens/automation/index.d.cts +13 -2
- package/dist/tokens/automation/index.d.ts +13 -2
- package/dist/tokens/automation/index.js +13 -2
- package/dist/tokens/consts/cssTokens.cjs +1 -0
- package/dist/tokens/consts/cssTokens.d.cts +2 -2
- package/dist/tokens/consts/cssTokens.d.ts +2 -2
- package/dist/tokens/consts/cssTokens.js +2 -2
- package/dist/tokens/index.cjs +48 -0
- package/dist/tokens/index.d.cts +15 -4
- package/dist/tokens/index.d.ts +15 -4
- package/dist/tokens/index.js +14 -3
- package/dist/tokens/types.d.cts +1 -1
- package/dist/tokens/types.d.ts +1 -1
- package/dist/uds/generated/componentData.cjs +2177 -2172
- package/dist/uds/generated/componentData.js +2177 -2172
- 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 +2718 -2713
- package/generated/migrationSchemaVersion.ts +1 -1
- package/generated/tailwindPurge.ts +2 -2
- package/package.json +1 -1
|
@@ -1,10 +1,78 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
-
import {
|
|
2
|
+
import { getExcludedPseudoStatesForComponentStateOption } from "./componentStatePseudoStates.js";
|
|
3
3
|
import { generateSchemaKey } from "./generateSchemaKey.js";
|
|
4
|
+
import { resolvePropertyStates } from "./resolvePropertyStates.js";
|
|
4
5
|
import { isVariantConfigWithComponentStates, isVariantConfigWithProperties } from "./variantConfigGuards.js";
|
|
5
6
|
import { getArbitraryFixture, validateArbitraryValue } from "../../../fixtures/src/util.js";
|
|
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 = 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
|
+
}
|
|
73
|
+
function isOptionalInDefaultSchema(property) {
|
|
74
|
+
return property.optionalInDefaultSchema === true;
|
|
75
|
+
}
|
|
8
76
|
/** Resolves the fixture type by finding which value set contains the given value */
|
|
9
77
|
function findFixtureTypeForValue(property, value) {
|
|
10
78
|
const index = property.values.findIndex((arr) => arr.includes(value));
|
|
@@ -17,13 +85,30 @@ function findFixtureTypeForValue(property, value) {
|
|
|
17
85
|
function findFixtureType(property, variantKey) {
|
|
18
86
|
return findFixtureTypeForValue(property, property.defaults[variantKey]);
|
|
19
87
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Walk a set of layers and emit schema entries keyed by layer (no
|
|
90
|
+
* component-state segment). Shared between `VariantConfigWithProperties` and
|
|
91
|
+
* the optional top-level `layers` field on `VariantConfigWithComponentStates`.
|
|
92
|
+
*/
|
|
93
|
+
function emitUniversalLayerSchema(result, layers, variantKey, variantOption, subComponentName) {
|
|
94
|
+
for (const layerKey in layers) {
|
|
95
|
+
const layer = layers[layerKey];
|
|
96
|
+
const schemaKey = generateSchemaKey({
|
|
97
|
+
variantKey,
|
|
98
|
+
variantValue: variantOption,
|
|
99
|
+
layer: layerKey,
|
|
100
|
+
subComponentName
|
|
101
|
+
});
|
|
102
|
+
result.variables[schemaKey] = {};
|
|
103
|
+
for (const propertyKey in layer.properties) {
|
|
104
|
+
const property = layer.properties[propertyKey];
|
|
105
|
+
if (isOptionalInDefaultSchema(property)) continue;
|
|
106
|
+
result.variables[schemaKey] = {
|
|
107
|
+
...result.variables[schemaKey],
|
|
108
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
27
112
|
}
|
|
28
113
|
/** Builds component schema from ComponentConfig at runtime */
|
|
29
114
|
function buildConfigSchema(config) {
|
|
@@ -35,6 +120,7 @@ function buildConfigSchema(config) {
|
|
|
35
120
|
for (const variantKey in config.variants) {
|
|
36
121
|
const variantConfig = config.variants[variantKey];
|
|
37
122
|
for (const variantOption of variantConfig.options) if (isVariantConfigWithComponentStates(variantConfig)) {
|
|
123
|
+
if (variantConfig.layers) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption);
|
|
38
124
|
const componentStates = variantConfig.componentStates;
|
|
39
125
|
for (const componentStateKey in componentStates) {
|
|
40
126
|
const componentState = componentStates[componentStateKey];
|
|
@@ -50,16 +136,10 @@ function buildConfigSchema(config) {
|
|
|
50
136
|
result.variables[schemaKey] = {};
|
|
51
137
|
for (const propertyKey in layer.properties) {
|
|
52
138
|
const property = layer.properties[propertyKey];
|
|
53
|
-
|
|
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, getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption));
|
|
139
|
+
if (isOptionalInDefaultSchema(property)) continue;
|
|
60
140
|
result.variables[schemaKey] = {
|
|
61
141
|
...result.variables[schemaKey],
|
|
62
|
-
|
|
142
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption, getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption))
|
|
63
143
|
};
|
|
64
144
|
}
|
|
65
145
|
}
|
|
@@ -70,43 +150,17 @@ function buildConfigSchema(config) {
|
|
|
70
150
|
result.variables[variantSchemaKey] = result.variables[variantSchemaKey] ?? {};
|
|
71
151
|
for (const propertyKey in variantConfig.variantProperties) {
|
|
72
152
|
const property = variantConfig.variantProperties[propertyKey];
|
|
73
|
-
|
|
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);
|
|
153
|
+
if (isOptionalInDefaultSchema(property)) continue;
|
|
80
154
|
result.variables[variantSchemaKey] = {
|
|
81
155
|
...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 = 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
|
|
156
|
+
[propertyKey]: buildPropertyStateMap({
|
|
157
|
+
label: "",
|
|
158
|
+
properties: {}
|
|
159
|
+
}, property, variantOption)
|
|
107
160
|
};
|
|
108
161
|
}
|
|
109
162
|
}
|
|
163
|
+
emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption);
|
|
110
164
|
}
|
|
111
165
|
}
|
|
112
166
|
if (config.subComponents) {
|
|
@@ -115,6 +169,7 @@ function buildConfigSchema(config) {
|
|
|
115
169
|
const variantConfig = subComponents[subComponentKey].variants[variantKey];
|
|
116
170
|
result.defaults[variantKey] = variantConfig.default;
|
|
117
171
|
for (const variantOption of variantConfig.options) if (isVariantConfigWithComponentStates(variantConfig)) {
|
|
172
|
+
if (variantConfig.layers) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption, subComponentKey);
|
|
118
173
|
const componentStates = variantConfig.componentStates;
|
|
119
174
|
for (const componentStateKey in componentStates) {
|
|
120
175
|
const componentState = componentStates[componentStateKey];
|
|
@@ -131,47 +186,15 @@ function buildConfigSchema(config) {
|
|
|
131
186
|
result.variables[schemaKey] = {};
|
|
132
187
|
for (const propertyKey in layer.properties) {
|
|
133
188
|
const property = layer.properties[propertyKey];
|
|
134
|
-
|
|
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, getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption));
|
|
189
|
+
if (isOptionalInDefaultSchema(property)) continue;
|
|
141
190
|
result.variables[schemaKey] = {
|
|
142
191
|
...result.variables[schemaKey],
|
|
143
|
-
|
|
192
|
+
[propertyKey]: buildPropertyStateMap(layer, property, variantOption, getExcludedPseudoStatesForComponentStateOption(componentState, componentStateOption))
|
|
144
193
|
};
|
|
145
194
|
}
|
|
146
195
|
}
|
|
147
196
|
}
|
|
148
|
-
} else if (isVariantConfigWithProperties(variantConfig))
|
|
149
|
-
const layers = variantConfig.layers;
|
|
150
|
-
for (const layerKey in layers) {
|
|
151
|
-
const layer = layers[layerKey];
|
|
152
|
-
const schemaKey = 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
|
-
}
|
|
197
|
+
} else if (isVariantConfigWithProperties(variantConfig)) emitUniversalLayerSchema(result, variantConfig.layers, variantKey, variantOption, subComponentKey);
|
|
175
198
|
}
|
|
176
199
|
}
|
|
177
200
|
return result;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
const require_StateAxis = require("../types/StateAxis.cjs");
|
|
3
|
+
//#region ../automated-config/dist/utils/canonicalizeStateKey.js
|
|
4
|
+
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
5
|
+
function canonicalizeStateKey(atoms) {
|
|
6
|
+
if (atoms.length === 0) return "rest";
|
|
7
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8
|
+
const modifiers = [];
|
|
9
|
+
const interactives = [];
|
|
10
|
+
for (const atom of atoms) {
|
|
11
|
+
if (seen.has(atom)) continue;
|
|
12
|
+
seen.add(atom);
|
|
13
|
+
if (require_StateAxis.isModifierAtomic(atom)) modifiers.push(atom);
|
|
14
|
+
else if (require_StateAxis.isInteractiveAtomic(atom)) interactives.push(atom);
|
|
15
|
+
else throw new Error(`canonicalizeStateKey received an unrecognized atom "${atom}". Atoms must be in MODIFIER_ATOMICS or INTERACTIVE_ATOMICS — see StateAxis.`);
|
|
16
|
+
}
|
|
17
|
+
modifiers.sort(require_StateAxis.comparePriority);
|
|
18
|
+
interactives.sort(require_StateAxis.comparePriority);
|
|
19
|
+
const ordered = [...modifiers, ...interactives];
|
|
20
|
+
return ordered.length === 0 ? "rest" : ordered.join("&");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Splits a canonical (or legacy) state key into its atomic parts.
|
|
24
|
+
* `'rest'` and `''` produce an empty array.
|
|
25
|
+
*/
|
|
26
|
+
function splitStateKey(stateKey) {
|
|
27
|
+
if (!stateKey || stateKey === "rest") return [];
|
|
28
|
+
return stateKey.split("&");
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.canonicalizeStateKey = canonicalizeStateKey;
|
|
32
|
+
exports.splitStateKey = splitStateKey;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { AtomicState } from "../types/StateAxis.cjs";
|
|
3
|
+
import { PossibleStatesWithRest } from "../types/ComponentConfig.cjs";
|
|
4
|
+
|
|
5
|
+
//#region ../automated-config/dist/utils/canonicalizeStateKey.d.ts
|
|
6
|
+
//#region src/utils/canonicalizeStateKey.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Returns the canonical state-key string for a list of atomic states.
|
|
9
|
+
*
|
|
10
|
+
* Canonical ordering rules:
|
|
11
|
+
* 1. Modifier atomics come first, sorted by `STATE_PRIORITY` (weakest first).
|
|
12
|
+
* 2. Interactive atomics come last, also sorted by `STATE_PRIORITY`. Multiple
|
|
13
|
+
* interactives can co-occur (e.g. `focus-within` + `hover`), so a key may
|
|
14
|
+
* carry more than one.
|
|
15
|
+
* Sorting by priority — not alphabetically — keeps a key's atom order aligned
|
|
16
|
+
* with the emission/cascade order in `resolvePropertyStates` and
|
|
17
|
+
* `resolveSlotByCascade`, so one ordering convention holds end-to-end. (For
|
|
18
|
+
* Input the two orders coincide; they diverge only for atoms like `visited`,
|
|
19
|
+
* `autofill`, or `focus-visible` whose priority rank differs from their
|
|
20
|
+
* alphabetical position.)
|
|
21
|
+
* 3. Duplicates are removed.
|
|
22
|
+
* 4. Unknown atoms throw. Every caller passes atoms already validated via
|
|
23
|
+
* `isModifierAtomic`/`isInteractiveAtomic` (or pulled from
|
|
24
|
+
* `MODIFIER_ATOMICS`/`INTERACTIVE_ATOMICS`), so an unrecognized atom signals
|
|
25
|
+
* a caller bug and fails loudly rather than producing a silent bad key.
|
|
26
|
+
*
|
|
27
|
+
* Examples:
|
|
28
|
+
* canonicalizeStateKey(['hover', 'invalid']) // 'invalid&hover'
|
|
29
|
+
* canonicalizeStateKey(['invalid', 'hover']) // 'invalid&hover' (same)
|
|
30
|
+
* canonicalizeStateKey(['hover']) // 'hover'
|
|
31
|
+
* canonicalizeStateKey([]) // 'rest'
|
|
32
|
+
*
|
|
33
|
+
* The narrow public overload returns `PossibleStatesWithRest` so callers
|
|
34
|
+
* passing known atomics get a usable state-key type back without having to
|
|
35
|
+
* cast the result at the call site. The looser overload remains for callers
|
|
36
|
+
* that may pass unvalidated strings; its return is widened to `string` since
|
|
37
|
+
* those inputs can't guarantee a canonical-key result. The runtime body
|
|
38
|
+
* type-checks against the loose overload and validates atoms at runtime.
|
|
39
|
+
*/
|
|
40
|
+
declare function canonicalizeStateKey(atoms: readonly AtomicState[]): PossibleStatesWithRest;
|
|
41
|
+
declare function canonicalizeStateKey(atoms: readonly string[]): string;
|
|
42
|
+
/**
|
|
43
|
+
* Splits a canonical (or legacy) state key into its atomic parts.
|
|
44
|
+
* `'rest'` and `''` produce an empty array.
|
|
45
|
+
*/
|
|
46
|
+
declare function splitStateKey(stateKey: string): string[]; //#endregion
|
|
47
|
+
//#endregion
|
|
48
|
+
export { canonicalizeStateKey, splitStateKey };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { AtomicState } from "../types/StateAxis.js";
|
|
3
|
+
import { PossibleStatesWithRest } from "../types/ComponentConfig.js";
|
|
4
|
+
|
|
5
|
+
//#region ../automated-config/dist/utils/canonicalizeStateKey.d.ts
|
|
6
|
+
//#region src/utils/canonicalizeStateKey.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Returns the canonical state-key string for a list of atomic states.
|
|
9
|
+
*
|
|
10
|
+
* Canonical ordering rules:
|
|
11
|
+
* 1. Modifier atomics come first, sorted by `STATE_PRIORITY` (weakest first).
|
|
12
|
+
* 2. Interactive atomics come last, also sorted by `STATE_PRIORITY`. Multiple
|
|
13
|
+
* interactives can co-occur (e.g. `focus-within` + `hover`), so a key may
|
|
14
|
+
* carry more than one.
|
|
15
|
+
* Sorting by priority — not alphabetically — keeps a key's atom order aligned
|
|
16
|
+
* with the emission/cascade order in `resolvePropertyStates` and
|
|
17
|
+
* `resolveSlotByCascade`, so one ordering convention holds end-to-end. (For
|
|
18
|
+
* Input the two orders coincide; they diverge only for atoms like `visited`,
|
|
19
|
+
* `autofill`, or `focus-visible` whose priority rank differs from their
|
|
20
|
+
* alphabetical position.)
|
|
21
|
+
* 3. Duplicates are removed.
|
|
22
|
+
* 4. Unknown atoms throw. Every caller passes atoms already validated via
|
|
23
|
+
* `isModifierAtomic`/`isInteractiveAtomic` (or pulled from
|
|
24
|
+
* `MODIFIER_ATOMICS`/`INTERACTIVE_ATOMICS`), so an unrecognized atom signals
|
|
25
|
+
* a caller bug and fails loudly rather than producing a silent bad key.
|
|
26
|
+
*
|
|
27
|
+
* Examples:
|
|
28
|
+
* canonicalizeStateKey(['hover', 'invalid']) // 'invalid&hover'
|
|
29
|
+
* canonicalizeStateKey(['invalid', 'hover']) // 'invalid&hover' (same)
|
|
30
|
+
* canonicalizeStateKey(['hover']) // 'hover'
|
|
31
|
+
* canonicalizeStateKey([]) // 'rest'
|
|
32
|
+
*
|
|
33
|
+
* The narrow public overload returns `PossibleStatesWithRest` so callers
|
|
34
|
+
* passing known atomics get a usable state-key type back without having to
|
|
35
|
+
* cast the result at the call site. The looser overload remains for callers
|
|
36
|
+
* that may pass unvalidated strings; its return is widened to `string` since
|
|
37
|
+
* those inputs can't guarantee a canonical-key result. The runtime body
|
|
38
|
+
* type-checks against the loose overload and validates atoms at runtime.
|
|
39
|
+
*/
|
|
40
|
+
declare function canonicalizeStateKey(atoms: readonly AtomicState[]): PossibleStatesWithRest;
|
|
41
|
+
declare function canonicalizeStateKey(atoms: readonly string[]): string;
|
|
42
|
+
/**
|
|
43
|
+
* Splits a canonical (or legacy) state key into its atomic parts.
|
|
44
|
+
* `'rest'` and `''` produce an empty array.
|
|
45
|
+
*/
|
|
46
|
+
declare function splitStateKey(stateKey: string): string[]; //#endregion
|
|
47
|
+
//#endregion
|
|
48
|
+
export { canonicalizeStateKey, splitStateKey };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
import { comparePriority, isInteractiveAtomic, isModifierAtomic } from "../types/StateAxis.js";
|
|
3
|
+
//#region ../automated-config/dist/utils/canonicalizeStateKey.js
|
|
4
|
+
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
5
|
+
function canonicalizeStateKey(atoms) {
|
|
6
|
+
if (atoms.length === 0) return "rest";
|
|
7
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8
|
+
const modifiers = [];
|
|
9
|
+
const interactives = [];
|
|
10
|
+
for (const atom of atoms) {
|
|
11
|
+
if (seen.has(atom)) continue;
|
|
12
|
+
seen.add(atom);
|
|
13
|
+
if (isModifierAtomic(atom)) modifiers.push(atom);
|
|
14
|
+
else if (isInteractiveAtomic(atom)) interactives.push(atom);
|
|
15
|
+
else throw new Error(`canonicalizeStateKey received an unrecognized atom "${atom}". Atoms must be in MODIFIER_ATOMICS or INTERACTIVE_ATOMICS — see StateAxis.`);
|
|
16
|
+
}
|
|
17
|
+
modifiers.sort(comparePriority);
|
|
18
|
+
interactives.sort(comparePriority);
|
|
19
|
+
const ordered = [...modifiers, ...interactives];
|
|
20
|
+
return ordered.length === 0 ? "rest" : ordered.join("&");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Splits a canonical (or legacy) state key into its atomic parts.
|
|
24
|
+
* `'rest'` and `''` produce an empty array.
|
|
25
|
+
*/
|
|
26
|
+
function splitStateKey(stateKey) {
|
|
27
|
+
if (!stateKey || stateKey === "rest") return [];
|
|
28
|
+
return stateKey.split("&");
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { canonicalizeStateKey, splitStateKey };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
const require_index = require("../../../css-tokens/dist/index.cjs");
|
|
3
|
+
const require_mapTextVariantFixtureToValue = require("../mapTextVariantFixtureToValue.cjs");
|
|
4
|
+
const require_properties = require("../properties.cjs");
|
|
5
|
+
const require_iconButtonMatchButtonHeight = require("./iconButtonMatchButtonHeight.cjs");
|
|
6
|
+
//#region ../automated-config/dist/utils/getButtonControlHeight.js
|
|
7
|
+
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
8
|
+
/** Sizes where IconButton control height should match Button. */
|
|
9
|
+
const SHARED_BUTTON_ICONBUTTON_SIZES = new Set([
|
|
10
|
+
"xs",
|
|
11
|
+
"sm",
|
|
12
|
+
"md",
|
|
13
|
+
"lg"
|
|
14
|
+
]);
|
|
15
|
+
function getButtonIconSizeVar({ schema, iconLayerKey, state, theme }) {
|
|
16
|
+
const iconSizeValue = schema.variables?.[iconLayerKey]?.size?.[state]?.value;
|
|
17
|
+
if (typeof iconSizeValue === "string" && iconSizeValue) return theme(require_properties.configurableProperties.iconSize.twThemePath("iconSizes", iconSizeValue));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Button content box: max(icon size, text line-height).
|
|
21
|
+
* Matches Figma auto-layout and keeps IconButton height aligned with Button.
|
|
22
|
+
*/
|
|
23
|
+
function getButtonControlContentSize({ schema, rootLayerKey, iconLayerKey, state, theme }) {
|
|
24
|
+
const iconSizeVar = getButtonIconSizeVar({
|
|
25
|
+
schema,
|
|
26
|
+
iconLayerKey,
|
|
27
|
+
state,
|
|
28
|
+
theme
|
|
29
|
+
});
|
|
30
|
+
const textVariantValue = schema.variables?.[rootLayerKey]?.textVariant?.[state]?.value;
|
|
31
|
+
if (iconSizeVar && typeof textVariantValue === "string" && textVariantValue) return `max(${iconSizeVar}, ${theme(require_mapTextVariantFixtureToValue.mapTextVariantFixtureToValue("lineHeight")("textVariants", textVariantValue))})`;
|
|
32
|
+
if (iconSizeVar) return iconSizeVar;
|
|
33
|
+
}
|
|
34
|
+
/** `round(up, …, 1px)` matches Math.ceil in getButtonControlHeightPx and Figma hug height. */
|
|
35
|
+
function formatControlHeightCalc(calcExpression) {
|
|
36
|
+
return `round(up, ${calcExpression}, 1px)`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Button control height: vertical padding on both sides plus max(icon size, text line-height).
|
|
40
|
+
*/
|
|
41
|
+
function getButtonControlHeight({ paddingVertical, schema, rootLayerKey, iconLayerKey, state, theme }) {
|
|
42
|
+
const contentSize = getButtonControlContentSize({
|
|
43
|
+
schema,
|
|
44
|
+
rootLayerKey,
|
|
45
|
+
iconLayerKey,
|
|
46
|
+
state,
|
|
47
|
+
theme
|
|
48
|
+
});
|
|
49
|
+
if (!contentSize) return;
|
|
50
|
+
return formatControlHeightCalc(`calc(2 * ${paddingVertical} + ${contentSize})`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* IconButton control height: uniform padding plus icon size only (no typography).
|
|
54
|
+
*/
|
|
55
|
+
function getIconButtonControlHeight({ paddingVertical, schema, iconLayerKey, state, theme }) {
|
|
56
|
+
const iconSizeVar = getButtonIconSizeVar({
|
|
57
|
+
schema,
|
|
58
|
+
iconLayerKey,
|
|
59
|
+
state,
|
|
60
|
+
theme
|
|
61
|
+
});
|
|
62
|
+
if (!iconSizeVar) return;
|
|
63
|
+
return formatControlHeightCalc(`calc(2 * ${paddingVertical} + ${iconSizeVar})`);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Layout line-height for button root: max(icon size, text line-height).
|
|
67
|
+
*/
|
|
68
|
+
function getButtonContentLineHeight({ schema, rootLayerKey, iconLayerKey, state, theme }) {
|
|
69
|
+
return getButtonControlContentSize({
|
|
70
|
+
schema,
|
|
71
|
+
rootLayerKey,
|
|
72
|
+
iconLayerKey,
|
|
73
|
+
state,
|
|
74
|
+
theme
|
|
75
|
+
}) ?? "1em";
|
|
76
|
+
}
|
|
77
|
+
function applyButtonControlHeightDeclarations({ cssDeclarations, paddingVertical, schema, rootLayerKey, iconLayerKey, state, theme }) {
|
|
78
|
+
const controlHeight = rootLayerKey ? getButtonControlHeight({
|
|
79
|
+
paddingVertical,
|
|
80
|
+
schema,
|
|
81
|
+
rootLayerKey,
|
|
82
|
+
iconLayerKey,
|
|
83
|
+
state,
|
|
84
|
+
theme
|
|
85
|
+
}) : getIconButtonControlHeight({
|
|
86
|
+
paddingVertical,
|
|
87
|
+
schema,
|
|
88
|
+
iconLayerKey,
|
|
89
|
+
state,
|
|
90
|
+
theme
|
|
91
|
+
});
|
|
92
|
+
if (controlHeight) {
|
|
93
|
+
cssDeclarations[require_index.BUTTON_CONTROL_HEIGHT_VAR] = controlHeight;
|
|
94
|
+
cssDeclarations.height = `var(${require_index.BUTTON_CONTROL_HEIGHT_VAR})`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function applyIconButtonSquareDimensions(cssDeclarations) {
|
|
98
|
+
if (cssDeclarations[require_index.BUTTON_CONTROL_HEIGHT_VAR]) cssDeclarations.width = `var(${require_index.BUTTON_CONTROL_HEIGHT_VAR})`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* IconButton height for xs–lg mirrors Button (padding + max(icon, line-height)).
|
|
102
|
+
* xl uses icon-only height from IconButton tokens.
|
|
103
|
+
*/
|
|
104
|
+
function applyIconButtonControlHeightDeclarations({ cssDeclarations, paddingVertical, iconButtonSchema, buttonHeightReferenceSchema, variantValue, iconLayerKey: _iconLayerKey, state, theme }) {
|
|
105
|
+
if (buttonHeightReferenceSchema && SHARED_BUTTON_ICONBUTTON_SIZES.has(variantValue) && require_iconButtonMatchButtonHeight.isIconButtonMatchButtonHeightEnabled(iconButtonSchema, variantValue)) {
|
|
106
|
+
const buttonRootLayerKey = `size/${variantValue}/root`;
|
|
107
|
+
const buttonIconLayerKey = `size/${variantValue}/icon`;
|
|
108
|
+
const buttonSpacingValue = buttonHeightReferenceSchema.variables?.[buttonRootLayerKey]?.spacingVertical?.[state]?.value;
|
|
109
|
+
applyButtonControlHeightDeclarations({
|
|
110
|
+
cssDeclarations,
|
|
111
|
+
paddingVertical: typeof buttonSpacingValue === "string" && buttonSpacingValue ? theme(require_properties.configurableProperties.spacingVertical.twThemePath("spacingAliases", buttonSpacingValue)) : paddingVertical,
|
|
112
|
+
schema: buttonHeightReferenceSchema,
|
|
113
|
+
rootLayerKey: buttonRootLayerKey,
|
|
114
|
+
iconLayerKey: buttonIconLayerKey,
|
|
115
|
+
state,
|
|
116
|
+
theme
|
|
117
|
+
});
|
|
118
|
+
applyIconButtonSquareDimensions(cssDeclarations);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
exports.SHARED_BUTTON_ICONBUTTON_SIZES = SHARED_BUTTON_ICONBUTTON_SIZES;
|
|
123
|
+
exports.applyButtonControlHeightDeclarations = applyButtonControlHeightDeclarations;
|
|
124
|
+
exports.applyIconButtonControlHeightDeclarations = applyIconButtonControlHeightDeclarations;
|
|
125
|
+
exports.getButtonContentLineHeight = getButtonContentLineHeight;
|
|
126
|
+
exports.getButtonControlContentSize = getButtonControlContentSize;
|
|
127
|
+
exports.getButtonControlHeight = getButtonControlHeight;
|
|
128
|
+
exports.getButtonIconSizeVar = getButtonIconSizeVar;
|
|
129
|
+
exports.getIconButtonControlHeight = getIconButtonControlHeight;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
import { IconButtonMatchButtonHeightConfig } from "./iconButtonMatchButtonHeight.cjs";
|
|
3
|
+
|
|
4
|
+
//#region ../automated-config/dist/utils/getButtonControlHeight.d.ts
|
|
5
|
+
//#region src/utils/getButtonControlHeight.d.ts
|
|
6
|
+
type ThemeFn = (path: string) => string;
|
|
7
|
+
/** Sizes where IconButton control height should match Button. */
|
|
8
|
+
declare const SHARED_BUTTON_ICONBUTTON_SIZES: Set<string>;
|
|
9
|
+
type ButtonControlSchema = IconButtonMatchButtonHeightConfig & {
|
|
10
|
+
variables?: Record<string, Record<string, Record<string, {
|
|
11
|
+
value?: unknown;
|
|
12
|
+
}>>>;
|
|
13
|
+
};
|
|
14
|
+
declare function getButtonIconSizeVar({
|
|
15
|
+
schema,
|
|
16
|
+
iconLayerKey,
|
|
17
|
+
state,
|
|
18
|
+
theme
|
|
19
|
+
}: {
|
|
20
|
+
schema: ButtonControlSchema;
|
|
21
|
+
iconLayerKey: string;
|
|
22
|
+
state: string;
|
|
23
|
+
theme: ThemeFn;
|
|
24
|
+
}): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Button content box: max(icon size, text line-height).
|
|
27
|
+
* Matches Figma auto-layout and keeps IconButton height aligned with Button.
|
|
28
|
+
*/
|
|
29
|
+
declare function getButtonControlContentSize({
|
|
30
|
+
schema,
|
|
31
|
+
rootLayerKey,
|
|
32
|
+
iconLayerKey,
|
|
33
|
+
state,
|
|
34
|
+
theme
|
|
35
|
+
}: {
|
|
36
|
+
schema: ButtonControlSchema;
|
|
37
|
+
rootLayerKey: string;
|
|
38
|
+
iconLayerKey: string;
|
|
39
|
+
state: string;
|
|
40
|
+
theme: ThemeFn;
|
|
41
|
+
}): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Button control height: vertical padding on both sides plus max(icon size, text line-height).
|
|
44
|
+
*/
|
|
45
|
+
declare function getButtonControlHeight({
|
|
46
|
+
paddingVertical,
|
|
47
|
+
schema,
|
|
48
|
+
rootLayerKey,
|
|
49
|
+
iconLayerKey,
|
|
50
|
+
state,
|
|
51
|
+
theme
|
|
52
|
+
}: {
|
|
53
|
+
paddingVertical: string;
|
|
54
|
+
schema: ButtonControlSchema;
|
|
55
|
+
rootLayerKey: string;
|
|
56
|
+
iconLayerKey: string;
|
|
57
|
+
state: string;
|
|
58
|
+
theme: ThemeFn;
|
|
59
|
+
}): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* IconButton control height: uniform padding plus icon size only (no typography).
|
|
62
|
+
*/
|
|
63
|
+
declare function getIconButtonControlHeight({
|
|
64
|
+
paddingVertical,
|
|
65
|
+
schema,
|
|
66
|
+
iconLayerKey,
|
|
67
|
+
state,
|
|
68
|
+
theme
|
|
69
|
+
}: {
|
|
70
|
+
paddingVertical: string;
|
|
71
|
+
schema: ButtonControlSchema;
|
|
72
|
+
iconLayerKey: string;
|
|
73
|
+
state: string;
|
|
74
|
+
theme: ThemeFn;
|
|
75
|
+
}): string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Layout line-height for button root: max(icon size, text line-height).
|
|
78
|
+
*/
|
|
79
|
+
declare function getButtonContentLineHeight({
|
|
80
|
+
schema,
|
|
81
|
+
rootLayerKey,
|
|
82
|
+
iconLayerKey,
|
|
83
|
+
state,
|
|
84
|
+
theme
|
|
85
|
+
}: {
|
|
86
|
+
schema: ButtonControlSchema;
|
|
87
|
+
rootLayerKey: string;
|
|
88
|
+
iconLayerKey: string;
|
|
89
|
+
state: string;
|
|
90
|
+
theme: ThemeFn;
|
|
91
|
+
}): string;
|
|
92
|
+
declare function applyButtonControlHeightDeclarations({
|
|
93
|
+
cssDeclarations,
|
|
94
|
+
paddingVertical,
|
|
95
|
+
schema,
|
|
96
|
+
rootLayerKey,
|
|
97
|
+
iconLayerKey,
|
|
98
|
+
state,
|
|
99
|
+
theme
|
|
100
|
+
}: {
|
|
101
|
+
cssDeclarations: Record<string, string>;
|
|
102
|
+
paddingVertical: string;
|
|
103
|
+
schema: ButtonControlSchema;
|
|
104
|
+
rootLayerKey?: string;
|
|
105
|
+
iconLayerKey: string;
|
|
106
|
+
state: string;
|
|
107
|
+
theme: ThemeFn;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* IconButton height for xs–lg mirrors Button (padding + max(icon, line-height)).
|
|
111
|
+
* xl uses icon-only height from IconButton tokens.
|
|
112
|
+
*/
|
|
113
|
+
declare function applyIconButtonControlHeightDeclarations({
|
|
114
|
+
cssDeclarations,
|
|
115
|
+
paddingVertical,
|
|
116
|
+
iconButtonSchema,
|
|
117
|
+
buttonHeightReferenceSchema,
|
|
118
|
+
variantValue,
|
|
119
|
+
iconLayerKey: _iconLayerKey,
|
|
120
|
+
state,
|
|
121
|
+
theme
|
|
122
|
+
}: {
|
|
123
|
+
cssDeclarations: Record<string, string>;
|
|
124
|
+
paddingVertical: string;
|
|
125
|
+
iconButtonSchema: ButtonControlSchema;
|
|
126
|
+
buttonHeightReferenceSchema?: ButtonControlSchema;
|
|
127
|
+
variantValue: string;
|
|
128
|
+
iconLayerKey: string;
|
|
129
|
+
state: string;
|
|
130
|
+
theme: ThemeFn;
|
|
131
|
+
}): void; //#endregion
|
|
132
|
+
//#endregion
|
|
133
|
+
export { type ButtonControlSchema, SHARED_BUTTON_ICONBUTTON_SIZES, applyButtonControlHeightDeclarations, applyIconButtonControlHeightDeclarations, getButtonContentLineHeight, getButtonControlContentSize, getButtonControlHeight, getButtonIconSizeVar, getIconButtonControlHeight };
|