foldkit-mixins 0.20.0 → 0.22.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/README.md +92 -7
- package/dist/a11y.d.ts +27 -0
- package/dist/a11y.d.ts.map +1 -0
- package/dist/a11y.js +78 -0
- package/dist/a11y.js.map +1 -0
- package/dist/{app.d.mts → app.d.ts} +14 -11
- package/dist/app.d.ts.map +1 -0
- package/dist/{app.mjs → app.js} +8 -7
- package/dist/app.js.map +1 -0
- package/dist/attr.d.ts +19 -0
- package/dist/attr.d.ts.map +1 -0
- package/dist/attr.js +23 -0
- package/dist/attr.js.map +1 -0
- package/dist/attribute.d.ts +18 -0
- package/dist/attribute.d.ts.map +1 -0
- package/dist/attribute.js +21 -0
- package/dist/attribute.js.map +1 -0
- package/dist/attributes.d.ts +15 -0
- package/dist/attributes.d.ts.map +1 -0
- package/dist/attributes.js +12 -0
- package/dist/attributes.js.map +1 -0
- package/dist/behavior.d.ts +50 -0
- package/dist/behavior.d.ts.map +1 -0
- package/dist/behavior.js +71 -0
- package/dist/behavior.js.map +1 -0
- package/dist/behaviors/collection.d.ts +40 -0
- package/dist/behaviors/collection.d.ts.map +1 -0
- package/dist/behaviors/collection.js +63 -0
- package/dist/behaviors/collection.js.map +1 -0
- package/dist/behaviors/disclosure.d.ts +10 -0
- package/dist/behaviors/disclosure.d.ts.map +1 -0
- package/dist/behaviors/disclosure.js +16 -0
- package/dist/behaviors/disclosure.js.map +1 -0
- package/dist/behaviors/field-association.d.ts +20 -0
- package/dist/behaviors/field-association.d.ts.map +1 -0
- package/dist/behaviors/field-association.js +36 -0
- package/dist/behaviors/field-association.js.map +1 -0
- package/dist/behaviors/index.d.ts +6 -0
- package/dist/behaviors/index.js +6 -0
- package/dist/behaviors/spin-value.d.ts +21 -0
- package/dist/behaviors/spin-value.d.ts.map +1 -0
- package/dist/behaviors/spin-value.js +49 -0
- package/dist/behaviors/spin-value.js.map +1 -0
- package/dist/behaviors/toggle-state.d.ts +11 -0
- package/dist/behaviors/toggle-state.d.ts.map +1 -0
- package/dist/behaviors/toggle-state.js +13 -0
- package/dist/behaviors/toggle-state.js.map +1 -0
- package/dist/capability.d.ts +33 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +70 -0
- package/dist/capability.js.map +1 -0
- package/dist/contribution.d.ts +38 -0
- package/dist/contribution.d.ts.map +1 -0
- package/dist/contribution.js +1 -0
- package/dist/cssBlocks.d.ts +24 -0
- package/dist/cssBlocks.d.ts.map +1 -0
- package/dist/cssBlocks.js +66 -0
- package/dist/cssBlocks.js.map +1 -0
- package/dist/{defaults.d.mts → defaults.d.ts} +2 -2
- package/dist/defaults.d.ts.map +1 -0
- package/dist/{defaults.mjs → defaults.js} +2 -2
- package/dist/defaults.js.map +1 -0
- package/dist/devOverlay.d.ts +18 -0
- package/dist/devOverlay.d.ts.map +1 -0
- package/dist/devOverlay.js +96 -0
- package/dist/devOverlay.js.map +1 -0
- package/dist/diagnostics.d.ts +20 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +12 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/event.d.ts +21 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +25 -0
- package/dist/event.js.map +1 -0
- package/dist/{foundations.d.mts → foundations.d.ts} +2 -2
- package/dist/foundations.d.ts.map +1 -0
- package/dist/{foundations.mjs → foundations.js} +23 -17
- package/dist/foundations.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +21 -0
- package/dist/inject.d.ts +24 -0
- package/dist/inject.d.ts.map +1 -0
- package/dist/{slotMark-e8KUUb85.mjs → inject.js} +48 -41
- package/dist/inject.js.map +1 -0
- package/dist/{layers.d.mts → layers.d.ts} +2 -2
- package/dist/layers.d.ts.map +1 -0
- package/dist/{layers-b5nx42uz.mjs → layers.js} +5 -66
- package/dist/layers.js.map +1 -0
- package/dist/{layout.d.mts → layout.d.ts} +2 -2
- package/dist/layout.d.ts.map +1 -0
- package/dist/{layout.mjs → layout.js} +5 -3
- package/dist/layout.js.map +1 -0
- package/dist/metadataToken.d.ts +22 -0
- package/dist/metadataToken.d.ts.map +1 -0
- package/dist/metadataToken.js +23 -0
- package/dist/metadataToken.js.map +1 -0
- package/dist/mixin.d.ts +24 -0
- package/dist/mixin.d.ts.map +1 -0
- package/dist/mixin.js +46 -0
- package/dist/mixin.js.map +1 -0
- package/dist/mountFailed.d.ts +14 -0
- package/dist/mountFailed.d.ts.map +1 -0
- package/dist/mountFailed.js +23 -0
- package/dist/mountFailed.js.map +1 -0
- package/dist/{pipe-BLRPph_m.d.mts → pipe.d.ts} +4 -3
- package/dist/pipe.d.ts.map +1 -0
- package/dist/pipe.js +6 -0
- package/dist/pipe.js.map +1 -0
- package/dist/{prose.d.mts → prose.d.ts} +2 -2
- package/dist/prose.d.ts.map +1 -0
- package/dist/{prose.mjs → prose.js} +2 -2
- package/dist/prose.js.map +1 -0
- package/dist/record.d.ts +9 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +12 -0
- package/dist/record.js.map +1 -0
- package/dist/requirement.d.ts +11 -0
- package/dist/requirement.d.ts.map +1 -0
- package/dist/requirement.js +15 -0
- package/dist/requirement.js.map +1 -0
- package/dist/resolver.d.ts +17 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +195 -0
- package/dist/resolver.js.map +1 -0
- package/dist/selector.d.ts +20 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +23 -0
- package/dist/selector.js.map +1 -0
- package/dist/slot.d.ts +108 -0
- package/dist/slot.d.ts.map +1 -0
- package/dist/slot.js +124 -0
- package/dist/slot.js.map +1 -0
- package/dist/{slotItem-Cpv59kaT.d.mts → slotItem.d.ts} +2 -3
- package/dist/slotItem.d.ts.map +1 -0
- package/dist/slotItem.js +1 -0
- package/dist/slotMark.d.ts +12 -0
- package/dist/slotMark.d.ts.map +1 -0
- package/dist/slotMark.js +23 -0
- package/dist/slotMark.js.map +1 -0
- package/dist/slotView.d.ts +174 -0
- package/dist/slotView.d.ts.map +1 -0
- package/dist/slotView.js +366 -0
- package/dist/slotView.js.map +1 -0
- package/dist/slots.d.ts +31 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +61 -0
- package/dist/slots.js.map +1 -0
- package/dist/{style-AYR3dZQN.d.mts → style.d.ts} +52 -84
- package/dist/style.d.ts.map +1 -0
- package/dist/style.js +421 -0
- package/dist/style.js.map +1 -0
- package/dist/styleRules.d.ts +40 -0
- package/dist/styleRules.d.ts.map +1 -0
- package/dist/styleRules.js +138 -0
- package/dist/styleRules.js.map +1 -0
- package/dist/{styleValue-DAnH8FFQ.d.mts → styleValue.d.ts} +36 -42
- package/dist/styleValue.d.ts.map +1 -0
- package/dist/{styleValue-agZrNfOL.mjs → styleValue.js} +15 -159
- package/dist/styleValue.js.map +1 -0
- package/dist/{testing.d.mts → testing.d.ts} +3 -3
- package/dist/testing.d.ts.map +1 -0
- package/dist/{testing.mjs → testing.js} +3 -2
- package/dist/testing.js.map +1 -0
- package/dist/{core-DtE4hSjG.d.mts → theme/core.d.ts} +13 -13
- package/dist/theme/core.d.ts.map +1 -0
- package/dist/{core-BKDVG8xT.mjs → theme/core.js} +4 -7
- package/dist/theme/core.js.map +1 -0
- package/dist/theme/cssMath.d.ts +15 -0
- package/dist/theme/cssMath.d.ts.map +1 -0
- package/dist/theme/cssMath.js +81 -0
- package/dist/theme/cssMath.js.map +1 -0
- package/dist/theme/fluid.d.ts +43 -0
- package/dist/theme/fluid.d.ts.map +1 -0
- package/dist/theme/fluid.js +67 -0
- package/dist/theme/fluid.js.map +1 -0
- package/dist/theme/fonts.d.ts +15 -0
- package/dist/theme/fonts.d.ts.map +1 -0
- package/dist/theme/fonts.js +18 -0
- package/dist/theme/fonts.js.map +1 -0
- package/dist/theme/gamut.d.ts +78 -0
- package/dist/theme/gamut.d.ts.map +1 -0
- package/dist/theme/gamut.js +205 -0
- package/dist/theme/gamut.js.map +1 -0
- package/dist/theme/iconMasks.d.ts +3 -0
- package/dist/theme/iconMasks.d.ts.map +1 -0
- package/dist/theme/iconMasks.js +18 -0
- package/dist/theme/iconMasks.js.map +1 -0
- package/dist/theme/knob.d.ts +97 -0
- package/dist/theme/knob.d.ts.map +1 -0
- package/dist/theme/knob.js +102 -0
- package/dist/theme/knob.js.map +1 -0
- package/dist/theme/knobs.d.ts +317 -0
- package/dist/theme/knobs.d.ts.map +1 -0
- package/dist/theme/knobs.js +725 -0
- package/dist/theme/knobs.js.map +1 -0
- package/dist/theme/knobsKept.d.ts +41 -0
- package/dist/theme/knobsKept.d.ts.map +1 -0
- package/dist/theme/knobsKept.js +67 -0
- package/dist/theme/knobsKept.js.map +1 -0
- package/dist/theme/oklch.d.ts +335 -0
- package/dist/theme/oklch.d.ts.map +1 -0
- package/dist/theme/oklch.js +258 -0
- package/dist/theme/oklch.js.map +1 -0
- package/dist/theme/raise.d.ts +16 -0
- package/dist/theme/raise.d.ts.map +1 -0
- package/dist/theme/raise.js +51 -0
- package/dist/theme/raise.js.map +1 -0
- package/dist/theme/root.d.ts +26 -0
- package/dist/theme/root.d.ts.map +1 -0
- package/dist/theme/root.js +42 -0
- package/dist/theme/root.js.map +1 -0
- package/dist/theme/scheme.d.ts +21 -0
- package/dist/theme/scheme.d.ts.map +1 -0
- package/dist/theme/scheme.js +42 -0
- package/dist/theme/scheme.js.map +1 -0
- package/dist/theme/scriptLiteral.d.ts +6 -0
- package/dist/theme/scriptLiteral.d.ts.map +1 -0
- package/dist/theme/scriptLiteral.js +9 -0
- package/dist/theme/scriptLiteral.js.map +1 -0
- package/dist/theme/shadows.d.ts +69 -0
- package/dist/theme/shadows.d.ts.map +1 -0
- package/dist/theme/shadows.js +99 -0
- package/dist/theme/shadows.js.map +1 -0
- package/dist/theme/themes.d.ts +66 -0
- package/dist/theme/themes.d.ts.map +1 -0
- package/dist/theme/themes.js +87 -0
- package/dist/theme/themes.js.map +1 -0
- package/dist/{tokens-CIBAmBRf.d.mts → theme/tokens.d.ts} +16 -350
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +321 -0
- package/dist/theme/tokens.js.map +1 -0
- package/dist/theme.d.ts +524 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +78 -0
- package/dist/theme.js.map +1 -0
- package/dist/{utilities.d.mts → utilities.d.ts} +6 -5
- package/dist/utilities.d.ts.map +1 -0
- package/dist/{utilities.mjs → utilities.js} +4 -4
- package/dist/utilities.js.map +1 -0
- package/package.json +29 -28
- package/dist/app.d.mts.map +0 -1
- package/dist/app.mjs.map +0 -1
- package/dist/core-BKDVG8xT.mjs.map +0 -1
- package/dist/core-DtE4hSjG.d.mts.map +0 -1
- package/dist/defaults.d.mts.map +0 -1
- package/dist/defaults.mjs.map +0 -1
- package/dist/foundations.d.mts.map +0 -1
- package/dist/foundations.mjs.map +0 -1
- package/dist/index.d.mts +0 -203
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -464
- package/dist/index.mjs.map +0 -1
- package/dist/layers-b5nx42uz.mjs.map +0 -1
- package/dist/layers.d.mts.map +0 -1
- package/dist/layers.mjs +0 -1
- package/dist/layout.d.mts.map +0 -1
- package/dist/layout.mjs.map +0 -1
- package/dist/pipe-BLRPph_m.d.mts.map +0 -1
- package/dist/prose.d.mts.map +0 -1
- package/dist/prose.mjs.map +0 -1
- package/dist/rolldown-runtime-D8jQpDG7.mjs +0 -12
- package/dist/root-DNvW49Q8.mjs +0 -370
- package/dist/root-DNvW49Q8.mjs.map +0 -1
- package/dist/slotItem-Cpv59kaT.d.mts.map +0 -1
- package/dist/slotMark-e8KUUb85.mjs.map +0 -1
- package/dist/slotView-DOeaLB2f.d.mts +0 -463
- package/dist/slotView-DOeaLB2f.d.mts.map +0 -1
- package/dist/style-AYR3dZQN.d.mts.map +0 -1
- package/dist/style-DDID8a-S.mjs +0 -1257
- package/dist/style-DDID8a-S.mjs.map +0 -1
- package/dist/styleValue-DAnH8FFQ.d.mts.map +0 -1
- package/dist/styleValue-agZrNfOL.mjs.map +0 -1
- package/dist/testing.d.mts.map +0 -1
- package/dist/testing.mjs.map +0 -1
- package/dist/theme.d.mts +0 -618
- package/dist/theme.d.mts.map +0 -1
- package/dist/theme.mjs +0 -228
- package/dist/theme.mjs.map +0 -1
- package/dist/themes-bB6oBgUD.d.mts +0 -492
- package/dist/themes-bB6oBgUD.d.mts.map +0 -1
- package/dist/tokens-CIBAmBRf.d.mts.map +0 -1
- package/dist/tokens-McwhqNmj.mjs +0 -1287
- package/dist/tokens-McwhqNmj.mjs.map +0 -1
- package/dist/utilities.d.mts.map +0 -1
- package/dist/utilities.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -188,7 +188,8 @@ Classes a stylesheet already on the page carries are left out, so
|
|
|
188
188
|
installing `Style.stylesheet(...)` yourself (for the first paint, or on the
|
|
189
189
|
server) never duplicates them. Outside a browser nothing is injected: a server
|
|
190
190
|
puts `Style.usedIn(html)`, the CSS of every compiled class the page's markup
|
|
191
|
-
uses
|
|
191
|
+
uses and the global rules of the Styles behind them (keyframes, `raise`'s depth
|
|
192
|
+
rules), in the page's head (with `foldkit-ssr`, through its `head` option).
|
|
192
193
|
|
|
193
194
|
## What the resolver guarantees
|
|
194
195
|
|
|
@@ -208,6 +209,39 @@ Conflicts throw `Diagnostics.DiagnosticError` with stable codes such as
|
|
|
208
209
|
DevTools and editor tooling can all speak the same diagnostic language. The style rule exists
|
|
209
210
|
because a positioning Behavior that writes `top` and a Style that also sets `top` would otherwise
|
|
210
211
|
fight silently, last writer winning.
|
|
212
|
+
A theme refuses its values the same way: `Theme.make` with a value out of a knob's range throws
|
|
213
|
+
`theme:knob-value`, naming the call and the knob (`Theme.make: surface.lightness refuses its
|
|
214
|
+
value: …`), and an unknown knob `theme:unknown-knob`.
|
|
215
|
+
|
|
216
|
+
Those are definition errors, thrown. One thing goes wrong only at runtime: a Mount composed
|
|
217
|
+
beside others that fails. It ends alone, so the slot's other Mounts go on, and it is reported as
|
|
218
|
+
a `MountFailed` diagnostic (`{ mount, slot, cause }`, level `error`) through `foldkit-surface`'s
|
|
219
|
+
`Diagnostics` channel, which by default is Effect's log (the console). A Mount that ends
|
|
220
|
+
interrupted is being torn down with its element and reports nothing. Foldkit runs a Mount in the
|
|
221
|
+
runtime's own context, not its `resources`, so the resolver dispatches the diagnostic at the
|
|
222
|
+
Mount's element (`Diagnostics.dispatch`), and a reporter given with `Diagnostics.layer(reporter)`
|
|
223
|
+
in the resources claims it; without one it goes to the log. A test runs the Mount's stream with
|
|
224
|
+
`Effect.provideService(Diagnostics.Reporter, collected.report)`, where `collected` is
|
|
225
|
+
`Diagnostics.collect()` (both from `foldkit-surface`), and asserts on `collected.reported`.
|
|
226
|
+
|
|
227
|
+
In development, `DevOverlay` lists on the page what the application's reporter heard, Mount
|
|
228
|
+
failures included:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { Diagnostics } from 'foldkit-surface'
|
|
232
|
+
import { DevOverlay } from 'foldkit-mixins'
|
|
233
|
+
|
|
234
|
+
const overlay = DevOverlay.make() // the newest 50; each passed on to Diagnostics.log
|
|
235
|
+
const resources = Diagnostics.layer(overlay.report)
|
|
236
|
+
// In the view, behind the application's development flag:
|
|
237
|
+
// h.div([h.OnMount(overlay.mount)], [])
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The panel is drawn in its element's shadow root, fixed in the bottom corner, with a Clear button,
|
|
241
|
+
and nothing while the list is empty. It sends no Message, so draw it only in development: a
|
|
242
|
+
Scene test of a page that draws it cannot resolve it.
|
|
243
|
+
The resolver's thrown `Diagnostics` namespace here is a different thing: import one of the two
|
|
244
|
+
under another name.
|
|
211
245
|
|
|
212
246
|
## Slots: the public contract
|
|
213
247
|
|
|
@@ -278,7 +312,7 @@ one.
|
|
|
278
312
|
| `Theme.schemeScript(key?)` / `Theme.chooseScheme(scheme, key?)` / `Theme.currentScheme()` | from `foldkit-mixins/theme`: a head script applying a kept `light` or `dark` before the first paint; a Command's Effect that applies and keeps a choice; the scheme applied now |
|
|
279
313
|
| `Theme.knobScript({ key?, selector? })` / `Theme.chooseKnobs(theme, { base, key?, selector? })` | from `foldkit-mixins/theme`: a head script applying kept knob variables before the first paint; a Command's Effect that applies `theme`'s knobs that differ from `base` and keeps them |
|
|
280
314
|
| `Theme.make(values)` / `Theme.standard(theme?)` / `Theme.fluidType({ min, max })` | from `foldkit-mixins/theme`: a theme, the typed knob values it changes (`Knobs.standard`); every shipped token with a theme's knobs, for `Theme.root`; one size blended between two lengths by the theme's fluid range |
|
|
281
|
-
| `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, reading, radius, motion, width, border, shadow and breakpoint scales, `icon` (the masks the components draw their own icons with,
|
|
315
|
+
| `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, reading, radius, motion, width, border, shadow and breakpoint scales, `icon` (the masks the components draw their own icons with, Heroicons' outline set at 2px by default; an application's pack is `foldkit-mixins-ui`'s `Icons.tokens(pack)`, passed as its own tokens), and `safe` (what a notch or the home indicator takes from each screen edge, `env(safe-area-inset-*)`, 0 unless the viewport meta says `viewport-fit=cover`); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
282
316
|
| `Layers.define(names)` / `Layers.standard` | cascade layers as a value: `names`, `declare` (the `@layer …;` statement as a global piece), `in(name, piece)` (a piece's unlayered rules and global CSS inside that layer; what is already layered keeps its layer; a piece wholly in another layer is `style:relayered`) and `layer(name)` (the placement `Style.forSlots(S)(pieces, { layer })` takes, so a slot style is compiled in that layer). A name outside the order is a type error. `standard` is `reset, tokens, theme, defaults, components, layouts, variants, utilities, app`; also under `foldkit-mixins/layers` |
|
|
283
317
|
| `Style.stylesheet(...)` | one `<style>` block from `NamedStyle`s and bare `StyleValue`s: the layer order hoisted first (two different orders is `style:conflicting-layer-order`), then global chunks, then scoped classes, deduplicated. Once an order is declared, a rule outside it is `style:unlayered-rule`, since it would beat every layer; keyframes, font faces and `@property` pass |
|
|
284
318
|
|
|
@@ -880,11 +914,62 @@ left and the row it reached, and no other. `drawRow` reads only its arguments,
|
|
|
880
914
|
so define it once, not per render. A Mixin that gives an item a handler made per
|
|
881
915
|
render, and an item drawing that holds another, are drawn every time: correct,
|
|
882
916
|
not cached.
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
917
|
+
An item no longer drawn is forgotten: a key is drawn once per pass, so a key
|
|
918
|
+
drawn again starts a new pass, and what neither that pass nor the one before
|
|
919
|
+
drew is dropped. Keys may come from something that keeps changing (a search's
|
|
920
|
+
results, 100,000 rows scrolled through) without the memo growing with them.
|
|
921
|
+
The memo is one per drawing function: two views drawing the same key with one
|
|
922
|
+
`drawRow` share it, and each misses whenever what it gives the row differs from
|
|
923
|
+
the other's. Drawn inert, nothing is kept.
|
|
924
|
+
|
|
925
|
+
### Regions: redraw by the Model paths read
|
|
926
|
+
|
|
927
|
+
A part reads keys of its view's input. An application view's input is the whole
|
|
928
|
+
Model, and the values a piece of it needs sit at paths below its fields: a
|
|
929
|
+
region names them through the application's field references, and is drawn
|
|
930
|
+
again only when a value at one of those paths changed.
|
|
931
|
+
|
|
932
|
+
```ts
|
|
933
|
+
const Header = SlotView.region(
|
|
934
|
+
Projection.struct({ cart: App.model.cart, title: App.model.page.title }),
|
|
935
|
+
({ cart, title }, slots: SlotView.SlotBuilders<typeof PageSlots, Message>, h: HtmlBuilder<Message>) =>
|
|
936
|
+
h.header(slots.header.attrs(), [title, ` (${cart.length} in the cart)`]),
|
|
937
|
+
)
|
|
938
|
+
// In the page's render, beside anything else it draws:
|
|
939
|
+
Header(model, slots, h)
|
|
940
|
+
```
|
|
941
|
+
|
|
942
|
+
`Projection` and `App.model` are `foldkit-surface`'s (any value with
|
|
943
|
+
`dependencies` and `read` will do). Each render, the region compares the
|
|
944
|
+
values at its paths with the last ones, by identity: all the same, it neither
|
|
945
|
+
reads nor draws, and Foldkit reuses its last drawing without diffing it. One
|
|
946
|
+
changed, it reads; a read holding the same fields as the last (a value derived
|
|
947
|
+
with `Projection.fromReader` that came out the same) is not drawn either. That
|
|
948
|
+
is `Projection.derive`'s rule, which the region is built on: a value a view
|
|
949
|
+
works out on every render without drawing it (a filtered list, a summary of
|
|
950
|
+
many Remote reads) is a `Projection.derive`, and a region can be drawn from
|
|
951
|
+
one. A Remote read declares no Model path, alone or in a `Projection.struct`
|
|
952
|
+
beside fields, so a region over one reads on every render and is drawn
|
|
953
|
+
again when the read gives new fields. Drawn from a `Projection.derive` that
|
|
954
|
+
names the store's field (`App.model.remote`) and makes the Remote read inside,
|
|
955
|
+
it is not read while the store holds.
|
|
956
|
+
|
|
957
|
+
- **It reads only its value.** `Header`'s drawing is given what the
|
|
958
|
+
Projection reads, so it cannot read a path it is not drawn again for. A
|
|
959
|
+
helper written over the Model takes `Pick<Model, …>` instead.
|
|
960
|
+
- **Its paths must be from the root.** A Projection built from field
|
|
961
|
+
references has them; one from `Projection.fromReader` needs its
|
|
962
|
+
`dependencies`, and one with none is read on every render.
|
|
963
|
+
- **Slots, Mixins and nesting** work as for an item: a Mixin reading the
|
|
964
|
+
view's input draws it every time, and a region or item drawn inside
|
|
965
|
+
another is drawn in place, the outer one every time. Put regions where
|
|
966
|
+
their reads are narrow (a header, a toolbar, a panel), and items in the
|
|
967
|
+
lists between them.
|
|
968
|
+
- **A reused drawing is not patched.** While its paths hold, Foldkit does
|
|
969
|
+
not touch the region's DOM, so a field whose `update` refused a keystroke
|
|
970
|
+
shows what was typed until a path it reads changes. Keep such a field's
|
|
971
|
+
value among its reads, or outside a region.
|
|
972
|
+
- **Memoizing needs a running application,** as for parts.
|
|
888
973
|
|
|
889
974
|
## With `foldkit-surface`
|
|
890
975
|
|
package/dist/a11y.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Diagnostic } from "./diagnostics.js";
|
|
2
|
+
import { Any, AttributeName, EventName, SlotCapability } from "./slot.js";
|
|
3
|
+
export type A11yDiagnosticCode = 'a11y:missing-slot' | 'a11y:hidden-slot' | 'a11y:capability-mismatch' | 'a11y:missing-event' | 'a11y:missing-attribute';
|
|
4
|
+
export interface A11yDiagnostic extends Diagnostic {
|
|
5
|
+
readonly source: 'a11y';
|
|
6
|
+
readonly code: A11yDiagnosticCode;
|
|
7
|
+
}
|
|
8
|
+
export interface SlotRequirement {
|
|
9
|
+
readonly capability?: SlotCapability;
|
|
10
|
+
readonly events?: ReadonlyArray<EventName>;
|
|
11
|
+
readonly attributes?: ReadonlyArray<AttributeName>;
|
|
12
|
+
/** An absent slot is expected, not a diagnostic. A present slot is still checked. */
|
|
13
|
+
readonly optional?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type Requirements = Readonly<Record<string, SlotRequirement>>;
|
|
16
|
+
export declare const PatternTypeId: unique symbol;
|
|
17
|
+
export interface Pattern<Spec extends Requirements = Requirements> {
|
|
18
|
+
readonly [PatternTypeId]: {
|
|
19
|
+
readonly Requirements: Spec;
|
|
20
|
+
};
|
|
21
|
+
readonly requirements: Spec;
|
|
22
|
+
}
|
|
23
|
+
export declare const pattern: <const Spec extends Requirements>(spec: Spec) => Pattern<Spec>;
|
|
24
|
+
export declare const validate: (pattern: Pattern, slots: {
|
|
25
|
+
readonly [name: string]: Any;
|
|
26
|
+
}) => ReadonlyArray<A11yDiagnostic>;
|
|
27
|
+
//# sourceMappingURL=a11y.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.d.ts","names":["AnySlot"],"sources":["../src/a11y.ts"],"mappings":";;YAaY;iBAOK,uBAAuB;WAC7B;WACA,MAAM;;iBAGA;WACN,aAAa;WACb,SAAS,cAAc;WACvB,aAAa,cAAc;;WAE3B;;YAGC,eAAe,SAAS,eAAe;qBAEtC;iBAEI,QAAQ,aAAa,eAAe;YACzC;aAA2B,cAAc;;WAC1C,cAAc;;qBAGZ,gBAAiB,aAAa,cAAY,MAAQ,SAAO,QAAQ;qBAyCjE,WAAQ,SACV,SAAO;YACG,eAAeA;MACjC,cAAc"}
|
package/dist/a11y.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as Capability from "./capability.js";
|
|
2
|
+
import * as MetadataToken from "./metadataToken.js";
|
|
3
|
+
// src/a11y.ts
|
|
4
|
+
/**
|
|
5
|
+
* Structural accessibility validation. A `Pattern` names the Slots a widget
|
|
6
|
+
* must publish, the capabilities those Slots must satisfy, and the events and
|
|
7
|
+
* attributes they must expose. `validate` compares a `Slots` contract against a
|
|
8
|
+
* pattern and reports every mismatch as a `Diagnostic`. It is pure and
|
|
9
|
+
* DOM-independent: it checks the declared contract, not a rendered tree, so it
|
|
10
|
+
* verifies only the contract it is given and does not certify WCAG conformance.
|
|
11
|
+
*/
|
|
12
|
+
const PatternTypeId = Symbol.for("foldkit-mixins/A11yPattern");
|
|
13
|
+
const pattern = (spec) => {
|
|
14
|
+
const requirements = Object.create(null);
|
|
15
|
+
for (const name of Object.getOwnPropertyNames(spec)) {
|
|
16
|
+
const requirement = spec[name];
|
|
17
|
+
if (requirement === void 0) continue;
|
|
18
|
+
Object.defineProperty(requirements, name, {
|
|
19
|
+
value: Object.freeze({ ...requirement }),
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: false,
|
|
22
|
+
writable: false
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
Object.freeze(requirements);
|
|
26
|
+
return Object.freeze({
|
|
27
|
+
[PatternTypeId]: { Requirements: void 0 },
|
|
28
|
+
requirements
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const publishes = (names, required) => {
|
|
32
|
+
const requiredName = MetadataToken.nameOf(required);
|
|
33
|
+
return names.some((name) => MetadataToken.nameOf(name) === requiredName);
|
|
34
|
+
};
|
|
35
|
+
const diagnostic = (code, message, slot, details) => ({
|
|
36
|
+
source: "a11y",
|
|
37
|
+
code,
|
|
38
|
+
severity: "error",
|
|
39
|
+
message,
|
|
40
|
+
slot,
|
|
41
|
+
...details === void 0 ? {} : { details }
|
|
42
|
+
});
|
|
43
|
+
const validate = (pattern, slots) => {
|
|
44
|
+
const diagnostics = [];
|
|
45
|
+
for (const name of Object.getOwnPropertyNames(pattern.requirements)) {
|
|
46
|
+
const requirement = pattern.requirements[name];
|
|
47
|
+
if (requirement === void 0) continue;
|
|
48
|
+
if (!Object.hasOwn(slots, name)) {
|
|
49
|
+
if (requirement.optional === true) continue;
|
|
50
|
+
diagnostics.push(diagnostic("a11y:missing-slot", `A11y pattern requires slot "${name}", which the contract does not publish`, name));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const slot = slots[name];
|
|
54
|
+
if (slot === void 0) continue;
|
|
55
|
+
if (slot.hidden) {
|
|
56
|
+
diagnostics.push(diagnostic("a11y:hidden-slot", `A11y pattern requires slot "${name}", which is hidden`, name));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (requirement.capability !== void 0 && !Capability.extendsCapability(slot.capability, requirement.capability)) diagnostics.push(diagnostic("a11y:capability-mismatch", `A11y pattern requires capability "${MetadataToken.nameOf(requirement.capability)}" on slot "${name}", which has "${MetadataToken.nameOf(slot.capability)}"`, name, {
|
|
60
|
+
required: MetadataToken.nameOf(requirement.capability),
|
|
61
|
+
actual: MetadataToken.nameOf(slot.capability)
|
|
62
|
+
}));
|
|
63
|
+
for (const event of requirement.events ?? []) {
|
|
64
|
+
const eventName = MetadataToken.nameOf(event);
|
|
65
|
+
if (publishes(slot.events, event)) continue;
|
|
66
|
+
diagnostics.push(diagnostic("a11y:missing-event", `A11y pattern requires event "${eventName}" on slot "${name}", which does not publish it`, name, { event: eventName }));
|
|
67
|
+
}
|
|
68
|
+
for (const attribute of requirement.attributes ?? []) {
|
|
69
|
+
const attributeName = MetadataToken.nameOf(attribute);
|
|
70
|
+
if (publishes(slot.attributes, attribute)) continue;
|
|
71
|
+
diagnostics.push(diagnostic("a11y:missing-attribute", `A11y pattern requires attribute "${attributeName}" on slot "${name}", which does not publish it`, name, { attribute: attributeName }));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return diagnostics;
|
|
75
|
+
};
|
|
76
|
+
export { PatternTypeId, pattern, validate };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=a11y.js.map
|
package/dist/a11y.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a11y.js","names":[],"sources":["../src/a11y.ts"],"sourcesContent":["/**\n * Structural accessibility validation. A `Pattern` names the Slots a widget\n * must publish, the capabilities those Slots must satisfy, and the events and\n * attributes they must expose. `validate` compares a `Slots` contract against a\n * pattern and reports every mismatch as a `Diagnostic`. It is pure and\n * DOM-independent: it checks the declared contract, not a rendered tree, so it\n * verifies only the contract it is given and does not certify WCAG conformance.\n */\nimport * as Capability from './capability.js'\nimport type { Diagnostic } from './diagnostics.js'\nimport * as MetadataToken from './metadataToken.js'\nimport type { Any as AnySlot, AttributeName, EventName, SlotCapability } from './slot.js'\n\nexport type A11yDiagnosticCode =\n | 'a11y:missing-slot'\n | 'a11y:hidden-slot'\n | 'a11y:capability-mismatch'\n | 'a11y:missing-event'\n | 'a11y:missing-attribute'\n\nexport interface A11yDiagnostic extends Diagnostic {\n readonly source: 'a11y'\n readonly code: A11yDiagnosticCode\n}\n\nexport interface SlotRequirement {\n readonly capability?: SlotCapability\n readonly events?: ReadonlyArray<EventName>\n readonly attributes?: ReadonlyArray<AttributeName>\n /** An absent slot is expected, not a diagnostic. A present slot is still checked. */\n readonly optional?: boolean\n}\n\nexport type Requirements = Readonly<Record<string, SlotRequirement>>\n\nexport const PatternTypeId: unique symbol = Symbol.for('foldkit-mixins/A11yPattern')\n\nexport interface Pattern<Spec extends Requirements = Requirements> {\n readonly [PatternTypeId]: { readonly Requirements: Spec }\n readonly requirements: Spec\n}\n\nexport const pattern = <const Spec extends Requirements>(spec: Spec): Pattern<Spec> => {\n const requirements = Object.create(null) as Record<string, SlotRequirement>\n for (const name of Object.getOwnPropertyNames(spec)) {\n const requirement = spec[name]\n if (requirement === undefined) continue\n Object.defineProperty(requirements, name, {\n value: Object.freeze({ ...requirement }),\n enumerable: true,\n configurable: false,\n writable: false,\n })\n }\n Object.freeze(requirements)\n return Object.freeze({\n [PatternTypeId]: { Requirements: undefined as unknown as Spec },\n requirements: requirements as Spec,\n }) as Pattern<Spec>\n}\n\nconst publishes = (\n names: ReadonlyArray<string | MetadataToken.Any>,\n required: string | MetadataToken.Any,\n): boolean => {\n const requiredName = MetadataToken.nameOf(required)\n return names.some(name => MetadataToken.nameOf(name) === requiredName)\n}\n\nconst diagnostic = (\n code: A11yDiagnosticCode,\n message: string,\n slot: string,\n details?: Readonly<Record<string, unknown>>,\n): A11yDiagnostic => ({\n source: 'a11y',\n code,\n severity: 'error',\n message,\n slot,\n ...(details === undefined ? {} : { details }),\n})\n\nexport const validate = (\n pattern: Pattern,\n slots: { readonly [name: string]: AnySlot },\n): ReadonlyArray<A11yDiagnostic> => {\n const diagnostics: Array<A11yDiagnostic> = []\n for (const name of Object.getOwnPropertyNames(pattern.requirements)) {\n const requirement = pattern.requirements[name]\n if (requirement === undefined) continue\n if (!Object.hasOwn(slots, name)) {\n if (requirement.optional === true) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-slot',\n `A11y pattern requires slot \"${name}\", which the contract does not publish`,\n name,\n ),\n )\n continue\n }\n const slot = slots[name]\n if (slot === undefined) continue\n if (slot.hidden) {\n diagnostics.push(\n diagnostic(\n 'a11y:hidden-slot',\n `A11y pattern requires slot \"${name}\", which is hidden`,\n name,\n ),\n )\n continue\n }\n if (\n requirement.capability !== undefined &&\n !Capability.extendsCapability(slot.capability, requirement.capability)\n ) {\n diagnostics.push(\n diagnostic(\n 'a11y:capability-mismatch',\n `A11y pattern requires capability \"${MetadataToken.nameOf(requirement.capability)}\" on slot \"${name}\", which has \"${MetadataToken.nameOf(slot.capability)}\"`,\n name,\n {\n required: MetadataToken.nameOf(requirement.capability),\n actual: MetadataToken.nameOf(slot.capability),\n },\n ),\n )\n }\n for (const event of requirement.events ?? []) {\n const eventName = MetadataToken.nameOf(event)\n if (publishes(slot.events, event)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-event',\n `A11y pattern requires event \"${eventName}\" on slot \"${name}\", which does not publish it`,\n name,\n { event: eventName },\n ),\n )\n }\n for (const attribute of requirement.attributes ?? []) {\n const attributeName = MetadataToken.nameOf(attribute)\n if (publishes(slot.attributes, attribute)) continue\n diagnostics.push(\n diagnostic(\n 'a11y:missing-attribute',\n `A11y pattern requires attribute \"${attributeName}\" on slot \"${name}\", which does not publish it`,\n name,\n { attribute: attributeName },\n ),\n )\n }\n }\n return diagnostics\n}\n"],"mappings":";;;;;;;;;;;AAmCA,MAAa,gBAA+B,OAAO,IAAI,4BAA4B;AAOnF,MAAa,WAA4C,SAA8B;CACrF,MAAM,eAAe,OAAO,OAAO,IAAI;CACvC,KAAK,MAAM,QAAQ,OAAO,oBAAoB,IAAI,GAAG;EACnD,MAAM,cAAc,KAAK;EACzB,IAAI,gBAAgB,KAAA,GAAW;EAC/B,OAAO,eAAe,cAAc,MAAM;GACxC,OAAO,OAAO,OAAO,EAAE,GAAG,YAAY,CAAC;GACvC,YAAY;GACZ,cAAc;GACd,UAAU;EACZ,CAAC;CACH;CACA,OAAO,OAAO,YAAY;CAC1B,OAAO,OAAO,OAAO;GAClB,gBAAgB,EAAE,cAAc,KAAA,EAA6B;EAChD;CAChB,CAAC;AACH;AAEA,MAAM,aACJ,OACA,aACY;CACZ,MAAM,eAAe,cAAc,OAAO,QAAQ;CAClD,OAAO,MAAM,MAAK,SAAQ,cAAc,OAAO,IAAI,MAAM,YAAY;AACvE;AAEA,MAAM,cACJ,MACA,SACA,MACA,aACoB;CACpB,QAAQ;CACR;CACA,UAAU;CACV;CACA;CACA,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ;AAC7C;AAEA,MAAa,YACX,SACA,UACkC;CAClC,MAAM,cAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,OAAO,oBAAoB,QAAQ,YAAY,GAAG;EACnE,MAAM,cAAc,QAAQ,aAAa;EACzC,IAAI,gBAAgB,KAAA,GAAW;EAC/B,IAAI,CAAC,OAAO,OAAO,OAAO,IAAI,GAAG;GAC/B,IAAI,YAAY,aAAa,MAAM;GACnC,YAAY,KACV,WACE,qBACA,+BAA+B,KAAK,yCACpC,IACF,CACF;GACA;EACF;EACA,MAAM,OAAO,MAAM;EACnB,IAAI,SAAS,KAAA,GAAW;EACxB,IAAI,KAAK,QAAQ;GACf,YAAY,KACV,WACE,oBACA,+BAA+B,KAAK,qBACpC,IACF,CACF;GACA;EACF;EACA,IACE,YAAY,eAAe,KAAA,KAC3B,CAAC,WAAW,kBAAkB,KAAK,YAAY,YAAY,UAAU,GAErE,YAAY,KACV,WACE,4BACA,qCAAqC,cAAc,OAAO,YAAY,UAAU,EAAE,aAAa,KAAK,gBAAgB,cAAc,OAAO,KAAK,UAAU,EAAE,IAC1J,MACA;GACE,UAAU,cAAc,OAAO,YAAY,UAAU;GACrD,QAAQ,cAAc,OAAO,KAAK,UAAU;EAC9C,CACF,CACF;EAEF,KAAK,MAAM,SAAS,YAAY,UAAU,CAAC,GAAG;GAC5C,MAAM,YAAY,cAAc,OAAO,KAAK;GAC5C,IAAI,UAAU,KAAK,QAAQ,KAAK,GAAG;GACnC,YAAY,KACV,WACE,sBACA,gCAAgC,UAAU,aAAa,KAAK,+BAC5D,MACA,EAAE,OAAO,UAAU,CACrB,CACF;EACF;EACA,KAAK,MAAM,aAAa,YAAY,cAAc,CAAC,GAAG;GACpD,MAAM,gBAAgB,cAAc,OAAO,SAAS;GACpD,IAAI,UAAU,KAAK,YAAY,SAAS,GAAG;GAC3C,YAAY,KACV,WACE,0BACA,oCAAoC,cAAc,aAAa,KAAK,+BACpE,MACA,EAAE,WAAW,cAAc,CAC7B,CACF;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { standard } from "./layers.js";
|
|
2
|
+
import { Declared, DeclaredPieces, NamedStyle, StyleOptions, StylePieces } from "./style.js";
|
|
3
|
+
import { StyleValue } from "./styleValue.js";
|
|
4
|
+
import { Refs, ThemeTokens, compose as compose$1 } from "./theme/core.js";
|
|
5
|
+
import { RootOptions } from "./theme/root.js";
|
|
6
|
+
import { StandardTokens, Themes } from "./theme/themes.js";
|
|
7
|
+
import { KnobTheme, Standard } from "./theme/knobs.js";
|
|
6
8
|
interface Common<Own extends ThemeTokens> {
|
|
7
9
|
/**
|
|
8
10
|
* Tokens of the application's own, laid over the shipped ones:
|
|
@@ -18,8 +20,8 @@ interface Common<Own extends ThemeTokens> {
|
|
|
18
20
|
readonly global?: ReadonlyArray<StyleValue>;
|
|
19
21
|
}
|
|
20
22
|
export interface AppStyleOptions<Own extends ThemeTokens> extends Common<Own> {
|
|
21
|
-
/** The application's one theme: `Theme.make({ … })`. */
|
|
22
|
-
readonly theme
|
|
23
|
+
/** The application's one theme: `Theme.make({ … })`. Default the shipped one, `Theme.make({})`. */
|
|
24
|
+
readonly theme?: KnobTheme<Standard>;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* The options with a set of named themes in place of one: the root declares
|
|
@@ -33,9 +35,9 @@ export interface AppStyleThemesOptions<Name extends string, Own extends ThemeTok
|
|
|
33
35
|
export type AppStyleOptionsFor = Omit<StyleOptions, 'layer'>;
|
|
34
36
|
export interface AppStyle<Own extends ThemeTokens> {
|
|
35
37
|
/** Every shipped token with the theme's knobs, and the application's own over them. */
|
|
36
|
-
readonly theme: ReturnType<typeof compose<StandardTokens, Own>>;
|
|
38
|
+
readonly theme: ReturnType<typeof compose$1<StandardTokens, Own>>;
|
|
37
39
|
/** Every token of `theme` as a typed `var(--fk-…)` reference. */
|
|
38
|
-
readonly t: Refs<ReturnType<typeof compose<StandardTokens, Own>>>;
|
|
40
|
+
readonly t: Refs<ReturnType<typeof compose$1<StandardTokens, Own>>>;
|
|
39
41
|
/** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */
|
|
40
42
|
readonly L: typeof standard;
|
|
41
43
|
/** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */
|
|
@@ -47,7 +49,8 @@ export interface AppStyle<Own extends ThemeTokens> {
|
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* The application's tokens, layer and page stylesheet:
|
|
50
|
-
* `const { t, slots, stylesheet } = AppStyle.make({ theme: Theme.make({ … }) })
|
|
52
|
+
* `const { t, slots, stylesheet } = AppStyle.make({ theme: Theme.make({ … }) })`,
|
|
53
|
+
* or `AppStyle.make({})` on the shipped theme.
|
|
51
54
|
* Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS
|
|
52
55
|
* when it first draws them.
|
|
53
56
|
*/
|
|
@@ -57,4 +60,4 @@ export declare const AppStyle: {
|
|
|
57
60
|
readonly make: typeof make;
|
|
58
61
|
};
|
|
59
62
|
export {};
|
|
60
|
-
//# sourceMappingURL=app.d.
|
|
63
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","names":["composeThemes"],"sources":["../src/app.ts"],"mappings":";;;;;;;UAyBU,OAAO,YAAY;;;;;WAKlB,SAAS;;WAET,cAAc,YAAY;;;;;WAK1B,SAAS,cAAc;;iBAGjB,gBAAgB,YAAY,qBAAqB,OAAO;;WAE9D,QAAQ,UAAU;;;;;;;iBAQZ,sBACf,qBACA,YAAY,qBACJ,OAAO;WACN,QAAQ,OAAO;;;YAId,qBAAqB,KAAK;iBAErB,SAAS,YAAY;;WAE3B,OAAO,kBAAkBA,UAAc,gBAAgB;;WAEvD,GAAG,KAAK,kBAAkBA,UAAc,gBAAgB;;WAExD,UAAU;;WAEV,QAAQ,GAAG,QAAQ,eAAe,IAAI,UAAU,uBAAuB,SAAS;;WAEhF,WAAW,OAClB,UAAU,WACN,QAAQ,YAAY,QAAQ,UAAU,uBAAuB,WAAW;;WAErE;;;;;;;;;wBAYK,KAAK,qBAAqB,YAAY,cAAc,sBAClE,SAAS,sBAAsB,MAAM,OACpC,SAAS;wBACI,KAAK,YAAY,cAAc,sBAC7C,SAAS,gBAAgB,OACxB,SAAS;qBA2BC"}
|
package/dist/{app.mjs → app.js}
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { body, reset } from "./defaults.js";
|
|
2
|
+
import { standard } from "./layers.js";
|
|
3
|
+
import { forSlots, slots, stylesheet } from "./style.js";
|
|
4
|
+
import { compose } from "./styleValue.js";
|
|
5
|
+
import { compose as compose$1, ref } from "./theme/core.js";
|
|
6
|
+
import { root } from "./theme/root.js";
|
|
7
|
+
import { standardOf } from "./theme/themes.js";
|
|
7
8
|
// src/app.ts
|
|
8
9
|
/**
|
|
9
10
|
* `foldkit-mixins/app`: an application's style setup, fixed once. Every
|
|
@@ -35,4 +36,4 @@ function make(options) {
|
|
|
35
36
|
const AppStyle = { make };
|
|
36
37
|
export { AppStyle, make };
|
|
37
38
|
|
|
38
|
-
//# sourceMappingURL=app.
|
|
39
|
+
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","names":["composeThemes"],"sources":["../src/app.ts"],"sourcesContent":["/**\n * `foldkit-mixins/app`: an application's style setup, fixed once. Every\n * application on the standard layers writes the same preamble: its theme's\n * tokens, their references, the `app` layer passed to each style, and a page\n * stylesheet of the layer order, the reset, the tokens and the body defaults.\n * `AppStyle.make` is that preamble as a value.\n */\nimport { body, reset } from './defaults.js'\nimport { standard } from './layers.js'\nimport {\n forSlots,\n slots,\n stylesheet,\n type Declared,\n type DeclaredPieces,\n type NamedStyle,\n type StyleOptions,\n type StylePieces,\n} from './style.js'\nimport { compose, type StyleValue } from './styleValue.js'\nimport { compose as composeThemes, ref, type Refs, type ThemeTokens } from './theme/core.js'\nimport type { KnobTheme, Standard } from './theme/knobs.js'\nimport { root, type RootOptions } from './theme/root.js'\nimport { standardOf, type StandardTokens, type Themes } from './theme/themes.js'\n\ninterface Common<Own extends ThemeTokens> {\n /**\n * Tokens of the application's own, laid over the shipped ones:\n * `Theme.define({ game: { … } })`, read through `t` beside them.\n */\n readonly tokens?: Own\n /** The page's `color-scheme`; `'light'` keeps a light page light in a dark browser. Default `'light dark'`. */\n readonly colorScheme?: NonNullable<RootOptions['colorScheme']>\n /**\n * More page-wide pieces after `Defaults.body`, such as `Defaults.headings`,\n * keyframes or a font face, placed in the `defaults` layer.\n */\n readonly global?: ReadonlyArray<StyleValue>\n}\n\nexport interface AppStyleOptions<Own extends ThemeTokens> extends Common<Own> {\n /** The application's one theme: `Theme.make({ … })`. Default the shipped one, `Theme.make({})`. */\n readonly theme?: KnobTheme<Standard>\n}\n\n/**\n * The options with a set of named themes in place of one: the root declares\n * the initial theme, and each other is drawn where the Model names it\n * (`Themes.apply`).\n */\nexport interface AppStyleThemesOptions<\n Name extends string,\n Own extends ThemeTokens,\n> extends Common<Own> {\n readonly themes: Themes<Name>\n}\n\n/** A style's options with its layer fixed to the application's. */\nexport type AppStyleOptionsFor = Omit<StyleOptions, 'layer'>\n\nexport interface AppStyle<Own extends ThemeTokens> {\n /** Every shipped token with the theme's knobs, and the application's own over them. */\n readonly theme: ReturnType<typeof composeThemes<StandardTokens, Own>>\n /** Every token of `theme` as a typed `var(--fk-…)` reference. */\n readonly t: Refs<ReturnType<typeof composeThemes<StandardTokens, Own>>>\n /** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */\n readonly L: typeof standard\n /** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */\n readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>\n /** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */\n readonly forSlots: <Slots>(\n contract: Slots,\n ) => (pieces: StylePieces<Slots>, options?: AppStyleOptionsFor) => NamedStyle<Slots>\n /** The page sheet: the layer order, reset, tokens, `Defaults.body` and `global`. */\n readonly stylesheet: string\n}\n\nconst app = standard.layer('app')\n\n/**\n * The application's tokens, layer and page stylesheet:\n * `const { t, slots, stylesheet } = AppStyle.make({ theme: Theme.make({ … }) })`,\n * or `AppStyle.make({})` on the shipped theme.\n * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS\n * when it first draws them.\n */\nexport function make<Name extends string, Own extends ThemeTokens = Record<never, never>>(\n options: AppStyleThemesOptions<Name, Own>,\n): AppStyle<Own>\nexport function make<Own extends ThemeTokens = Record<never, never>>(\n options: AppStyleOptions<Own>,\n): AppStyle<Own>\nexport function make(\n options: AppStyleOptions<ThemeTokens> | AppStyleThemesOptions<string, ThemeTokens>,\n): AppStyle<ThemeTokens> {\n const shipped = 'themes' in options ? options.themes.root : standardOf(options.theme)\n const theme = composeThemes(shipped, options.tokens ?? {})\n const scheme = options.colorScheme === undefined ? {} : { colorScheme: options.colorScheme }\n return Object.freeze({\n theme,\n t: ref(theme),\n L: standard,\n slots: <S>(pieces: DeclaredPieces<S>, styleOptions?: AppStyleOptionsFor) =>\n slots(pieces, { ...styleOptions, layer: app }),\n forSlots:\n <Slots>(contract: Slots) =>\n (pieces: StylePieces<Slots>, styleOptions?: AppStyleOptionsFor) =>\n forSlots(contract)(pieces, { ...styleOptions, layer: app }),\n stylesheet: stylesheet(\n standard.declare,\n standard.in('reset', reset),\n standard.in('theme', root(theme, scheme)),\n ...('themes' in options ? [standard.in('theme', options.themes.scoped)] : []),\n standard.in('defaults', compose(body, ...(options.global ?? []))),\n ),\n })\n}\n\nexport const AppStyle = { make } as const\n"],"mappings":";;;;;;;;;;;;;;;AA6EA,MAAM,MAAM,SAAS,MAAM,KAAK;AAehC,SAAgB,KACd,SACuB;CACvB,MAAM,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,WAAW,QAAQ,KAAK;CACpF,MAAM,QAAQA,UAAc,SAAS,QAAQ,UAAU,CAAC,CAAC;CACzD,MAAM,SAAS,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;CAC3F,OAAO,OAAO,OAAO;EACnB;EACA,GAAG,IAAI,KAAK;EACZ,GAAG;EACH,QAAW,QAA2B,iBACpC,MAAM,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC/C,WACU,cACP,QAA4B,iBAC3B,SAAS,QAAQ,CAAC,CAAC,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC9D,YAAY,WACV,SAAS,SACT,SAAS,GAAG,SAAS,KAAK,GAC1B,SAAS,GAAG,SAAS,KAAK,OAAO,MAAM,CAAC,GACxC,GAAI,YAAY,UAAU,CAAC,SAAS,GAAG,SAAS,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,GAC3E,SAAS,GAAG,YAAY,QAAQ,MAAM,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC,CAClE;CACF,CAAC;AACH;AAEA,MAAa,WAAW,EAAE,KAAK"}
|
package/dist/attr.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as MetadataToken from "./metadataToken.js";
|
|
2
|
+
export type AttrToken<Name extends string = string> = MetadataToken.MetadataToken<'view.attribute', Name>;
|
|
3
|
+
export declare const is: (value: unknown) => value is AttrToken;
|
|
4
|
+
export declare const make: <const Name extends string>(name: Name) => AttrToken<Name>;
|
|
5
|
+
export declare const equals: (left: AttrToken, right: AttrToken) => boolean;
|
|
6
|
+
export declare const describe: (attr: AttrToken) => {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const Role: AttrToken<"role">;
|
|
10
|
+
export declare const AriaLabel: AttrToken<"aria-label">;
|
|
11
|
+
export declare const AriaDescribedby: AttrToken<"aria-describedby">;
|
|
12
|
+
export declare const AriaExpanded: AttrToken<"aria-expanded">;
|
|
13
|
+
export declare const AriaSelected: AttrToken<"aria-selected">;
|
|
14
|
+
export declare const AriaInvalid: AttrToken<"aria-invalid">;
|
|
15
|
+
export declare const AriaPressed: AttrToken<"aria-pressed">;
|
|
16
|
+
export declare const AriaDisabled: AttrToken<"aria-disabled">;
|
|
17
|
+
export declare const Disabled: AttrToken<"disabled">;
|
|
18
|
+
export declare const Value: AttrToken<"value">;
|
|
19
|
+
//# sourceMappingURL=attr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr.d.ts","names":[],"sources":["../src/attr.ts"],"mappings":";YAMY,UAAU,gCAAgC,cAAc,gCAElE;qBAGW,KAAE,mBAAqB,SAAS;qBAGhC,aAAc,qBAAmB,MAAQ,SAAO,UAAU;qBAG1D,SAAM,MAAU,WAAS,OAAS;qBAElC,WAAQ,MAAU;WAAuB;;qBAIzC,MAAI;qBACJ,WAAS;qBACT,iBAAe;qBACf,cAAY;qBACZ,cAAY;qBACZ,aAAW;qBACX,aAAW;qBACX,cAAY;qBACZ,UAAQ;qBACR,OAAK"}
|
package/dist/attr.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as MetadataToken from "./metadataToken.js";
|
|
2
|
+
// src/attr.ts
|
|
3
|
+
/**
|
|
4
|
+
* Slot attribute tokens. Ported from `effect-atom-jsx/src/View.ts` `Attribute`,
|
|
5
|
+
* plus ARIA names the Foldkit plan lists.
|
|
6
|
+
*/
|
|
7
|
+
const is = (value) => MetadataToken.is(value) && value.kind === "view.attribute";
|
|
8
|
+
const make = (name) => MetadataToken.make("view.attribute", name);
|
|
9
|
+
const equals = (left, right) => left.name === right.name;
|
|
10
|
+
const describe = (attr) => ({ name: attr.name });
|
|
11
|
+
const Role = make("role");
|
|
12
|
+
const AriaLabel = make("aria-label");
|
|
13
|
+
const AriaDescribedby = make("aria-describedby");
|
|
14
|
+
const AriaExpanded = make("aria-expanded");
|
|
15
|
+
const AriaSelected = make("aria-selected");
|
|
16
|
+
const AriaInvalid = make("aria-invalid");
|
|
17
|
+
const AriaPressed = make("aria-pressed");
|
|
18
|
+
const AriaDisabled = make("aria-disabled");
|
|
19
|
+
const Disabled = make("disabled");
|
|
20
|
+
const Value = make("value");
|
|
21
|
+
export { AriaDescribedby, AriaDisabled, AriaExpanded, AriaInvalid, AriaLabel, AriaPressed, AriaSelected, Disabled, Role, Value, describe, equals, is, make };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=attr.js.map
|
package/dist/attr.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr.js","names":[],"sources":["../src/attr.ts"],"sourcesContent":["/**\n * Slot attribute tokens. Ported from `effect-atom-jsx/src/View.ts` `Attribute`,\n * plus ARIA names the Foldkit plan lists.\n */\nimport * as MetadataToken from './metadataToken.js'\n\nexport type AttrToken<Name extends string = string> = MetadataToken.MetadataToken<\n 'view.attribute',\n Name\n>\n\nexport const is = (value: unknown): value is AttrToken =>\n MetadataToken.is(value) && value.kind === 'view.attribute'\n\nexport const make = <const Name extends string>(name: Name): AttrToken<Name> =>\n MetadataToken.make('view.attribute', name)\n\nexport const equals = (left: AttrToken, right: AttrToken): boolean => left.name === right.name\n\nexport const describe = (attr: AttrToken): { readonly name: string } => ({\n name: attr.name,\n})\n\nexport const Role = make('role')\nexport const AriaLabel = make('aria-label')\nexport const AriaDescribedby = make('aria-describedby')\nexport const AriaExpanded = make('aria-expanded')\nexport const AriaSelected = make('aria-selected')\nexport const AriaInvalid = make('aria-invalid')\nexport const AriaPressed = make('aria-pressed')\nexport const AriaDisabled = make('aria-disabled')\nexport const Disabled = make('disabled')\nexport const Value = make('value')\n"],"mappings":";;;;;;AAWA,MAAa,MAAM,UACjB,cAAc,GAAG,KAAK,KAAK,MAAM,SAAS;AAE5C,MAAa,QAAmC,SAC9C,cAAc,KAAK,kBAAkB,IAAI;AAE3C,MAAa,UAAU,MAAiB,UAA8B,KAAK,SAAS,MAAM;AAE1F,MAAa,YAAY,UAAgD,EACvE,MAAM,KAAK,KACb;AAEA,MAAa,OAAO,KAAK,MAAM;AAC/B,MAAa,YAAY,KAAK,YAAY;AAC1C,MAAa,kBAAkB,KAAK,kBAAkB;AACtD,MAAa,eAAe,KAAK,eAAe;AAChD,MAAa,eAAe,KAAK,eAAe;AAChD,MAAa,cAAc,KAAK,cAAc;AAC9C,MAAa,cAAc,KAAK,cAAc;AAC9C,MAAa,eAAe,KAAK,eAAe;AAChD,MAAa,WAAW,KAAK,UAAU;AACvC,MAAa,QAAQ,KAAK,OAAO"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Attribute, ChildAttribute } from "foldkit/html";
|
|
2
|
+
import { MountAction } from "foldkit/mount";
|
|
3
|
+
export declare const isChildAttribute: (value: unknown) => value is ChildAttribute;
|
|
4
|
+
interface Tagged {
|
|
5
|
+
readonly _tag: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const isTagged: (value: unknown) => value is Tagged;
|
|
8
|
+
/** `Class` carries no Message, so the inert builder is the honest constructor. */
|
|
9
|
+
export declare const classAttribute: (value: string) => Attribute<never>;
|
|
10
|
+
export declare const styleAttribute: (value: Record<string, string>) => Attribute<never>;
|
|
11
|
+
/**
|
|
12
|
+
* `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing
|
|
13
|
+
* mount is built directly. The shape is the same tagged value `h.OnMount`
|
|
14
|
+
* produces (`{ _tag: 'OnMount', action }`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const mountAttribute: <Message>(action: MountAction<Message, any>) => Attribute<Message>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","names":[],"sources":["../src/attribute.ts"],"mappings":";;qBAYa,mBAAgB,mBAAqB,SAAS;UAGjD;WACC;;qBAGE,WAAQ,mBAAqB,SAAS;;qBAStC,iBAAc,kBAAoB;qBAElC,iBAAc,OAAW,2BAAyB;;;;;;qBAOlD,iBAAkB,SAAO,QAAU,YAAY,kBAAgB,UAAU"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { inertHtml } from "foldkit/html";
|
|
2
|
+
// src/attribute.ts
|
|
3
|
+
/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */
|
|
4
|
+
const CHILD_ATTRIBUTE_BRAND = "__childAttribute";
|
|
5
|
+
const isChildAttribute = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND);
|
|
6
|
+
const isTagged = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, "_tag") && "_tag" in value && typeof value._tag === "string";
|
|
7
|
+
/** `Class` carries no Message, so the inert builder is the honest constructor. */
|
|
8
|
+
const classAttribute = (value) => inertHtml.Class(value);
|
|
9
|
+
const styleAttribute = (value) => inertHtml.Style(value);
|
|
10
|
+
/**
|
|
11
|
+
* `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing
|
|
12
|
+
* mount is built directly. The shape is the same tagged value `h.OnMount`
|
|
13
|
+
* produces (`{ _tag: 'OnMount', action }`).
|
|
14
|
+
*/
|
|
15
|
+
const mountAttribute = (action) => ({
|
|
16
|
+
_tag: "OnMount",
|
|
17
|
+
action
|
|
18
|
+
});
|
|
19
|
+
export { classAttribute, isChildAttribute, isTagged, mountAttribute, styleAttribute };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.js","names":["ih"],"sources":["../src/attribute.ts"],"sourcesContent":["/**\n * Internal attribute helpers. Foldkit's `isChildAttribute` and the tagged\n * attribute shape are not public, so this module reads them in one place.\n * Probed against foldkit 0.158.2; see docs/design/mixins-DESIGN.md.\n */\nimport type { Attribute, ChildAttribute } from 'foldkit/html'\nimport { inertHtml as ih } from 'foldkit/html'\nimport type { MountAction } from 'foldkit/mount'\n\n/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */\nconst CHILD_ATTRIBUTE_BRAND = '__childAttribute'\n\nexport const isChildAttribute = (value: unknown): value is ChildAttribute =>\n typeof value === 'object' && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND)\n\ninterface Tagged {\n readonly _tag: string\n}\n\nexport const isTagged = (value: unknown): value is Tagged =>\n typeof value === 'object' &&\n value !== null &&\n // `hasOwn` refuses an inherited tag; `in` is what narrows the type.\n Object.hasOwn(value, '_tag') &&\n '_tag' in value &&\n typeof value._tag === 'string'\n\n/** `Class` carries no Message, so the inert builder is the honest constructor. */\nexport const classAttribute = (value: string): Attribute<never> => ih.Class(value)\n\nexport const styleAttribute = (value: Record<string, string>): Attribute<never> => ih.Style(value)\n\n/**\n * `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing\n * mount is built directly. The shape is the same tagged value `h.OnMount`\n * produces (`{ _tag: 'OnMount', action }`).\n */\nexport const mountAttribute = <Message>(action: MountAction<Message, any>): Attribute<Message> =>\n ({ _tag: 'OnMount', action }) as Attribute<Message>\n"],"mappings":";;;AAUA,MAAM,wBAAwB;AAE9B,MAAa,oBAAoB,UAC/B,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,OAAO,qBAAqB;AAM3F,MAAa,YAAY,UACvB,OAAO,UAAU,YACjB,UAAU,QAEV,OAAO,OAAO,OAAO,MAAM,KAC3B,UAAU,SACV,OAAO,MAAM,SAAS;;AAGxB,MAAa,kBAAkB,UAAoCA,UAAG,MAAM,KAAK;AAEjF,MAAa,kBAAkB,UAAoDA,UAAG,MAAM,KAAK;;;;;;AAOjG,MAAa,kBAA2B,YACrC;CAAE,MAAM;CAAW;AAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Attribute } from "foldkit/html";
|
|
2
|
+
import { SlotAttributes } from "./resolver.js";
|
|
3
|
+
/** Every Foldkit attribute tag: `'Class'`, `'OnClick'`, `'DataAttribute'`, … */
|
|
4
|
+
export type Tag = Attribute<never>['_tag'];
|
|
5
|
+
/** The attribute variant carrying `T`. */
|
|
6
|
+
export type Of<Message, T extends Tag> = Extract<Attribute<Message>, {
|
|
7
|
+
readonly _tag: T;
|
|
8
|
+
}>;
|
|
9
|
+
/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */
|
|
10
|
+
export declare const tagOf: <Message>(attribute: SlotAttributes<Message>[number]) => Tag | undefined;
|
|
11
|
+
/** The first attribute with `tag`, typed as that variant. */
|
|
12
|
+
export declare const find: <Message, T extends Tag>(attributes: SlotAttributes<Message>, tag: T) => Of<Message, T> | undefined;
|
|
13
|
+
/** Every attribute with `tag`, in bundle order. */
|
|
14
|
+
export declare const filter: <Message, T extends Tag>(attributes: SlotAttributes<Message>, tag: T) => ReadonlyArray<Of<Message, T>>;
|
|
15
|
+
//# sourceMappingURL=attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","names":[],"sources":["../src/attributes.ts"],"mappings":";;;YAUY,MAAM;;YAGN,GAAG,SAAS,UAAU,OAAO,QAAQ,UAAU;WAAqB,MAAM;;;qBAGzE,QAAS,SAAO,WAAa,eAAe,qBAAmB;;qBAS/D,OAAQ,SAAS,UAAU,KAAG,YAC7B,eAAe,UAAQ,KAC9B,MACJ,GAAG,SAAS;;qBAGF,SAAU,SAAS,UAAU,KAAG,YAC/B,eAAe,UAAQ,KAC9B,MACJ,cAAc,GAAG,SAAS"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isTagged } from "./attribute.js";
|
|
2
|
+
// src/attributes.ts
|
|
3
|
+
/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */
|
|
4
|
+
const tagOf = (attribute) => isTagged(attribute) ? attribute._tag : void 0;
|
|
5
|
+
const hasTag = (tag) => (attribute) => tagOf(attribute) === tag;
|
|
6
|
+
/** The first attribute with `tag`, typed as that variant. */
|
|
7
|
+
const find = (attributes, tag) => attributes.find(hasTag(tag));
|
|
8
|
+
/** Every attribute with `tag`, in bundle order. */
|
|
9
|
+
const filter = (attributes, tag) => attributes.filter(hasTag(tag));
|
|
10
|
+
export { filter, find, tagOf };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","names":[],"sources":["../src/attributes.ts"],"sourcesContent":["/**\n * Typed reads over a resolved `SlotAttributes` bundle. Foldkit's tagged\n * attribute union narrows on `_tag`, so a lookup by tag returns that variant's\n * own fields (`value`, `message`, `key`, `action`) without a cast.\n */\nimport type { Attribute } from 'foldkit/html'\nimport { isTagged } from './attribute.js'\nimport type { SlotAttributes } from './resolver.js'\n\n/** Every Foldkit attribute tag: `'Class'`, `'OnClick'`, `'DataAttribute'`, … */\nexport type Tag = Attribute<never>['_tag']\n\n/** The attribute variant carrying `T`. */\nexport type Of<Message, T extends Tag> = Extract<Attribute<Message>, { readonly _tag: T }>\n\n/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */\nexport const tagOf = <Message>(attribute: SlotAttributes<Message>[number]): Tag | undefined =>\n isTagged(attribute) ? attribute._tag : undefined\n\nconst hasTag =\n <Message, T extends Tag>(tag: T) =>\n (attribute: SlotAttributes<Message>[number]): attribute is Of<Message, T> =>\n tagOf(attribute) === tag\n\n/** The first attribute with `tag`, typed as that variant. */\nexport const find = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): Of<Message, T> | undefined => attributes.find(hasTag<Message, T>(tag))\n\n/** Every attribute with `tag`, in bundle order. */\nexport const filter = <Message, T extends Tag>(\n attributes: SlotAttributes<Message>,\n tag: T,\n): ReadonlyArray<Of<Message, T>> => attributes.filter(hasTag<Message, T>(tag))\n"],"mappings":";;;AAgBA,MAAa,SAAkB,cAC7B,SAAS,SAAS,IAAI,UAAU,OAAO,KAAA;AAEzC,MAAM,UACqB,SACxB,cACC,MAAM,SAAS,MAAM;;AAGzB,MAAa,QACX,YACA,QAC+B,WAAW,KAAK,OAAmB,GAAG,CAAC;;AAGxE,MAAa,UACX,YACA,QACkC,WAAW,OAAO,OAAmB,GAAG,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Attribute, ChildAttribute, HtmlBuilder } from "foldkit/html";
|
|
2
|
+
import { Mixin } from "./mixin.js";
|
|
3
|
+
import * as SlotView from "./slotView.js";
|
|
4
|
+
import { AttributeName, EventName, HiddenOf, SlotCapability } from "./slot.js";
|
|
5
|
+
import { MountAction } from "foldkit/mount";
|
|
6
|
+
import { SlotItem } from "./contribution.js";
|
|
7
|
+
export interface SlotRequirements {
|
|
8
|
+
readonly capability?: SlotCapability;
|
|
9
|
+
readonly events?: ReadonlyArray<EventName>;
|
|
10
|
+
readonly attributes?: ReadonlyArray<AttributeName>;
|
|
11
|
+
}
|
|
12
|
+
export interface BehaviorSlotOptions<Input, Message> {
|
|
13
|
+
readonly requires?: SlotRequirements;
|
|
14
|
+
/**
|
|
15
|
+
* Attributes for one resolution of the slot. `item` is present when the view
|
|
16
|
+
* passed one to `slots.x.attrs(base, item)`, that is, when the slot is
|
|
17
|
+
* rendered once per item.
|
|
18
|
+
*/
|
|
19
|
+
readonly attributes?: (context: {
|
|
20
|
+
readonly input: Input;
|
|
21
|
+
readonly h: HtmlBuilder<Message>;
|
|
22
|
+
readonly item?: SlotItem;
|
|
23
|
+
}) => ReadonlyArray<Attribute<Message> | ChildAttribute>;
|
|
24
|
+
readonly mount?: (input: Input, item?: SlotItem) => MountAction<Message, any>;
|
|
25
|
+
}
|
|
26
|
+
export type BehaviorSpec<Slots, Input, Message> = { readonly [K in keyof Slots as HiddenOf<Slots[K]> extends true ? never : K]?: BehaviorSlotOptions<Input, Message>; };
|
|
27
|
+
export interface NamedBehavior<Slots, Input, Message> {
|
|
28
|
+
readonly name?: string;
|
|
29
|
+
readonly spec: BehaviorSpec<Slots, Input, Message>;
|
|
30
|
+
readonly mixin: Mixin<Message>;
|
|
31
|
+
}
|
|
32
|
+
/** Identity helper; `forSlots` supplies the contextual `Input`/`Message`. */
|
|
33
|
+
export declare const slot: <Options extends BehaviorSlotOptions<any, any>>(options: Options) => Options;
|
|
34
|
+
export declare const forSlots: <Slots>(slots: Slots) => <Input, Message>(spec: BehaviorSpec<Slots, Input, Message>, options?: {
|
|
35
|
+
readonly name?: string;
|
|
36
|
+
}) => NamedBehavior<Slots, Input, Message>;
|
|
37
|
+
/**
|
|
38
|
+
* Attaches a Behavior to a view. The behavior's `Input` becomes the attached
|
|
39
|
+
* view's `Input`: a behavior declared over only the fields it reads is rejected
|
|
40
|
+
* even though those fields are a subset, and one declared over extra fields
|
|
41
|
+
* widens what the view must be called with. Declare `Input` as the view's own
|
|
42
|
+
* input type.
|
|
43
|
+
*/
|
|
44
|
+
export declare const attach: <BehaviorSlots, Message, Input>(behavior: NamedBehavior<BehaviorSlots, Input, Message>) => <ViewSlots>(view: SlotView.SlotView<ViewSlots, Input, Message>) => SlotView.SlotView<ViewSlots, Input, Message>;
|
|
45
|
+
export declare const Behavior: {
|
|
46
|
+
readonly slot: typeof slot;
|
|
47
|
+
readonly forSlots: typeof forSlots;
|
|
48
|
+
readonly attach: typeof attach;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=behavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior.d.ts","names":["MixinValue"],"sources":["../src/behavior.ts"],"mappings":";;;;;;iBAkBiB;WACN,aAAa;WACb,SAAS,cAAc;WACvB,aAAa,cAAc;;iBAGrB,oBAAoB,OAAO;WACjC,WAAW;;;;;;WAMX,cAAc;aACZ,OAAO;aACP,GAAG,YAAY;aACf,OAAO;QACZ,cAAc,UAAU,WAAW;WAChC,SAAS,OAAO,OAAO,OAAO,aAAa,YAAY;;YAGtD,aAAa,OAAO,OAAO,uBAC3B,WAAW,SAAS,SAAS,MAAM,2BAA2B,KAAK,oBAC3E,OACA;iBAIa,cAAc,OAAO,OAAO;WAClC;WACA,MAAM,aAAa,OAAO,OAAO;WACjC,OAAOA,MAAW;;;qBAIhB,OAAQ,gBAAgB,+BAA6B,SAAW,YAAU;qBA2D1E,WACV,OAAK,OAAS,WACd,OAAO,SAAO,MACP,aAAa,OAAO,OAAO,UAAQ;WACpB;MACpB,cAAc,OAAO,OAAO;;;;;;;;qBA8CpB,SACV,eAAe,SAAS,OAAK,UAAY,cAAc,eAAe,OAAO,cAC7E,WAAS,MACF,SAAS,SAAS,WAAW,OAAO,aACzC,SAAS,SAAS,WAAW,OAAO;qBAG5B"}
|