@yahoo/uds-create-config 5.68.5 → 5.70.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 +18 -0
- package/dist/configs/system.js +4 -0
- package/dist/entities/native/NativeSettings.d.ts +18 -0
- package/dist/entities/system/Component.js +19 -1
- package/dist/entities/system/LinkedSystem.d.ts +2 -0
- package/dist/entities/system/LinkedSystem.js +14 -4
- package/dist/entities/system/Settings.d.ts +72 -1
- package/dist/entities/system/Settings.js +58 -6
- package/dist/entities/system/link-plan.d.ts +34 -1
- package/dist/entities/system/link-plan.js +157 -2
- package/dist/framework/Config.d.ts +11 -1
- package/dist/framework/Config.js +31 -2
- package/dist/framework/class-names.d.ts +1 -1
- package/dist/framework/component-api-changes.d.ts +14 -1
- package/dist/framework/component-api-changes.js +22 -6
- package/dist/framework/component-states.d.ts +16 -1
- package/dist/framework/component-states.js +17 -1
- package/dist/framework/defineEntity.d.ts +2 -1
- package/dist/framework/defineEntity.js +1 -0
- package/dist/framework/plan.d.ts +5 -0
- package/dist/framework/plan.js +9 -2
- package/dist/framework/registry.d.ts +5 -0
- package/dist/framework/registry.js +2 -1
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -4
- package/dist/migrations/20261102143821_default_colors.d.ts +12 -0
- package/dist/migrations/20261102143821_default_colors.js +10 -0
- package/dist/migrations/20261102185610_link_replace.d.ts +7 -0
- package/dist/migrations/20261102185610_link_replace.js +8 -0
- package/dist/spec/bake.js +35 -2
- package/dist/spec/cell.js +11 -2
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -2
- package/dist/spec/preview-content.js +3 -1
- package/dist/spec/preview-elements.d.ts +12 -4
- package/dist/spec/preview-elements.js +6 -1
- package/dist/spec/rewrite-refs.d.ts +14 -2
- package/dist/spec/rewrite-refs.js +30 -10
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `defaults` section joins the settings, holding `background` and `color`: the colours a system's
|
|
3
|
+
* components sit on, each a CSS colour or a token ref, alone or as `{ value, output }`. The
|
|
4
|
+
* stylesheet sets them on `body`, and Create paints them behind a component's matrix cells.
|
|
5
|
+
*
|
|
6
|
+
* Additive, so `up` is identity: a stored config written before it has no `defaults`, so nothing is
|
|
7
|
+
* painted or emitted. No stored draft patch can write a section that did not exist, so there is no
|
|
8
|
+
* `upPatch`.
|
|
9
|
+
*/
|
|
10
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
11
|
+
export declare const DEFAULT_COLORS_VERSION = 20261102143821;
|
|
12
|
+
export declare const defaultColorsMigration: SchemaMigration;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/migrations/20261102143821_default_colors.ts
|
|
2
|
+
const DEFAULT_COLORS_VERSION = 20261102143821;
|
|
3
|
+
const defaultColorsMigration = {
|
|
4
|
+
version: DEFAULT_COLORS_VERSION,
|
|
5
|
+
up(json) {
|
|
6
|
+
return json;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { DEFAULT_COLORS_VERSION, defaultColorsMigration };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** `linked-system/link` and `link-plan` take `replace`: a component this config holds under one name,
|
|
2
|
+
* replaced with a linked system's of another name. The op writes only patches that already exist (a
|
|
3
|
+
* create, a rename, a pin update), and no stored config or draft row carries its input, so this is an
|
|
4
|
+
* identity hop. Retire it only when no supported artifact predates this schema. */
|
|
5
|
+
import type { SchemaMigration } from '../framework/schema-version';
|
|
6
|
+
export declare const LINK_REPLACE_VERSION = 20261102185610;
|
|
7
|
+
export declare const linkReplaceMigration: SchemaMigration;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/migrations/20261102185610_link_replace.ts
|
|
2
|
+
const LINK_REPLACE_VERSION = 20261102185610;
|
|
3
|
+
const linkReplaceMigration = {
|
|
4
|
+
version: LINK_REPLACE_VERSION,
|
|
5
|
+
up: (json) => json
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { LINK_REPLACE_VERSION, linkReplaceMigration };
|
package/dist/spec/bake.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { kindOf, refLeaf } from "../framework/utils/refs.js";
|
|
2
2
|
import { defaultsFor } from "../framework/default-conditions.js";
|
|
3
|
+
import { UDS_FORCE_STATES, componentStateDefaults, componentStates, instanceStatePins } from "../framework/component-states.js";
|
|
3
4
|
import { declaredPropDefaults } from "../framework/projections.js";
|
|
4
5
|
import { graftPreviewElements } from "./preview-elements.js";
|
|
5
6
|
import { instanceSpec } from "../framework/render-spec.js";
|
|
@@ -28,9 +29,24 @@ function withCellValues(config, spec) {
|
|
|
28
29
|
path: component.path,
|
|
29
30
|
props: own
|
|
30
31
|
});
|
|
32
|
+
const states = new Set(componentStates(config, component.path).map(({ name }) => name));
|
|
33
|
+
const rest = componentStateDefaults(config, component.path);
|
|
34
|
+
const held = instanceStatePins({
|
|
35
|
+
config,
|
|
36
|
+
path: component.path,
|
|
37
|
+
props: own
|
|
38
|
+
});
|
|
31
39
|
let props;
|
|
32
40
|
let slots;
|
|
41
|
+
let pins;
|
|
33
42
|
for (const prop of seed.props) {
|
|
43
|
+
if (states.has(prop)) {
|
|
44
|
+
const value = seed.root.props?.[prop];
|
|
45
|
+
if (held[prop] !== void 0 || value === rest[prop]) continue;
|
|
46
|
+
pins ??= {};
|
|
47
|
+
pins[prop] = value;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
34
50
|
if (own[prop] !== void 0) continue;
|
|
35
51
|
if (holdsContent(elements ?? spec.elements, element, prop)) continue;
|
|
36
52
|
const fills = seed.root.slots?.[prop];
|
|
@@ -53,6 +69,13 @@ function withCellValues(config, spec) {
|
|
|
53
69
|
slots ??= { ...element.slots ?? {} };
|
|
54
70
|
slots[prop] = added;
|
|
55
71
|
}
|
|
72
|
+
if (pins) {
|
|
73
|
+
props ??= { ...own };
|
|
74
|
+
props[UDS_FORCE_STATES] = {
|
|
75
|
+
...own["__udsForceStates"] ?? {},
|
|
76
|
+
...pins
|
|
77
|
+
};
|
|
78
|
+
}
|
|
56
79
|
if (!props && !slots) continue;
|
|
57
80
|
elements ??= { ...spec.elements };
|
|
58
81
|
elements[key] = {
|
|
@@ -69,8 +92,18 @@ function withCellValues(config, spec) {
|
|
|
69
92
|
/** The component placed at the cell `props` pick, with what that cell bakes in: the seed a slot of
|
|
70
93
|
* an instance is restored from. */
|
|
71
94
|
function cellSeedSpec({ config, path, props }) {
|
|
72
|
-
const
|
|
73
|
-
const
|
|
95
|
+
const states = new Set(componentStates(config, path).map(({ name }) => name));
|
|
96
|
+
const pins = instanceStatePins({
|
|
97
|
+
config,
|
|
98
|
+
path,
|
|
99
|
+
props
|
|
100
|
+
});
|
|
101
|
+
const picked = {};
|
|
102
|
+
const pinned = {};
|
|
103
|
+
for (const axis of cellAxes(config, path)) if (states.has(axis)) {
|
|
104
|
+
if (pins[axis] !== void 0) pinned[axis] = pins[axis];
|
|
105
|
+
} else if (Object.hasOwn(props, axis)) picked[axis] = props[axis];
|
|
106
|
+
if (Object.keys(pinned).length > 0) picked[UDS_FORCE_STATES] = pinned;
|
|
74
107
|
let byKey = bakedByConfig.get(config);
|
|
75
108
|
if (!byKey) {
|
|
76
109
|
byKey = /* @__PURE__ */ new Map();
|
package/dist/spec/cell.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { canonicalCondition, refLeaf } from "../framework/utils/refs.js";
|
|
2
2
|
import { storedDefaultConditions } from "../framework/default-conditions.js";
|
|
3
3
|
import { createSliceMemo } from "../framework/memo.js";
|
|
4
|
-
import { componentStates } from "../framework/component-states.js";
|
|
4
|
+
import { componentStates, instanceStatePins } from "../framework/component-states.js";
|
|
5
5
|
import { unconditionalPreviewProps } from "../framework/preview-store.js";
|
|
6
6
|
import { holdingPreviewConditions, previewConditionalProps, previewDefaults } from "../framework/projections.js";
|
|
7
7
|
import { propApplies, surfaceProps } from "../framework/prop-surface.js";
|
|
@@ -433,7 +433,16 @@ function canvasDefaultCoordinate(config, path) {
|
|
|
433
433
|
* axis values over it. With no props, the default cell itself. */
|
|
434
434
|
function canvasCellAt({ config, path, props }) {
|
|
435
435
|
const coordinate = { ...canvasDefaultCoordinate(config, path) };
|
|
436
|
-
|
|
436
|
+
const pins = instanceStatePins({
|
|
437
|
+
config,
|
|
438
|
+
path,
|
|
439
|
+
props
|
|
440
|
+
});
|
|
441
|
+
const states = new Set(componentStates(config, path).map(({ name }) => name));
|
|
442
|
+
for (const axis of cellAxes(config, path)) {
|
|
443
|
+
const value = states.has(axis) ? pins[axis] : props?.[axis];
|
|
444
|
+
if (value !== void 0) coordinate[axis] = value;
|
|
445
|
+
}
|
|
437
446
|
return cellAt({
|
|
438
447
|
config,
|
|
439
448
|
path,
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraftableElement, GraftableSpec, PreviewElement, PreviewRef, PreviewSpecNode, PreviewValue, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, previewElementNodes, previewElementType } from "./preview-elements.js";
|
|
2
2
|
import { Slot, SlotCell } from "./slot.js";
|
|
3
3
|
import { Cell, CellSlot } from "./cell.js";
|
|
4
|
-
import { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames } from "./rewrite-refs.js";
|
|
4
|
+
import { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames } from "./rewrite-refs.js";
|
|
5
5
|
import { applyForcedModifiers, collectForcedModifierProps } from "./apply-forced-modifiers.js";
|
|
6
6
|
import { AcceptsChildNodes, ChildNodesClassification, ClassifyChildNodes, buildAcceptsChildNodes, buildClassifyChildNodes, stripInjectedSlots, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots } from "./empty-node-slots.js";
|
|
7
7
|
import { CollapseTextLabelsResult, CollapsedTextLabel, collapseWrappedTextLabels } from "./collapse-text-labels.js";
|
|
@@ -29,4 +29,4 @@ import { SpecToJsxOptions, SpecToJsxResult, specToJsx } from "./specToJsx.js";
|
|
|
29
29
|
* element, without changing the rendered layer hierarchy. */
|
|
30
30
|
declare const SYNTHETIC_TEXT_SLOT_PROP = "data-uds-synthetic-text-slot";
|
|
31
31
|
//#endregion
|
|
32
|
-
export { type AcceptsChildNodes, type Cell, type CellSlot, type ChildNodesClassification, type ClassifyChildNodes, type CollapseTextLabelsResult, type CollapsedTextLabel, type DocumentRename, type GlyphJsxForm, type GlyphNodeResolver, type GraftableElement, type GraftableSpec, type JsxToSpecOptions, type MappedInstance, type MappedProps, type MatchedValue, type PreviewElement, type PreviewRef, type PreviewSpecNode, type PreviewValue, type PropMapping, type PropMappingConflict, type PropMappingResult, type PropMappingRule, type RewritableElement, type RewritableSpec, SYNTHETIC_TEXT_SLOT_PROP, type Slot, type SlotCell, type SpecRewrite, type SpecToJsxOptions, type SpecToJsxResult, UNRESOLVED, applyForcedModifiers, applyPropMapping, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, mapComponentProps, onlyMapsProps, parseGlyphType, previewElementNodes, previewElementType, propMappingErrors, propMappingRuleSchema, propMappingRulesSchema, propMappingsIn, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, styleNumberReadingRenames, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
|
|
32
|
+
export { type AcceptsChildNodes, type Cell, type CellSlot, type ChildNodesClassification, type ClassifyChildNodes, type CollapseTextLabelsResult, type CollapsedTextLabel, type DocumentRename, type GlyphJsxForm, type GlyphNodeResolver, type GraftableElement, type GraftableSpec, type JsxToSpecOptions, type MappedInstance, type MappedProps, type MatchedValue, type PreviewElement, type PreviewRef, type PreviewSpecNode, type PreviewValue, type PropMapping, type PropMappingConflict, type PropMappingResult, type PropMappingRule, type RewritableElement, type RewritableSpec, SYNTHETIC_TEXT_SLOT_PROP, type Slot, type SlotCell, type SpecRewrite, type SpecToJsxOptions, type SpecToJsxResult, UNRESOLVED, applyForcedModifiers, applyPropMapping, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, mapComponentProps, onlyMapsProps, parseGlyphType, previewElementNodes, previewElementType, propMappingErrors, propMappingRuleSchema, propMappingRulesSchema, propMappingsIn, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, styleNumberReadingRenames, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
|
package/dist/spec/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, previewElementNodes, previewElementType } from "./preview-elements.js";
|
|
2
|
-
import { composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames } from "./rewrite-refs.js";
|
|
2
|
+
import { componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames } from "./rewrite-refs.js";
|
|
3
3
|
import { applyPropMapping, mapComponentProps, onlyMapsProps, propMappingErrors, propMappingRuleSchema, propMappingRulesSchema, propMappingsIn } from "./prop-mapping.js";
|
|
4
4
|
import { glyphJsxForm, glyphMemberOf, jsxIdentifier, parseGlyphType } from "./glyph-jsx.js";
|
|
5
5
|
import { applyForcedModifiers, collectForcedModifierProps } from "./apply-forced-modifiers.js";
|
|
@@ -26,4 +26,4 @@ import { specToJsx } from "./specToJsx.js";
|
|
|
26
26
|
* element, without changing the rendered layer hierarchy. */
|
|
27
27
|
const SYNTHETIC_TEXT_SLOT_PROP = "data-uds-synthetic-text-slot";
|
|
28
28
|
//#endregion
|
|
29
|
-
export { SYNTHETIC_TEXT_SLOT_PROP, UNRESOLVED, applyForcedModifiers, applyPropMapping, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, mapComponentProps, onlyMapsProps, parseGlyphType, previewElementNodes, previewElementType, propMappingErrors, propMappingRuleSchema, propMappingRulesSchema, propMappingsIn, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, styleNumberReadingRenames, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
|
|
29
|
+
export { SYNTHETIC_TEXT_SLOT_PROP, UNRESOLVED, applyForcedModifiers, applyPropMapping, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, mapComponentProps, onlyMapsProps, parseGlyphType, previewElementNodes, previewElementType, propMappingErrors, propMappingRuleSchema, propMappingRulesSchema, propMappingsIn, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, styleNumberReadingRenames, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ref, refLeaf, splitRef } from "../framework/utils/refs.js";
|
|
2
|
+
import "../framework/component-states.js";
|
|
2
3
|
import { unconditionalPreviewProps } from "../framework/preview-store.js";
|
|
3
4
|
import { holdingPreviewConditions, keyedPreviewConditions } from "../framework/projections.js";
|
|
4
|
-
import { isPreviewElement } from "./preview-elements.js";
|
|
5
|
+
import { isPreviewElement, isPreviewStatePins } from "./preview-elements.js";
|
|
5
6
|
//#region src/spec/preview-content.ts
|
|
6
7
|
/** The `defaultProps` a component stores and the props of its `*` preview entry, empty for a path
|
|
7
8
|
* naming none. */
|
|
@@ -110,6 +111,7 @@ function previewElementFromSpec({ elements, key, config }) {
|
|
|
110
111
|
continue;
|
|
111
112
|
}
|
|
112
113
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") props[name] = value;
|
|
114
|
+
else if (name === "__udsForceStates" && isPreviewStatePins(value)) props[name] = value;
|
|
113
115
|
}
|
|
114
116
|
for (const [into, keys] of Object.entries(el.slots ?? {})) {
|
|
115
117
|
const held = keys.map((fill) => previewElementFromSpec({
|
|
@@ -4,12 +4,20 @@ interface PreviewElement {
|
|
|
4
4
|
readonly __ref: string;
|
|
5
5
|
};
|
|
6
6
|
/** Literals, an element handed as a prop (`<IconButton icon={<PlusIcon />} />`) or a list of them,
|
|
7
|
-
* which fill the slot the prop names the way the root's own element-valued props do,
|
|
8
|
-
* component handed as a prop (`icon={PlusIcon}`), which stays a prop as a ref
|
|
9
|
-
|
|
7
|
+
* which fill the slot the prop names the way the root's own element-valued props do, a
|
|
8
|
+
* component handed as a prop (`icon={PlusIcon}`), which stays a prop as a ref, or the states the
|
|
9
|
+
* element is pinned in, under the module's force key. */
|
|
10
|
+
readonly props?: Record<string, string | number | boolean | PreviewElement | PreviewElement[] | PreviewRef | PreviewStatePins>;
|
|
10
11
|
readonly children?: PreviewElement[];
|
|
11
12
|
readonly text?: string;
|
|
12
13
|
}
|
|
14
|
+
/** The states a preview element is pinned in, by state name (`expanded`, `_hover`): `true` for a
|
|
15
|
+
* boolean state or a modifier, the value's name for a variant state. Design-time, as on a canvas. */
|
|
16
|
+
interface PreviewStatePins {
|
|
17
|
+
readonly [state: string]: string | boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Whether a stored value is a {@link PreviewStatePins} record. */
|
|
20
|
+
declare function isPreviewStatePins(value: unknown): value is PreviewStatePins;
|
|
13
21
|
/**
|
|
14
22
|
* A component handed as a prop value rather than rendered: `icon={DotsThreeIcon}` names the glyph
|
|
15
23
|
* and lets the receiving component draw it. It is the `element` half of a {@link PreviewElement} on
|
|
@@ -99,4 +107,4 @@ declare function graftSlotContent<S extends GraftableSpec>({
|
|
|
99
107
|
*/
|
|
100
108
|
declare function graftPreviewElements<S extends GraftableSpec>(spec: S, values: Record<string, unknown>): S;
|
|
101
109
|
//#endregion
|
|
102
|
-
export { GraftableElement, GraftableSpec, PreviewElement, PreviewRef, PreviewSpecNode, PreviewValue, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, previewElementNodes, previewElementType };
|
|
110
|
+
export { GraftableElement, GraftableSpec, PreviewElement, PreviewRef, PreviewSpecNode, PreviewStatePins, PreviewValue, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, isPreviewStatePins, previewElementNodes, previewElementType };
|
|
@@ -6,6 +6,11 @@ import { kindOf } from "../framework/utils/refs.js";
|
|
|
6
6
|
* It is authoring data, not a React element and not yet a json-render node. The helpers in this file
|
|
7
7
|
* own the conversion into the UDS spec dialect so every render host receives the same shape.
|
|
8
8
|
*/
|
|
9
|
+
/** Whether a stored value is a {@link PreviewStatePins} record. */
|
|
10
|
+
function isPreviewStatePins(value) {
|
|
11
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
12
|
+
return Object.values(value).every((pin) => typeof pin === "string" || typeof pin === "boolean");
|
|
13
|
+
}
|
|
9
14
|
/** Whether a stored value names an element to render. */
|
|
10
15
|
function isPreviewElement(value) {
|
|
11
16
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -166,4 +171,4 @@ function graftPreviewElements(spec, values) {
|
|
|
166
171
|
return next;
|
|
167
172
|
}
|
|
168
173
|
//#endregion
|
|
169
|
-
export { graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, previewElementNodes, previewElementType };
|
|
174
|
+
export { graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, isPreviewStatePins, previewElementNodes, previewElementType };
|
|
@@ -2,7 +2,10 @@ import { Config } from "../framework/Config.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/spec/rewrite-refs.d.ts
|
|
4
4
|
/** One rename to carry into a document, named by WHAT was renamed. */
|
|
5
|
-
type DocumentRename =
|
|
5
|
+
type DocumentRename =
|
|
6
|
+
/** A component's path — `element.type` and a node's own component name. The component's parts move
|
|
7
|
+
* with it, so `Card` → `Panel` carries `Card/Header` to `Panel/Header` too. */
|
|
8
|
+
{
|
|
6
9
|
readonly kind: 'component';
|
|
7
10
|
readonly from: string;
|
|
8
11
|
readonly to: string;
|
|
@@ -51,6 +54,15 @@ type DocumentRename = /** A component's path — `element.type` and a node's own
|
|
|
51
54
|
readonly to: string;
|
|
52
55
|
readonly branch?: string;
|
|
53
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Where the component at `path` is after a component rename, or `undefined` when the rename doesn't
|
|
59
|
+
* reach it. A rename moves the component's parts with it (`Card/Header` follows `Card`), so a path
|
|
60
|
+
* under `from` follows as well as `from` itself.
|
|
61
|
+
*/
|
|
62
|
+
declare function componentPathAfter(path: string, rename: {
|
|
63
|
+
readonly from: string;
|
|
64
|
+
readonly to: string;
|
|
65
|
+
}): string | undefined;
|
|
54
66
|
/**
|
|
55
67
|
* The renames a list of patches recorded, oldest first — the only source that names both halves of every case.
|
|
56
68
|
*
|
|
@@ -124,4 +136,4 @@ interface SpecRewrite {
|
|
|
124
136
|
*/
|
|
125
137
|
declare function rewriteSpecRefs(config: Config, spec: RewritableSpec, renames: readonly DocumentRename[]): SpecRewrite;
|
|
126
138
|
//#endregion
|
|
127
|
-
export { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames };
|
|
139
|
+
export { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs, styleNumberReadingRenames };
|
|
@@ -42,6 +42,15 @@ import { Component } from "../entities/system/Component.js";
|
|
|
42
42
|
* halves of every case below.
|
|
43
43
|
*/
|
|
44
44
|
/**
|
|
45
|
+
* Where the component at `path` is after a component rename, or `undefined` when the rename doesn't
|
|
46
|
+
* reach it. A rename moves the component's parts with it (`Card/Header` follows `Card`), so a path
|
|
47
|
+
* under `from` follows as well as `from` itself.
|
|
48
|
+
*/
|
|
49
|
+
function componentPathAfter(path, rename) {
|
|
50
|
+
if (path === rename.from) return rename.to;
|
|
51
|
+
if (path.startsWith(`${rename.from}/`)) return `${rename.to}${path.slice(rename.from.length)}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
45
54
|
* The renames a list of patches recorded, oldest first — the only source that names both halves of every case.
|
|
46
55
|
*
|
|
47
56
|
* A renamed prop, variant value, layer, style property, token or modifier leaves no trace in the set of paths a
|
|
@@ -140,6 +149,14 @@ function documentRenamesFromSource({ before, after, slug, renames }) {
|
|
|
140
149
|
moved.delete(from);
|
|
141
150
|
moved.add(to);
|
|
142
151
|
projected.push(rename);
|
|
152
|
+
if (rename.kind !== "component") continue;
|
|
153
|
+
for (const target of [...inherited]) {
|
|
154
|
+
if (kindOf(target) !== "component") continue;
|
|
155
|
+
const part = componentPathAfter(pathOf(target), rename);
|
|
156
|
+
if (part === void 0 || part === rename.to) continue;
|
|
157
|
+
inherited.delete(target);
|
|
158
|
+
inherited.add(`component:${part}`);
|
|
159
|
+
}
|
|
143
160
|
}
|
|
144
161
|
for (const target of moved) {
|
|
145
162
|
const body = after.storedBody(kindOf(target), pathOf(target));
|
|
@@ -186,11 +203,12 @@ function sameScope(a, b) {
|
|
|
186
203
|
if ("path" in a && "path" in b && a.path !== b.path) return false;
|
|
187
204
|
return true;
|
|
188
205
|
}
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (type
|
|
193
|
-
|
|
206
|
+
/** The local component a stored `type` names, in either form it may be written in. A ref into a
|
|
207
|
+
* source names that source's component, which a rename here doesn't move. */
|
|
208
|
+
function localComponentOf(type) {
|
|
209
|
+
if (typeof type !== "string") return void 0;
|
|
210
|
+
if (!type.includes(":")) return type;
|
|
211
|
+
return kindOf(type) === "component" && sourceOf(type) === void 0 ? pathOf(type) : void 0;
|
|
194
212
|
}
|
|
195
213
|
/** The component an element names, as a path — `undefined` for an intrinsic tag or another kind. */
|
|
196
214
|
function componentOf(type) {
|
|
@@ -412,15 +430,17 @@ function rewriteSpecRefs(config, spec, renames) {
|
|
|
412
430
|
if (Object.keys(own.declared).length > 0 || !path) return own;
|
|
413
431
|
return {
|
|
414
432
|
component: path,
|
|
415
|
-
declared: scopeFor(config, renames.filter((r) => r.kind === "component").reduce((at, r) =>
|
|
433
|
+
declared: scopeFor(config, renames.filter((r) => r.kind === "component").reduce((at, r) => componentPathAfter(at, r) ?? at, path)).declared
|
|
416
434
|
};
|
|
417
435
|
};
|
|
418
436
|
for (const rename of renames) {
|
|
419
437
|
if (rename.from === rename.to) continue;
|
|
420
438
|
if (rename.kind === "component") {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
439
|
+
const named = localComponentOf(type);
|
|
440
|
+
const after = named === void 0 ? void 0 : componentPathAfter(named, rename);
|
|
441
|
+
if (after === void 0) continue;
|
|
442
|
+
type = typeof type === "string" && type.includes(":") ? `component:${after}` : after;
|
|
443
|
+
current = after;
|
|
424
444
|
touched++;
|
|
425
445
|
continue;
|
|
426
446
|
}
|
|
@@ -456,4 +476,4 @@ function rewriteSpecRefs(config, spec, renames) {
|
|
|
456
476
|
};
|
|
457
477
|
}
|
|
458
478
|
//#endregion
|
|
459
|
-
export { LAYER_PROPS, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, layerComponent, modifierBlock, nestedBag, rewriteSpecRefs, styleNumberReadingRenames };
|
|
479
|
+
export { LAYER_PROPS, componentPathAfter, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, layerComponent, modifierBlock, nestedBag, rewriteSpecRefs, styleNumberReadingRenames };
|