@pwfabric/runtime 0.0.0-stage → 1.0.0-rc.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/LICENSE +90 -0
- package/README.md +43 -2
- package/dist/a11y/announcer.d.ts +65 -0
- package/dist/a11y/announcer.js +140 -0
- package/dist/a11y/announcer.js.map +1 -0
- package/dist/a11y/contrast.d.ts +54 -0
- package/dist/a11y/contrast.js +93 -0
- package/dist/a11y/contrast.js.map +1 -0
- package/dist/a11y/focus.d.ts +123 -0
- package/dist/a11y/focus.js +282 -0
- package/dist/a11y/focus.js.map +1 -0
- package/dist/a11y/index.d.ts +21 -0
- package/dist/a11y/index.js +18 -0
- package/dist/a11y/index.js.map +1 -0
- package/dist/a11y/keyboard.d.ts +144 -0
- package/dist/a11y/keyboard.js +317 -0
- package/dist/a11y/keyboard.js.map +1 -0
- package/dist/adapters/default-image.d.ts +25 -0
- package/dist/adapters/default-image.js +37 -0
- package/dist/adapters/default-image.js.map +1 -0
- package/dist/adapters/index.d.ts +27 -0
- package/dist/adapters/index.js +28 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/next-image.d.ts +38 -0
- package/dist/adapters/next-image.js +124 -0
- package/dist/adapters/next-image.js.map +1 -0
- package/dist/adapters/types.d.ts +61 -0
- package/dist/adapters/types.js +11 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/analytics/index.d.ts +14 -0
- package/dist/analytics/index.js +15 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/tracker.d.ts +65 -0
- package/dist/analytics/tracker.js +251 -0
- package/dist/analytics/tracker.js.map +1 -0
- package/dist/analytics/types.d.ts +130 -0
- package/dist/analytics/types.js +11 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/provider.d.ts +132 -0
- package/dist/auth/provider.js +473 -0
- package/dist/auth/provider.js.map +1 -0
- package/dist/auth/types.d.ts +117 -0
- package/dist/auth/types.js +9 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/binding/collection.d.ts +190 -0
- package/dist/binding/collection.js +358 -0
- package/dist/binding/collection.js.map +1 -0
- package/dist/binding/datasource.d.ts +319 -0
- package/dist/binding/datasource.js +556 -0
- package/dist/binding/datasource.js.map +1 -0
- package/dist/binding/engine.d.ts +65 -0
- package/dist/binding/engine.js +268 -0
- package/dist/binding/engine.js.map +1 -0
- package/dist/binding/expression.d.ts +150 -0
- package/dist/binding/expression.js +787 -0
- package/dist/binding/expression.js.map +1 -0
- package/dist/binding/index.d.ts +19 -0
- package/dist/binding/index.js +14 -0
- package/dist/binding/index.js.map +1 -0
- package/dist/binding/two-way.d.ts +149 -0
- package/dist/binding/two-way.js +462 -0
- package/dist/binding/two-way.js.map +1 -0
- package/dist/binding/types.d.ts +119 -0
- package/dist/binding/types.js +9 -0
- package/dist/binding/types.js.map +1 -0
- package/dist/blocks/component-types.d.ts +81 -0
- package/dist/blocks/component-types.js +11 -0
- package/dist/blocks/component-types.js.map +1 -0
- package/dist/blocks/composition-rules.d.ts +168 -0
- package/dist/blocks/composition-rules.js +391 -0
- package/dist/blocks/composition-rules.js.map +1 -0
- package/dist/blocks/hooks.d.ts +31 -0
- package/dist/blocks/hooks.js +42 -0
- package/dist/blocks/hooks.js.map +1 -0
- package/dist/blocks/index.d.ts +14 -0
- package/dist/blocks/index.js +23 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/registry.d.ts +84 -0
- package/dist/blocks/registry.js +136 -0
- package/dist/blocks/registry.js.map +1 -0
- package/dist/blocks/rule-engine.d.ts +131 -0
- package/dist/blocks/rule-engine.js +321 -0
- package/dist/blocks/rule-engine.js.map +1 -0
- package/dist/blocks/surface-event-context.d.ts +13 -0
- package/dist/blocks/surface-event-context.js +14 -0
- package/dist/blocks/surface-event-context.js.map +1 -0
- package/dist/blocks/surface-id-context.d.ts +13 -0
- package/dist/blocks/surface-id-context.js +15 -0
- package/dist/blocks/surface-id-context.js.map +1 -0
- package/dist/bus.d.ts +41 -0
- package/dist/bus.js +158 -0
- package/dist/bus.js.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.js +10 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory.d.ts +32 -0
- package/dist/cache/memory.js +138 -0
- package/dist/cache/memory.js.map +1 -0
- package/dist/cache/types.d.ts +62 -0
- package/dist/cache/types.js +9 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/capability/index.d.ts +72 -0
- package/dist/capability/index.js +87 -0
- package/dist/capability/index.js.map +1 -0
- package/dist/capability/kernel-capabilities.d.ts +31 -0
- package/dist/capability/kernel-capabilities.js +36 -0
- package/dist/capability/kernel-capabilities.js.map +1 -0
- package/dist/capability/platform-capabilities.d.ts +71 -0
- package/dist/capability/platform-capabilities.js +267 -0
- package/dist/capability/platform-capabilities.js.map +1 -0
- package/dist/capability/type-mapping.d.ts +70 -0
- package/dist/capability/type-mapping.js +107 -0
- package/dist/capability/type-mapping.js.map +1 -0
- package/dist/capability/validation.d.ts +46 -0
- package/dist/capability/validation.js +54 -0
- package/dist/capability/validation.js.map +1 -0
- package/dist/connectors/declared-connector.d.ts +48 -0
- package/dist/connectors/declared-connector.js +333 -0
- package/dist/connectors/declared-connector.js.map +1 -0
- package/dist/connectors/engine-registry.d.ts +50 -0
- package/dist/connectors/engine-registry.js +135 -0
- package/dist/connectors/engine-registry.js.map +1 -0
- package/dist/connectors/index.d.ts +14 -0
- package/dist/connectors/index.js +14 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/module-loader.d.ts +70 -0
- package/dist/connectors/module-loader.js +143 -0
- package/dist/connectors/module-loader.js.map +1 -0
- package/dist/connectors/types.d.ts +174 -0
- package/dist/connectors/types.js +23 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/context.d.ts +27 -0
- package/dist/context.js +38 -0
- package/dist/context.js.map +1 -0
- package/dist/data/DataCapabilityProvider.d.ts +39 -0
- package/dist/data/DataCapabilityProvider.js +58 -0
- package/dist/data/DataCapabilityProvider.js.map +1 -0
- package/dist/data/index.d.ts +17 -0
- package/dist/data/index.js +18 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/manager.d.ts +40 -0
- package/dist/data/manager.js +442 -0
- package/dist/data/manager.js.map +1 -0
- package/dist/data/types.d.ts +218 -0
- package/dist/data/types.js +2 -0
- package/dist/data/types.js.map +1 -0
- package/dist/entity/aggregate.d.ts +8 -0
- package/dist/entity/aggregate.js +24 -0
- package/dist/entity/aggregate.js.map +1 -0
- package/dist/entity/apply-query.d.ts +58 -0
- package/dist/entity/apply-query.js +264 -0
- package/dist/entity/apply-query.js.map +1 -0
- package/dist/entity/behavior.d.ts +94 -0
- package/dist/entity/behavior.js +78 -0
- package/dist/entity/behavior.js.map +1 -0
- package/dist/entity/connector.d.ts +141 -0
- package/dist/entity/connector.js +89 -0
- package/dist/entity/connector.js.map +1 -0
- package/dist/entity/connectors/index.d.ts +12 -0
- package/dist/entity/connectors/index.js +11 -0
- package/dist/entity/connectors/index.js.map +1 -0
- package/dist/entity/connectors/static.d.ts +51 -0
- package/dist/entity/connectors/static.js +245 -0
- package/dist/entity/connectors/static.js.map +1 -0
- package/dist/entity/entity-datasource.d.ts +50 -0
- package/dist/entity/entity-datasource.js +33 -0
- package/dist/entity/entity-datasource.js.map +1 -0
- package/dist/entity/facade.d.ts +70 -0
- package/dist/entity/facade.js +70 -0
- package/dist/entity/facade.js.map +1 -0
- package/dist/entity/http-connector.d.ts +123 -0
- package/dist/entity/http-connector.js +295 -0
- package/dist/entity/http-connector.js.map +1 -0
- package/dist/entity/index.d.ts +38 -0
- package/dist/entity/index.js +31 -0
- package/dist/entity/index.js.map +1 -0
- package/dist/entity/postgres-connector.d.ts +64 -0
- package/dist/entity/postgres-connector.js +239 -0
- package/dist/entity/postgres-connector.js.map +1 -0
- package/dist/entity/registry.d.ts +59 -0
- package/dist/entity/registry.js +90 -0
- package/dist/entity/registry.js.map +1 -0
- package/dist/entity/store.d.ts +66 -0
- package/dist/entity/store.js +349 -0
- package/dist/entity/store.js.map +1 -0
- package/dist/entity/types.d.ts +180 -0
- package/dist/entity/types.js +10 -0
- package/dist/entity/types.js.map +1 -0
- package/dist/execution-context.d.ts +88 -0
- package/dist/execution-context.js +146 -0
- package/dist/execution-context.js.map +1 -0
- package/dist/executor.d.ts +27 -0
- package/dist/executor.js +33 -0
- package/dist/executor.js.map +1 -0
- package/dist/forms/form-entity-bridge.d.ts +94 -0
- package/dist/forms/form-entity-bridge.js +96 -0
- package/dist/forms/form-entity-bridge.js.map +1 -0
- package/dist/forms/form-write-target.d.ts +34 -0
- package/dist/forms/form-write-target.js +81 -0
- package/dist/forms/form-write-target.js.map +1 -0
- package/dist/forms/index.d.ts +22 -0
- package/dist/forms/index.js +25 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/named-control-values.d.ts +27 -0
- package/dist/forms/named-control-values.js +42 -0
- package/dist/forms/named-control-values.js.map +1 -0
- package/dist/forms/processor.d.ts +55 -0
- package/dist/forms/processor.js +154 -0
- package/dist/forms/processor.js.map +1 -0
- package/dist/forms/types.d.ts +174 -0
- package/dist/forms/types.js +33 -0
- package/dist/forms/types.js.map +1 -0
- package/dist/forms/validator.d.ts +61 -0
- package/dist/forms/validator.js +218 -0
- package/dist/forms/validator.js.map +1 -0
- package/dist/graph/index.d.ts +10 -0
- package/dist/graph/index.js +9 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/resolver.d.ts +66 -0
- package/dist/graph/resolver.js +243 -0
- package/dist/graph/resolver.js.map +1 -0
- package/dist/graph/types.d.ts +125 -0
- package/dist/graph/types.js +9 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/hooks/useInstalledAtoms.d.ts +96 -0
- package/dist/hooks/useInstalledAtoms.js +92 -0
- package/dist/hooks/useInstalledAtoms.js.map +1 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +14 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/translator.d.ts +76 -0
- package/dist/i18n/translator.js +357 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/i18n/types.d.ts +93 -0
- package/dist/i18n/types.js +9 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +47 -0
- package/dist/kernel.js +258 -0
- package/dist/kernel.js.map +1 -0
- package/dist/perf/budget.d.ts +92 -0
- package/dist/perf/budget.js +122 -0
- package/dist/perf/budget.js.map +1 -0
- package/dist/perf/index.d.ts +16 -0
- package/dist/perf/index.js +13 -0
- package/dist/perf/index.js.map +1 -0
- package/dist/perf/render-timer.d.ts +90 -0
- package/dist/perf/render-timer.js +136 -0
- package/dist/perf/render-timer.js.map +1 -0
- package/dist/perf/reporter.d.ts +126 -0
- package/dist/perf/reporter.js +241 -0
- package/dist/perf/reporter.js.map +1 -0
- package/dist/perf/web-vitals.d.ts +111 -0
- package/dist/perf/web-vitals.js +268 -0
- package/dist/perf/web-vitals.js.map +1 -0
- package/dist/registry.d.ts +63 -0
- package/dist/registry.js +126 -0
- package/dist/registry.js.map +1 -0
- package/dist/render/BehaviorSurfaceProvider.d.ts +65 -0
- package/dist/render/BehaviorSurfaceProvider.js +185 -0
- package/dist/render/BehaviorSurfaceProvider.js.map +1 -0
- package/dist/render/BlockErrorBoundary.d.ts +26 -0
- package/dist/render/BlockErrorBoundary.js +41 -0
- package/dist/render/BlockErrorBoundary.js.map +1 -0
- package/dist/render/DataBoundSurfaceRenderer.d.ts +78 -0
- package/dist/render/DataBoundSurfaceRenderer.js +998 -0
- package/dist/render/DataBoundSurfaceRenderer.js.map +1 -0
- package/dist/render/DynamicBlockWrapper.d.ts +23 -0
- package/dist/render/DynamicBlockWrapper.js +117 -0
- package/dist/render/DynamicBlockWrapper.js.map +1 -0
- package/dist/render/appearance-resolver.d.ts +50 -0
- package/dist/render/appearance-resolver.js +78 -0
- package/dist/render/appearance-resolver.js.map +1 -0
- package/dist/render/capability-gate.d.ts +69 -0
- package/dist/render/capability-gate.js +94 -0
- package/dist/render/capability-gate.js.map +1 -0
- package/dist/render/conditional-states-css.d.ts +41 -0
- package/dist/render/conditional-states-css.js +82 -0
- package/dist/render/conditional-states-css.js.map +1 -0
- package/dist/render/connections-context.d.ts +31 -0
- package/dist/render/connections-context.js +34 -0
- package/dist/render/connections-context.js.map +1 -0
- package/dist/render/dark-theme-css.d.ts +36 -0
- package/dist/render/dark-theme-css.js +67 -0
- package/dist/render/dark-theme-css.js.map +1 -0
- package/dist/render/data-binding-types.d.ts +191 -0
- package/dist/render/data-binding-types.js +11 -0
- package/dist/render/data-binding-types.js.map +1 -0
- package/dist/render/data-cache.d.ts +30 -0
- package/dist/render/data-cache.js +37 -0
- package/dist/render/data-cache.js.map +1 -0
- package/dist/render/derive-dark-theme.d.ts +17 -0
- package/dist/render/derive-dark-theme.js +18 -0
- package/dist/render/derive-dark-theme.js.map +1 -0
- package/dist/render/dynamic-artifact-context.d.ts +77 -0
- package/dist/render/dynamic-artifact-context.js +89 -0
- package/dist/render/dynamic-artifact-context.js.map +1 -0
- package/dist/render/dynamic-block-loader.d.ts +80 -0
- package/dist/render/dynamic-block-loader.js +197 -0
- package/dist/render/dynamic-block-loader.js.map +1 -0
- package/dist/render/endpoint.d.ts +18 -0
- package/dist/render/endpoint.js +109 -0
- package/dist/render/endpoint.js.map +1 -0
- package/dist/render/entity-facade-context.d.ts +34 -0
- package/dist/render/entity-facade-context.js +37 -0
- package/dist/render/entity-facade-context.js.map +1 -0
- package/dist/render/group-states-css.d.ts +41 -0
- package/dist/render/group-states-css.js +73 -0
- package/dist/render/group-states-css.js.map +1 -0
- package/dist/render/hooks/useSurfaceEvents.d.ts +8 -0
- package/dist/render/hooks/useSurfaceEvents.js +9 -0
- package/dist/render/hooks/useSurfaceEvents.js.map +1 -0
- package/dist/render/hooks/useSurfaceId.d.ts +8 -0
- package/dist/render/hooks/useSurfaceId.js +9 -0
- package/dist/render/hooks/useSurfaceId.js.map +1 -0
- package/dist/render/index.d.ts +48 -0
- package/dist/render/index.js +61 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/interaction-rule-engine.d.ts +12 -0
- package/dist/render/interaction-rule-engine.js +47 -0
- package/dist/render/interaction-rule-engine.js.map +1 -0
- package/dist/render/keyframes-css.d.ts +31 -0
- package/dist/render/keyframes-css.js +44 -0
- package/dist/render/keyframes-css.js.map +1 -0
- package/dist/render/query-state.d.ts +3 -0
- package/dist/render/query-state.js +70 -0
- package/dist/render/query-state.js.map +1 -0
- package/dist/render/renderer.d.ts +44 -0
- package/dist/render/renderer.js +937 -0
- package/dist/render/renderer.js.map +1 -0
- package/dist/render/resolve-expressions.d.ts +37 -0
- package/dist/render/resolve-expressions.js +309 -0
- package/dist/render/resolve-expressions.js.map +1 -0
- package/dist/render/responsive-style-css.d.ts +42 -0
- package/dist/render/responsive-style-css.js +123 -0
- package/dist/render/responsive-style-css.js.map +1 -0
- package/dist/render/responsive.d.ts +49 -0
- package/dist/render/responsive.js +99 -0
- package/dist/render/responsive.js.map +1 -0
- package/dist/render/scoped-css.d.ts +71 -0
- package/dist/render/scoped-css.js +102 -0
- package/dist/render/scoped-css.js.map +1 -0
- package/dist/render/shell-selection.d.ts +69 -0
- package/dist/render/shell-selection.js +117 -0
- package/dist/render/shell-selection.js.map +1 -0
- package/dist/render/states-css.d.ts +32 -0
- package/dist/render/states-css.js +63 -0
- package/dist/render/states-css.js.map +1 -0
- package/dist/render/surface-data-context.d.ts +18 -0
- package/dist/render/surface-data-context.js +21 -0
- package/dist/render/surface-data-context.js.map +1 -0
- package/dist/render/surface-event-bus.d.ts +19 -0
- package/dist/render/surface-event-bus.js +68 -0
- package/dist/render/surface-event-bus.js.map +1 -0
- package/dist/render/surface-event-context.d.ts +11 -0
- package/dist/render/surface-event-context.js +12 -0
- package/dist/render/surface-event-context.js.map +1 -0
- package/dist/render/surface-id-context.d.ts +8 -0
- package/dist/render/surface-id-context.js +9 -0
- package/dist/render/surface-id-context.js.map +1 -0
- package/dist/render/theme-utils.d.ts +14 -0
- package/dist/render/theme-utils.js +15 -0
- package/dist/render/theme-utils.js.map +1 -0
- package/dist/render/types.d.ts +282 -0
- package/dist/render/types.js +9 -0
- package/dist/render/types.js.map +1 -0
- package/dist/render/visibility-css.d.ts +42 -0
- package/dist/render/visibility-css.js +119 -0
- package/dist/render/visibility-css.js.map +1 -0
- package/dist/render/width-scope.d.ts +34 -0
- package/dist/render/width-scope.js +44 -0
- package/dist/render/width-scope.js.map +1 -0
- package/dist/render/write-only-sources.d.ts +33 -0
- package/dist/render/write-only-sources.js +99 -0
- package/dist/render/write-only-sources.js.map +1 -0
- package/dist/routing/index.d.ts +14 -0
- package/dist/routing/index.js +15 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/router.d.ts +42 -0
- package/dist/routing/router.js +218 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/routing/types.d.ts +124 -0
- package/dist/routing/types.js +9 -0
- package/dist/routing/types.js.map +1 -0
- package/dist/seo/generator.d.ts +39 -0
- package/dist/seo/generator.js +236 -0
- package/dist/seo/generator.js.map +1 -0
- package/dist/seo/index.d.ts +14 -0
- package/dist/seo/index.js +15 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/seo/types.d.ts +181 -0
- package/dist/seo/types.js +9 -0
- package/dist/seo/types.js.map +1 -0
- package/dist/state/index.d.ts +15 -0
- package/dist/state/index.js +16 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/manager.d.ts +33 -0
- package/dist/state/manager.js +81 -0
- package/dist/state/manager.js.map +1 -0
- package/dist/state/store.d.ts +40 -0
- package/dist/state/store.js +145 -0
- package/dist/state/store.js.map +1 -0
- package/dist/state/types.d.ts +107 -0
- package/dist/state/types.js +9 -0
- package/dist/state/types.js.map +1 -0
- package/dist/surface/expression.d.ts +65 -0
- package/dist/surface/expression.js +179 -0
- package/dist/surface/expression.js.map +1 -0
- package/dist/surface/index.d.ts +32 -0
- package/dist/surface/index.js +25 -0
- package/dist/surface/index.js.map +1 -0
- package/dist/surface/interpreter.d.ts +96 -0
- package/dist/surface/interpreter.js +231 -0
- package/dist/surface/interpreter.js.map +1 -0
- package/dist/surface/layout.d.ts +54 -0
- package/dist/surface/layout.js +288 -0
- package/dist/surface/layout.js.map +1 -0
- package/dist/surface/output.d.ts +90 -0
- package/dist/surface/output.js +104 -0
- package/dist/surface/output.js.map +1 -0
- package/dist/surface/primitives.d.ts +180 -0
- package/dist/surface/primitives.js +339 -0
- package/dist/surface/primitives.js.map +1 -0
- package/dist/surface/renderer.d.ts +96 -0
- package/dist/surface/renderer.js +190 -0
- package/dist/surface/renderer.js.map +1 -0
- package/dist/surface/schemas.d.ts +181 -0
- package/dist/surface/schemas.js +142 -0
- package/dist/surface/schemas.js.map +1 -0
- package/dist/surface/transforms.d.ts +144 -0
- package/dist/surface/transforms.js +120 -0
- package/dist/surface/transforms.js.map +1 -0
- package/dist/surface/types.d.ts +160 -0
- package/dist/surface/types.js +51 -0
- package/dist/surface/types.js.map +1 -0
- package/dist/surface/validation.d.ts +123 -0
- package/dist/surface/validation.js +147 -0
- package/dist/surface/validation.js.map +1 -0
- package/dist/validator.d.ts +55 -0
- package/dist/validator.js +100 -0
- package/dist/validator.js.map +1 -0
- package/package.json +106 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Component Types
|
|
3
|
+
*
|
|
4
|
+
* Minimal type definitions for block React components.
|
|
5
|
+
* These types are structurally compatible with @pwfabric/runtime's
|
|
6
|
+
* BlockComponent and BlockComponentRegistry types.
|
|
7
|
+
*
|
|
8
|
+
* @module @pwfabric/runtime/blocks/component-types
|
|
9
|
+
*/
|
|
10
|
+
import type { ReactNode } from 'react';
|
|
11
|
+
import type { Block } from '@pwfabric/contracts';
|
|
12
|
+
import type { BreakpointName } from '@pwfabric/core';
|
|
13
|
+
/**
|
|
14
|
+
* Surface event types emitted by block components
|
|
15
|
+
*/
|
|
16
|
+
export type BlockSurfaceEventType = 'click' | 'submit' | 'change' | 'navigate' | 'custom';
|
|
17
|
+
/**
|
|
18
|
+
* Surface event emitted by block components
|
|
19
|
+
*/
|
|
20
|
+
export interface BlockSurfaceEvent {
|
|
21
|
+
/** Event type */
|
|
22
|
+
readonly type: BlockSurfaceEventType;
|
|
23
|
+
/** Block ID that triggered the event */
|
|
24
|
+
readonly blockId: string;
|
|
25
|
+
/** Event payload */
|
|
26
|
+
readonly payload?: unknown;
|
|
27
|
+
/** Original DOM event (if applicable) */
|
|
28
|
+
readonly originalEvent?: Event;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Minimal block rendering context available to block components.
|
|
32
|
+
* Structurally compatible with @pwfabric/runtime's BlockContext.
|
|
33
|
+
*/
|
|
34
|
+
export interface BlockComponentContext {
|
|
35
|
+
/** Event handler for block events */
|
|
36
|
+
readonly onEvent?: ((event: BlockSurfaceEvent) => void) | undefined;
|
|
37
|
+
/** Current viewport breakpoint */
|
|
38
|
+
readonly viewport?: BreakpointName;
|
|
39
|
+
/** Image adapter (optional, runtime-provided) */
|
|
40
|
+
readonly imageAdapter?: unknown;
|
|
41
|
+
/** Capabilities (optional, runtime-provided) */
|
|
42
|
+
readonly capabilities?: Map<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Props passed to block components
|
|
46
|
+
*/
|
|
47
|
+
export interface BlockComponentProps<T = Record<string, unknown>> {
|
|
48
|
+
/** Block instance */
|
|
49
|
+
readonly block: Block;
|
|
50
|
+
/** Resolved props (validated and defaulted) */
|
|
51
|
+
readonly props: T;
|
|
52
|
+
/** Rendered children (for container blocks) */
|
|
53
|
+
readonly children?: ReactNode;
|
|
54
|
+
/** Block context */
|
|
55
|
+
readonly context: BlockComponentContext;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Block component type
|
|
59
|
+
*/
|
|
60
|
+
export type BlockComponent<T = Record<string, unknown>> = ((props: BlockComponentProps<T>) => ReactNode) & {
|
|
61
|
+
/**
|
|
62
|
+
* How the block wants to be sized when it sits in a flex ROW.
|
|
63
|
+
*
|
|
64
|
+
* The engine's default for a row child is an equal share (`flex: 1 1 0`) —
|
|
65
|
+
* right for two content columns, wrong for an avatar, a badge, a button: an
|
|
66
|
+
* intrinsic thing stretched to half a row is the single most measured layout
|
|
67
|
+
* defect of the 2026-09 surface audit (127 hand-written `flex: 0 0 auto`
|
|
68
|
+
* overrides across 14 receipts). A block whose natural width is its content
|
|
69
|
+
* declares `sizing: 'intrinsic'` — as a static on the component, the same
|
|
70
|
+
* way `displayName` travels — and the engine gives it `flex: 0 0 auto`.
|
|
71
|
+
* An authored flex hint on the instance still wins. The engine memorises no
|
|
72
|
+
* block names: the block declares, the engine obeys.
|
|
73
|
+
*/
|
|
74
|
+
sizing?: BlockSizing;
|
|
75
|
+
};
|
|
76
|
+
/** The only sizing word the engine knows besides its default (fluid share). */
|
|
77
|
+
export type BlockSizing = 'intrinsic';
|
|
78
|
+
/**
|
|
79
|
+
* Block component registry — maps block type strings to React component implementations
|
|
80
|
+
*/
|
|
81
|
+
export type BlockComponentRegistry = Record<string, BlockComponent>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block Component Types
|
|
3
|
+
*
|
|
4
|
+
* Minimal type definitions for block React components.
|
|
5
|
+
* These types are structurally compatible with @pwfabric/runtime's
|
|
6
|
+
* BlockComponent and BlockComponentRegistry types.
|
|
7
|
+
*
|
|
8
|
+
* @module @pwfabric/runtime/blocks/component-types
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=component-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-types.js","sourceRoot":"","sources":["../../src/blocks/component-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG","sourcesContent":["/**\n * Block Component Types\n *\n * Minimal type definitions for block React components.\n * These types are structurally compatible with @pwfabric/runtime's\n * BlockComponent and BlockComponentRegistry types.\n *\n * @module @pwfabric/runtime/blocks/component-types\n */\n\nimport type { ReactNode } from 'react'\nimport type { Block } from '@pwfabric/contracts'\nimport type { BreakpointName } from '@pwfabric/core'\n\n// ============================================================\n// SURFACE EVENTS (minimal subset used by block components)\n// ============================================================\n\n/**\n * Surface event types emitted by block components\n */\nexport type BlockSurfaceEventType = 'click' | 'submit' | 'change' | 'navigate' | 'custom'\n\n/**\n * Surface event emitted by block components\n */\nexport interface BlockSurfaceEvent {\n /** Event type */\n readonly type: BlockSurfaceEventType\n /** Block ID that triggered the event */\n readonly blockId: string\n /** Event payload */\n readonly payload?: unknown\n /** Original DOM event (if applicable) */\n readonly originalEvent?: Event\n}\n\n// ============================================================\n// BLOCK CONTEXT (minimal subset needed by block components)\n// ============================================================\n\n/**\n * Minimal block rendering context available to block components.\n * Structurally compatible with @pwfabric/runtime's BlockContext.\n */\nexport interface BlockComponentContext {\n /** Event handler for block events */\n readonly onEvent?: ((event: BlockSurfaceEvent) => void) | undefined\n /** Current viewport breakpoint */\n readonly viewport?: BreakpointName\n /** Image adapter (optional, runtime-provided) */\n readonly imageAdapter?: unknown\n /** Capabilities (optional, runtime-provided) */\n readonly capabilities?: Map<string, unknown>\n}\n\n// ============================================================\n// BLOCK COMPONENT TYPES\n// ============================================================\n\n/**\n * Props passed to block components\n */\nexport interface BlockComponentProps<T = Record<string, unknown>> {\n /** Block instance */\n readonly block: Block\n /** Resolved props (validated and defaulted) */\n readonly props: T\n /** Rendered children (for container blocks) */\n readonly children?: ReactNode\n /** Block context */\n readonly context: BlockComponentContext\n}\n\n/**\n * Block component type\n */\nexport type BlockComponent<T = Record<string, unknown>> = ((\n props: BlockComponentProps<T>\n) => ReactNode) & {\n /**\n * How the block wants to be sized when it sits in a flex ROW.\n *\n * The engine's default for a row child is an equal share (`flex: 1 1 0`) —\n * right for two content columns, wrong for an avatar, a badge, a button: an\n * intrinsic thing stretched to half a row is the single most measured layout\n * defect of the 2026-09 surface audit (127 hand-written `flex: 0 0 auto`\n * overrides across 14 receipts). A block whose natural width is its content\n * declares `sizing: 'intrinsic'` — as a static on the component, the same\n * way `displayName` travels — and the engine gives it `flex: 0 0 auto`.\n * An authored flex hint on the instance still wins. The engine memorises no\n * block names: the block declares, the engine obeys.\n */\n sizing?: BlockSizing\n}\n\n/** The only sizing word the engine knows besides its default (fluid share). */\nexport type BlockSizing = 'intrinsic'\n\n/**\n * Block component registry — maps block type strings to React component implementations\n */\nexport type BlockComponentRegistry = Record<string, BlockComponent>\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition Rules
|
|
3
|
+
*
|
|
4
|
+
* CP7: Rules defining valid block compositions
|
|
5
|
+
*
|
|
6
|
+
* @module @pwfabric/core/blocks/composition-rules
|
|
7
|
+
*/
|
|
8
|
+
import type { CompositionRule } from '@pwfabric/core';
|
|
9
|
+
/**
|
|
10
|
+
* Maximum nesting depth rule
|
|
11
|
+
*
|
|
12
|
+
* Prevents blocks from being nested too deeply.
|
|
13
|
+
*/
|
|
14
|
+
export declare const maxDepthRule: CompositionRule;
|
|
15
|
+
/**
|
|
16
|
+
* Form children rule
|
|
17
|
+
*
|
|
18
|
+
* Forms can contain all form input elements plus structural/content blocks.
|
|
19
|
+
*/
|
|
20
|
+
export declare const formChildrenRule: CompositionRule;
|
|
21
|
+
/**
|
|
22
|
+
* Grid children rule
|
|
23
|
+
*
|
|
24
|
+
* Grids cannot have nested grids as direct children.
|
|
25
|
+
*/
|
|
26
|
+
export declare const gridChildrenRule: CompositionRule;
|
|
27
|
+
/**
|
|
28
|
+
* Button no children rule
|
|
29
|
+
*
|
|
30
|
+
* Buttons cannot have children.
|
|
31
|
+
*/
|
|
32
|
+
export declare const buttonNoChildrenRule: CompositionRule;
|
|
33
|
+
/**
|
|
34
|
+
* Text no children rule
|
|
35
|
+
*
|
|
36
|
+
* Text blocks cannot have children.
|
|
37
|
+
*/
|
|
38
|
+
export declare const textNoChildrenRule: CompositionRule;
|
|
39
|
+
/**
|
|
40
|
+
* Heading no children rule
|
|
41
|
+
*
|
|
42
|
+
* Heading blocks cannot have children.
|
|
43
|
+
*/
|
|
44
|
+
export declare const headingNoChildrenRule: CompositionRule;
|
|
45
|
+
/**
|
|
46
|
+
* Image no children rule
|
|
47
|
+
*
|
|
48
|
+
* Image blocks cannot have children.
|
|
49
|
+
*/
|
|
50
|
+
export declare const imageNoChildrenRule: CompositionRule;
|
|
51
|
+
/**
|
|
52
|
+
* Input no children rule
|
|
53
|
+
*
|
|
54
|
+
* Input blocks cannot have children.
|
|
55
|
+
*/
|
|
56
|
+
export declare const inputNoChildrenRule: CompositionRule;
|
|
57
|
+
/**
|
|
58
|
+
* Input required parent rule
|
|
59
|
+
*
|
|
60
|
+
* Inputs should be inside forms or containers.
|
|
61
|
+
*/
|
|
62
|
+
export declare const inputParentRule: CompositionRule;
|
|
63
|
+
/**
|
|
64
|
+
* Link no children rule
|
|
65
|
+
*
|
|
66
|
+
* Link blocks cannot have children.
|
|
67
|
+
*/
|
|
68
|
+
export declare const linkNoChildrenRule: CompositionRule;
|
|
69
|
+
/**
|
|
70
|
+
* Icon no children rule
|
|
71
|
+
*
|
|
72
|
+
* Icon blocks cannot have children.
|
|
73
|
+
*/
|
|
74
|
+
export declare const iconNoChildrenRule: CompositionRule;
|
|
75
|
+
/**
|
|
76
|
+
* Badge no children rule
|
|
77
|
+
*
|
|
78
|
+
* Badge blocks cannot have children.
|
|
79
|
+
*/
|
|
80
|
+
export declare const badgeNoChildrenRule: CompositionRule;
|
|
81
|
+
/**
|
|
82
|
+
* Code no children rule
|
|
83
|
+
*
|
|
84
|
+
* Code blocks cannot have children.
|
|
85
|
+
*/
|
|
86
|
+
export declare const codeNoChildrenRule: CompositionRule;
|
|
87
|
+
/**
|
|
88
|
+
* Divider no children rule
|
|
89
|
+
*
|
|
90
|
+
* Divider blocks cannot have children.
|
|
91
|
+
*/
|
|
92
|
+
export declare const dividerNoChildrenRule: CompositionRule;
|
|
93
|
+
/**
|
|
94
|
+
* List no children rule
|
|
95
|
+
*
|
|
96
|
+
* List blocks cannot have children.
|
|
97
|
+
*/
|
|
98
|
+
export declare const listNoChildrenRule: CompositionRule;
|
|
99
|
+
/**
|
|
100
|
+
* Table no children rule
|
|
101
|
+
*
|
|
102
|
+
* Table blocks cannot have children.
|
|
103
|
+
*/
|
|
104
|
+
export declare const tableNoChildrenRule: CompositionRule;
|
|
105
|
+
/**
|
|
106
|
+
* Accordion no children rule
|
|
107
|
+
*
|
|
108
|
+
* Accordion items are defined via props, not children.
|
|
109
|
+
*/
|
|
110
|
+
export declare const accordionNoChildrenRule: CompositionRule;
|
|
111
|
+
/**
|
|
112
|
+
* Dropdown no children rule
|
|
113
|
+
*
|
|
114
|
+
* Dropdown items are defined via props, not children.
|
|
115
|
+
*/
|
|
116
|
+
export declare const dropdownNoChildrenRule: CompositionRule;
|
|
117
|
+
/**
|
|
118
|
+
* Avatar no children rule
|
|
119
|
+
*
|
|
120
|
+
* Avatar is a leaf block with no children.
|
|
121
|
+
*/
|
|
122
|
+
export declare const avatarNoChildrenRule: CompositionRule;
|
|
123
|
+
/**
|
|
124
|
+
* Tooltip children rule
|
|
125
|
+
*
|
|
126
|
+
* Tooltip can wrap specific inline/interactive blocks.
|
|
127
|
+
*/
|
|
128
|
+
export declare const tooltipChildrenRule: CompositionRule;
|
|
129
|
+
/**
|
|
130
|
+
* Tabs children rule
|
|
131
|
+
*
|
|
132
|
+
* Tabs can contain containers as tab panels.
|
|
133
|
+
*/
|
|
134
|
+
export declare const tabsChildrenRule: CompositionRule;
|
|
135
|
+
/**
|
|
136
|
+
* Modal children rule
|
|
137
|
+
*
|
|
138
|
+
* Modal can contain layout and content blocks.
|
|
139
|
+
*/
|
|
140
|
+
export declare const modalChildrenRule: CompositionRule;
|
|
141
|
+
/**
|
|
142
|
+
* No self nesting rule
|
|
143
|
+
*
|
|
144
|
+
* Blocks cannot be nested inside themselves.
|
|
145
|
+
*/
|
|
146
|
+
export declare const noSelfNestingRule: CompositionRule;
|
|
147
|
+
/**
|
|
148
|
+
* All composition rules
|
|
149
|
+
*/
|
|
150
|
+
export declare const compositionRules: readonly CompositionRule[];
|
|
151
|
+
/**
|
|
152
|
+
* Get rules that apply to a specific block type
|
|
153
|
+
*
|
|
154
|
+
* @param blockType - Block type to get rules for
|
|
155
|
+
* @returns Array of applicable rules
|
|
156
|
+
*/
|
|
157
|
+
export declare function getRulesForBlockType(blockType: string): readonly CompositionRule[];
|
|
158
|
+
/**
|
|
159
|
+
* Get rules by type
|
|
160
|
+
*
|
|
161
|
+
* @param ruleType - Rule type to filter by
|
|
162
|
+
* @returns Array of matching rules
|
|
163
|
+
*/
|
|
164
|
+
export declare function getRulesByType(ruleType: CompositionRule['type']): readonly CompositionRule[];
|
|
165
|
+
/** Allowed direct children of a tabs block */
|
|
166
|
+
export declare const TABS_ALLOWED_CHILDREN: Set<string>;
|
|
167
|
+
/** Allowed direct children of a form block */
|
|
168
|
+
export declare const FORM_ALLOWED_CHILDREN: Set<string>;
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition Rules
|
|
3
|
+
*
|
|
4
|
+
* CP7: Rules defining valid block compositions
|
|
5
|
+
*
|
|
6
|
+
* @module @pwfabric/core/blocks/composition-rules
|
|
7
|
+
*/
|
|
8
|
+
import { MAX_NESTING_DEPTH } from '@pwfabric/core';
|
|
9
|
+
// ============================================================
|
|
10
|
+
// BUILT-IN RULES
|
|
11
|
+
// ============================================================
|
|
12
|
+
/**
|
|
13
|
+
* Maximum nesting depth rule
|
|
14
|
+
*
|
|
15
|
+
* Prevents blocks from being nested too deeply.
|
|
16
|
+
*/
|
|
17
|
+
export const maxDepthRule = {
|
|
18
|
+
type: 'max_depth',
|
|
19
|
+
description: `Blocks cannot be nested more than ${MAX_NESTING_DEPTH} levels deep`,
|
|
20
|
+
appliesTo: '*',
|
|
21
|
+
config: {
|
|
22
|
+
maxDepth: MAX_NESTING_DEPTH,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Form children rule
|
|
27
|
+
*
|
|
28
|
+
* Forms can contain all form input elements plus structural/content blocks.
|
|
29
|
+
*/
|
|
30
|
+
export const formChildrenRule = {
|
|
31
|
+
type: 'allowed_children',
|
|
32
|
+
description: 'Forms can contain form input elements and structural/content blocks (text, heading, container, divider, button)',
|
|
33
|
+
appliesTo: 'form',
|
|
34
|
+
config: {
|
|
35
|
+
allowedChildren: [
|
|
36
|
+
// Form input elements — the form family of the first-party base pack as
|
|
37
|
+
// shipped, so every field a form pattern uses passes validation.
|
|
38
|
+
'input',
|
|
39
|
+
'textarea',
|
|
40
|
+
'select',
|
|
41
|
+
'checkbox',
|
|
42
|
+
'radio',
|
|
43
|
+
'toggle',
|
|
44
|
+
'slider',
|
|
45
|
+
'combobox',
|
|
46
|
+
'date-input',
|
|
47
|
+
'file-dropzone',
|
|
48
|
+
'number-stepper',
|
|
49
|
+
'otp-input',
|
|
50
|
+
'rich-text-editor',
|
|
51
|
+
'segmented-control',
|
|
52
|
+
'tag-input',
|
|
53
|
+
// legacy names kept so older documents keep validating
|
|
54
|
+
'switch',
|
|
55
|
+
'file-upload',
|
|
56
|
+
// Structural / content blocks valid inside forms
|
|
57
|
+
'button',
|
|
58
|
+
'text',
|
|
59
|
+
'heading',
|
|
60
|
+
'container',
|
|
61
|
+
'divider',
|
|
62
|
+
'badge',
|
|
63
|
+
'icon',
|
|
64
|
+
'link',
|
|
65
|
+
'alert',
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Grid children rule
|
|
71
|
+
*
|
|
72
|
+
* Grids cannot have nested grids as direct children.
|
|
73
|
+
*/
|
|
74
|
+
export const gridChildrenRule = {
|
|
75
|
+
type: 'allowed_children',
|
|
76
|
+
description: 'Grids cannot contain other grids as direct children',
|
|
77
|
+
appliesTo: 'grid',
|
|
78
|
+
config: {
|
|
79
|
+
disallowedChildren: ['grid'],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Button no children rule
|
|
84
|
+
*
|
|
85
|
+
* Buttons cannot have children.
|
|
86
|
+
*/
|
|
87
|
+
export const buttonNoChildrenRule = {
|
|
88
|
+
type: 'no_children',
|
|
89
|
+
description: 'Buttons cannot have children',
|
|
90
|
+
appliesTo: 'button',
|
|
91
|
+
config: {},
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Text no children rule
|
|
95
|
+
*
|
|
96
|
+
* Text blocks cannot have children.
|
|
97
|
+
*/
|
|
98
|
+
export const textNoChildrenRule = {
|
|
99
|
+
type: 'no_children',
|
|
100
|
+
description: 'Text blocks cannot have children',
|
|
101
|
+
appliesTo: 'text',
|
|
102
|
+
config: {},
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Heading no children rule
|
|
106
|
+
*
|
|
107
|
+
* Heading blocks cannot have children.
|
|
108
|
+
*/
|
|
109
|
+
export const headingNoChildrenRule = {
|
|
110
|
+
type: 'no_children',
|
|
111
|
+
description: 'Heading blocks cannot have children',
|
|
112
|
+
appliesTo: 'heading',
|
|
113
|
+
config: {},
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Image no children rule
|
|
117
|
+
*
|
|
118
|
+
* Image blocks cannot have children.
|
|
119
|
+
*/
|
|
120
|
+
export const imageNoChildrenRule = {
|
|
121
|
+
type: 'no_children',
|
|
122
|
+
description: 'Image blocks cannot have children',
|
|
123
|
+
appliesTo: 'image',
|
|
124
|
+
config: {},
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Input no children rule
|
|
128
|
+
*
|
|
129
|
+
* Input blocks cannot have children.
|
|
130
|
+
*/
|
|
131
|
+
export const inputNoChildrenRule = {
|
|
132
|
+
type: 'no_children',
|
|
133
|
+
description: 'Input blocks cannot have children',
|
|
134
|
+
appliesTo: 'input',
|
|
135
|
+
config: {},
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Input required parent rule
|
|
139
|
+
*
|
|
140
|
+
* Inputs should be inside forms or containers.
|
|
141
|
+
*/
|
|
142
|
+
export const inputParentRule = {
|
|
143
|
+
type: 'allowed_parents',
|
|
144
|
+
description: 'Inputs should be placed inside forms or containers',
|
|
145
|
+
appliesTo: 'input',
|
|
146
|
+
config: {
|
|
147
|
+
allowedParents: ['form', 'container'],
|
|
148
|
+
severity: 'warning',
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Link no children rule
|
|
153
|
+
*
|
|
154
|
+
* Link blocks cannot have children.
|
|
155
|
+
*/
|
|
156
|
+
export const linkNoChildrenRule = {
|
|
157
|
+
type: 'no_children',
|
|
158
|
+
description: 'Link blocks cannot have children',
|
|
159
|
+
appliesTo: 'link',
|
|
160
|
+
config: {},
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Icon no children rule
|
|
164
|
+
*
|
|
165
|
+
* Icon blocks cannot have children.
|
|
166
|
+
*/
|
|
167
|
+
export const iconNoChildrenRule = {
|
|
168
|
+
type: 'no_children',
|
|
169
|
+
description: 'Icon blocks cannot have children',
|
|
170
|
+
appliesTo: 'icon',
|
|
171
|
+
config: {},
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Badge no children rule
|
|
175
|
+
*
|
|
176
|
+
* Badge blocks cannot have children.
|
|
177
|
+
*/
|
|
178
|
+
export const badgeNoChildrenRule = {
|
|
179
|
+
type: 'no_children',
|
|
180
|
+
description: 'Badge blocks cannot have children',
|
|
181
|
+
appliesTo: 'badge',
|
|
182
|
+
config: {},
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Code no children rule
|
|
186
|
+
*
|
|
187
|
+
* Code blocks cannot have children.
|
|
188
|
+
*/
|
|
189
|
+
export const codeNoChildrenRule = {
|
|
190
|
+
type: 'no_children',
|
|
191
|
+
description: 'Code blocks cannot have children',
|
|
192
|
+
appliesTo: 'code',
|
|
193
|
+
config: {},
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Divider no children rule
|
|
197
|
+
*
|
|
198
|
+
* Divider blocks cannot have children.
|
|
199
|
+
*/
|
|
200
|
+
export const dividerNoChildrenRule = {
|
|
201
|
+
type: 'no_children',
|
|
202
|
+
description: 'Divider blocks cannot have children',
|
|
203
|
+
appliesTo: 'divider',
|
|
204
|
+
config: {},
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* List no children rule
|
|
208
|
+
*
|
|
209
|
+
* List blocks cannot have children.
|
|
210
|
+
*/
|
|
211
|
+
export const listNoChildrenRule = {
|
|
212
|
+
type: 'no_children',
|
|
213
|
+
description: 'List blocks cannot have children',
|
|
214
|
+
appliesTo: 'list',
|
|
215
|
+
config: {},
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Table no children rule
|
|
219
|
+
*
|
|
220
|
+
* Table blocks cannot have children.
|
|
221
|
+
*/
|
|
222
|
+
export const tableNoChildrenRule = {
|
|
223
|
+
type: 'no_children',
|
|
224
|
+
description: 'Table blocks cannot have children',
|
|
225
|
+
appliesTo: 'table',
|
|
226
|
+
config: {},
|
|
227
|
+
};
|
|
228
|
+
// ============================================================
|
|
229
|
+
// INTERACTIVE BLOCK RULES
|
|
230
|
+
// ============================================================
|
|
231
|
+
/**
|
|
232
|
+
* Accordion no children rule
|
|
233
|
+
*
|
|
234
|
+
* Accordion items are defined via props, not children.
|
|
235
|
+
*/
|
|
236
|
+
export const accordionNoChildrenRule = {
|
|
237
|
+
type: 'no_children',
|
|
238
|
+
description: 'Accordion items are defined via props, not as children blocks',
|
|
239
|
+
appliesTo: 'accordion',
|
|
240
|
+
config: {},
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Dropdown no children rule
|
|
244
|
+
*
|
|
245
|
+
* Dropdown items are defined via props, not children.
|
|
246
|
+
*/
|
|
247
|
+
export const dropdownNoChildrenRule = {
|
|
248
|
+
type: 'no_children',
|
|
249
|
+
description: 'Dropdown items are defined via props, not as children blocks',
|
|
250
|
+
appliesTo: 'dropdown',
|
|
251
|
+
config: {},
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Avatar no children rule
|
|
255
|
+
*
|
|
256
|
+
* Avatar is a leaf block with no children.
|
|
257
|
+
*/
|
|
258
|
+
export const avatarNoChildrenRule = {
|
|
259
|
+
type: 'no_children',
|
|
260
|
+
description: 'Avatar blocks cannot have children',
|
|
261
|
+
appliesTo: 'avatar',
|
|
262
|
+
config: {},
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Tooltip children rule
|
|
266
|
+
*
|
|
267
|
+
* Tooltip can wrap specific inline/interactive blocks.
|
|
268
|
+
*/
|
|
269
|
+
export const tooltipChildrenRule = {
|
|
270
|
+
type: 'allowed_children',
|
|
271
|
+
description: 'Tooltips can only wrap text, buttons, icons, badges, and links',
|
|
272
|
+
appliesTo: 'tooltip',
|
|
273
|
+
config: {
|
|
274
|
+
allowedChildren: ['text', 'button', 'icon', 'badge', 'link'],
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Tabs children rule
|
|
279
|
+
*
|
|
280
|
+
* Tabs can contain containers as tab panels.
|
|
281
|
+
*/
|
|
282
|
+
export const tabsChildrenRule = {
|
|
283
|
+
type: 'allowed_children',
|
|
284
|
+
description: 'Tabs can only contain containers as tab panel content',
|
|
285
|
+
appliesTo: 'tabs',
|
|
286
|
+
config: {
|
|
287
|
+
allowedChildren: ['container'],
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Modal children rule
|
|
292
|
+
*
|
|
293
|
+
* Modal can contain layout and content blocks.
|
|
294
|
+
*/
|
|
295
|
+
export const modalChildrenRule = {
|
|
296
|
+
type: 'allowed_children',
|
|
297
|
+
description: 'Modals can contain layout and content blocks',
|
|
298
|
+
appliesTo: 'modal',
|
|
299
|
+
config: {
|
|
300
|
+
allowedChildren: [
|
|
301
|
+
'container',
|
|
302
|
+
'grid',
|
|
303
|
+
'text',
|
|
304
|
+
'heading',
|
|
305
|
+
'button',
|
|
306
|
+
'image',
|
|
307
|
+
'form',
|
|
308
|
+
'input',
|
|
309
|
+
'list',
|
|
310
|
+
'table',
|
|
311
|
+
'divider',
|
|
312
|
+
'icon',
|
|
313
|
+
'badge',
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* No self nesting rule
|
|
319
|
+
*
|
|
320
|
+
* Blocks cannot be nested inside themselves.
|
|
321
|
+
*/
|
|
322
|
+
export const noSelfNestingRule = {
|
|
323
|
+
type: 'no_self_nesting',
|
|
324
|
+
description: 'Blocks cannot be nested inside themselves',
|
|
325
|
+
appliesTo: '*',
|
|
326
|
+
config: {},
|
|
327
|
+
};
|
|
328
|
+
// ============================================================
|
|
329
|
+
// ALL RULES
|
|
330
|
+
// ============================================================
|
|
331
|
+
/**
|
|
332
|
+
* All composition rules
|
|
333
|
+
*/
|
|
334
|
+
export const compositionRules = [
|
|
335
|
+
maxDepthRule,
|
|
336
|
+
formChildrenRule,
|
|
337
|
+
gridChildrenRule,
|
|
338
|
+
// Content blocks - no children
|
|
339
|
+
buttonNoChildrenRule,
|
|
340
|
+
textNoChildrenRule,
|
|
341
|
+
headingNoChildrenRule,
|
|
342
|
+
linkNoChildrenRule,
|
|
343
|
+
iconNoChildrenRule,
|
|
344
|
+
badgeNoChildrenRule,
|
|
345
|
+
codeNoChildrenRule,
|
|
346
|
+
dividerNoChildrenRule,
|
|
347
|
+
// Layout blocks - no children (leaf)
|
|
348
|
+
listNoChildrenRule,
|
|
349
|
+
tableNoChildrenRule,
|
|
350
|
+
// Media blocks - no children
|
|
351
|
+
imageNoChildrenRule,
|
|
352
|
+
// Form blocks - no children
|
|
353
|
+
inputNoChildrenRule,
|
|
354
|
+
inputParentRule,
|
|
355
|
+
// Interactive blocks
|
|
356
|
+
accordionNoChildrenRule,
|
|
357
|
+
dropdownNoChildrenRule,
|
|
358
|
+
avatarNoChildrenRule,
|
|
359
|
+
tooltipChildrenRule,
|
|
360
|
+
tabsChildrenRule,
|
|
361
|
+
modalChildrenRule,
|
|
362
|
+
// Universal rules
|
|
363
|
+
noSelfNestingRule,
|
|
364
|
+
];
|
|
365
|
+
/**
|
|
366
|
+
* Get rules that apply to a specific block type
|
|
367
|
+
*
|
|
368
|
+
* @param blockType - Block type to get rules for
|
|
369
|
+
* @returns Array of applicable rules
|
|
370
|
+
*/
|
|
371
|
+
export function getRulesForBlockType(blockType) {
|
|
372
|
+
return compositionRules.filter((rule) => rule.appliesTo === '*' || rule.appliesTo === blockType);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get rules by type
|
|
376
|
+
*
|
|
377
|
+
* @param ruleType - Rule type to filter by
|
|
378
|
+
* @returns Array of matching rules
|
|
379
|
+
*/
|
|
380
|
+
export function getRulesByType(ruleType) {
|
|
381
|
+
return compositionRules.filter((rule) => rule.type === ruleType);
|
|
382
|
+
}
|
|
383
|
+
// ============================================================
|
|
384
|
+
// CANONICAL CHILD SETS (single source of truth)
|
|
385
|
+
// Import these in API validator instead of redeclaring.
|
|
386
|
+
// ============================================================
|
|
387
|
+
/** Allowed direct children of a tabs block */
|
|
388
|
+
export const TABS_ALLOWED_CHILDREN = new Set(tabsChildrenRule.config.allowedChildren);
|
|
389
|
+
/** Allowed direct children of a form block */
|
|
390
|
+
export const FORM_ALLOWED_CHILDREN = new Set(formChildrenRule.config.allowedChildren);
|
|
391
|
+
//# sourceMappingURL=composition-rules.js.map
|