@yahoo/uds-v5-wip 1.13.0 → 1.14.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/createConfig.d.ts +58 -20
- package/dist/config/dist/createConfig.js +120 -70
- package/dist/config/dist/index.d.ts +2 -2
- package/dist/config/dist/index.js +1 -1
- package/dist/config/dist/preset-merge.js +9 -4
- package/dist/config/dist/propertyGroups.d.ts +11 -0
- package/dist/config/dist/propertyGroups.js +432 -0
- package/dist/config/dist/types.d.ts +2 -62
- package/dist/config.d.ts +3 -3842
- package/dist/config.js +1 -2
- package/dist/foundational-presets/dist/boldVibrant.d.ts +2 -3839
- package/dist/foundational-presets/dist/brutalist.d.ts +2 -3839
- package/dist/foundational-presets/dist/candy.d.ts +2 -3839
- package/dist/foundational-presets/dist/cleanMinimalist.d.ts +2 -3839
- package/dist/foundational-presets/dist/corporate.d.ts +2 -3839
- package/dist/foundational-presets/dist/darkMoody.d.ts +2 -3839
- package/dist/foundational-presets/dist/defaultPreset.d.ts +2 -3839
- package/dist/foundational-presets/dist/defaultPreset.js +219 -605
- package/dist/foundational-presets/dist/forest.d.ts +2 -3839
- package/dist/foundational-presets/dist/highContrast.d.ts +2 -3839
- package/dist/foundational-presets/dist/lavender.d.ts +2 -3839
- package/dist/foundational-presets/dist/luxury.d.ts +2 -3839
- package/dist/foundational-presets/dist/monochrome.d.ts +2 -3839
- package/dist/foundational-presets/dist/motion.d.ts +2 -1
- package/dist/foundational-presets/dist/neonCyber.d.ts +2 -3839
- package/dist/foundational-presets/dist/newspaper.d.ts +2 -3839
- package/dist/foundational-presets/dist/ocean.d.ts +2 -3839
- package/dist/foundational-presets/dist/slate.d.ts +2 -3839
- package/dist/foundational-presets/dist/sunset.d.ts +2 -3839
- package/dist/foundational-presets/dist/terminal.d.ts +2 -3839
- package/dist/foundational-presets/dist/warmOrganic.d.ts +2 -3839
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/config/dist/resolvedMappings.d.ts +0 -22
- package/dist/config/dist/resolvedMappings.js +0 -43
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyGroupId } from "./propertyGroups.js";
|
|
2
|
+
import { VarsConfig } from "./types.js";
|
|
2
3
|
import { BaseModifierProp, ComponentsConfig, ConfigurableProp, MacroConfig, ModifierProp, MotionPreset, RemotionComponentDef, RemotionConfig, RemotionTransitionDef, StyleProp } from "@uds/types";
|
|
3
4
|
|
|
4
5
|
//#region ../config/dist/createConfig.d.ts
|
|
@@ -76,29 +77,19 @@ interface AtomicToken<M extends ModifierNameShape = ModifierNameShape> {
|
|
|
76
77
|
/** Merge two token structures */
|
|
77
78
|
type MergeTokens<A, B> = { [K in keyof A | keyof B]: K extends keyof B ? K extends keyof A ? A[K] & B[K] : B[K] : K extends keyof A ? A[K] : never };
|
|
78
79
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
80
|
+
* Derive token types directly from defineVars namespaces.
|
|
81
|
+
* Each var namespace key becomes a token property with the namespace's token names.
|
|
82
|
+
* An index signature allows property-name access (e.g., `tokens.borderRadius`)
|
|
83
|
+
* in addition to var-namespace access (e.g., `tokens.radius`).
|
|
84
|
+
* Used by `defineScopes` to populate tokens without an explicit utility mapping.
|
|
81
85
|
*/
|
|
82
|
-
type
|
|
83
|
-
/** Collapse a union into an intersection so multi-namespace token maps are merged. */
|
|
84
|
-
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
85
|
-
/**
|
|
86
|
-
* Derive the token map shape (`{ propName: { tokenName: string } }`) that
|
|
87
|
-
* `defineUtilities` adds to `TTokens`, based on the accumulated `TVars` and the
|
|
88
|
-
* concrete utilities config type.
|
|
89
|
-
*
|
|
90
|
-
* Only `values: '{namespace}'` references produce typed tokens; literal-values
|
|
91
|
-
* and boolean utilities fall through to `Record<string, string>`.
|
|
92
|
-
*/
|
|
93
|
-
type ExtractVarsTokens<TVars extends VarsConfig, TUtils extends Record<string, unknown>> = { [P in keyof TUtils]: TUtils[P] extends {
|
|
94
|
-
values: infer V;
|
|
95
|
-
} ? V extends string ? ExtractNsTokens<TVars, V> : V extends readonly string[] ? UnionToIntersection<ExtractNsTokens<TVars, V[number]>> : Record<string, string> : Record<string, string> };
|
|
86
|
+
type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in keyof TVars[K]]: string } } & Record<string, Record<string, string>>;
|
|
96
87
|
/** Empty tokens type for initial state */
|
|
97
88
|
type EmptyTokens = {};
|
|
98
89
|
/** Empty vars type for initial state */
|
|
99
90
|
type EmptyVars = {};
|
|
100
91
|
/** Build a structured token reference object from atomic tokens */
|
|
101
|
-
declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<
|
|
92
|
+
declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
|
|
102
93
|
/** Build a structured macro reference object for use in defineModifiers context */
|
|
103
94
|
/** Extract all modifiers from mode groups and check if any are reserved */
|
|
104
95
|
type CheckForReservedModifiers<T extends readonly ModeGroup[]> = true extends HasReservedModifier<GetModifierName<T>> ? 'ERROR: Cannot use reserved modifier names from ModifierProp. Please use a different modifier name.' : T;
|
|
@@ -136,7 +127,18 @@ interface UdsConfigData {
|
|
|
136
127
|
examples?: Record<string, ExampleDef>;
|
|
137
128
|
designPrinciples?: string[];
|
|
138
129
|
vars?: VarsConfig;
|
|
139
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Map each ConfigurableProp to its generated CSS class prefix.
|
|
132
|
+
* Set via `defineClassNames()`. Falls back to kebab-case of the property name.
|
|
133
|
+
*/
|
|
134
|
+
classNames?: Record<string, string>;
|
|
135
|
+
/**
|
|
136
|
+
* Map each var namespace to the property group IDs it feeds.
|
|
137
|
+
* Set via `defineScopes()`. This is the canonical source for
|
|
138
|
+
* "which tokens can this property use" — the Studio UI reads and
|
|
139
|
+
* edits this via draft patches.
|
|
140
|
+
*/
|
|
141
|
+
scopes?: Record<string, string[]>;
|
|
140
142
|
}
|
|
141
143
|
interface ComponentConfig<TComponents extends ComponentsConfig<string> = ComponentsConfig<string>, TMotion extends MotionPresetsDef | undefined = MotionPresetsDef | undefined> {
|
|
142
144
|
name?: string;
|
|
@@ -205,7 +207,43 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
|
|
|
205
207
|
tokens: TTokens;
|
|
206
208
|
}) => Record<string, RemotionTransitionDef>)): ConfigResult<TModifier, TTokens, TMotion, TExt, TMacros, TModeModifiers, TVars>;
|
|
207
209
|
defineVars<const TVarsNew extends VarsConfig<[TModeModifiers] extends [never] ? `_${string}` : TModeModifiers>>(vars: TVarsNew): ConfigResult<TModifier, TTokens, TMotion, TExt, TMacros, TModeModifiers, TVars & TVarsNew>;
|
|
208
|
-
|
|
210
|
+
/**
|
|
211
|
+
* Map each ConfigurableProp to a CSS class prefix.
|
|
212
|
+
* Falls back to kebab-case of the property name when not specified.
|
|
213
|
+
* Typically called once by the foundational preset — consumers rarely touch this.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* uds.defineClassNames({
|
|
218
|
+
* color: 'text',
|
|
219
|
+
* bg: 'bg',
|
|
220
|
+
* borderColor: 'border-color',
|
|
221
|
+
* spacing: 'p',
|
|
222
|
+
* gap: 'gap',
|
|
223
|
+
* borderRadius: 'rounded',
|
|
224
|
+
* })
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
defineClassNames(classNames: { [K in StyleProp]?: string }): ConfigResult<TModifier, TTokens, TMotion, TExt, TMacros, TModeModifiers, TVars>;
|
|
228
|
+
/**
|
|
229
|
+
* Map var namespaces to property groups, defining which tokens each property
|
|
230
|
+
* group can reference. This is the canonical scope definition — the Studio UI
|
|
231
|
+
* renders it as checkboxes per token group.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* uds
|
|
236
|
+
* .defineVars({
|
|
237
|
+
* color: { brand: { value: '#1167f4' } },
|
|
238
|
+
* spacing: { sm: { value: '4px' } },
|
|
239
|
+
* })
|
|
240
|
+
* .defineScopes({
|
|
241
|
+
* color: ['textColor', 'background', 'borderColor', 'ringColor'],
|
|
242
|
+
* spacing: ['padding', 'gap', 'margin'],
|
|
243
|
+
* })
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
defineScopes(scopes: [keyof TVars] extends [never] ? Record<string, PropertyGroupId[]> : { [K in keyof TVars]?: PropertyGroupId[] }): ConfigResult<TModifier, MergeTokens<TTokens, VarsToTokens<TVars>>, TMotion, TExt, TMacros, TModeModifiers, TVars>;
|
|
209
247
|
}
|
|
210
248
|
type AnyUdsConfig = UdsConfig<ModifierNameShape, any, any, any, any, any, any>;
|
|
211
249
|
/** Extract the raw config data from a builder instance */
|
|
@@ -5,18 +5,27 @@ import { getConfigurablePropMapping } from "../../core/dist/propMappings.js";
|
|
|
5
5
|
import "../../core/dist/index.js";
|
|
6
6
|
import { buildMotionReference, resolveComponentMotionAliases, validateComponentVariants } from "./component-resolution.js";
|
|
7
7
|
import { applyPresetToData, deepMerge, mergeAtomic } from "./preset-merge.js";
|
|
8
|
+
import { expandPropertyGroups } from "./propertyGroups.js";
|
|
8
9
|
//#region ../config/dist/createConfig.js
|
|
9
10
|
/** biome-ignore-all lint/suspicious/noExplicitAny: necessary for dynamic builder to work correctly */
|
|
10
11
|
/** Build a structured token reference object from atomic tokens */
|
|
11
12
|
function buildTokenReference(atomic, configPrefix) {
|
|
12
13
|
const result = Object.create(null);
|
|
13
|
-
for (const token of atomic)
|
|
14
|
-
|
|
14
|
+
for (const token of atomic) {
|
|
15
|
+
const varPrefix = token.cssPrefix ?? getConfigurablePropMapping(token.properties[0])?.defaultVarPrefix;
|
|
16
|
+
const tokenEntries = Object.create(null);
|
|
15
17
|
for (const t of token.tokens) {
|
|
16
|
-
const varPrefix = token.cssPrefix ?? getConfigurablePropMapping(prop)?.defaultVarPrefix;
|
|
17
18
|
const safeName = safeTokenName(t.name);
|
|
18
19
|
const cssVarName = configPrefix ? `--${configPrefix}-${varPrefix}-${safeName}` : `--${varPrefix}-${safeName}`;
|
|
19
|
-
|
|
20
|
+
tokenEntries[t.name] = `var(${cssVarName})`;
|
|
21
|
+
}
|
|
22
|
+
for (const prop of token.properties) {
|
|
23
|
+
if (!result[prop]) result[prop] = Object.create(null);
|
|
24
|
+
Object.assign(result[prop], tokenEntries);
|
|
25
|
+
}
|
|
26
|
+
if (varPrefix) {
|
|
27
|
+
if (!result[varPrefix]) result[varPrefix] = Object.create(null);
|
|
28
|
+
Object.assign(result[varPrefix], tokenEntries);
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
return result;
|
|
@@ -30,20 +39,6 @@ function buildMacroReference(macros) {
|
|
|
30
39
|
}
|
|
31
40
|
return result;
|
|
32
41
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Parse a `'{namespace}'` reference string, returning the namespace name
|
|
35
|
-
* or `undefined` if the string is not a valid reference.
|
|
36
|
-
*/
|
|
37
|
-
function parseVarsReference(ref) {
|
|
38
|
-
return ref.match(/^\{(.+)\}$/)?.[1];
|
|
39
|
-
}
|
|
40
|
-
/** Normalize values to an array of string refs, filtering out non-string forms. */
|
|
41
|
-
function normalizeValuesRefs(values) {
|
|
42
|
-
if (!values) return [];
|
|
43
|
-
if (typeof values === "string") return [values];
|
|
44
|
-
if (Array.isArray(values)) return values;
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
42
|
/** Convert a VarGroupDef into AtomicToken tokens, extracting modifier overrides. */
|
|
48
43
|
function varGroupToTokens(varGroup, knownModifiers) {
|
|
49
44
|
const tokens = [];
|
|
@@ -62,55 +57,99 @@ function varGroupToTokens(varGroup, knownModifiers) {
|
|
|
62
57
|
return tokens;
|
|
63
58
|
}
|
|
64
59
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
* Sort properties so the one matching the cssPrefix comes last.
|
|
61
|
+
* `buildVarToTokenMap` uses "last wins", so this ensures e.g. `color.brand`
|
|
62
|
+
* beats `shadowColor.brand` when both reference `var(--uds-color-brand)`.
|
|
63
|
+
*/
|
|
64
|
+
function sortPropertiesByPrefixMatch(properties, namespace, cssPfx) {
|
|
65
|
+
return properties.slice().sort((a, b) => {
|
|
66
|
+
return (a === namespace || kebabCase(a) === cssPfx ? 1 : 0) - (b === namespace || kebabCase(b) === cssPfx ? 1 : 0);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Synthesize AtomicToken[] from defineScopes + defineVars data.
|
|
71
71
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* For each namespace in `scopes`, expands property group IDs into
|
|
73
|
+
* ConfigurableProps, extracts tokens from the matching var namespace,
|
|
74
|
+
* and produces an AtomicToken group.
|
|
75
75
|
*/
|
|
76
|
-
function
|
|
76
|
+
function synthesizeAtomicFromScopesAndVars(vars, scopes, modes) {
|
|
77
77
|
const knownModifiers = /* @__PURE__ */ new Set();
|
|
78
78
|
for (const mode of modes) for (const option of mode.options) knownModifiers.add(option.modifier);
|
|
79
|
-
const pairs = /* @__PURE__ */ new Map();
|
|
80
|
-
for (const [propName, utilDef] of Object.entries(utilities)) {
|
|
81
|
-
if (!utilDef) continue;
|
|
82
|
-
const refs = normalizeValuesRefs(utilDef.values);
|
|
83
|
-
for (const ref of refs) {
|
|
84
|
-
const namespace = parseVarsReference(ref);
|
|
85
|
-
if (!namespace || !vars[namespace]) continue;
|
|
86
|
-
const key = `${namespace}|${propName}`;
|
|
87
|
-
pairs.set(key, {
|
|
88
|
-
namespace,
|
|
89
|
-
property: propName
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const namespaceGroups = /* @__PURE__ */ new Map();
|
|
94
|
-
for (const { namespace, property } of pairs.values()) {
|
|
95
|
-
const props = namespaceGroups.get(namespace) ?? /* @__PURE__ */ new Set();
|
|
96
|
-
props.add(property);
|
|
97
|
-
namespaceGroups.set(namespace, props);
|
|
98
|
-
}
|
|
99
79
|
const result = [];
|
|
100
|
-
for (const [namespace,
|
|
80
|
+
for (const [namespace, groupIds] of Object.entries(scopes)) {
|
|
101
81
|
const varGroup = vars[namespace];
|
|
102
82
|
if (!varGroup) continue;
|
|
83
|
+
const properties = expandPropertyGroups(groupIds);
|
|
84
|
+
if (properties.length === 0) continue;
|
|
103
85
|
const tokens = varGroupToTokens(varGroup, knownModifiers);
|
|
104
|
-
const cssPfx = (
|
|
105
|
-
const
|
|
106
|
-
return (a === namespace || kebabCase(a) === cssPfx ? 1 : 0) - (b === namespace || kebabCase(b) === cssPfx ? 1 : 0);
|
|
107
|
-
});
|
|
86
|
+
const cssPfx = (properties.includes(namespace) ? getConfigurablePropMapping(namespace) : void 0)?.defaultVarPrefix ?? kebabCase(namespace);
|
|
87
|
+
const sorted = sortPropertiesByPrefixMatch(properties, namespace, cssPfx);
|
|
108
88
|
result.push({
|
|
109
|
-
properties,
|
|
89
|
+
properties: sorted,
|
|
110
90
|
tokens,
|
|
111
91
|
cssPrefix: cssPfx
|
|
112
92
|
});
|
|
113
93
|
}
|
|
94
|
+
return disambiguateOverlappingProperties(result, scopes);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* When multiple scope namespaces reference the **same** property group
|
|
98
|
+
* (e.g. `rotate`, `scale`, `skew`, `translate` all mapping to `['transform']`),
|
|
99
|
+
* each namespace's AtomicToken gets ALL properties from that group, causing
|
|
100
|
+
* last-write-wins collisions in CSS generation.
|
|
101
|
+
*
|
|
102
|
+
* This function partitions those shared-group properties among namespaces
|
|
103
|
+
* using longest camelCase prefix matching. Cross-group overlaps (e.g.
|
|
104
|
+
* `color` and `bg` both including the `bg` property via different groups)
|
|
105
|
+
* are intentional cascading and left untouched.
|
|
106
|
+
*/
|
|
107
|
+
function disambiguateOverlappingProperties(tokens, scopes) {
|
|
108
|
+
const groupToNamespaces = /* @__PURE__ */ new Map();
|
|
109
|
+
for (const [ns, groupIds] of Object.entries(scopes)) for (const gid of groupIds) {
|
|
110
|
+
const list = groupToNamespaces.get(gid) ?? [];
|
|
111
|
+
list.push(ns);
|
|
112
|
+
groupToNamespaces.set(gid, list);
|
|
113
|
+
}
|
|
114
|
+
const contestedGroups = /* @__PURE__ */ new Map();
|
|
115
|
+
for (const [gid, nsList] of groupToNamespaces) if (nsList.length > 1) contestedGroups.set(gid, nsList);
|
|
116
|
+
if (contestedGroups.size === 0) return tokens;
|
|
117
|
+
const propOwner = /* @__PURE__ */ new Map();
|
|
118
|
+
for (const [gid, nsList] of contestedGroups) {
|
|
119
|
+
const groupProps = expandPropertyGroups([gid]);
|
|
120
|
+
const assignments = /* @__PURE__ */ new Map();
|
|
121
|
+
const nsWithMatch = /* @__PURE__ */ new Set();
|
|
122
|
+
for (const prop of groupProps) {
|
|
123
|
+
let bestNs = "";
|
|
124
|
+
let bestLen = 0;
|
|
125
|
+
for (const ns of nsList) if (prop === ns || prop.startsWith(ns) && prop.length > ns.length) {
|
|
126
|
+
if (ns.length > bestLen) {
|
|
127
|
+
bestNs = ns;
|
|
128
|
+
bestLen = ns.length;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (bestNs) {
|
|
132
|
+
assignments.set(prop, bestNs);
|
|
133
|
+
nsWithMatch.add(bestNs);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (nsWithMatch.size < 2) continue;
|
|
137
|
+
for (const [prop, ns] of assignments) propOwner.set(prop, ns);
|
|
138
|
+
}
|
|
139
|
+
if (propOwner.size === 0) return tokens;
|
|
140
|
+
const namespaces = Object.keys(scopes);
|
|
141
|
+
const result = [];
|
|
142
|
+
for (const token of tokens) {
|
|
143
|
+
const ns = namespaces.find((n) => token.cssPrefix === kebabCase(n)) ?? "";
|
|
144
|
+
const filtered = token.properties.filter((prop) => {
|
|
145
|
+
const owner = propOwner.get(prop);
|
|
146
|
+
return !owner || owner === ns;
|
|
147
|
+
});
|
|
148
|
+
if (filtered.length > 0) result.push({
|
|
149
|
+
...token,
|
|
150
|
+
properties: filtered
|
|
151
|
+
});
|
|
152
|
+
}
|
|
114
153
|
return result;
|
|
115
154
|
}
|
|
116
155
|
/** Extract the raw config data from a builder instance */
|
|
@@ -133,13 +172,15 @@ function resolveConfig(config) {
|
|
|
133
172
|
examples: config.examples,
|
|
134
173
|
designPrinciples: config.designPrinciples,
|
|
135
174
|
vars: config.vars,
|
|
136
|
-
|
|
175
|
+
classNames: config.classNames,
|
|
176
|
+
scopes: config.scopes
|
|
137
177
|
};
|
|
138
|
-
if (configData.vars && configData.
|
|
139
|
-
const synthesized =
|
|
178
|
+
if (configData.vars && configData.scopes) {
|
|
179
|
+
const synthesized = synthesizeAtomicFromScopesAndVars(configData.vars, configData.scopes, configData.modes);
|
|
180
|
+
const atomic = mergeAtomic(configData.atomic, synthesized, "merge");
|
|
140
181
|
configData = {
|
|
141
182
|
...configData,
|
|
142
|
-
atomic
|
|
183
|
+
atomic
|
|
143
184
|
};
|
|
144
185
|
}
|
|
145
186
|
return configData;
|
|
@@ -192,7 +233,8 @@ function resolvePresetData(input) {
|
|
|
192
233
|
examples: input.examples,
|
|
193
234
|
designPrinciples: input.designPrinciples,
|
|
194
235
|
vars: input.vars,
|
|
195
|
-
|
|
236
|
+
classNames: input.classNames,
|
|
237
|
+
scopes: input.scopes
|
|
196
238
|
};
|
|
197
239
|
}
|
|
198
240
|
function extractVarReferences(value) {
|
|
@@ -230,7 +272,10 @@ function collectRequiredTokens(sourceData, components, motion) {
|
|
|
230
272
|
}
|
|
231
273
|
function availableTokenNames(data) {
|
|
232
274
|
const names = /* @__PURE__ */ new Set();
|
|
233
|
-
for (const group of data.atomic) for (const
|
|
275
|
+
for (const group of data.atomic) for (const token of group.tokens) {
|
|
276
|
+
for (const prop of group.properties) names.add(`${prop}.${token.name}`);
|
|
277
|
+
if (group.cssPrefix) names.add(`${group.cssPrefix}.${token.name}`);
|
|
278
|
+
}
|
|
234
279
|
return names;
|
|
235
280
|
}
|
|
236
281
|
function validatePresetRequiredTokens(base, preset) {
|
|
@@ -434,8 +479,7 @@ function createConfigBuilder(data, extensions) {
|
|
|
434
479
|
arbitraryTokens: input.arbitraryTokens ?? data.arbitraryTokens,
|
|
435
480
|
examples: input.examples ?? data.examples,
|
|
436
481
|
designPrinciples: input.designPrinciples ?? data.designPrinciples,
|
|
437
|
-
vars: input.vars ?? data.vars
|
|
438
|
-
utilities: input.utilities ?? data.utilities
|
|
482
|
+
vars: input.vars ?? data.vars
|
|
439
483
|
}, extensions);
|
|
440
484
|
},
|
|
441
485
|
extend(ext) {
|
|
@@ -515,8 +559,8 @@ function createConfigBuilder(data, extensions) {
|
|
|
515
559
|
...group
|
|
516
560
|
};
|
|
517
561
|
const updates = { vars: merged };
|
|
518
|
-
if (data.
|
|
519
|
-
const synthesized =
|
|
562
|
+
if (data.scopes && Object.keys(data.scopes).length > 0) {
|
|
563
|
+
const synthesized = synthesizeAtomicFromScopesAndVars(merged, data.scopes, data.modes ?? []);
|
|
520
564
|
updates.atomic = mergeAtomic(data.atomic, synthesized, "merge");
|
|
521
565
|
}
|
|
522
566
|
return createConfigBuilder({
|
|
@@ -524,14 +568,20 @@ function createConfigBuilder(data, extensions) {
|
|
|
524
568
|
...updates
|
|
525
569
|
}, extensions);
|
|
526
570
|
},
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
...data.
|
|
530
|
-
...
|
|
571
|
+
defineClassNames(classNames) {
|
|
572
|
+
return next({ classNames: {
|
|
573
|
+
...data.classNames,
|
|
574
|
+
...classNames
|
|
575
|
+
} });
|
|
576
|
+
},
|
|
577
|
+
defineScopes(scopes) {
|
|
578
|
+
const mergedScopes = {
|
|
579
|
+
...data.scopes,
|
|
580
|
+
...scopes
|
|
531
581
|
};
|
|
532
|
-
const updates = {
|
|
582
|
+
const updates = { scopes: mergedScopes };
|
|
533
583
|
if (data.vars && Object.keys(data.vars).length > 0) {
|
|
534
|
-
const synthesized =
|
|
584
|
+
const synthesized = synthesizeAtomicFromScopesAndVars(data.vars, mergedScopes, data.modes ?? []);
|
|
535
585
|
updates.atomic = mergeAtomic(data.atomic ?? [], synthesized, "merge");
|
|
536
586
|
}
|
|
537
587
|
return createConfigBuilder({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultColors } from "./consts/defaultColors.js";
|
|
2
|
-
import {
|
|
2
|
+
import { PropertyGroupId } from "./propertyGroups.js";
|
|
3
|
+
import { VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
|
|
3
4
|
import { ArbitraryTokenGroup, AtomicToken, BuildOptions, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GlobalStylesDef, InterpolateMarker, ModeGroup, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.js";
|
|
4
|
-
import { ResolvedUtilityMapping, resolveUtilityMappings } from "./resolvedMappings.js";
|
|
5
5
|
import { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig } from "./serialize.js";
|
|
6
6
|
import { ComponentsConfig as ComponentsConfig$1 } from "@uds/types";
|
|
7
7
|
export { type ComponentsConfig$1 as ComponentsConfig };
|
|
@@ -142,9 +142,13 @@ function applyPresetToData(base, preset, strategy) {
|
|
|
142
142
|
const mergedPrinciples = base.designPrinciples || preset.designPrinciples ? [...base.designPrinciples ?? [], ...preset.designPrinciples ?? []] : void 0;
|
|
143
143
|
const mergedArbitraryTokens = base.arbitraryTokens || preset.arbitraryTokens ? [...base.arbitraryTokens ?? [], ...preset.arbitraryTokens ?? []] : void 0;
|
|
144
144
|
const mergedVars = base.vars || preset.vars ? mergeRecordByKey(base.vars ?? {}, preset.vars ?? {}, "merge") : void 0;
|
|
145
|
-
const
|
|
146
|
-
...base.
|
|
147
|
-
...preset.
|
|
145
|
+
const mergedClassNames = base.classNames || preset.classNames ? {
|
|
146
|
+
...base.classNames,
|
|
147
|
+
...preset.classNames
|
|
148
|
+
} : void 0;
|
|
149
|
+
const mergedScopes = base.scopes || preset.scopes ? {
|
|
150
|
+
...base.scopes,
|
|
151
|
+
...preset.scopes
|
|
148
152
|
} : void 0;
|
|
149
153
|
const merged = {
|
|
150
154
|
...base,
|
|
@@ -163,7 +167,8 @@ function applyPresetToData(base, preset, strategy) {
|
|
|
163
167
|
examples: mergedExamples,
|
|
164
168
|
designPrinciples: mergedPrinciples,
|
|
165
169
|
vars: mergedVars,
|
|
166
|
-
|
|
170
|
+
classNames: mergedClassNames,
|
|
171
|
+
scopes: mergedScopes
|
|
167
172
|
};
|
|
168
173
|
validateComponentVariants(merged.components);
|
|
169
174
|
return merged;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfigurableProp } from "@uds/types";
|
|
2
|
+
|
|
3
|
+
//#region ../config/dist/propertyGroups.d.ts
|
|
4
|
+
//#region src/propertyGroups.d.ts
|
|
5
|
+
type PropertyGroupId = 'textColor' | 'background' | 'borderColor' | 'outlineColor' | 'ringColor' | 'divideColor' | 'shadowColor' | 'svgFill' | 'svgStroke' | 'caretColor' | 'textDecorationColor' | 'opacity' | 'colorOpacity' | 'bgOpacity' | 'borderColorOpacity' | 'divideColorOpacity' | 'outlineColorOpacity' | 'ringColorOpacity' | 'textDecorationColorOpacity' | 'svgFillOpacity' | 'svgStrokeOpacity' | 'shadowColorOpacity' | 'caretColorOpacity' | 'fontFamily' | 'fontSize' | 'fontWeight' | 'lineHeight' | 'letterSpacing' | 'blur' | 'backdropBlur' | 'animation' | 'shadow' | 'textShadow' | 'zIndex' | 'borderWidth' | 'borderRadius' | 'outlineWidth' | 'divideWidth' | 'ringWidth' | 'padding' | 'margin' | 'offset' | 'gap' | 'indent' | 'scrollSnapGap' | 'scrollSnapSpacing' | 'tableBorderSpacing' | 'width' | 'height' | 'aspectRatio' | 'positionPlacement' | 'flex' | 'transform' | 'strokeWidth';
|
|
6
|
+
/**
|
|
7
|
+
* A logical grouping of ConfigurableProps with a human-readable label.
|
|
8
|
+
* Used by the Studio UI to let users scope token groups to specific properties.
|
|
9
|
+
*/
|
|
10
|
+
//#endregion
|
|
11
|
+
export { PropertyGroupId };
|