foldkit-mixins 0.23.0 → 0.25.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 +197 -17
- package/dist/app.d.ts +5 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +5 -1
- package/dist/app.js.map +1 -1
- package/dist/defaults.js +3 -3
- package/dist/defaults.js.map +1 -1
- package/dist/foldkitNames.d.ts +42 -0
- package/dist/foldkitNames.d.ts.map +1 -0
- package/dist/foldkitNames.js +169 -0
- package/dist/foldkitNames.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/inject.d.ts +11 -0
- package/dist/inject.d.ts.map +1 -1
- package/dist/inject.js +21 -8
- package/dist/inject.js.map +1 -1
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +109 -85
- package/dist/resolver.js.map +1 -1
- package/dist/slotView.d.ts.map +1 -1
- package/dist/slotView.js +3 -2
- package/dist/slotView.js.map +1 -1
- package/dist/style.d.ts +18 -5
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +2 -1
- package/dist/style.js.map +1 -1
- package/dist/styleNames.d.ts +21 -0
- package/dist/styleNames.d.ts.map +1 -0
- package/dist/styleNames.js +116 -0
- package/dist/styleNames.js.map +1 -0
- package/dist/styleValue.d.ts.map +1 -1
- package/dist/styleValue.js +4 -0
- package/dist/styleValue.js.map +1 -1
- package/dist/testing.d.ts +3 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +1 -1
- package/dist/theme/prune.d.ts +20 -0
- package/dist/theme/prune.d.ts.map +1 -0
- package/dist/theme/prune.js +96 -0
- package/dist/theme/prune.js.map +1 -0
- package/dist/theme/tokens.d.ts +3 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +1 -0
- package/dist/theme/tokens.js.map +1 -1
- package/dist/theme.d.ts +3 -0
- package/dist/utilities.d.ts +19 -0
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +27 -5
- package/dist/utilities.js.map +1 -1
- package/dist/vite.d.ts +22 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +94 -19
- package/dist/vite.js.map +1 -1
- package/dist/viteFreeze.d.ts +28 -0
- package/dist/viteFreeze.d.ts.map +1 -0
- package/dist/viteFreeze.js +146 -0
- package/dist/viteFreeze.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -199,9 +199,21 @@ Attachments are not concatenated and left to renderer order. The resolver applie
|
|
|
199
199
|
- inline styles from Style pieces merge per property, later attachments winning, over the
|
|
200
200
|
view's base; a property a Behavior sets (through `h.Style` in its attributes) has exactly one
|
|
201
201
|
owner, so a Style piece, the base, or a second Behavior setting the same property is an error;
|
|
202
|
-
- an event or scalar attribute has exactly one owner — a second owner is an error
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
- an event or scalar attribute has exactly one owner — a second owner is an error. Owners are
|
|
203
|
+
compared by what Foldkit really sets on the element: `h.OnKeyDownPreventDefault` owns `keydown`
|
|
204
|
+
as `h.OnKeyDown` does, `h.OnDoubleClick` owns `dblclick`, and `h.AriaLabel`,
|
|
205
|
+
`h.Attribute('aria-label', …)` and a `Prop` named `ariaLabel` share one owner;
|
|
206
|
+
- a `ChildAttribute` (a Submodel's published handler) is preserved by identity; one a Mixin adds
|
|
207
|
+
meets the same ownership and protection checks as its own attributes, and a child `Class` joins
|
|
208
|
+
the one `Class`;
|
|
209
|
+
- the resolver writes the one `class` and `style`, so a Mixin may not set either through
|
|
210
|
+
`h.Attribute`, a `Prop` or a child `Style`, nor an inline handler (`h.Attribute('onclick', …)`);
|
|
211
|
+
- a style property is the declaration it writes, so `insetInlineEnd` and `'inset-inline-end'` are
|
|
212
|
+
one property. A protected property, or one a Behavior owns, is also guarded against what writes
|
|
213
|
+
over it: a shorthand (`inset`, `margin`), its physical side (`right` or `left` for
|
|
214
|
+
`insetInlineEnd`), and `translate`, `rotate` or `scale` beside `transform`;
|
|
215
|
+
- `Key`, `InnerHTML` and a `Prop` that replaces the children are structural and cannot be
|
|
216
|
+
overridden;
|
|
205
217
|
- multiple mount contributions compose into exactly one `OnMount`.
|
|
206
218
|
|
|
207
219
|
Conflicts throw `Diagnostics.DiagnosticError` with stable codes such as
|
|
@@ -299,7 +311,7 @@ one.
|
|
|
299
311
|
| `Style.when(condition, piece)` | a boolean known at authoring time |
|
|
300
312
|
| `Style.whenInput(predicate, piece)` | a condition read from the view input at render time |
|
|
301
313
|
| `Style.recipe({ base, variants, defaults, compound })` | one slot: returns `selection => StyleValue`; every field is optional, so a recipe may be only its base |
|
|
302
|
-
| `Style.recipeFor(Slots)({ base, variants, defaults, compound })` | every slot: returns `selection =>
|
|
314
|
+
| `Style.recipeFor(Slots)({ base, variants, defaults, compound })` | every slot: returns `selection => RecipePieces`, in which every `base` slot is present and a variant's slot may be absent; `null` unsets a defaulted axis, which is how a recipe makes a piece optional; `.extend(patch)` composes per slot, removes nothing, and refuses a slot the contract lacks |
|
|
303
315
|
| `Style.perItem(item => piece)` / `Style.stagger({ stepMs })` | a piece from the item the slot is rendered for (`attrs(base, item)`); stagger writes `--fk-index` inline and the `calc` delay as a rule |
|
|
304
316
|
| `Style.forCapability(Slots)(capability, piece)` | one piece for every public slot whose capability satisfies it |
|
|
305
317
|
| `Style.slots(pieces, options?)` / `Style.slot(slotOptions, piece)` | an application's own Slots declared by their style: `{ slots, style }` (see [An application's own look](#an-applications-own-look)) |
|
|
@@ -312,10 +324,24 @@ one.
|
|
|
312
324
|
| `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 |
|
|
313
325
|
| `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 |
|
|
314
326
|
| `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 |
|
|
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` |
|
|
327
|
+
| `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`), and `overlay.scrim` (what a modal's backdrop draws over the page: the page's own base at 45%, so it dims in either scheme; a theme that wants a darker veil overrides that token in the tokens it composes); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
316
328
|
| `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` |
|
|
317
329
|
| `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 |
|
|
318
330
|
|
|
331
|
+
A selection is a plain object of pieces. A base slot needs no fallback when one recipe's look goes on
|
|
332
|
+
another element (`Recipes.Button({ tone: 'neutral' }).button`), and leaving a piece out of one use
|
|
333
|
+
is destructuring:
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
import { DialogSlots, Recipes } from 'foldkit-mixins-ui'
|
|
337
|
+
|
|
338
|
+
const { closeButton: _corner, ...dialogPieces } = Recipes.Dialog({ size: 'sm' })
|
|
339
|
+
const PlainDialogStyle = Style.forSlots(DialogSlots)(dialogPieces)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Leaving out a style does not leave out the element: the view still draws the close button wherever
|
|
343
|
+
it puts `dialog.closeButton`, now without the recipe's look.
|
|
344
|
+
|
|
319
345
|
Rule-based Style compiles to one deterministic class (an FNV-1a hash of canonical rule text) plus
|
|
320
346
|
CSS as data:
|
|
321
347
|
|
|
@@ -379,6 +405,9 @@ throws where the theme is made. A theme is `pipe`able: `Theme.set` changes some
|
|
|
379
405
|
`Theme.describe` gives it a title and a description for a list of themes.
|
|
380
406
|
|
|
381
407
|
```ts
|
|
408
|
+
import { Layers } from 'foldkit-mixins'
|
|
409
|
+
import { Theme } from 'foldkit-mixins/theme'
|
|
410
|
+
|
|
382
411
|
const cobalt = Theme.make({
|
|
383
412
|
accent: { hue: 235, chroma: 0.225, lightness: 55 },
|
|
384
413
|
surface: { saturation: 0, contrast: 24 },
|
|
@@ -440,6 +469,10 @@ not outgrow its height.
|
|
|
440
469
|
Themes are installed by name, the names being a record's keys:
|
|
441
470
|
|
|
442
471
|
```ts
|
|
472
|
+
import { Schema } from 'effect'
|
|
473
|
+
import { AppStyle } from 'foldkit-mixins/app'
|
|
474
|
+
import { Themes } from 'foldkit-mixins/theme'
|
|
475
|
+
|
|
443
476
|
const themes = Themes.make({ cobalt, cobaltDense }, { initial: 'cobalt' })
|
|
444
477
|
const { t, stylesheet } = AppStyle.make({ themes })
|
|
445
478
|
const Model = Schema.Struct({ theme: themes.Name })
|
|
@@ -528,7 +561,7 @@ fade still plays.
|
|
|
528
561
|
|
|
529
562
|
A theme reaches the page as pieces, and the page chooses the layers:
|
|
530
563
|
|
|
531
|
-
```ts
|
|
564
|
+
```ts standalone
|
|
532
565
|
import { Layers, Slot, Slots, Capability, Style } from 'foldkit-mixins'
|
|
533
566
|
import { Theme } from 'foldkit-mixins/theme'
|
|
534
567
|
|
|
@@ -617,6 +650,14 @@ variables with token fallbacks; the options only write those variables inline, s
|
|
|
617
650
|
with ten gaps are one rule and ten inline declarations. The pieces are unlayered; put them in
|
|
618
651
|
`layouts`:
|
|
619
652
|
|
|
653
|
+
<!-- docs-check standalone
|
|
654
|
+
import { Capability, Slot, Slots } from 'foldkit-mixins'
|
|
655
|
+
const CardSlots = Slots.define({
|
|
656
|
+
root: Slot.make({ capability: Capability.Container }),
|
|
657
|
+
actions: Slot.make({ capability: Capability.Container }),
|
|
658
|
+
})
|
|
659
|
+
-->
|
|
660
|
+
|
|
620
661
|
```ts
|
|
621
662
|
import { Layers, Style } from 'foldkit-mixins'
|
|
622
663
|
import { Layout } from 'foldkit-mixins/layout'
|
|
@@ -651,6 +692,11 @@ paragraph, list to paragraph, around figures) whose options are `--fk-prose-*` v
|
|
|
651
692
|
element. Its measure and line height are a rule reading those variables, so a later layer can
|
|
652
693
|
override them. Both are unlayered; the page places them:
|
|
653
694
|
|
|
695
|
+
<!-- docs-check standalone
|
|
696
|
+
import { Capability, Slot, Slots } from 'foldkit-mixins'
|
|
697
|
+
const ArticleSlots = Slots.define({ body: Slot.make({ capability: Capability.Container }) })
|
|
698
|
+
-->
|
|
699
|
+
|
|
654
700
|
```ts
|
|
655
701
|
import { Layers, Style } from 'foldkit-mixins'
|
|
656
702
|
import { Defaults } from 'foldkit-mixins/defaults'
|
|
@@ -681,7 +727,7 @@ that case the contract, the style and the setup can each be written once:
|
|
|
681
727
|
| fixing theme, `app` layer and page sheet for one application | `AppStyle.make` from `foldkit-mixins/app` |
|
|
682
728
|
| writing a token-backed declaration in a word | `Utilities` from `foldkit-mixins/utilities` |
|
|
683
729
|
|
|
684
|
-
```ts
|
|
730
|
+
```ts standalone
|
|
685
731
|
import { Event, Style, SlotView } from 'foldkit-mixins'
|
|
686
732
|
import { AppStyle } from 'foldkit-mixins/app'
|
|
687
733
|
import { Theme } from 'foldkit-mixins/theme'
|
|
@@ -718,7 +764,9 @@ What each call does, and does not do:
|
|
|
718
764
|
- `AppStyle.make` computes, once: `theme` is `Theme.compose(Theme.tokens, palette)`, `t` is
|
|
719
765
|
`Theme.ref(theme)`, `L` is `Layers.standard`, and `stylesheet` is the text of the layer order,
|
|
720
766
|
`Defaults.reset`, the tokens, the palette and `Defaults.body` (plus any `global` pieces, in the
|
|
721
|
-
`defaults` layer).
|
|
767
|
+
`defaults` layer). The text is built when `stylesheet` is first read, and kept: building it
|
|
768
|
+
costs milliseconds, so a browser whose sheet is a file should not read it (destructuring
|
|
769
|
+
`stylesheet` reads it). It installs nothing and owns no state; a scheme or theme the user picks is
|
|
722
770
|
still a Model fact (see [Theme from a few knobs](#theme-from-a-few-knobs)).
|
|
723
771
|
- `slots(pieces)` is `Style.slots(pieces, { layer: L.layer('app') })`, and `forSlots` is
|
|
724
772
|
`Style.forSlots` with the same layer: the options take a `name`, never a layer. Both
|
|
@@ -736,14 +784,21 @@ step is a type error and the value still follows the `density` knob and theme ov
|
|
|
736
784
|
(`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a palette
|
|
737
785
|
color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
|
|
738
786
|
constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
|
|
739
|
-
`truncate`, `pointer` and `selectNone`, and `
|
|
787
|
+
`truncate`, `srOnly`, `pointer` and `selectNone`, `scriptedOnly` and `plainOnly(display)` (the
|
|
788
|
+
pair for a page in a browser running no scripts: a control only a script drives is hidden there,
|
|
789
|
+
and its plain stand-in, `display: none` until then, is shown as `display`; put `scriptedOnly` last
|
|
790
|
+
in a slot's pieces so it wins over a width's `display`), and `scrollFade(axis)`, a scroller's content dissolving
|
|
740
791
|
toward an edge with more to scroll (a scroll-driven mask: the true ends stay crisp until something
|
|
741
792
|
is past them, and a browser without scroll timelines gets no fade), `scrollDivider(axis)` with
|
|
742
793
|
`scrollTimeline(axis)`, a hairline at each edge with more past it, drawn on a positioned parent's
|
|
743
794
|
`::before` and `::after` (the fade's mask would erase a line inside the scroller) from the timeline
|
|
744
795
|
the scroller names, where the browser has `timeline-scope`, and `steady(weight)`, room for a
|
|
745
796
|
label at a heavier weight, read from the element's `data-label`, so turning bold moves nothing
|
|
746
|
-
beside it
|
|
797
|
+
beside it, and `busyReveal`, busy text said only once a wait is noticeable: on an element marked
|
|
798
|
+
`aria-busy="true"` it fades in after 0.6s, so a read answered sooner never flashes a "Loading…";
|
|
799
|
+
the element renders from the start, holding its space, and without `aria-busy` the piece does
|
|
800
|
+
nothing, so one status Slot also says "Nothing here." plainly. Its fade follows the `motion` knob;
|
|
801
|
+
its delay does not, or a still theme would bring the flash back. Each is a `Style.self` rule, unlayered, so it takes the
|
|
747
802
|
layer of the style it is composed into, and a plain declaration after it wins per property. A
|
|
748
803
|
value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
|
|
749
804
|
the palette's groups is read through `t`.
|
|
@@ -755,6 +810,61 @@ state. Its attributes are built while resolving from the view's `input` and `h`,
|
|
|
755
810
|
emit Messages from the view's own Message universe. Like an agent capability,
|
|
756
811
|
a Behavior points one way — toward a Message — and never gets a Model setter.
|
|
757
812
|
|
|
813
|
+
<!-- docs-check standalone
|
|
814
|
+
import { Schema } from 'effect'
|
|
815
|
+
import type { HtmlBuilder } from 'foldkit/html'
|
|
816
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
817
|
+
import type { MountAction } from 'foldkit/mount'
|
|
818
|
+
import { expect } from 'vitest'
|
|
819
|
+
import { Projection, Surface } from 'foldkit-surface'
|
|
820
|
+
import { A11y, Attr, Behavior, Capability, Event, Slot, Slots, SlotView, Style } from 'foldkit-mixins'
|
|
821
|
+
const Message = defineMessageUnion({ ChangedValue: { value: Schema.String } })
|
|
822
|
+
type Message = typeof Message.Type
|
|
823
|
+
type FieldInput = { readonly value: string; readonly invalid: boolean }
|
|
824
|
+
const Container = Slot.make({ capability: Capability.Container })
|
|
825
|
+
const FieldSlots = Slots.define({
|
|
826
|
+
root: Container,
|
|
827
|
+
input: Slot.make({
|
|
828
|
+
capability: Capability.TextInput,
|
|
829
|
+
events: [Event.Input],
|
|
830
|
+
attributes: [Attr.AriaInvalid],
|
|
831
|
+
}),
|
|
832
|
+
})
|
|
833
|
+
const FieldStyle = Style.forSlots(FieldSlots)({
|
|
834
|
+
root: Style.compose(Style.class('field'), Style.inline({ display: 'grid' })),
|
|
835
|
+
input: Style.class('field-input'),
|
|
836
|
+
})
|
|
837
|
+
const Validation = Behavior.forSlots(FieldSlots)<FieldInput, Message>({
|
|
838
|
+
input: Behavior.slot({
|
|
839
|
+
requires: { capability: Capability.TextInput, attributes: [Attr.AriaInvalid] },
|
|
840
|
+
attributes: ({ input, h }) => [h.AriaInvalid(input.invalid)],
|
|
841
|
+
}),
|
|
842
|
+
})
|
|
843
|
+
declare const MeasureField: (value: string) => MountAction<Message, never>
|
|
844
|
+
const ListSlots = Slots.define({ root: Container, list: Container, row: Container })
|
|
845
|
+
const ToolbarSlots = Slots.define({ root: Container, tool: Container })
|
|
846
|
+
const PanelSlots = Slots.define({ root: Container, title: Container, count: Container })
|
|
847
|
+
const PageSlots = Slots.define({ header: Container })
|
|
848
|
+
const DialogSlots = Slots.define({ trigger: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }), content: Container })
|
|
849
|
+
const ListParts = SlotView.parts(ListSlots)<{ readonly rows: ReadonlyArray<string> }, Message>()
|
|
850
|
+
const PageModel = Schema.Struct({
|
|
851
|
+
cart: Schema.Array(Schema.String),
|
|
852
|
+
page: Schema.Struct({ title: Schema.String }),
|
|
853
|
+
})
|
|
854
|
+
type PageModel = typeof PageModel.Type
|
|
855
|
+
const App = Surface.application({ Model: PageModel, Message })
|
|
856
|
+
const Counter = SlotView.forMessages<never>().define(
|
|
857
|
+
Slots.define({ root: Container, count: Container }),
|
|
858
|
+
(count: number, slots, h) => h.main(slots.root.attrs(), [h.p(slots.count.attrs(), [String(count)])]),
|
|
859
|
+
)
|
|
860
|
+
const stylesheet = Style.stylesheet()
|
|
861
|
+
declare const slots: SlotView.SlotBuilders<typeof ListSlots, Message> &
|
|
862
|
+
SlotView.SlotBuilders<typeof PageSlots, Message>
|
|
863
|
+
declare const h: HtmlBuilder<Message>
|
|
864
|
+
declare const model: PageModel
|
|
865
|
+
declare const items: ReadonlyArray<{ readonly id: string; readonly label: string }>
|
|
866
|
+
-->
|
|
867
|
+
|
|
758
868
|
```ts
|
|
759
869
|
const Focus = Behavior.forSlots(FieldSlots)<FieldInput, Message>({
|
|
760
870
|
input: Behavior.slot({
|
|
@@ -791,7 +901,10 @@ array once, and a view and the Behaviors on it agree about identity, order, and
|
|
|
791
901
|
```ts
|
|
792
902
|
import { Behaviors } from 'foldkit-mixins'
|
|
793
903
|
|
|
794
|
-
|
|
904
|
+
type ToolbarInput = { readonly tools: ReadonlyArray<{ readonly id: string; readonly disabled: boolean }> }
|
|
905
|
+
declare const toolbar: ToolbarInput
|
|
906
|
+
|
|
907
|
+
const tools = Behaviors.Collection.of(toolbar.tools, {
|
|
795
908
|
id: tool => tool.id,
|
|
796
909
|
disabled: tool => tool.disabled,
|
|
797
910
|
}) // ids, size, at, indexOf, isDisabled, enabled, slotItem
|
|
@@ -802,7 +915,7 @@ const Ids = Behaviors.Collection.behavior(ToolbarSlots)<ToolbarInput, Message>({
|
|
|
802
915
|
posInSet: true,
|
|
803
916
|
})
|
|
804
917
|
|
|
805
|
-
// in the view: slots.tool.attrs([h.Key(tool.id)],
|
|
918
|
+
// in the view: slots.tool.attrs([h.Key(tool.id)], tools.slotItem(index))
|
|
806
919
|
```
|
|
807
920
|
|
|
808
921
|
`of` is pure and refuses two items with one id (`mixins:duplicate-item-id`), since an id is what
|
|
@@ -1103,8 +1216,9 @@ development through the running server and in a build through one of its own. It
|
|
|
1103
1216
|
compiles a module the application owns, through a server, as the page would
|
|
1104
1217
|
compile it, so the build's foundations are the application's rather than a copy.
|
|
1105
1218
|
|
|
1106
|
-
```ts
|
|
1219
|
+
```ts standalone
|
|
1107
1220
|
// vite.config.ts
|
|
1221
|
+
import { defineConfig } from 'vite'
|
|
1108
1222
|
import { foundations } from 'foldkit-mixins/foundations'
|
|
1109
1223
|
|
|
1110
1224
|
export default defineConfig({
|
|
@@ -1125,8 +1239,9 @@ parsed again by the server's checks of the page. `foldkit-mixins/vite` writes
|
|
|
1125
1239
|
it once, as a hashed file in the browser build, and gives the server its
|
|
1126
1240
|
address; the page links it:
|
|
1127
1241
|
|
|
1128
|
-
```ts
|
|
1242
|
+
```ts standalone
|
|
1129
1243
|
// vite.config.ts
|
|
1244
|
+
import { defineConfig } from 'vite'
|
|
1130
1245
|
import { styles } from 'foldkit-mixins/vite'
|
|
1131
1246
|
|
|
1132
1247
|
export default defineConfig({
|
|
@@ -1134,7 +1249,7 @@ export default defineConfig({
|
|
|
1134
1249
|
})
|
|
1135
1250
|
```
|
|
1136
1251
|
|
|
1137
|
-
```ts
|
|
1252
|
+
```ts sketch
|
|
1138
1253
|
// the server entry: a link in the document's head, so the first paint waits for it
|
|
1139
1254
|
import { href } from 'virtual:foldkit-styles'
|
|
1140
1255
|
|
|
@@ -1146,8 +1261,10 @@ const head = `<link rel="stylesheet" href="${href}" data-foldkit-styles-href>`
|
|
|
1146
1261
|
sheet followed by `Style.complete(sheet)`'s addition: every class and global
|
|
1147
1262
|
rule the process compiled that the sheet does not hold. The plugin bundles the
|
|
1148
1263
|
sheet module (every module it imports is kept, since compiling a Style is a
|
|
1149
|
-
side effect), so import the application's styled modules from it.
|
|
1150
|
-
|
|
1264
|
+
side effect), so import the application's styled modules from it. Keep the
|
|
1265
|
+
module out of the browser's: `examples/foldkit/domains-plus` reads the sheet
|
|
1266
|
+
in `src/server/sheet.ts` alone, so the page never builds the text it links.
|
|
1267
|
+
Declare the virtual module for TypeScript (`declare module 'virtual:foldkit-styles' { export const href: string }`).
|
|
1151
1268
|
|
|
1152
1269
|
- **Build.** `assets/styles-<hash>.css` is written by the `client` build, named
|
|
1153
1270
|
by its content; `href` carries Vite's `base`, which must be absolute. A
|
|
@@ -1162,6 +1279,69 @@ virtual module for TypeScript (`declare module 'virtual:foldkit-styles' { export
|
|
|
1162
1279
|
its classes are injected again rather than lost.
|
|
1163
1280
|
- **Without the plugin**, `Style.usedIn(html)` still writes what one page uses.
|
|
1164
1281
|
|
|
1282
|
+
### Only the tokens the sheet reads
|
|
1283
|
+
|
|
1284
|
+
`Theme.standard` defines every scale and palette, whether a page draws it or
|
|
1285
|
+
not, and on domains-plus those definitions were most of the sheet. With
|
|
1286
|
+
`prune`, the plugin ships only the `--fk-*` tokens a rule reads, directly or
|
|
1287
|
+
through another kept token, in dev and in the build alike (`Inert.prune` on the
|
|
1288
|
+
completed sheet, from `foldkit-mixins/testing`, so a browser reading `Theme`
|
|
1289
|
+
carries none of it). Domains-plus's sheet went from 15.2 KB to 10.6 KB brotli.
|
|
1290
|
+
|
|
1291
|
+
```ts
|
|
1292
|
+
styles({ sheet: '/src/style.ts', prune: { keep: [] } })
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
A token read outside the sheet is taken too: an inline style built with
|
|
1296
|
+
`Theme.ref`, or a script reading a computed value by name. Name each in `keep`,
|
|
1297
|
+
as `--fk-x` or as `Theme.ref` writes it (`var(--fk-x)`); an entry naming no
|
|
1298
|
+
token throws. Hold it with a test: `Inert.missingTokens(tree, Inert.prune(css,
|
|
1299
|
+
{ keep }))` lists each token a drawn view reads that the pruned sheet does not
|
|
1300
|
+
define. It sees only what is drawn, so a browser test comparing the page's
|
|
1301
|
+
computed styles under both sheets covers the states a server never draws
|
|
1302
|
+
(`examples/foldkit/domains-plus/test/look.browser.test.ts`). It is off unless
|
|
1303
|
+
asked for.
|
|
1304
|
+
|
|
1305
|
+
### Style modules shipped as data
|
|
1306
|
+
|
|
1307
|
+
The sheet already holds every class, but a page that imports its style
|
|
1308
|
+
module still runs the compiler to work out each class's name: the recipes,
|
|
1309
|
+
the theme builder and the rules, about 30 KB brotli on domains-plus. Name the
|
|
1310
|
+
style modules in `modules`, and the production browser build replaces each
|
|
1311
|
+
with what it evaluated to while the sheet was built:
|
|
1312
|
+
|
|
1313
|
+
```ts
|
|
1314
|
+
styles({ sheet: '/src/server/sheet.ts', modules: ['/src/client/style.ts'] })
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
- **What a listed module ships.** Each Style keeps its `name` and its `mixin`,
|
|
1318
|
+
whose Slots draw the classes and inline declarations the Style compiled to;
|
|
1319
|
+
a `Style.slots` declaration keeps its `slots` contract and its `style`. Its
|
|
1320
|
+
other fields (`pieces`, `css`, `rules`) throw when read. A string, or an
|
|
1321
|
+
object of strings such as `t`, ships as it is.
|
|
1322
|
+
- **What fails the build.** An export that is anything else (a function, an
|
|
1323
|
+
`AppStyle`), and a Style using `Style.whenInput` or `Style.perItem`, which
|
|
1324
|
+
choose classes at run time. The error names the module and the export. Keep
|
|
1325
|
+
such a module at run time by leaving it off the list.
|
|
1326
|
+
- **Attach with `SlotView`.** A module that imports `Style` keeps the compiler
|
|
1327
|
+
in the page, so attach a frozen style with `SlotView.attach(Page.style.mixin)`
|
|
1328
|
+
rather than `Style.attach(Page.style)`, and keep the `AppStyle` (its `slots`
|
|
1329
|
+
and `forSlots` are functions) in a module of its own that only the listed
|
|
1330
|
+
module and the sheet import.
|
|
1331
|
+
- **Production and development.** With a module listed, a production browser
|
|
1332
|
+
build's Slots inject nothing: the linked sheet holds every class, and the
|
|
1333
|
+
build fails if a class a frozen module draws has no rule in it. It fails
|
|
1334
|
+
too if the page still compiles a Style (a module left off the list, or a
|
|
1335
|
+
`Style.perItem` made at draw time), naming the modules that bring the
|
|
1336
|
+
compiler, since its classes would have no rule to draw. Development
|
|
1337
|
+
is unchanged: modules run as written, and a Slot injects what it draws. The
|
|
1338
|
+
server build is unchanged too.
|
|
1339
|
+
|
|
1340
|
+
On domains-plus the page's JavaScript fell from 217.5 KB to 191.6 KB brotli,
|
|
1341
|
+
and no recipe or rule compiler is left in it (`test/bundle.test.ts`);
|
|
1342
|
+
`test/frozen.test.ts` checks that every frozen export draws what the run-time
|
|
1343
|
+
module does.
|
|
1344
|
+
|
|
1165
1345
|
## `@foldkit/ui`
|
|
1166
1346
|
|
|
1167
1347
|
`foldkit-mixins-ui` adapts `@foldkit/ui` components that expose attribute bundles or a consumer
|
package/dist/app.d.ts
CHANGED
|
@@ -44,7 +44,11 @@ export interface AppStyle<Own extends ThemeTokens> {
|
|
|
44
44
|
readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>;
|
|
45
45
|
/** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */
|
|
46
46
|
readonly forSlots: <Slots>(contract: Slots) => (pieces: StylePieces<Slots>, options?: AppStyleOptionsFor) => NamedStyle<Slots>;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The page sheet: the layer order, reset, tokens, `Defaults.body` and
|
|
49
|
+
* `global`. Built when first read and kept: a browser whose sheet comes from
|
|
50
|
+
* `foldkit-mixins/vite` never reads it, and building it costs milliseconds.
|
|
51
|
+
*/
|
|
48
52
|
readonly stylesheet: string;
|
|
49
53
|
}
|
|
50
54
|
/**
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","names":["composeThemes"],"sources":["../src/app.ts"],"mappings":";;;;;;;UAyBU,OA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
|
|
18
18
|
const shipped = "themes" in options ? options.themes.root : standardOf(options.theme);
|
|
19
19
|
const theme = compose$1(shipped, options.tokens ?? {});
|
|
20
20
|
const scheme = options.colorScheme === void 0 ? {} : { colorScheme: options.colorScheme };
|
|
21
|
+
let sheet;
|
|
21
22
|
return Object.freeze({
|
|
22
23
|
theme,
|
|
23
24
|
t: ref(theme),
|
|
@@ -30,7 +31,10 @@ function make(options) {
|
|
|
30
31
|
...styleOptions,
|
|
31
32
|
layer: app
|
|
32
33
|
}),
|
|
33
|
-
|
|
34
|
+
get stylesheet() {
|
|
35
|
+
sheet ??= stylesheet(standard.declare, standard.in("reset", reset), standard.in("theme", root(theme, scheme)), ..."themes" in options ? [standard.in("theme", options.themes.scoped)] : [], standard.in("defaults", compose(body, ...options.global ?? [])));
|
|
36
|
+
return sheet;
|
|
37
|
+
}
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
const AppStyle = { make };
|
package/dist/app.js.map
CHANGED
|
@@ -1 +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
|
|
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 /**\n * The page sheet: the layer order, reset, tokens, `Defaults.body` and\n * `global`. Built when first read and kept: a browser whose sheet comes from\n * `foldkit-mixins/vite` never reads it, and building it costs milliseconds.\n */\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 let sheet: string | undefined\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 get stylesheet() {\n sheet ??= 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 return sheet\n },\n })\n}\n\nexport const AppStyle = { make } as const\n"],"mappings":";;;;;;;;;;;;;;;AAiFA,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,IAAI;CACJ,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,IAAI,aAAa;GACf,UAAU,WACR,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;GACA,OAAO;EACT;CACF,CAAC;AACH;AAEA,MAAa,WAAW,EAAE,KAAK"}
|
package/dist/defaults.js
CHANGED
|
@@ -61,9 +61,9 @@ const controls = global([
|
|
|
61
61
|
`:where(:is(input,select,textarea):focus-visible){border-color:${v("accent-default", "Highlight")}}`,
|
|
62
62
|
`:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v("error-default", "red")}}`,
|
|
63
63
|
`:where(button,[type=button],[type=submit],[type=reset]){padding:${v("space-xs", "0.5rem")} ${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "ButtonFace")};color:${v("text-default", "ButtonText")};cursor:pointer;transition:background ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
|
|
64
|
-
`@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v("surface-muted", "ButtonFace")}}}`,
|
|
65
|
-
`:where(button,[type=button],[type=submit],[type=reset]):active{background:${v("surface-muted", "ButtonFace")}}`,
|
|
66
|
-
`:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,
|
|
64
|
+
`@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v("surface-muted", "ButtonFace")}}}`,
|
|
65
|
+
`:where(button,[type=button],[type=submit],[type=reset]):active:not([aria-disabled=true]){background:${v("surface-muted", "ButtonFace")}}`,
|
|
66
|
+
`:where(:is(button,input,select,textarea):disabled,:is(button,[type=button],[type=submit],[type=reset])[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,
|
|
67
67
|
`:where(:is(input,select,textarea,button)::placeholder){color:${v("text-muted", "GrayText")}}`
|
|
68
68
|
].join(""));
|
|
69
69
|
/** Every default except `reset`, which belongs in its own layer. */
|
package/dist/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:var(--fk-reading-heading-wrap, balance)}',\n ':where(p){text-wrap:var(--fk-reading-body-wrap, pretty);overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAGA;CAIA;CACA;CAIA;CAKA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE5D,EAAE,kBAAkB,WAAW,EAAE,8CAC3D,EAAE,aAAa,uBAAuB,EAAE,aAAa,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,kBAAkB,KAAK,EAAE,eAAe,EAAE,iBAAiB,KAAK,EAAE,SAAS,EA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AAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,aAAa,EAAE,+BAA+B,EAAE,gBAAgB,OAAO,EAAE;AAC/Q,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,WAAuB,OAClC;CACE,sHAAsH,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,gBAAgB,OAAO,EAAE,SAAS,EAAE,gBAAgB,WAAW,EAAE,2BAA2B,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACvc,iEAAiE,EAAE,kBAAkB,WAAW,EAAE;CAClG,sEAAsE,EAAE,iBAAiB,KAAK,EAAE;CAChG,mEAAmE,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,MAAM,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,YAAY,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,wCAAwC,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACta,iGAAiG,EAAE,iBAAiB,YAAY,EAAE;CAClI,6EAA6E,EAAE,iBAAiB,YAAY,EAAE;CAC9G;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
|
|
1
|
+
{"version":3,"file":"defaults.js","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:var(--fk-reading-heading-wrap, balance)}',\n ':where(p){text-wrap:var(--fk-reading-body-wrap, pretty);overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active:not([aria-disabled=true]){background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled,:is(button,[type=button],[type=submit],[type=reset])[aria-disabled=true]){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAGA;CAIA;CACA;CAIA;CAKA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE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;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Attribute } from "foldkit/html";
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
/** `AriaLabel` -> `arialabel`, `aria-label` -> `arialabel`; tags and tokens agree. */
|
|
4
|
+
export declare const normalizeName: (name: string) => string;
|
|
5
|
+
type FoldkitTag = Attribute<unknown>['_tag'];
|
|
6
|
+
/** Handlers that are no one DOM event: a Mount is composed, an unmount is a hook, and a custom event names its own. */
|
|
7
|
+
type NotOneEvent = 'OnMount' | 'OnUnmount' | 'OnCustomEvent';
|
|
8
|
+
type EventTag = Exclude<Extract<FoldkitTag, `On${string}`>, NotOneEvent> | 'AllowDrop';
|
|
9
|
+
/**
|
|
10
|
+
* The DOM event each Foldkit handler builder registers. The variants own their
|
|
11
|
+
* base event: `OnKeyDownPreventDefault` listens to `keydown`, and Foldkit
|
|
12
|
+
* chains it onto any other `keydown` handler on the element. A Foldkit release
|
|
13
|
+
* that adds a handler fails to compile here until it is listed.
|
|
14
|
+
*/
|
|
15
|
+
export declare const EVENT_OF_TAG: { readonly [Tag in EventTag]: string; };
|
|
16
|
+
/**
|
|
17
|
+
* The DOM event a contribution listens to, normalized like a protected event:
|
|
18
|
+
* `OnClick` and `OnCustomEvent('click')` both read `click`, and
|
|
19
|
+
* `OnKeyDownPreventDefault` reads `keydown`. `None` for an attribute that is
|
|
20
|
+
* no event, a custom event with no name, or a handler `isUnknownHandler` names.
|
|
21
|
+
*/
|
|
22
|
+
export declare const eventNameOf: (tag: string, value: unknown) => Option.Option<string>;
|
|
23
|
+
/**
|
|
24
|
+
* A tag shaped like a handler that Foldkit's table lacks: a child attribute's
|
|
25
|
+
* from another Foldkit, say. Its event cannot be read from its spelling (that
|
|
26
|
+
* guess once let every variant past protection), so the resolver refuses it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isUnknownHandler: (tag: string) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* An `Attribute` or `Prop` named like `onclick`: an inline handler, which
|
|
31
|
+
* listens to its event outside every owner and protection the resolver keeps.
|
|
32
|
+
*/
|
|
33
|
+
export declare const isInlineHandler: (tag: string, value: unknown) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The HTML attribute a contribution sets, normalized to compare with a protected one:
|
|
36
|
+
* `AriaLabel`, `Attribute('aria-label')` and `Prop({ key: 'ariaLabel' })` all read
|
|
37
|
+
* `arialabel`, `Prop({ key: 'className' })` reads `class`, and `DataAttribute('x')`
|
|
38
|
+
* reads as `data-x`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const attributeNameOf: (tag: string, value: unknown) => string;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=foldkitNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"foldkitNames.d.ts","names":[],"sources":["../src/foldkitNames.ts"],"mappings":";;;qBAWa,gBAAa;KAErB,aAAa;;KAGb;KAEA,WAAW,QAAQ,QAAQ,4BAA4B;;;;;;;qBAQ/C,0BAA0B,OAAO;;;;;;;qBAsFjC,cAAW,aAAe,mBAAmB,OAAO;;;;;;qBAkBpD,mBAAgB;;;;;qBA8ChB,kBAAe,aAAe;;;;;;;qBAgB9B,kBAAe,aAAe"}
|