@yahoo/uds-create-config 2.44.0 → 3.0.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/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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
//#region src/renderer/spec-content.tsx
|
|
3
|
+
/**
|
|
4
|
+
* An injected drop-target `Slot` placeholder (`withContainerChildSlots` /
|
|
5
|
+
* `withEmptyNodeSlots` in `../spec/empty-node-slots.ts`) arrives here as a
|
|
6
|
+
* rendered json-render element wrapper whose spec element is `Slot`-typed —
|
|
7
|
+
* the same `props.element.type` detection child-enumerating render fns use.
|
|
8
|
+
* It is editing scaffolding (a canvas insertion affordance), not content.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A child that is PRESENT in the spec but paints nothing.
|
|
12
|
+
*
|
|
13
|
+
* Two shapes, one category. A `Slot` is the trailing drop target every node container gets injected.
|
|
14
|
+
* A `visible: false` element is one expansion deliberately keeps rather than drops — "json-render
|
|
15
|
+
* tests `visible` before it looks the type up, so a false node draws nothing and every key a parent
|
|
16
|
+
* names still exists" — which is right for the spec and wrong for this question.
|
|
17
|
+
*
|
|
18
|
+
* Both must be invisible HERE too, or a container holding only these looks occupied and swallows its
|
|
19
|
+
* own label. That is not hypothetical: every `Button` cell in the matrix rendered blank, because the
|
|
20
|
+
* root lists `startIcon`/`endIcon` as children and an unset icon is exactly a `visible: false` node.
|
|
21
|
+
* The compiled module never hits this — `{startIcon && <Box/>}` emits nothing at all when unset — so
|
|
22
|
+
* it only ever shows on the anatomy path.
|
|
23
|
+
*/
|
|
24
|
+
function rendersNothing(child) {
|
|
25
|
+
const element = specElementOf(child);
|
|
26
|
+
return element?.type === "Slot" || element?.visible === false;
|
|
27
|
+
}
|
|
28
|
+
/** The spec element a rendered child wraps: json-render's `ElementRenderer` carries it on
|
|
29
|
+
* `props.element`. Undefined for anything else in the children stream. */
|
|
30
|
+
function specElementOf(child) {
|
|
31
|
+
if (!React.isValidElement(child)) return void 0;
|
|
32
|
+
return child.props.element;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The marker an editor stamps on a layer it paints although the layer's own condition hides it in
|
|
36
|
+
* that cell. Its value names why the layer was hidden.
|
|
37
|
+
*/
|
|
38
|
+
const REVEALED_LAYER_ATTR = "data-uds-ghost";
|
|
39
|
+
/** A child an editor revealed for selection. It paints, but it is not the cell's content. */
|
|
40
|
+
function isRevealed(child) {
|
|
41
|
+
return specElementOf(child)?.props?.[REVEALED_LAYER_ATTR] !== void 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The child that IS the component's content slot — the anatomy's content-position
|
|
45
|
+
* node, which `deriveSpec` projects stamped
|
|
46
|
+
* `data-uds-slot-anatomy`. Its index is where the render interleaves the
|
|
47
|
+
* instance's content, which is the one fact a string `children` label needs:
|
|
48
|
+
* the label splices there, exactly where the compiled module's own JSX puts it.
|
|
49
|
+
*/
|
|
50
|
+
function slotAnatomyIndex(children) {
|
|
51
|
+
return children.findIndex((child) => typeof specElementOf(child)?.props?.["data-uds-slot-anatomy"] === "string");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The one merge of a spec element's two content channels.
|
|
55
|
+
*
|
|
56
|
+
* An element carries content twice — `element.children` holds keys json-render renders into the
|
|
57
|
+
* children stream, `props.children` holds an authored label — and every render path has to decide
|
|
58
|
+
* between them the same way, or a component paints differently through its compiled entry than
|
|
59
|
+
* through an expanded anatomy's intrinsic tags.
|
|
60
|
+
*
|
|
61
|
+
* Spec children win over a `props.children` label — but ONLY ones that paint. A container whose
|
|
62
|
+
* spec children all render nothing (see {@link rendersNothing}) is empty as far as the label is
|
|
63
|
+
* concerned, so the label renders first and they follow it, preserving the canvas's
|
|
64
|
+
* bottom-insertion affordance.
|
|
65
|
+
*
|
|
66
|
+
* A `children` label coexists with the element's own spec children rather than losing to them:
|
|
67
|
+
* Button's anatomy is icon-box layers as children edges PLUS the label as a string `children`
|
|
68
|
+
* prop, and the built module paints both at once — dropping the label made every slot fill look
|
|
69
|
+
* like it wiped the cell. WHERE it lands is the anatomy's to say: the content-position node marks
|
|
70
|
+
* it ({@link slotAnatomyIndex}), and the label splices there, before the placeholder, so an edit
|
|
71
|
+
* surface keeps the slot's own affordance. A spec with no marker — a stale artifact, a
|
|
72
|
+
* studio-created component — keeps the pre-marker behavior: spec children win. A slot fill can't
|
|
73
|
+
* double either way — json-render hands it through `slots`, never the child array.
|
|
74
|
+
*
|
|
75
|
+
* A revealed layer ({@link REVEALED_LAYER_ATTR}) paints, so with the marker present it takes its
|
|
76
|
+
* real place around the label. Without the marker it counts as painting nothing, or selecting a
|
|
77
|
+
* hidden layer would make the label vanish from that cell.
|
|
78
|
+
*/
|
|
79
|
+
function specContent({ children, propChildren }) {
|
|
80
|
+
const childArray = React.Children.toArray(children);
|
|
81
|
+
const slotAt = slotAnatomyIndex(childArray);
|
|
82
|
+
if (childArray.some((c) => !rendersNothing(c) && (slotAt >= 0 || !isRevealed(c)))) {
|
|
83
|
+
if (slotAt >= 0 && propChildren != null) return [
|
|
84
|
+
...childArray.slice(0, slotAt),
|
|
85
|
+
propChildren,
|
|
86
|
+
...childArray.slice(slotAt)
|
|
87
|
+
];
|
|
88
|
+
return children;
|
|
89
|
+
}
|
|
90
|
+
if (propChildren != null && childArray.length > 0) return [propChildren, ...childArray];
|
|
91
|
+
if (childArray.length > 0) return children;
|
|
92
|
+
return propChildren;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { REVEALED_LAYER_ATTR, specContent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StylePropClassMap } from "./wrappers/html-aliases.js";
|
|
2
2
|
import { ComponentRegistry } from "@json-render/react";
|
|
3
3
|
|
|
4
4
|
//#region src/renderer/wrapRegistry.d.ts
|
|
@@ -10,31 +10,27 @@ import { ComponentRegistry } from "@json-render/react";
|
|
|
10
10
|
* component or style-prop names. Every field is optional; an omitted/empty
|
|
11
11
|
* descriptor makes the dependent wrapper a no-op (e.g. a host registry that
|
|
12
12
|
* supplies its own components without a descriptor).
|
|
13
|
+
*
|
|
14
|
+
* Per-component facts — whether children are stripped, which slots exist —
|
|
15
|
+
* live in each module's emitted entry (`makeComponentEntry`), not here. What
|
|
16
|
+
* remains is ingest normalization and the intrinsic fallback, which describe
|
|
17
|
+
* the CONFIG rather than any one component.
|
|
13
18
|
*/
|
|
14
19
|
interface RegistryDescriptor {
|
|
15
|
-
/**
|
|
16
|
-
* Component names whose root renders a void HTML element (`img`, `input`,
|
|
17
|
-
* …). `wrapVoidElements` strips `children` from these — React throws if a
|
|
18
|
-
* void element gets children. Bare names; namespace prefixes are stripped
|
|
19
|
-
* at match time.
|
|
20
|
-
*/
|
|
21
|
-
voidComponents?: readonly string[];
|
|
22
|
-
/**
|
|
23
|
-
* Component names that declare no `children` slot (`acceptsChildren ===
|
|
24
|
-
* false`). `wrapVoidElements` strips `children` from these too — the
|
|
25
|
-
* component's render has nowhere to put them and would otherwise forward
|
|
26
|
-
* them onto a nested void element (a `div`-rooted form control's `<input>`)
|
|
27
|
-
* and throw. Complements `voidComponents` (which keys on a void ROOT tag);
|
|
28
|
-
* the two sets overlap only harmlessly. Bare names; prefixes stripped at
|
|
29
|
-
* match time.
|
|
30
|
-
*/
|
|
31
|
-
noChildrenComponents?: readonly string[];
|
|
32
20
|
/**
|
|
33
21
|
* camelCase CSS property → style-prop name, inverted from each
|
|
34
22
|
* `StyleProp.cssProperty`. Lets `wrapInlineStyleProps` hoist a raw
|
|
35
23
|
* `style: {...}` (Figma / AI import) onto typed style props.
|
|
36
24
|
*/
|
|
37
25
|
cssPropertyToStyleProp?: Readonly<Record<string, string>>;
|
|
26
|
+
/**
|
|
27
|
+
* Style-prop name → declared value → its utility class. Lets `aliasHtmlTypes` turn a style prop
|
|
28
|
+
* into a class for an INTRINSIC tag, which has none of the resolution a component's own render
|
|
29
|
+
* does — so `<section bg="highlight">` becomes `<section class="…-bg-highlight">` instead of an
|
|
30
|
+
* inert attribute. Keyed by DECLARED value (the leaf a group-bound prop offers), because that is
|
|
31
|
+
* the only value a class was emitted for.
|
|
32
|
+
*/
|
|
33
|
+
stylePropClasses?: StylePropClassMap;
|
|
38
34
|
/**
|
|
39
35
|
* Container primitives (root renders `div`): a fixed `height` from an
|
|
40
36
|
* imported `style` becomes `minHeight` so content can still grow.
|
|
@@ -45,30 +41,19 @@ interface RegistryDescriptor {
|
|
|
45
41
|
* an imported `style` is dropped — text shouldn't carry a bounding box.
|
|
46
42
|
*/
|
|
47
43
|
textComponents?: readonly string[];
|
|
48
|
-
/**
|
|
49
|
-
* Component-typed slots (the aliased `Icon` pattern): componentName →
|
|
50
|
-
* propName → accepted asset-group slug. A `slot({ type: 'component' })
|
|
51
|
-
* .accepts(<icon group>)` saves the picked asset as an inline name string
|
|
52
|
-
* and its render fn expects the icon component itself, so
|
|
53
|
-
* `wrapComponentTypedSlots` resolves the name to the member component (paired
|
|
54
|
-
* with the runtime `assetMembersBySlug` lookup). Absent for components
|
|
55
|
-
* without such slots.
|
|
56
|
-
*/
|
|
57
|
-
componentSlots?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
58
44
|
}
|
|
59
45
|
/**
|
|
60
46
|
* Apply the standard wrapper stack + built-in spec primitives to an
|
|
61
|
-
* existing `ComponentRegistry`.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
47
|
+
* existing `ComponentRegistry`. The emitted `react-registry` composes this
|
|
48
|
+
* over `defineRegistry(catalog, entries).registry`, AND `UdsRenderer`
|
|
49
|
+
* re-applies it when a host provides a custom registry that needs the same
|
|
50
|
+
* wrappers on top.
|
|
65
51
|
*
|
|
66
52
|
* `descriptor` carries the config-derived facts the config-dependent
|
|
67
|
-
* wrappers (`
|
|
68
|
-
* wrappers pass through. Composition order
|
|
69
|
-
*
|
|
70
|
-
* seen the element.
|
|
53
|
+
* wrappers (`inline-styles`, `html-aliases`) need; omit it and those
|
|
54
|
+
* wrappers pass through. Composition order matters — each wrapper assumes
|
|
55
|
+
* its outer wrappers haven't yet seen the element.
|
|
71
56
|
*/
|
|
72
|
-
declare function wrapRegistry(reg: ComponentRegistry, descriptor?: RegistryDescriptor
|
|
57
|
+
declare function wrapRegistry(reg: ComponentRegistry, descriptor?: RegistryDescriptor): ComponentRegistry;
|
|
73
58
|
//#endregion
|
|
74
59
|
export { RegistryDescriptor, wrapRegistry };
|
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
import { FragmentRenderer } from "./primitives/FragmentRenderer.js";
|
|
2
2
|
import { SlotRenderer } from "./primitives/SlotRenderer.js";
|
|
3
|
-
import { wrapComponentTypedSlots } from "./wrappers/component-slots.js";
|
|
4
3
|
import { wrapEventBridge } from "./wrappers/event-bridge.js";
|
|
5
4
|
import { wrapNormalizeHex } from "./wrappers/hex-normalize.js";
|
|
6
5
|
import { aliasHtmlTypes } from "./wrappers/html-aliases.js";
|
|
7
6
|
import { wrapInlineStyleProps } from "./wrappers/inline-styles.js";
|
|
8
|
-
import { wrapSlotResolution } from "./wrappers/slot-resolution.js";
|
|
9
|
-
import { wrapVoidElements } from "./wrappers/void-elements.js";
|
|
10
7
|
//#region src/renderer/wrapRegistry.ts
|
|
11
8
|
/**
|
|
12
9
|
* Apply the standard wrapper stack + built-in spec primitives to an
|
|
13
|
-
* existing `ComponentRegistry`.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* existing `ComponentRegistry`. The emitted `react-registry` composes this
|
|
11
|
+
* over `defineRegistry(catalog, entries).registry`, AND `UdsRenderer`
|
|
12
|
+
* re-applies it when a host provides a custom registry that needs the same
|
|
13
|
+
* wrappers on top.
|
|
17
14
|
*
|
|
18
15
|
* `descriptor` carries the config-derived facts the config-dependent
|
|
19
|
-
* wrappers (`
|
|
20
|
-
* wrappers pass through. Composition order
|
|
21
|
-
*
|
|
22
|
-
* seen the element.
|
|
16
|
+
* wrappers (`inline-styles`, `html-aliases`) need; omit it and those
|
|
17
|
+
* wrappers pass through. Composition order matters — each wrapper assumes
|
|
18
|
+
* its outer wrappers haven't yet seen the element.
|
|
23
19
|
*/
|
|
24
|
-
function wrapRegistry(reg, descriptor
|
|
25
|
-
return aliasHtmlTypes(wrapInlineStyleProps(wrapNormalizeHex(wrapEventBridge(
|
|
20
|
+
function wrapRegistry(reg, descriptor) {
|
|
21
|
+
return aliasHtmlTypes(wrapInlineStyleProps(wrapNormalizeHex(wrapEventBridge({
|
|
26
22
|
...reg,
|
|
27
23
|
Fragment: reg.Fragment ?? FragmentRenderer,
|
|
28
24
|
Slot: reg.Slot ?? SlotRenderer
|
|
29
|
-
}, {
|
|
30
|
-
voidComponents: descriptor?.voidComponents,
|
|
31
|
-
noChildrenComponents: descriptor?.noChildrenComponents
|
|
32
25
|
})), {
|
|
33
|
-
componentSlots: descriptor?.componentSlots,
|
|
34
|
-
assetMembersBySlug
|
|
35
|
-
}))), {
|
|
36
26
|
cssPropertyToStyleProp: descriptor?.cssPropertyToStyleProp,
|
|
37
27
|
layoutComponents: descriptor?.layoutComponents,
|
|
38
28
|
textComponents: descriptor?.textComponents
|
|
39
|
-
}));
|
|
29
|
+
}), descriptor?.stylePropClasses);
|
|
40
30
|
}
|
|
41
31
|
//#endregion
|
|
42
32
|
export { wrapRegistry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { useStateStore } from "@json-render/react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
//#region src/renderer/wrappers/event-bridge.tsx
|
|
4
4
|
/**
|
|
5
5
|
* Map json-render `on.*` event bindings to React callback prop names.
|
|
@@ -37,11 +37,11 @@ const EVENT_TO_CALLBACKS = {
|
|
|
37
37
|
*/
|
|
38
38
|
function wrapEventBridge(reg) {
|
|
39
39
|
const wrapped = { ...reg };
|
|
40
|
-
|
|
40
|
+
const makeEventBridgeWrapper = (Comp) => function EventBridgeWrapper(renderProps) {
|
|
41
41
|
const stateStore = useStateStore();
|
|
42
42
|
const { element, emit } = renderProps;
|
|
43
43
|
const on = element.on;
|
|
44
|
-
if (!on) return
|
|
44
|
+
if (!on) return React.createElement(Comp, renderProps);
|
|
45
45
|
const callbackProps = {};
|
|
46
46
|
for (const [eventName, binding] of Object.entries(on)) {
|
|
47
47
|
const callbackNames = EVENT_TO_CALLBACKS[eventName];
|
|
@@ -59,7 +59,7 @@ function wrapEventBridge(reg) {
|
|
|
59
59
|
};
|
|
60
60
|
for (const cbName of callbackNames) callbackProps[cbName] = handler;
|
|
61
61
|
}
|
|
62
|
-
if (Object.keys(callbackProps).length === 0) return
|
|
62
|
+
if (Object.keys(callbackProps).length === 0) return React.createElement(Comp, renderProps);
|
|
63
63
|
const patchedElement = {
|
|
64
64
|
...element,
|
|
65
65
|
props: {
|
|
@@ -67,11 +67,12 @@ function wrapEventBridge(reg) {
|
|
|
67
67
|
...callbackProps
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
return
|
|
70
|
+
return React.createElement(Comp, {
|
|
71
71
|
...renderProps,
|
|
72
72
|
element: patchedElement
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
+
for (const [name, Comp] of Object.entries(reg)) wrapped[name] = makeEventBridgeWrapper(Comp);
|
|
75
76
|
return wrapped;
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
//#region src/renderer/wrappers/hex-normalize.tsx
|
|
3
3
|
const RAW_HEX_RE = /^#[0-9a-fA-F]{3,8}$/;
|
|
4
4
|
/**
|
|
@@ -11,17 +11,17 @@ const RAW_HEX_RE = /^#[0-9a-fA-F]{3,8}$/;
|
|
|
11
11
|
*/
|
|
12
12
|
function wrapNormalizeHex(reg) {
|
|
13
13
|
const wrapped = { ...reg };
|
|
14
|
-
|
|
14
|
+
const makeHexNormalizeWrapper = (Comp) => function HexNormalizeWrapper(renderProps) {
|
|
15
15
|
const props = renderProps.element.props;
|
|
16
|
-
if (!props) return
|
|
16
|
+
if (!props) return React.createElement(Comp, renderProps);
|
|
17
17
|
let patched = false;
|
|
18
18
|
const newProps = { ...props };
|
|
19
19
|
for (const [propName, value] of Object.entries(newProps)) if (typeof value === "string" && RAW_HEX_RE.test(value)) {
|
|
20
20
|
newProps[propName] = `[${value}]`;
|
|
21
21
|
patched = true;
|
|
22
22
|
}
|
|
23
|
-
if (!patched) return
|
|
24
|
-
return
|
|
23
|
+
if (!patched) return React.createElement(Comp, renderProps);
|
|
24
|
+
return React.createElement(Comp, {
|
|
25
25
|
...renderProps,
|
|
26
26
|
element: {
|
|
27
27
|
...renderProps.element,
|
|
@@ -29,6 +29,7 @@ function wrapNormalizeHex(reg) {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
+
for (const [name, Comp] of Object.entries(reg)) wrapped[name] = makeHexNormalizeWrapper(Comp);
|
|
32
33
|
return wrapped;
|
|
33
34
|
}
|
|
34
35
|
//#endregion
|
|
@@ -19,6 +19,11 @@ import { ComponentRegistry } from "@json-render/react";
|
|
|
19
19
|
* shape, which lazily caches intrinsic renderers on `target` as they're
|
|
20
20
|
* accessed so repeated lookups return the same function reference.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Style-prop name → declared value → the utility class that value wears. Emitted into
|
|
24
|
+
* `RegistryDescriptor` by codegen, so this wrapper names no style prop of its own.
|
|
25
|
+
*/
|
|
26
|
+
type StylePropClassMap = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
27
|
+
declare function aliasHtmlTypes(reg: ComponentRegistry, stylePropClasses?: StylePropClassMap): ComponentRegistry;
|
|
23
28
|
//#endregion
|
|
24
|
-
export { aliasHtmlTypes };
|
|
29
|
+
export { StylePropClassMap, aliasHtmlTypes };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { specContent } from "../spec-content.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
//#region src/renderer/wrappers/html-aliases.tsx
|
|
3
4
|
const INTRINSIC_TAG_RE = /^[a-z][a-zA-Z0-9-]*$/;
|
|
@@ -14,37 +15,52 @@ const FORBIDDEN_INTRINSIC_PROPS = new Set(["dangerouslySetInnerHTML"]);
|
|
|
14
15
|
const NullEl = () => null;
|
|
15
16
|
NullEl.displayName = "ForbiddenIntrinsic";
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
* (stray SVG internals like `path`, `rect`, `circle`, `g`, or a raw HTML
|
|
19
|
-
* tag a non-conforming spec slips in) renders as a native React intrinsic
|
|
20
|
-
* element instead of triggering json-render's "no renderer for component
|
|
21
|
-
* type" warning.
|
|
18
|
+
* Marks a registry this function already aliased.
|
|
22
19
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Returns a Proxy — successive `wrapRegistry` callers see the proxy
|
|
31
|
-
* shape, which lazily caches intrinsic renderers on `target` as they're
|
|
32
|
-
* accessed so repeated lookups return the same function reference.
|
|
20
|
+
* `wrapRegistry` runs more than once on the same registry — the codegen-emitted bundle wraps at build
|
|
21
|
+
* time WITH its descriptor, and `UdsRenderer` wraps again at render time WITHOUT one (a host that
|
|
22
|
+
* passes its own registry has no descriptor to hand over). Its comment says re-applying the stack is
|
|
23
|
+
* idempotent; for this wrapper it was not. Intrinsic renderers are created lazily on first access, so
|
|
24
|
+
* a second proxy over a shallow copy did not yet have `section` on its target and minted its OWN —
|
|
25
|
+
* with no class map. The style prop then reached the DOM as an attribute again, and only for tags
|
|
26
|
+
* nothing had touched before the re-wrap, which is as order-dependent as it sounds.
|
|
33
27
|
*/
|
|
34
|
-
|
|
28
|
+
const ALIASED = Symbol.for("uds.aliasHtmlTypes");
|
|
29
|
+
function aliasHtmlTypes(reg, stylePropClasses) {
|
|
30
|
+
if (reg[ALIASED]) return reg;
|
|
35
31
|
const wrapped = { ...reg };
|
|
36
32
|
return new Proxy(wrapped, {
|
|
37
33
|
get(target, prop, receiver) {
|
|
34
|
+
if (prop === ALIASED) return true;
|
|
38
35
|
if (typeof prop === "string" && prop in target) return Reflect.get(target, prop, receiver);
|
|
39
36
|
if (typeof prop === "string" && FORBIDDEN_INTRINSIC_TAGS.has(prop)) return NullEl;
|
|
40
37
|
if (typeof prop === "string" && INTRINSIC_TAG_RE.test(prop)) {
|
|
41
|
-
const IntrinsicEl = ({ element, children }) => {
|
|
38
|
+
const IntrinsicEl = ({ element, children, slots }) => {
|
|
39
|
+
const props = element.props;
|
|
42
40
|
const intrinsicProps = {};
|
|
43
|
-
|
|
41
|
+
const styleClasses = [];
|
|
42
|
+
for (const [key, value] of Object.entries(props ?? {})) {
|
|
44
43
|
if (FORBIDDEN_INTRINSIC_PROPS.has(key)) continue;
|
|
44
|
+
if (key === "children") continue;
|
|
45
|
+
const byValue = stylePropClasses?.[key];
|
|
46
|
+
if (byValue) {
|
|
47
|
+
const resolved = typeof value === "string" ? byValue[value] : void 0;
|
|
48
|
+
if (resolved) styleClasses.push(resolved);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
45
51
|
intrinsicProps[key] = value;
|
|
46
52
|
}
|
|
47
|
-
|
|
53
|
+
if (styleClasses.length > 0) {
|
|
54
|
+
const existing = intrinsicProps.className;
|
|
55
|
+
intrinsicProps.className = [typeof existing === "string" ? existing : void 0, ...styleClasses].filter(Boolean).join(" ");
|
|
56
|
+
}
|
|
57
|
+
const content = specContent({
|
|
58
|
+
children,
|
|
59
|
+
propChildren: props?.children
|
|
60
|
+
});
|
|
61
|
+
const slotContent = slots ? Object.values(slots) : [];
|
|
62
|
+
const parts = [...content === void 0 || content === null ? [] : [content], ...slotContent];
|
|
63
|
+
return parts.length === 0 ? React.createElement(prop, intrinsicProps) : React.createElement(prop, intrinsicProps, ...parts);
|
|
48
64
|
};
|
|
49
65
|
IntrinsicEl.displayName = prop;
|
|
50
66
|
target[prop] = IntrinsicEl;
|
|
@@ -53,6 +69,7 @@ function aliasHtmlTypes(reg) {
|
|
|
53
69
|
return Reflect.get(target, prop, receiver);
|
|
54
70
|
},
|
|
55
71
|
has(target, prop) {
|
|
72
|
+
if (prop === ALIASED) return true;
|
|
56
73
|
if (typeof prop === "string" && INTRINSIC_TAG_RE.test(prop)) return true;
|
|
57
74
|
return Reflect.has(target, prop);
|
|
58
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
//#region src/renderer/wrappers/inline-styles.tsx
|
|
3
3
|
const HEX_RE = /^#[0-9a-fA-F]{3,8}$/;
|
|
4
4
|
const UNIT_RE = /^-?\d+(\.\d+)?(px|rem|em|%|vh|vw)$/;
|
|
@@ -63,15 +63,15 @@ function wrapInlineStyleProps(reg, config = {}) {
|
|
|
63
63
|
const layoutSet = new Set(config.layoutComponents ?? []);
|
|
64
64
|
const textSet = new Set(config.textComponents ?? []);
|
|
65
65
|
const wrapped = { ...reg };
|
|
66
|
-
|
|
66
|
+
const makeInlineStylePropsWrapper = (Comp) => function InlineStylePropsWrapper(renderProps) {
|
|
67
67
|
const props = renderProps.element.props;
|
|
68
68
|
const elementType = renderProps.element.type;
|
|
69
69
|
const rawStyle = props?.style;
|
|
70
|
-
if (!props || rawStyle == null) return
|
|
70
|
+
if (!props || rawStyle == null) return React.createElement(Comp, renderProps);
|
|
71
71
|
let style;
|
|
72
72
|
if (typeof rawStyle === "string") style = parseCssDeclarationString(rawStyle);
|
|
73
73
|
else if (typeof rawStyle === "object" && !Array.isArray(rawStyle)) style = rawStyle;
|
|
74
|
-
else return
|
|
74
|
+
else return React.createElement(Comp, renderProps);
|
|
75
75
|
let patched = typeof rawStyle === "string";
|
|
76
76
|
const newProps = { ...props };
|
|
77
77
|
const remainingStyle = {};
|
|
@@ -87,10 +87,10 @@ function wrapInlineStyleProps(reg, config = {}) {
|
|
|
87
87
|
} else if (shouldDropCssStyle(cssKey, elementType, textSet)) patched = true;
|
|
88
88
|
else remainingStyle[cssKey] = cssValue;
|
|
89
89
|
}
|
|
90
|
-
if (!patched) return
|
|
90
|
+
if (!patched) return React.createElement(Comp, renderProps);
|
|
91
91
|
if (Object.keys(remainingStyle).length > 0) newProps.style = remainingStyle;
|
|
92
92
|
else delete newProps.style;
|
|
93
|
-
return
|
|
93
|
+
return React.createElement(Comp, {
|
|
94
94
|
...renderProps,
|
|
95
95
|
element: {
|
|
96
96
|
...renderProps.element,
|
|
@@ -98,6 +98,7 @@ function wrapInlineStyleProps(reg, config = {}) {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
+
for (const [name, Comp] of Object.entries(reg)) wrapped[name] = makeInlineStylePropsWrapper(Comp);
|
|
101
102
|
return wrapped;
|
|
102
103
|
}
|
|
103
104
|
//#endregion
|
package/dist/spec/asset-jsx.d.ts
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
//#region src/spec/asset-jsx.d.ts
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* The identifier a type is KNOWN AS in JSX — `component:buttons/Primary` → `Primary`.
|
|
4
|
+
*
|
|
5
|
+
* A type is a ref (`component:buttons/Primary`), and neither half of it is JSX: the kind isn't part
|
|
6
|
+
* of the name, and a grouped path isn't a legal tag or import name. The leaf is what codegen names
|
|
7
|
+
* the export, so `<Primary />` and `import { Primary }` agree with the module that actually exists.
|
|
8
|
+
* An intrinsic tag has no kind and no group, so it passes through untouched.
|
|
9
|
+
*/
|
|
10
|
+
declare function jsxIdentifier(type: string): string;
|
|
11
|
+
/** Pull the library slug + member out of an asset node's type, or `null` for anything else — a
|
|
12
|
+
* component, a package export, an intrinsic tag. */
|
|
3
13
|
declare function parseAssetType(type: string): {
|
|
4
14
|
slug: string;
|
|
5
15
|
member: string;
|
|
6
16
|
} | null;
|
|
7
17
|
/**
|
|
8
|
-
* `slug →
|
|
9
|
-
* the asset groups that declare a `component`; a slug missing from
|
|
10
|
-
* no authoring component and falls back to the bare member tag.
|
|
18
|
+
* `slug → the component a placed member renders through` (e.g. `{ icons: 'Icon' }`).
|
|
19
|
+
* Derived from the asset groups that declare a `component`; a slug missing from
|
|
20
|
+
* the map has no authoring component and falls back to the bare member tag.
|
|
21
|
+
* A value may be the component's bare name OR its full path (`primitives/Icon`) —
|
|
22
|
+
* serialization reduces it to the JSX leaf either way ({@link jsxIdentifier}),
|
|
23
|
+
* since a grouped path is not a legal tag.
|
|
11
24
|
*/
|
|
12
25
|
type AssetComponentMap = Readonly<Record<string, string>>;
|
|
13
26
|
/** How a placed asset node should appear in exported JSX. */
|
|
@@ -45,4 +58,4 @@ declare function assetJsxForm(type: string, assetComponents?: AssetComponentMap)
|
|
|
45
58
|
*/
|
|
46
59
|
type AssetNodeResolver = (tag: string, props: Readonly<Record<string, unknown>>) => string | null;
|
|
47
60
|
//#endregion
|
|
48
|
-
export { AssetComponentMap, AssetJsxForm, AssetNodeResolver, assetJsxForm, parseAssetType };
|
|
61
|
+
export { AssetComponentMap, AssetJsxForm, AssetNodeResolver, assetJsxForm, jsxIdentifier, parseAssetType };
|
package/dist/spec/asset-jsx.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
import { pathOf } from "../framework/utils/refs.js";
|
|
1
2
|
//#region src/spec/asset-jsx.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const ASSET_KIND = "icon:";
|
|
4
|
+
/**
|
|
5
|
+
* The identifier a type is KNOWN AS in JSX — `component:buttons/Primary` → `Primary`.
|
|
6
|
+
*
|
|
7
|
+
* A type is a ref (`component:buttons/Primary`), and neither half of it is JSX: the kind isn't part
|
|
8
|
+
* of the name, and a grouped path isn't a legal tag or import name. The leaf is what codegen names
|
|
9
|
+
* the export, so `<Primary />` and `import { Primary }` agree with the module that actually exists.
|
|
10
|
+
* An intrinsic tag has no kind and no group, so it passes through untouched.
|
|
11
|
+
*/
|
|
12
|
+
function jsxIdentifier(type) {
|
|
13
|
+
const path = pathOf(type);
|
|
14
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
15
|
+
}
|
|
16
|
+
/** Pull the library slug + member out of an asset node's type, or `null` for anything else — a
|
|
17
|
+
* component, a package export, an intrinsic tag. */
|
|
5
18
|
function parseAssetType(type) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else {
|
|
9
|
-
const markerIndex = type.indexOf(NAMESPACED_ASSET_MARKER);
|
|
10
|
-
if (markerIndex === -1) return null;
|
|
11
|
-
bodyStart = markerIndex + 7;
|
|
12
|
-
}
|
|
19
|
+
if (!type.startsWith(ASSET_KIND)) return null;
|
|
20
|
+
const bodyStart = 5;
|
|
13
21
|
const slashIndex = type.indexOf("/", bodyStart);
|
|
14
22
|
if (slashIndex === -1) return null;
|
|
15
23
|
const slug = type.slice(bodyStart, slashIndex);
|
|
@@ -34,15 +42,18 @@ function assetJsxForm(type, assetComponents) {
|
|
|
34
42
|
const parsed = parseAssetType(type);
|
|
35
43
|
if (!parsed) return null;
|
|
36
44
|
const component = assetComponents?.[parsed.slug];
|
|
37
|
-
if (component)
|
|
38
|
-
tag
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if (component) {
|
|
46
|
+
const tag = jsxIdentifier(component);
|
|
47
|
+
return {
|
|
48
|
+
tag,
|
|
49
|
+
nameAttr: parsed.member,
|
|
50
|
+
importName: tag
|
|
51
|
+
};
|
|
52
|
+
}
|
|
42
53
|
return {
|
|
43
54
|
tag: parsed.member,
|
|
44
55
|
importName: parsed.member
|
|
45
56
|
};
|
|
46
57
|
}
|
|
47
58
|
//#endregion
|
|
48
|
-
export { assetJsxForm, parseAssetType };
|
|
59
|
+
export { assetJsxForm, jsxIdentifier, parseAssetType };
|
|
@@ -1,32 +1,22 @@
|
|
|
1
|
+
import { Config } from "../framework/Config.js";
|
|
2
|
+
|
|
1
3
|
//#region src/spec/collapse-text-labels.d.ts
|
|
2
4
|
type Props = Record<string, unknown>;
|
|
3
5
|
interface ElementShape {
|
|
4
6
|
type: string;
|
|
5
7
|
props?: Props;
|
|
6
8
|
children?: unknown;
|
|
9
|
+
slots?: Record<string, string[]>;
|
|
7
10
|
}
|
|
8
11
|
interface SpecShape {
|
|
9
12
|
root: string;
|
|
10
13
|
elements: Record<string, ElementShape>;
|
|
11
14
|
}
|
|
12
|
-
interface ComponentClassification {
|
|
13
|
-
derived: {
|
|
14
|
-
acceptsChildren: boolean;
|
|
15
|
-
acceptsChildNodes: boolean;
|
|
16
|
-
prop?(name: string): {
|
|
17
|
-
kind: string;
|
|
18
|
-
layer?: string;
|
|
19
|
-
} | undefined;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
interface ConfigLike {
|
|
23
|
-
getComponent(type: string): ComponentClassification | undefined;
|
|
24
|
-
}
|
|
25
15
|
/** One collapse the transform performed — surfaced for lint/reporting. */
|
|
26
16
|
interface CollapsedTextLabel {
|
|
27
17
|
/** The string-label component whose label was inlined. */
|
|
28
18
|
parentKey: string;
|
|
29
|
-
/** The string-label component's spec `type` (e.g. `
|
|
19
|
+
/** The string-label component's spec `type` (e.g. `component:Badge`). */
|
|
30
20
|
parentType: string;
|
|
31
21
|
/** The wrapped Text element that was removed (when it wasn't shared). */
|
|
32
22
|
childKey: string;
|
|
@@ -43,6 +33,6 @@ interface CollapseTextLabelsResult<S extends SpecShape> {
|
|
|
43
33
|
* header). Non-mutating: unchanged elements are reused, and a spec with no such
|
|
44
34
|
* wrappers is returned as-is with an empty `collapsed` report.
|
|
45
35
|
*/
|
|
46
|
-
declare function collapseWrappedTextLabels<S extends SpecShape>(spec: S, config:
|
|
36
|
+
declare function collapseWrappedTextLabels<S extends SpecShape>(spec: S, config: Config): CollapseTextLabelsResult<S>;
|
|
47
37
|
//#endregion
|
|
48
38
|
export { CollapseTextLabelsResult, CollapsedTextLabel, collapseWrappedTextLabels };
|