@yahoo/uds-create-config 4.16.0 → 4.17.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/configs/react-native-system.d.ts +6 -5
- package/dist/configs/system.d.ts +5 -5
- package/dist/configs/system.js +2 -0
- package/dist/entities/native/NativeToken.d.ts +4 -3
- package/dist/entities/system/Modifier.js +2 -5
- package/dist/entities/system/Token.d.ts +5 -5
- package/dist/entities/system/Token.js +3 -4
- package/dist/entities/system/color.d.ts +4 -1
- package/dist/entities/system/color.js +59 -5
- package/dist/entities/system/composed-values.d.ts +36 -0
- package/dist/entities/system/composed-values.js +52 -0
- package/dist/entities/system/style-bag.d.ts +2 -2
- package/dist/entities/system/style-bag.js +3 -5
- package/dist/entities/system/transition.d.ts +35 -0
- package/dist/entities/system/transition.js +57 -0
- package/dist/framework/Config.d.ts +1 -1
- package/dist/framework/Config.js +1 -1
- package/dist/framework/defineEntity.js +2 -5
- package/dist/framework/projections.js +2 -3
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/utils/refs.d.ts +7 -1
- package/dist/framework/utils/refs.js +10 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/migrations/2.0.0/v1-artifact.d.ts +3 -3
- package/dist/migrations/20260923144958_transition_token_value.d.ts +13 -0
- package/dist/migrations/20260923144958_transition_token_value.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -15,7 +15,8 @@ import { StoredPreviewCondition } from "../framework/preview-store.js";
|
|
|
15
15
|
import { listSlots, namedSlots, slotHostedBy, slotOf } from "../spec/slot.js";
|
|
16
16
|
import { cellAt } from "../spec/cell.js";
|
|
17
17
|
import { instanceAt } from "../spec/instance.js";
|
|
18
|
-
import {
|
|
18
|
+
import { ComposedValue } from "../entities/system/composed-values.js";
|
|
19
|
+
import { DerivedColor } from "../entities/system/color.js";
|
|
19
20
|
import { StyleValue } from "../entities/system/style-bag.js";
|
|
20
21
|
import { ComponentElementBody, ComponentReference, ComponentStyleBody } from "../entities/system/Component.js";
|
|
21
22
|
import { OverrideCondition } from "../entities/system/Token.js";
|
|
@@ -62,11 +63,11 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
62
63
|
}, _$zod_v4_core0.$strict>>;
|
|
63
64
|
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
|
|
64
65
|
tokens: EntityClass<_$zod.ZodObject<Omit<{
|
|
65
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
66
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
66
67
|
type: _$zod.ZodOptional<_$zod.ZodString>;
|
|
67
68
|
overrides: _$zod.ZodOptional<SubEntityClass<_$zod.ZodObject<{
|
|
68
69
|
on: _$zod.ZodType<OverrideCondition, unknown, _$zod_v4_core0.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
69
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
70
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
70
71
|
}, _$zod_v4_core0.$strip>>>;
|
|
71
72
|
}, "value" | "overrides"> & {
|
|
72
73
|
value: _$zod.ZodType<string | number | boolean | Ref | DerivedColor, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | boolean | Ref | DerivedColor, unknown>>;
|
|
@@ -2216,11 +2217,11 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
2216
2217
|
}, _$zod_v4_core0.$strict>>;
|
|
2217
2218
|
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<Omit<Record<never, never>, never> & {}, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
|
|
2218
2219
|
tokens: EntityClass<_$zod.ZodObject<Omit<{
|
|
2219
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
2220
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
2220
2221
|
type: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2221
2222
|
overrides: _$zod.ZodOptional<SubEntityClass<_$zod.ZodObject<{
|
|
2222
2223
|
on: _$zod.ZodType<OverrideCondition, unknown, _$zod_v4_core0.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
2223
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
2224
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
2224
2225
|
}, _$zod_v4_core0.$strip>>>;
|
|
2225
2226
|
}, "value" | "overrides"> & {
|
|
2226
2227
|
value: _$zod.ZodType<string | number | boolean | Ref | DerivedColor, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | boolean | Ref | DerivedColor, unknown>>;
|
package/dist/configs/system.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { StoredPreviewCondition } from "../framework/preview-store.js";
|
|
|
15
15
|
import { listSlots, namedSlots, slotHostedBy, slotOf } from "../spec/slot.js";
|
|
16
16
|
import { cellAt } from "../spec/cell.js";
|
|
17
17
|
import { instanceAt } from "../spec/instance.js";
|
|
18
|
-
import {
|
|
18
|
+
import { ComposedValue } from "../entities/system/composed-values.js";
|
|
19
19
|
import { StyleValue } from "../entities/system/style-bag.js";
|
|
20
20
|
import { ComponentElementBody, ComponentReference, ComponentStyleBody } from "../entities/system/Component.js";
|
|
21
21
|
import { OverrideCondition } from "../entities/system/Token.js";
|
|
@@ -56,11 +56,11 @@ declare const System: ConfigClass<{
|
|
|
56
56
|
}, _$zod_v4_core0.$strict>>;
|
|
57
57
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
|
|
58
58
|
tokens: EntityClass<_$zod.ZodObject<{
|
|
59
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
59
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
60
60
|
type: _$zod.ZodOptional<_$zod.ZodString>;
|
|
61
61
|
overrides: _$zod.ZodOptional<SubEntityClass<_$zod.ZodObject<{
|
|
62
62
|
on: _$zod.ZodType<OverrideCondition, unknown, _$zod_v4_core0.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
63
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
63
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
64
64
|
}, _$zod_v4_core0.$strip>>>;
|
|
65
65
|
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
|
|
66
66
|
cssPrefix: _$zod.ZodOptional<_$zod.ZodString>;
|
|
@@ -2082,11 +2082,11 @@ declare const System: ConfigClass<{
|
|
|
2082
2082
|
}, _$zod_v4_core0.$strict>>;
|
|
2083
2083
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<Record<never, never>, _$zod_v4_core0.$strip>, "settings", Record<never, never>, Record<never, never>, true, Record<never, never>, Record<never, never>>;
|
|
2084
2084
|
tokens: EntityClass<_$zod.ZodObject<{
|
|
2085
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
2085
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
2086
2086
|
type: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2087
2087
|
overrides: _$zod.ZodOptional<SubEntityClass<_$zod.ZodObject<{
|
|
2088
2088
|
on: _$zod.ZodType<OverrideCondition, unknown, _$zod_v4_core0.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
2089
|
-
value: _$zod.ZodType<string | number | Ref |
|
|
2089
|
+
value: _$zod.ZodType<string | number | Ref | ComposedValue, unknown, _$zod_v4_core0.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
2090
2090
|
}, _$zod_v4_core0.$strip>>>;
|
|
2091
2091
|
}, _$zod_v4_core0.$strip>, _$zod.ZodObject<{
|
|
2092
2092
|
cssPrefix: _$zod.ZodOptional<_$zod.ZodString>;
|
package/dist/configs/system.js
CHANGED
|
@@ -37,6 +37,7 @@ import { iconLibraryWithoutComponentMigration } from "../migrations/202609210440
|
|
|
37
37
|
import { iconLibrariesMigration } from "../migrations/20260922013625_icon_libraries.js";
|
|
38
38
|
import { iconCanvasToolMigration } from "../migrations/20260923005318_icon_canvas_tool.js";
|
|
39
39
|
import { computedValuesAndRepeatedNodesMigration } from "../migrations/20260923112910_computed_values_and_repeated_nodes.js";
|
|
40
|
+
import { transitionTokenValueMigration } from "../migrations/20260923144958_transition_token_value.js";
|
|
40
41
|
//#region src/configs/system.ts
|
|
41
42
|
/**
|
|
42
43
|
* `System` — the design-system config TYPE. Declares the exact kinds a design system owns (tokens,
|
|
@@ -94,5 +95,6 @@ if (!registeredSchemaMigrations().has(20260921044042)) registerSchemaMigrations(
|
|
|
94
95
|
if (!registeredSchemaMigrations().has(20260922013625)) registerSchemaMigrations(iconLibrariesMigration);
|
|
95
96
|
if (!registeredSchemaMigrations().has(20260923005318)) registerSchemaMigrations(iconCanvasToolMigration);
|
|
96
97
|
if (!registeredSchemaMigrations().has(20260923112910)) registerSchemaMigrations(computedValuesAndRepeatedNodesMigration);
|
|
98
|
+
if (!registeredSchemaMigrations().has(20260923144958)) registerSchemaMigrations(transitionTokenValueMigration);
|
|
97
99
|
//#endregion
|
|
98
100
|
export { System };
|
|
@@ -2,18 +2,19 @@ import { Ref } from "../../framework/utils/ref-grammar.js";
|
|
|
2
2
|
import { Ref as Ref$1 } from "../../framework/utils/refs.js";
|
|
3
3
|
import { SubEntityClass } from "../../framework/defineSubEntity.js";
|
|
4
4
|
import { EntityClass } from "../../framework/defineEntity.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ComposedValue } from "../system/composed-values.js";
|
|
6
|
+
import { DerivedColor } from "../system/color.js";
|
|
6
7
|
import { OverrideCondition } from "../system/Token.js";
|
|
7
8
|
import { z } from "zod";
|
|
8
9
|
|
|
9
10
|
//#region src/entities/native/NativeToken.d.ts
|
|
10
11
|
declare const nativeTokenValue: z.ZodType<number | boolean | string | Ref$1 | DerivedColor>;
|
|
11
12
|
declare const NativeToken: EntityClass<z.ZodObject<Omit<{
|
|
12
|
-
value: z.ZodType<string | number | Ref |
|
|
13
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
13
14
|
type: z.ZodOptional<z.ZodString>;
|
|
14
15
|
overrides: z.ZodOptional<SubEntityClass<z.ZodObject<{
|
|
15
16
|
on: z.ZodType<OverrideCondition, unknown, z.core.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
16
|
-
value: z.ZodType<string | number | Ref |
|
|
17
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
17
18
|
}, z.core.$strip>>>;
|
|
18
19
|
}, "value" | "overrides"> & {
|
|
19
20
|
value: z.ZodType<string | number | boolean | Ref | DerivedColor, unknown, z.core.$ZodTypeInternals<string | number | boolean | Ref | DerivedColor, unknown>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRef,
|
|
1
|
+
import { isRef, refTo } from "../../framework/utils/refs.js";
|
|
2
2
|
import { defineEntity } from "../../framework/defineEntity.js";
|
|
3
3
|
import { Composite } from "./Composite.js";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -14,10 +14,7 @@ const WEB_ACTIVATIONS = [
|
|
|
14
14
|
"composite"
|
|
15
15
|
];
|
|
16
16
|
/** A ref to a modifier, spelled out because the kind's own class is what this is a field of. */
|
|
17
|
-
const modifierRef =
|
|
18
|
-
ref: true,
|
|
19
|
-
refKind: "modifier"
|
|
20
|
-
});
|
|
17
|
+
const modifierRef = refTo("modifier");
|
|
21
18
|
/**
|
|
22
19
|
* A modifier group's own fields.
|
|
23
20
|
*
|
|
@@ -2,7 +2,7 @@ import { Ref } from "../../framework/utils/ref-grammar.js";
|
|
|
2
2
|
import { Ref as Ref$1 } from "../../framework/utils/refs.js";
|
|
3
3
|
import { SubEntityClass } from "../../framework/defineSubEntity.js";
|
|
4
4
|
import { EntityClass } from "../../framework/defineEntity.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ComposedValue } from "./composed-values.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
|
|
8
8
|
//#region src/entities/system/Token.d.ts
|
|
@@ -40,22 +40,22 @@ declare function defineOverride<TValue extends z.ZodTypeAny>(value: TValue): Sub
|
|
|
40
40
|
value: TValue;
|
|
41
41
|
}, z.core.$strip>>;
|
|
42
42
|
declare const tokenFields: z.ZodObject<{
|
|
43
|
-
value: z.ZodType<string | number | Ref |
|
|
43
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
44
44
|
type: z.ZodOptional<z.ZodString>;
|
|
45
45
|
overrides: z.ZodOptional<SubEntityClass<z.ZodObject<{
|
|
46
46
|
on: z.ZodType<OverrideCondition, unknown, z.core.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
47
|
-
value: z.ZodType<string | number | Ref |
|
|
47
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
48
48
|
}, z.core.$strip>>>;
|
|
49
49
|
}, z.core.$strip>;
|
|
50
50
|
/** A token's stored body — what a `create` writes and what `Token.get` hands back typed. Exported
|
|
51
51
|
* so a consumer building one names the entity's own shape instead of restating it. */
|
|
52
52
|
type TokenBody = z.infer<typeof tokenFields>;
|
|
53
53
|
declare const Token: EntityClass<z.ZodObject<{
|
|
54
|
-
value: z.ZodType<string | number | Ref |
|
|
54
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
55
55
|
type: z.ZodOptional<z.ZodString>;
|
|
56
56
|
overrides: z.ZodOptional<SubEntityClass<z.ZodObject<{
|
|
57
57
|
on: z.ZodType<OverrideCondition, unknown, z.core.$ZodTypeInternals<OverrideCondition, unknown>>;
|
|
58
|
-
value: z.ZodType<string | number | Ref |
|
|
58
|
+
value: z.ZodType<string | number | Ref | ComposedValue, unknown, z.core.$ZodTypeInternals<string | number | Ref | ComposedValue, unknown>>;
|
|
59
59
|
}, z.core.$strip>>>;
|
|
60
60
|
}, z.core.$strip>, z.ZodObject<{
|
|
61
61
|
cssPrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isRef, pathOf, ref, sourceOf } from "../../framework/utils/refs.js";
|
|
2
2
|
import { defineEntity } from "../../framework/defineEntity.js";
|
|
3
3
|
import { defineSubEntity } from "../../framework/defineSubEntity.js";
|
|
4
|
-
import {
|
|
4
|
+
import { composedValueSchemas } from "./composed-values.js";
|
|
5
5
|
import { Font } from "./Font.js";
|
|
6
6
|
import { Modifier } from "./Modifier.js";
|
|
7
7
|
import { z } from "zod";
|
|
@@ -28,9 +28,8 @@ const tokenValue = z.union([
|
|
|
28
28
|
z.number(),
|
|
29
29
|
z.lazy(() => Token),
|
|
30
30
|
Font,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
], { error: "a token's `value` is one CSS value as a string (`#1DB954`, `4px`, `\"Circular\", sans-serif`), a number, a ref to another token or to a font (`{ \"__ref\": \"font:<name>\" }`), a derived color (`{ \"op\": \"darken\", \"color\": { \"__ref\": \"token:color/brand\" }, \"amount\": 10 }`) or a gradient. It is required; a font family is a string value or a `font` entity, never a field of its own." });
|
|
31
|
+
...composedValueSchemas
|
|
32
|
+
], { error: "a token's `value` is one CSS value as a string (`#1DB954`, `4px`, `\"Circular\", sans-serif`), a number, a ref to another token or to a font (`{ \"__ref\": \"font:<name>\" }`), a derived color (`{ \"op\": \"darken\", \"color\": { \"__ref\": \"token:color/brand\" }, \"amount\": 10 }`), a gradient, or a transition (`{ \"transition\": [{ \"properties\": [\"background-color\"], \"timing\": { \"__ref\": \"token:motion/color\" } }] }`). It is required; a font family is a string value or a `font` entity, never a field of its own." });
|
|
34
33
|
/**
|
|
35
34
|
* What an override applies under: one modifier, or several that all hold at once (`dark` and `lg`
|
|
36
35
|
* together). Each is a ref, so the override is an ordinary edge: the dependency graph sees every
|
|
@@ -43,6 +43,9 @@ declare function isGradient(value: unknown): value is Gradient;
|
|
|
43
43
|
declare function linearGradient(spec: Omit<Gradient, 'gradient'>): Gradient;
|
|
44
44
|
/** Whether a value is a derived colour — the test the renderers branch on. */
|
|
45
45
|
declare function isDerivedColor(value: unknown): value is DerivedColor;
|
|
46
|
+
/** The interpolation space each op is authored in: `oklch` for shading (perceptually even), `srgb`
|
|
47
|
+
* for alpha. */
|
|
48
|
+
declare const DERIVED_COLOR_SPACE: Record<DerivedColor['op'], string>;
|
|
46
49
|
/** Blend toward black in light mode and white in dark — so a hover state darkens in both. */
|
|
47
50
|
declare function darken(color: ColorValue, amount: number): DerivedColor;
|
|
48
51
|
/** Mirror of {@link darken}: toward white in light mode, black in dark. */
|
|
@@ -61,4 +64,4 @@ declare function renderDerivedColor(value: DerivedColor, render: (color: ColorVa
|
|
|
61
64
|
/** A gradient as CSS — `linear-gradient(to right, transparent 0%, var(--uds-bg-primary) 50%)`. */
|
|
62
65
|
declare function renderGradient(value: Gradient, render: (color: ColorValue) => string): string;
|
|
63
66
|
//#endregion
|
|
64
|
-
export { ColorValue, DerivedColor, Gradient, alpha, darken, isDerivedColor, isGradient, lighten, linearGradient, mix, renderDerivedColor, renderGradient };
|
|
67
|
+
export { ColorValue, DERIVED_COLOR_SPACE, DerivedColor, Gradient, alpha, darken, isDerivedColor, isGradient, lighten, linearGradient, mix, renderDerivedColor, renderGradient };
|
|
@@ -63,13 +63,21 @@ const derivedColor = z.lazy(() => z.strictObject({
|
|
|
63
63
|
function isDerivedColor(value) {
|
|
64
64
|
return typeof value === "object" && value !== null && typeof value.op === "string" && "color" in value;
|
|
65
65
|
}
|
|
66
|
+
/** The interpolation space each op is authored in: `oklch` for shading (perceptually even), `srgb`
|
|
67
|
+
* for alpha. */
|
|
68
|
+
const DERIVED_COLOR_SPACE = {
|
|
69
|
+
darken: "oklch",
|
|
70
|
+
lighten: "oklch",
|
|
71
|
+
alpha: "srgb",
|
|
72
|
+
mix: "oklch"
|
|
73
|
+
};
|
|
66
74
|
/** Blend toward black in light mode and white in dark — so a hover state darkens in both. */
|
|
67
75
|
function darken(color, amount) {
|
|
68
76
|
return {
|
|
69
77
|
op: "darken",
|
|
70
78
|
color,
|
|
71
79
|
amount,
|
|
72
|
-
space:
|
|
80
|
+
space: DERIVED_COLOR_SPACE.darken
|
|
73
81
|
};
|
|
74
82
|
}
|
|
75
83
|
/** Mirror of {@link darken}: toward white in light mode, black in dark. */
|
|
@@ -78,7 +86,7 @@ function lighten(color, amount) {
|
|
|
78
86
|
op: "lighten",
|
|
79
87
|
color,
|
|
80
88
|
amount,
|
|
81
|
-
space:
|
|
89
|
+
space: DERIVED_COLOR_SPACE.lighten
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
/** `alpha(color, 0.2)` — the colour at 20% opacity. Takes a 0–1 opacity, like CSS. */
|
|
@@ -87,11 +95,11 @@ function alpha(color, opacity) {
|
|
|
87
95
|
op: "alpha",
|
|
88
96
|
color,
|
|
89
97
|
amount: Math.round(Math.max(0, Math.min(1, opacity)) * 100),
|
|
90
|
-
space:
|
|
98
|
+
space: DERIVED_COLOR_SPACE.alpha
|
|
91
99
|
};
|
|
92
100
|
}
|
|
93
101
|
/** `mix(a, b, 30)` — 30% of the way from `a` to `b`. */
|
|
94
|
-
function mix(color, towards, amount, space =
|
|
102
|
+
function mix(color, towards, amount, space = DERIVED_COLOR_SPACE.mix) {
|
|
95
103
|
return {
|
|
96
104
|
op: "mix",
|
|
97
105
|
color,
|
|
@@ -101,6 +109,52 @@ function mix(color, towards, amount, space = "oklch") {
|
|
|
101
109
|
};
|
|
102
110
|
}
|
|
103
111
|
/**
|
|
112
|
+
* The helper call that authors a stored derived colour, or `undefined` for one no helper produces (a
|
|
113
|
+
* `darken` in another space, an `alpha` at a fractional percent). `alpha` stores a 0–100 percent and
|
|
114
|
+
* takes a 0–1 opacity, so the argument is the percent scaled back. A `darken`, `lighten` or `mix`
|
|
115
|
+
* with no `space` renders in `oklch`, so it is the helper's own value; an `alpha` with none renders
|
|
116
|
+
* in `oklch` too, which is not what `alpha()` writes, so it stays an object.
|
|
117
|
+
*/
|
|
118
|
+
function derivedColorAuthoring(value) {
|
|
119
|
+
if (value.op === "darken" || value.op === "lighten") {
|
|
120
|
+
if ((value.space ?? DERIVED_COLOR_SPACE[value.op]) !== DERIVED_COLOR_SPACE[value.op] || value.with !== void 0) return;
|
|
121
|
+
return {
|
|
122
|
+
helper: value.op,
|
|
123
|
+
args: [value.color, value.amount]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (value.op === "alpha") {
|
|
127
|
+
const whole = Number.isInteger(value.amount);
|
|
128
|
+
const inRange = value.amount >= 0 && value.amount <= 100;
|
|
129
|
+
if (value.space !== DERIVED_COLOR_SPACE.alpha || value.with !== void 0 || !whole || !inRange) return;
|
|
130
|
+
return {
|
|
131
|
+
helper: "alpha",
|
|
132
|
+
args: [value.color, value.amount / 100]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (value.with === void 0) return void 0;
|
|
136
|
+
const args = [
|
|
137
|
+
value.color,
|
|
138
|
+
value.with,
|
|
139
|
+
value.amount
|
|
140
|
+
];
|
|
141
|
+
if (value.space !== void 0 && value.space !== DERIVED_COLOR_SPACE.mix) args.push(value.space);
|
|
142
|
+
return {
|
|
143
|
+
helper: "mix",
|
|
144
|
+
args
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** The `linearGradient({...})` call that authors a stored gradient; a radial or conic one has no
|
|
148
|
+
* helper and prints as the object it is. */
|
|
149
|
+
function gradientAuthoring(value) {
|
|
150
|
+
if (value.gradient !== "linear") return void 0;
|
|
151
|
+
const { gradient: _kind, ...spec } = value;
|
|
152
|
+
return {
|
|
153
|
+
helper: "linearGradient",
|
|
154
|
+
args: [spec]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
104
158
|
* A derived colour as CSS.
|
|
105
159
|
*
|
|
106
160
|
* `render` resolves the nested colours — passed in rather than imported, because resolving a token
|
|
@@ -120,4 +174,4 @@ function renderGradient(value, render) {
|
|
|
120
174
|
return `${value.repeating ? "repeating-" : ""}${value.gradient}-gradient(${[...head, stops].join(", ")})`;
|
|
121
175
|
}
|
|
122
176
|
//#endregion
|
|
123
|
-
export { alpha, darken, derivedColor, gradient, isDerivedColor, isGradient, lighten, linearGradient, mix, renderDerivedColor, renderGradient };
|
|
177
|
+
export { DERIVED_COLOR_SPACE, alpha, darken, derivedColor, derivedColorAuthoring, gradient, gradientAuthoring, isDerivedColor, isGradient, lighten, linearGradient, mix, renderDerivedColor, renderGradient };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Transition } from "./transition.js";
|
|
2
|
+
import { DerivedColor, Gradient } from "./color.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/entities/system/composed-values.d.ts
|
|
6
|
+
type ComposedValue = DerivedColor | Gradient | Transition;
|
|
7
|
+
/** How the write engine spells a stored value: the helper's name and its positional arguments. */
|
|
8
|
+
interface ComposedValueAuthoring {
|
|
9
|
+
readonly helper: string;
|
|
10
|
+
readonly args: readonly unknown[];
|
|
11
|
+
}
|
|
12
|
+
interface ComposedValueForm<T extends ComposedValue = ComposedValue> {
|
|
13
|
+
readonly schema: z.ZodType<T>;
|
|
14
|
+
readonly is: (value: unknown) => value is T;
|
|
15
|
+
/** The value as CSS, with `render` resolving each part it holds. */
|
|
16
|
+
readonly render: (value: T, render: (part: unknown) => string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* The helper call that builds this value, or `undefined` for a value no helper produces (a radial
|
|
19
|
+
* gradient, a `darken` in an unexpected space). Such a value is written as the object it is.
|
|
20
|
+
*/
|
|
21
|
+
readonly authoring: (value: T) => ComposedValueAuthoring | undefined;
|
|
22
|
+
}
|
|
23
|
+
declare const composedValueForms: readonly ComposedValueForm[];
|
|
24
|
+
/** The forms' schemas, in registry order, for a value union to spread. */
|
|
25
|
+
declare const composedValueSchemas: readonly z.ZodType<ComposedValue>[];
|
|
26
|
+
/** The form a value takes, or `undefined` for anything that is not composed. A string or a number
|
|
27
|
+
* answers before the forms are asked, since every form is an object. */
|
|
28
|
+
declare function composedValueFormOf(value: unknown): ComposedValueForm | undefined;
|
|
29
|
+
/** Whether a value is one of the composed forms. */
|
|
30
|
+
declare function isComposedValue(value: unknown): value is ComposedValue;
|
|
31
|
+
/** A composed value as CSS, with `render` resolving each part it holds. */
|
|
32
|
+
declare function renderComposedValue(value: ComposedValue, render: (part: unknown) => string): string;
|
|
33
|
+
/** The helper call that authors a composed value, or `undefined` when none does. */
|
|
34
|
+
declare function composedValueAuthoring(value: unknown): ComposedValueAuthoring | undefined;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ComposedValue, ComposedValueAuthoring, ComposedValueForm, composedValueAuthoring, composedValueFormOf, composedValueForms, composedValueSchemas, isComposedValue, renderComposedValue };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { derivedColor, derivedColorAuthoring, gradient, gradientAuthoring, isDerivedColor, isGradient, renderDerivedColor, renderGradient } from "./color.js";
|
|
2
|
+
import { isTransition, renderTransition, transitionAuthoring, transitionValue } from "./transition.js";
|
|
3
|
+
//#region src/entities/system/composed-values.ts
|
|
4
|
+
/** A form written against its own type, widened to the union the registry holds. `render` and
|
|
5
|
+
* `authoring` take the narrower type, which the union's signature cannot express without this. */
|
|
6
|
+
function form(spec) {
|
|
7
|
+
return spec;
|
|
8
|
+
}
|
|
9
|
+
const composedValueForms = [
|
|
10
|
+
form({
|
|
11
|
+
schema: derivedColor,
|
|
12
|
+
is: isDerivedColor,
|
|
13
|
+
render: renderDerivedColor,
|
|
14
|
+
authoring: derivedColorAuthoring
|
|
15
|
+
}),
|
|
16
|
+
form({
|
|
17
|
+
schema: gradient,
|
|
18
|
+
is: isGradient,
|
|
19
|
+
render: renderGradient,
|
|
20
|
+
authoring: gradientAuthoring
|
|
21
|
+
}),
|
|
22
|
+
form({
|
|
23
|
+
schema: transitionValue,
|
|
24
|
+
is: isTransition,
|
|
25
|
+
render: renderTransition,
|
|
26
|
+
authoring: transitionAuthoring
|
|
27
|
+
})
|
|
28
|
+
];
|
|
29
|
+
/** The forms' schemas, in registry order, for a value union to spread. */
|
|
30
|
+
const composedValueSchemas = composedValueForms.map((entry) => entry.schema);
|
|
31
|
+
/** The form a value takes, or `undefined` for anything that is not composed. A string or a number
|
|
32
|
+
* answers before the forms are asked, since every form is an object. */
|
|
33
|
+
function composedValueFormOf(value) {
|
|
34
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
35
|
+
return composedValueForms.find((entry) => entry.is(value));
|
|
36
|
+
}
|
|
37
|
+
/** Whether a value is one of the composed forms. */
|
|
38
|
+
function isComposedValue(value) {
|
|
39
|
+
return composedValueFormOf(value) !== void 0;
|
|
40
|
+
}
|
|
41
|
+
/** A composed value as CSS, with `render` resolving each part it holds. */
|
|
42
|
+
function renderComposedValue(value, render) {
|
|
43
|
+
const entry = composedValueFormOf(value);
|
|
44
|
+
if (!entry) throw new Error("not a composed value");
|
|
45
|
+
return entry.render(value, render);
|
|
46
|
+
}
|
|
47
|
+
/** The helper call that authors a composed value, or `undefined` when none does. */
|
|
48
|
+
function composedValueAuthoring(value) {
|
|
49
|
+
return composedValueFormOf(value)?.authoring(value);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { composedValueAuthoring, composedValueFormOf, composedValueForms, composedValueSchemas, isComposedValue, renderComposedValue };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComposedValue } from "./composed-values.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/entities/system/style-bag.d.ts
|
|
@@ -13,7 +13,7 @@ import { z } from "zod";
|
|
|
13
13
|
*/
|
|
14
14
|
type StyleValue = string | number | boolean | {
|
|
15
15
|
readonly __ref: string;
|
|
16
|
-
} |
|
|
16
|
+
} | ComposedValue | {
|
|
17
17
|
readonly [key: string]: StyleValue;
|
|
18
18
|
};
|
|
19
19
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isExtendedRef, isRef, ref, refSchema, splitRef } from "../../framework/utils/refs.js";
|
|
2
2
|
import { defineSubEntity } from "../../framework/defineSubEntity.js";
|
|
3
|
-
import {
|
|
3
|
+
import { composedValueSchemas } from "./composed-values.js";
|
|
4
4
|
import { isCssProperty, kebabCase } from "../../css/values.js";
|
|
5
5
|
import { valueSchemaOf } from "../../framework/value-domain.js";
|
|
6
6
|
import { glyphLeafOf, glyphPackageRef } from "./glyph-identity.js";
|
|
@@ -14,8 +14,7 @@ const styleValue = z.lazy(() => z.union([
|
|
|
14
14
|
z.number(),
|
|
15
15
|
z.boolean(),
|
|
16
16
|
refSchema,
|
|
17
|
-
|
|
18
|
-
gradient,
|
|
17
|
+
...composedValueSchemas,
|
|
19
18
|
glyphPackageRef,
|
|
20
19
|
z.record(z.string(), styleValue)
|
|
21
20
|
]));
|
|
@@ -25,8 +24,7 @@ const anatomyPropValue = z.lazy(() => z.union([
|
|
|
25
24
|
z.boolean(),
|
|
26
25
|
z.null(),
|
|
27
26
|
refSchema,
|
|
28
|
-
|
|
29
|
-
gradient,
|
|
27
|
+
...composedValueSchemas,
|
|
30
28
|
z.array(z.union([
|
|
31
29
|
z.string(),
|
|
32
30
|
z.number(),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Ref } from "../../framework/utils/refs.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/entities/system/transition.d.ts
|
|
5
|
+
/** A timing part of a transition: a literal (`'150ms ease-out'`) or a ref to the entity that names it,
|
|
6
|
+
* a token or a motion role. */
|
|
7
|
+
type TimingValue = string | Ref;
|
|
8
|
+
interface TransitionSegment {
|
|
9
|
+
/** The CSS properties this segment animates. Each renders as its own `<property> <timing>` entry. */
|
|
10
|
+
readonly properties: readonly string[];
|
|
11
|
+
/** The duration and easing, together, as a ref to the entity that names them or a literal. */
|
|
12
|
+
readonly timing: TimingValue;
|
|
13
|
+
readonly delay?: TimingValue;
|
|
14
|
+
}
|
|
15
|
+
interface Transition {
|
|
16
|
+
readonly transition: readonly TransitionSegment[];
|
|
17
|
+
}
|
|
18
|
+
/** Whether a value is a composed transition — the test the renderers branch on. Every segment must
|
|
19
|
+
* carry its properties and timing, so a record that merely holds a list under `transition` is not
|
|
20
|
+
* one. */
|
|
21
|
+
declare function isTransition(value: unknown): value is Transition;
|
|
22
|
+
/**
|
|
23
|
+
* `transition({ properties: ['translate', 'scale'], timing: Token.ref('motion/expressive') })`.
|
|
24
|
+
* Several segments compose one transition whose properties run on different roles.
|
|
25
|
+
*/
|
|
26
|
+
declare function transition(...segments: readonly TransitionSegment[]): Transition;
|
|
27
|
+
/**
|
|
28
|
+
* A transition as CSS — `background-color var(--uds-motion-color), box-shadow var(--uds-motion-color)`.
|
|
29
|
+
*
|
|
30
|
+
* `render` resolves the timing parts. It is passed in rather than imported because resolving a ref
|
|
31
|
+
* to a `var()` is the projection layer's job and this module is the value's shape.
|
|
32
|
+
*/
|
|
33
|
+
declare function renderTransition(value: Transition, render: (part: TimingValue) => string): string;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { TimingValue, Transition, TransitionSegment, isTransition, renderTransition, transition };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { refSchema } from "../../framework/utils/refs.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/entities/system/transition.ts
|
|
4
|
+
/**
|
|
5
|
+
* A CSS transition composed from the properties it animates and the timing they run on —
|
|
6
|
+
* `transition({ properties: ['background-color', 'box-shadow'], timing: Token.ref('motion/color') })`.
|
|
7
|
+
*
|
|
8
|
+
* A design system names its timing once, as a motion role (`motion/color` is "150ms linear"), and a
|
|
9
|
+
* transition is that role applied to some properties. Spelled as one string the role is copied into
|
|
10
|
+
* the transition and stops following the token: retune the duration and the transition keeps the old
|
|
11
|
+
* one. Held as parts, the role is a ref, so it renders as a `var()` and the dependency graph sees it.
|
|
12
|
+
*
|
|
13
|
+
* Usable wherever a style value is — a token's value, a style bag — for the same reason a gradient
|
|
14
|
+
* is: it is a value, not its own kind.
|
|
15
|
+
*/
|
|
16
|
+
const timingValue = z.union([z.string(), refSchema]);
|
|
17
|
+
const transitionValue = z.strictObject({ transition: z.array(z.strictObject({
|
|
18
|
+
properties: z.array(z.string()).min(1),
|
|
19
|
+
timing: timingValue,
|
|
20
|
+
delay: timingValue.optional()
|
|
21
|
+
})).min(1) });
|
|
22
|
+
/** Whether a value is a composed transition — the test the renderers branch on. Every segment must
|
|
23
|
+
* carry its properties and timing, so a record that merely holds a list under `transition` is not
|
|
24
|
+
* one. */
|
|
25
|
+
function isTransition(value) {
|
|
26
|
+
if (typeof value !== "object" || value === null) return false;
|
|
27
|
+
const segments = value.transition;
|
|
28
|
+
return Array.isArray(segments) && segments.every((segment) => typeof segment === "object" && segment !== null && Array.isArray(segment.properties) && "timing" in segment);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `transition({ properties: ['translate', 'scale'], timing: Token.ref('motion/expressive') })`.
|
|
32
|
+
* Several segments compose one transition whose properties run on different roles.
|
|
33
|
+
*/
|
|
34
|
+
function transition(...segments) {
|
|
35
|
+
return { transition: segments };
|
|
36
|
+
}
|
|
37
|
+
/** The `transition(...)` call that authors a stored value: its segments are the arguments. */
|
|
38
|
+
function transitionAuthoring(value) {
|
|
39
|
+
return {
|
|
40
|
+
helper: "transition",
|
|
41
|
+
args: value.transition
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A transition as CSS — `background-color var(--uds-motion-color), box-shadow var(--uds-motion-color)`.
|
|
46
|
+
*
|
|
47
|
+
* `render` resolves the timing parts. It is passed in rather than imported because resolving a ref
|
|
48
|
+
* to a `var()` is the projection layer's job and this module is the value's shape.
|
|
49
|
+
*/
|
|
50
|
+
function renderTransition(value, render) {
|
|
51
|
+
return value.transition.flatMap((segment) => {
|
|
52
|
+
const timing = [segment.timing, segment.delay].filter((part) => part !== void 0).map(render);
|
|
53
|
+
return segment.properties.map((property) => [property, ...timing].join(" "));
|
|
54
|
+
}).join(", ");
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { isTransition, renderTransition, transition, transitionAuthoring, transitionValue };
|
|
@@ -72,7 +72,7 @@ interface RecordedSource {
|
|
|
72
72
|
* The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
|
|
73
73
|
* that replaced it (see `detectedWireVersion`).
|
|
74
74
|
*/
|
|
75
|
-
declare const SERIALIZED_CONFIG_VERSION =
|
|
75
|
+
declare const SERIALIZED_CONFIG_VERSION = 20260923144958;
|
|
76
76
|
interface SerializedConfig {
|
|
77
77
|
/** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
|
|
78
78
|
readonly version: number;
|
package/dist/framework/Config.js
CHANGED
|
@@ -4836,7 +4836,7 @@ var Config = class Config {
|
|
|
4836
4836
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
4837
4837
|
hydrateFrom(stored, options) {
|
|
4838
4838
|
const claimed = schemaVersionOf(stored);
|
|
4839
|
-
if (claimed >
|
|
4839
|
+
if (claimed > 20260923144958) throw new SchemaVersionTooNew(claimed);
|
|
4840
4840
|
const wire = upgradeSerializedConfig(stored);
|
|
4841
4841
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating, or port the repo once with \`uds migrate\`.`);
|
|
4842
4842
|
const leftover = wire.options;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRef, kindOf, pathOf, ref, refSchema, sourceOf } from "./utils/refs.js";
|
|
1
|
+
import { isRef, kindOf, pathOf, ref, refSchema, refTo, sourceOf } from "./utils/refs.js";
|
|
2
2
|
import { CONFIG_OPERATION_KIND } from "./config-operation-kind.js";
|
|
3
3
|
import { resolveFields } from "./schemas.js";
|
|
4
4
|
import { buildKind } from "./registry.js";
|
|
@@ -129,10 +129,7 @@ function defineEntity(spec) {
|
|
|
129
129
|
authoredValue: spec.authoredValue,
|
|
130
130
|
invariants: spec.invariants
|
|
131
131
|
});
|
|
132
|
-
const schema =
|
|
133
|
-
ref: true,
|
|
134
|
-
refKind: spec.kind
|
|
135
|
-
});
|
|
132
|
+
const schema = refTo(spec.kind);
|
|
136
133
|
/**
|
|
137
134
|
* The path a caller named — from a path, a ref object, or a ref string (`component:Box`, which is
|
|
138
135
|
* what a spec element's `type` is, so a caller reading one needn't take it apart first).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isRef, kindOf, memberOf, pathOf, ref, refLeaf, sourceOf, splitRef } from "./utils/refs.js";
|
|
2
2
|
import { forwardedPropName, forwardsOf } from "../entities/system/element.js";
|
|
3
3
|
import { classPrefixOf, varPrefixOf } from "../entities/system/Settings.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isComposedValue, renderComposedValue } from "../entities/system/composed-values.js";
|
|
5
5
|
import { fontFamilyStack } from "../entities/system/Font.js";
|
|
6
6
|
import { listedIn } from "./utils/enumerated.js";
|
|
7
7
|
import { modifierCategory } from "../entities/system/Modifier.js";
|
|
@@ -488,8 +488,7 @@ function resolveTokenValueUnder(config, path, condition, seen = /* @__PURE__ */
|
|
|
488
488
|
* ordinary call — it is `config`'s own prefix. */
|
|
489
489
|
function renderStyleValue(config, value, varPrefix) {
|
|
490
490
|
if (Array.isArray(value)) return value.map((part) => renderStyleValue(config, part, varPrefix)).join(" ");
|
|
491
|
-
if (
|
|
492
|
-
if (isGradient(value)) return renderGradient(value, (color) => renderStyleValue(config, color, varPrefix));
|
|
491
|
+
if (isComposedValue(value)) return renderComposedValue(value, (part) => renderStyleValue(config, part, varPrefix));
|
|
493
492
|
if (isRef(value)) {
|
|
494
493
|
const source = config.configFor(value);
|
|
495
494
|
if (!source) return "";
|
|
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
|
|
|
15
15
|
* sets this constant to its own older timestamp; the merge ref then carries a registered migration
|
|
16
16
|
* newer than the constant, and the assertion fails until the author re-mints.
|
|
17
17
|
*/
|
|
18
|
-
declare const CURRENT_SCHEMA_VERSION =
|
|
18
|
+
declare const CURRENT_SCHEMA_VERSION = 20260923144958;
|
|
19
19
|
/** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
|
|
20
20
|
* and a raw old-shape record both flow in without casts. */
|
|
21
21
|
interface VersionStamped {
|