@homepages/concrete 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { acceptsLink } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/slot-bindings.ts
|
|
4
|
+
const blankVideo = () => ({
|
|
5
|
+
video_id: "",
|
|
6
|
+
url: "",
|
|
7
|
+
poster: "",
|
|
8
|
+
alt: ""
|
|
9
|
+
});
|
|
10
|
+
const blankTour = () => ({
|
|
11
|
+
tour_id: "",
|
|
12
|
+
url: "",
|
|
13
|
+
poster: "",
|
|
14
|
+
alt: ""
|
|
15
|
+
});
|
|
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
|
+
function isRecord(value) {
|
|
23
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function normalizeString(value) {
|
|
26
|
+
if (typeof value === "string") return value;
|
|
27
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
function stringField(value) {
|
|
31
|
+
return typeof value === "string" ? value : "";
|
|
32
|
+
}
|
|
33
|
+
function normalizeNumber(value) {
|
|
34
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
35
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
36
|
+
const parsed = Number(value);
|
|
37
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function normalizeUrl(slot, value) {
|
|
42
|
+
if (typeof value !== "string") return "";
|
|
43
|
+
if (value === "" || typeof slot.accepts !== "string") return value;
|
|
44
|
+
return acceptsLink(slot.accepts, value) ? value : "";
|
|
45
|
+
}
|
|
46
|
+
function normalizeImage(value) {
|
|
47
|
+
return isRecord(value) && typeof value.url === "string" && value.url !== "" ? value : null;
|
|
48
|
+
}
|
|
49
|
+
function normalizeDocument(value) {
|
|
50
|
+
return isRecord(value) && typeof value.url === "string" && value.url !== "" ? value : null;
|
|
51
|
+
}
|
|
52
|
+
function normalizeVideo(slot, value) {
|
|
53
|
+
if (!admitsLinkVideo(slot.sources) && isLinkVideo(value)) return blankVideo();
|
|
54
|
+
if (!isRecord(value)) return blankVideo();
|
|
55
|
+
return {
|
|
56
|
+
...value,
|
|
57
|
+
video_id: stringField(value.video_id),
|
|
58
|
+
url: stringField(value.url),
|
|
59
|
+
poster: stringField(value.poster),
|
|
60
|
+
alt: stringField(value.alt)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function normalizeTour(value) {
|
|
64
|
+
if (!isRecord(value)) return blankTour();
|
|
65
|
+
return {
|
|
66
|
+
...value,
|
|
67
|
+
tour_id: stringField(value.tour_id),
|
|
68
|
+
url: stringField(value.url),
|
|
69
|
+
poster: stringField(value.poster),
|
|
70
|
+
alt: stringField(value.alt)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function normalizeRow(fields, row) {
|
|
74
|
+
const source = isRecord(row) ? row : {};
|
|
75
|
+
const normalized = { id: stringField(source.id) };
|
|
76
|
+
for (const [field, def] of Object.entries(fields)) normalized[field] = normalizeValue(def, source[field]);
|
|
77
|
+
return normalized;
|
|
78
|
+
}
|
|
79
|
+
function normalizeValue(def, value) {
|
|
80
|
+
const slot = def;
|
|
81
|
+
switch (slot.type) {
|
|
82
|
+
case "text":
|
|
83
|
+
case "select": return normalizeString(value);
|
|
84
|
+
case "number": return normalizeNumber(value);
|
|
85
|
+
case "url": return normalizeUrl(slot, value);
|
|
86
|
+
case "image": return normalizeImage(value);
|
|
87
|
+
case "video": return normalizeVideo(slot, value);
|
|
88
|
+
case "tour": return normalizeTour(value);
|
|
89
|
+
case "document": return normalizeDocument(value);
|
|
90
|
+
case "poi": return isRecord(value) ? value : null;
|
|
91
|
+
case "list": {
|
|
92
|
+
if (!Array.isArray(value)) return [];
|
|
93
|
+
if (isRecord(slot.fields)) {
|
|
94
|
+
const fields = slot.fields;
|
|
95
|
+
return value.map((row) => normalizeRow(fields, row));
|
|
96
|
+
}
|
|
97
|
+
if (slot.element == null) return value;
|
|
98
|
+
const element = slot.element;
|
|
99
|
+
return (element.type === "video" && !admitsLinkVideo(element.sources) ? value.filter((member) => isRecord(member) && !isLinkVideo(member)) : value).map((member) => normalizeValue(element, member)).filter((member) => member !== null);
|
|
100
|
+
}
|
|
101
|
+
default: return value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Is this (normalized) video value non-blank? A poster-only value — a pending
|
|
105
|
+
* transcode — is present and still renders. */
|
|
106
|
+
function videoValuePresent(value) {
|
|
107
|
+
return Boolean(value?.url) || Boolean(value?.poster);
|
|
108
|
+
}
|
|
109
|
+
function presentValue(def, value) {
|
|
110
|
+
switch (def.type) {
|
|
111
|
+
case "text":
|
|
112
|
+
case "select":
|
|
113
|
+
case "url": return value !== "";
|
|
114
|
+
case "number":
|
|
115
|
+
case "image":
|
|
116
|
+
case "document": return value !== null;
|
|
117
|
+
case "video": return videoValuePresent(value);
|
|
118
|
+
case "tour": return videoValuePresent(value);
|
|
119
|
+
case "list": return Array.isArray(value) && value.length > 0;
|
|
120
|
+
case "poi": return value !== null;
|
|
121
|
+
default: return value != null && value !== "";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function rowPresent(fields, row) {
|
|
125
|
+
const source = isRecord(row) ? row : {};
|
|
126
|
+
return Object.entries(fields).some(([field, def]) => presentValue(def, source[field]));
|
|
127
|
+
}
|
|
128
|
+
function itemPresentValue(def, value) {
|
|
129
|
+
const slot = def;
|
|
130
|
+
if (slot.type !== "list") return true;
|
|
131
|
+
if (isRecord(slot.fields)) return rowPresent(slot.fields, value);
|
|
132
|
+
return slot.element == null ? value != null : presentValue(slot.element, value);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Bind a section's schema to the values its renderer received.
|
|
136
|
+
*
|
|
137
|
+
* ```tsx
|
|
138
|
+
* import { bindSlots, defineSchema, Section, Slot, text } from "@homepages/concrete";
|
|
139
|
+
* import type { SectionProps } from "@homepages/concrete";
|
|
140
|
+
*
|
|
141
|
+
* const schema = defineSchema({
|
|
142
|
+
* label: "Contact",
|
|
143
|
+
* anchor: "contact",
|
|
144
|
+
* slots: { phone: text.short({ label: "Phone" }) },
|
|
145
|
+
* });
|
|
146
|
+
* type Props = SectionProps<typeof schema>;
|
|
147
|
+
*
|
|
148
|
+
* export default function Contact({ slots }: Props) {
|
|
149
|
+
* const slot = bindSlots(schema, slots);
|
|
150
|
+
* return (
|
|
151
|
+
* <Section>
|
|
152
|
+
* <Slot.Text slot={slot.phone} as="span" />
|
|
153
|
+
* </Section>
|
|
154
|
+
* );
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* The returned map is keyed and typed off `typeof schema`, so a mistyped slot id is a
|
|
159
|
+
* compile error rather than an `undefined` that renders nothing. Call it per render:
|
|
160
|
+
* bindings are fresh objects with no memoised identity, which is harmless because they
|
|
161
|
+
* are only read, never used as a React key or dependency.
|
|
162
|
+
*/
|
|
163
|
+
function bindSlots(schema, slots) {
|
|
164
|
+
const bindings = {};
|
|
165
|
+
for (const [id, def] of Object.entries(schema.slots)) {
|
|
166
|
+
const value = normalizeValue(def, slots[id]);
|
|
167
|
+
bindings[id] = {
|
|
168
|
+
id,
|
|
169
|
+
def,
|
|
170
|
+
value,
|
|
171
|
+
present: presentValue(def, value)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return bindings;
|
|
175
|
+
}
|
|
176
|
+
function bindRowFields(binding, index) {
|
|
177
|
+
const row = binding.value[index] ?? {};
|
|
178
|
+
const fields = {};
|
|
179
|
+
for (const [field, def] of Object.entries(binding.def.fields)) {
|
|
180
|
+
const value = normalizeValue(def, row[field]);
|
|
181
|
+
fields[field] = {
|
|
182
|
+
slot: binding.id,
|
|
183
|
+
item: index,
|
|
184
|
+
field,
|
|
185
|
+
def,
|
|
186
|
+
value,
|
|
187
|
+
present: presentValue(def, value)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return fields;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Does this def declare a RECORD item — the one item shape whose members carry
|
|
194
|
+
* field bindings? Read off the declared `fields`: the item, not the type name,
|
|
195
|
+
* is what decides.
|
|
196
|
+
*/
|
|
197
|
+
function isRecordItemDef(def) {
|
|
198
|
+
if (typeof def !== "object" || def == null) return false;
|
|
199
|
+
const { type, fields } = def;
|
|
200
|
+
return type === "list" && isRecord(fields);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Bind a list slot's items for iteration — the one idiom for rendering anything
|
|
204
|
+
* multi-item: `bindItems(slot.units).map((unit) => …)` is an ordinary React
|
|
205
|
+
* array, so clones, splits, and free-form markup are plain JavaScript rather
|
|
206
|
+
* than list-primitive modes.
|
|
207
|
+
*
|
|
208
|
+
* Accepts a top-level list binding or a row field's list binding (a `list`
|
|
209
|
+
* declared inside a record item); a non-list binding is a compile error. An
|
|
210
|
+
* empty or absent value yields `[]`.
|
|
211
|
+
*/
|
|
212
|
+
function bindItems(binding) {
|
|
213
|
+
const values = binding.value ?? [];
|
|
214
|
+
const slotName = "id" in binding ? binding.id : binding.field;
|
|
215
|
+
const recordItem = isRecordItemDef(binding.def);
|
|
216
|
+
return values.map((value, index) => ({
|
|
217
|
+
slot: slotName,
|
|
218
|
+
index,
|
|
219
|
+
value,
|
|
220
|
+
present: itemPresentValue(binding.def, value),
|
|
221
|
+
...recordItem ? { fields: bindRowFields(binding, index) } : {}
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
export { bindItems, bindSlots, isRecordItemDef, videoValuePresent };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DocumentValue } from "../packages/internal/template-contracts/dist/document-value.js";
|
|
2
|
+
import { ValueBinding } from "./slot-scalar.js";
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementType, ReactNode } from "react";
|
|
4
|
+
//#region src/primitives/slot-document.d.ts
|
|
5
|
+
type DocumentOwnProps<D> = {
|
|
6
|
+
slot: ValueBinding<D> & {
|
|
7
|
+
value: DocumentValue | null | undefined;
|
|
8
|
+
};
|
|
9
|
+
/** Author markup inside the marked element (an icon, the filename, a size
|
|
10
|
+
* line) — rendered in every branch, absent value included. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
13
|
+
* full identity stays, and the copy is still patched live. */
|
|
14
|
+
selectable?: boolean;
|
|
15
|
+
};
|
|
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
|
+
/**
|
|
21
|
+
* Slot.Document — renders the slot's document as one anchor, with the author's
|
|
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.
|
|
25
|
+
*
|
|
26
|
+
* An unfilled slot renders the same marked element with no `href` — a
|
|
27
|
+
* placeholder that is still selectable in the editor, never a dead link.
|
|
28
|
+
* Never a text leaf: the value is a URL in an attribute, and what the element
|
|
29
|
+
* says is the author's markup.
|
|
30
|
+
*/
|
|
31
|
+
declare function SlotDocument<D extends {
|
|
32
|
+
type: "document";
|
|
33
|
+
}, As extends ElementType = "a">(props: DocumentProps<D, As>): ReactNode;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { SlotDocument };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useSlotProbe } from "./probe-context.js";
|
|
2
|
+
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
|
+
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/slot-document.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Slot.Document — renders the slot's document as one anchor, with the author's
|
|
9
|
+
* children as its contents. Opens in a new tab by default (`target="_blank"`,
|
|
10
|
+
* `rel="noopener noreferrer"`); both are ordinary props and an author may
|
|
11
|
+
* override either.
|
|
12
|
+
*
|
|
13
|
+
* An unfilled slot renders the same marked element with no `href` — a
|
|
14
|
+
* placeholder that is still selectable in the editor, never a dead link.
|
|
15
|
+
* Never a text leaf: the value is a URL in an attribute, and what the element
|
|
16
|
+
* says is the author's markup.
|
|
17
|
+
*/
|
|
18
|
+
function SlotDocument(props) {
|
|
19
|
+
const { slot, as, children, selectable = true, ...rest } = props;
|
|
20
|
+
useSlotProbe(slot);
|
|
21
|
+
const Tag = as ?? "a";
|
|
22
|
+
const url = slot.value?.url;
|
|
23
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
24
|
+
...typeof url === "string" && url !== "" ? {
|
|
25
|
+
href: url,
|
|
26
|
+
target: "_blank",
|
|
27
|
+
rel: "noopener noreferrer"
|
|
28
|
+
} : {},
|
|
29
|
+
...rest,
|
|
30
|
+
...identityMarkerAttrs(slot),
|
|
31
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" },
|
|
32
|
+
children
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { SlotDocument };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ItemBinding } from "./slot-bindings.js";
|
|
2
|
+
import { ComponentProps, ElementType, ReactNode } from "react";
|
|
3
|
+
//#region src/primitives/slot-group.d.ts
|
|
4
|
+
/** The declared-group form: a card's id (the marker) and its editor title. */
|
|
5
|
+
type DeclaredGroupProps = {
|
|
6
|
+
/** The card's id — `data-slot-group` on the container, and the group's id in the schema. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** The card's title in the editor sidebar. */
|
|
9
|
+
label: string;
|
|
10
|
+
slot?: undefined;
|
|
11
|
+
};
|
|
12
|
+
/** The collection-row form: one row of a list, by its `ItemBinding`. */
|
|
13
|
+
type RowProps = {
|
|
14
|
+
/** The row to mark: one collection row's `ItemBinding`. */
|
|
15
|
+
slot: Pick<ItemBinding<unknown>, "slot" | "index">;
|
|
16
|
+
id?: undefined;
|
|
17
|
+
label?: undefined;
|
|
18
|
+
};
|
|
19
|
+
type SlotGroupOwnProps = (DeclaredGroupProps | RowProps) & {
|
|
20
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive
|
|
21
|
+
* mirror) — full identity stays, and the copy is still patched live. */
|
|
22
|
+
selectable?: boolean;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
};
|
|
25
|
+
type SlotGroupProps<As extends ElementType> = SlotGroupOwnProps & {
|
|
26
|
+
/** The element (or component) this primitive renders and marks. Defaults to `div`. */
|
|
27
|
+
as?: As;
|
|
28
|
+
} & Omit<ComponentProps<As>, "id" | "label" | "slot" | "selectable" | "children" | "as">;
|
|
29
|
+
/**
|
|
30
|
+
* Render `as` (a host element or component, `div` by default) carrying the unit's
|
|
31
|
+
* marker: `<SlotGroup id="address" label="Property address">` emits
|
|
32
|
+
* `data-slot-group="address"` and declares the card; `<SlotGroup slot={item}>` over a
|
|
33
|
+
* collection row's `ItemBinding` emits `data-slot-item` — so the editor outlines and
|
|
34
|
+
* edits the container as one sidebar card. Rendering the same unit again (a clone
|
|
35
|
+
* slide, a second layout branch) is just another `SlotGroup` with the same id or
|
|
36
|
+
* binding; every copy is live.
|
|
37
|
+
*/
|
|
38
|
+
declare function SlotGroup<As extends ElementType = "div">(props: SlotGroupProps<As>): ReactNode;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { SlotGroup };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { GroupContext, useGroupProbe } from "./probe-context.js";
|
|
2
|
+
import { ATTR_SLOT_GROUP, ATTR_SLOT_ITEM, ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/slot-group.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Render `as` (a host element or component, `div` by default) carrying the unit's
|
|
8
|
+
* marker: `<SlotGroup id="address" label="Property address">` emits
|
|
9
|
+
* `data-slot-group="address"` and declares the card; `<SlotGroup slot={item}>` over a
|
|
10
|
+
* collection row's `ItemBinding` emits `data-slot-item` — so the editor outlines and
|
|
11
|
+
* edits the container as one sidebar card. Rendering the same unit again (a clone
|
|
12
|
+
* slide, a second layout branch) is just another `SlotGroup` with the same id or
|
|
13
|
+
* binding; every copy is live.
|
|
14
|
+
*/
|
|
15
|
+
function SlotGroup(props) {
|
|
16
|
+
const { id, label, slot, as, selectable = true, children, ...rest } = props;
|
|
17
|
+
const declared = slot === void 0 && id !== void 0 && label !== void 0 ? {
|
|
18
|
+
id,
|
|
19
|
+
label
|
|
20
|
+
} : null;
|
|
21
|
+
useGroupProbe(declared);
|
|
22
|
+
const Tag = as ?? "div";
|
|
23
|
+
const unselectable = selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" };
|
|
24
|
+
if (declared === null) {
|
|
25
|
+
const row = slot;
|
|
26
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
27
|
+
...rest,
|
|
28
|
+
[ATTR_SLOT_ITEM]: row.index,
|
|
29
|
+
...unselectable,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
34
|
+
...rest,
|
|
35
|
+
[ATTR_SLOT_GROUP]: declared.id,
|
|
36
|
+
...unselectable,
|
|
37
|
+
children: /* @__PURE__ */ jsx(GroupContext.Provider, {
|
|
38
|
+
value: declared,
|
|
39
|
+
children
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SlotGroup };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldBinding, SlotBinding } from "./slot-bindings.js";
|
|
2
|
+
import { ComponentProps, ElementType, ReactNode } from "react";
|
|
3
|
+
//#region src/primitives/slot-list.d.ts
|
|
4
|
+
type SlotListOwnProps<D> = {
|
|
5
|
+
/** The collection to mark: a top-level slot binding, or a row field's collection
|
|
6
|
+
* binding (a `list` declared inside a record item). */
|
|
7
|
+
slot: SlotBinding<D> | FieldBinding<D>;
|
|
8
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive
|
|
9
|
+
* mirror) — full identity stays, and the copy is still patched live. */
|
|
10
|
+
selectable?: boolean;
|
|
11
|
+
/** The author's own markup — iteration is plain `bindItems(...).map(...)`; an empty
|
|
12
|
+
* collection renders these children (a placeholder) inside the marked container. */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
type SlotListProps<D, As extends ElementType> = SlotListOwnProps<D> & {
|
|
16
|
+
/** The one element (or component) this primitive renders and marks. */
|
|
17
|
+
as: As;
|
|
18
|
+
} & Omit<ComponentProps<As>, keyof SlotListOwnProps<D> | "as">;
|
|
19
|
+
declare function SlotList<D, As extends ElementType>(props: SlotListProps<D, As>): ReactNode;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SlotList };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useSlotProbe } from "./probe-context.js";
|
|
2
|
+
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
|
+
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/slot-list.tsx
|
|
7
|
+
function SlotList(props) {
|
|
8
|
+
const { slot, as, children, selectable = true, ...rest } = props;
|
|
9
|
+
useSlotProbe(slot);
|
|
10
|
+
const Container = as;
|
|
11
|
+
const containerAttrs = {
|
|
12
|
+
...identityMarkerAttrs(slot),
|
|
13
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
14
|
+
};
|
|
15
|
+
return /* @__PURE__ */ jsx(Container, {
|
|
16
|
+
...rest,
|
|
17
|
+
...containerAttrs,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SlotList };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
2
|
+
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
3
|
+
import { ImageValue } from "../schema/runtime-values.js";
|
|
4
|
+
import { Image } from "./Image.js";
|
|
5
|
+
import { ValueBinding } from "./slot-scalar.js";
|
|
6
|
+
import { Tour } from "./Tour.js";
|
|
7
|
+
import { Video } from "./Video.js";
|
|
8
|
+
import { ComponentProps, ReactNode } from "react";
|
|
9
|
+
//#region src/primitives/slot-media.d.ts
|
|
10
|
+
type SlotImageProps<D> = Omit<ComponentProps<typeof Image>, "value" | "slot" | "mobileBreakpoint"> & {
|
|
11
|
+
slot: ValueBinding<D> & {
|
|
12
|
+
value: ImageValue | VideoValue | TourValue | null | undefined;
|
|
13
|
+
};
|
|
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
|
+
/**
|
|
19
|
+
* Slot.Image — binds `<Image>` to a slot. The mobile-crop breakpoint comes from the
|
|
20
|
+
* slot's OWN declared `crop.mobile.breakpoint`, so the cut the cropper made is the cut
|
|
21
|
+
* the page serves; everything else — `frame`, `fit`, `className`, `rendition`, the HTML
|
|
22
|
+
* passthrough — is `<Image>`'s own prop, with `<Image>`'s own default. See `./Image.js`
|
|
23
|
+
* for the framed/unframed/empty render contract this wraps.
|
|
24
|
+
*
|
|
25
|
+
* **Over a video or tour slot it renders that asset's poster.** A template that wants a
|
|
26
|
+
* still of the video or 3D tour the user picked binds THAT slot to this primitive — there
|
|
27
|
+
* is no separate poster slot to keep in agreement, and no second primitive to learn. The
|
|
28
|
+
* identity marker names that slot, so a click on the poster opens its card and a new pick
|
|
29
|
+
* repatches this element. A poster that does not exist yet — a transcode still running,
|
|
30
|
+
* or a tour provider that published no thumbnail — renders `<Image>`'s ordinary empty
|
|
31
|
+
* rect. `rendition` has no effect here: a poster carries no per-view crop.
|
|
32
|
+
*/
|
|
33
|
+
declare function SlotImage<D extends {
|
|
34
|
+
type: "image" | "video" | "tour";
|
|
35
|
+
}>(props: SlotImageProps<D>): ReactNode;
|
|
36
|
+
type SlotVideoProps<D> = Omit<ComponentProps<typeof Video>, "value" | "playback" | "slot"> & {
|
|
37
|
+
slot: ValueBinding<D> & {
|
|
38
|
+
value: VideoValue | null | undefined;
|
|
39
|
+
};
|
|
40
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
41
|
+
* full identity stays, and the copy is still patched live. */
|
|
42
|
+
selectable?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Slot.Video — binds `<Video>` to a slot: `playback` comes from the slot's own declared
|
|
46
|
+
* `def`; `frame` and the rest are `<Video>`'s own props with its own defaults. See
|
|
47
|
+
* `./Video.js` for the framed/unframed/poster-only render contract.
|
|
48
|
+
*/
|
|
49
|
+
declare function SlotVideo<D extends {
|
|
50
|
+
type: "video";
|
|
51
|
+
}>(props: SlotVideoProps<D>): ReactNode;
|
|
52
|
+
type SlotTourProps<D> = Omit<ComponentProps<typeof Tour>, "value" | "slot"> & {
|
|
53
|
+
slot: ValueBinding<D> & {
|
|
54
|
+
value: TourValue | null | undefined;
|
|
55
|
+
};
|
|
56
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
57
|
+
* full identity stays, and the copy is still patched live. */
|
|
58
|
+
selectable?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Slot.Tour — binds `<Tour>` to a slot. `frame` and the rest are `<Tour>`'s own props
|
|
62
|
+
* with its own defaults. See `./Tour.js` for the framed/unframed/empty render contract.
|
|
63
|
+
*
|
|
64
|
+
* 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.
|
|
66
|
+
*/
|
|
67
|
+
declare function SlotTour<D extends {
|
|
68
|
+
type: "tour";
|
|
69
|
+
}>(props: SlotTourProps<D>): ReactNode;
|
|
70
|
+
//#endregion
|
|
71
|
+
export { SlotImage, SlotTour, SlotVideo };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useSlotProbe } from "./probe-context.js";
|
|
2
|
+
import { ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
3
|
+
import { identityMarkerAttrs } from "./marker-attrs.js";
|
|
4
|
+
import { Image } from "./Image.js";
|
|
5
|
+
import { Tour } from "./Tour.js";
|
|
6
|
+
import { Video } from "./Video.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/primitives/slot-media.tsx
|
|
10
|
+
function declaredMobileBreakpoint(def) {
|
|
11
|
+
return def.crop?.mobile?.breakpoint;
|
|
12
|
+
}
|
|
13
|
+
function declaredPlayback(def) {
|
|
14
|
+
return def.playback ?? null;
|
|
15
|
+
}
|
|
16
|
+
function posterAsImage(value) {
|
|
17
|
+
return {
|
|
18
|
+
photo_id: "",
|
|
19
|
+
url: value.poster,
|
|
20
|
+
alt: value.alt,
|
|
21
|
+
responsive: value.poster_responsive ?? null
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function isPosterSlot(def) {
|
|
25
|
+
const type = def.type;
|
|
26
|
+
return type === "video" || type === "tour";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Slot.Image — binds `<Image>` to a slot. The mobile-crop breakpoint comes from the
|
|
30
|
+
* slot's OWN declared `crop.mobile.breakpoint`, so the cut the cropper made is the cut
|
|
31
|
+
* the page serves; everything else — `frame`, `fit`, `className`, `rendition`, the HTML
|
|
32
|
+
* passthrough — is `<Image>`'s own prop, with `<Image>`'s own default. See `./Image.js`
|
|
33
|
+
* for the framed/unframed/empty render contract this wraps.
|
|
34
|
+
*
|
|
35
|
+
* **Over a video or tour slot it renders that asset's poster.** A template that wants a
|
|
36
|
+
* still of the video or 3D tour the user picked binds THAT slot to this primitive — there
|
|
37
|
+
* is no separate poster slot to keep in agreement, and no second primitive to learn. The
|
|
38
|
+
* identity marker names that slot, so a click on the poster opens its card and a new pick
|
|
39
|
+
* repatches this element. A poster that does not exist yet — a transcode still running,
|
|
40
|
+
* or a tour provider that published no thumbnail — renders `<Image>`'s ordinary empty
|
|
41
|
+
* rect. `rendition` has no effect here: a poster carries no per-view crop.
|
|
42
|
+
*/
|
|
43
|
+
function SlotImage(props) {
|
|
44
|
+
const { slot, selectable = true, ...rest } = props;
|
|
45
|
+
useSlotProbe(slot);
|
|
46
|
+
const markerAttrs = {
|
|
47
|
+
...identityMarkerAttrs(slot),
|
|
48
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
49
|
+
};
|
|
50
|
+
return /* @__PURE__ */ jsx(Image, {
|
|
51
|
+
value: isPosterSlot(slot.def) && slot.value ? posterAsImage(slot.value) : slot.value,
|
|
52
|
+
mobileBreakpoint: declaredMobileBreakpoint(slot.def),
|
|
53
|
+
...rest,
|
|
54
|
+
...markerAttrs
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Slot.Video — binds `<Video>` to a slot: `playback` comes from the slot's own declared
|
|
59
|
+
* `def`; `frame` and the rest are `<Video>`'s own props with its own defaults. See
|
|
60
|
+
* `./Video.js` for the framed/unframed/poster-only render contract.
|
|
61
|
+
*/
|
|
62
|
+
function SlotVideo(props) {
|
|
63
|
+
const { slot, selectable = true, ...rest } = props;
|
|
64
|
+
useSlotProbe(slot);
|
|
65
|
+
const markerAttrs = {
|
|
66
|
+
...identityMarkerAttrs(slot),
|
|
67
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ jsx(Video, {
|
|
70
|
+
value: slot.value,
|
|
71
|
+
playback: declaredPlayback(slot.def),
|
|
72
|
+
...rest,
|
|
73
|
+
...markerAttrs
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Slot.Tour — binds `<Tour>` to a slot. `frame` and the rest are `<Tour>`'s own props
|
|
78
|
+
* with its own defaults. See `./Tour.js` for the framed/unframed/empty render contract.
|
|
79
|
+
*
|
|
80
|
+
* Bind the SAME slot to `Slot.Image` to render the tour's thumbnail instead — or beside
|
|
81
|
+
* this one, for two positions from one selection.
|
|
82
|
+
*/
|
|
83
|
+
function SlotTour(props) {
|
|
84
|
+
const { slot, selectable = true, ...rest } = props;
|
|
85
|
+
useSlotProbe(slot);
|
|
86
|
+
const markerAttrs = {
|
|
87
|
+
...identityMarkerAttrs(slot),
|
|
88
|
+
...selectable ? {} : { [ATTR_SLOT_UNSELECTABLE]: "" }
|
|
89
|
+
};
|
|
90
|
+
return /* @__PURE__ */ jsx(Tour, {
|
|
91
|
+
value: slot.value,
|
|
92
|
+
...rest,
|
|
93
|
+
...markerAttrs
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
export { SlotImage, SlotTour, SlotVideo };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SlotValue } from "../schema/section-props.js";
|
|
2
|
+
import { FieldBinding, SlotBinding } from "./slot-bindings.js";
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementType, ReactNode } from "react";
|
|
4
|
+
//#region src/primitives/slot-scalar.d.ts
|
|
5
|
+
/** What every value primitive accepts: a top-level slot binding OR a row-field binding.
|
|
6
|
+
* The primitive reads `def`, `value`, and the identity (`id` vs `field`), deriving the
|
|
7
|
+
* matching marker attribute (`data-slot-id` vs `data-slot-field`) itself. */
|
|
8
|
+
type ValueBinding<D> = Pick<SlotBinding<D>, "id" | "def" | "value"> | Pick<FieldBinding<D>, "field" | "def" | "value">;
|
|
9
|
+
type TextishOwnProps<D> = {
|
|
10
|
+
slot: ValueBinding<D>;
|
|
11
|
+
/** Author-supplied display text, keyed off the value. Withholds the leaf. */
|
|
12
|
+
format?: (value: NonNullable<SlotValue<D>>) => ReactNode;
|
|
13
|
+
/** Author markup instead of the raw value, in every branch — a blank value renders the
|
|
14
|
+
* marked element with these children inside, so the slot stays selectable. Withholds
|
|
15
|
+
* the leaf. */
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
/** Split the value on `\n` into `<br>`. Keeps the leaf. Ignored under `format`/`children`. */
|
|
18
|
+
multiline?: boolean;
|
|
19
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
20
|
+
* full identity stays, and the copy is still patched live. */
|
|
21
|
+
selectable?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type TextishProps<D, As extends ElementType> = TextishOwnProps<D> & {
|
|
24
|
+
/** The one element (or component) this primitive renders and marks. */
|
|
25
|
+
as: As;
|
|
26
|
+
} & Omit<ComponentPropsWithoutRef<As>, keyof TextishOwnProps<D> | "as">;
|
|
27
|
+
declare function SlotText<D extends {
|
|
28
|
+
type: "text";
|
|
29
|
+
}, As extends ElementType>(props: TextishProps<D, As>): ReactNode;
|
|
30
|
+
declare function SlotNumber<D extends {
|
|
31
|
+
type: "number";
|
|
32
|
+
}, As extends ElementType>(props: TextishProps<D, As>): ReactNode;
|
|
33
|
+
declare function SlotSelect<D extends {
|
|
34
|
+
type: "select";
|
|
35
|
+
}, As extends ElementType>(props: TextishProps<D, As>): ReactNode;
|
|
36
|
+
type UrlOwnProps<D> = {
|
|
37
|
+
slot: ValueBinding<D>;
|
|
38
|
+
/** Author markup inside the marked element (an icon, a label, an empty-state
|
|
39
|
+
* placeholder) — rendered in every branch, blank value included. */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
/** `false` declines selection on THIS copy (a carousel clone, a responsive mirror) —
|
|
42
|
+
* full identity stays, and the copy is still patched live. */
|
|
43
|
+
selectable?: boolean;
|
|
44
|
+
};
|
|
45
|
+
type UrlProps<D, As extends ElementType> = UrlOwnProps<D> & {
|
|
46
|
+
/** The element (or component) the URL lands on. Defaults to `a`. */
|
|
47
|
+
as?: As;
|
|
48
|
+
} & Omit<ComponentPropsWithoutRef<As>, keyof UrlOwnProps<D> | "as">;
|
|
49
|
+
declare function SlotUrl<D extends {
|
|
50
|
+
type: "url";
|
|
51
|
+
}, As extends ElementType = "a">(props: UrlProps<D, As>): ReactNode;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { SlotNumber, SlotSelect, SlotText, SlotUrl, ValueBinding };
|