@homepages/concrete 8.0.0 → 9.1.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/CHANGELOG.md +1005 -0
- package/README.md +20 -9
- package/codemods/list-grammar.mjs +923 -0
- package/codemods/manifest.json +64 -0
- package/codemods/process-builders.mjs +198 -0
- package/codemods/slot-object.mjs +1097 -0
- package/codemods/steps/content-object-fields.mjs +324 -0
- package/codemods/steps/list-object-form.mjs +6 -7
- package/codemods/table-rows.mjs +568 -0
- package/codemods/unwrap-object-fields.mjs +310 -0
- package/codemods/viewer-slot-document.mjs +131 -0
- package/codemods/write-property-as-facts-document.mjs +716 -0
- package/codemods/write-the-address-line.mjs +255 -0
- package/codemods/write-the-registry-members.mjs +653 -0
- package/codemods/write-the-select-from.mjs +141 -0
- package/codemods/write-the-sole-from.mjs +369 -0
- package/codemods/write-the-table-from.mjs +267 -0
- package/codemods/write-the-whole-item.mjs +512 -0
- package/codemods/writeback-drop.mjs +168 -0
- package/codemods/written-contact-address.mjs +162 -0
- package/codemods/written-media-category.mjs +227 -0
- package/codemods/written-ref-kinds-name-the-layer.mjs +172 -0
- package/codemods/written-uploads-replace-pool-reads.mjs +454 -0
- package/codemods/written-uploads-sort-into-lists.mjs +405 -0
- package/codemods/written-uploads-stated-in-sorted-lists.mjs +295 -0
- package/codemods/written-video-sources-drop.mjs +144 -0
- package/codemods/written-without-pick-none.mjs +146 -0
- package/codemods/written-without-retired-knowledge.mjs +223 -0
- package/codemods/written-without-the-media-key.mjs +202 -0
- package/codemods/written-without-the-property-type.mjs +249 -0
- package/dist/artifact/playground/client/assets/index-BOYbgBnP.js +1259 -0
- package/dist/artifact/playground/client/assets/index-DDOcM0zA.css +1 -0
- package/dist/artifact/playground/client/index.html +2 -2
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -1
- package/dist/artifact/playground/host.mjs +61 -27
- package/dist/base.css +58 -1
- package/dist/cli/build/artifact.js +6 -9
- package/dist/cli/build/captures.js +2 -12
- package/dist/cli/build/esbuild.js +1 -25
- package/dist/cli/build/fixtures.js +2 -1
- package/dist/cli/build/icons.js +1 -1
- package/dist/cli/build/static.js +2 -2
- package/dist/cli/capture/capture.js +8 -9
- package/dist/cli/check/analyze.js +8 -1
- package/dist/cli/check/load-outdir.js +47 -0
- package/dist/cli/check/load-workspace.js +4 -4
- package/dist/cli/check/render/html.js +1 -2
- package/dist/cli/check/render/inputs.js +10 -3
- package/dist/cli/check/render/island-frames.js +2 -1
- package/dist/cli/check/render/marker-coverage.js +23 -15
- package/dist/cli/check/report.js +5 -0
- package/dist/cli/check/stages/bundles.js +1 -1
- package/dist/cli/check/stages/relations.js +1 -1
- package/dist/cli/check/stages/render.js +48 -33
- package/dist/cli/check/stages/sections.js +83 -31
- package/dist/cli/check/stages/workspace.js +2 -0
- package/dist/cli/check/template-key.js +16 -0
- package/dist/cli/commands.js +1 -1
- package/dist/cli/dev/crop.js +1 -1
- package/dist/cli/dev/fixture-ladders.js +96 -0
- package/dist/cli/dev/islands.js +12 -123
- package/dist/cli/dev/listen.js +20 -1
- package/dist/cli/dev/load-template.js +1 -1
- package/dist/cli/dev/server.js +35 -10
- package/dist/cli/dev/vite.js +9 -7
- package/dist/cli/dev/workspace-reader.js +16 -16
- package/dist/cli/media/derive.js +43 -57
- package/dist/cli/media/frame-rung-floor.js +0 -1
- package/dist/cli/property/index.js +1 -6
- package/dist/css/inline.js +1 -22
- package/dist/eslint/rules/no-marker-literal.js +1 -1
- package/dist/fixtures/load.js +16 -7
- package/dist/fixtures/media-plugin.js +17 -12
- package/dist/fixtures/media-store.js +115 -0
- package/dist/fixtures/property.js +345 -126
- package/dist/fixtures/resolve.js +260 -251
- package/dist/fixtures/rows.js +4 -11
- package/dist/fixtures.d.ts +234 -109
- package/dist/index.d.ts +25 -16
- package/dist/index.js +10 -6
- package/dist/islands/marker.js +2 -1
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/canvas-core/dist/island-host.js +62 -0
- package/dist/packages/internal/canvas-core/dist/island-shields.js +30 -0
- package/dist/packages/internal/capture-settle/dist/index.js +3 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.d.ts +13 -0
- package/dist/packages/internal/capture-settle/dist/island-markers.js +6 -0
- package/dist/packages/internal/capture-settle/dist/settle.js +150 -0
- package/dist/packages/internal/{image-ladder/dist/crop.js → crop-region/dist/index.js} +21 -20
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +250 -46
- package/dist/packages/internal/fill-bake/dist/compute-reads.js +361 -4
- package/dist/packages/internal/fill-bake/dist/derive-source.js +25 -18
- package/dist/packages/internal/fill-bake/dist/index.js +9 -3
- package/dist/packages/internal/fill-bake/dist/item-merge.js +113 -0
- package/dist/packages/internal/fill-bake/dist/item-overrides.js +1 -0
- package/dist/packages/internal/fill-bake/dist/linked-merge.js +38 -0
- package/dist/packages/internal/fill-bake/dist/list-grammar.js +174 -0
- package/dist/packages/internal/fill-bake/dist/stored-row-reader.js +1 -0
- package/dist/packages/internal/fill-vocabulary/dist/holder.js +51 -0
- package/dist/packages/internal/fill-vocabulary/dist/resolved-decision.js +363 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +1 -23
- package/dist/packages/internal/fill-vocabulary/dist/verbs.js +60 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +11 -147
- package/dist/packages/internal/format-geometry/dist/format.d.ts +8 -2
- package/dist/packages/internal/format-geometry/dist/geometry.js +13 -2
- package/dist/packages/internal/image-ladder/dist/encode.js +27 -14
- package/dist/packages/internal/image-ladder/dist/index.js +3 -3
- package/dist/packages/internal/image-ladder/dist/policy.js +28 -53
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +1 -1
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +3 -12
- package/dist/packages/internal/island-runtime/dist/contract.js +2 -2
- package/dist/packages/internal/island-runtime/dist/index.d.ts +3 -7
- package/dist/packages/internal/island-runtime/dist/index.js +2 -1
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +1 -1
- package/dist/packages/internal/media-resolution/dist/crop-key.js +7 -0
- package/dist/packages/internal/media-resolution/dist/document.js +63 -0
- package/dist/packages/internal/media-resolution/dist/image.js +226 -0
- package/dist/packages/internal/media-resolution/dist/index.js +11 -0
- package/dist/packages/internal/media-resolution/dist/list.js +112 -0
- package/dist/packages/internal/media-resolution/dist/media.js +59 -0
- package/dist/packages/internal/media-resolution/dist/records.js +7 -0
- package/dist/packages/internal/media-resolution/dist/slot.js +37 -0
- package/dist/packages/internal/media-resolution/dist/store.js +19 -0
- package/dist/packages/internal/media-resolution/dist/tour.js +59 -0
- package/dist/packages/internal/media-resolution/dist/video.js +93 -0
- package/dist/packages/internal/property-facts/dist/registry-facts.js +245 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +8 -17
- package/dist/packages/internal/section-contracts/dist/catalog.js +34 -14
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/directly-linked-list-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/fill-options.js +12 -0
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +1 -5
- package/dist/packages/internal/section-contracts/dist/fill-verb-contract.js +95 -0
- package/dist/packages/internal/section-contracts/dist/grammar-scope.js +154 -0
- package/dist/packages/internal/section-contracts/dist/index.js +7 -2
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +2 -36
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +12 -21
- package/dist/packages/internal/section-contracts/dist/list-source-contract.js +46 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +11 -2
- package/dist/packages/internal/section-contracts/dist/object-contract.js +92 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +9 -5
- package/dist/packages/internal/section-contracts/dist/reads-acyclic-contract.js +63 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +6 -17
- package/dist/packages/internal/section-contracts/dist/row-rule-contract.js +80 -0
- package/dist/packages/internal/section-contracts/dist/row-source-contract.js +67 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +77 -18
- package/dist/packages/internal/section-contracts/dist/select-contract.js +0 -8
- package/dist/packages/internal/section-contracts/dist/source-contract.js +89 -95
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +47 -17
- package/dist/packages/internal/section-contracts/dist/table-member.js +16 -0
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +39 -23
- package/dist/packages/internal/source-resolution/dist/index.js +113 -73
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -0
- package/dist/packages/internal/street-address/dist/index.js +72 -0
- package/dist/packages/internal/template-artifact/dist/asset-mime.js +30 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +1 -2
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +12 -29
- package/dist/packages/internal/template-contracts/dist/address-value.d.ts +52 -0
- package/dist/packages/internal/template-contracts/dist/address-value.js +90 -0
- package/dist/packages/internal/template-contracts/dist/comparable-address.js +19 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.d.ts +29 -6
- package/dist/{schema → packages/internal/template-contracts/dist}/compute.js +11 -13
- package/dist/packages/internal/template-contracts/dist/content-pick.js +51 -0
- package/dist/packages/internal/template-contracts/dist/decision-fills.js +81 -0
- package/dist/packages/internal/template-contracts/dist/display-overrides.js +7 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +16 -5
- package/dist/packages/internal/template-contracts/dist/fact-compute.d.ts +24 -0
- package/dist/packages/internal/template-contracts/dist/fact-compute.js +30 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.d.ts +44 -0
- package/dist/packages/internal/template-contracts/dist/fact-keys.js +88 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.d.ts +290 -0
- package/dist/packages/internal/template-contracts/dist/fact-registry.js +598 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +10 -24
- package/dist/packages/internal/template-contracts/dist/fill-builders.d.ts +157 -0
- package/dist/packages/internal/template-contracts/dist/fill-builders.js +79 -0
- package/dist/packages/internal/template-contracts/dist/fill-declaration.d.ts +14 -0
- package/dist/{schema → packages/internal/template-contracts/dist}/fill-declaration.js +6 -5
- package/dist/packages/internal/template-contracts/dist/fill-spec-schema.js +93 -0
- package/dist/packages/internal/template-contracts/dist/fill-spec.js +291 -0
- package/dist/packages/internal/template-contracts/dist/findable.js +8 -0
- package/dist/packages/internal/template-contracts/dist/floor-presets.js +13 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.d.ts +5 -0
- package/dist/packages/internal/template-contracts/dist/icon-names.js +70 -0
- package/dist/packages/internal/template-contracts/dist/legacy-facts.js +167 -0
- package/dist/packages/internal/template-contracts/dist/list-editing.js +93 -0
- package/dist/packages/internal/template-contracts/dist/list.d.ts +215 -0
- package/dist/packages/internal/template-contracts/dist/list.js +258 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +2 -2
- package/dist/packages/internal/template-contracts/dist/media-candidates.js +38 -0
- package/dist/packages/internal/template-contracts/dist/mirror-kind.js +48 -0
- package/dist/packages/internal/template-contracts/dist/number-display.js +10 -0
- package/dist/packages/internal/template-contracts/dist/object.d.ts +89 -0
- package/dist/packages/internal/template-contracts/dist/object.js +131 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.d.ts +1 -0
- package/dist/packages/internal/template-contracts/dist/primitive-descriptors.js +162 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.d.ts +77 -0
- package/dist/packages/internal/template-contracts/dist/process-builders.js +73 -0
- package/dist/packages/internal/template-contracts/dist/read-graph.js +240 -0
- package/dist/packages/internal/template-contracts/dist/ref-locate.js +176 -0
- package/dist/packages/internal/template-contracts/dist/registry-aliases.js +77 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.d.ts +270 -0
- package/dist/packages/internal/template-contracts/dist/registry-facts.js +202 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.d.ts +41 -0
- package/dist/packages/internal/template-contracts/dist/registry-shape.js +135 -0
- package/dist/packages/internal/template-contracts/dist/resolve-scope.js +103 -0
- package/dist/packages/internal/{image-descriptor/dist/index.d.ts → template-contracts/dist/responsive-image.d.ts} +1 -1
- package/dist/packages/internal/template-contracts/dist/row-planners.js +29 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.d.ts +127 -0
- package/dist/packages/internal/template-contracts/dist/row-ref.js +101 -0
- package/dist/packages/internal/template-contracts/dist/row-sources.js +41 -5
- package/dist/packages/internal/template-contracts/dist/row.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/row.js +84 -0
- package/dist/packages/internal/template-contracts/dist/runtime-values.d.ts +97 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.d.ts +782 -0
- package/dist/packages/internal/template-contracts/dist/slot-builders.js +233 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +233 -405
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +331 -227
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +21 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.d.ts +155 -0
- package/dist/packages/internal/template-contracts/dist/slot-ref.js +76 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.d.ts +163 -0
- package/dist/packages/internal/template-contracts/dist/slot-types.js +139 -0
- package/dist/packages/internal/template-contracts/dist/slot-value.d.ts +95 -0
- package/dist/packages/internal/template-contracts/dist/table-members.d.ts +25 -0
- package/dist/packages/internal/template-contracts/dist/table-members.js +90 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +5 -5
- package/dist/packages/internal/template-contracts/dist/value-contracts.js +15 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +2 -2
- package/dist/platform/fs.js +5 -2
- package/dist/playground/canvas-island-host.d.ts +11 -0
- package/dist/playground/canvas-island-host.js +29 -0
- package/dist/playground/canvas-markers.js +14 -0
- package/dist/playground-island-runtime.d.ts +3 -2
- package/dist/playground-island-runtime.js +3 -2
- package/dist/primitives/FrameShell.js +0 -1
- package/dist/primitives/Image.d.ts +5 -4
- package/dist/primitives/Tour.d.ts +1 -1
- package/dist/primitives/Video.d.ts +2 -2
- package/dist/primitives/index.d.ts +2 -3
- package/dist/primitives/picture-sources.js +2 -2
- package/dist/primitives/probe-context.js +2 -12
- package/dist/primitives/slot-address.d.ts +44 -0
- package/dist/primitives/slot-address.js +19 -0
- package/dist/primitives/slot-bindings.d.ts +65 -26
- package/dist/primitives/slot-bindings.js +104 -46
- package/dist/primitives/slot-document.d.ts +23 -18
- package/dist/primitives/slot-document.js +39 -14
- package/dist/primitives/slot-download.d.ts +39 -0
- package/dist/primitives/slot-download.js +39 -0
- package/dist/primitives/slot-list.d.ts +3 -3
- package/dist/primitives/slot-list.js +0 -2
- package/dist/primitives/slot-media.d.ts +24 -5
- package/dist/primitives/slot-media.js +6 -9
- package/dist/primitives/slot-object.d.ts +49 -0
- package/dist/primitives/slot-object.js +20 -0
- package/dist/primitives/slot-scalar.d.ts +27 -2
- package/dist/primitives/slot-scalar.js +50 -7
- package/dist/primitives/slot.d.ts +13 -6
- package/dist/primitives/slot.js +10 -3
- package/dist/rules/registry.js +25 -30
- package/dist/schema/define-schema.d.ts +4 -8
- package/dist/schema/define-schema.js +178 -79
- package/dist/schema/extract-fill-spec.js +2 -153
- package/dist/schema/fact.d.ts +57 -15
- package/dist/schema/fact.js +42 -7
- package/dist/schema/facts-view.d.ts +14 -0
- package/dist/schema/format.d.ts +1 -0
- package/dist/schema/format.js +2 -1
- package/dist/schema/manifest.js +24 -0
- package/dist/schema/property-facts.d.ts +8 -12
- package/dist/schema/section-props.d.ts +2 -66
- package/dist/schema/section-schema.d.ts +8 -11
- package/dist/schema/section-schema.js +27 -10
- package/dist/section/declare.d.ts +18 -7
- package/dist/section/declare.js +18 -5
- package/dist/section/materialize.js +3 -8
- package/dist/section/section.d.ts +12 -8
- package/dist/section/section.js +1 -1
- package/dist/template/logic-shim.d.ts +14 -7
- package/dist/template/logic-shim.js +14 -7
- package/dist/template/materialize.js +17 -18
- package/dist/template/mirror-types.js +30 -31
- package/dist/template/section-reads.js +85 -9
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +2 -2
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +29 -25
- package/package.json +9 -8
- package/dist/artifact/playground/client/assets/index-CckS2ONm.css +0 -1
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +0 -1101
- package/dist/fixtures/canonical.d.ts +0 -166
- package/dist/fixtures/media.js +0 -163
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +0 -51
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +0 -15
- package/dist/packages/internal/format-geometry/dist/index.js +0 -4
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +0 -10
- package/dist/packages/internal/property-facts/dist/index.js +0 -3
- package/dist/packages/internal/property-facts/dist/property-facts-Cy7-O4p0.js +0 -189
- package/dist/packages/internal/section-contracts/dist/group-contract.js +0 -19
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +0 -24
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +0 -22
- package/dist/packages/internal/template-contracts/dist/facts-view.js +0 -104
- package/dist/packages/internal/template-contracts/dist/select-key.js +0 -7
- package/dist/primitives/slot-group.d.ts +0 -40
- package/dist/primitives/slot-group.js +0 -36
- package/dist/schema/extract-used-facts.js +0 -34
- package/dist/schema/fill-builders.d.ts +0 -115
- package/dist/schema/fill-builders.js +0 -25
- package/dist/schema/fill-declaration.d.ts +0 -14
- package/dist/schema/fill-spec.js +0 -98
- package/dist/schema/layout.d.ts +0 -30
- package/dist/schema/layout.js +0 -14
- package/dist/schema/row-fields.js +0 -88
- package/dist/schema/row-ref.d.ts +0 -59
- package/dist/schema/row-ref.js +0 -28
- package/dist/schema/runtime-values.d.ts +0 -71
- package/dist/schema/section-nav.js +0 -14
- package/dist/schema/slot-builders.d.ts +0 -633
- package/dist/schema/slot-builders.js +0 -177
- package/dist/schema/slot-ref.d.ts +0 -79
- package/dist/schema/slot-ref.js +0 -41
- package/dist/schema/slot-types.d.ts +0 -111
- package/dist/schema/slot-types.js +0 -214
- package/dist/section/groups.js +0 -68
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeAddressValue } from "../packages/internal/template-contracts/dist/address-value.js";
|
|
2
|
+
import { OBJECT_BINDING_OWN_KEYS, acceptsLink, declaredKinds, isEmailValue, isIsoDateValue, isPhoneValue } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
3
|
|
|
3
4
|
//#region src/primitives/slot-bindings.ts
|
|
4
5
|
const blankVideo = () => ({
|
|
@@ -13,12 +14,6 @@ const blankTour = () => ({
|
|
|
13
14
|
poster: "",
|
|
14
15
|
alt: ""
|
|
15
16
|
});
|
|
16
|
-
function admitsLinkVideo(sources) {
|
|
17
|
-
return Array.isArray(sources) && sources.includes("link");
|
|
18
|
-
}
|
|
19
|
-
function isLinkVideo(value) {
|
|
20
|
-
return typeof value === "object" && value !== null && value.source === "link";
|
|
21
|
-
}
|
|
22
17
|
function isRecord(value) {
|
|
23
18
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
19
|
}
|
|
@@ -47,10 +42,13 @@ function normalizeImage(value) {
|
|
|
47
42
|
return isRecord(value) && typeof value.url === "string" && value.url !== "" ? value : null;
|
|
48
43
|
}
|
|
49
44
|
function normalizeDocument(value) {
|
|
50
|
-
|
|
45
|
+
if (!isRecord(value) || typeof value.url !== "string" || value.url === "") return null;
|
|
46
|
+
return typeof value.poster === "string" ? value : {
|
|
47
|
+
...value,
|
|
48
|
+
poster: ""
|
|
49
|
+
};
|
|
51
50
|
}
|
|
52
|
-
function normalizeVideo(
|
|
53
|
-
if (!admitsLinkVideo(slot.sources) && isLinkVideo(value)) return blankVideo();
|
|
51
|
+
function normalizeVideo(value) {
|
|
54
52
|
if (!isRecord(value)) return blankVideo();
|
|
55
53
|
return {
|
|
56
54
|
...value,
|
|
@@ -70,15 +68,44 @@ function normalizeTour(value) {
|
|
|
70
68
|
alt: stringField(value.alt)
|
|
71
69
|
};
|
|
72
70
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
function normalizeMedia(slot, value) {
|
|
72
|
+
if (!isRecord(value) || typeof value.kind !== "string" || !declaredKinds({
|
|
73
|
+
type: "media",
|
|
74
|
+
kinds: slot.kinds
|
|
75
|
+
}).some((kind) => kind === value.kind)) return null;
|
|
76
|
+
switch (value.kind) {
|
|
77
|
+
case "image":
|
|
78
|
+
case "document": {
|
|
79
|
+
const normalized = value.kind === "image" ? normalizeImage(value) : normalizeDocument(value);
|
|
80
|
+
return normalized === null ? null : {
|
|
81
|
+
...normalized,
|
|
82
|
+
kind: value.kind
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
case "video":
|
|
86
|
+
case "tour": {
|
|
87
|
+
const normalized = value.kind === "video" ? normalizeVideo(value) : normalizeTour(value);
|
|
88
|
+
return normalized.url === "" && normalized.poster === "" ? null : {
|
|
89
|
+
...normalized,
|
|
90
|
+
kind: value.kind
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default: return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const IDENTITY_KEYS = ["id"];
|
|
97
|
+
function normalizeFields(fields, value, identity) {
|
|
98
|
+
const source = isRecord(value) ? value : {};
|
|
99
|
+
const normalized = {};
|
|
100
|
+
if (identity) {
|
|
101
|
+
for (const key of IDENTITY_KEYS) if (typeof source[key] === "string") normalized[key] = source[key];
|
|
102
|
+
}
|
|
76
103
|
for (const [field, def] of Object.entries(fields)) normalized[field] = normalizeValue(def, source[field]);
|
|
77
104
|
return normalized;
|
|
78
105
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
return
|
|
106
|
+
function itemFieldsOf(def) {
|
|
107
|
+
const element = def?.element;
|
|
108
|
+
return element?.type === "object" && isRecord(element.fields) ? element.fields : void 0;
|
|
82
109
|
}
|
|
83
110
|
function normalizeValue(def, value) {
|
|
84
111
|
const slot = def;
|
|
@@ -87,21 +114,26 @@ function normalizeValue(def, value) {
|
|
|
87
114
|
case "select": return normalizeString(value);
|
|
88
115
|
case "number": return normalizeNumber(value);
|
|
89
116
|
case "url": return normalizeUrl(slot, value);
|
|
117
|
+
case "date": return isIsoDateValue(value) ? value : null;
|
|
118
|
+
case "email": return isEmailValue(value) ? value : "";
|
|
119
|
+
case "phone": return isPhoneValue(value) ? value : "";
|
|
90
120
|
case "image": return normalizeImage(value);
|
|
91
|
-
case "video": return normalizeVideo(
|
|
121
|
+
case "video": return normalizeVideo(value);
|
|
92
122
|
case "tour": return normalizeTour(value);
|
|
93
123
|
case "document": return normalizeDocument(value);
|
|
124
|
+
case "media": return normalizeMedia(slot, value);
|
|
94
125
|
case "poi": return isRecord(value) ? value : null;
|
|
126
|
+
case "address": return normalizeAddressValue(value);
|
|
127
|
+
case "object": return normalizeFields(isRecord(slot.fields) ? slot.fields : {}, value, false);
|
|
128
|
+
case "row": return typeof value === "string" && value !== "" ? value : null;
|
|
95
129
|
case "list": {
|
|
96
130
|
if (!Array.isArray(value)) return [];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return value.map((row) => normalizeRow(fields, row, idKey));
|
|
101
|
-
}
|
|
131
|
+
const fields = itemFieldsOf(slot);
|
|
132
|
+
if (fields !== void 0) return value.map((item) => normalizeFields(fields, item, true));
|
|
133
|
+
if (slot.element?.type === "row") return value.filter((id) => typeof id === "string" && id !== "");
|
|
102
134
|
if (slot.element == null) return value;
|
|
103
135
|
const element = slot.element;
|
|
104
|
-
return
|
|
136
|
+
return value.map((member) => normalizeValue(element, member)).filter((member) => member !== null);
|
|
105
137
|
}
|
|
106
138
|
default: return value;
|
|
107
139
|
}
|
|
@@ -113,32 +145,42 @@ function presentValue(def, value) {
|
|
|
113
145
|
switch (def.type) {
|
|
114
146
|
case "text":
|
|
115
147
|
case "select":
|
|
116
|
-
case "url":
|
|
148
|
+
case "url":
|
|
149
|
+
case "email":
|
|
150
|
+
case "phone": return value !== "";
|
|
151
|
+
case "date": return value !== null;
|
|
117
152
|
case "number":
|
|
118
153
|
case "image":
|
|
119
|
-
case "document":
|
|
154
|
+
case "document":
|
|
155
|
+
case "media": return value !== null;
|
|
120
156
|
case "video": return videoValuePresent(value);
|
|
121
157
|
case "tour": return videoValuePresent(value);
|
|
122
158
|
case "list": return Array.isArray(value) && value.length > 0;
|
|
123
|
-
case "poi":
|
|
159
|
+
case "poi":
|
|
160
|
+
case "row":
|
|
161
|
+
case "address": return value !== null;
|
|
162
|
+
case "object": return fieldsPresent(isRecord(def.fields) ? def.fields : {}, value);
|
|
124
163
|
default: return value != null && value !== "";
|
|
125
164
|
}
|
|
126
165
|
}
|
|
127
|
-
function
|
|
128
|
-
const source = isRecord(
|
|
166
|
+
function fieldsPresent(fields, value) {
|
|
167
|
+
const source = isRecord(value) ? value : {};
|
|
129
168
|
return Object.entries(fields).some(([field, def]) => presentValue(def, source[field]));
|
|
130
169
|
}
|
|
131
170
|
function itemPresentValue(def, value) {
|
|
132
171
|
const slot = def;
|
|
133
172
|
if (slot.type !== "list") return true;
|
|
134
|
-
|
|
173
|
+
const fields = itemFieldsOf(slot);
|
|
174
|
+
if (fields !== void 0) return fieldsPresent(fields, value);
|
|
135
175
|
return slot.element == null ? value != null : presentValue(slot.element, value);
|
|
136
176
|
}
|
|
137
177
|
function bindSlots(schema, slots) {
|
|
138
178
|
const bindings = {};
|
|
139
179
|
for (const [id, def] of Object.entries(schema.slots)) {
|
|
140
180
|
const value = normalizeValue(def, slots[id]);
|
|
181
|
+
const fields = objectFieldsOf(def);
|
|
141
182
|
bindings[id] = {
|
|
183
|
+
...fields === void 0 ? {} : bindRowFields(id, fields, value),
|
|
142
184
|
id,
|
|
143
185
|
def,
|
|
144
186
|
value,
|
|
@@ -147,39 +189,55 @@ function bindSlots(schema, slots) {
|
|
|
147
189
|
}
|
|
148
190
|
return bindings;
|
|
149
191
|
}
|
|
150
|
-
function
|
|
151
|
-
const
|
|
192
|
+
function objectFieldsOf(def) {
|
|
193
|
+
const { type, fields } = def;
|
|
194
|
+
return type === "object" && isRecord(fields) ? fields : void 0;
|
|
195
|
+
}
|
|
196
|
+
const BINDING_OWN = new Set(OBJECT_BINDING_OWN_KEYS);
|
|
197
|
+
function bindRowFields(slot, defs, value, item, enclosing) {
|
|
198
|
+
const source = isRecord(value) ? value : {};
|
|
152
199
|
const fields = {};
|
|
153
|
-
for (const [field, def] of Object.entries(
|
|
154
|
-
|
|
200
|
+
for (const [field, def] of Object.entries(defs)) {
|
|
201
|
+
if (BINDING_OWN.has(field)) continue;
|
|
202
|
+
const fieldValue = normalizeValue(def, source[field]);
|
|
155
203
|
fields[field] = {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
204
|
+
...enclosing ?? {
|
|
205
|
+
slot,
|
|
206
|
+
...item === void 0 ? {} : { item },
|
|
207
|
+
field
|
|
208
|
+
},
|
|
159
209
|
def,
|
|
160
|
-
value,
|
|
161
|
-
present: presentValue(def,
|
|
210
|
+
value: fieldValue,
|
|
211
|
+
present: presentValue(def, fieldValue)
|
|
162
212
|
};
|
|
163
213
|
}
|
|
164
214
|
return fields;
|
|
165
215
|
}
|
|
166
|
-
function isRecordItemDef(def) {
|
|
167
|
-
if (typeof def !== "object" || def == null) return false;
|
|
168
|
-
const { type, fields } = def;
|
|
169
|
-
return type === "list" && isRecord(fields);
|
|
170
|
-
}
|
|
171
216
|
function bindItems(binding) {
|
|
172
217
|
const values = binding.value ?? [];
|
|
173
218
|
const slotName = "id" in binding ? binding.id : binding.field;
|
|
174
|
-
const
|
|
219
|
+
const objectFields = itemFieldsOf(binding.def);
|
|
220
|
+
const element = binding.def.element;
|
|
221
|
+
const enclosing = "id" in binding || objectFields === void 0 ? void 0 : fieldAddressOf(binding);
|
|
175
222
|
return values.map((value, index) => ({
|
|
223
|
+
...objectFields === void 0 ? {} : {
|
|
224
|
+
...bindRowFields(slotName, objectFields, value, index, enclosing),
|
|
225
|
+
def: element
|
|
226
|
+
},
|
|
176
227
|
slot: slotName,
|
|
177
228
|
index,
|
|
178
229
|
value,
|
|
179
230
|
present: itemPresentValue(binding.def, value),
|
|
180
|
-
...
|
|
231
|
+
...enclosing === void 0 ? {} : { enclosing }
|
|
181
232
|
}));
|
|
182
233
|
}
|
|
234
|
+
function fieldAddressOf(binding) {
|
|
235
|
+
return {
|
|
236
|
+
slot: binding.slot,
|
|
237
|
+
...binding.item === void 0 ? {} : { item: binding.item },
|
|
238
|
+
field: binding.field
|
|
239
|
+
};
|
|
240
|
+
}
|
|
183
241
|
|
|
184
242
|
//#endregion
|
|
185
|
-
export { bindItems, bindSlots,
|
|
243
|
+
export { bindItems, bindSlots, videoValuePresent };
|
|
@@ -1,35 +1,40 @@
|
|
|
1
1
|
import { DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
2
2
|
import { ValueBinding } from "./slot-scalar.js";
|
|
3
|
-
import {
|
|
3
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
4
4
|
//#region src/primitives/slot-document.d.ts
|
|
5
|
-
type
|
|
5
|
+
type DocumentProps<D> = Omit<HTMLAttributes<HTMLElement>, "title" | "slot"> & {
|
|
6
6
|
slot: ValueBinding<D> & {
|
|
7
7
|
value: DocumentValue | null | undefined;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/** Titles the `<iframe>` for assistive technology. Defaults to the file's name. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Render inside the kit's frame — a clipped, relatively positioned wrapper the viewer
|
|
12
|
+
* fills edge to edge, tinted when there is nothing to show. It has NO geometry of its
|
|
13
|
+
* own: `className` lands on it and your classes are its whole box. `false` renders a
|
|
14
|
+
* bare `<iframe>` instead. Default `true`. */
|
|
15
|
+
frame?: boolean;
|
|
12
16
|
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
13
17
|
* full identity stays, and the copy is still patched live. */
|
|
14
18
|
selectable?: boolean;
|
|
15
19
|
};
|
|
16
|
-
type DocumentProps<D, As extends ElementType> = DocumentOwnProps<D> & {
|
|
17
|
-
/** The element (or component) the document link lands on. Defaults to `a`. */
|
|
18
|
-
as?: As;
|
|
19
|
-
} & Omit<ComponentPropsWithoutRef<As>, keyof DocumentOwnProps<D> | "as">;
|
|
20
20
|
/**
|
|
21
|
-
* Slot.Document —
|
|
22
|
-
* children as its contents. Opens in a new tab by default (`target="_blank"`,
|
|
23
|
-
* `rel="noopener noreferrer"`); both are ordinary props and an author may
|
|
24
|
-
* override either.
|
|
21
|
+
* Slot.Document — embeds the slot's PDF in the browser's own viewer.
|
|
25
22
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
23
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via
|
|
24
|
+
* `.concrete-image-frame` — that your `className` lands on and the viewer absolutely
|
|
25
|
+
* fills. Size the wrapper with your own classes, as for `Slot.Image` and `Slot.Tour`.
|
|
26
|
+
*
|
|
27
|
+
* **Empty is a neutral rect.** An unfilled slot, and a document that is not a PDF,
|
|
28
|
+
* render the frame alone: the browser has no inline viewer for any other format.
|
|
29
|
+
* Link to such a file with `Slot.Download`, or draw its first page with `Slot.Image`.
|
|
30
|
+
*
|
|
31
|
+
* Over an open-kind `media()` slot, narrow on the value's `kind` first and hand it the
|
|
32
|
+
* narrowed value, as `Slot.Video` takes it.
|
|
30
33
|
*/
|
|
31
34
|
declare function SlotDocument<D extends {
|
|
32
35
|
type: "document";
|
|
33
|
-
}
|
|
36
|
+
} | {
|
|
37
|
+
type: "media";
|
|
38
|
+
}>(props: DocumentProps<D>): ReactNode;
|
|
34
39
|
//#endregion
|
|
35
40
|
export { SlotDocument };
|
|
@@ -1,24 +1,49 @@
|
|
|
1
|
-
import { useSlotProbe } from "./probe-context.js";
|
|
2
1
|
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
2
|
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
|
|
6
5
|
//#region src/primitives/slot-document.tsx
|
|
6
|
+
const PDF = "application/pdf";
|
|
7
7
|
function SlotDocument(props) {
|
|
8
|
-
const { slot,
|
|
9
|
-
|
|
10
|
-
const Tag = as ?? "a";
|
|
11
|
-
const url = slot.value?.url;
|
|
12
|
-
return /* @__PURE__ */ jsx(Tag, {
|
|
13
|
-
...typeof url === "string" && url !== "" ? {
|
|
14
|
-
href: url,
|
|
15
|
-
target: "_blank",
|
|
16
|
-
rel: "noopener noreferrer"
|
|
17
|
-
} : {},
|
|
18
|
-
...rest,
|
|
8
|
+
const { slot, title, frame, className, selectable = true, ...rest } = props;
|
|
9
|
+
const markerAttrs = {
|
|
19
10
|
...identityMarkerAttrs(slot),
|
|
20
|
-
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
21
|
-
|
|
11
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
12
|
+
};
|
|
13
|
+
const value = slot.value;
|
|
14
|
+
const isPdf = value?.content_type.split(";")[0]?.trim().toLowerCase() === PDF;
|
|
15
|
+
const src = value && value.url !== "" && isPdf ? value.url : null;
|
|
16
|
+
const label = title ?? value?.filename ?? "";
|
|
17
|
+
const unframedCls = ["concrete-image-block", className].filter(Boolean).join(" ");
|
|
18
|
+
const viewer = src === null ? null : /* @__PURE__ */ jsx("iframe", {
|
|
19
|
+
src,
|
|
20
|
+
title: label || "Document",
|
|
21
|
+
loading: "lazy",
|
|
22
|
+
className: frame === false ? unframedCls : "absolute inset-0 h-full w-full",
|
|
23
|
+
...frame === false ? {
|
|
24
|
+
...rest,
|
|
25
|
+
...markerAttrs
|
|
26
|
+
} : {}
|
|
27
|
+
});
|
|
28
|
+
if (frame === false) {
|
|
29
|
+
if (viewer) return viewer;
|
|
30
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
|
+
className: unframedCls,
|
|
32
|
+
role: "img",
|
|
33
|
+
"aria-label": label || void 0,
|
|
34
|
+
...rest,
|
|
35
|
+
...markerAttrs
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: ["concrete-image-frame concrete-image-block relative overflow-hidden", className].filter(Boolean).join(" "),
|
|
40
|
+
...viewer ? {} : {
|
|
41
|
+
role: "img",
|
|
42
|
+
"aria-label": label || void 0
|
|
43
|
+
},
|
|
44
|
+
...rest,
|
|
45
|
+
...markerAttrs,
|
|
46
|
+
children: viewer
|
|
22
47
|
});
|
|
23
48
|
}
|
|
24
49
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
2
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
3
|
+
import { ImageValue } from "../packages/internal/template-contracts/dist/runtime-values.js";
|
|
4
|
+
import { ValueBinding } from "./slot-scalar.js";
|
|
5
|
+
import { ComponentPropsWithoutRef, ElementType, ReactNode } from "react";
|
|
6
|
+
//#region src/primitives/slot-download.d.ts
|
|
7
|
+
type DownloadOwnProps<D> = {
|
|
8
|
+
slot: ValueBinding<D> & {
|
|
9
|
+
value: ImageValue | VideoValue | DocumentValue | null | undefined;
|
|
10
|
+
};
|
|
11
|
+
/** Author markup inside the marked element (an icon, the filename, a size
|
|
12
|
+
* line) — rendered in every branch, absent value included. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
15
|
+
* full identity stays, and the copy is still patched live. */
|
|
16
|
+
selectable?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type DownloadProps<D, As extends ElementType> = DownloadOwnProps<D> & {
|
|
19
|
+
/** The element (or component) the download link lands on. Defaults to `a`. */
|
|
20
|
+
as?: As;
|
|
21
|
+
} & Omit<ComponentPropsWithoutRef<As>, keyof DownloadOwnProps<D> | "as">;
|
|
22
|
+
/**
|
|
23
|
+
* Slot.Download — renders one anchor at the original of an image, video or
|
|
24
|
+
* document slot's asset, with the author's children as its contents. Opens in a
|
|
25
|
+
* new tab by default (`target="_blank"`, `rel="noopener noreferrer"`); both are
|
|
26
|
+
* ordinary props and an author may override either, or add `download`.
|
|
27
|
+
*
|
|
28
|
+
* An image links its uncropped picture whatever crop the slot shows, a video its
|
|
29
|
+
* hosted file, a document the file itself. A slot with nothing to hand over — an
|
|
30
|
+
* unfilled slot, or a video that is a provider link — renders the same marked
|
|
31
|
+
* element with no `href`: a placeholder that is still selectable in the editor,
|
|
32
|
+
* never a dead link. Never a text leaf: the value is a URL in an attribute, and
|
|
33
|
+
* what the element says is the author's markup.
|
|
34
|
+
*/
|
|
35
|
+
declare function SlotDownload<D extends {
|
|
36
|
+
type: "image" | "video" | "document" | "media";
|
|
37
|
+
}, As extends ElementType = "a">(props: DownloadProps<D, As>): ReactNode;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { SlotDownload };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
2
|
+
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/slot-download.tsx
|
|
6
|
+
function originalUrl(def, value) {
|
|
7
|
+
if (!value) return "";
|
|
8
|
+
const declared = def.type;
|
|
9
|
+
switch (declared === "media" ? value.kind : declared) {
|
|
10
|
+
case "image": {
|
|
11
|
+
const image = value;
|
|
12
|
+
return image.download_url || image.url;
|
|
13
|
+
}
|
|
14
|
+
case "video": {
|
|
15
|
+
const video = value;
|
|
16
|
+
return video.source === "link" ? "" : video.url;
|
|
17
|
+
}
|
|
18
|
+
default: return value.url;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function SlotDownload(props) {
|
|
22
|
+
const { slot, as, children, selectable = true, ...rest } = props;
|
|
23
|
+
const Tag = as ?? "a";
|
|
24
|
+
const url = originalUrl(slot.def, slot.value);
|
|
25
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
26
|
+
...url !== "" ? {
|
|
27
|
+
href: url,
|
|
28
|
+
target: "_blank",
|
|
29
|
+
rel: "noopener noreferrer"
|
|
30
|
+
} : {},
|
|
31
|
+
...rest,
|
|
32
|
+
...identityMarkerAttrs(slot),
|
|
33
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" },
|
|
34
|
+
children
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { SlotDownload };
|
|
@@ -2,14 +2,14 @@ import { FieldBinding, SlotBinding } from "./slot-bindings.js";
|
|
|
2
2
|
import { ComponentProps, ElementType, ReactNode } from "react";
|
|
3
3
|
//#region src/primitives/slot-list.d.ts
|
|
4
4
|
type SlotListOwnProps<D> = {
|
|
5
|
-
/** The
|
|
6
|
-
* binding (a `list` declared inside
|
|
5
|
+
/** The list to mark: a top-level slot binding, or an object field's list
|
|
6
|
+
* binding (a `list` declared inside an object). */
|
|
7
7
|
slot: SlotBinding<D> | FieldBinding<D>;
|
|
8
8
|
/** `false` declines selection on THIS copy (a carousel clone, a responsive
|
|
9
9
|
* mirror) — full identity stays, and the copy is still patched live. */
|
|
10
10
|
selectable?: boolean;
|
|
11
11
|
/** The author's own markup — iteration is plain `bindItems(...).map(...)`; an empty
|
|
12
|
-
*
|
|
12
|
+
* list renders these children (a placeholder) inside the marked container. */
|
|
13
13
|
children?: ReactNode;
|
|
14
14
|
};
|
|
15
15
|
type SlotListProps<D, As extends ElementType> = SlotListOwnProps<D> & {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useSlotProbe } from "./probe-context.js";
|
|
2
1
|
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
2
|
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -6,7 +5,6 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
5
|
//#region src/primitives/slot-list.tsx
|
|
7
6
|
function SlotList(props) {
|
|
8
7
|
const { slot, as, children, selectable = true, ...rest } = props;
|
|
9
|
-
useSlotProbe(slot);
|
|
10
8
|
const Container = as;
|
|
11
9
|
const containerAttrs = {
|
|
12
10
|
...identityMarkerAttrs(slot),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
2
2
|
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
3
|
-
import {
|
|
3
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
4
|
+
import { ImageValue, MediaValue } from "../packages/internal/template-contracts/dist/runtime-values.js";
|
|
4
5
|
import { Image } from "./Image.js";
|
|
5
6
|
import { ValueBinding } from "./slot-scalar.js";
|
|
6
7
|
import { Tour } from "./Tour.js";
|
|
@@ -9,7 +10,7 @@ import { ComponentProps, ReactNode } from "react";
|
|
|
9
10
|
//#region src/primitives/slot-media.d.ts
|
|
10
11
|
type SlotImageProps<D> = Omit<ComponentProps<typeof Image>, "value" | "slot" | "mobileBreakpoint"> & {
|
|
11
12
|
slot: ValueBinding<D> & {
|
|
12
|
-
value: ImageValue | VideoValue | TourValue | null | undefined;
|
|
13
|
+
value: ImageValue | VideoValue | TourValue | DocumentValue | MediaValue | null | undefined;
|
|
13
14
|
};
|
|
14
15
|
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
15
16
|
* full identity stays, and the copy is still patched live. */
|
|
@@ -29,9 +30,18 @@ type SlotImageProps<D> = Omit<ComponentProps<typeof Image>, "value" | "slot" | "
|
|
|
29
30
|
* repatches this element. A poster that does not exist yet — a transcode still running,
|
|
30
31
|
* or a tour provider that published no thumbnail — renders `<Image>`'s ordinary empty
|
|
31
32
|
* rect. `rendition` has no effect here: a poster carries no per-view crop.
|
|
33
|
+
*
|
|
34
|
+
* **Over a document slot it renders the document's first page**, the preview the
|
|
35
|
+
* platform renders from a PDF, titled by the file's name. A document with no preview
|
|
36
|
+
* — any other format, or a PDF whose preview has not been rendered yet — renders the
|
|
37
|
+
* empty rect.
|
|
38
|
+
*
|
|
39
|
+
* **Over an open-kind `media()` slot it draws whatever the value is** — the image
|
|
40
|
+
* itself, or the still of a video, tour or document, by the value's `kind` — so a
|
|
41
|
+
* gallery's thumbnails need no narrowing.
|
|
32
42
|
*/
|
|
33
43
|
declare function SlotImage<D extends {
|
|
34
|
-
type: "image" | "video" | "tour";
|
|
44
|
+
type: "image" | "video" | "tour" | "document" | "media";
|
|
35
45
|
}>(props: SlotImageProps<D>): ReactNode;
|
|
36
46
|
type SlotVideoProps<D> = Omit<ComponentProps<typeof Video>, "value" | "playback" | "slot"> & {
|
|
37
47
|
slot: ValueBinding<D> & {
|
|
@@ -45,9 +55,15 @@ type SlotVideoProps<D> = Omit<ComponentProps<typeof Video>, "value" | "playback"
|
|
|
45
55
|
* Slot.Video — binds `<Video>` to a slot: `playback` comes from the slot's own declared
|
|
46
56
|
* `def`; `frame` and the rest are `<Video>`'s own props with its own defaults. See
|
|
47
57
|
* `./Video.js` for the framed/unframed/poster-only render contract.
|
|
58
|
+
*
|
|
59
|
+
* Over an open-kind `media()` slot, narrow on the value's `kind` first and hand it the
|
|
60
|
+
* narrowed value — `value?.kind === "video" && <Slot.Video slot={{ ...slot, value }} />`.
|
|
61
|
+
* A `media()` slot declares no `playback`, so it plays as a plain controls player.
|
|
48
62
|
*/
|
|
49
63
|
declare function SlotVideo<D extends {
|
|
50
64
|
type: "video";
|
|
65
|
+
} | {
|
|
66
|
+
type: "media";
|
|
51
67
|
}>(props: SlotVideoProps<D>): ReactNode;
|
|
52
68
|
type SlotTourProps<D> = Omit<ComponentProps<typeof Tour>, "value" | "slot"> & {
|
|
53
69
|
slot: ValueBinding<D> & {
|
|
@@ -62,10 +78,13 @@ type SlotTourProps<D> = Omit<ComponentProps<typeof Tour>, "value" | "slot"> & {
|
|
|
62
78
|
* with its own defaults. See `./Tour.js` for the framed/unframed/empty render contract.
|
|
63
79
|
*
|
|
64
80
|
* Bind the SAME slot to `Slot.Image` to render the tour's thumbnail instead — or beside
|
|
65
|
-
* this one, for two positions from one selection.
|
|
81
|
+
* this one, for two positions from one selection. Over an open-kind `media()` slot,
|
|
82
|
+
* narrow on the value's `kind` first and hand it the narrowed value, as `Slot.Video` takes it.
|
|
66
83
|
*/
|
|
67
84
|
declare function SlotTour<D extends {
|
|
68
85
|
type: "tour";
|
|
86
|
+
} | {
|
|
87
|
+
type: "media";
|
|
69
88
|
}>(props: SlotTourProps<D>): ReactNode;
|
|
70
89
|
//#endregion
|
|
71
90
|
export { SlotImage, SlotTour, SlotVideo };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useSlotProbe } from "./probe-context.js";
|
|
2
1
|
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
2
|
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
3
|
import { Image } from "./Image.js";
|
|
@@ -17,23 +16,23 @@ function posterAsImage(value) {
|
|
|
17
16
|
return {
|
|
18
17
|
photo_id: "",
|
|
19
18
|
url: value.poster,
|
|
20
|
-
alt: value.alt,
|
|
19
|
+
alt: "alt" in value ? value.alt : value.filename,
|
|
21
20
|
responsive: value.poster_responsive ?? null
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
function isPosterSlot(def) {
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
function isPosterSlot(def, value) {
|
|
24
|
+
const declared = def.type;
|
|
25
|
+
const type = declared === "media" ? value?.kind : declared;
|
|
26
|
+
return type === "video" || type === "tour" || type === "document";
|
|
27
27
|
}
|
|
28
28
|
function SlotImage(props) {
|
|
29
29
|
const { slot, selectable = true, ...rest } = props;
|
|
30
|
-
useSlotProbe(slot);
|
|
31
30
|
const markerAttrs = {
|
|
32
31
|
...identityMarkerAttrs(slot),
|
|
33
32
|
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
34
33
|
};
|
|
35
34
|
return /* @__PURE__ */ jsx(Image, {
|
|
36
|
-
value: isPosterSlot(slot.def) && slot.value ? posterAsImage(slot.value) : slot.value,
|
|
35
|
+
value: isPosterSlot(slot.def, slot.value) && slot.value ? posterAsImage(slot.value) : slot.value,
|
|
37
36
|
mobileBreakpoint: declaredMobileBreakpoint(slot.def),
|
|
38
37
|
...rest,
|
|
39
38
|
...markerAttrs
|
|
@@ -41,7 +40,6 @@ function SlotImage(props) {
|
|
|
41
40
|
}
|
|
42
41
|
function SlotVideo(props) {
|
|
43
42
|
const { slot, selectable = true, ...rest } = props;
|
|
44
|
-
useSlotProbe(slot);
|
|
45
43
|
const markerAttrs = {
|
|
46
44
|
...identityMarkerAttrs(slot),
|
|
47
45
|
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
@@ -55,7 +53,6 @@ function SlotVideo(props) {
|
|
|
55
53
|
}
|
|
56
54
|
function SlotTour(props) {
|
|
57
55
|
const { slot, selectable = true, ...rest } = props;
|
|
58
|
-
useSlotProbe(slot);
|
|
59
56
|
const markerAttrs = {
|
|
60
57
|
...identityMarkerAttrs(slot),
|
|
61
58
|
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentProps, ElementType, ReactNode } from "react";
|
|
2
|
+
//#region src/primitives/slot-object.d.ts
|
|
3
|
+
/** A top-level object's binding, as `Slot.Object` reads it: its id and its object definition. */
|
|
4
|
+
type ObjectTarget = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly def: {
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An item of a list of objects, as `Slot.Object` reads it: its list, its index and its
|
|
12
|
+
* object definition — and, for an item of an object's list of objects, the enclosing
|
|
13
|
+
* field it marks as.
|
|
14
|
+
*/
|
|
15
|
+
type ObjectItemTarget = {
|
|
16
|
+
readonly slot: string;
|
|
17
|
+
readonly index: number;
|
|
18
|
+
readonly def: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
};
|
|
21
|
+
readonly enclosing?: {
|
|
22
|
+
readonly field: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type SlotObjectOwnProps = {
|
|
26
|
+
/** The object to mark: a top-level object's binding, or one `ItemBinding` of a list of objects. */
|
|
27
|
+
slot: ObjectTarget | ObjectItemTarget;
|
|
28
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive
|
|
29
|
+
* mirror) — full identity stays, and the copy is still patched live. */
|
|
30
|
+
selectable?: boolean;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
};
|
|
33
|
+
type SlotObjectProps<As extends ElementType> = SlotObjectOwnProps & {
|
|
34
|
+
/** The element (or component) this primitive renders and marks. Defaults to `div`. */
|
|
35
|
+
as?: As;
|
|
36
|
+
} & Omit<ComponentProps<As>, "slot" | "selectable" | "children" | "as">;
|
|
37
|
+
/**
|
|
38
|
+
* Render `as` (a host element or component, `div` by default) carrying the object's
|
|
39
|
+
* marker: `<Slot.Object slot={slot.contact}>` emits `data-slot-id="contact"`, and
|
|
40
|
+
* `<Slot.Object slot={item}>` over an object item's `ItemBinding` emits
|
|
41
|
+
* `data-slot-item` — so the editor outlines and edits the container as one sidebar
|
|
42
|
+
* card. Render the object's fields inside it, each through its own binding
|
|
43
|
+
* (`slot.contact.phone`, `item.price`). Rendering the same object again
|
|
44
|
+
* (a clone slide, a second layout branch) is just another `Slot.Object` over the same
|
|
45
|
+
* binding; every copy is live.
|
|
46
|
+
*/
|
|
47
|
+
declare function SlotObject<As extends ElementType = "div">(props: SlotObjectProps<As>): ReactNode;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { SlotObject };
|