@jam-overture/loom 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +743 -0
- package/dist/catalogue.d.ts +70 -0
- package/dist/catalogue.js +88 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +83 -0
- package/dist/cli/filesystem.d.ts +15 -0
- package/dist/cli/filesystem.js +31 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +12 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +30 -0
- package/dist/cli/namespace.d.ts +40 -0
- package/dist/cli/namespace.js +40 -0
- package/dist/cli/plan.d.ts +84 -0
- package/dist/cli/plan.js +113 -0
- package/dist/cli/run.d.ts +17 -0
- package/dist/cli/run.js +75 -0
- package/dist/cli/templates.d.ts +43 -0
- package/dist/cli/templates.js +134 -0
- package/dist/closed-set.d.ts +34 -0
- package/dist/closed-set.js +34 -0
- package/dist/data/adapter.d.ts +123 -0
- package/dist/data/adapter.js +91 -0
- package/dist/data/binding.d.ts +48 -0
- package/dist/data/binding.js +39 -0
- package/dist/data/catalogue.d.ts +26 -0
- package/dist/data/catalogue.js +6 -0
- package/dist/data/index.d.ts +14 -0
- package/dist/data/index.js +14 -0
- package/dist/data/plan.d.ts +58 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +91 -0
- package/dist/data/resolution.js +96 -0
- package/dist/data/resolve.d.ts +46 -0
- package/dist/data/resolve.js +37 -0
- package/dist/data/source.d.ts +40 -0
- package/dist/data/source.js +45 -0
- package/dist/deadline.d.ts +57 -0
- package/dist/deadline.js +78 -0
- package/dist/frame/catalogue.d.ts +24 -0
- package/dist/frame/catalogue.js +5 -0
- package/dist/frame/index.d.ts +12 -0
- package/dist/frame/index.js +12 -0
- package/dist/frame/origin.d.ts +87 -0
- package/dist/frame/origin.js +114 -0
- package/dist/frame/resolution.d.ts +85 -0
- package/dist/frame/resolution.js +79 -0
- package/dist/grammar.d.ts +26 -0
- package/dist/grammar.js +28 -0
- package/dist/ids.d.ts +57 -0
- package/dist/ids.js +104 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/interactivity.d.ts +50 -0
- package/dist/interactivity.js +22 -0
- package/dist/interpretation/anthropic.d.ts +22 -0
- package/dist/interpretation/anthropic.js +76 -0
- package/dist/interpretation/client.d.ts +83 -0
- package/dist/interpretation/client.js +2 -0
- package/dist/interpretation/draft.d.ts +234 -0
- package/dist/interpretation/draft.js +84 -0
- package/dist/interpretation/index.d.ts +15 -0
- package/dist/interpretation/index.js +15 -0
- package/dist/interpretation/interpreter.d.ts +62 -0
- package/dist/interpretation/interpreter.js +151 -0
- package/dist/interpretation/materialize.d.ts +42 -0
- package/dist/interpretation/materialize.js +107 -0
- package/dist/interpretation/prompt.d.ts +229 -0
- package/dist/interpretation/prompt.js +285 -0
- package/dist/interpretation/render.d.ts +76 -0
- package/dist/interpretation/render.js +272 -0
- package/dist/interpretation/schema.d.ts +49 -0
- package/dist/interpretation/schema.js +131 -0
- package/dist/json.d.ts +35 -0
- package/dist/json.js +11 -0
- package/dist/paging.d.ts +60 -0
- package/dist/paging.js +49 -0
- package/dist/primitive-type.d.ts +32 -0
- package/dist/primitive-type.js +39 -0
- package/dist/render/addressing.d.ts +59 -0
- package/dist/render/addressing.js +60 -0
- package/dist/render/anchor.d.ts +105 -0
- package/dist/render/anchor.js +84 -0
- package/dist/render/behaviour-adjust.d.ts +62 -0
- package/dist/render/behaviour-adjust.js +78 -0
- package/dist/render/behaviour-copy.d.ts +53 -0
- package/dist/render/behaviour-copy.js +75 -0
- package/dist/render/behaviour-disclose.d.ts +74 -0
- package/dist/render/behaviour-disclose.js +77 -0
- package/dist/render/behaviour-present.d.ts +123 -0
- package/dist/render/behaviour-present.js +173 -0
- package/dist/render/behaviour.d.ts +243 -0
- package/dist/render/behaviour.js +284 -0
- package/dist/render/control.d.ts +81 -0
- package/dist/render/control.js +80 -0
- package/dist/render/decorative.d.ts +62 -0
- package/dist/render/decorative.js +2 -0
- package/dist/render/diagnostics.d.ts +260 -0
- package/dist/render/diagnostics.js +61 -0
- package/dist/render/disclosed.d.ts +37 -0
- package/dist/render/disclosed.js +37 -0
- package/dist/render/editable.d.ts +34 -0
- package/dist/render/editable.js +35 -0
- package/dist/render/frame.d.ts +42 -0
- package/dist/render/frame.js +31 -0
- package/dist/render/index.d.ts +35 -0
- package/dist/render/index.js +35 -0
- package/dist/render/inline-variables.d.ts +77 -0
- package/dist/render/inline-variables.js +220 -0
- package/dist/render/presented.d.ts +82 -0
- package/dist/render/presented.js +82 -0
- package/dist/render/primitive.d.ts +228 -0
- package/dist/render/primitive.js +36 -0
- package/dist/render/props.d.ts +48 -0
- package/dist/render/props.js +2 -0
- package/dist/render/reads.d.ts +73 -0
- package/dist/render/reads.js +45 -0
- package/dist/render/render.d.ts +164 -0
- package/dist/render/render.js +571 -0
- package/dist/render/request.d.ts +111 -0
- package/dist/render/request.js +60 -0
- package/dist/render/text.d.ts +91 -0
- package/dist/render/text.js +44 -0
- package/dist/render/theme.d.ts +61 -0
- package/dist/render/theme.js +52 -0
- package/dist/reserved-props.d.ts +35 -0
- package/dist/reserved-props.js +45 -0
- package/dist/result.d.ts +27 -0
- package/dist/result.js +30 -0
- package/dist/role.d.ts +71 -0
- package/dist/role.js +22 -0
- package/dist/runtime/analysis.d.ts +149 -0
- package/dist/runtime/analysis.js +187 -0
- package/dist/runtime/assessment.d.ts +35 -0
- package/dist/runtime/assessment.js +13 -0
- package/dist/runtime/disposition.d.ts +102 -0
- package/dist/runtime/disposition.js +59 -0
- package/dist/runtime/events.d.ts +187 -0
- package/dist/runtime/events.js +7 -0
- package/dist/runtime/gate.d.ts +43 -0
- package/dist/runtime/gate.js +169 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/index.js +27 -0
- package/dist/runtime/intent.d.ts +60 -0
- package/dist/runtime/intent.js +36 -0
- package/dist/runtime/interpreter.d.ts +117 -0
- package/dist/runtime/interpreter.js +46 -0
- package/dist/runtime/inverse-interpreter.d.ts +90 -0
- package/dist/runtime/inverse-interpreter.js +56 -0
- package/dist/runtime/inverse.d.ts +87 -0
- package/dist/runtime/inverse.js +48 -0
- package/dist/runtime/narration.d.ts +24 -0
- package/dist/runtime/narration.js +36 -0
- package/dist/runtime/nesting.d.ts +31 -0
- package/dist/runtime/nesting.js +46 -0
- package/dist/runtime/pipeline.d.ts +124 -0
- package/dist/runtime/pipeline.js +178 -0
- package/dist/runtime/policy-fingerprint.d.ts +29 -0
- package/dist/runtime/policy-fingerprint.js +119 -0
- package/dist/runtime/policy-source.d.ts +42 -0
- package/dist/runtime/policy-source.js +8 -0
- package/dist/runtime/policy.d.ts +156 -0
- package/dist/runtime/policy.js +107 -0
- package/dist/runtime/proposal.d.ts +423 -0
- package/dist/runtime/proposal.js +109 -0
- package/dist/runtime/redirection.d.ts +53 -0
- package/dist/runtime/redirection.js +38 -0
- package/dist/runtime/repointing.d.ts +71 -0
- package/dist/runtime/repointing.js +0 -0
- package/dist/runtime/reversibility.d.ts +36 -0
- package/dist/runtime/reversibility.js +39 -0
- package/dist/runtime/stake-level.d.ts +33 -0
- package/dist/runtime/stake-level.js +58 -0
- package/dist/runtime/stakes.d.ts +47 -0
- package/dist/runtime/stakes.js +305 -0
- package/dist/runtime/vocabulary.d.ts +122 -0
- package/dist/runtime/vocabulary.js +87 -0
- package/dist/sdk/audit.d.ts +195 -0
- package/dist/sdk/audit.js +128 -0
- package/dist/sdk/catalogue.d.ts +37 -0
- package/dist/sdk/catalogue.js +16 -0
- package/dist/sdk/conformance.d.ts +342 -0
- package/dist/sdk/conformance.js +494 -0
- package/dist/sdk/copy.d.ts +105 -0
- package/dist/sdk/copy.js +90 -0
- package/dist/sdk/definition.d.ts +242 -0
- package/dist/sdk/definition.js +64 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.js +19 -0
- package/dist/sdk/interactivity.d.ts +29 -0
- package/dist/sdk/interactivity.js +34 -0
- package/dist/sdk/pairings.d.ts +124 -0
- package/dist/sdk/pairings.js +81 -0
- package/dist/sdk/registry.d.ts +162 -0
- package/dist/sdk/registry.js +329 -0
- package/dist/sdk/selection.d.ts +46 -0
- package/dist/sdk/selection.js +24 -0
- package/dist/sdk/text.d.ts +100 -0
- package/dist/sdk/text.js +105 -0
- package/dist/sdk/vocabulary.d.ts +39 -0
- package/dist/sdk/vocabulary.js +36 -0
- package/dist/signals/broadcast.d.ts +134 -0
- package/dist/signals/broadcast.js +451 -0
- package/dist/signals/collect.d.ts +184 -0
- package/dist/signals/collect.js +196 -0
- package/dist/signals/deliver.d.ts +64 -0
- package/dist/signals/deliver.js +85 -0
- package/dist/signals/fold.d.ts +112 -0
- package/dist/signals/fold.js +76 -0
- package/dist/signals/index.d.ts +31 -0
- package/dist/signals/index.js +31 -0
- package/dist/signals/ingest.d.ts +51 -0
- package/dist/signals/ingest.js +70 -0
- package/dist/signals/intake.d.ts +149 -0
- package/dist/signals/intake.js +154 -0
- package/dist/signals/journal.d.ts +94 -0
- package/dist/signals/journal.js +11 -0
- package/dist/signals/kinds.d.ts +22 -0
- package/dist/signals/kinds.js +22 -0
- package/dist/signals/ledger.d.ts +46 -0
- package/dist/signals/ledger.js +81 -0
- package/dist/signals/memory.d.ts +17 -0
- package/dist/signals/memory.js +99 -0
- package/dist/signals/migrate.d.ts +27 -0
- package/dist/signals/migrate.js +78 -0
- package/dist/signals/postgres.d.ts +7 -0
- package/dist/signals/postgres.js +295 -0
- package/dist/signals/rollup.d.ts +142 -0
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +534 -0
- package/dist/signals/schema.js +92 -0
- package/dist/signals/signal.d.ts +381 -0
- package/dist/signals/signal.js +150 -0
- package/dist/signals/tally.d.ts +70 -0
- package/dist/signals/tally.js +2 -0
- package/dist/signals/view.d.ts +51 -0
- package/dist/signals/view.js +54 -0
- package/dist/store/attribution.d.ts +125 -0
- package/dist/store/attribution.js +116 -0
- package/dist/store/database.d.ts +14 -0
- package/dist/store/database.js +2 -0
- package/dist/store/driver.d.ts +29 -0
- package/dist/store/driver.js +39 -0
- package/dist/store/errors.d.ts +56 -0
- package/dist/store/errors.js +37 -0
- package/dist/store/index.d.ts +16 -0
- package/dist/store/index.js +16 -0
- package/dist/store/memory.d.ts +3 -0
- package/dist/store/memory.js +115 -0
- package/dist/store/migrate.d.ts +54 -0
- package/dist/store/migrate.js +122 -0
- package/dist/store/postgres-holds.d.ts +4 -0
- package/dist/store/postgres-holds.js +192 -0
- package/dist/store/postgres.d.ts +8 -0
- package/dist/store/postgres.js +262 -0
- package/dist/store/replay.d.ts +94 -0
- package/dist/store/replay.js +82 -0
- package/dist/store/revert.d.ts +116 -0
- package/dist/store/revert.js +243 -0
- package/dist/store/schema.d.ts +371 -0
- package/dist/store/schema.js +78 -0
- package/dist/store/source.d.ts +23 -0
- package/dist/store/source.js +37 -0
- package/dist/store/store.d.ts +231 -0
- package/dist/store/store.js +52 -0
- package/dist/store/undone.d.ts +18 -0
- package/dist/store/undone.js +89 -0
- package/dist/submit/catalogue.d.ts +20 -0
- package/dist/submit/catalogue.js +5 -0
- package/dist/submit/declaration.d.ts +39 -0
- package/dist/submit/declaration.js +30 -0
- package/dist/submit/endpoint.d.ts +131 -0
- package/dist/submit/endpoint.js +160 -0
- package/dist/submit/index.d.ts +13 -0
- package/dist/submit/index.js +13 -0
- package/dist/submit/plan.d.ts +49 -0
- package/dist/submit/plan.js +47 -0
- package/dist/submit/resolution.d.ts +61 -0
- package/dist/submit/resolution.js +64 -0
- package/dist/submit/resolve.d.ts +45 -0
- package/dist/submit/resolve.js +36 -0
- package/dist/telemetry/calibration.d.ts +132 -0
- package/dist/telemetry/calibration.js +151 -0
- package/dist/telemetry/episode.d.ts +140 -0
- package/dist/telemetry/episode.js +272 -0
- package/dist/telemetry/event.d.ts +2310 -0
- package/dist/telemetry/event.js +405 -0
- package/dist/telemetry/index.d.ts +15 -0
- package/dist/telemetry/index.js +15 -0
- package/dist/telemetry/journal.d.ts +116 -0
- package/dist/telemetry/journal.js +11 -0
- package/dist/telemetry/memory.d.ts +24 -0
- package/dist/telemetry/memory.js +75 -0
- package/dist/telemetry/migrate.d.ts +26 -0
- package/dist/telemetry/migrate.js +40 -0
- package/dist/telemetry/postgres.d.ts +6 -0
- package/dist/telemetry/postgres.js +139 -0
- package/dist/telemetry/retention.d.ts +131 -0
- package/dist/telemetry/retention.js +217 -0
- package/dist/telemetry/schema.d.ts +113 -0
- package/dist/telemetry/schema.js +33 -0
- package/dist/telemetry/sink.d.ts +42 -0
- package/dist/telemetry/sink.js +61 -0
- package/dist/testing/contracts.d.ts +34 -0
- package/dist/testing/contracts.js +34 -0
- package/dist/testing/definitions.d.ts +15 -0
- package/dist/testing/definitions.js +48 -0
- package/dist/testing/doubles.d.ts +94 -0
- package/dist/testing/doubles.js +141 -0
- package/dist/testing/episode-harness.d.ts +49 -0
- package/dist/testing/episode-harness.js +65 -0
- package/dist/testing/filesystem.d.ts +17 -0
- package/dist/testing/filesystem.js +17 -0
- package/dist/testing/fixtures.d.ts +57 -0
- package/dist/testing/fixtures.js +84 -0
- package/dist/testing/hold-contract.d.ts +19 -0
- package/dist/testing/hold-contract.js +374 -0
- package/dist/testing/index.d.ts +41 -0
- package/dist/testing/index.js +41 -0
- package/dist/testing/journal-contract.d.ts +17 -0
- package/dist/testing/journal-contract.js +353 -0
- package/dist/testing/model-replies.d.ts +34 -0
- package/dist/testing/model-replies.js +101 -0
- package/dist/testing/primitives.d.ts +7 -0
- package/dist/testing/primitives.js +29 -0
- package/dist/testing/reader-signal-contract.d.ts +38 -0
- package/dist/testing/reader-signal-contract.js +318 -0
- package/dist/testing/row-security.d.ts +17 -0
- package/dist/testing/row-security.js +21 -0
- package/dist/testing/store-contract.d.ts +25 -0
- package/dist/testing/store-contract.js +500 -0
- package/dist/theme/apply.d.ts +17 -0
- package/dist/theme/apply.js +60 -0
- package/dist/theme/contrast.d.ts +197 -0
- package/dist/theme/contrast.js +259 -0
- package/dist/theme/derive.d.ts +77 -0
- package/dist/theme/derive.js +167 -0
- package/dist/theme/faces.d.ts +73 -0
- package/dist/theme/faces.js +119 -0
- package/dist/theme/font-packs.d.ts +25 -0
- package/dist/theme/font-packs.js +257 -0
- package/dist/theme/index.d.ts +20 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/lab.d.ts +30 -0
- package/dist/theme/lab.js +46 -0
- package/dist/theme/library.d.ts +114 -0
- package/dist/theme/library.js +300 -0
- package/dist/theme/measure.d.ts +144 -0
- package/dist/theme/measure.js +145 -0
- package/dist/theme/palettes.d.ts +64 -0
- package/dist/theme/palettes.js +497 -0
- package/dist/theme/registry.d.ts +59 -0
- package/dist/theme/registry.js +60 -0
- package/dist/theme/separation.d.ts +177 -0
- package/dist/theme/separation.js +203 -0
- package/dist/theme/style-presets.d.ts +60 -0
- package/dist/theme/style-presets.js +124 -0
- package/dist/theme/theme.d.ts +253 -0
- package/dist/theme/theme.js +171 -0
- package/dist/tree/apply.d.ts +16 -0
- package/dist/tree/apply.js +104 -0
- package/dist/tree/builders.d.ts +19 -0
- package/dist/tree/builders.js +20 -0
- package/dist/tree/compare.d.ts +68 -0
- package/dist/tree/compare.js +75 -0
- package/dist/tree/configuration.d.ts +25 -0
- package/dist/tree/configuration.js +108 -0
- package/dist/tree/delta.d.ts +288 -0
- package/dist/tree/delta.js +88 -0
- package/dist/tree/errors.d.ts +69 -0
- package/dist/tree/errors.js +34 -0
- package/dist/tree/identity.d.ts +117 -0
- package/dist/tree/identity.js +145 -0
- package/dist/tree/index.d.ts +21 -0
- package/dist/tree/index.js +21 -0
- package/dist/tree/inverse.d.ts +24 -0
- package/dist/tree/inverse.js +112 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +49 -0
- package/dist/tree/naming.d.ts +4 -0
- package/dist/tree/naming.js +35 -0
- package/dist/tree/navigation.d.ts +38 -0
- package/dist/tree/navigation.js +83 -0
- package/dist/tree/node.d.ts +103 -0
- package/dist/tree/node.js +46 -0
- package/dist/tree/outline.d.ts +28 -0
- package/dist/tree/outline.js +10 -0
- package/dist/tree/tree.d.ts +83 -0
- package/dist/tree/tree.js +62 -0
- package/dist/write/commit.d.ts +124 -0
- package/dist/write/commit.js +234 -0
- package/dist/write/held.d.ts +674 -0
- package/dist/write/held.js +185 -0
- package/dist/write/index.d.ts +11 -0
- package/dist/write/index.js +11 -0
- package/dist/write/liveness.d.ts +132 -0
- package/dist/write/liveness.js +91 -0
- package/dist/write/revert.d.ts +79 -0
- package/dist/write/revert.js +134 -0
- package/package.json +160 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
import { AdjustControl } from "./behaviour-adjust.js";
|
|
3
|
+
import { CopyControl } from "./behaviour-copy.js";
|
|
4
|
+
import { DiscloseControl } from "./behaviour-disclose.js";
|
|
5
|
+
import { DismissControl, PresentControl } from "./behaviour-present.js";
|
|
6
|
+
export { DISCLOSED_ATTRIBUTE } from "./disclosed.js";
|
|
7
|
+
export { DISMISS_EVENT, PRESENTED_ATTRIBUTE } from "./presented.js";
|
|
8
|
+
/**
|
|
9
|
+
* The behaviour seam: the things a primitive *does* that its props cannot carry.
|
|
10
|
+
*
|
|
11
|
+
* It is the fourth gap of the shape §4e, §4f and §4g each answered. Data is a
|
|
12
|
+
* question props cannot ask; text is a string props must not hold; a submission
|
|
13
|
+
* is an address props may not name. A **behaviour** is an interaction props
|
|
14
|
+
* cannot express at all — a click handler is a function, and a primitive's
|
|
15
|
+
* props are JSON.
|
|
16
|
+
*
|
|
17
|
+
* The case that forced it is the copy button on a code panel: every reference
|
|
18
|
+
* site a developer reads has one, and `loom.code` could not have one, because
|
|
19
|
+
* there was nowhere for a behaviour to come from. `interactive` was the closest
|
|
20
|
+
* thing and it is not that — it *describes* a target so the Gate can refuse a
|
|
21
|
+
* bad nesting, and describing one does not create one.
|
|
22
|
+
*
|
|
23
|
+
* **A behaviour is a control the framework builds and a primitive places.** Not
|
|
24
|
+
* a prop, not a script a host remembers to install, not a client boundary each
|
|
25
|
+
* primitive opens for itself:
|
|
26
|
+
*
|
|
27
|
+
* - **Not a prop**, for 0055's reason. A prop is written by a model and weighed
|
|
28
|
+
* by the Gate as a small reversible change, and "this button now copies
|
|
29
|
+
* something else" is not that. Nothing in the tree names a behaviour; the
|
|
30
|
+
* registered component does, and a human approved that component once.
|
|
31
|
+
* - **Not a host-installed script**, for 0055's other reason. A primitive that
|
|
32
|
+
* works only where somebody remembered to link something fails silently, in
|
|
33
|
+
* someone else's deployment, with nothing in the render to say why.
|
|
34
|
+
* - **Not a client boundary per primitive.** That is the shape this could have
|
|
35
|
+
* taken and the reason it does not is the closed set. The things a Loom page
|
|
36
|
+
* may *do* are as much a bounded vocabulary as the primitives it may name and
|
|
37
|
+
* the schemes a URL may use (0053); a library where any component may open a
|
|
38
|
+
* boundary has no such list, and nothing to check against it.
|
|
39
|
+
*
|
|
40
|
+
* So the vocabulary is here, one entry per behaviour, and `src/primitives/`
|
|
41
|
+
* declares from it and never implements. Three things follow, and each one is a
|
|
42
|
+
* check the registry can make at registration rather than a bug someone finds
|
|
43
|
+
* on a page:
|
|
44
|
+
*
|
|
45
|
+
* - A control needs an **accessible name**, so a behaviour names the text keys
|
|
46
|
+
* the primitive must declare — and they resolve through the ordinary text
|
|
47
|
+
* seam, so a German deployment translates the copy button with the dictionary
|
|
48
|
+
* it already has.
|
|
49
|
+
* - A control **is a target**, so a primitive that takes one must say it is
|
|
50
|
+
* `interactive` — otherwise the Gate would let a code panel with a copy
|
|
51
|
+
* button sit inside a linked card, which is a button inside an anchor and one
|
|
52
|
+
* of the two silently stops working.
|
|
53
|
+
* - A behaviour the primitive **never places** is a control that never appears,
|
|
54
|
+
* which is what the conformance probe reports the same way it reports a
|
|
55
|
+
* declared slot nobody rendered.
|
|
56
|
+
*
|
|
57
|
+
* What a control acts on comes from the **tree**, not from the DOM. The copy
|
|
58
|
+
* button copies the text of the node it belongs to, read off the same tree the
|
|
59
|
+
* page was projected from — so it is right before the browser has laid anything
|
|
60
|
+
* out, needs no ref into markup the primitive owns, and copies what the page
|
|
61
|
+
* *says* rather than whatever text happened to render beside it.
|
|
62
|
+
*
|
|
63
|
+
* Two members later that is still true of what a control *reads*, and the
|
|
64
|
+
* vocabulary has grown a second axis it says nothing about: what a control hands
|
|
65
|
+
* *back*. `copy` hands back nothing. `disclose` hands back a boolean, on its own
|
|
66
|
+
* element, which a sibling selector reaches. `adjust` hands back a number, on the
|
|
67
|
+
* element the primitive placed it in, because inheritance is the only way a
|
|
68
|
+
* stylesheet can compute with one. Each is the smallest thing that reaches the
|
|
69
|
+
* layout it has to reach, and
|
|
70
|
+
* [0096](../../decisions/0096-a-behaviour-publishes-a-value-on-the-element-the-primitive-placed-it-in.md)
|
|
71
|
+
* records why the third could not be the second.
|
|
72
|
+
*
|
|
73
|
+
* `present` and `dismiss` are the fourth and fifth, and they are the first
|
|
74
|
+
* *pair*: a third axis, which is whether a control is answerable to another one.
|
|
75
|
+
* Every member before them is complete on its own, and an overlay is the case
|
|
76
|
+
* where that stops being possible — a dialog is closed by a cross inside the
|
|
77
|
+
* panel as well as by the trigger that opened it, and a click handler is a
|
|
78
|
+
* function whichever button it is on. So `dismiss` is meaningless without
|
|
79
|
+
* `present`, which is a fourth thing the registry checks at registration, and
|
|
80
|
+
* the two agree through the DOM rather than through the seam. `presented.ts`
|
|
81
|
+
* carries why, and [0176](../../decisions/0176-a-control-may-be-answerable-to-another-control-and-they-agree-through-the-dom.md)
|
|
82
|
+
* records what was rejected.
|
|
83
|
+
*
|
|
84
|
+
* What a control hands back is not the same question as what a primitive may say
|
|
85
|
+
* about it, and the second one lives in `control.ts`: the class every control
|
|
86
|
+
* carries, and the custom property that decides whether it is displayed. Both
|
|
87
|
+
* exist because a control's presentation is an inline style, which a rule cannot
|
|
88
|
+
* beat.
|
|
89
|
+
*/
|
|
90
|
+
export const BEHAVIOUR_NAMES = ["copy", "disclose", "adjust", "present", "dismiss"];
|
|
91
|
+
/**
|
|
92
|
+
* The custom property an adjust control publishes its value on: a plain number
|
|
93
|
+
* between {@link ADJUST_MINIMUM} and {@link ADJUST_MAXIMUM}, no unit.
|
|
94
|
+
*
|
|
95
|
+
* **This is the whole of the contract between the runtime and a primitive that
|
|
96
|
+
* takes `adjust`**, and it is a custom property rather than an attribute for the
|
|
97
|
+
* one reason an attribute cannot be made to work: what this hands back is a
|
|
98
|
+
* number a stylesheet has to *compute with*, and there is no portable way to
|
|
99
|
+
* read an attribute's value into a length. `attr()` outside `content` is not
|
|
100
|
+
* something a library may rely on today.
|
|
101
|
+
*
|
|
102
|
+
* A property is read with `var()`, which resolves by **inheritance**, and that
|
|
103
|
+
* is what makes this behaviour differ from `disclose` in a way worth stating
|
|
104
|
+
* rather than glossing. `data-loom-disclosed` is read *sideways*, by an ordinary
|
|
105
|
+
* sibling selector, so the control stamping it on its own button reaches the
|
|
106
|
+
* region beside it. Inheritance runs downwards only, so a property set on the
|
|
107
|
+
* control's own element would be readable by nothing at all — least of all the
|
|
108
|
+
* sibling region the control exists to drive.
|
|
109
|
+
*
|
|
110
|
+
* So the control writes this property on **the element the primitive placed it
|
|
111
|
+
* in**, its parent, and the primitive reads it from anywhere in that subtree.
|
|
112
|
+
* The unit is left off deliberately, so one value serves every use:
|
|
113
|
+
*
|
|
114
|
+
* ```css
|
|
115
|
+
* .after { clip-path: inset(0 calc(100% - var(--loom-adjust, 50) * 1%) 0 0) }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* **The fallback is not optional and not decoration.** The property is absent
|
|
119
|
+
* until the control has mounted and proved scripting runs, and absent again the
|
|
120
|
+
* moment it unmounts — so the second argument to `var()` is what a page served
|
|
121
|
+
* with scripting off renders, and it should be the position the primitive's own
|
|
122
|
+
* props declared. That is what keeps the still version of a comparison the thing
|
|
123
|
+
* that ships, rather than a blank waiting on a control that may never arrive.
|
|
124
|
+
*
|
|
125
|
+
* See [0096](../../decisions/0096-a-behaviour-publishes-a-value-on-the-element-the-primitive-placed-it-in.md).
|
|
126
|
+
*/
|
|
127
|
+
export const ADJUST_PROPERTY = "--loom-adjust";
|
|
128
|
+
/** The bottom of an adjust control's range. */
|
|
129
|
+
export const ADJUST_MINIMUM = 0;
|
|
130
|
+
/**
|
|
131
|
+
* The top of an adjust control's range.
|
|
132
|
+
*
|
|
133
|
+
* A percentage rather than a unit interval, because every use so far multiplies
|
|
134
|
+
* by `1%` and a stylesheet author reading `var(--loom-adjust)` should see the
|
|
135
|
+
* number they would have typed. Fixed rather than declarable for the reason the
|
|
136
|
+
* seam gives about props: what a control ranges over is not a model's to write.
|
|
137
|
+
*/
|
|
138
|
+
export const ADJUST_MAXIMUM = 100;
|
|
139
|
+
/**
|
|
140
|
+
* Where the control sits before anybody moves it.
|
|
141
|
+
*
|
|
142
|
+
* The midpoint, and it is the control's rather than the primitive's on purpose.
|
|
143
|
+
* `build` receives the node's text and its content, not its props, so there is
|
|
144
|
+
* nothing here that could read a declared position — and nothing that needs to:
|
|
145
|
+
* the primitive supplies its own position as the `var()` fallback, which covers
|
|
146
|
+
* the case that actually matters, the page where the control never mounts. Once
|
|
147
|
+
* a reader has a slider in front of them, where it started is theirs to change.
|
|
148
|
+
*/
|
|
149
|
+
export const ADJUST_RESTING = 50;
|
|
150
|
+
export const BEHAVIOURS = {
|
|
151
|
+
copy: {
|
|
152
|
+
description: "A control that puts the node's own text on the clipboard, and shows itself only where the clipboard is actually available.",
|
|
153
|
+
text: ["copy", "copied"],
|
|
154
|
+
rendersControl: true,
|
|
155
|
+
build: (content, text) => createElement(CopyControl, {
|
|
156
|
+
value: content,
|
|
157
|
+
label: text.copy ?? "",
|
|
158
|
+
copiedLabel: text.copied ?? "",
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* The second member, and the first that does not act on the node's text.
|
|
163
|
+
*
|
|
164
|
+
* `copy` reads `content` because what it acts on is in the tree. A disclosure
|
|
165
|
+
* acts on a *region of the render*, which is not in the tree and is not the
|
|
166
|
+
* runtime's to reach for — so the control publishes its state as
|
|
167
|
+
* `DISCLOSED_ATTRIBUTE` and the primitive's stylesheet does the rest. That
|
|
168
|
+
* asymmetry is the point rather than an omission: it is what lets a behaviour
|
|
169
|
+
* be a single node the primitive places, in the case where the thing being
|
|
170
|
+
* behaved on is layout the primitive owns.
|
|
171
|
+
*/
|
|
172
|
+
disclose: {
|
|
173
|
+
description: "A control that opens and closes a region the primitive lays out beside it, and shows itself only where scripting actually runs.",
|
|
174
|
+
text: ["disclose"],
|
|
175
|
+
rendersControl: true,
|
|
176
|
+
build: (_content, text) => createElement(DiscloseControl, {
|
|
177
|
+
label: text.disclose ?? "",
|
|
178
|
+
}),
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* The third member, and the first that hands a value *back*.
|
|
182
|
+
*
|
|
183
|
+
* `copy` reads the node's text because what it acts on is in the tree.
|
|
184
|
+
* `disclose` publishes a boolean because what it acts on is layout the
|
|
185
|
+
* primitive owns and a sibling selector can reach. This publishes a number,
|
|
186
|
+
* because what it acts on is a length a stylesheet has to compute — and that
|
|
187
|
+
* is the one thing neither of the other two shapes can express.
|
|
188
|
+
*
|
|
189
|
+
* It is the first control that writes to an element the runtime did not
|
|
190
|
+
* create, which is a cost recorded rather than a detail (0096). The element is
|
|
191
|
+
* the one the primitive placed the control in, so it is chosen and not
|
|
192
|
+
* discovered; see {@link ADJUST_PROPERTY}.
|
|
193
|
+
*/
|
|
194
|
+
adjust: {
|
|
195
|
+
description: "A control the reader drags to choose a number, published to the primitive as a CSS custom property so a stylesheet can compute a length from it.",
|
|
196
|
+
text: ["adjust"],
|
|
197
|
+
rendersControl: true,
|
|
198
|
+
build: (_content, text) => createElement(AdjustControl, {
|
|
199
|
+
label: text.adjust ?? "",
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
/**
|
|
203
|
+
* The fourth member, and the first whose state something other than its own
|
|
204
|
+
* button can change.
|
|
205
|
+
*
|
|
206
|
+
* It is `disclose` for a region that is not the button's sibling. The state
|
|
207
|
+
* goes on the element the primitive placed the trigger in, so a descendant
|
|
208
|
+
* selector reaches a panel, a menu or a frame laid out anywhere inside that
|
|
209
|
+
* box; Escape and a press outside that box close it, because an overlay a
|
|
210
|
+
* reader cannot get out of is the failure every one of these primitives is
|
|
211
|
+
* judged on. See {@link PRESENTED_ATTRIBUTE}.
|
|
212
|
+
*/
|
|
213
|
+
present: {
|
|
214
|
+
description: "A control that opens a region the primitive lays out inside it and closes again on Escape, on a press outside, or on a dismiss control within it.",
|
|
215
|
+
text: ["present"],
|
|
216
|
+
rendersControl: true,
|
|
217
|
+
build: (_content, text) => createElement(PresentControl, {
|
|
218
|
+
label: text.present ?? "",
|
|
219
|
+
}),
|
|
220
|
+
},
|
|
221
|
+
/**
|
|
222
|
+
* The fifth, and the only one that is not complete on its own.
|
|
223
|
+
*
|
|
224
|
+
* It publishes nothing and reads nothing. Pressed, it asks the nearest
|
|
225
|
+
* presentation above it to close, and that is the whole of it — see
|
|
226
|
+
* {@link DISMISS_EVENT} for why a bubbling event rather than a shared store,
|
|
227
|
+
* and `behaviour-present.ts` for why this is the one control whose name is
|
|
228
|
+
* not rendered as text.
|
|
229
|
+
*/
|
|
230
|
+
dismiss: {
|
|
231
|
+
description: "A cross inside a presented region that closes it, for the overlay whose own scrim fills the page and cannot be pressed past.",
|
|
232
|
+
text: ["dismiss"],
|
|
233
|
+
rendersControl: true,
|
|
234
|
+
requires: "present",
|
|
235
|
+
build: (_content, text) => createElement(DismissControl, {
|
|
236
|
+
label: text.dismiss ?? "",
|
|
237
|
+
}),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
export const isBehaviourName = (value) => BEHAVIOUR_NAMES.includes(value);
|
|
241
|
+
/**
|
|
242
|
+
* The map handed to a primitive that declared none. Null-prototype for the
|
|
243
|
+
* reason `NO_TEXT` gives: `constructor` is not a behaviour name today, and a
|
|
244
|
+
* lookup that answered with a function off `Object.prototype` if it ever were
|
|
245
|
+
* is not a thing anyone should have to debug from a rendered page.
|
|
246
|
+
*/
|
|
247
|
+
export const NO_BEHAVIOURS = Object.freeze(Object.create(null));
|
|
248
|
+
export const isBehaviourResolver = (value) => typeof value.behavioursFor === "function";
|
|
249
|
+
const NO_UNNAMED = Object.freeze([]);
|
|
250
|
+
export const NO_RESOLVED_BEHAVIOURS = Object.freeze({
|
|
251
|
+
behaviours: NO_BEHAVIOURS,
|
|
252
|
+
unnamed: NO_UNNAMED,
|
|
253
|
+
});
|
|
254
|
+
/**
|
|
255
|
+
* Builds the controls for one node.
|
|
256
|
+
*
|
|
257
|
+
* A behaviour whose text is missing or blank is **dropped rather than rendered
|
|
258
|
+
* nameless**. That is the same judgement the text seam makes about a control
|
|
259
|
+
* with no accessible name, taken one step further because there is a whole
|
|
260
|
+
* control to leave out here rather than a string to fall back on: a copy button
|
|
261
|
+
* a screen reader announces as "button" is worse than a page with no copy
|
|
262
|
+
* button, in exactly the way the finding that asked for this said a fake one
|
|
263
|
+
* would be.
|
|
264
|
+
*/
|
|
265
|
+
export const resolveBehaviours = (names, content, text) => {
|
|
266
|
+
if (names.length === 0)
|
|
267
|
+
return NO_RESOLVED_BEHAVIOURS;
|
|
268
|
+
const behaviours = Object.create(null);
|
|
269
|
+
const unnamed = [];
|
|
270
|
+
for (const name of names) {
|
|
271
|
+
const behaviour = BEHAVIOURS[name];
|
|
272
|
+
const missing = behaviour.text.find((key) => (text[key] ?? "").trim() === "");
|
|
273
|
+
if (missing !== undefined) {
|
|
274
|
+
unnamed.push({ behaviour: name, key: missing });
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
behaviours[name] = behaviour.build(content, text);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
behaviours: Object.freeze(behaviours),
|
|
281
|
+
unnamed: unnamed.length === 0 ? NO_UNNAMED : Object.freeze(unnamed),
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=behaviour.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { BehaviourName } from "./behaviour.js";
|
|
2
|
+
/**
|
|
3
|
+
* The handle a primitive has on a control it did not build.
|
|
4
|
+
*
|
|
5
|
+
* A behaviour arrives as a node with nothing left to configure, and that is what
|
|
6
|
+
* makes placing it the whole of a primitive's part. It also means the primitive
|
|
7
|
+
* is handed an element it cannot name: the class it would aim a rule at, and the
|
|
8
|
+
* one line of that rule an inline style would otherwise beat. Both are here, in
|
|
9
|
+
* one module the controls and the seam can share, because a control importing
|
|
10
|
+
* them from the seam that imports the control is a cycle.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The class every control carries, and the stem of the second one naming which
|
|
14
|
+
* behaviour built it: `loom-control loom-control-copy`.
|
|
15
|
+
*
|
|
16
|
+
* Until this existed, a primitive styling the control it had been handed had two
|
|
17
|
+
* options and neither was good. An element selector guesses what a control
|
|
18
|
+
* renders — `button`, which stopped being true the first time a behaviour
|
|
19
|
+
* rendered an input, as `adjust` does. A wrapper of the primitive's own exists
|
|
20
|
+
* only so there is something to select, and costs a box on every page. A stable
|
|
21
|
+
* class removes both, and costs the runtime one attribute.
|
|
22
|
+
*
|
|
23
|
+
* A plain class rather than a data attribute because it is written for a
|
|
24
|
+
* stylesheet, and a stylesheet author writes `.loom-control-copy`. Nothing reads
|
|
25
|
+
* it back: what a control publishes is an attribute or a custom property, and
|
|
26
|
+
* those are documented apart from this because they are the parts that carry
|
|
27
|
+
* state.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CONTROL_CLASS = "loom-control";
|
|
30
|
+
/** The classes the runtime stamps on the control one behaviour builds. */
|
|
31
|
+
export declare const controlClass: (name: BehaviourName) => string;
|
|
32
|
+
/**
|
|
33
|
+
* The custom property that decides whether a control is displayed — every
|
|
34
|
+
* control at once.
|
|
35
|
+
*
|
|
36
|
+
* A class gives a primitive somewhere to aim a rule. It does not give it a rule
|
|
37
|
+
* that *wins*. Every control sets its own presentation as an inline `style`, for
|
|
38
|
+
* the reason each control file states: the render seam may not depend on
|
|
39
|
+
* `src/primitives/`, and a control that only looks right under a mounted theme
|
|
40
|
+
* renders invisible in a preview pane that mounts none. An inline declaration
|
|
41
|
+
* beats every selector a stylesheet can write short of `!important`, so
|
|
42
|
+
* `.loom-control-disclose { display: none }` silently does nothing — and the
|
|
43
|
+
* primitive that most needs it is the one whose control belongs on a phone and
|
|
44
|
+
* not on a laptop.
|
|
45
|
+
*
|
|
46
|
+
* A custom property crosses that boundary because it is substituted *into* the
|
|
47
|
+
* inline declaration rather than competing with it. The control writes
|
|
48
|
+
* `display: var(…, inline-flex)`; a primitive sets the property in whatever media
|
|
49
|
+
* query it likes, on any ancestor, and inheritance carries it down. The fallback
|
|
50
|
+
* is what a page renders when nobody has set anything, so this is additive by
|
|
51
|
+
* construction: a primitive that says nothing sees no change.
|
|
52
|
+
*
|
|
53
|
+
* **Hiding a control does not clear what it publishes.** A disclosure whose
|
|
54
|
+
* button is displayed `none` still carries its attribute, and the sibling rule
|
|
55
|
+
* keyed on that attribute still matches — so a primitive that hides the control
|
|
56
|
+
* at a width has to stop hiding the region at that width too, in the same query.
|
|
57
|
+
* That is the one sharp edge here, and it is the primitive's to hold because the
|
|
58
|
+
* runtime does not know which region is which.
|
|
59
|
+
*/
|
|
60
|
+
export declare const CONTROL_DISPLAY_PROPERTY = "--loom-control-display";
|
|
61
|
+
/**
|
|
62
|
+
* The custom property that decides whether *one* behaviour's control is
|
|
63
|
+
* displayed: `--loom-copy-display`.
|
|
64
|
+
*
|
|
65
|
+
* The group property is the common case and this is the escape from it. A
|
|
66
|
+
* primitive that places two controls — a code panel that copies and folds — has
|
|
67
|
+
* one subtree and therefore one inherited value, so without a per-behaviour name
|
|
68
|
+
* hiding either would hide both.
|
|
69
|
+
*/
|
|
70
|
+
export declare const controlDisplayProperty: (name: BehaviourName) => string;
|
|
71
|
+
/**
|
|
72
|
+
* The value a control writes for `display`: its own, behind the two properties a
|
|
73
|
+
* primitive may override it with.
|
|
74
|
+
*
|
|
75
|
+
* Nested deliberately, and in this order. The specific name wins over the group
|
|
76
|
+
* name, the group name wins over the control's own resting value, and a
|
|
77
|
+
* deployment that sets neither gets exactly what the control set before any of
|
|
78
|
+
* this existed.
|
|
79
|
+
*/
|
|
80
|
+
export declare const controlDisplay: (name: BehaviourName, resting: string) => string;
|
|
81
|
+
//# sourceMappingURL=control.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handle a primitive has on a control it did not build.
|
|
3
|
+
*
|
|
4
|
+
* A behaviour arrives as a node with nothing left to configure, and that is what
|
|
5
|
+
* makes placing it the whole of a primitive's part. It also means the primitive
|
|
6
|
+
* is handed an element it cannot name: the class it would aim a rule at, and the
|
|
7
|
+
* one line of that rule an inline style would otherwise beat. Both are here, in
|
|
8
|
+
* one module the controls and the seam can share, because a control importing
|
|
9
|
+
* them from the seam that imports the control is a cycle.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The class every control carries, and the stem of the second one naming which
|
|
13
|
+
* behaviour built it: `loom-control loom-control-copy`.
|
|
14
|
+
*
|
|
15
|
+
* Until this existed, a primitive styling the control it had been handed had two
|
|
16
|
+
* options and neither was good. An element selector guesses what a control
|
|
17
|
+
* renders — `button`, which stopped being true the first time a behaviour
|
|
18
|
+
* rendered an input, as `adjust` does. A wrapper of the primitive's own exists
|
|
19
|
+
* only so there is something to select, and costs a box on every page. A stable
|
|
20
|
+
* class removes both, and costs the runtime one attribute.
|
|
21
|
+
*
|
|
22
|
+
* A plain class rather than a data attribute because it is written for a
|
|
23
|
+
* stylesheet, and a stylesheet author writes `.loom-control-copy`. Nothing reads
|
|
24
|
+
* it back: what a control publishes is an attribute or a custom property, and
|
|
25
|
+
* those are documented apart from this because they are the parts that carry
|
|
26
|
+
* state.
|
|
27
|
+
*/
|
|
28
|
+
export const CONTROL_CLASS = "loom-control";
|
|
29
|
+
/** The classes the runtime stamps on the control one behaviour builds. */
|
|
30
|
+
export const controlClass = (name) => `${CONTROL_CLASS} ${CONTROL_CLASS}-${name}`;
|
|
31
|
+
/**
|
|
32
|
+
* The custom property that decides whether a control is displayed — every
|
|
33
|
+
* control at once.
|
|
34
|
+
*
|
|
35
|
+
* A class gives a primitive somewhere to aim a rule. It does not give it a rule
|
|
36
|
+
* that *wins*. Every control sets its own presentation as an inline `style`, for
|
|
37
|
+
* the reason each control file states: the render seam may not depend on
|
|
38
|
+
* `src/primitives/`, and a control that only looks right under a mounted theme
|
|
39
|
+
* renders invisible in a preview pane that mounts none. An inline declaration
|
|
40
|
+
* beats every selector a stylesheet can write short of `!important`, so
|
|
41
|
+
* `.loom-control-disclose { display: none }` silently does nothing — and the
|
|
42
|
+
* primitive that most needs it is the one whose control belongs on a phone and
|
|
43
|
+
* not on a laptop.
|
|
44
|
+
*
|
|
45
|
+
* A custom property crosses that boundary because it is substituted *into* the
|
|
46
|
+
* inline declaration rather than competing with it. The control writes
|
|
47
|
+
* `display: var(…, inline-flex)`; a primitive sets the property in whatever media
|
|
48
|
+
* query it likes, on any ancestor, and inheritance carries it down. The fallback
|
|
49
|
+
* is what a page renders when nobody has set anything, so this is additive by
|
|
50
|
+
* construction: a primitive that says nothing sees no change.
|
|
51
|
+
*
|
|
52
|
+
* **Hiding a control does not clear what it publishes.** A disclosure whose
|
|
53
|
+
* button is displayed `none` still carries its attribute, and the sibling rule
|
|
54
|
+
* keyed on that attribute still matches — so a primitive that hides the control
|
|
55
|
+
* at a width has to stop hiding the region at that width too, in the same query.
|
|
56
|
+
* That is the one sharp edge here, and it is the primitive's to hold because the
|
|
57
|
+
* runtime does not know which region is which.
|
|
58
|
+
*/
|
|
59
|
+
export const CONTROL_DISPLAY_PROPERTY = "--loom-control-display";
|
|
60
|
+
/**
|
|
61
|
+
* The custom property that decides whether *one* behaviour's control is
|
|
62
|
+
* displayed: `--loom-copy-display`.
|
|
63
|
+
*
|
|
64
|
+
* The group property is the common case and this is the escape from it. A
|
|
65
|
+
* primitive that places two controls — a code panel that copies and folds — has
|
|
66
|
+
* one subtree and therefore one inherited value, so without a per-behaviour name
|
|
67
|
+
* hiding either would hide both.
|
|
68
|
+
*/
|
|
69
|
+
export const controlDisplayProperty = (name) => `--loom-${name}-display`;
|
|
70
|
+
/**
|
|
71
|
+
* The value a control writes for `display`: its own, behind the two properties a
|
|
72
|
+
* primitive may override it with.
|
|
73
|
+
*
|
|
74
|
+
* Nested deliberately, and in this order. The specific name wins over the group
|
|
75
|
+
* name, the group name wins over the control's own resting value, and a
|
|
76
|
+
* deployment that sets neither gets exactly what the control set before any of
|
|
77
|
+
* this existed.
|
|
78
|
+
*/
|
|
79
|
+
export const controlDisplay = (name, resting) => `var(${controlDisplayProperty(name)}, var(${CONTROL_DISPLAY_PROPERTY}, ${resting}))`;
|
|
80
|
+
//# sourceMappingURL=control.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The same children again, as a copy nothing can resolve to a node.
|
|
4
|
+
*
|
|
5
|
+
* Some arrangements need content said twice — a seamless loop, a mirrored
|
|
6
|
+
* region, a fading echo — and the second copy is not content, it is the shape
|
|
7
|
+
* of the first one. This is how a primitive asks for one without putting a
|
|
8
|
+
* node's identity on two elements.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The copy, rendered on demand.
|
|
12
|
+
*
|
|
13
|
+
* A seamless loop is the arrangement that forced this: a track translating by
|
|
14
|
+
* exactly one run's width has to have a second copy of the run waiting after
|
|
15
|
+
* the seam, or the band pauses empty once a cycle.
|
|
16
|
+
*
|
|
17
|
+
* Children arrive at a primitive already rendered, carrying whatever the render
|
|
18
|
+
* seam put on them. In edit mode that includes `data-loom-node`, so placing the
|
|
19
|
+
* same `children` twice puts one node id on two elements — the failure
|
|
20
|
+
* [0051](../../decisions/0051-a-slot-is-a-region-the-primitive-places.md)
|
|
21
|
+
* rejected, where a portal resolves an id to a copy and highlights a node that
|
|
22
|
+
* is not the one the reviewer clicked. `loom.marquee` met it on 25 August and
|
|
23
|
+
* [0091](../../decisions/0091-motion-stops-in-edit-mode-and-that-is-where-a-decorative-duplicate-belongs.md)
|
|
24
|
+
* answered it by not duplicating in edit mode at all, which is right about
|
|
25
|
+
* motion and says nothing about the next primitive that wants an echo standing
|
|
26
|
+
* still.
|
|
27
|
+
*
|
|
28
|
+
* So the renderer offers the copy instead of leaving each primitive to
|
|
29
|
+
* rediscover the hazard. `loom.decorative()` renders this node's children a
|
|
30
|
+
* second time with identity switched off: the same nodes, in the same order,
|
|
31
|
+
* with the same props, and not one `data-loom-node` among them.
|
|
32
|
+
*
|
|
33
|
+
* Three things it deliberately does not do.
|
|
34
|
+
*
|
|
35
|
+
* **It does not mark the copy.** The renderer wraps nothing — `editable.ts`
|
|
36
|
+
* gives the reason, and it holds here — so there is no element for a marker to
|
|
37
|
+
* sit on that the primitive did not create itself. What makes the copy honest
|
|
38
|
+
* is the *absence* of identity, which is the property 0091 already named: a
|
|
39
|
+
* decorative duplicate exists only where identity attributes do not. Announcing
|
|
40
|
+
* it to a reader is still the primitive's job, with `aria-hidden` and `inert`
|
|
41
|
+
* on whatever it wrapped the copy in.
|
|
42
|
+
*
|
|
43
|
+
* **It does not make the copy inert.** A copy placed without them is duplicated
|
|
44
|
+
* content a screen reader reads twice and a keyboard tabs through twice. The
|
|
45
|
+
* seam cannot prevent that, because the element it would set them on belongs to
|
|
46
|
+
* the primitive; what it can do is guarantee that nothing in the copy resolves,
|
|
47
|
+
* which is the half a primitive could not do for itself.
|
|
48
|
+
*
|
|
49
|
+
* **It does not reach slot regions.** A named region may hold content the host
|
|
50
|
+
* projected into the render, which is not this tree's and cannot be rendered
|
|
51
|
+
* again — so the guarantee here is about the tree: no node *of this tree*
|
|
52
|
+
* carries its identity twice.
|
|
53
|
+
*
|
|
54
|
+
* One consequence worth stating rather than discovering. `loom.editable` is the
|
|
55
|
+
* statement *this element can be edited*, and nothing in a decorative copy can
|
|
56
|
+
* be: it is not a node, and there is no id to author an intent against. So
|
|
57
|
+
* descendants inside the copy do not receive it, and a descendant that branches
|
|
58
|
+
* on it — the one branch 0091 licenses, holding still — takes its unedited
|
|
59
|
+
* branch there while the original beside it holds.
|
|
60
|
+
*/
|
|
61
|
+
export type DecorativeChildren = () => ReactNode;
|
|
62
|
+
//# sourceMappingURL=decorative.d.ts.map
|