@yahoo/uds-v5-wip 1.33.0 → 1.35.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 +45 -6
- package/dist/config/dist/createConfig.js +32 -2
- package/dist/config/dist/index.d.ts +1 -1
- package/dist/config/dist/index.js +2 -0
- package/dist/config/dist/propertyAcceptedTypes.js +148 -0
- package/dist/config/dist/resolveStyleProp.d.ts +1 -0
- package/dist/config/dist/resolveStyleProp.js +2 -0
- package/dist/config.d.ts +259 -205
- package/dist/core/dist/compositeStyles.d.ts +2 -1
- package/dist/core/dist/createComponent.d.ts +2 -1
- package/dist/core/dist/createComponentExample.d.ts +2 -1
- package/dist/core/dist/createProvider.d.ts +2 -1
- package/dist/core/dist/generated/stylePropsTwMap.d.ts +2 -1
- package/dist/core/dist/getComponentStyles.d.ts +2 -1
- package/dist/core/dist/getStyles.d.ts +2 -1
- package/dist/core/dist/propMappings.d.ts +2 -1
- package/dist/core/dist/resolveMotionState.d.ts +2 -1
- package/dist/core/dist/transformPreset.d.ts +2 -1
- package/dist/core/dist/withDefaultStyleProps.d.ts +2 -1
- package/dist/foundational-presets/dist/boldVibrant.d.ts +260 -205
- package/dist/foundational-presets/dist/brutalist.d.ts +260 -205
- package/dist/foundational-presets/dist/candy.d.ts +260 -205
- package/dist/foundational-presets/dist/cleanMinimalist.d.ts +260 -205
- package/dist/foundational-presets/dist/corporate.d.ts +260 -205
- package/dist/foundational-presets/dist/darkMoody.d.ts +260 -205
- package/dist/foundational-presets/dist/defaultPreset.d.ts +260 -205
- package/dist/foundational-presets/dist/defaultPreset.js +10 -41
- package/dist/foundational-presets/dist/forest.d.ts +260 -205
- package/dist/foundational-presets/dist/highContrast.d.ts +260 -205
- package/dist/foundational-presets/dist/lavender.d.ts +260 -205
- package/dist/foundational-presets/dist/luxury.d.ts +260 -205
- package/dist/foundational-presets/dist/monochrome.d.ts +260 -205
- package/dist/foundational-presets/dist/motion.d.ts +2 -1
- package/dist/foundational-presets/dist/neonCyber.d.ts +260 -205
- package/dist/foundational-presets/dist/newspaper.d.ts +260 -205
- package/dist/foundational-presets/dist/ocean.d.ts +260 -205
- package/dist/foundational-presets/dist/slate.d.ts +260 -205
- package/dist/foundational-presets/dist/sunset.d.ts +260 -205
- package/dist/foundational-presets/dist/terminal.d.ts +260 -205
- package/dist/foundational-presets/dist/warmOrganic.d.ts +260 -205
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -28,6 +28,8 @@ type IsReservedModifier<T> = T extends BaseModifierProp ? true : false;
|
|
|
28
28
|
type HasReservedModifier<T> = T extends any ? IsReservedModifier<T> extends true ? true : never : never;
|
|
29
29
|
interface ModeOption {
|
|
30
30
|
name: string;
|
|
31
|
+
/** Optional human-readable label for Studio. Falls back to `name`. */
|
|
32
|
+
label?: string;
|
|
31
33
|
modifier: ModifierNameShape;
|
|
32
34
|
/** Description for AI prompt generation (e.g. "Apply styles in dark mode") */
|
|
33
35
|
description?: string;
|
|
@@ -37,16 +39,55 @@ interface ModeOption {
|
|
|
37
39
|
}
|
|
38
40
|
interface ModeGroup {
|
|
39
41
|
name: string;
|
|
42
|
+
/** Optional human-readable label for Studio. Falls back to `name`. */
|
|
43
|
+
label?: string;
|
|
40
44
|
options: ModeOption[];
|
|
41
45
|
}
|
|
46
|
+
/** Single option within a mode set, as authored. */
|
|
47
|
+
interface ModeOptionInput {
|
|
48
|
+
/** Optional human-readable label for Studio. Falls back to the option key. */
|
|
49
|
+
label?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional explicit modifier string. When omitted, derived as `_${optionKey}`.
|
|
52
|
+
* Use this when the option key and modifier must differ (e.g. `xxl` → `_2xl`).
|
|
53
|
+
*/
|
|
54
|
+
modifier?: ModifierNameShape;
|
|
55
|
+
/** CSS selector applied when this option is active (e.g. `.dark`). */
|
|
56
|
+
css?: string;
|
|
57
|
+
/** Media query applied when this option is active. */
|
|
58
|
+
media?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Single mode set, as authored. */
|
|
61
|
+
interface ModeSetInput {
|
|
62
|
+
/** Optional human-readable label for Studio. Falls back to the set key. */
|
|
63
|
+
label?: string;
|
|
64
|
+
options: Record<string, ModeOptionInput>;
|
|
65
|
+
}
|
|
66
|
+
/** Object-keyed input shape accepted by `defineModes`. */
|
|
67
|
+
type ModesInput = Record<string, ModeSetInput>;
|
|
68
|
+
/**
|
|
69
|
+
* Extract the union of modifier strings produced by an authored `ModesInput`.
|
|
70
|
+
* Uses an explicit `modifier` when present; otherwise derives `_${optionKey}`.
|
|
71
|
+
* Drives both the reserved-modifier guard and the modifier types that flow
|
|
72
|
+
* through subsequent builder calls.
|
|
73
|
+
*/
|
|
74
|
+
type GetModifierFromInput<I extends ModesInput> = { [SetKey in keyof I]: { [OptKey in keyof I[SetKey]['options']]: I[SetKey]['options'][OptKey] extends {
|
|
75
|
+
modifier: infer M;
|
|
76
|
+
} ? M extends ModifierNameShape ? M : never : OptKey extends string ? `_${OptKey}` : never }[keyof I[SetKey]['options']] }[keyof I];
|
|
77
|
+
/** Reject any input whose derived/explicit modifiers collide with reserved names. */
|
|
78
|
+
type CheckForReservedModifiersInput<I extends ModesInput> = true extends HasReservedModifier<GetModifierFromInput<I>> ? 'ERROR: Cannot use reserved modifier names from ModifierProp. Please use a different modifier name.' : I;
|
|
79
|
+
/**
|
|
80
|
+
* Convert the authored object-keyed input into the internal `ModeGroup[]` shape.
|
|
81
|
+
* Derives `_${optionKey}` modifiers when no explicit `modifier` is provided.
|
|
82
|
+
* Never sets `default: true` — the new API has no concept of a default option;
|
|
83
|
+
* downstream consumers treat "no option active" as the implicit default.
|
|
84
|
+
*/
|
|
42
85
|
interface ModifierDef {
|
|
43
86
|
modifier: ModifierNameShape;
|
|
44
87
|
selector: string;
|
|
45
88
|
/** Description for AI prompt generation (e.g. "Apply styles on elevation-1 surfaces") */
|
|
46
89
|
description?: string;
|
|
47
90
|
}
|
|
48
|
-
/** Extract modifier union from all mode groups */
|
|
49
|
-
type GetModifierName<M extends readonly ModeGroup[]> = M[number]['options'][number]['modifier'];
|
|
50
91
|
interface ArbitraryTokenGroup {
|
|
51
92
|
properties: string[];
|
|
52
93
|
pattern: string | string[];
|
|
@@ -133,8 +174,6 @@ type EmptyVars = {};
|
|
|
133
174
|
/** Build a structured token reference object from atomic tokens */
|
|
134
175
|
declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
|
|
135
176
|
/** Build a structured composite-styles reference object for use in defineModifiers context */
|
|
136
|
-
/** Extract all modifiers from mode groups and check if any are reserved */
|
|
137
|
-
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;
|
|
138
177
|
/** Global styles definition — CSS selector → style props */
|
|
139
178
|
type GlobalStylesDef = Record<string, Record<string, any>>;
|
|
140
179
|
/** CSS properties for the example wrapper element */
|
|
@@ -226,7 +265,7 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
|
|
|
226
265
|
preflight(enabled?: boolean): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
|
|
227
266
|
prefix(value: string): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
|
|
228
267
|
buildOptions(options: BuildOptions): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
|
|
229
|
-
defineModes<const NewModes extends
|
|
268
|
+
defineModes<const NewModes extends ModesInput>(params: CheckForReservedModifiersInput<NewModes>): ConfigResult<TModifier | GetModifierFromInput<NewModes>, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers | GetModifierFromInput<NewModes>, TVars>;
|
|
230
269
|
defineModifiers<const Defs extends readonly ModifierDef[]>(params: Defs | ((ctx: {
|
|
231
270
|
tokens: TTokens;
|
|
232
271
|
compositeStyles: CompositeStylesReference<TCompositeStyles>;
|
|
@@ -315,4 +354,4 @@ interface InterpolateMarker {
|
|
|
315
354
|
declare function darker(color: string, amount: number): string;
|
|
316
355
|
declare function lighter(color: string, amount: number): string;
|
|
317
356
|
//#endregion
|
|
318
|
-
export { ArbitraryTokenGroup, AtomicToken, BuildOptions, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GlobalStylesDef, InterpolateMarker, ModeGroup, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
|
|
357
|
+
export { ArbitraryTokenGroup, AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
|
|
@@ -9,6 +9,35 @@ import { resolveTokenType, sniffTokenTypeFromValue } from "./resolveTokenTypes.j
|
|
|
9
9
|
import { applyPresetToData, deepMerge, mergeAtomic } from "./preset-merge.js";
|
|
10
10
|
//#region ../config/dist/createConfig.js
|
|
11
11
|
/** biome-ignore-all lint/suspicious/noExplicitAny: necessary for dynamic builder to work correctly */
|
|
12
|
+
/**
|
|
13
|
+
* Convert the authored object-keyed input into the internal `ModeGroup[]` shape.
|
|
14
|
+
* Derives `_${optionKey}` modifiers when no explicit `modifier` is provided.
|
|
15
|
+
* Never sets `default: true` — the new API has no concept of a default option;
|
|
16
|
+
* downstream consumers treat "no option active" as the implicit default.
|
|
17
|
+
*/
|
|
18
|
+
function convertModesInputToGroups(input) {
|
|
19
|
+
const groups = [];
|
|
20
|
+
for (const [setKey, setValue] of Object.entries(input)) {
|
|
21
|
+
const options = [];
|
|
22
|
+
for (const [optionKey, optionValue] of Object.entries(setValue.options)) {
|
|
23
|
+
const option = {
|
|
24
|
+
name: optionKey,
|
|
25
|
+
modifier: optionValue.modifier ?? `_${optionKey}`
|
|
26
|
+
};
|
|
27
|
+
if (optionValue.label !== void 0) option.label = optionValue.label;
|
|
28
|
+
if (optionValue.css !== void 0) option.css = optionValue.css;
|
|
29
|
+
if (optionValue.media !== void 0) option.media = optionValue.media;
|
|
30
|
+
options.push(option);
|
|
31
|
+
}
|
|
32
|
+
const group = {
|
|
33
|
+
name: setKey,
|
|
34
|
+
options
|
|
35
|
+
};
|
|
36
|
+
if (setValue.label !== void 0) group.label = setValue.label;
|
|
37
|
+
groups.push(group);
|
|
38
|
+
}
|
|
39
|
+
return groups;
|
|
40
|
+
}
|
|
12
41
|
/** Build a structured token reference object from atomic tokens */
|
|
13
42
|
function buildTokenReference(atomic, configPrefix) {
|
|
14
43
|
const result = Object.create(null);
|
|
@@ -391,9 +420,10 @@ function createConfigBuilder(data, extensions) {
|
|
|
391
420
|
return next({ buildOptions: options });
|
|
392
421
|
},
|
|
393
422
|
defineModes(params) {
|
|
423
|
+
const newGroups = convertModesInputToGroups(params);
|
|
394
424
|
return createConfigBuilder({
|
|
395
425
|
...data,
|
|
396
|
-
modes: [...data.modes, ...
|
|
426
|
+
modes: [...data.modes, ...newGroups]
|
|
397
427
|
}, extensions);
|
|
398
428
|
},
|
|
399
429
|
defineModifiers(params) {
|
|
@@ -692,4 +722,4 @@ const uds = createConfigBuilder({
|
|
|
692
722
|
remotion: void 0
|
|
693
723
|
});
|
|
694
724
|
//#endregion
|
|
695
|
-
export { buildCompositeStylesReference, buildTokenReference, createConfigBuilder, darker, interpolate, lighter, rem, resolveConfig, uds };
|
|
725
|
+
export { buildCompositeStylesReference, buildTokenReference, convertModesInputToGroups, createConfigBuilder, darker, interpolate, lighter, rem, resolveConfig, uds };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultColors } from "./consts/defaultColors.js";
|
|
2
2
|
import { PropertyGroupId } from "./propertyGroups.js";
|
|
3
3
|
import { TokenType, VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
|
|
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 { ArbitraryTokenGroup, AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.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 };
|
|
@@ -0,0 +1,148 @@
|
|
|
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 LENGTH_ONLY = { types: ["length"] };
|
|
16
|
+
const COLOR_ONLY = { types: ["color"] };
|
|
17
|
+
const TIME_ONLY = { types: ["time"] };
|
|
18
|
+
const NUMBER_ONLY = { types: ["number", "integer"] };
|
|
19
|
+
const ANGLE_ONLY = { types: ["angle"] };
|
|
20
|
+
const LENGTH_PCT_PROPS = [
|
|
21
|
+
"gap",
|
|
22
|
+
"column-gap",
|
|
23
|
+
"row-gap",
|
|
24
|
+
"padding",
|
|
25
|
+
"padding-top",
|
|
26
|
+
"padding-right",
|
|
27
|
+
"padding-bottom",
|
|
28
|
+
"padding-left",
|
|
29
|
+
"padding-block",
|
|
30
|
+
"padding-inline",
|
|
31
|
+
"padding-inline-start",
|
|
32
|
+
"padding-inline-end",
|
|
33
|
+
"scroll-margin",
|
|
34
|
+
"scroll-margin-top",
|
|
35
|
+
"scroll-margin-bottom",
|
|
36
|
+
"scroll-margin-block",
|
|
37
|
+
"scroll-margin-inline",
|
|
38
|
+
"scroll-margin-inline-start",
|
|
39
|
+
"scroll-margin-inline-end",
|
|
40
|
+
"scroll-padding",
|
|
41
|
+
"scroll-padding-top",
|
|
42
|
+
"scroll-padding-bottom",
|
|
43
|
+
"scroll-padding-block",
|
|
44
|
+
"scroll-padding-inline",
|
|
45
|
+
"scroll-padding-inline-start",
|
|
46
|
+
"scroll-padding-inline-end",
|
|
47
|
+
"border-radius",
|
|
48
|
+
"border-top-left-radius",
|
|
49
|
+
"border-top-right-radius",
|
|
50
|
+
"border-bottom-left-radius",
|
|
51
|
+
"border-bottom-right-radius",
|
|
52
|
+
"border-start-start-radius",
|
|
53
|
+
"border-start-end-radius",
|
|
54
|
+
"border-end-start-radius",
|
|
55
|
+
"border-end-end-radius",
|
|
56
|
+
"text-indent",
|
|
57
|
+
"font-size"
|
|
58
|
+
];
|
|
59
|
+
const LENGTH_PCT_AUTO_PROPS = [
|
|
60
|
+
"margin",
|
|
61
|
+
"margin-top",
|
|
62
|
+
"margin-right",
|
|
63
|
+
"margin-bottom",
|
|
64
|
+
"margin-left",
|
|
65
|
+
"margin-block",
|
|
66
|
+
"margin-inline",
|
|
67
|
+
"margin-inline-start",
|
|
68
|
+
"margin-inline-end",
|
|
69
|
+
"top",
|
|
70
|
+
"right",
|
|
71
|
+
"bottom",
|
|
72
|
+
"left",
|
|
73
|
+
"inset",
|
|
74
|
+
"inset-block",
|
|
75
|
+
"inset-inline",
|
|
76
|
+
"width",
|
|
77
|
+
"height",
|
|
78
|
+
"min-width",
|
|
79
|
+
"min-height",
|
|
80
|
+
"max-width",
|
|
81
|
+
"max-height"
|
|
82
|
+
];
|
|
83
|
+
const LENGTH_ONLY_PROPS = [
|
|
84
|
+
"border-width",
|
|
85
|
+
"border-top-width",
|
|
86
|
+
"border-right-width",
|
|
87
|
+
"border-bottom-width",
|
|
88
|
+
"border-left-width",
|
|
89
|
+
"border-block-width",
|
|
90
|
+
"border-inline-width",
|
|
91
|
+
"border-inline-start-width",
|
|
92
|
+
"border-inline-end-width",
|
|
93
|
+
"outline-width",
|
|
94
|
+
"outline-offset",
|
|
95
|
+
"border-spacing",
|
|
96
|
+
"letter-spacing",
|
|
97
|
+
"text-underline-offset",
|
|
98
|
+
"text-decoration-thickness"
|
|
99
|
+
];
|
|
100
|
+
const COLOR_PROPS = [
|
|
101
|
+
"color",
|
|
102
|
+
"background-color",
|
|
103
|
+
"border-color",
|
|
104
|
+
"border-top-color",
|
|
105
|
+
"border-right-color",
|
|
106
|
+
"border-bottom-color",
|
|
107
|
+
"border-left-color",
|
|
108
|
+
"border-block-color",
|
|
109
|
+
"border-inline-color",
|
|
110
|
+
"border-inline-start-color",
|
|
111
|
+
"border-inline-end-color",
|
|
112
|
+
"outline-color",
|
|
113
|
+
"text-decoration-color",
|
|
114
|
+
"caret-color",
|
|
115
|
+
"fill",
|
|
116
|
+
"stroke"
|
|
117
|
+
];
|
|
118
|
+
const TIME_PROPS = ["transition-duration", "transition-delay"];
|
|
119
|
+
const NUMBER_PROPS = [
|
|
120
|
+
"flex-grow",
|
|
121
|
+
"flex-shrink",
|
|
122
|
+
"order",
|
|
123
|
+
"z-index",
|
|
124
|
+
"-webkit-line-clamp"
|
|
125
|
+
];
|
|
126
|
+
const ANGLE_PROPS = ["rotate"];
|
|
127
|
+
new Map([
|
|
128
|
+
...LENGTH_PCT_PROPS.map((p) => [p, LENGTH_PCT]),
|
|
129
|
+
...LENGTH_PCT_AUTO_PROPS.map((p) => [p, LENGTH_PCT_AUTO]),
|
|
130
|
+
...LENGTH_ONLY_PROPS.map((p) => [p, LENGTH_ONLY]),
|
|
131
|
+
...COLOR_PROPS.map((p) => [p, COLOR_ONLY]),
|
|
132
|
+
...TIME_PROPS.map((p) => [p, TIME_ONLY]),
|
|
133
|
+
...NUMBER_PROPS.map((p) => [p, NUMBER_ONLY]),
|
|
134
|
+
...ANGLE_PROPS.map((p) => [p, ANGLE_ONLY]),
|
|
135
|
+
["font-weight", { types: [
|
|
136
|
+
"font-weight",
|
|
137
|
+
"number",
|
|
138
|
+
"integer"
|
|
139
|
+
] }],
|
|
140
|
+
["font-family", { types: ["font-family"] }],
|
|
141
|
+
["transition-timing-function", { types: ["easing-function"] }],
|
|
142
|
+
["box-shadow", { types: ["shadow"] }],
|
|
143
|
+
["text-shadow", { types: ["shadow"] }],
|
|
144
|
+
["list-style-image", { types: ["url", "image"] }],
|
|
145
|
+
["aspect-ratio", { types: ["ratio", "number"] }],
|
|
146
|
+
["opacity", { types: ["number", "percentage"] }]
|
|
147
|
+
]);
|
|
148
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|