@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,43 @@
|
|
|
1
|
+
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/primitives/Tour.d.ts
|
|
4
|
+
type Props = Omit<HTMLAttributes<HTMLElement>, "title"> & {
|
|
5
|
+
/** The whole resolved slot value — `slots.walkthrough`, or an element of a tour collection. */
|
|
6
|
+
value: TourValue | null | undefined;
|
|
7
|
+
/** Overrides the value's own alt, which titles the `<iframe>`. */
|
|
8
|
+
alt?: string;
|
|
9
|
+
/** Render inside the kit's frame — a clipped, relatively positioned wrapper the embed
|
|
10
|
+
* fills edge to edge, tinted when there is no embed. It has NO geometry of its own:
|
|
11
|
+
* `className` lands on it and your classes are its whole box. `false` renders a bare
|
|
12
|
+
* `<iframe>` instead. Default `true`. */
|
|
13
|
+
frame?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Tour — the 3D-walkthrough primitive.
|
|
17
|
+
*
|
|
18
|
+
* Takes the whole slot value; the embed `url` and `alt` are read off it. There is one
|
|
19
|
+
* branch, not two: a tour is always a provider embed, so this is `<Video>`'s link half
|
|
20
|
+
* with the `<video>` half — and with it `playback`, `sources`, `fit` and the intrinsic
|
|
21
|
+
* dimensions — gone rather than left inert. `url` is the FINISHED embed src, rewritten
|
|
22
|
+
* once at resolve by `tourEmbedUrl`, so this component is a pure read.
|
|
23
|
+
*
|
|
24
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame` —
|
|
25
|
+
* that your `className` lands on and the iframe absolutely fills. The kit paints no
|
|
26
|
+
* geometry: size the wrapper with your own classes and the embed fills it, same as
|
|
27
|
+
* `<Image>`/`<Video>`.
|
|
28
|
+
*
|
|
29
|
+
* **Empty is a neutral rect, not a poster facade.** With no embed url the framed
|
|
30
|
+
* wrapper renders alone — the same `role="img"` placeholder `<Video>` leaves. The
|
|
31
|
+
* tour's THUMBNAIL is a separate rendering: bind the same slot to `<Slot.Image>`,
|
|
32
|
+
* which renders the poster under this slot's own identity.
|
|
33
|
+
*
|
|
34
|
+
* **The marker is never dropped**: `{...slot.x}` lands on the outermost element in
|
|
35
|
+
* every branch — framed, unframed, and empty — so a tour rendered twice on one slot is
|
|
36
|
+
* selectable from either.
|
|
37
|
+
*
|
|
38
|
+
* `object-fit` is not offered: it has no effect on a replaced-element iframe, and the
|
|
39
|
+
* provider's own player letterboxes inside whatever box it is given.
|
|
40
|
+
*/
|
|
41
|
+
declare function Tour({ value, alt, frame, className, ...rest }: Props): ReactNode;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Tour };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { splitMarkerAttrs } from "./marker-attrs.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/primitives/Tour.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Tour — the 3D-walkthrough primitive.
|
|
7
|
+
*
|
|
8
|
+
* Takes the whole slot value; the embed `url` and `alt` are read off it. There is one
|
|
9
|
+
* branch, not two: a tour is always a provider embed, so this is `<Video>`'s link half
|
|
10
|
+
* with the `<video>` half — and with it `playback`, `sources`, `fit` and the intrinsic
|
|
11
|
+
* dimensions — gone rather than left inert. `url` is the FINISHED embed src, rewritten
|
|
12
|
+
* once at resolve by `tourEmbedUrl`, so this component is a pure read.
|
|
13
|
+
*
|
|
14
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame` —
|
|
15
|
+
* that your `className` lands on and the iframe absolutely fills. The kit paints no
|
|
16
|
+
* geometry: size the wrapper with your own classes and the embed fills it, same as
|
|
17
|
+
* `<Image>`/`<Video>`.
|
|
18
|
+
*
|
|
19
|
+
* **Empty is a neutral rect, not a poster facade.** With no embed url the framed
|
|
20
|
+
* wrapper renders alone — the same `role="img"` placeholder `<Video>` leaves. The
|
|
21
|
+
* tour's THUMBNAIL is a separate rendering: bind the same slot to `<Slot.Image>`,
|
|
22
|
+
* which renders the poster under this slot's own identity.
|
|
23
|
+
*
|
|
24
|
+
* **The marker is never dropped**: `{...slot.x}` lands on the outermost element in
|
|
25
|
+
* every branch — framed, unframed, and empty — so a tour rendered twice on one slot is
|
|
26
|
+
* selectable from either.
|
|
27
|
+
*
|
|
28
|
+
* `object-fit` is not offered: it has no effect on a replaced-element iframe, and the
|
|
29
|
+
* provider's own player letterboxes inside whatever box it is given.
|
|
30
|
+
*/
|
|
31
|
+
function Tour({ value, alt, frame, className, ...rest }) {
|
|
32
|
+
const { markerAttrs, rest: hostAttrs } = splitMarkerAttrs(rest);
|
|
33
|
+
const src = value?.url ? value.url : null;
|
|
34
|
+
const altText = alt ?? value?.alt ?? "";
|
|
35
|
+
const unframedCls = ["tr-image-block", className].filter(Boolean).join(" ");
|
|
36
|
+
const iframeEl = src === null ? null : /* @__PURE__ */ jsx("iframe", {
|
|
37
|
+
src,
|
|
38
|
+
title: altText || "3D tour",
|
|
39
|
+
loading: "lazy",
|
|
40
|
+
allowFullScreen: true,
|
|
41
|
+
allow: "accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; xr-spatial-tracking",
|
|
42
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
43
|
+
className: frame === false ? unframedCls : "absolute inset-0 h-full w-full",
|
|
44
|
+
...frame === false ? {
|
|
45
|
+
...markerAttrs,
|
|
46
|
+
...hostAttrs
|
|
47
|
+
} : {}
|
|
48
|
+
});
|
|
49
|
+
if (frame === false) {
|
|
50
|
+
if (iframeEl) return iframeEl;
|
|
51
|
+
return /* @__PURE__ */ jsx("div", {
|
|
52
|
+
className: unframedCls,
|
|
53
|
+
role: "img",
|
|
54
|
+
"aria-label": altText || void 0,
|
|
55
|
+
...markerAttrs,
|
|
56
|
+
...hostAttrs
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: ["tr-image-frame tr-image-block relative overflow-hidden", className].filter(Boolean).join(" "),
|
|
61
|
+
...iframeEl ? {} : {
|
|
62
|
+
role: "img",
|
|
63
|
+
"aria-label": altText || void 0
|
|
64
|
+
},
|
|
65
|
+
...markerAttrs,
|
|
66
|
+
...hostAttrs,
|
|
67
|
+
children: iframeEl
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Tour };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
2
|
+
import { PlaybackConfig } from "../schema/runtime-values.js";
|
|
3
|
+
import { ReactNode, VideoHTMLAttributes } from "react";
|
|
4
|
+
//#region src/primitives/Video.d.ts
|
|
5
|
+
type Props = Omit<VideoHTMLAttributes<HTMLVideoElement>, "src" | "poster" | "autoPlay" | "loop" | "muted" | "controls" | "playsInline" | "preload" | "width" | "height"> & {
|
|
6
|
+
/** The whole resolved slot value — `slots.tour`, or an element of a video collection. */
|
|
7
|
+
value: VideoValue | null | undefined;
|
|
8
|
+
/** Overrides the value's own alt. Pass `""` for a purely decorative loop. */
|
|
9
|
+
alt?: string;
|
|
10
|
+
/** Render inside the kit's frame — a clipped, relatively positioned wrapper the player
|
|
11
|
+
* fills edge to edge, tinted while there is nothing to show. It has NO geometry of its
|
|
12
|
+
* own: `className` lands on it and your classes are its whole box. `false` renders a
|
|
13
|
+
* bare `<video>` (or iframe) instead. Default `true`. */
|
|
14
|
+
frame?: boolean;
|
|
15
|
+
/** Object-fit for the rendered video. Framed mode defaults to `cover`. */
|
|
16
|
+
fit?: "cover" | "contain";
|
|
17
|
+
/** Author-declared playback (the slot's `playback` field). Absent ⇒ a plain controls player. */
|
|
18
|
+
playback?: PlaybackConfig | null;
|
|
19
|
+
/** A muted, looping, controls-free teaser. Overrides `playback`. Render it alongside a
|
|
20
|
+
* second `<Video>` on the SAME slot to preview before the real player. */
|
|
21
|
+
preview?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Video — the video primitive, whoever hosts the bytes.
|
|
25
|
+
*
|
|
26
|
+
* Takes the whole slot value; `url`, `poster`, `alt` and the intrinsic dimensions are
|
|
27
|
+
* read off it. There is no cropping, no editing, and no responsive ladder: one
|
|
28
|
+
* progressive MP4 is served per hosted video and the poster is baked upstream.
|
|
29
|
+
*
|
|
30
|
+
* **Two branches, discriminated by `value.source`.** An upload renders a `<video>`
|
|
31
|
+
* element over its transcoded rendition; a link renders a lazy provider `<iframe>` over
|
|
32
|
+
* an embed src the resolver already finished. Absent `source` is an upload. Both share
|
|
33
|
+
* one frame container, one poster-only fallback, and one marker spread.
|
|
34
|
+
*
|
|
35
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame` —
|
|
36
|
+
* that your `className` lands on and the player absolutely fills. The kit paints no
|
|
37
|
+
* geometry: size the wrapper with your own classes (an aspect utility, a height) and the
|
|
38
|
+
* player covers it. `frame={false}` hands your classes to the media element itself.
|
|
39
|
+
* Framed, `className` is the only prop that lands on the wrapper — the rest of the bag
|
|
40
|
+
* rides the inner `<video>` one element below it, a link's provider `<iframe>` takes none
|
|
41
|
+
* of it in either mode, and the empty-state box spreads none either — so an element that
|
|
42
|
+
* must carry a styled class and a selector-addressed attribute together takes
|
|
43
|
+
* `frame={false}`, with a wrapping element owning the box.
|
|
44
|
+
*
|
|
45
|
+
* **Playback is author-declared**, from the slot's `playback` config, except under
|
|
46
|
+
* `preview`: a hosted video takes it as `<video>` attributes verbatim, a link as the
|
|
47
|
+
* provider's own player params, as far as that player allows. `autoplay` requires
|
|
48
|
+
* `muted` — enforced on the schema at `check` time, so a video reaching here with
|
|
49
|
+
* `autoplay` is already muted.
|
|
50
|
+
*
|
|
51
|
+
* **The marker is never dropped**: `{...slot.x}` is applied to the outermost element in
|
|
52
|
+
* every branch, so two `<Video>` on one slot (a preview and the real player) are both
|
|
53
|
+
* selectable in the editor.
|
|
54
|
+
*/
|
|
55
|
+
declare function Video({ value, alt, frame, fit, playback, preview, className, ...rest }: Props): ReactNode;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { Video };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { objectFitClass } from "./object-fit.js";
|
|
2
|
+
import { splitMarkerAttrs } from "./marker-attrs.js";
|
|
3
|
+
import { playbackEmbedSrc } from "./embed-playback.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/Video.tsx
|
|
7
|
+
const DEFAULT_PLAYBACK = { controls: true };
|
|
8
|
+
const PREVIEW_PLAYBACK = {
|
|
9
|
+
autoplay: true,
|
|
10
|
+
loop: true,
|
|
11
|
+
muted: true,
|
|
12
|
+
playsinline: true,
|
|
13
|
+
controls: false,
|
|
14
|
+
preload: "metadata"
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Video — the video primitive, whoever hosts the bytes.
|
|
18
|
+
*
|
|
19
|
+
* Takes the whole slot value; `url`, `poster`, `alt` and the intrinsic dimensions are
|
|
20
|
+
* read off it. There is no cropping, no editing, and no responsive ladder: one
|
|
21
|
+
* progressive MP4 is served per hosted video and the poster is baked upstream.
|
|
22
|
+
*
|
|
23
|
+
* **Two branches, discriminated by `value.source`.** An upload renders a `<video>`
|
|
24
|
+
* element over its transcoded rendition; a link renders a lazy provider `<iframe>` over
|
|
25
|
+
* an embed src the resolver already finished. Absent `source` is an upload. Both share
|
|
26
|
+
* one frame container, one poster-only fallback, and one marker spread.
|
|
27
|
+
*
|
|
28
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame` —
|
|
29
|
+
* that your `className` lands on and the player absolutely fills. The kit paints no
|
|
30
|
+
* geometry: size the wrapper with your own classes (an aspect utility, a height) and the
|
|
31
|
+
* player covers it. `frame={false}` hands your classes to the media element itself.
|
|
32
|
+
* Framed, `className` is the only prop that lands on the wrapper — the rest of the bag
|
|
33
|
+
* rides the inner `<video>` one element below it, a link's provider `<iframe>` takes none
|
|
34
|
+
* of it in either mode, and the empty-state box spreads none either — so an element that
|
|
35
|
+
* must carry a styled class and a selector-addressed attribute together takes
|
|
36
|
+
* `frame={false}`, with a wrapping element owning the box.
|
|
37
|
+
*
|
|
38
|
+
* **Playback is author-declared**, from the slot's `playback` config, except under
|
|
39
|
+
* `preview`: a hosted video takes it as `<video>` attributes verbatim, a link as the
|
|
40
|
+
* provider's own player params, as far as that player allows. `autoplay` requires
|
|
41
|
+
* `muted` — enforced on the schema at `check` time, so a video reaching here with
|
|
42
|
+
* `autoplay` is already muted.
|
|
43
|
+
*
|
|
44
|
+
* **The marker is never dropped**: `{...slot.x}` is applied to the outermost element in
|
|
45
|
+
* every branch, so two `<Video>` on one slot (a preview and the real player) are both
|
|
46
|
+
* selectable in the editor.
|
|
47
|
+
*/
|
|
48
|
+
function Video({ value, alt, frame, fit, playback, preview, className, ...rest }) {
|
|
49
|
+
const { markerAttrs, rest: videoAttrs } = splitMarkerAttrs(rest);
|
|
50
|
+
const src = value?.url ? value.url : null;
|
|
51
|
+
const poster = value?.poster ?? null;
|
|
52
|
+
const altText = alt ?? value?.alt ?? "";
|
|
53
|
+
const p = preview ? PREVIEW_PLAYBACK : playback ?? DEFAULT_PLAYBACK;
|
|
54
|
+
const objectFit = objectFitClass(fit ?? "cover");
|
|
55
|
+
const unframedCls = [
|
|
56
|
+
"tr-image-block",
|
|
57
|
+
fit ? objectFitClass(fit) : null,
|
|
58
|
+
className
|
|
59
|
+
].filter(Boolean).join(" ");
|
|
60
|
+
const mediaEl = src === null ? null : value?.source === "link" ? /* @__PURE__ */ jsx("iframe", {
|
|
61
|
+
src: playbackEmbedSrc(src, value.provider, p),
|
|
62
|
+
title: altText || "Video",
|
|
63
|
+
loading: "lazy",
|
|
64
|
+
allowFullScreen: true,
|
|
65
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",
|
|
66
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
67
|
+
className: frame === false ? unframedCls : "absolute inset-0 h-full w-full",
|
|
68
|
+
...frame === false ? markerAttrs : {}
|
|
69
|
+
}) : /* @__PURE__ */ jsx("video", {
|
|
70
|
+
src,
|
|
71
|
+
poster: poster ?? void 0,
|
|
72
|
+
"aria-label": altText || void 0,
|
|
73
|
+
width: value?.width,
|
|
74
|
+
height: value?.height,
|
|
75
|
+
autoPlay: p.autoplay,
|
|
76
|
+
loop: p.loop,
|
|
77
|
+
muted: p.muted,
|
|
78
|
+
controls: p.controls,
|
|
79
|
+
playsInline: p.playsinline,
|
|
80
|
+
preload: p.preload,
|
|
81
|
+
className: frame === false ? unframedCls : `absolute inset-0 h-full w-full ${objectFit}`,
|
|
82
|
+
...frame === false ? markerAttrs : {},
|
|
83
|
+
...videoAttrs
|
|
84
|
+
});
|
|
85
|
+
if (frame === false) {
|
|
86
|
+
if (mediaEl) return mediaEl;
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: unframedCls,
|
|
89
|
+
role: "img",
|
|
90
|
+
"aria-label": altText || void 0,
|
|
91
|
+
...markerAttrs
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const containerCls = ["tr-image-frame tr-image-block relative overflow-hidden", className].filter(Boolean).join(" ");
|
|
95
|
+
if (!mediaEl) return /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: containerCls,
|
|
97
|
+
role: "img",
|
|
98
|
+
"aria-label": altText || void 0,
|
|
99
|
+
...markerAttrs,
|
|
100
|
+
children: poster ? /* @__PURE__ */ jsx("img", {
|
|
101
|
+
src: poster,
|
|
102
|
+
alt: "",
|
|
103
|
+
loading: "lazy",
|
|
104
|
+
decoding: "async",
|
|
105
|
+
className: `absolute inset-0 h-full w-full ${objectFit}`
|
|
106
|
+
}) : null
|
|
107
|
+
});
|
|
108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: containerCls,
|
|
110
|
+
...markerAttrs,
|
|
111
|
+
children: mediaEl
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { Video };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/primitives/embed-playback.ts
|
|
2
|
+
function providerOf(url, declared) {
|
|
3
|
+
const hint = (declared ?? url.hostname).toLowerCase();
|
|
4
|
+
if (hint.includes("youtube") || hint.includes("youtu.be")) return "youtube";
|
|
5
|
+
if (hint.includes("vimeo")) return "vimeo";
|
|
6
|
+
return "other";
|
|
7
|
+
}
|
|
8
|
+
/** The embed src with `playback` written onto it as the provider's player params. */
|
|
9
|
+
function playbackEmbedSrc(src, provider, playback) {
|
|
10
|
+
let url;
|
|
11
|
+
try {
|
|
12
|
+
url = new URL(src);
|
|
13
|
+
} catch {
|
|
14
|
+
return src;
|
|
15
|
+
}
|
|
16
|
+
const autoplay = playback.autoplay === true;
|
|
17
|
+
const muted = playback.muted === true;
|
|
18
|
+
const loop = playback.loop === true;
|
|
19
|
+
const chromeless = playback.controls === false;
|
|
20
|
+
if (!autoplay && !muted && !loop && !chromeless && playback.playsinline !== true) return src;
|
|
21
|
+
const q = url.searchParams;
|
|
22
|
+
if (autoplay) q.set("autoplay", "1");
|
|
23
|
+
if (loop) q.set("loop", "1");
|
|
24
|
+
if (chromeless) q.set("controls", "0");
|
|
25
|
+
switch (providerOf(url, provider)) {
|
|
26
|
+
case "youtube":
|
|
27
|
+
if (muted) q.set("mute", "1");
|
|
28
|
+
if (playback.playsinline) q.set("playsinline", "1");
|
|
29
|
+
if (chromeless) {
|
|
30
|
+
q.set("disablekb", "1");
|
|
31
|
+
q.set("iv_load_policy", "3");
|
|
32
|
+
}
|
|
33
|
+
if (loop) {
|
|
34
|
+
const id = url.pathname.split("/").filter(Boolean).at(-1);
|
|
35
|
+
if (id) q.set("playlist", id);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case "vimeo":
|
|
39
|
+
if (muted) q.set("muted", "1");
|
|
40
|
+
if (autoplay && muted && chromeless) q.set("background", "1");
|
|
41
|
+
break;
|
|
42
|
+
case "other":
|
|
43
|
+
if (muted) q.set("muted", "1");
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return url.toString();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { playbackEmbedSrc };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems } from "./slot-bindings.js";
|
|
2
|
+
import { FrameShell } from "./FrameShell.js";
|
|
3
|
+
import { Image } from "./Image.js";
|
|
4
|
+
import { PicturePlan, PictureSourceSpec } from "./picture-sources.js";
|
|
5
|
+
import { Section } from "./Section.js";
|
|
6
|
+
import { SlotGroup } from "./slot-group.js";
|
|
7
|
+
import { ValueBinding } from "./slot-scalar.js";
|
|
8
|
+
import { Tour } from "./Tour.js";
|
|
9
|
+
import { Video } from "./Video.js";
|
|
10
|
+
import { Slot } from "./slot.js";
|
|
11
|
+
export { type BoundSlotValue, type FieldBinding, FrameShell, Image, type ItemBinding, type PicturePlan, type PictureSourceSpec, type RowBinding, Section, Slot, type SlotBinding, type SlotBindingMap, SlotGroup, Tour, type ValueBinding, Video, bindItems };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ATTR_SLOT_FIELD, ATTR_SLOT_GROUP, ATTR_SLOT_ID, ATTR_SLOT_ITEM, ATTR_SLOT_TEXT_LEAF, ATTR_SLOT_UNSELECTABLE } from "../packages/internal/template-contracts/dist/markers.js";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/marker-attrs.ts
|
|
4
|
+
/**
|
|
5
|
+
* The marker attribute a binding's identity derives to: `data-slot-id` for a slot
|
|
6
|
+
* binding (it carries `id`), `data-slot-field` for a row-field binding (it carries
|
|
7
|
+
* `field`). Structural discrimination — only a slot binding has `id`.
|
|
8
|
+
*/
|
|
9
|
+
function identityMarkerAttrs(binding) {
|
|
10
|
+
return "id" in binding ? { [ATTR_SLOT_ID]: binding.id } : { [ATTR_SLOT_FIELD]: binding.field };
|
|
11
|
+
}
|
|
12
|
+
const MARKER_ATTRS = [
|
|
13
|
+
ATTR_SLOT_ID,
|
|
14
|
+
ATTR_SLOT_TEXT_LEAF,
|
|
15
|
+
ATTR_SLOT_ITEM,
|
|
16
|
+
ATTR_SLOT_FIELD,
|
|
17
|
+
ATTR_SLOT_GROUP,
|
|
18
|
+
ATTR_SLOT_UNSELECTABLE
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Splits spread marker attributes off a component's remaining props.
|
|
22
|
+
*
|
|
23
|
+
* `Slot.Image`/`Slot.Video` deliver the marker through the same prop bag as `className`
|
|
24
|
+
* and `loading`, but the marker belongs on the element the component makes its own: the
|
|
25
|
+
* framed wrapper, the bare `<img>`/`<video>`, or the empty-state box that renders no
|
|
26
|
+
* media element at all. Every branch applies `markerAttrs`, which is what makes the
|
|
27
|
+
* marker impossible to drop — though not always to the branch's ROOT. `<Image>` unframed
|
|
28
|
+
* keeps it on the `<img>` inside any `<picture>` it generates (a `display: contents`
|
|
29
|
+
* wrapper, so the `<img>` is still the element that owns the layout), so a consumer
|
|
30
|
+
* looking for it must query descendants too.
|
|
31
|
+
*/
|
|
32
|
+
function splitMarkerAttrs(props) {
|
|
33
|
+
const markerAttrs = {};
|
|
34
|
+
const rest = {};
|
|
35
|
+
for (const [key, value] of Object.entries(props)) if (MARKER_ATTRS.includes(key)) markerAttrs[key] = value;
|
|
36
|
+
else rest[key] = value;
|
|
37
|
+
return {
|
|
38
|
+
markerAttrs,
|
|
39
|
+
rest
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { identityMarkerAttrs, splitMarkerAttrs };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/primitives/picture-sources.d.ts
|
|
2
|
+
/** One `<source>` element's attributes within a `PicturePlan`. */
|
|
3
|
+
type PictureSourceSpec = {
|
|
4
|
+
type?: string;
|
|
5
|
+
media?: string;
|
|
6
|
+
srcSet: string;
|
|
7
|
+
sizes?: string;
|
|
8
|
+
};
|
|
9
|
+
/** The `<picture>` markup plan the `Image` primitive renders from: an ordered list of `<source>` specs plus the trailing `<img>`'s own srcset/sizes/dimensions. */
|
|
10
|
+
type PicturePlan = {
|
|
11
|
+
/**
|
|
12
|
+
* Ordered <source> specs: mobile (media-gated) first, then desktop. May be empty
|
|
13
|
+
* even with a valid plan (a single-format descriptor puts everything on the <img>);
|
|
14
|
+
* `sources: []` AND no `imgSrcSet` is the "no responsive — caller degrades" signal.
|
|
15
|
+
*/
|
|
16
|
+
sources: PictureSourceSpec[];
|
|
17
|
+
/** srcset for the trailing <img> (the desktop base raster). */
|
|
18
|
+
imgSrcSet?: string;
|
|
19
|
+
imgSizes?: string;
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { PicturePlan, PictureSourceSpec };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/primitives/picture-sources.ts
|
|
2
|
+
function capSrcset(srcset, maxRungWidth) {
|
|
3
|
+
const entries = srcset.split(",").map((s) => s.trim()).filter(Boolean).map((cand) => {
|
|
4
|
+
const m = cand.match(/(\d+)w\s*$/);
|
|
5
|
+
return {
|
|
6
|
+
cand,
|
|
7
|
+
w: m ? Number(m[1]) : Number.POSITIVE_INFINITY
|
|
8
|
+
};
|
|
9
|
+
}).sort((a, b) => a.w - b.w);
|
|
10
|
+
if (entries.length === 0) return srcset;
|
|
11
|
+
if (maxRungWidth == null) return entries.map((event) => event.cand).join(", ");
|
|
12
|
+
const kept = entries.filter((event) => event.w <= maxRungWidth);
|
|
13
|
+
return (kept.length > 0 ? kept : [entries[0]]).map((event) => event.cand).join(", ");
|
|
14
|
+
}
|
|
15
|
+
function buildPictureSources(args) {
|
|
16
|
+
const { responsive, responsiveMobile, sizes, maxRungWidth, mobileBreakpoint } = args;
|
|
17
|
+
if (!responsive || responsive.sources.length === 0) return { sources: [] };
|
|
18
|
+
const sources = [];
|
|
19
|
+
if (responsiveMobile && responsiveMobile.sources.length > 0 && mobileBreakpoint) {
|
|
20
|
+
const media = `(max-width: ${mobileBreakpoint - 1}px)`;
|
|
21
|
+
const m = responsiveMobile.sources;
|
|
22
|
+
const mBase = m[m.length - 1];
|
|
23
|
+
for (const s of m.slice(0, -1)) sources.push({
|
|
24
|
+
type: s.type,
|
|
25
|
+
media,
|
|
26
|
+
srcSet: capSrcset(s.srcset, maxRungWidth),
|
|
27
|
+
sizes
|
|
28
|
+
});
|
|
29
|
+
sources.push({
|
|
30
|
+
media,
|
|
31
|
+
srcSet: capSrcset(mBase.srcset, maxRungWidth),
|
|
32
|
+
sizes
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const d = responsive.sources;
|
|
36
|
+
const dBase = d[d.length - 1];
|
|
37
|
+
for (const s of d.slice(0, -1)) sources.push({
|
|
38
|
+
type: s.type,
|
|
39
|
+
srcSet: capSrcset(s.srcset, maxRungWidth),
|
|
40
|
+
sizes
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
sources,
|
|
44
|
+
imgSrcSet: capSrcset(dBase.srcset, maxRungWidth),
|
|
45
|
+
imgSizes: sizes,
|
|
46
|
+
width: responsive.width,
|
|
47
|
+
height: responsive.height
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { buildPictureSources };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/probe-context.ts
|
|
4
|
+
/** The active probe, or `null` in an ordinary render. */
|
|
5
|
+
const ProbeContext = createContext(null);
|
|
6
|
+
const GroupContext = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Called by every value-rendering primitive with the binding it marks. Under the groups
|
|
9
|
+
* probe, a SLOT binding (one carrying `id`) rendered inside a declared group records
|
|
10
|
+
* its membership; a row-field binding (`field`) is not a slot and records nothing.
|
|
11
|
+
*/
|
|
12
|
+
function useSlotProbe(binding) {
|
|
13
|
+
const probe = useContext(ProbeContext);
|
|
14
|
+
const group = useContext(GroupContext);
|
|
15
|
+
if (probe?.kind === "groups" && group !== null && "id" in binding) probe.member(binding.id, group.id);
|
|
16
|
+
}
|
|
17
|
+
/** Called by `SlotGroup` in its declared form: records the card under the groups probe. */
|
|
18
|
+
function useGroupProbe(group) {
|
|
19
|
+
const probe = useContext(ProbeContext);
|
|
20
|
+
if (probe?.kind === "groups" && group !== null) probe.group(group.id, group.label);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { GroupContext, ProbeContext, useGroupProbe, useSlotProbe };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { SectionSchemaShape } from "../schema/section-schema.js";
|
|
2
|
+
import { RowValue, SlotValue } from "../schema/section-props.js";
|
|
3
|
+
//#region src/primitives/slot-bindings.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The value shape a binding holds after bind-time normalization: `SlotValue`
|
|
6
|
+
* for every kind except a RECORD list, whose bound rows are always the
|
|
7
|
+
* declared-fields row (`RowValue`) — row normalization keeps the
|
|
8
|
+
* editor-stamped `id` plus each DECLARED field and drops everything else, so a
|
|
9
|
+
* whole-row-baked slot's projection-only fields (which `SlotValue` types on
|
|
10
|
+
* the raw slot value) never survive into a binding. Read those off the raw
|
|
11
|
+
* prop, never off a binding's value.
|
|
12
|
+
*/
|
|
13
|
+
type BoundSlotValue<D> = D extends {
|
|
14
|
+
type: "list";
|
|
15
|
+
fields: infer I;
|
|
16
|
+
} ? RowValue<I>[] : SlotValue<D>;
|
|
17
|
+
/**
|
|
18
|
+
* One slot: its id, the definition the section declared for it, and its runtime value.
|
|
19
|
+
*
|
|
20
|
+
* The slot primitives own the marker — they derive it from `id`, so it cannot be
|
|
21
|
+
* forgotten and cannot land anywhere else. The binding must never be spread onto an
|
|
22
|
+
* element (`id`/`def`/`value` are not DOM attributes).
|
|
23
|
+
*/
|
|
24
|
+
type SlotBinding<D> = {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly def: D;
|
|
27
|
+
readonly value: BoundSlotValue<D>;
|
|
28
|
+
/** Derived, never declared: the structural non-blank test of the normalized
|
|
29
|
+
* value — `""`/`null`/the blank video record/`[]` are the per-kind blanks. */
|
|
30
|
+
readonly present: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* One field of one row of a record list — the fourth dimension of slot identity.
|
|
34
|
+
*
|
|
35
|
+
* `slot` + `item` + `field` is the full address; because a record cannot nest
|
|
36
|
+
* inside a record, no fifth dimension can exist and the tuple
|
|
37
|
+
* stays fixed.
|
|
38
|
+
*/
|
|
39
|
+
type FieldBinding<D> = {
|
|
40
|
+
readonly slot: string;
|
|
41
|
+
readonly item: number;
|
|
42
|
+
readonly field: string;
|
|
43
|
+
readonly def: D;
|
|
44
|
+
readonly value: SlotValue<D>;
|
|
45
|
+
/** Same derivation as {@link SlotBinding.present}, over this field's value. */
|
|
46
|
+
readonly present: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** The map `bindSlots` returns: one binding per declared slot, keyed by slot id. */
|
|
49
|
+
type SlotBindingMap<S extends SectionSchemaShape> = { readonly [K in keyof S["slots"]]: SlotBinding<S["slots"][K]>; };
|
|
50
|
+
type RowFieldDefs<D> = D extends {
|
|
51
|
+
type: "list";
|
|
52
|
+
fields: infer I;
|
|
53
|
+
} ? I : never;
|
|
54
|
+
/** The field bindings for one row: one per field the row's `fields` record declares. */
|
|
55
|
+
type RowBinding<D> = { readonly [F in keyof RowFieldDefs<D>]: FieldBinding<RowFieldDefs<D>[F]>; };
|
|
56
|
+
type ItemValue<D> = NonNullable<BoundSlotValue<D>> extends readonly (infer E)[] ? E : unknown;
|
|
57
|
+
/**
|
|
58
|
+
* One item of a list slot: the list's identity, the item's index — which is
|
|
59
|
+
* also its `data-slot-item` value — and its raw runtime value. A RECORD item
|
|
60
|
+
* additionally carries `fields`, one {@link FieldBinding} per declared row
|
|
61
|
+
* field, so each field renders through its own binding.
|
|
62
|
+
*
|
|
63
|
+
* Plain JSON like every other binding: an item crosses component and island
|
|
64
|
+
* boundaries as an ordinary prop. `Slot.Group` accepts one directly to mark a
|
|
65
|
+
* list row.
|
|
66
|
+
*/
|
|
67
|
+
type ItemBinding<D> = {
|
|
68
|
+
readonly slot: string;
|
|
69
|
+
readonly index: number;
|
|
70
|
+
readonly value: ItemValue<D>;
|
|
71
|
+
/** Same derivation as {@link SlotBinding.present}, over this member's value —
|
|
72
|
+
* a record row is present when any of its declared fields is. */
|
|
73
|
+
readonly present: boolean;
|
|
74
|
+
} & (D extends {
|
|
75
|
+
type: "list";
|
|
76
|
+
fields: Record<string, unknown>;
|
|
77
|
+
} ? {
|
|
78
|
+
readonly fields: RowBinding<D>;
|
|
79
|
+
} : {
|
|
80
|
+
readonly fields?: undefined;
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Bind a list slot's items for iteration — the one idiom for rendering anything
|
|
84
|
+
* multi-item: `bindItems(slot.units).map((unit) => …)` is an ordinary React
|
|
85
|
+
* array, so clones, splits, and free-form markup are plain JavaScript rather
|
|
86
|
+
* than list-primitive modes.
|
|
87
|
+
*
|
|
88
|
+
* Accepts a top-level list binding or a row field's list binding (a `list`
|
|
89
|
+
* declared inside a record item); a non-list binding is a compile error. An
|
|
90
|
+
* empty or absent value yields `[]`.
|
|
91
|
+
*/
|
|
92
|
+
declare function bindItems<D extends {
|
|
93
|
+
type: "list";
|
|
94
|
+
}>(binding: SlotBinding<D> | FieldBinding<D>): ItemBinding<D>[];
|
|
95
|
+
//#endregion
|
|
96
|
+
export { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems };
|