@yahoo/uds-v5-wip 1.61.0 → 1.62.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/config/dist/AssetGroup.d.ts +75 -0
- package/dist/config/dist/AssetGroup.js +114 -0
- package/dist/config/dist/Component.d.ts +309 -0
- package/dist/config/dist/Component.js +897 -0
- package/dist/config/dist/ComponentGroup.d.ts +21 -0
- package/dist/config/dist/ComponentGroup.js +46 -0
- package/dist/config/dist/CompositeStyle.d.ts +28 -0
- package/dist/config/dist/CompositeStyle.js +52 -0
- package/dist/config/dist/Config.d.ts +422 -0
- package/dist/config/dist/Config.js +1426 -0
- package/dist/config/dist/Mode.d.ts +42 -0
- package/dist/config/dist/Mode.js +81 -0
- package/dist/config/dist/Modifier.d.ts +52 -0
- package/dist/config/dist/Modifier.js +97 -0
- package/dist/config/dist/MotionDef.d.ts +50 -0
- package/dist/config/dist/MotionDef.js +97 -0
- package/dist/config/dist/Props.d.ts +235 -126
- package/dist/config/dist/Provider.d.ts +21 -0
- package/dist/config/dist/Provider.js +14 -0
- package/dist/config/dist/StyleProp.d.ts +113 -0
- package/dist/config/dist/StyleProp.js +197 -0
- package/dist/config/dist/Token.d.ts +56 -0
- package/dist/config/dist/Token.js +112 -0
- package/dist/config/dist/TokenGroup.d.ts +33 -0
- package/dist/config/dist/TokenGroup.js +68 -0
- package/dist/config/dist/asset-kind.d.ts +56 -0
- package/dist/config/dist/asset-kind.js +29 -0
- package/dist/config/dist/brands.d.ts +31 -0
- package/dist/config/dist/brands.js +20 -0
- package/dist/config/dist/captureCallerPath.d.ts +49 -0
- package/dist/config/dist/captureCallerPath.js +95 -0
- package/dist/config/dist/colorExpressions.d.ts +132 -0
- package/dist/config/dist/colorExpressions.js +148 -0
- package/dist/config/dist/defineAssetGroup.d.ts +158 -0
- package/dist/config/dist/defineAssetGroup.js +263 -0
- package/dist/config/dist/defineProvider.d.ts +30 -0
- package/dist/config/dist/defineProvider.js +60 -0
- package/dist/config/dist/element-marker.d.ts +55 -0
- package/dist/config/dist/element-marker.js +113 -0
- package/dist/config/dist/entity-utils.d.ts +27 -0
- package/dist/config/dist/entity-utils.js +105 -0
- package/dist/config/dist/factories.d.ts +707 -0
- package/dist/config/dist/factories.js +393 -0
- package/dist/config/dist/foreign-component-name.js +42 -0
- package/dist/config/dist/index.d.ts +30 -21
- package/dist/config/dist/index.js +26 -14
- package/dist/config/dist/interpolate.d.ts +21 -0
- package/dist/config/dist/interpolate.js +10 -0
- package/dist/config/dist/markers.d.ts +218 -0
- package/dist/config/dist/markers.js +67 -0
- package/dist/config/dist/refs.d.ts +143 -69
- package/dist/config/dist/refs.js +95 -113
- package/dist/config/dist/token-override-rows.d.ts +67 -0
- package/dist/config/dist/token-override-rows.js +223 -0
- package/dist/config/dist/tokenValueType.js +138 -0
- package/dist/config/dist/types/css-properties.d.ts +132 -122
- package/dist/config/dist/types/css-property-keywords.d.ts +157 -0
- package/dist/config/dist/types/css-property-keywords.js +616 -0
- package/dist/config/dist/types/css-values.d.ts +18 -16
- package/dist/config/dist/types.d.ts +688 -66
- package/dist/config/dist/units.d.ts +15 -0
- package/dist/config/dist/units.js +16 -0
- package/dist/config.d.ts +31 -22
- package/dist/config.js +28 -16
- package/dist/loader/dist/loader/artifacts.js +26 -9
- package/dist/loader/dist/loader.d.ts +11 -23
- package/dist/loader/dist/loader.js +54 -99
- package/dist/loader/dist/next.js +3 -3
- package/dist/loader/dist/transform-runner.js +1 -8
- package/dist/loader/dist/unplugin.d.ts +2 -2
- package/dist/loader/dist/unplugin.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/dist/index.js +1 -0
- package/dist/utils/dist/motion-utils/resolveMotionState.d.ts +35 -0
- package/dist/utils/dist/motion-utils/resolveMotionState.js +33 -0
- package/dist/utils/dist/string-utils/componentClassName.d.ts +41 -8
- package/dist/utils/dist/string-utils/componentClassName.js +48 -11
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +3 -2
- package/package.json +3 -3
- package/dist/codegen/dist/loader/getLoaderArtifacts.js +0 -2
- package/dist/config/dist/bindRender.d.ts +0 -16
- package/dist/config/dist/bindRender.js +0 -310
- package/dist/config/dist/className.d.ts +0 -54
- package/dist/config/dist/className.js +0 -77
- package/dist/config/dist/component-config.d.ts +0 -862
- package/dist/config/dist/component-config.js +0 -163
- package/dist/config/dist/component-refs.d.ts +0 -121
- package/dist/config/dist/createConfig.d.ts +0 -456
- package/dist/config/dist/createConfig.js +0 -503
- package/dist/config/dist/createStyler.d.ts +0 -35
- package/dist/config/dist/createStyler.js +0 -93
- package/dist/config/dist/defineComponent.d.ts +0 -317
- package/dist/config/dist/defineComponent.js +0 -264
- package/dist/config/dist/defineCompositeStyle.d.ts +0 -93
- package/dist/config/dist/defineCompositeStyle.js +0 -18
- package/dist/config/dist/defineMotionConfig.d.ts +0 -152
- package/dist/config/dist/definePreview.d.ts +0 -45
- package/dist/config/dist/definePreview.js +0 -35
- package/dist/config/dist/defineStyleProp.d.ts +0 -289
- package/dist/config/dist/defineStyleProp.js +0 -61
- package/dist/config/dist/merge-utils.js +0 -51
- package/dist/config/dist/propertyAcceptedTypes.d.ts +0 -19
- package/dist/config/dist/propertyAcceptedTypes.js +0 -220
- package/dist/config/dist/resolveCompoundProps.d.ts +0 -65
- package/dist/config/dist/resolveCompoundProps.js +0 -120
- package/dist/config/dist/resolveStyleProp.d.ts +0 -157
- package/dist/config/dist/resolveStyleProp.js +0 -260
- package/dist/config/dist/runtime-registry.js +0 -37
- package/dist/config/dist/serialize.d.ts +0 -47
- package/dist/config/dist/serialize.js +0 -111
- package/dist/config/dist/sniffTokenType.d.ts +0 -7
- package/dist/config/dist/sniffTokenType.js +0 -67
- package/dist/config/dist/style-prop-runtime.d.ts +0 -75
- package/dist/config/dist/style-prop-runtime.js +0 -390
- package/dist/loader/dist/loader/internal-meta.js +0 -59
- package/dist/loader/dist/loader/lower-new-api-primitive.js +0 -252
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
//#region ../config/dist/propertyAcceptedTypes.js
|
|
2
|
-
const LENGTH_PCT = { types: [
|
|
3
|
-
"length",
|
|
4
|
-
"percentage",
|
|
5
|
-
"length-percentage"
|
|
6
|
-
] };
|
|
7
|
-
const LENGTH_PCT_AUTO = {
|
|
8
|
-
types: [
|
|
9
|
-
"length",
|
|
10
|
-
"percentage",
|
|
11
|
-
"length-percentage"
|
|
12
|
-
],
|
|
13
|
-
literals: ["auto"]
|
|
14
|
-
};
|
|
15
|
-
const SIZING = {
|
|
16
|
-
types: [
|
|
17
|
-
"length",
|
|
18
|
-
"percentage",
|
|
19
|
-
"length-percentage"
|
|
20
|
-
],
|
|
21
|
-
literals: [
|
|
22
|
-
"auto",
|
|
23
|
-
"min-content",
|
|
24
|
-
"max-content",
|
|
25
|
-
"fit-content"
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
const SIZING_WITH_NONE = {
|
|
29
|
-
types: [
|
|
30
|
-
"length",
|
|
31
|
-
"percentage",
|
|
32
|
-
"length-percentage"
|
|
33
|
-
],
|
|
34
|
-
literals: [
|
|
35
|
-
"auto",
|
|
36
|
-
"min-content",
|
|
37
|
-
"max-content",
|
|
38
|
-
"fit-content",
|
|
39
|
-
"none"
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
const LENGTH_ONLY = { types: ["length"] };
|
|
43
|
-
const COLOR_ONLY = {
|
|
44
|
-
types: ["color"],
|
|
45
|
-
literals: ["transparent", "currentColor"]
|
|
46
|
-
};
|
|
47
|
-
const TIME_ONLY = { types: ["time"] };
|
|
48
|
-
const NUMBER_ONLY = { types: ["number", "integer"] };
|
|
49
|
-
const ANGLE_ONLY = { types: ["angle"] };
|
|
50
|
-
/**
|
|
51
|
-
* CSS-wide keywords — accepted on every CSS property per the CSS spec.
|
|
52
|
-
* Synthesizer marks these as `$type: 'string'` so they don't match the
|
|
53
|
-
* property's type-based accept rule; they pass via this set instead.
|
|
54
|
-
*/
|
|
55
|
-
const CSS_WIDE_KEYWORDS = new Set([
|
|
56
|
-
"inherit",
|
|
57
|
-
"initial",
|
|
58
|
-
"unset",
|
|
59
|
-
"revert",
|
|
60
|
-
"revert-layer",
|
|
61
|
-
"transparent",
|
|
62
|
-
"currentColor",
|
|
63
|
-
"currentcolor"
|
|
64
|
-
]);
|
|
65
|
-
const LENGTH_PCT_PROPS = [
|
|
66
|
-
"gap",
|
|
67
|
-
"column-gap",
|
|
68
|
-
"row-gap",
|
|
69
|
-
"padding",
|
|
70
|
-
"padding-top",
|
|
71
|
-
"padding-right",
|
|
72
|
-
"padding-bottom",
|
|
73
|
-
"padding-left",
|
|
74
|
-
"padding-block",
|
|
75
|
-
"padding-inline",
|
|
76
|
-
"padding-inline-start",
|
|
77
|
-
"padding-inline-end",
|
|
78
|
-
"scroll-margin",
|
|
79
|
-
"scroll-margin-top",
|
|
80
|
-
"scroll-margin-bottom",
|
|
81
|
-
"scroll-margin-block",
|
|
82
|
-
"scroll-margin-inline",
|
|
83
|
-
"scroll-margin-inline-start",
|
|
84
|
-
"scroll-margin-inline-end",
|
|
85
|
-
"scroll-padding",
|
|
86
|
-
"scroll-padding-top",
|
|
87
|
-
"scroll-padding-bottom",
|
|
88
|
-
"scroll-padding-block",
|
|
89
|
-
"scroll-padding-inline",
|
|
90
|
-
"scroll-padding-inline-start",
|
|
91
|
-
"scroll-padding-inline-end",
|
|
92
|
-
"border-radius",
|
|
93
|
-
"border-top-left-radius",
|
|
94
|
-
"border-top-right-radius",
|
|
95
|
-
"border-bottom-left-radius",
|
|
96
|
-
"border-bottom-right-radius",
|
|
97
|
-
"border-start-start-radius",
|
|
98
|
-
"border-start-end-radius",
|
|
99
|
-
"border-end-start-radius",
|
|
100
|
-
"border-end-end-radius",
|
|
101
|
-
"text-indent",
|
|
102
|
-
"font-size"
|
|
103
|
-
];
|
|
104
|
-
const LENGTH_PCT_AUTO_PROPS = [
|
|
105
|
-
"margin",
|
|
106
|
-
"margin-top",
|
|
107
|
-
"margin-right",
|
|
108
|
-
"margin-bottom",
|
|
109
|
-
"margin-left",
|
|
110
|
-
"margin-block",
|
|
111
|
-
"margin-inline",
|
|
112
|
-
"margin-inline-start",
|
|
113
|
-
"margin-inline-end",
|
|
114
|
-
"top",
|
|
115
|
-
"right",
|
|
116
|
-
"bottom",
|
|
117
|
-
"left",
|
|
118
|
-
"inset",
|
|
119
|
-
"inset-block",
|
|
120
|
-
"inset-inline"
|
|
121
|
-
];
|
|
122
|
-
const SIZING_PROPS = [
|
|
123
|
-
"width",
|
|
124
|
-
"height",
|
|
125
|
-
"min-width",
|
|
126
|
-
"min-height"
|
|
127
|
-
];
|
|
128
|
-
const SIZING_WITH_NONE_PROPS = ["max-width", "max-height"];
|
|
129
|
-
const LENGTH_ONLY_PROPS = [
|
|
130
|
-
"border-width",
|
|
131
|
-
"border-top-width",
|
|
132
|
-
"border-right-width",
|
|
133
|
-
"border-bottom-width",
|
|
134
|
-
"border-left-width",
|
|
135
|
-
"border-block-width",
|
|
136
|
-
"border-inline-width",
|
|
137
|
-
"border-inline-start-width",
|
|
138
|
-
"border-inline-end-width",
|
|
139
|
-
"outline-width",
|
|
140
|
-
"outline-offset",
|
|
141
|
-
"border-spacing",
|
|
142
|
-
"letter-spacing",
|
|
143
|
-
"text-underline-offset",
|
|
144
|
-
"text-decoration-thickness"
|
|
145
|
-
];
|
|
146
|
-
const COLOR_PROPS = [
|
|
147
|
-
"color",
|
|
148
|
-
"background-color",
|
|
149
|
-
"border-color",
|
|
150
|
-
"border-top-color",
|
|
151
|
-
"border-right-color",
|
|
152
|
-
"border-bottom-color",
|
|
153
|
-
"border-left-color",
|
|
154
|
-
"border-block-color",
|
|
155
|
-
"border-inline-color",
|
|
156
|
-
"border-inline-start-color",
|
|
157
|
-
"border-inline-end-color",
|
|
158
|
-
"outline-color",
|
|
159
|
-
"text-decoration-color",
|
|
160
|
-
"caret-color",
|
|
161
|
-
"fill",
|
|
162
|
-
"stroke"
|
|
163
|
-
];
|
|
164
|
-
const TIME_PROPS = ["transition-duration", "transition-delay"];
|
|
165
|
-
const NUMBER_PROPS = [
|
|
166
|
-
"flex-grow",
|
|
167
|
-
"flex-shrink",
|
|
168
|
-
"order",
|
|
169
|
-
"z-index",
|
|
170
|
-
"-webkit-line-clamp"
|
|
171
|
-
];
|
|
172
|
-
const ANGLE_PROPS = ["rotate"];
|
|
173
|
-
const PROPERTY_ACCEPTED_TYPES = new Map([
|
|
174
|
-
...LENGTH_PCT_PROPS.map((p) => [p, LENGTH_PCT]),
|
|
175
|
-
...LENGTH_PCT_AUTO_PROPS.map((p) => [p, LENGTH_PCT_AUTO]),
|
|
176
|
-
...SIZING_PROPS.map((p) => [p, SIZING]),
|
|
177
|
-
...SIZING_WITH_NONE_PROPS.map((p) => [p, SIZING_WITH_NONE]),
|
|
178
|
-
...LENGTH_ONLY_PROPS.map((p) => [p, LENGTH_ONLY]),
|
|
179
|
-
...COLOR_PROPS.map((p) => [p, COLOR_ONLY]),
|
|
180
|
-
...TIME_PROPS.map((p) => [p, TIME_ONLY]),
|
|
181
|
-
...NUMBER_PROPS.map((p) => [p, NUMBER_ONLY]),
|
|
182
|
-
...ANGLE_PROPS.map((p) => [p, ANGLE_ONLY]),
|
|
183
|
-
["font-weight", { types: [
|
|
184
|
-
"font-weight",
|
|
185
|
-
"number",
|
|
186
|
-
"integer"
|
|
187
|
-
] }],
|
|
188
|
-
["font-family", { types: ["font-family"] }],
|
|
189
|
-
["transition-timing-function", { types: ["easing-function"] }],
|
|
190
|
-
["box-shadow", {
|
|
191
|
-
types: ["shadow"],
|
|
192
|
-
literals: ["none"]
|
|
193
|
-
}],
|
|
194
|
-
["text-shadow", {
|
|
195
|
-
types: ["shadow"],
|
|
196
|
-
literals: ["none"]
|
|
197
|
-
}],
|
|
198
|
-
["list-style-image", { types: ["url", "image"] }],
|
|
199
|
-
["aspect-ratio", { types: ["ratio", "number"] }],
|
|
200
|
-
["opacity", { types: ["number", "percentage"] }],
|
|
201
|
-
["z-index", {
|
|
202
|
-
types: ["integer", "number"],
|
|
203
|
-
literals: ["auto"]
|
|
204
|
-
}]
|
|
205
|
-
]);
|
|
206
|
-
/**
|
|
207
|
-
* Whether a token with the given detected value type AND raw string value
|
|
208
|
-
* is accepted by the CSS property. Returns `true` for any property not in
|
|
209
|
-
* the table.
|
|
210
|
-
*/
|
|
211
|
-
function isTokenAcceptedByProperty(cssProperty, valueType, rawValue) {
|
|
212
|
-
if (CSS_WIDE_KEYWORDS.has(rawValue)) return true;
|
|
213
|
-
const entry = PROPERTY_ACCEPTED_TYPES.get(cssProperty);
|
|
214
|
-
if (!entry) return true;
|
|
215
|
-
if (valueType && entry.types?.includes(valueType)) return true;
|
|
216
|
-
if (entry.literals?.includes(rawValue)) return true;
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
|
-
export { PROPERTY_ACCEPTED_TYPES, isTokenAcceptedByProperty };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { CompoundPropsEntry, HiddenMarker, LayerInput } from "./component-config.js";
|
|
2
|
-
|
|
3
|
-
//#region ../config/dist/resolveCompoundProps.d.ts
|
|
4
|
-
//#region src/resolveCompoundProps.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Per-layer entry on the resolved overrides map. Either a flat style/
|
|
7
|
-
* prop bag (for style overrides) or the hide marker. Downstream
|
|
8
|
-
* consumers can branch on `__kind === 'hidden'` to pick between
|
|
9
|
-
* `display: none` and stripping the layer from the rendered tree.
|
|
10
|
-
*/
|
|
11
|
-
type ResolvedLayerOverride = HiddenMarker | Record<string, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Per-layer map of overrides that should win at the given active-prop
|
|
14
|
-
* combination.
|
|
15
|
-
*/
|
|
16
|
-
type ResolvedCompoundOverrides = Record<string, ResolvedLayerOverride>;
|
|
17
|
-
/**
|
|
18
|
-
* Find every `compoundProps` entry whose `when` clause is satisfied by
|
|
19
|
-
* the active props and merge them into a single per-layer override map.
|
|
20
|
-
*
|
|
21
|
-
* Conflict resolution:
|
|
22
|
-
* - For style-map overrides, per-property: higher `specificity(when)`
|
|
23
|
-
* wins; tie-break is later position in source order.
|
|
24
|
-
* - For a `hidden()` layer marker, the layer-level decision: most-
|
|
25
|
-
* specific hidden marker wins; tie-break is later source order. The
|
|
26
|
-
* marker takes precedence over style overrides at the same layer,
|
|
27
|
-
* since a hidden layer's styles are moot anyway.
|
|
28
|
-
*
|
|
29
|
-
* Returns an empty object when nothing matches — callers can treat it
|
|
30
|
-
* as a no-op without a separate `undefined` check.
|
|
31
|
-
*/
|
|
32
|
-
declare function resolveCompoundProps<TLayers extends Record<string, LayerInput>, TProps extends Record<string, any> = Record<string, any>>(compoundProps: readonly CompoundPropsEntry<TLayers, TProps>[] | undefined, activeProps: Record<string, unknown>): ResolvedCompoundOverrides;
|
|
33
|
-
/**
|
|
34
|
-
* Fold a `resolveCompoundProps` result into an existing per-layer
|
|
35
|
-
* bundle of resolved style-prop values (the output of the enum/bool
|
|
36
|
-
* merge for the active prop combination).
|
|
37
|
-
*
|
|
38
|
-
* A `HiddenMarker` on a layer rewrites that layer's bundle to
|
|
39
|
-
* `{ __hidden: true }` — a sentinel the render fn checks at the JSX
|
|
40
|
-
* site to skip rendering the layer entirely, rather than emitting a
|
|
41
|
-
* `display: none` declaration that would leave a layout-occupying
|
|
42
|
-
* DOM node. Use {@link isLayerHidden} for the check:
|
|
43
|
-
*
|
|
44
|
-
* .render(({ props }) => (
|
|
45
|
-
* <a {...props.root}>
|
|
46
|
-
* {!isLayerHidden(props.endIcon) && <span {...props.endIcon} />}
|
|
47
|
-
* </a>
|
|
48
|
-
* ))
|
|
49
|
-
*
|
|
50
|
-
* Style-map overrides merge per-key into the existing bundle. The
|
|
51
|
-
* input bundles are not mutated — every layer that receives any
|
|
52
|
-
* override is copied first.
|
|
53
|
-
*/
|
|
54
|
-
declare function applyCompoundProps(layerBundles: Record<string, Record<string, unknown>>, overrides: ResolvedCompoundOverrides): Record<string, Record<string, unknown>>;
|
|
55
|
-
/**
|
|
56
|
-
* Type guard used by render fns to skip rendering a hidden layer:
|
|
57
|
-
*
|
|
58
|
-
* {!isLayerHidden(props.endIcon) && <span {...props.endIcon} />}
|
|
59
|
-
*
|
|
60
|
-
* Returns `true` when the bundle carries the `__hidden: true`
|
|
61
|
-
* sentinel written by `applyCompoundProps`.
|
|
62
|
-
*/
|
|
63
|
-
declare function isLayerHidden(bundle: Record<string, unknown> | undefined): boolean; //#endregion
|
|
64
|
-
//#endregion
|
|
65
|
-
export { ResolvedCompoundOverrides, ResolvedLayerOverride, applyCompoundProps, isLayerHidden, resolveCompoundProps };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
//#region ../config/dist/resolveCompoundProps.js
|
|
2
|
-
function whenMatches(when, activeProps) {
|
|
3
|
-
for (const key in when) {
|
|
4
|
-
if (!Object.hasOwn(when, key)) continue;
|
|
5
|
-
if (activeProps[key] !== when[key]) return false;
|
|
6
|
-
}
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
function specificity(when) {
|
|
10
|
-
let count = 0;
|
|
11
|
-
for (const key in when) if (Object.hasOwn(when, key)) count++;
|
|
12
|
-
return count;
|
|
13
|
-
}
|
|
14
|
-
function isHiddenMarker(value) {
|
|
15
|
-
return typeof value === "object" && value !== null && value.__kind === "hidden";
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Find every `compoundProps` entry whose `when` clause is satisfied by
|
|
19
|
-
* the active props and merge them into a single per-layer override map.
|
|
20
|
-
*
|
|
21
|
-
* Conflict resolution:
|
|
22
|
-
* - For style-map overrides, per-property: higher `specificity(when)`
|
|
23
|
-
* wins; tie-break is later position in source order.
|
|
24
|
-
* - For a `hidden()` layer marker, the layer-level decision: most-
|
|
25
|
-
* specific hidden marker wins; tie-break is later source order. The
|
|
26
|
-
* marker takes precedence over style overrides at the same layer,
|
|
27
|
-
* since a hidden layer's styles are moot anyway.
|
|
28
|
-
*
|
|
29
|
-
* Returns an empty object when nothing matches — callers can treat it
|
|
30
|
-
* as a no-op without a separate `undefined` check.
|
|
31
|
-
*/
|
|
32
|
-
function resolveCompoundProps(compoundProps, activeProps) {
|
|
33
|
-
if (!compoundProps || compoundProps.length === 0) return {};
|
|
34
|
-
const styleResolved = {};
|
|
35
|
-
const stylePropSpecificity = {};
|
|
36
|
-
const hiddenSpecificity = {};
|
|
37
|
-
for (const entry of compoundProps) {
|
|
38
|
-
if (!whenMatches(entry.when, activeProps)) continue;
|
|
39
|
-
const entrySpecificity = specificity(entry.when);
|
|
40
|
-
for (const layerName in entry.layers) {
|
|
41
|
-
if (!Object.hasOwn(entry.layers, layerName)) continue;
|
|
42
|
-
const layerOverride = entry.layers[layerName];
|
|
43
|
-
if (!layerOverride) continue;
|
|
44
|
-
if (isHiddenMarker(layerOverride)) {
|
|
45
|
-
const prev = hiddenSpecificity[layerName];
|
|
46
|
-
if (prev === void 0 || entrySpecificity >= prev) hiddenSpecificity[layerName] = entrySpecificity;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const styleMap = layerOverride;
|
|
50
|
-
styleResolved[layerName] ??= {};
|
|
51
|
-
stylePropSpecificity[layerName] ??= {};
|
|
52
|
-
for (const propKey in styleMap) {
|
|
53
|
-
if (!Object.hasOwn(styleMap, propKey)) continue;
|
|
54
|
-
const prevSpecificity = stylePropSpecificity[layerName][propKey];
|
|
55
|
-
if (prevSpecificity === void 0 || entrySpecificity >= prevSpecificity) {
|
|
56
|
-
styleResolved[layerName][propKey] = styleMap[propKey];
|
|
57
|
-
stylePropSpecificity[layerName][propKey] = entrySpecificity;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const resolved = {};
|
|
63
|
-
for (const layerName in styleResolved) resolved[layerName] = styleResolved[layerName];
|
|
64
|
-
for (const layerName in hiddenSpecificity) resolved[layerName] = { __kind: "hidden" };
|
|
65
|
-
return resolved;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Fold a `resolveCompoundProps` result into an existing per-layer
|
|
69
|
-
* bundle of resolved style-prop values (the output of the enum/bool
|
|
70
|
-
* merge for the active prop combination).
|
|
71
|
-
*
|
|
72
|
-
* A `HiddenMarker` on a layer rewrites that layer's bundle to
|
|
73
|
-
* `{ __hidden: true }` — a sentinel the render fn checks at the JSX
|
|
74
|
-
* site to skip rendering the layer entirely, rather than emitting a
|
|
75
|
-
* `display: none` declaration that would leave a layout-occupying
|
|
76
|
-
* DOM node. Use {@link isLayerHidden} for the check:
|
|
77
|
-
*
|
|
78
|
-
* .render(({ props }) => (
|
|
79
|
-
* <a {...props.root}>
|
|
80
|
-
* {!isLayerHidden(props.endIcon) && <span {...props.endIcon} />}
|
|
81
|
-
* </a>
|
|
82
|
-
* ))
|
|
83
|
-
*
|
|
84
|
-
* Style-map overrides merge per-key into the existing bundle. The
|
|
85
|
-
* input bundles are not mutated — every layer that receives any
|
|
86
|
-
* override is copied first.
|
|
87
|
-
*/
|
|
88
|
-
function applyCompoundProps(layerBundles, overrides) {
|
|
89
|
-
if (Object.keys(overrides).length === 0) return layerBundles;
|
|
90
|
-
const result = { ...layerBundles };
|
|
91
|
-
for (const layerName in overrides) {
|
|
92
|
-
if (!Object.hasOwn(overrides, layerName)) continue;
|
|
93
|
-
const override = overrides[layerName];
|
|
94
|
-
if (!override) continue;
|
|
95
|
-
if (isHiddenMarker(override)) {
|
|
96
|
-
result[layerName] = { __hidden: true };
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const merged = { ...result[layerName] ?? {} };
|
|
100
|
-
for (const propKey in override) {
|
|
101
|
-
if (!Object.hasOwn(override, propKey)) continue;
|
|
102
|
-
merged[propKey] = override[propKey];
|
|
103
|
-
}
|
|
104
|
-
result[layerName] = merged;
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Type guard used by render fns to skip rendering a hidden layer:
|
|
110
|
-
*
|
|
111
|
-
* {!isLayerHidden(props.endIcon) && <span {...props.endIcon} />}
|
|
112
|
-
*
|
|
113
|
-
* Returns `true` when the bundle carries the `__hidden: true`
|
|
114
|
-
* sentinel written by `applyCompoundProps`.
|
|
115
|
-
*/
|
|
116
|
-
function isLayerHidden(bundle) {
|
|
117
|
-
return bundle?.__hidden === true;
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
export { applyCompoundProps, isLayerHidden, resolveCompoundProps };
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { CssValueTypeName } from "./types/css-values.js";
|
|
2
|
-
import { ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
|
|
3
|
-
import { TokenType } from "./types.js";
|
|
4
|
-
import { UdsConfigData } from "./createConfig.js";
|
|
5
|
-
|
|
6
|
-
//#region ../config/dist/resolveStyleProp.d.ts
|
|
7
|
-
//#region src/resolveStyleProp.d.ts
|
|
8
|
-
interface ResolvedToken {
|
|
9
|
-
/** The token's raw key, e.g. `'brand'`. */
|
|
10
|
-
readonly name: string;
|
|
11
|
-
/** Resolved CSS value, e.g. `'#1167f4'` or `'1rem'`. */
|
|
12
|
-
readonly value: string;
|
|
13
|
-
/** Detected CSS value type, used for filtering. `undefined` if not detectable. */
|
|
14
|
-
readonly valueType: CssValueTypeName | undefined;
|
|
15
|
-
/** The token group's namespace (or cssPrefix fallback) the token came from. */
|
|
16
|
-
readonly group: string;
|
|
17
|
-
/**
|
|
18
|
-
* Style-prop-local namespace, set only when the token was sourced via a
|
|
19
|
-
* `NamespacedTokenGroup` (`{ ref: tokenGroup('X'), namespace: 'Y' }`).
|
|
20
|
-
* Used to disambiguate when two groups feed the same prop and share keys.
|
|
21
|
-
*/
|
|
22
|
-
readonly namespace?: string;
|
|
23
|
-
/**
|
|
24
|
-
* The user-facing key the consumer writes in JSX. For un-namespaced
|
|
25
|
-
* groups this is just `name`; for namespaced groups, `'${namespace}.${name}'`.
|
|
26
|
-
*/
|
|
27
|
-
readonly qualifiedName: string;
|
|
28
|
-
/**
|
|
29
|
-
* The token name with characters that aren't class-name-safe replaced
|
|
30
|
-
* (e.g. `/` → `_`, `.` → `_`). Used as the trailing segment of generated
|
|
31
|
-
* `@utility` class names and CSS variable names. Mirrors
|
|
32
|
-
* `safeTokenName` from `@uds/utils`.
|
|
33
|
-
*/
|
|
34
|
-
readonly safeName: string;
|
|
35
|
-
/**
|
|
36
|
-
* Full CSS variable reference for this token at config-build time, e.g.
|
|
37
|
-
* `'--uds-bg-brand'`. Built as `--{config.prefix}-{group.cssPrefix}-{safeName}`,
|
|
38
|
-
* falling back to omit the config prefix when it's empty.
|
|
39
|
-
*/
|
|
40
|
-
readonly cssVar: string;
|
|
41
|
-
/**
|
|
42
|
-
* Per-modifier value overrides carried verbatim from the source
|
|
43
|
-
* `AtomicTokenValue`. Used by CSS-gen to emit mode override blocks
|
|
44
|
-
* (e.g. `.dark { --uds-bg-brand: ... }`).
|
|
45
|
-
*/
|
|
46
|
-
readonly modifiers?: Record<string, string>;
|
|
47
|
-
}
|
|
48
|
-
interface ResolvedStyleProp {
|
|
49
|
-
/** The JSX prop name — the map key from `registerStyleProps({...})`. */
|
|
50
|
-
readonly propName: string;
|
|
51
|
-
/** The CSS property (or properties) this prop writes — passed through
|
|
52
|
-
* verbatim from the source `defineStyleProp` input. Single string for
|
|
53
|
-
* direct props, array for fan-out props (e.g. `borderRadiusStart` →
|
|
54
|
-
* both start-side corners). Readers normalize at the call site
|
|
55
|
-
* (`Array.isArray(p) ? p : [p]`) when iteration matters. */
|
|
56
|
-
readonly cssProperty: string | readonly string[];
|
|
57
|
-
readonly classPrefix: string;
|
|
58
|
-
/**
|
|
59
|
-
* Set on opacity-sibling entries to the JSX-prop name of the parent
|
|
60
|
-
* color prop they compose with (`bg` for `bgOpacity`). Authored via
|
|
61
|
-
* `.withOpacity({ as })` on the parent's `defineStyleProp`. Consumers
|
|
62
|
-
* use this to merge `bg="primary"` + `bgOpacity="75"` into a single
|
|
63
|
-
* `bg-primary_75` class.
|
|
64
|
-
*/
|
|
65
|
-
readonly pairedWith?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Class-name separator between the parent's token suffix and the
|
|
68
|
-
* opacity value (`bg-primary_75` vs. `bg-primary/75`). Only set when
|
|
69
|
-
* `pairedWith` is set. Defaults to `'_'` at the authoring layer.
|
|
70
|
-
*/
|
|
71
|
-
readonly separator?: string;
|
|
72
|
-
readonly tokens: readonly ResolvedToken[];
|
|
73
|
-
readonly literals: readonly (string | number | boolean)[];
|
|
74
|
-
/** Alias → CSS-value map for `{ alias, value }` entries in `values`.
|
|
75
|
-
* When an author writes `flexDirection='col'`, the CSS emitter looks
|
|
76
|
-
* this up to write `flex-direction: column` instead of `flex-direction: col`.
|
|
77
|
-
* Object values represent composite styles (`truncate=true` mapping to
|
|
78
|
-
* three CSS properties at once). Only populated when at least one
|
|
79
|
-
* entry used the alias form. */
|
|
80
|
-
readonly literalAliases?: Readonly<Record<string, string | Readonly<Record<string, string>>>>;
|
|
81
|
-
readonly arbitrary: ArbitrarySpec | undefined;
|
|
82
|
-
readonly metadata: StylePropMetadata;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Structurally-loose input shape for the resolver. Any `StyleProp<P>` from
|
|
86
|
-
* `defineStyleProp` is assignable to this. Defined locally so the
|
|
87
|
-
* resolver's signature doesn't expand `ValuesEntry<P>` over the full CSS
|
|
88
|
-
* property union (TS2590).
|
|
89
|
-
*/
|
|
90
|
-
interface ResolveStylePropInput {
|
|
91
|
-
readonly kind?: 'styleProp';
|
|
92
|
-
readonly cssProperty: string | readonly string[];
|
|
93
|
-
readonly classPrefix: string;
|
|
94
|
-
readonly values?: readonly unknown[];
|
|
95
|
-
readonly arbitrary?: ArbitrarySpec;
|
|
96
|
-
readonly cssType?: CssValueTypeName;
|
|
97
|
-
readonly metadata?: StylePropMetadata;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Minimal input shapes for {@link detectTokenValueType} — see that
|
|
101
|
-
* function's docs for the algorithmic contract.
|
|
102
|
-
* `AtomicToken['tokens'][number]` and `AtomicToken` are structurally
|
|
103
|
-
* assignable to these, so codegen's existing call sites keep working
|
|
104
|
-
* unchanged.
|
|
105
|
-
*/
|
|
106
|
-
interface DetectTokenValueTypeInput {
|
|
107
|
-
readonly value: string;
|
|
108
|
-
readonly type?: TokenType;
|
|
109
|
-
}
|
|
110
|
-
interface DetectTokenValueTypeGroup {
|
|
111
|
-
readonly type?: TokenType;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Detect a token's CSS value type. Resolution order:
|
|
115
|
-
* 1. Per-token `type` override.
|
|
116
|
-
* 2. Group-level `type`.
|
|
117
|
-
*
|
|
118
|
-
* When the resolved type is `'length-percentage'` and the raw value ends in
|
|
119
|
-
* `%`, narrow to `'percentage'`; otherwise narrow to `'length'`. When the
|
|
120
|
-
* resolved type is `'string'`, narrow shadow-like values to `'shadow'` and
|
|
121
|
-
* ratio-shaped values to `'ratio'`.
|
|
122
|
-
*
|
|
123
|
-
* Exported so Studio (and any other runtime consumer) can resolve a cell's
|
|
124
|
-
* effective `CssValueTypeName`.
|
|
125
|
-
*
|
|
126
|
-
* The input shapes ({@link DetectTokenValueTypeInput} /
|
|
127
|
-
* {@link DetectTokenValueTypeGroup}) are intentionally minimal: the resolver
|
|
128
|
-
* reads only `token.value`, `token.type`, and `group.type` — never walks
|
|
129
|
-
* `group.tokens`, never checks that `token` is inside `group`. Typing them
|
|
130
|
-
* as full `AtomicToken` would force trimmed-shape consumers (Studio's
|
|
131
|
-
* `TokenEntry`) to either round-trip back to the source group or `as`-assert
|
|
132
|
-
* past the type system.
|
|
133
|
-
*/
|
|
134
|
-
declare function detectTokenValueType(token: DetectTokenValueTypeInput, group: DetectTokenValueTypeGroup): CssValueTypeName | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Resolve a style prop against the given resolved UDS config. Unknown group
|
|
137
|
-
* refs are silently dropped from `tokens` (callers can detect this by
|
|
138
|
-
* comparing input refs vs. resolved tokens if they need to surface a
|
|
139
|
-
* config-build warning).
|
|
140
|
-
*
|
|
141
|
-
* @param propName - The JSX prop name (the map key from `registerStyleProps`).
|
|
142
|
-
*/
|
|
143
|
-
declare function resolveStyleProp(propName: string, styleProp: ResolveStylePropInput, config: UdsConfigData): ResolvedStyleProp;
|
|
144
|
-
/**
|
|
145
|
-
* Walk a resolved config's `resolvedStyleProps` and return the
|
|
146
|
-
* color-prop → opacity-sibling-prop map. Built from each opacity
|
|
147
|
-
* sibling's `pairedWith` field (set by the resolver when expanding a
|
|
148
|
-
* `.withOpacity({ as })` parent). Returns an empty object when no
|
|
149
|
-
* pairings exist.
|
|
150
|
-
*
|
|
151
|
-
* Replaces the legacy `colorPropToOpacityProp` table that lived in
|
|
152
|
-
* `@uds/core` — consumers (codegen safelist generation, runtime
|
|
153
|
-
* `getStyles`, loader style-transform) should call this instead.
|
|
154
|
-
*/
|
|
155
|
-
declare function getColorOpacityMap(config: UdsConfigData): Record<string, string>; //#endregion
|
|
156
|
-
//#endregion
|
|
157
|
-
export { DetectTokenValueTypeGroup, DetectTokenValueTypeInput, ResolvedStyleProp, ResolvedToken, detectTokenValueType, getColorOpacityMap, resolveStyleProp };
|