@yahoo/uds-create-config 5.19.1 → 5.21.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/documentation.js +1 -1
- package/dist/configs/system.d.ts +607 -2
- package/dist/configs/system.js +8 -0
- package/dist/entities/documentation/Documentation.d.ts +1 -1
- package/dist/entities/system/Component.js +1 -2
- package/dist/entities/system/LinkedSystem.d.ts +45 -5
- package/dist/entities/system/LinkedSystem.js +55 -4
- package/dist/entities/system/Modifier.d.ts +5 -2
- package/dist/entities/system/Modifier.js +5 -2
- package/dist/entities/system/Motion.d.ts +578 -4
- package/dist/entities/system/Motion.js +233 -70
- package/dist/entities/system/css-motion-reach.d.ts +62 -0
- package/dist/entities/system/css-motion-reach.js +195 -0
- package/dist/entities/system/css-motion.d.ts +55 -0
- package/dist/entities/system/css-motion.js +445 -0
- package/dist/entities/system/css-timing.d.ts +40 -0
- package/dist/entities/system/css-timing.js +247 -0
- package/dist/entities/system/easings.d.ts +29 -0
- package/dist/entities/system/easings.js +99 -0
- package/dist/entities/system/motion-convert.d.ts +42 -0
- package/dist/entities/system/motion-convert.js +517 -0
- package/dist/entities/system/motion-presets.d.ts +9 -1
- package/dist/entities/system/motion-presets.js +27 -38
- package/dist/entities/system/motion-variants.js +66 -49
- package/dist/entities/system/reduced-motion.d.ts +20 -0
- package/dist/entities/system/reduced-motion.js +42 -0
- package/dist/framework/Config.d.ts +32 -2
- package/dist/framework/Config.js +117 -7
- package/dist/framework/class-names.d.ts +2 -1
- package/dist/framework/class-names.js +31 -13
- package/dist/framework/defineEntity.d.ts +3 -1
- package/dist/framework/defineEntity.js +2 -0
- package/dist/framework/registered.d.ts +8 -1
- package/dist/framework/registry.d.ts +38 -1
- package/dist/framework/registry.js +3 -1
- package/dist/framework/render-spec.js +7 -2
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/signature.js +4 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/migrations/2.0.0/v1-artifact.d.ts +606 -2
- package/dist/migrations/20261009000514_css_motion_states.d.ts +11 -0
- package/dist/migrations/20261009000514_css_motion_states.js +10 -0
- package/dist/migrations/20261009022722_starting_style_modifier.d.ts +9 -0
- package/dist/migrations/20261009022722_starting_style_modifier.js +10 -0
- package/dist/migrations/20261009181635_css_motion_strict.d.ts +23 -0
- package/dist/migrations/20261009181635_css_motion_strict.js +152 -0
- package/dist/migrations/20261009193004_link_override_ref.d.ts +9 -0
- package/dist/migrations/20261009193004_link_override_ref.js +10 -0
- package/dist/spec/links.d.ts +2 -0
- package/dist/spec/links.js +2 -0
- package/dist/spec/motion.d.ts +7 -0
- package/dist/spec/motion.js +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A modifier may activate as `starting-style`, which wraps its block in `@starting-style`. Every
|
|
3
|
+
* stored modifier activates as one of the existing types, so the wire shape of every stored config
|
|
4
|
+
* is unchanged.
|
|
5
|
+
* Additive, so the envelope passes through as it is.
|
|
6
|
+
*/
|
|
7
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
8
|
+
export declare const STARTING_STYLE_MODIFIER_VERSION = 20261009022722;
|
|
9
|
+
export declare const startingStyleModifierMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261009022722_starting_style_modifier.ts
|
|
2
|
+
const STARTING_STYLE_MODIFIER_VERSION = 20261009022722;
|
|
3
|
+
const startingStyleModifierMigration = {
|
|
4
|
+
version: STARTING_STYLE_MODIFIER_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { STARTING_STYLE_MODIFIER_VERSION, startingStyleModifierMigration };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A CSS motion preset takes only CSS fields. The fields only a JS preset has (`layout`, `drag`,
|
|
3
|
+
* `dragConstraints`, `dragElastic`, `whileDrag`) and a state's `transitionEnd` are gone from it, and
|
|
4
|
+
* its `transition` is CSS timing: `duration` and `delay` as CSS times, an `easing` that is CSS or a
|
|
5
|
+
* spring (`{ spring: { stiffness, damping, … } }`), and a value's own timing under `properties`.
|
|
6
|
+
* `motion/convert` rewrites a preset between the runtimes from here on.
|
|
7
|
+
*
|
|
8
|
+
* `up` rewrites a stored CSS preset written the JS way into that form. The previous version read a
|
|
9
|
+
* level with an `easing`, or a `duration` that is no number, as CSS and ignored the spring beside it,
|
|
10
|
+
* so that level keeps its CSS fields and drops the spring's. Any other level is read as `motion/react`
|
|
11
|
+
* writes one: a number is seconds, a `type: 'spring'` is a spring, and an `ease` is the easing. A
|
|
12
|
+
* draft patch that creates or replaces a CSS preset is rewritten the same way. One that updates a
|
|
13
|
+
* preset isn't, since it doesn't say which runtime the preset it writes into has.
|
|
14
|
+
*
|
|
15
|
+
* The rewrite is copied here rather than imported from `motion-convert.ts`, so a later change to the
|
|
16
|
+
* conversion can't change what this hop does.
|
|
17
|
+
*/
|
|
18
|
+
import type { RawWireConfig, SchemaMigration } from '../framework/schema-version';
|
|
19
|
+
export declare const CSS_MOTION_STRICT_VERSION = 20261009181635;
|
|
20
|
+
/** A stored CSS preset in the strict form. Anything else comes back as it is. */
|
|
21
|
+
export declare function strictCssMotion(body: unknown): unknown;
|
|
22
|
+
export declare function cssMotionStrict(json: RawWireConfig): RawWireConfig;
|
|
23
|
+
export declare const cssMotionStrictMigration: SchemaMigration;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/migrations/20261009181635_css_motion_strict.ts
|
|
3
|
+
/**
|
|
4
|
+
* A CSS motion preset takes only CSS fields. The fields only a JS preset has (`layout`, `drag`,
|
|
5
|
+
* `dragConstraints`, `dragElastic`, `whileDrag`) and a state's `transitionEnd` are gone from it, and
|
|
6
|
+
* its `transition` is CSS timing: `duration` and `delay` as CSS times, an `easing` that is CSS or a
|
|
7
|
+
* spring (`{ spring: { stiffness, damping, … } }`), and a value's own timing under `properties`.
|
|
8
|
+
* `motion/convert` rewrites a preset between the runtimes from here on.
|
|
9
|
+
*
|
|
10
|
+
* `up` rewrites a stored CSS preset written the JS way into that form. The previous version read a
|
|
11
|
+
* level with an `easing`, or a `duration` that is no number, as CSS and ignored the spring beside it,
|
|
12
|
+
* so that level keeps its CSS fields and drops the spring's. Any other level is read as `motion/react`
|
|
13
|
+
* writes one: a number is seconds, a `type: 'spring'` is a spring, and an `ease` is the easing. A
|
|
14
|
+
* draft patch that creates or replaces a CSS preset is rewritten the same way. One that updates a
|
|
15
|
+
* preset isn't, since it doesn't say which runtime the preset it writes into has.
|
|
16
|
+
*
|
|
17
|
+
* The rewrite is copied here rather than imported from `motion-convert.ts`, so a later change to the
|
|
18
|
+
* conversion can't change what this hop does.
|
|
19
|
+
*/
|
|
20
|
+
const CSS_MOTION_STRICT_VERSION = 20261009181635;
|
|
21
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
const isRef = (value) => isRecord(value) && "__ref" in value;
|
|
23
|
+
const JS_ONLY = [
|
|
24
|
+
"whileDrag",
|
|
25
|
+
"layout",
|
|
26
|
+
"drag",
|
|
27
|
+
"dragConstraints",
|
|
28
|
+
"dragElastic"
|
|
29
|
+
];
|
|
30
|
+
const STATES = [
|
|
31
|
+
"initial",
|
|
32
|
+
"animate",
|
|
33
|
+
"exit",
|
|
34
|
+
"whileHover",
|
|
35
|
+
"whileTap",
|
|
36
|
+
"whileFocus"
|
|
37
|
+
];
|
|
38
|
+
const TIMING = new Set([
|
|
39
|
+
"type",
|
|
40
|
+
"duration",
|
|
41
|
+
"delay",
|
|
42
|
+
"ease",
|
|
43
|
+
"easing",
|
|
44
|
+
"times",
|
|
45
|
+
"stiffness",
|
|
46
|
+
"damping",
|
|
47
|
+
"mass",
|
|
48
|
+
"bounce",
|
|
49
|
+
"visualDuration"
|
|
50
|
+
]);
|
|
51
|
+
const SPRING = [
|
|
52
|
+
"stiffness",
|
|
53
|
+
"damping",
|
|
54
|
+
"mass",
|
|
55
|
+
"bounce"
|
|
56
|
+
];
|
|
57
|
+
/** `motion/react`'s easings that are a Bézier curve, as the previous version spelled them. */
|
|
58
|
+
const NAMED = {
|
|
59
|
+
linear: "linear",
|
|
60
|
+
easeIn: "cubic-bezier(0.42, 0, 1, 1)",
|
|
61
|
+
easeOut: "cubic-bezier(0, 0, 0.58, 1)",
|
|
62
|
+
easeInOut: "cubic-bezier(0.42, 0, 0.58, 1)",
|
|
63
|
+
backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)"
|
|
64
|
+
};
|
|
65
|
+
const time = (value) => typeof value === "number" ? `${Math.round(value * 1e3)}ms` : value;
|
|
66
|
+
function easingOf(ease) {
|
|
67
|
+
if (isRef(ease)) return ease;
|
|
68
|
+
if (Array.isArray(ease) && ease.length === 4 && ease.every((n) => typeof n === "number")) return `cubic-bezier(${ease.join(", ")})`;
|
|
69
|
+
if (typeof ease === "string") return NAMED[ease.trim()] ?? ease.trim();
|
|
70
|
+
}
|
|
71
|
+
/** One level of a transition, as CSS timing. */
|
|
72
|
+
function timingOf(level) {
|
|
73
|
+
const out = {};
|
|
74
|
+
if (level.delay !== void 0) out.delay = time(level.delay);
|
|
75
|
+
if (Array.isArray(level.times)) out.times = level.times;
|
|
76
|
+
if (level.easing !== void 0 || level.duration !== void 0 && typeof level.duration !== "number") {
|
|
77
|
+
if (level.duration !== void 0) out.duration = time(level.duration);
|
|
78
|
+
if (level.easing !== void 0) out.easing = level.easing;
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
if (level.type === "spring") {
|
|
82
|
+
const spring = {};
|
|
83
|
+
for (const key of SPRING) if (level[key] !== void 0) spring[key] = level[key];
|
|
84
|
+
for (const key of ["duration", "visualDuration"]) if (level[key] !== void 0) spring[key] = time(level[key]);
|
|
85
|
+
out.easing = { spring };
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
if (level.duration !== void 0) out.duration = time(level.duration);
|
|
89
|
+
const easing = easingOf(level.ease);
|
|
90
|
+
if (easing !== void 0) out.easing = easing;
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** A transition as CSS: its base timing (`default` where it has one), and each value's own under
|
|
94
|
+
* `properties`. A transition already written as CSS comes back as it is. */
|
|
95
|
+
function transitionOf(transition) {
|
|
96
|
+
const out = timingOf(isRecord(transition.default) ? transition.default : transition);
|
|
97
|
+
const properties = isRecord(transition.properties) ? { ...transition.properties } : {};
|
|
98
|
+
for (const [key, value] of Object.entries(transition)) {
|
|
99
|
+
if (key === "default" || key === "properties" || TIMING.has(key)) continue;
|
|
100
|
+
if (isRecord(value) && !isRef(value)) properties[key] = timingOf(value);
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(properties).length > 0) out.properties = properties;
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function stateOf(target) {
|
|
106
|
+
if (!isRecord(target)) return target;
|
|
107
|
+
const { transitionEnd: _transitionEnd, ...rest } = target;
|
|
108
|
+
if (isRecord(rest.transition)) rest.transition = transitionOf(rest.transition);
|
|
109
|
+
return rest;
|
|
110
|
+
}
|
|
111
|
+
/** A stored CSS preset in the strict form. Anything else comes back as it is. */
|
|
112
|
+
function strictCssMotion(body) {
|
|
113
|
+
if (!isRecord(body) || body.runtime !== "css") return body;
|
|
114
|
+
const out = { ...body };
|
|
115
|
+
for (const field of JS_ONLY) delete out[field];
|
|
116
|
+
for (const state of STATES) if (out[state] !== void 0) out[state] = stateOf(out[state]);
|
|
117
|
+
if (isRecord(out.variants)) out.variants = Object.fromEntries(Object.entries(out.variants).map(([name, target]) => [name, stateOf(target)]));
|
|
118
|
+
if (isRecord(out.transition)) out.transition = transitionOf(out.transition);
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function cssMotionStrict(json) {
|
|
122
|
+
const items = json.items;
|
|
123
|
+
if (!isRecord(items) || !isRecord(items.motion)) return json;
|
|
124
|
+
const motion = Object.fromEntries(Object.entries(items.motion).map(([path, body]) => [path, strictCssMotion(body)]));
|
|
125
|
+
return {
|
|
126
|
+
...json,
|
|
127
|
+
items: {
|
|
128
|
+
...items,
|
|
129
|
+
motion
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const cssMotionStrictMigration = {
|
|
134
|
+
version: CSS_MOTION_STRICT_VERSION,
|
|
135
|
+
up: cssMotionStrict,
|
|
136
|
+
fromSchema: z.looseObject({}),
|
|
137
|
+
toSchema: z.looseObject({}).refine((json) => {
|
|
138
|
+
const items = json.items;
|
|
139
|
+
if (!isRecord(items) || !isRecord(items.motion)) return true;
|
|
140
|
+
return Object.values(items.motion).every((body) => !isRecord(body) || body.runtime !== "css" || JS_ONLY.every((field) => body[field] === void 0));
|
|
141
|
+
}, { message: "a CSS motion preset holds none of a JS preset's own fields" }),
|
|
142
|
+
upPatch(patch) {
|
|
143
|
+
if (patch.kind !== "motion" || !("data" in patch)) return patch;
|
|
144
|
+
if (patch.operation !== "create" && patch.operation !== "replace") return patch;
|
|
145
|
+
return {
|
|
146
|
+
...patch,
|
|
147
|
+
data: strictCssMotion(patch.data)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { CSS_MOTION_STRICT_VERSION, cssMotionStrictMigration };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A link's `options` entry may give `override` as a ref to another entity of the same kind, which
|
|
3
|
+
* re-points the path to it (`'js/scale': { override: Motion.ref('css/scale') }`). Every stored
|
|
4
|
+
* `override` is a body, so the wire shape of every stored config is unchanged. Additive, so the
|
|
5
|
+
* envelope passes through as it is.
|
|
6
|
+
*/
|
|
7
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
8
|
+
export declare const LINK_OVERRIDE_REF_VERSION = 20261009193004;
|
|
9
|
+
export declare const linkOverrideRefMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261009193004_link_override_ref.ts
|
|
2
|
+
const LINK_OVERRIDE_REF_VERSION = 20261009193004;
|
|
3
|
+
const linkOverrideRefMigration = {
|
|
4
|
+
version: LINK_OVERRIDE_REF_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { LINK_OVERRIDE_REF_VERSION, linkOverrideRefMigration };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { REDUCED_MOTION_ATTRIBUTE, REDUCED_MOTION_VALUES, ReducedMotion, ReducedMotionLayer, reducedMotionLayers } from "../entities/system/reduced-motion.js";
|
|
2
|
+
import { MOTION_PACKAGE, presetReducedMotions } from "../entities/system/motion-presets.js";
|
|
3
|
+
import { CSS_MOTION_STATES, CssMotionKeyframeList, CssMotionState, CssMotionTiming, CssMotionTimings, CssMotionTransitions, cssMotionExitDuration, cssMotionKeyframeLists, cssMotionTokens, cssMotionTransitions } from "../entities/system/css-motion.js";
|
|
4
|
+
import { MotionConversion, MotionConversionNote, MotionConversionPlan, MotionRuntime, convertMotion } from "../entities/system/motion-convert.js";
|
|
5
|
+
import { CssMotionExitOnUnmount, CssMotionPlacement, LinkedMotionSwap, SwappedLinkJsMotion, cssMotionExitsOnUnmount, cssMotionPlacements, cssMotionVariantGroups, linkedMotionSwaps, swappedLinkJsMotions } from "../entities/system/css-motion-reach.js";
|
|
6
|
+
import { SpringOptions, SpringTiming, cssEasing, springTiming } from "../entities/system/css-timing.js";
|
|
7
|
+
export { CSS_MOTION_STATES, type CssMotionExitOnUnmount, type CssMotionKeyframeList, type CssMotionPlacement, type CssMotionState, type CssMotionTiming, type CssMotionTimings, type CssMotionTransitions, type LinkedMotionSwap, MOTION_PACKAGE, type MotionConversion, type MotionConversionNote, type MotionConversionPlan, type MotionRuntime, REDUCED_MOTION_ATTRIBUTE, REDUCED_MOTION_VALUES, type ReducedMotion, type ReducedMotionLayer, type SpringOptions, type SpringTiming, type SwappedLinkJsMotion, convertMotion, cssEasing, cssMotionExitDuration, cssMotionExitsOnUnmount, cssMotionKeyframeLists, cssMotionPlacements, cssMotionTokens, cssMotionTransitions, cssMotionVariantGroups, linkedMotionSwaps, presetReducedMotions, reducedMotionLayers, springTiming, swappedLinkJsMotions };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { cssEasing, springTiming } from "../entities/system/css-timing.js";
|
|
2
|
+
import { convertMotion } from "../entities/system/motion-convert.js";
|
|
3
|
+
import { cssMotionExitsOnUnmount, cssMotionPlacements, cssMotionVariantGroups, linkedMotionSwaps, swappedLinkJsMotions } from "../entities/system/css-motion-reach.js";
|
|
4
|
+
import { REDUCED_MOTION_ATTRIBUTE, REDUCED_MOTION_VALUES, reducedMotionLayers } from "../entities/system/reduced-motion.js";
|
|
5
|
+
import { MOTION_PACKAGE, presetReducedMotions } from "../entities/system/motion-presets.js";
|
|
6
|
+
import { CSS_MOTION_STATES, cssMotionExitDuration, cssMotionKeyframeLists, cssMotionTokens, cssMotionTransitions } from "../entities/system/css-motion.js";
|
|
7
|
+
export { CSS_MOTION_STATES, MOTION_PACKAGE, REDUCED_MOTION_ATTRIBUTE, REDUCED_MOTION_VALUES, convertMotion, cssEasing, cssMotionExitDuration, cssMotionExitsOnUnmount, cssMotionKeyframeLists, cssMotionPlacements, cssMotionTokens, cssMotionTransitions, cssMotionVariantGroups, linkedMotionSwaps, presetReducedMotions, reducedMotionLayers, springTiming, swappedLinkJsMotions };
|