@yahoo/uds-create-config 2.45.0 → 3.0.1
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/README.md +129 -0
- package/dist/ai-lanes.d.ts +23 -0
- package/dist/ai-lanes.js +34 -0
- package/dist/authoring/define-component.d.ts +85 -0
- package/dist/configs/CanvasConfig.d.ts +3237 -0
- package/dist/configs/CanvasConfig.js +332 -0
- package/dist/configs/build-options.d.ts +10 -0
- package/dist/configs/build-options.js +68 -0
- package/dist/configs/platform.d.ts +15 -0
- package/dist/configs/platform.js +17 -0
- package/dist/configs/react-native-system.d.ts +3026 -0
- package/dist/configs/react-native-system.js +64 -0
- package/dist/configs/system.d.ts +2771 -0
- package/dist/configs/system.js +74 -0
- package/dist/css/properties.generated.d.ts +14 -0
- package/dist/css/properties.generated.js +6260 -0
- package/dist/css/value-type.d.ts +48 -0
- package/dist/css/value-type.js +131 -0
- package/dist/css/values.d.ts +33 -0
- package/dist/css/values.js +116 -0
- package/dist/entities/native/NativeModifier.d.ts +25 -0
- package/dist/entities/native/NativeModifier.js +41 -0
- package/dist/entities/native/NativeSettings.d.ts +44 -0
- package/dist/entities/native/NativeSettings.js +39 -0
- package/dist/entities/native/NativeStyleProperty.d.ts +355 -0
- package/dist/entities/native/NativeStyleProperty.js +28 -0
- package/dist/entities/native/NativeToken.d.ts +31 -0
- package/dist/entities/native/NativeToken.js +49 -0
- package/dist/entities/system/CanvasRole.d.ts +34 -0
- package/dist/entities/system/CanvasRole.js +45 -0
- package/dist/entities/system/Component.d.ts +1287 -0
- package/dist/entities/system/Component.js +1840 -0
- package/dist/entities/system/Composite.d.ts +12 -0
- package/dist/entities/system/Composite.js +26 -0
- package/dist/entities/system/Device.d.ts +11 -0
- package/dist/entities/system/Device.js +18 -0
- package/dist/entities/system/File.d.ts +72 -0
- package/dist/entities/system/File.js +136 -0
- package/dist/entities/system/Font.d.ts +48 -0
- package/dist/entities/system/Font.js +56 -0
- package/dist/entities/system/GlobalStyle.d.ts +26 -0
- package/dist/entities/system/GlobalStyle.js +54 -0
- package/dist/entities/system/Guidance.d.ts +85 -0
- package/dist/entities/system/Guidance.js +59 -0
- package/dist/entities/system/GuidanceStyle.d.ts +14 -0
- package/dist/entities/system/GuidanceStyle.js +8 -0
- package/dist/entities/system/Icon.d.ts +46 -0
- package/dist/entities/system/Icon.js +46 -0
- package/dist/entities/system/LinkedSystem.d.ts +504 -0
- package/dist/entities/system/LinkedSystem.js +814 -0
- package/dist/entities/system/Modifier.d.ts +92 -0
- package/dist/entities/system/Modifier.js +120 -0
- package/dist/entities/system/Motion.d.ts +28 -0
- package/dist/entities/system/Motion.js +48 -0
- package/dist/entities/system/Operation.d.ts +100 -0
- package/dist/entities/system/Operation.js +236 -0
- package/dist/entities/system/Package.d.ts +42 -0
- package/dist/entities/system/Package.js +75 -0
- package/dist/entities/system/Settings.d.ts +94 -0
- package/dist/entities/system/Settings.js +166 -0
- package/dist/entities/system/StyleProperty.d.ts +135 -0
- package/dist/entities/system/StyleProperty.js +438 -0
- package/dist/entities/system/Token.d.ts +67 -0
- package/dist/entities/system/Token.js +129 -0
- package/dist/entities/system/Tool.d.ts +134 -0
- package/dist/entities/system/Tool.js +124 -0
- package/dist/entities/system/color.d.ts +64 -0
- package/dist/entities/system/color.js +123 -0
- package/dist/entities/system/component-module.d.ts +63 -0
- package/dist/entities/system/component-module.js +258 -0
- package/dist/entities/system/copy-plan.d.ts +98 -0
- package/dist/entities/system/copy-plan.js +451 -0
- package/dist/entities/system/defineComponent.d.ts +428 -0
- package/dist/entities/system/defineComponent.js +337 -0
- package/dist/entities/system/element.d.ts +101 -0
- package/dist/entities/system/element.js +171 -0
- package/dist/entities/system/icon-library.d.ts +64 -0
- package/dist/entities/system/icon-library.js +112 -0
- package/dist/entities/system/icon-metadata.d.ts +72 -0
- package/dist/entities/system/icon-metadata.js +111 -0
- package/dist/entities/system/link-declaration.d.ts +27 -0
- package/dist/entities/system/link-declaration.js +64 -0
- package/dist/entities/system/link-plan.d.ts +160 -0
- package/dist/entities/system/link-plan.js +770 -0
- package/dist/entities/system/runtime-modules.d.ts +25 -0
- package/dist/entities/system/runtime-modules.js +38 -0
- package/dist/entities/system/style-bag.d.ts +20 -0
- package/dist/entities/system/style-bag.js +246 -0
- package/dist/entities/system/token-index.d.ts +89 -0
- package/dist/entities/system/token-index.js +112 -0
- package/dist/framework/Config.d.ts +2472 -0
- package/dist/framework/Config.js +5023 -0
- package/dist/framework/Entity.d.ts +127 -0
- package/dist/framework/Entity.js +125 -0
- package/dist/framework/authoring.d.ts +24 -0
- package/dist/framework/authoring.js +7 -0
- package/dist/framework/change-hooks.d.ts +119 -0
- package/dist/framework/change-hooks.js +131 -0
- package/dist/framework/changes.d.ts +88 -0
- package/dist/framework/changes.js +246 -0
- package/dist/framework/class-names.d.ts +260 -0
- package/dist/framework/class-names.js +630 -0
- package/dist/framework/coalesce.d.ts +25 -0
- package/dist/framework/coalesce.js +60 -0
- package/dist/framework/config-op.d.ts +76 -0
- package/dist/framework/config-op.js +43 -0
- package/dist/framework/config-operation-kind.d.ts +14 -0
- package/dist/framework/config-operation-kind.js +14 -0
- package/dist/framework/config-ops.d.ts +34 -0
- package/dist/framework/config-ops.js +187 -0
- package/dist/framework/defineConfig.d.ts +196 -0
- package/dist/framework/defineConfig.js +100 -0
- package/dist/framework/defineDerivedEntity.d.ts +74 -0
- package/dist/framework/defineDerivedEntity.js +83 -0
- package/dist/framework/defineEntity.d.ts +318 -0
- package/dist/framework/defineEntity.js +183 -0
- package/dist/framework/defineSubEntity.d.ts +148 -0
- package/dist/framework/defineSubEntity.js +121 -0
- package/dist/framework/derived-mutations.d.ts +20 -0
- package/dist/framework/derived-mutations.js +38 -0
- package/dist/framework/entity-search.d.ts +29 -0
- package/dist/framework/entity-search.js +117 -0
- package/dist/framework/inline-sources.d.ts +49 -0
- package/dist/framework/inline-sources.js +388 -0
- package/dist/framework/layer-styles.d.ts +25 -0
- package/dist/framework/layer-styles.js +49 -0
- package/dist/framework/memo.d.ts +48 -0
- package/dist/framework/memo.js +84 -0
- package/dist/framework/overlay.d.ts +49 -0
- package/dist/framework/overlay.js +17 -0
- package/dist/framework/plan.d.ts +49 -0
- package/dist/framework/plan.js +73 -0
- package/dist/framework/projections.d.ts +480 -0
- package/dist/framework/projections.js +974 -0
- package/dist/framework/prop-surface.d.ts +132 -0
- package/dist/framework/prop-surface.js +278 -0
- package/dist/framework/ref-graph.d.ts +71 -0
- package/dist/framework/ref-graph.js +158 -0
- package/dist/framework/ref-integrity.d.ts +55 -0
- package/dist/framework/ref-integrity.js +171 -0
- package/dist/framework/registered.d.ts +95 -0
- package/dist/framework/registry-dir.d.ts +42 -0
- package/dist/framework/registry-dir.js +48 -0
- package/dist/framework/registry.d.ts +300 -0
- package/dist/framework/registry.js +104 -0
- package/dist/framework/rejection.d.ts +58 -0
- package/dist/framework/rejection.js +111 -0
- package/dist/framework/rename-inference.d.ts +26 -0
- package/dist/framework/rename-inference.js +50 -0
- package/dist/framework/render-spec.d.ts +296 -0
- package/dist/framework/render-spec.js +809 -0
- package/dist/framework/schema-version.d.ts +140 -0
- package/dist/framework/schema-version.js +214 -0
- package/dist/framework/schemas.d.ts +109 -0
- package/dist/framework/schemas.js +615 -0
- package/dist/framework/session.d.ts +196 -0
- package/dist/framework/session.js +367 -0
- package/dist/framework/signature.d.ts +15 -0
- package/dist/framework/signature.js +83 -0
- package/dist/framework/snapshot.d.ts +115 -0
- package/dist/framework/snapshot.js +277 -0
- package/dist/framework/source-integrity.d.ts +226 -0
- package/dist/framework/source-integrity.js +478 -0
- package/dist/framework/sources.d.ts +211 -0
- package/dist/framework/sources.js +89 -0
- package/dist/framework/utils/compiled-schema.d.ts +23 -0
- package/dist/framework/utils/compiled-schema.js +46 -0
- package/dist/framework/utils/content-key.d.ts +15 -0
- package/dist/framework/utils/content-key.js +33 -0
- package/dist/framework/utils/enumerated.d.ts +13 -0
- package/dist/framework/utils/enumerated.js +19 -0
- package/dist/framework/utils/field-path.d.ts +95 -0
- package/dist/framework/utils/field-path.js +136 -0
- package/dist/framework/utils/field-schema.d.ts +55 -0
- package/dist/framework/utils/field-schema.js +183 -0
- package/dist/framework/utils/group.d.ts +37 -0
- package/dist/framework/utils/group.js +13 -0
- package/dist/framework/utils/package-path.d.ts +37 -0
- package/dist/framework/utils/package-path.js +61 -0
- package/dist/framework/utils/refs.d.ts +194 -0
- package/dist/framework/utils/refs.js +403 -0
- package/dist/framework/validate-spec.d.ts +27 -0
- package/dist/framework/validate-spec.js +45 -0
- package/dist/framework/value-domain.d.ts +26 -0
- package/dist/framework/value-domain.js +202 -0
- package/dist/framework/views-facade.d.ts +15 -0
- package/dist/framework/views-facade.js +19 -0
- package/dist/index.d.ts +90 -42
- package/dist/index.js +86 -37
- package/dist/migrations/2.0.0/raw-css.d.ts +11 -0
- package/dist/migrations/2.0.0/raw-css.js +72 -0
- package/dist/migrations/2.0.0/v1-artifact.d.ts +1559 -0
- package/dist/migrations/2.0.0/v1-artifact.js +1018 -0
- package/dist/migrations/20260908171448_settings_as_kind.d.ts +22 -0
- package/dist/migrations/20260908171448_settings_as_kind.js +89 -0
- package/dist/migrations/20260908194245_visible_state_pointer.d.ts +19 -0
- package/dist/migrations/20260908194245_visible_state_pointer.js +115 -0
- package/dist/migrations/20260909183001_icon_knockout_variants.d.ts +18 -0
- package/dist/migrations/20260909183001_icon_knockout_variants.js +8 -0
- package/dist/migrations/20260910212453_linked_system_link_ops.d.ts +13 -0
- package/dist/migrations/20260910212453_linked_system_link_ops.js +8 -0
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.js +2 -0
- package/dist/react-native/style-keys.generated.d.ts +10 -0
- package/dist/react-native/style-keys.generated.js +167 -0
- package/dist/renderer/RendererErrorBoundary.d.ts +32 -5
- package/dist/renderer/RendererErrorBoundary.js +59 -10
- package/dist/renderer/UdsRenderer.d.ts +11 -10
- package/dist/renderer/UdsRenderer.js +1 -1
- package/dist/renderer/assetEntries.d.ts +37 -0
- package/dist/renderer/assetEntries.js +39 -0
- package/dist/renderer/assetRenderable.d.ts +14 -6
- package/dist/renderer/assetRenderable.js +8 -2
- package/dist/renderer/componentEntry.d.ts +58 -0
- package/dist/renderer/componentEntry.js +71 -0
- package/dist/renderer/icon-library.d.ts +20 -0
- package/dist/renderer/index.d.ts +7 -7
- package/dist/renderer/index.js +5 -5
- package/dist/renderer/primitives/SlotRenderer.d.ts +1 -1
- package/dist/renderer/primitives/SlotRenderer.js +1 -1
- package/dist/renderer/runtimeComponent.d.ts +33 -0
- package/dist/renderer/runtimeComponent.js +113 -0
- package/dist/renderer/spec-content.d.ts +43 -0
- package/dist/renderer/spec-content.js +95 -0
- package/dist/renderer/wrapRegistry.d.ts +22 -37
- package/dist/renderer/wrapRegistry.js +10 -20
- package/dist/renderer/wrappers/event-bridge.js +6 -5
- package/dist/renderer/wrappers/hex-normalize.js +6 -5
- package/dist/renderer/wrappers/html-aliases.d.ts +7 -2
- package/dist/renderer/wrappers/html-aliases.js +36 -19
- package/dist/renderer/wrappers/inline-styles.js +7 -6
- package/dist/spec/asset-jsx.d.ts +18 -5
- package/dist/spec/asset-jsx.js +27 -16
- package/dist/spec/collapse-text-labels.d.ts +5 -15
- package/dist/spec/collapse-text-labels.js +26 -19
- package/dist/spec/empty-node-slots.d.ts +56 -34
- package/dist/spec/empty-node-slots.js +87 -47
- package/dist/spec/index.d.ts +21 -10
- package/dist/spec/index.js +21 -10
- package/dist/spec/jsxToSpec.d.ts +14 -9
- package/dist/spec/jsxToSpec.js +20 -3
- package/dist/spec/preview-elements.d.ts +63 -0
- package/dist/spec/preview-elements.js +89 -0
- package/dist/spec/rewrite-refs.d.ts +58 -0
- package/dist/spec/rewrite-refs.js +250 -0
- package/dist/spec/specToJsx.js +18 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -52
- package/dist/AssetGroup.d.ts +0 -77
- package/dist/AssetGroup.js +0 -125
- package/dist/Component.d.ts +0 -333
- package/dist/Component.js +0 -1061
- package/dist/ComponentGroup.d.ts +0 -22
- package/dist/ComponentGroup.js +0 -51
- package/dist/CompositeStyle.d.ts +0 -30
- package/dist/CompositeStyle.js +0 -59
- package/dist/Config.d.ts +0 -528
- package/dist/Config.js +0 -1712
- package/dist/Mode.d.ts +0 -41
- package/dist/Mode.js +0 -81
- package/dist/Modifier.d.ts +0 -51
- package/dist/Modifier.js +0 -97
- package/dist/MotionDef.d.ts +0 -81
- package/dist/MotionDef.js +0 -212
- package/dist/Props.d.ts +0 -332
- package/dist/Props.js +0 -35
- package/dist/Provider.d.ts +0 -20
- package/dist/Provider.js +0 -14
- package/dist/StyleProp.d.ts +0 -145
- package/dist/StyleProp.js +0 -239
- package/dist/Token.d.ts +0 -76
- package/dist/Token.js +0 -133
- package/dist/TokenGroup.d.ts +0 -33
- package/dist/TokenGroup.js +0 -69
- package/dist/asset-kind.d.ts +0 -55
- package/dist/asset-kind.js +0 -29
- package/dist/asset-value.d.ts +0 -23
- package/dist/asset-value.js +0 -40
- package/dist/brands.d.ts +0 -30
- package/dist/brands.js +0 -20
- package/dist/captureCallerPath.d.ts +0 -48
- package/dist/captureCallerPath.js +0 -95
- package/dist/colorExpressions.d.ts +0 -131
- package/dist/colorExpressions.js +0 -148
- package/dist/component-referrers.d.ts +0 -30
- package/dist/component-referrers.js +0 -40
- package/dist/config-diagnostics.d.ts +0 -21
- package/dist/config-diagnostics.js +0 -12
- package/dist/defineAssetGroup.d.ts +0 -200
- package/dist/defineAssetGroup.js +0 -323
- package/dist/defineProvider.d.ts +0 -29
- package/dist/defineProvider.js +0 -60
- package/dist/element-marker.d.ts +0 -63
- package/dist/element-marker.js +0 -113
- package/dist/entity-utils.d.ts +0 -56
- package/dist/entity-utils.js +0 -105
- package/dist/extension.d.ts +0 -55
- package/dist/extension.js +0 -214
- package/dist/factories.d.ts +0 -863
- package/dist/factories.js +0 -475
- package/dist/font-face.d.ts +0 -25
- package/dist/font-face.js +0 -72
- package/dist/foreign-component-name.d.ts +0 -21
- package/dist/foreign-component-name.js +0 -42
- package/dist/interpolate.d.ts +0 -20
- package/dist/interpolate.js +0 -10
- package/dist/jsx/__fixtures__/cross-component-preview.d.ts +0 -3
- package/dist/jsx/__fixtures__/cross-component-preview.js +0 -15
- package/dist/jsx/jsx-dev-runtime.d.ts +0 -15
- package/dist/jsx/jsx-dev-runtime.js +0 -11
- package/dist/jsx/jsx-runtime.d.ts +0 -48
- package/dist/jsx/jsx-runtime.js +0 -305
- package/dist/linked-system-pins.d.ts +0 -30
- package/dist/linked-system-pins.js +0 -45
- package/dist/linkedNodePrefixes.d.ts +0 -73
- package/dist/linkedNodePrefixes.js +0 -99
- package/dist/markers.d.ts +0 -235
- package/dist/markers.js +0 -70
- package/dist/motion-constants.d.ts +0 -37
- package/dist/motion-constants.js +0 -61
- package/dist/native/NativeConfig.d.ts +0 -56
- package/dist/native/NativeConfig.js +0 -162
- package/dist/native/assets.d.ts +0 -20
- package/dist/native/assets.js +0 -17
- package/dist/native/components.d.ts +0 -139
- package/dist/native/components.js +0 -67
- package/dist/native/index.d.ts +0 -18
- package/dist/native/index.js +0 -17
- package/dist/native/modes.d.ts +0 -10
- package/dist/native/modes.js +0 -11
- package/dist/native/types.d.ts +0 -95
- package/dist/native/types.js +0 -0
- package/dist/native/validation.d.ts +0 -8
- package/dist/native/validation.js +0 -885
- package/dist/native/values.d.ts +0 -7
- package/dist/native/values.js +0 -15
- package/dist/native.d.ts +0 -12
- package/dist/native.js +0 -10
- package/dist/refs.d.ts +0 -204
- package/dist/refs.js +0 -129
- package/dist/registry-aliases.d.ts +0 -33
- package/dist/registry-aliases.js +0 -35
- package/dist/registry-dir.d.ts +0 -22
- package/dist/registry-dir.js +0 -10
- package/dist/renderer/makeRegistry.d.ts +0 -34
- package/dist/renderer/makeRegistry.js +0 -52
- package/dist/renderer/makeUdsRenderer.d.ts +0 -13
- package/dist/renderer/makeUdsRenderer.js +0 -51
- package/dist/renderer/wrappers/component-slots.d.ts +0 -41
- package/dist/renderer/wrappers/component-slots.js +0 -66
- package/dist/renderer/wrappers/slot-resolution.d.ts +0 -25
- package/dist/renderer/wrappers/slot-resolution.js +0 -68
- package/dist/renderer/wrappers/void-elements.d.ts +0 -37
- package/dist/renderer/wrappers/void-elements.js +0 -40
- package/dist/spec/layer-props.d.ts +0 -52
- package/dist/spec/layer-props.js +0 -149
- package/dist/spec/preview-controls.d.ts +0 -44
- package/dist/spec/preview-controls.js +0 -139
- package/dist/spec/slot-refs.d.ts +0 -39
- package/dist/spec/slot-refs.js +0 -56
- package/dist/token-override-rows.d.ts +0 -68
- package/dist/token-override-rows.js +0 -233
- package/dist/tokenValueType.d.ts +0 -34
- package/dist/tokenValueType.js +0 -138
- package/dist/types/css-properties.d.ts +0 -233
- package/dist/types/css-properties.js +0 -14
- package/dist/types/css-property-keywords.d.ts +0 -156
- package/dist/types/css-property-keywords.js +0 -616
- package/dist/types/css-values.d.ts +0 -63
- package/dist/types/css-values.js +0 -16
- package/dist/types.d.ts +0 -1138
- package/dist/types.js +0 -12
- package/dist/units.d.ts +0 -14
- package/dist/units.js +0 -16
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -4
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ComponentRegistry } from '@json-render/react';
|
|
2
|
-
import type React from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Config-derived facts for the aliased `Icon` pattern. A component-typed slot
|
|
5
|
-
* (`slot({ type: 'component' }).accepts(<icon group>)`) saves the picked asset
|
|
6
|
-
* as an inline name string (`"Trophy"`) — not a `$slot` ref — and its render fn
|
|
7
|
-
* expects the icon *component* itself (`({ name: SvgIcon }) => <SvgIcon … />`).
|
|
8
|
-
*
|
|
9
|
-
* - `componentSlots`: componentName → propName → accepted asset-group slug,
|
|
10
|
-
* emitted by codegen's `deriveRegistryDescriptor` from each slot's
|
|
11
|
-
* `authoredType: 'component'` + `acceptsAssetGroup`.
|
|
12
|
-
* - `assetMembersBySlug`: slug → assetName → member component, built at runtime
|
|
13
|
-
* by `makeRegistry` from the same live asset groups it keys under their
|
|
14
|
-
* namespaced asset type. The stored component is the renderable form
|
|
15
|
-
* (the member rendered through the group's declared system component, e.g.
|
|
16
|
-
* `<Icon name=… />`, or the bare member when none is declared), so the
|
|
17
|
-
* author's `<SvgIcon variant size />` draws.
|
|
18
|
-
*/
|
|
19
|
-
export interface ComponentTypedSlotsConfig {
|
|
20
|
-
componentSlots?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
21
|
-
assetMembersBySlug?: ReadonlyMap<string, ReadonlyMap<string, React.ComponentType>>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Resolve component-typed slot props from their saved inline asset name to the
|
|
25
|
-
* member component, so the consuming component's render fn receives a callable
|
|
26
|
-
* component (not a rendered `$slot` child routed through `ElementRenderer`).
|
|
27
|
-
*
|
|
28
|
-
* A component-typed prop's only valid value is the inline asset-name string, so
|
|
29
|
-
* this wrapper guarantees the render fn receives a member component or
|
|
30
|
-
* `undefined` — never a rendered element:
|
|
31
|
-
* - a string resolves to its member component (an unresolvable name — not in
|
|
32
|
-
* the group — is left as the string so the render fn can guard);
|
|
33
|
-
* - any non-string, non-undefined value (e.g. a leftover `{ $slot }` ref from a
|
|
34
|
-
* spec authored before component-typed slots were distinguished) is stripped
|
|
35
|
-
* to `undefined`, so it can't reach `wrapSlotResolution` and render as an
|
|
36
|
-
* `ElementRenderer` child the render fn would choke on.
|
|
37
|
-
*
|
|
38
|
-
* It runs OUTSIDE `wrapSlotResolution`, so it sees the raw prop value before any
|
|
39
|
-
* `$slot` resolution. Both lookups absent ⇒ no-op.
|
|
40
|
-
*/
|
|
41
|
-
export declare function wrapComponentTypedSlots(reg: ComponentRegistry, { componentSlots, assetMembersBySlug }?: ComponentTypedSlotsConfig): ComponentRegistry;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
//#region src/renderer/wrappers/component-slots.tsx
|
|
3
|
-
/** Local component name of a registry key: `yahoo-os:IconSlotFixture` →
|
|
4
|
-
* `IconSlotFixture`. Registry keys are `<namespace>:<Name>`; component names
|
|
5
|
-
* never contain `:`, so split on the first one. Mirrors `wrapVoidElements`. */
|
|
6
|
-
function localName(key) {
|
|
7
|
-
const colon = key.indexOf(":");
|
|
8
|
-
return colon === -1 ? key : key.slice(colon + 1);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolve component-typed slot props from their saved inline asset name to the
|
|
12
|
-
* member component, so the consuming component's render fn receives a callable
|
|
13
|
-
* component (not a rendered `$slot` child routed through `ElementRenderer`).
|
|
14
|
-
*
|
|
15
|
-
* A component-typed prop's only valid value is the inline asset-name string, so
|
|
16
|
-
* this wrapper guarantees the render fn receives a member component or
|
|
17
|
-
* `undefined` — never a rendered element:
|
|
18
|
-
* - a string resolves to its member component (an unresolvable name — not in
|
|
19
|
-
* the group — is left as the string so the render fn can guard);
|
|
20
|
-
* - any non-string, non-undefined value (e.g. a leftover `{ $slot }` ref from a
|
|
21
|
-
* spec authored before component-typed slots were distinguished) is stripped
|
|
22
|
-
* to `undefined`, so it can't reach `wrapSlotResolution` and render as an
|
|
23
|
-
* `ElementRenderer` child the render fn would choke on.
|
|
24
|
-
*
|
|
25
|
-
* It runs OUTSIDE `wrapSlotResolution`, so it sees the raw prop value before any
|
|
26
|
-
* `$slot` resolution. Both lookups absent ⇒ no-op.
|
|
27
|
-
*/
|
|
28
|
-
function wrapComponentTypedSlots(reg, { componentSlots, assetMembersBySlug } = {}) {
|
|
29
|
-
if (!componentSlots || !assetMembersBySlug) return reg;
|
|
30
|
-
const wrapped = { ...reg };
|
|
31
|
-
for (const key of Object.keys(reg)) {
|
|
32
|
-
const slotProps = componentSlots[localName(key)];
|
|
33
|
-
if (!slotProps) continue;
|
|
34
|
-
const Orig = wrapped[key];
|
|
35
|
-
if (!Orig) continue;
|
|
36
|
-
wrapped[key] = function ComponentTypedSlotWrapper(renderProps) {
|
|
37
|
-
const props = renderProps.element.props;
|
|
38
|
-
if (!props) return /* @__PURE__ */ jsx(Orig, { ...renderProps });
|
|
39
|
-
let resolved;
|
|
40
|
-
for (const [propName, slug] of Object.entries(slotProps)) {
|
|
41
|
-
const value = props[propName];
|
|
42
|
-
if (value === void 0) continue;
|
|
43
|
-
if (typeof value === "string") {
|
|
44
|
-
const member = assetMembersBySlug.get(slug)?.get(value);
|
|
45
|
-
if (!member) continue;
|
|
46
|
-
resolved ??= { ...props };
|
|
47
|
-
resolved[propName] = member;
|
|
48
|
-
} else {
|
|
49
|
-
resolved ??= { ...props };
|
|
50
|
-
resolved[propName] = void 0;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (!resolved) return /* @__PURE__ */ jsx(Orig, { ...renderProps });
|
|
54
|
-
return /* @__PURE__ */ jsx(Orig, {
|
|
55
|
-
...renderProps,
|
|
56
|
-
element: {
|
|
57
|
-
...renderProps.element,
|
|
58
|
-
props: resolved
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return wrapped;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { wrapComponentTypedSlots };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentRegistry } from "@json-render/react";
|
|
2
|
-
|
|
3
|
-
//#region src/renderer/wrappers/slot-resolution.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Resolve `$slot` prop references to rendered React children.
|
|
6
|
-
*
|
|
7
|
-
* Components like `Card` declare named slots in their authoring spec:
|
|
8
|
-
*
|
|
9
|
-
* props: {
|
|
10
|
-
* title: slot('header/text'),
|
|
11
|
-
* footer: slot('footer'),
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* Codegen lowers each `slot(...)` to a `{ $slot: 'key' }` marker that
|
|
15
|
-
* surfaces in `element.props`. At render time this wrapper pairs each
|
|
16
|
-
* slot key against the keyed React children passed in by `Renderer`
|
|
17
|
-
* (json-render assigns each rendered child a key derived from its
|
|
18
|
-
* spec element id), pulls the matching child out of the regular
|
|
19
|
-
* children stream, and feeds it through as the resolved prop value.
|
|
20
|
-
* Children whose keys don't match any slot pass through to the
|
|
21
|
-
* component as regular `children`.
|
|
22
|
-
*/
|
|
23
|
-
declare function wrapSlotResolution(reg: ComponentRegistry): ComponentRegistry;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { wrapSlotResolution };
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { isSlotRef } from "../../spec/slot-refs.js";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region src/renderer/wrappers/slot-resolution.tsx
|
|
5
|
-
/**
|
|
6
|
-
* Resolve `$slot` prop references to rendered React children.
|
|
7
|
-
*
|
|
8
|
-
* Components like `Card` declare named slots in their authoring spec:
|
|
9
|
-
*
|
|
10
|
-
* props: {
|
|
11
|
-
* title: slot('header/text'),
|
|
12
|
-
* footer: slot('footer'),
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
* Codegen lowers each `slot(...)` to a `{ $slot: 'key' }` marker that
|
|
16
|
-
* surfaces in `element.props`. At render time this wrapper pairs each
|
|
17
|
-
* slot key against the keyed React children passed in by `Renderer`
|
|
18
|
-
* (json-render assigns each rendered child a key derived from its
|
|
19
|
-
* spec element id), pulls the matching child out of the regular
|
|
20
|
-
* children stream, and feeds it through as the resolved prop value.
|
|
21
|
-
* Children whose keys don't match any slot pass through to the
|
|
22
|
-
* component as regular `children`.
|
|
23
|
-
*/
|
|
24
|
-
function wrapSlotResolution(reg) {
|
|
25
|
-
const wrapped = {};
|
|
26
|
-
for (const [name, Comp] of Object.entries(reg)) wrapped[name] = function SlotWrapper(renderProps) {
|
|
27
|
-
const { element, children } = renderProps;
|
|
28
|
-
const props = element.props;
|
|
29
|
-
if (!props) return /* @__PURE__ */ jsx(Comp, { ...renderProps });
|
|
30
|
-
const slotEntries = [];
|
|
31
|
-
for (const [propName, value] of Object.entries(props)) if (isSlotRef(value)) slotEntries.push([propName, value.$slot]);
|
|
32
|
-
if (slotEntries.length === 0) return /* @__PURE__ */ jsx(Comp, { ...renderProps });
|
|
33
|
-
const slotKeySet = /* @__PURE__ */ new Set();
|
|
34
|
-
for (const [, ref] of slotEntries) {
|
|
35
|
-
const refs = Array.isArray(ref) ? ref : [ref];
|
|
36
|
-
for (const r of refs) slotKeySet.add(r);
|
|
37
|
-
}
|
|
38
|
-
const childArray = React.Children.toArray(children);
|
|
39
|
-
const slotChildMap = /* @__PURE__ */ new Map();
|
|
40
|
-
const regularChildren = [];
|
|
41
|
-
for (const child of childArray) {
|
|
42
|
-
if (React.isValidElement(child) && typeof child.key === "string") {
|
|
43
|
-
const elementKey = child.key.startsWith(".$") ? child.key.slice(2) : child.key;
|
|
44
|
-
if (slotKeySet.has(elementKey)) {
|
|
45
|
-
slotChildMap.set(elementKey, child);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
regularChildren.push(child);
|
|
50
|
-
}
|
|
51
|
-
const resolvedProps = { ...props };
|
|
52
|
-
for (const [propName, ref] of slotEntries) if (Array.isArray(ref)) {
|
|
53
|
-
const resolved = ref.map((key) => slotChildMap.get(key)).filter(Boolean);
|
|
54
|
-
resolvedProps[propName] = resolved.length > 0 ? resolved : void 0;
|
|
55
|
-
} else resolvedProps[propName] = slotChildMap.get(ref) ?? void 0;
|
|
56
|
-
return /* @__PURE__ */ jsx(Comp, {
|
|
57
|
-
...renderProps,
|
|
58
|
-
element: {
|
|
59
|
-
...element,
|
|
60
|
-
props: resolvedProps
|
|
61
|
-
},
|
|
62
|
-
children: regularChildren.length > 0 ? regularChildren : void 0
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
return wrapped;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
export { wrapSlotResolution };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ComponentRegistry } from "@json-render/react";
|
|
2
|
-
|
|
3
|
-
//#region src/renderer/wrappers/void-elements.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Strip `children` from components that must never receive them. Source Specs
|
|
6
|
-
* (author-emitted, AI-emitted, Figma import) sometimes carry a stray
|
|
7
|
-
* `children` prop on such a component; drop it centrally rather than letting
|
|
8
|
-
* it reach the DOM and throw.
|
|
9
|
-
*
|
|
10
|
-
* Two config-derived sets feed this, and they're COMPLEMENTARY, not nested:
|
|
11
|
-
* - `voidComponents` — root renders a void HTML tag (`img`, `input`). React
|
|
12
|
-
* throws if a void element gets children. A single-primitive `Image`
|
|
13
|
-
* lands here even though its `acceptsChildren` is true (a primitive root
|
|
14
|
-
* "accepts children" for authoring, yet `<img>` still can't take them).
|
|
15
|
-
* - `noChildrenComponents` — `acceptsChildren === false`: the component
|
|
16
|
-
* declares no `children` slot, so its render has nowhere to put children.
|
|
17
|
-
* Catches composed roots (Modal/Banner/Toast) and the labeled form
|
|
18
|
-
* controls (Checkbox/Input/Radio/Switch) whose root is a `div` — so
|
|
19
|
-
* `voidComponents` misses them, yet a leaked `children` forwards down
|
|
20
|
-
* onto the nested void `<input>` and throws (UDS-2907).
|
|
21
|
-
*
|
|
22
|
-
* Both derive from the `Config`, so this stays config-agnostic. Matches on the
|
|
23
|
-
* namespace-stripped local name, so a namespaced registry (`yahoo-os:Image`)
|
|
24
|
-
* is recognized, not just the bare `Image` key. Empty union ⇒ no-op.
|
|
25
|
-
*/
|
|
26
|
-
interface VoidElementsConfig {
|
|
27
|
-
/** Component names whose root renders a void HTML tag (`img`, `input`, …). */
|
|
28
|
-
voidComponents?: readonly string[];
|
|
29
|
-
/** Component names that declare no `children` slot (`acceptsChildren === false`). */
|
|
30
|
-
noChildrenComponents?: readonly string[];
|
|
31
|
-
}
|
|
32
|
-
declare function wrapVoidElements(reg: ComponentRegistry, {
|
|
33
|
-
voidComponents,
|
|
34
|
-
noChildrenComponents
|
|
35
|
-
}?: VoidElementsConfig): ComponentRegistry;
|
|
36
|
-
//#endregion
|
|
37
|
-
export { wrapVoidElements };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
//#region src/renderer/wrappers/void-elements.tsx
|
|
3
|
-
/** Local component name of a registry key: `yahoo-os:Image` → `Image`,
|
|
4
|
-
* `Image` → `Image`. Registry keys are `<namespace>:<Name>`; component names
|
|
5
|
-
* never contain `:`, so split on the first one. */
|
|
6
|
-
function localName(key) {
|
|
7
|
-
const colon = key.indexOf(":");
|
|
8
|
-
return colon === -1 ? key : key.slice(colon + 1);
|
|
9
|
-
}
|
|
10
|
-
function wrapVoidElements(reg, { voidComponents, noChildrenComponents } = {}) {
|
|
11
|
-
const childless = new Set([...voidComponents ?? [], ...noChildrenComponents ?? []]);
|
|
12
|
-
if (childless.size === 0) return reg;
|
|
13
|
-
const wrapped = { ...reg };
|
|
14
|
-
for (const key of Object.keys(reg)) {
|
|
15
|
-
if (!childless.has(localName(key))) continue;
|
|
16
|
-
const Orig = wrapped[key];
|
|
17
|
-
if (!Orig) continue;
|
|
18
|
-
wrapped[key] = function VoidElementWrapper(p) {
|
|
19
|
-
const props = p.element?.props;
|
|
20
|
-
let next = p;
|
|
21
|
-
if (props && "children" in props) {
|
|
22
|
-
const { children: _dropped, ...rest } = props;
|
|
23
|
-
next = {
|
|
24
|
-
...p,
|
|
25
|
-
element: {
|
|
26
|
-
...p.element,
|
|
27
|
-
props: rest
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return /* @__PURE__ */ jsx(Orig, {
|
|
32
|
-
...next,
|
|
33
|
-
children: void 0
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return wrapped;
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { wrapVoidElements };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { BaseStyles, CompoundPropsEntry } from "../types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/spec/layer-props.d.ts
|
|
4
|
-
type RenderedLayerProps = Record<string, Record<string, unknown>>;
|
|
5
|
-
/**
|
|
6
|
-
* Structural view of the component fields style resolution reads. Satisfied by
|
|
7
|
-
* a real `@yahoo/uds-create-config` `Component` (Studio, playground) AND by codegen's
|
|
8
|
-
* capture-time `ProbeComponent` (`extractPreviewSpecs.buildRenderSpec`), so the
|
|
9
|
-
* same resolver bakes styles into the render spec at build time and resolves
|
|
10
|
-
* derived (non-render) values like the layers-panel `display` at render time.
|
|
11
|
-
*/
|
|
12
|
-
interface ResolvableComponent {
|
|
13
|
-
layers: ReadonlyMap<string, unknown>;
|
|
14
|
-
base?: BaseStyles;
|
|
15
|
-
props?: Record<string, unknown>;
|
|
16
|
-
compoundProps?: readonly CompoundPropsEntry[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Resolve the styles a layer effectively has for a set of prop-axis values and
|
|
20
|
-
* (optionally) one forced interaction state, walking the authoring surfaces
|
|
21
|
-
* codegen reads:
|
|
22
|
-
*
|
|
23
|
-
* 1. `component.base[layer]` — the always-on baseline.
|
|
24
|
-
* 2. `component.props[axis].values[value][layer]` — per axis key in `propValues`.
|
|
25
|
-
* 3. `component.compoundProps[].layers[layer]` — for entries whose `when`
|
|
26
|
-
* is a subset of `propValues` (multi-axis overrides).
|
|
27
|
-
* 4. State overlay — when `state` names a modifier sub-object (`_hover`) on
|
|
28
|
-
* the merged surface, its props overlay the base so a static preview
|
|
29
|
-
* shows that state.
|
|
30
|
-
*
|
|
31
|
-
* `propValues` are plain axis names → values (no reserved keys). `state` is a
|
|
32
|
-
* single forced interaction modifier (`'_hover'`); pass it directly rather than
|
|
33
|
-
* smuggling it into `propValues`. **Modes are intentionally not a parameter** —
|
|
34
|
-
* mode visuals ride a scoped wrapper class (`.dark &`) and flip live, so they
|
|
35
|
-
* are never folded into the static base here.
|
|
36
|
-
*/
|
|
37
|
-
declare function resolveAuthoredLayerProps(component: ResolvableComponent | undefined | null, layer: string, propValues: Record<string, unknown>, state?: string | null): Record<string, unknown>;
|
|
38
|
-
/**
|
|
39
|
-
* Resolve per-layer style bags for a set of prop values, mirroring the config's
|
|
40
|
-
* variant resolution. `buildRenderSpec` calls this once per variant combo to
|
|
41
|
-
* bake the bags onto the render spec.
|
|
42
|
-
*
|
|
43
|
-
* `state` is left `null` by the bake path — modifier blocks ride through as
|
|
44
|
-
* nested style props and forced state is applied per cell (the render-spec
|
|
45
|
-
* consumers fold the active modifier into props), so folding it into the base
|
|
46
|
-
* here would be redundant. (Derived callers like the layers panel also pass no
|
|
47
|
-
* state.) `cssVarPrefix` resolves color expressions to a `var(...)`-referencing
|
|
48
|
-
* arbitrary value.
|
|
49
|
-
*/
|
|
50
|
-
declare function resolveRenderedLayerProps(component: ResolvableComponent | undefined, propValues: Record<string, unknown>, state?: string | null, cssVarPrefix?: string): RenderedLayerProps;
|
|
51
|
-
//#endregion
|
|
52
|
-
export { ResolvableComponent, resolveAuthoredLayerProps, resolveRenderedLayerProps };
|
package/dist/spec/layer-props.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { makeTokenRefToCss } from "../entity-utils.js";
|
|
2
|
-
import { isTokenRef } from "../refs.js";
|
|
3
|
-
import { isColorExpression, resolveColorExpression } from "../colorExpressions.js";
|
|
4
|
-
//#region src/spec/layer-props.ts
|
|
5
|
-
const REST_STATE = "rest";
|
|
6
|
-
const isStateKey = (key) => key.startsWith("_");
|
|
7
|
-
/**
|
|
8
|
-
* Resolve the styles a layer effectively has for a set of prop-axis values and
|
|
9
|
-
* (optionally) one forced interaction state, walking the authoring surfaces
|
|
10
|
-
* codegen reads:
|
|
11
|
-
*
|
|
12
|
-
* 1. `component.base[layer]` — the always-on baseline.
|
|
13
|
-
* 2. `component.props[axis].values[value][layer]` — per axis key in `propValues`.
|
|
14
|
-
* 3. `component.compoundProps[].layers[layer]` — for entries whose `when`
|
|
15
|
-
* is a subset of `propValues` (multi-axis overrides).
|
|
16
|
-
* 4. State overlay — when `state` names a modifier sub-object (`_hover`) on
|
|
17
|
-
* the merged surface, its props overlay the base so a static preview
|
|
18
|
-
* shows that state.
|
|
19
|
-
*
|
|
20
|
-
* `propValues` are plain axis names → values (no reserved keys). `state` is a
|
|
21
|
-
* single forced interaction modifier (`'_hover'`); pass it directly rather than
|
|
22
|
-
* smuggling it into `propValues`. **Modes are intentionally not a parameter** —
|
|
23
|
-
* mode visuals ride a scoped wrapper class (`.dark &`) and flip live, so they
|
|
24
|
-
* are never folded into the static base here.
|
|
25
|
-
*/
|
|
26
|
-
function resolveAuthoredLayerProps(component, layer, propValues, state) {
|
|
27
|
-
if (!component) return {};
|
|
28
|
-
const merged = { ...component.base?.[layer] ?? {} };
|
|
29
|
-
for (const [key, value] of Object.entries(propValues)) {
|
|
30
|
-
const binding = component.props?.[key];
|
|
31
|
-
if (!binding || typeof binding !== "object") continue;
|
|
32
|
-
const layerStyles = pickAxisLayers(binding, value)?.[layer];
|
|
33
|
-
if (layerStyles) mergeLayerStyles(merged, layerStyles);
|
|
34
|
-
}
|
|
35
|
-
if (component.compoundProps) for (const entry of component.compoundProps) {
|
|
36
|
-
if (!matchesContext(entry.when, propValues)) continue;
|
|
37
|
-
const layerStyles = entry.layers[layer];
|
|
38
|
-
if (layerStyles && typeof layerStyles === "object") mergeLayerStyles(merged, layerStyles);
|
|
39
|
-
}
|
|
40
|
-
if (state && state !== REST_STATE && isStateKey(state)) {
|
|
41
|
-
const stateStyles = merged[state];
|
|
42
|
-
if (stateStyles && typeof stateStyles === "object") Object.assign(merged, stateStyles);
|
|
43
|
-
}
|
|
44
|
-
return merged;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Resolve per-layer style bags for a set of prop values, mirroring the config's
|
|
48
|
-
* variant resolution. `buildRenderSpec` calls this once per variant combo to
|
|
49
|
-
* bake the bags onto the render spec.
|
|
50
|
-
*
|
|
51
|
-
* `state` is left `null` by the bake path — modifier blocks ride through as
|
|
52
|
-
* nested style props and forced state is applied per cell (the render-spec
|
|
53
|
-
* consumers fold the active modifier into props), so folding it into the base
|
|
54
|
-
* here would be redundant. (Derived callers like the layers panel also pass no
|
|
55
|
-
* state.) `cssVarPrefix` resolves color expressions to a `var(...)`-referencing
|
|
56
|
-
* arbitrary value.
|
|
57
|
-
*/
|
|
58
|
-
function resolveRenderedLayerProps(component, propValues, state, cssVarPrefix) {
|
|
59
|
-
if (!component) return {};
|
|
60
|
-
const layerStyles = {};
|
|
61
|
-
for (const layerName of component.layers.keys()) layerStyles[layerName] = finalizeLayerProps(resolveAuthoredLayerProps(component, layerName, propValues, state), state, cssVarPrefix);
|
|
62
|
-
return layerStyles;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Fold the active (selected) state's styles into the flat bag so the static
|
|
66
|
-
* preview shows that state without real interaction, KEEP modifier blocks as
|
|
67
|
-
* nested objects so the component renderer emits their classes (`_hover:bg-x`,
|
|
68
|
-
* `_stackedChildren:ms-[-6px]`) — structural modifiers (child combinators,
|
|
69
|
-
* attrs) apply and interaction states stay live — and bake color expressions
|
|
70
|
-
* into arbitrary style-prop values so they flow through the class system
|
|
71
|
-
* instead of an inline `style`.
|
|
72
|
-
*/
|
|
73
|
-
function finalizeLayerProps(styles, state, cssVarPrefix) {
|
|
74
|
-
const merged = { ...styles };
|
|
75
|
-
const stateStyles = state && isStateKey(state) ? styles[state] : void 0;
|
|
76
|
-
if (stateStyles && typeof stateStyles === "object") Object.assign(merged, stateStyles);
|
|
77
|
-
return bakeColorValues(merged, makeTokenRefToCss(cssVarPrefix));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Resolve every color expression / token ref in a layer's style map to an
|
|
81
|
-
* arbitrary `[…]` value, recursing into nested modifier blocks. A
|
|
82
|
-
* `color-mix(...)` / `var(--…)` isn't a pre-compiled token class, so the
|
|
83
|
-
* bracket form lets `getClassName` encode it into a class the same way it
|
|
84
|
-
* handles `[16px]` — keeping styling renderer-agnostic (no inline `style` whose
|
|
85
|
-
* `var(...)` the build would tree-shake).
|
|
86
|
-
*/
|
|
87
|
-
function bakeColorValues(styles, tokenRefToCss) {
|
|
88
|
-
const out = {};
|
|
89
|
-
for (const [key, value] of Object.entries(styles)) if (isColorExpression(value)) out[key] = `[${resolveColorExpression(value, tokenRefToCss)}]`;
|
|
90
|
-
else if (isTokenRef(value)) out[key] = `[${tokenRefToCss(value.ref)}]`;
|
|
91
|
-
else if (value !== null && typeof value === "object" && !Array.isArray(value)) out[key] = bakeColorValues(value, tokenRefToCss);
|
|
92
|
-
else out[key] = value;
|
|
93
|
-
return out;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Layer `from` onto `into`, deep-merging interaction-state modifier blocks
|
|
97
|
-
* (`_hover`, `_disabled`, …) instead of replacing them. A variant's
|
|
98
|
-
* `_disabled: { borderColor }` must combine with `base`'s `_disabled: { opacity }`
|
|
99
|
-
* — a shallow `Object.assign` would drop the base opacity, so the
|
|
100
|
-
* secondary+disabled cell loses its dimming. Non-modifier props still
|
|
101
|
-
* shallow-replace (a later authoring surface wins that property outright).
|
|
102
|
-
*/
|
|
103
|
-
function mergeLayerStyles(into, from) {
|
|
104
|
-
for (const [key, value] of Object.entries(from)) {
|
|
105
|
-
const existing = into[key];
|
|
106
|
-
if (isStateKey(key) && isStyleMap(existing) && isStyleMap(value)) into[key] = {
|
|
107
|
-
...existing,
|
|
108
|
-
...value
|
|
109
|
-
};
|
|
110
|
-
else into[key] = value;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Pull the per-layer style map keyed by `value` off a `variant` / `boolean`
|
|
115
|
-
* marker. Booleans accept a real boolean or its string form.
|
|
116
|
-
*/
|
|
117
|
-
function pickAxisLayers(binding, value) {
|
|
118
|
-
if (binding.__kind === "variant") {
|
|
119
|
-
const values = binding.values;
|
|
120
|
-
if (!values) return void 0;
|
|
121
|
-
const entry = values[String(value)];
|
|
122
|
-
return isStyleMap(entry) ? entry : void 0;
|
|
123
|
-
}
|
|
124
|
-
if (binding.__kind === "boolean") {
|
|
125
|
-
const values = binding.values;
|
|
126
|
-
if (!values) return void 0;
|
|
127
|
-
const key = coerceBooleanKey(value);
|
|
128
|
-
if (key === void 0) return void 0;
|
|
129
|
-
const entry = values[key];
|
|
130
|
-
return isStyleMap(entry) ? entry : void 0;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function isStyleMap(value) {
|
|
134
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
135
|
-
}
|
|
136
|
-
function coerceBooleanKey(value) {
|
|
137
|
-
if (value === true || value === "true") return "true";
|
|
138
|
-
if (value === false || value === "false") return "false";
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* `when` is a subset of `context` when every key in `when` is present in
|
|
142
|
-
* `context` with the same stringified value.
|
|
143
|
-
*/
|
|
144
|
-
function matchesContext(when, context) {
|
|
145
|
-
for (const [k, v] of Object.entries(when)) if (String(context[k]) !== String(v)) return false;
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
//#endregion
|
|
149
|
-
export { resolveAuthoredLayerProps, resolveRenderedLayerProps };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Component } from "../Component.js";
|
|
2
|
-
import { Config } from "../Config.js";
|
|
3
|
-
|
|
4
|
-
//#region src/spec/preview-controls.d.ts
|
|
5
|
-
type PreviewControlKind = 'variant' | 'boolean' | 'string';
|
|
6
|
-
interface PreviewControl {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly kind: PreviewControlKind;
|
|
9
|
-
readonly defaultValue: unknown;
|
|
10
|
-
/** Selectable values — set for `variant` controls (incl. composite/styleProp). */
|
|
11
|
-
readonly options?: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The selectable values for a prop, or `undefined` when it isn't option-backed.
|
|
15
|
-
* Resolves by the prop's declared kind: a `variant()`'s declared values, a
|
|
16
|
-
* `composite()`'s registered style keys (e.g. `textVariant` → its variant
|
|
17
|
-
* names), or a `styleProp()`'s token + keyword names. A name that isn't a
|
|
18
|
-
* declared prop falls back to a same-named registered style prop (the Box
|
|
19
|
-
* surface — e.g. `color`/`bg` set only via `preview.defaultProps`).
|
|
20
|
-
*/
|
|
21
|
-
declare function propOptions(config: Config, component: Component, name: string): readonly string[] | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Editable preview controls for a component:
|
|
24
|
-
*
|
|
25
|
-
* - `variant` → dropdown of declared values
|
|
26
|
-
* - `composite` → dropdown, options from the registered composite
|
|
27
|
-
* - `boolean` → toggle; `string` / `number` → text input
|
|
28
|
-
* - `slot` → text input when string-typed/seeded (`children: 'Badge'`); a
|
|
29
|
-
* ReactNode slot is omitted (its content is a keyed spec element, not a
|
|
30
|
-
* scalar prop — it can't be set from a value control)
|
|
31
|
-
* - `styleProp` / `function` → omitted from the main walk (the Box style
|
|
32
|
-
* surface would flood; event handlers aren't value-editable)
|
|
33
|
-
* - any scalar `preview.defaultProps` entry not already covered (e.g.
|
|
34
|
-
* `children` on a primitive) → text/toggle, or a dropdown when the prop is
|
|
35
|
-
* option-backed (e.g. a `color` styleProp default → token dropdown)
|
|
36
|
-
*
|
|
37
|
-
* `seed` is the rendered instance's current root props (the authored example /
|
|
38
|
-
* live override); a seed value wins over `defaultProps` for the shown default.
|
|
39
|
-
* Variant/slot stay unset when nothing seeds them so the row reads "Default".
|
|
40
|
-
* Sorted variant-first, then the rest, each group alphabetized.
|
|
41
|
-
*/
|
|
42
|
-
declare function derivePreviewControls(config: Config, component: Component, seed?: Record<string, unknown>): PreviewControl[];
|
|
43
|
-
//#endregion
|
|
44
|
-
export { PreviewControl, PreviewControlKind, derivePreviewControls, propOptions };
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
//#region src/spec/preview-controls.ts
|
|
2
|
-
/**
|
|
3
|
-
* The selectable values for a prop, or `undefined` when it isn't option-backed.
|
|
4
|
-
* Resolves by the prop's declared kind: a `variant()`'s declared values, a
|
|
5
|
-
* `composite()`'s registered style keys (e.g. `textVariant` → its variant
|
|
6
|
-
* names), or a `styleProp()`'s token + keyword names. A name that isn't a
|
|
7
|
-
* declared prop falls back to a same-named registered style prop (the Box
|
|
8
|
-
* surface — e.g. `color`/`bg` set only via `preview.defaultProps`).
|
|
9
|
-
*/
|
|
10
|
-
function propOptions(config, component, name) {
|
|
11
|
-
const info = component.derived.props.find((p) => p.name === name);
|
|
12
|
-
if (!info) return optionsForStyleProp(config, name);
|
|
13
|
-
switch (info.kind) {
|
|
14
|
-
case "variant": return info.values.map(String);
|
|
15
|
-
case "composite": {
|
|
16
|
-
const composite = config.compositeStyles.get(info.compositeName);
|
|
17
|
-
return composite ? [...composite.styles.keys()] : void 0;
|
|
18
|
-
}
|
|
19
|
-
case "styleProp": return optionsForStyleProp(config, info.stylePropName);
|
|
20
|
-
default: return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function optionsForStyleProp(config, propName) {
|
|
24
|
-
const styleProp = config.styleProps.get(propName);
|
|
25
|
-
if (!styleProp) return void 0;
|
|
26
|
-
const values = [];
|
|
27
|
-
for (const token of styleProp.derived.tokens) values.push(token.name);
|
|
28
|
-
for (const key of styleProp.derived.keywords.keys()) if (typeof key === "string") values.push(key);
|
|
29
|
-
return values.length > 0 ? values : void 0;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Editable preview controls for a component:
|
|
33
|
-
*
|
|
34
|
-
* - `variant` → dropdown of declared values
|
|
35
|
-
* - `composite` → dropdown, options from the registered composite
|
|
36
|
-
* - `boolean` → toggle; `string` / `number` → text input
|
|
37
|
-
* - `slot` → text input when string-typed/seeded (`children: 'Badge'`); a
|
|
38
|
-
* ReactNode slot is omitted (its content is a keyed spec element, not a
|
|
39
|
-
* scalar prop — it can't be set from a value control)
|
|
40
|
-
* - `styleProp` / `function` → omitted from the main walk (the Box style
|
|
41
|
-
* surface would flood; event handlers aren't value-editable)
|
|
42
|
-
* - any scalar `preview.defaultProps` entry not already covered (e.g.
|
|
43
|
-
* `children` on a primitive) → text/toggle, or a dropdown when the prop is
|
|
44
|
-
* option-backed (e.g. a `color` styleProp default → token dropdown)
|
|
45
|
-
*
|
|
46
|
-
* `seed` is the rendered instance's current root props (the authored example /
|
|
47
|
-
* live override); a seed value wins over `defaultProps` for the shown default.
|
|
48
|
-
* Variant/slot stay unset when nothing seeds them so the row reads "Default".
|
|
49
|
-
* Sorted variant-first, then the rest, each group alphabetized.
|
|
50
|
-
*/
|
|
51
|
-
function derivePreviewControls(config, component, seed = {}) {
|
|
52
|
-
const controls = [];
|
|
53
|
-
const seen = /* @__PURE__ */ new Set();
|
|
54
|
-
const declaredDefaults = component.defaultProps ?? {};
|
|
55
|
-
for (const info of component.derived.props) {
|
|
56
|
-
const control = describeProp(config, component, info, declaredDefaults[info.name], seed[info.name]);
|
|
57
|
-
if (!control) continue;
|
|
58
|
-
controls.push(control);
|
|
59
|
-
seen.add(info.name);
|
|
60
|
-
}
|
|
61
|
-
const previewDefaults = component.preview?.defaultProps ?? {};
|
|
62
|
-
for (const [name, value] of Object.entries(previewDefaults)) {
|
|
63
|
-
if (seen.has(name)) continue;
|
|
64
|
-
const options = propOptions(config, component, name);
|
|
65
|
-
if (options && options.length > 0) {
|
|
66
|
-
controls.push({
|
|
67
|
-
name,
|
|
68
|
-
kind: "variant",
|
|
69
|
-
defaultValue: seed[name] ?? value,
|
|
70
|
-
options
|
|
71
|
-
});
|
|
72
|
-
seen.add(name);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const kind = scalarKind(value);
|
|
76
|
-
if (!kind) continue;
|
|
77
|
-
controls.push({
|
|
78
|
-
name,
|
|
79
|
-
kind,
|
|
80
|
-
defaultValue: seed[name] ?? value
|
|
81
|
-
});
|
|
82
|
-
seen.add(name);
|
|
83
|
-
}
|
|
84
|
-
return sortPreviewControls(controls);
|
|
85
|
-
}
|
|
86
|
-
function describeProp(config, component, info, declaredDefault, seed) {
|
|
87
|
-
switch (info.kind) {
|
|
88
|
-
case "variant": return {
|
|
89
|
-
name: info.name,
|
|
90
|
-
kind: "variant",
|
|
91
|
-
defaultValue: seed ?? declaredDefault ?? void 0,
|
|
92
|
-
options: info.values.map(String)
|
|
93
|
-
};
|
|
94
|
-
case "boolean": return {
|
|
95
|
-
name: info.name,
|
|
96
|
-
kind: "boolean",
|
|
97
|
-
defaultValue: seed ?? declaredDefault ?? false
|
|
98
|
-
};
|
|
99
|
-
case "string":
|
|
100
|
-
case "number": return {
|
|
101
|
-
name: info.name,
|
|
102
|
-
kind: "string",
|
|
103
|
-
defaultValue: seed ?? declaredDefault ?? ""
|
|
104
|
-
};
|
|
105
|
-
case "composite": {
|
|
106
|
-
const options = propOptions(config, component, info.name);
|
|
107
|
-
if (!options || options.length === 0) return null;
|
|
108
|
-
return {
|
|
109
|
-
name: info.name,
|
|
110
|
-
kind: "variant",
|
|
111
|
-
defaultValue: seed ?? declaredDefault ?? void 0,
|
|
112
|
-
options
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
case "slot": {
|
|
116
|
-
const value = seed ?? declaredDefault;
|
|
117
|
-
if (info.authoredType === "string" || typeof value === "string") return {
|
|
118
|
-
name: info.name,
|
|
119
|
-
kind: "string",
|
|
120
|
-
defaultValue: typeof value === "string" ? value : ""
|
|
121
|
-
};
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
default: return null;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function scalarKind(value) {
|
|
128
|
-
if (typeof value === "boolean") return "boolean";
|
|
129
|
-
if (typeof value === "string" || typeof value === "number") return "string";
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
function sortPreviewControls(controls) {
|
|
133
|
-
const byName = (a, b) => a.name.localeCompare(b.name);
|
|
134
|
-
const variants = controls.filter((c) => c.kind === "variant").sort(byName);
|
|
135
|
-
const rest = controls.filter((c) => c.kind !== "variant").sort(byName);
|
|
136
|
-
return [...variants, ...rest];
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
export { derivePreviewControls, propOptions };
|