@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
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { attachSourcePath, captureCallerPath } from "./captureCallerPath.js";
|
|
2
|
+
import { composite, styleProp, tag, token } from "./refs.js";
|
|
3
|
+
import { darken, lighten } from "./colorExpressions.js";
|
|
4
|
+
import "./defineProvider.js";
|
|
5
|
+
//#region ../config/dist/factories.js
|
|
6
|
+
function defineTokenGroup(t) {
|
|
7
|
+
const out = {
|
|
8
|
+
tokens: t,
|
|
9
|
+
metadata(meta) {
|
|
10
|
+
if (meta.label !== void 0) out.label = meta.label;
|
|
11
|
+
if (meta.description !== void 0) out.description = meta.description;
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
attachSourcePath(out, captureCallerPath());
|
|
16
|
+
Object.defineProperty(out, "metadata", {
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: out.metadata
|
|
21
|
+
});
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function defineModifier(t) {
|
|
25
|
+
return attachSourcePath(t, captureCallerPath());
|
|
26
|
+
}
|
|
27
|
+
function defineMode(t) {
|
|
28
|
+
return attachSourcePath(t, captureCallerPath());
|
|
29
|
+
}
|
|
30
|
+
function defineCompositeStyle(t) {
|
|
31
|
+
return attachSourcePath(t, captureCallerPath());
|
|
32
|
+
}
|
|
33
|
+
function defineMotion(t) {
|
|
34
|
+
return attachSourcePath(t, captureCallerPath());
|
|
35
|
+
}
|
|
36
|
+
function defineComponentGroup(t) {
|
|
37
|
+
return attachSourcePath(t, captureCallerPath());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Author a style-prop spec. `P` is inferred from `cssProperty` so the
|
|
41
|
+
* `values` array narrows against the chosen CSS property's accepted
|
|
42
|
+
* keyword union (`'transparent'` is OK for `border-color`, errors for
|
|
43
|
+
* `padding`). For custom properties (`--foo`), `values` accepts open
|
|
44
|
+
* strings — `cssType` constrains the runtime value space instead.
|
|
45
|
+
*
|
|
46
|
+
* Returns the spec with a non-enumerable `.metadata({...})` chain;
|
|
47
|
+
* the chain merges the supplied bag into `spec.metadata` so multiple
|
|
48
|
+
* `.metadata({...})` calls accumulate.
|
|
49
|
+
*/
|
|
50
|
+
function defineStyleProp(spec) {
|
|
51
|
+
const attached = attachSourcePath(spec, captureCallerPath());
|
|
52
|
+
Object.defineProperty(attached, "metadata", {
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value(meta) {
|
|
57
|
+
attached.metadata = {
|
|
58
|
+
...attached.metadata ?? {},
|
|
59
|
+
...meta
|
|
60
|
+
};
|
|
61
|
+
return attached;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(attached, "withOpacity", {
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value(opacitySpec) {
|
|
69
|
+
attached.opacityPair = {
|
|
70
|
+
as: opacitySpec.as,
|
|
71
|
+
values: opacitySpec.values,
|
|
72
|
+
separator: opacitySpec.separator ?? "_",
|
|
73
|
+
ref: opacitySpec.as
|
|
74
|
+
};
|
|
75
|
+
return attached;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return attached;
|
|
79
|
+
}
|
|
80
|
+
function slot(pathOrOptions, options) {
|
|
81
|
+
let marker;
|
|
82
|
+
const openOptions = typeof pathOrOptions === "object" ? pathOrOptions : void 0;
|
|
83
|
+
const pathOrLayer = typeof pathOrOptions === "string" ? pathOrOptions : void 0;
|
|
84
|
+
const valueType = openOptions?.type ?? options?.type;
|
|
85
|
+
if (pathOrLayer === void 0) marker = { __kind: "slot" };
|
|
86
|
+
else if (options?.prop !== void 0) marker = {
|
|
87
|
+
__kind: "slot",
|
|
88
|
+
layer: pathOrLayer,
|
|
89
|
+
layerProp: options.prop
|
|
90
|
+
};
|
|
91
|
+
else {
|
|
92
|
+
const slash = pathOrLayer.indexOf("/");
|
|
93
|
+
marker = slash === -1 ? {
|
|
94
|
+
__kind: "slot",
|
|
95
|
+
layer: pathOrLayer,
|
|
96
|
+
layerProp: "children"
|
|
97
|
+
} : {
|
|
98
|
+
__kind: "slot",
|
|
99
|
+
layer: pathOrLayer.slice(0, slash),
|
|
100
|
+
layerProp: pathOrLayer.slice(slash + 1)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (valueType !== void 0) Object.defineProperty(marker, "__valueType", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: valueType
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(marker, "required", {
|
|
110
|
+
enumerable: false,
|
|
111
|
+
configurable: true,
|
|
112
|
+
writable: true,
|
|
113
|
+
value() {
|
|
114
|
+
Object.defineProperty(marker, "__required", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
configurable: true,
|
|
117
|
+
writable: true,
|
|
118
|
+
value: true
|
|
119
|
+
});
|
|
120
|
+
return marker;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(marker, "accepts", {
|
|
124
|
+
enumerable: false,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true,
|
|
127
|
+
value(component) {
|
|
128
|
+
Object.defineProperty(marker, "__accepts", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: Array.isArray(component) ? component : [component]
|
|
133
|
+
});
|
|
134
|
+
return marker;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(marker, "transform", {
|
|
138
|
+
enumerable: false,
|
|
139
|
+
configurable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
value(fn) {
|
|
142
|
+
Object.defineProperty(marker, "__transform", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: fn
|
|
147
|
+
});
|
|
148
|
+
return marker;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return marker;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Attach a chainable `.required()` method to a marker that flips
|
|
155
|
+
* `__required: true` and returns the same marker reference (so further
|
|
156
|
+
* chaining still works).
|
|
157
|
+
*/
|
|
158
|
+
function attachRequired(marker) {
|
|
159
|
+
Object.defineProperty(marker, "required", {
|
|
160
|
+
enumerable: false,
|
|
161
|
+
configurable: true,
|
|
162
|
+
writable: true,
|
|
163
|
+
value() {
|
|
164
|
+
Object.defineProperty(marker, "__required", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: true
|
|
169
|
+
});
|
|
170
|
+
return marker;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return marker;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Boolean-prop binding. Codegen emits the prop as `<name>?: boolean`
|
|
177
|
+
* and routes presence/absence into a per-layer `data-${name}` attribute
|
|
178
|
+
* the runtime selects on. Mirrors the old `@uds/config` `helpers.boolean()`.
|
|
179
|
+
*
|
|
180
|
+
* The optional `values` argument carries per-state per-layer styles
|
|
181
|
+
* (`{ true: { root: {...} }, false: { root: {...} } }`) — codegen emits
|
|
182
|
+
* one variant CSS class per layer per state, same as `variant({...})`.
|
|
183
|
+
*
|
|
184
|
+
* `.required()` flips the prop to mandatory at JSX call sites.
|
|
185
|
+
*/
|
|
186
|
+
function boolean(values) {
|
|
187
|
+
return attachRequired(values === void 0 ? { __kind: "boolean" } : {
|
|
188
|
+
__kind: "boolean",
|
|
189
|
+
values
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Cross-layer style override — `_hover: layer('close', { opacity: 1 })`
|
|
194
|
+
* declares "when this layer is hovered, apply these styles to the
|
|
195
|
+
* named layer". Codegen emits a descendant-combinator rule pointing
|
|
196
|
+
* from the source layer's selector to the target layer's selector.
|
|
197
|
+
* Mirrors the old `@uds/config` `helpers.layer()`.
|
|
198
|
+
*/
|
|
199
|
+
function layer(layerName, styles) {
|
|
200
|
+
return {
|
|
201
|
+
__kind: "layer",
|
|
202
|
+
layer: layerName,
|
|
203
|
+
styles
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function variant(values, defaultValue) {
|
|
207
|
+
return attachRequired(defaultValue === void 0 ? {
|
|
208
|
+
__kind: "variant",
|
|
209
|
+
values
|
|
210
|
+
} : {
|
|
211
|
+
__kind: "variant",
|
|
212
|
+
values,
|
|
213
|
+
default: defaultValue
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Wide-string prop binding. Codegen emits the prop as `<name>?: string`
|
|
218
|
+
* (or required when chained with `.required()`). No CSS effect — use
|
|
219
|
+
* this for free-form text props (URLs, labels). When you want a
|
|
220
|
+
* constrained list of accepted strings, reach for the array form of
|
|
221
|
+
* `variant(...)` instead.
|
|
222
|
+
*/
|
|
223
|
+
function string() {
|
|
224
|
+
return attachRequired({ __kind: "string" });
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Wide-number prop binding. Codegen emits the prop as `<name>?: number`
|
|
228
|
+
* (or required when chained with `.required()`). No CSS effect — use
|
|
229
|
+
* this for free-form numeric props (tabIndex, count). When you want a
|
|
230
|
+
* constrained list of accepted numbers, reach for the array form of
|
|
231
|
+
* `variant(...)` instead.
|
|
232
|
+
*/
|
|
233
|
+
function number() {
|
|
234
|
+
return attachRequired({ __kind: "number" });
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Axis marker for `.preview({ matrix: { columns, rows } })`. The
|
|
238
|
+
* `kind` field discriminates between prop axes (varies a JSX prop
|
|
239
|
+
* across the grid) and modifier axes (toggles a `_${name}` modifier
|
|
240
|
+
* across the grid). Studio reads these to build the canvas preview;
|
|
241
|
+
* codegen round-trips them verbatim through `Component.preview`.
|
|
242
|
+
*
|
|
243
|
+
* `.nest(child)` builds a 2-D nesting — the outer axis steps once
|
|
244
|
+
* per child-axis sweep. Mirrors the old `@uds/config` matrix shape.
|
|
245
|
+
*/
|
|
246
|
+
function makePreviewAxis(source, nested) {
|
|
247
|
+
return {
|
|
248
|
+
__kind: "previewAxis",
|
|
249
|
+
...source,
|
|
250
|
+
...nested !== void 0 ? { nested } : {},
|
|
251
|
+
nest(child) {
|
|
252
|
+
return makePreviewAxis(source, child);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
const configHelpers = {
|
|
257
|
+
slot,
|
|
258
|
+
variant,
|
|
259
|
+
boolean,
|
|
260
|
+
string,
|
|
261
|
+
number,
|
|
262
|
+
layer,
|
|
263
|
+
composite,
|
|
264
|
+
styleProp,
|
|
265
|
+
token,
|
|
266
|
+
darken,
|
|
267
|
+
lighten
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Normalize the `props()` argument to a rule list: a flat bag becomes a
|
|
271
|
+
* single unconditional rule; a rule array passes through.
|
|
272
|
+
*/
|
|
273
|
+
function normalizePropsRules(arg) {
|
|
274
|
+
return Array.isArray(arg) ? arg : [{ props: arg }];
|
|
275
|
+
}
|
|
276
|
+
const previewHelpers = {
|
|
277
|
+
prop: (name) => makePreviewAxis({
|
|
278
|
+
kind: "prop",
|
|
279
|
+
prop: name
|
|
280
|
+
}),
|
|
281
|
+
modifier: (name) => makePreviewAxis({
|
|
282
|
+
kind: "modifier",
|
|
283
|
+
modifier: name
|
|
284
|
+
}),
|
|
285
|
+
props: (arg) => makePreviewAxis({
|
|
286
|
+
kind: "props",
|
|
287
|
+
rules: normalizePropsRules(arg)
|
|
288
|
+
})
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Fields merged shallowly when `.config(cb)` runs — each subkey from a
|
|
292
|
+
* later call overlays the same subkey on the seed (so `defaultProps:
|
|
293
|
+
* { as: 'path' }` doesn't drop Box's inherited defaults). Other fields
|
|
294
|
+
* (`compoundProps`, `motion` scalar) overwrite.
|
|
295
|
+
*/
|
|
296
|
+
const MERGEABLE_NESTED_FIELDS = new Set([
|
|
297
|
+
"props",
|
|
298
|
+
"base",
|
|
299
|
+
"defaultProps",
|
|
300
|
+
"motion"
|
|
301
|
+
]);
|
|
302
|
+
function mergeConfigIntoSeed(seed, addition) {
|
|
303
|
+
for (const [key, value] of Object.entries(addition)) {
|
|
304
|
+
if (MERGEABLE_NESTED_FIELDS.has(key) && typeof value === "object" && value !== null) {
|
|
305
|
+
const existing = seed[key];
|
|
306
|
+
const base = typeof existing === "object" && existing !== null ? existing : {};
|
|
307
|
+
if (key === "base") {
|
|
308
|
+
const merged = { ...base };
|
|
309
|
+
for (const [layerName, layerStyles] of Object.entries(value)) {
|
|
310
|
+
const prevLayer = merged[layerName];
|
|
311
|
+
merged[layerName] = typeof prevLayer === "object" && prevLayer !== null && typeof layerStyles === "object" && layerStyles !== null ? {
|
|
312
|
+
...prevLayer,
|
|
313
|
+
...layerStyles
|
|
314
|
+
} : layerStyles;
|
|
315
|
+
}
|
|
316
|
+
seed[key] = merged;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
seed[key] = {
|
|
320
|
+
...base,
|
|
321
|
+
...value
|
|
322
|
+
};
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
seed[key] = value;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function isComponentBuilderValue(value) {
|
|
329
|
+
return typeof value === "object" && value !== null && typeof value.config === "function";
|
|
330
|
+
}
|
|
331
|
+
function attachChainMethods(seed) {
|
|
332
|
+
const def = (key, value) => {
|
|
333
|
+
Object.defineProperty(seed, key, {
|
|
334
|
+
enumerable: false,
|
|
335
|
+
configurable: true,
|
|
336
|
+
writable: true,
|
|
337
|
+
value
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
def("config", function configMethod(cb) {
|
|
341
|
+
mergeConfigIntoSeed(seed, cb(configHelpers));
|
|
342
|
+
return seed;
|
|
343
|
+
});
|
|
344
|
+
def("render", function renderMethod(fn) {
|
|
345
|
+
def("__renderFn", fn);
|
|
346
|
+
def("__hasRenderFn", true);
|
|
347
|
+
return seed;
|
|
348
|
+
});
|
|
349
|
+
def("preview", function previewMethod(spec) {
|
|
350
|
+
def("__preview", typeof spec === "function" ? spec(previewHelpers) : spec);
|
|
351
|
+
return seed;
|
|
352
|
+
});
|
|
353
|
+
def("subcomponents", function subcomponentsMethod(children) {
|
|
354
|
+
for (const [childName, child] of Object.entries(children)) if (typeof child !== "object" || child === null || typeof child.layers !== "object") throw new Error(`subcomponents: entry "${childName}" is not a component definition`);
|
|
355
|
+
def("__subcomponents", children);
|
|
356
|
+
return seed;
|
|
357
|
+
});
|
|
358
|
+
def("metadata", function metadataMethod(meta) {
|
|
359
|
+
seed.metadata = {
|
|
360
|
+
...seed.metadata ?? {},
|
|
361
|
+
...meta
|
|
362
|
+
};
|
|
363
|
+
return seed;
|
|
364
|
+
});
|
|
365
|
+
return seed;
|
|
366
|
+
}
|
|
367
|
+
function defineComponentImpl(arg) {
|
|
368
|
+
let seed;
|
|
369
|
+
let extendsFromRef;
|
|
370
|
+
if (typeof arg === "string") seed = { layers: { root: tag(arg) } };
|
|
371
|
+
else if (isComponentBuilderValue(arg)) {
|
|
372
|
+
const source = arg;
|
|
373
|
+
seed = { ...source };
|
|
374
|
+
extendsFromRef = source;
|
|
375
|
+
} else seed = arg;
|
|
376
|
+
attachSourcePath(seed, captureCallerPath());
|
|
377
|
+
attachChainMethods(seed);
|
|
378
|
+
if (extendsFromRef !== void 0) Object.defineProperty(seed, "__extendsFrom", {
|
|
379
|
+
enumerable: false,
|
|
380
|
+
configurable: true,
|
|
381
|
+
writable: true,
|
|
382
|
+
value: extendsFromRef
|
|
383
|
+
});
|
|
384
|
+
return seed;
|
|
385
|
+
}
|
|
386
|
+
defineComponentImpl.layers = function layersEntry(layers) {
|
|
387
|
+
const seed = { layers };
|
|
388
|
+
attachSourcePath(seed, captureCallerPath());
|
|
389
|
+
return attachChainMethods(seed);
|
|
390
|
+
};
|
|
391
|
+
const defineComponent = defineComponentImpl;
|
|
392
|
+
//#endregion
|
|
393
|
+
export { boolean, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineStyleProp, defineTokenGroup, number, slot, string, variant };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region ../config/dist/foreign-component-name.js
|
|
2
|
+
/**
|
|
3
|
+
* Reserved registry namespace for third-party leaf components — the prefix in a
|
|
4
|
+
* `foreign:<displayName>` key. Not a peer design-system namespace (those are
|
|
5
|
+
* meaningful disambiguation); it marks "not a UDS component," so display
|
|
6
|
+
* surfaces strip it to the bare name.
|
|
7
|
+
*/
|
|
8
|
+
const FOREIGN_NAMESPACE = "foreign";
|
|
9
|
+
const FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
10
|
+
const MEMO_TYPE = Symbol.for("react.memo");
|
|
11
|
+
function nameOf(value) {
|
|
12
|
+
if (typeof value !== "object" && typeof value !== "function") return null;
|
|
13
|
+
const named = value;
|
|
14
|
+
if (typeof named.displayName === "string" && named.displayName.length > 0) return named.displayName;
|
|
15
|
+
if (typeof named.name === "string" && named.name.length > 0) return named.name;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Display name for a `forwardRef`/`memo` component object — preferring its own
|
|
20
|
+
* `displayName`, then the wrapped function's name. Returns `null` for anything
|
|
21
|
+
* that isn't one of those wrappers, and for an anonymous wrapper with no
|
|
22
|
+
* resolvable name (so the JSX runtime can keep it as a pending ref instead).
|
|
23
|
+
*/
|
|
24
|
+
function foreignComponentName(type) {
|
|
25
|
+
if (type === null || typeof type !== "object") return null;
|
|
26
|
+
const wrapper = type;
|
|
27
|
+
if (wrapper.$$typeof === FORWARD_REF_TYPE) return nameOf(type) ?? nameOf(wrapper.render);
|
|
28
|
+
if (wrapper.$$typeof === MEMO_TYPE) return nameOf(type) ?? nameOf(wrapper.type);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Registry key for a foreign component: `foreign:<displayName>`. The
|
|
33
|
+
* `foreign:` namespace keeps a third-party component (e.g. an icon named
|
|
34
|
+
* `Button`) from clobbering a registered UDS component of the same name.
|
|
35
|
+
* Returns `null` when the component has no resolvable foreign name.
|
|
36
|
+
*/
|
|
37
|
+
function foreignRegistryKey(type) {
|
|
38
|
+
const name = foreignComponentName(type);
|
|
39
|
+
return name === null ? null : `${FOREIGN_NAMESPACE}:${name}`;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { FOREIGN_NAMESPACE, foreignRegistryKey };
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BoolMarker, ComponentConfigInput, ComponentConfigValue, ComponentMotionValue, ComponentSlotStyles, CompositeBinding, CompositeMarker, CompoundPropsEntry, EnumMarker, HiddenMarker, HtmlTag, LayerBundle, LayerInput, LayerOverride, PrimitiveLayer, PrimitivePropBinding, PropBinding, RenderArgs, RootTag, SingleLayerCompositeBinding, SlotMarker, SlotMotion, SplitSlotPath, StringMarker, StylePropBinding, StylePropMarker, StylePropShorthand, TokenGroupMarker, TokenMarker, VerbosePropBinding, WhenClause, bool, composite, enums, hidden, slot, string, styleProp, token, tokenGroup } from "./component-config.js";
|
|
4
|
-
import { Props, PropsOf } from "./Props.js";
|
|
5
|
-
import { CreateComponentRenderArgs } from "./bindRender.js";
|
|
6
|
-
import { buildStylePropClassName } from "./className.js";
|
|
7
|
-
import { DefinedPreview, PreviewMetadata, definePreview } from "./definePreview.js";
|
|
8
|
-
import { CompositeStyleDef, CompositeStyleInput, CompositeStyleObject, CompositeStylesConfig, DefinedCompositeStyle, defineCompositeStyle } from "./defineCompositeStyle.js";
|
|
9
|
-
import { BoundComponent, DefineHelpers, DefinedComponent, PrimitiveComponentInput, defineComponent } from "./defineComponent.js";
|
|
1
|
+
import { ASSET_CLASS_CAPABILITIES, AssetKind, isPlaceable } from "./asset-kind.js";
|
|
2
|
+
import { AnyRef, AssetGroupName, AssetGroupRef, ComponentName, ComponentRef, CompositeName, CompositeRef, CompositeRefBuilder, ModeName, ModeRef, RegisteredAssetGroups, RegisteredComponents, RegisteredCompositeStyles, RegisteredModes, RegisteredModifiers, RegisteredMotionDefs, RegisteredStyleProps, RegisteredTokenGroups, StylePropName, StylePropRef, TagName, TagRef, TokenGroupName, TokenGroupRef, TokenName, TokenQualifiedName, TokenRef, assetGroup, component, composite, isAssetGroupRef, isComponentRef, isCompositeRef, isModeRef, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, mode, styleProp, tag, token, tokenGroup } from "./refs.js";
|
|
10
3
|
import { ColorFn, ColorKeyword, CssAngle, CssColor, CssLength, CssPercentage, CssRatio, CssTime, CssValue, CssValueTypeName, CssVarRef, HexColor, HslColor, RgbColor } from "./types/css-values.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { ResolvedCompoundOverrides,
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
4
|
+
import { ColorExpression, ColorSpace, ColorValue, GradientStop, GradientValue, LengthOrPercent, LineDirection, LinearGradientExpr, MixExpr, RadialGradientExpr, RadialSize, TokenRefToCss, alpha, isColorExpression, isLinearGradientExpr, isMixExpr, isRadialGradientExpr, linearGradient, mix, radialGradient, resolveColorExpression } from "./colorExpressions.js";
|
|
5
|
+
import { CSS_GLOBAL_KEYWORDS, CSS_PROPERTY_KEYWORDS, CssPropertyWithKeywords } from "./types/css-property-keywords.js";
|
|
6
|
+
import { ColorCssProperty, CssGlobalKeyword, CssPropertyName, CssPropertyValues } from "./types/css-properties.js";
|
|
7
|
+
import { AssetGroupBuilder, AssetGroupConfig, AssetGroupDefinition, FontAssetGroupConfig, FontAssetGroupDefinition, IconAssetGroupConfig, IconAssetGroupDefinition, IconAssetMember, IconAssetMetadata, defineAssetGroup, defineAssetIcon } from "./defineAssetGroup.js";
|
|
8
|
+
import { AnyStylePropDefinition, ArbitrarySpec, BaseStyles, BuildOptions, ComponentDefinition, ComponentGroupDefinition, ComponentMetadata, CompositeStyleDefinition, CompositeStyleObject, CompoundPropsEntry, CssMotionDefinition, FontAssetMember, GlobalStylesDef, JsMotionDefinition, LayerInput, LiteralFor, ModeDefinition, ModeOptionDefinition, ModifierDefinition, MotionDefinitionInput, MotionKeyframes, MotionStateKeyframe, MotionTransition, OpacityPairSpec, PreviewDefinition, PropBinding, SerializedAssetGroup, SerializedComponentGroup, SerializedConfig, SerializedFontAssetGroup, SerializedIconAssetGroup, SerializedTokenGroup, SlotMotion, StylePropDefinition, StylePropMetadata, StylePropProperty, TokenDefinition, TokenGroupDefinition, TokenModifierKey, TokenModifierValue, TokenType, TokenValue, ValuesEntry } from "./types.js";
|
|
9
|
+
import { AssetGroup } from "./AssetGroup.js";
|
|
10
|
+
import { Css, CssClassName, CssDeclaration, CssSelector, CssVar, cssClassName, cssDeclaration, cssSelector, cssVar } from "./brands.js";
|
|
11
|
+
import { BooleanMarker, LayerMarker, NumberMarker, PREVIEW_SEED_KEY, PreviewAxisMarker, PreviewPropsRule, RequiredBrand, SlotMarker, SlotRef, SlotValueType, StringMarker, VariantMarker, VariantMarkerArray, VariantMarkerObject, isBoolMarker, isLayerMarker, isNumberMarker, isPreviewAxisMarker, isSlotMarker, isStringMarker, isVariantArrayMarker, isVariantMarker, matchesPreviewWhen, resolvePreviewRules } from "./markers.js";
|
|
12
|
+
import { Component, ComponentKind, CompositeInfo, FunctionInfo, Layer, PrimitivePropKind, PropBase, PropInfo, PropKind, ResolvedCompoundOverrides, SlotInfo, SlotValueKind, StylePropInfo, StylePropKeyword, StylePropTokenUsage, VariantInfo } from "./Component.js";
|
|
13
|
+
import { ComponentGroup } from "./ComponentGroup.js";
|
|
14
|
+
import { CompositeStyle } from "./CompositeStyle.js";
|
|
15
|
+
import { makeTokenRefToCss } from "./entity-utils.js";
|
|
16
|
+
import { DataAttrs } from "./Props.js";
|
|
17
|
+
import { BoundComponent, ComponentBuilder, ComponentBuilderMethods, ComponentRenderFn, ConfigCallbackHelpers, DefineComponentFn, DefinedComponent, DefinedProvider, DefinedStyleProp, DefinedTokenGroup, PreviewCallbackHelpers, TokenGroupMetadata, TypedSlotRef, boolean, defineComponent, defineComponentGroup, defineCompositeStyle, defineMode, defineModifier, defineMotion, defineStyleProp, defineTokenGroup, number, slot, string, variant } from "./factories.js";
|
|
18
|
+
import { defineProvider } from "./defineProvider.js";
|
|
19
|
+
import { Mode, ModeOption } from "./Mode.js";
|
|
20
|
+
import { Modifier } from "./Modifier.js";
|
|
21
|
+
import { CssMotionDef, JsMotionDef, MotionDef } from "./MotionDef.js";
|
|
22
|
+
import { Provider } from "./Provider.js";
|
|
23
|
+
import { ResolvedTokenLiteral, Token } from "./Token.js";
|
|
24
|
+
import { StyleProp } from "./StyleProp.js";
|
|
25
|
+
import { TokenGroup } from "./TokenGroup.js";
|
|
26
|
+
import { Config, DependenciesQuery, DependencyKind, DependencyRef, DependentsQuery, parseRegistryKey } from "./Config.js";
|
|
27
|
+
import { SOURCE_PATH_KEY, attachSourcePath, captureCallerPath, readSourcePath } from "./captureCallerPath.js";
|
|
28
|
+
import { ELEMENT_MARKER_KIND, ElementMarker, OpaqueLeafPredicate, hasElementMarkerDeep, isElementLikeValue, isElementMarker, reviveElementMarkersDeep } from "./element-marker.js";
|
|
29
|
+
import { interpolate } from "./interpolate.js";
|
|
30
|
+
import { ModeBackedModifierDefinition, ModeBackedModifierInput, ModeBackedModifierLookup, OverrideModeRef, OverrideRow, buildModeBackedModifierLookup, buildNestedModifierUpdate, createModeBackedModifierLookup, mergeModifierUpdates, modifierIdToPath, modifierPathToId, modifierTreeToOverrideRows, overrideRowsToModifierTree, resolveOverrideRowValue } from "./token-override-rows.js";
|
|
31
|
+
import { rem } from "./units.js";
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
1
|
+
import "./brands.js";
|
|
2
|
+
import "./entity-utils.js";
|
|
3
|
+
import "./AssetGroup.js";
|
|
4
|
+
import "./asset-kind.js";
|
|
5
|
+
import "./captureCallerPath.js";
|
|
4
6
|
import "./refs.js";
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
7
|
-
import "./
|
|
8
|
-
import "./
|
|
9
|
-
import "./
|
|
10
|
-
import "./
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
13
|
-
import "./
|
|
14
|
-
import "./
|
|
15
|
-
import "./
|
|
7
|
+
import "./colorExpressions.js";
|
|
8
|
+
import "./defineAssetGroup.js";
|
|
9
|
+
import "./element-marker.js";
|
|
10
|
+
import "./markers.js";
|
|
11
|
+
import "./Component.js";
|
|
12
|
+
import "./ComponentGroup.js";
|
|
13
|
+
import "./CompositeStyle.js";
|
|
14
|
+
import "./Mode.js";
|
|
15
|
+
import "./Modifier.js";
|
|
16
|
+
import "./MotionDef.js";
|
|
17
|
+
import "./Provider.js";
|
|
18
|
+
import "./StyleProp.js";
|
|
19
|
+
import "./Token.js";
|
|
20
|
+
import "./TokenGroup.js";
|
|
21
|
+
import "./Config.js";
|
|
22
|
+
import "./defineProvider.js";
|
|
23
|
+
import "./factories.js";
|
|
24
|
+
import "./interpolate.js";
|
|
25
|
+
import "./token-override-rows.js";
|
|
26
|
+
import "./types/css-property-keywords.js";
|
|
27
|
+
import "./units.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region ../config/dist/interpolate.d.ts
|
|
2
|
+
//#region src/interpolate.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Motion interpolation marker — used inside `JsMotionDefinition`
|
|
5
|
+
* keyframes to declare an index-based interpolation (e.g. stagger).
|
|
6
|
+
*
|
|
7
|
+
* Codegen's `motion-transform.ts` detects `{ __type: 'interpolate' }`
|
|
8
|
+
* shapes on keyframe values and lifts them into the renderer's
|
|
9
|
+
* `useTransform`-style interpolation.
|
|
10
|
+
*/
|
|
11
|
+
interface InterpolateMarker {
|
|
12
|
+
readonly __type: 'interpolate';
|
|
13
|
+
readonly output: readonly number[];
|
|
14
|
+
readonly extrapolate: 'clamp' | 'extend' | 'identity';
|
|
15
|
+
}
|
|
16
|
+
declare function interpolate(config: {
|
|
17
|
+
output: readonly number[];
|
|
18
|
+
extrapolate?: 'clamp' | 'extend' | 'identity';
|
|
19
|
+
}): InterpolateMarker; //#endregion
|
|
20
|
+
//#endregion
|
|
21
|
+
export { interpolate };
|