foldkit-mixins 0.22.0 → 0.24.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 +219 -10
- 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 +2 -2
- package/dist/defaults.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/inject.d.ts +18 -0
- package/dist/inject.d.ts.map +1 -1
- package/dist/inject.js +110 -13
- package/dist/inject.js.map +1 -1
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +107 -67
- package/dist/resolver.js.map +1 -1
- package/dist/slotView.d.ts.map +1 -1
- package/dist/slotView.js +23 -13
- package/dist/slotView.js.map +1 -1
- package/dist/style.d.ts +19 -5
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +4 -2
- package/dist/style.js.map +1 -1
- 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/knobs.js +1 -1
- package/dist/theme/knobs.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 +29 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +190 -0
- package/dist/vite.js.map +1 -0
- 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 +14 -3
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ one.
|
|
|
299
299
|
| `Style.when(condition, piece)` | a boolean known at authoring time |
|
|
300
300
|
| `Style.whenInput(predicate, piece)` | a condition read from the view input at render time |
|
|
301
301
|
| `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 =>
|
|
302
|
+
| `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
303
|
| `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
304
|
| `Style.forCapability(Slots)(capability, piece)` | one piece for every public slot whose capability satisfies it |
|
|
305
305
|
| `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 +312,24 @@ one.
|
|
|
312
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 |
|
|
313
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 |
|
|
314
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 |
|
|
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` |
|
|
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`), 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
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` |
|
|
317
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 |
|
|
318
318
|
|
|
319
|
+
A selection is a plain object of pieces. A base slot needs no fallback when one recipe's look goes on
|
|
320
|
+
another element (`Recipes.Button({ tone: 'neutral' }).button`), and leaving a piece out of one use
|
|
321
|
+
is destructuring:
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
import { DialogSlots, Recipes } from 'foldkit-mixins-ui'
|
|
325
|
+
|
|
326
|
+
const { closeButton: _corner, ...dialogPieces } = Recipes.Dialog({ size: 'sm' })
|
|
327
|
+
const PlainDialogStyle = Style.forSlots(DialogSlots)(dialogPieces)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Leaving out a style does not leave out the element: the view still draws the close button wherever
|
|
331
|
+
it puts `dialog.closeButton`, now without the recipe's look.
|
|
332
|
+
|
|
319
333
|
Rule-based Style compiles to one deterministic class (an FNV-1a hash of canonical rule text) plus
|
|
320
334
|
CSS as data:
|
|
321
335
|
|
|
@@ -379,6 +393,9 @@ throws where the theme is made. A theme is `pipe`able: `Theme.set` changes some
|
|
|
379
393
|
`Theme.describe` gives it a title and a description for a list of themes.
|
|
380
394
|
|
|
381
395
|
```ts
|
|
396
|
+
import { Layers } from 'foldkit-mixins'
|
|
397
|
+
import { Theme } from 'foldkit-mixins/theme'
|
|
398
|
+
|
|
382
399
|
const cobalt = Theme.make({
|
|
383
400
|
accent: { hue: 235, chroma: 0.225, lightness: 55 },
|
|
384
401
|
surface: { saturation: 0, contrast: 24 },
|
|
@@ -440,6 +457,10 @@ not outgrow its height.
|
|
|
440
457
|
Themes are installed by name, the names being a record's keys:
|
|
441
458
|
|
|
442
459
|
```ts
|
|
460
|
+
import { Schema } from 'effect'
|
|
461
|
+
import { AppStyle } from 'foldkit-mixins/app'
|
|
462
|
+
import { Themes } from 'foldkit-mixins/theme'
|
|
463
|
+
|
|
443
464
|
const themes = Themes.make({ cobalt, cobaltDense }, { initial: 'cobalt' })
|
|
444
465
|
const { t, stylesheet } = AppStyle.make({ themes })
|
|
445
466
|
const Model = Schema.Struct({ theme: themes.Name })
|
|
@@ -528,7 +549,7 @@ fade still plays.
|
|
|
528
549
|
|
|
529
550
|
A theme reaches the page as pieces, and the page chooses the layers:
|
|
530
551
|
|
|
531
|
-
```ts
|
|
552
|
+
```ts standalone
|
|
532
553
|
import { Layers, Slot, Slots, Capability, Style } from 'foldkit-mixins'
|
|
533
554
|
import { Theme } from 'foldkit-mixins/theme'
|
|
534
555
|
|
|
@@ -617,6 +638,14 @@ variables with token fallbacks; the options only write those variables inline, s
|
|
|
617
638
|
with ten gaps are one rule and ten inline declarations. The pieces are unlayered; put them in
|
|
618
639
|
`layouts`:
|
|
619
640
|
|
|
641
|
+
<!-- docs-check standalone
|
|
642
|
+
import { Capability, Slot, Slots } from 'foldkit-mixins'
|
|
643
|
+
const CardSlots = Slots.define({
|
|
644
|
+
root: Slot.make({ capability: Capability.Container }),
|
|
645
|
+
actions: Slot.make({ capability: Capability.Container }),
|
|
646
|
+
})
|
|
647
|
+
-->
|
|
648
|
+
|
|
620
649
|
```ts
|
|
621
650
|
import { Layers, Style } from 'foldkit-mixins'
|
|
622
651
|
import { Layout } from 'foldkit-mixins/layout'
|
|
@@ -651,6 +680,11 @@ paragraph, list to paragraph, around figures) whose options are `--fk-prose-*` v
|
|
|
651
680
|
element. Its measure and line height are a rule reading those variables, so a later layer can
|
|
652
681
|
override them. Both are unlayered; the page places them:
|
|
653
682
|
|
|
683
|
+
<!-- docs-check standalone
|
|
684
|
+
import { Capability, Slot, Slots } from 'foldkit-mixins'
|
|
685
|
+
const ArticleSlots = Slots.define({ body: Slot.make({ capability: Capability.Container }) })
|
|
686
|
+
-->
|
|
687
|
+
|
|
654
688
|
```ts
|
|
655
689
|
import { Layers, Style } from 'foldkit-mixins'
|
|
656
690
|
import { Defaults } from 'foldkit-mixins/defaults'
|
|
@@ -681,7 +715,7 @@ that case the contract, the style and the setup can each be written once:
|
|
|
681
715
|
| fixing theme, `app` layer and page sheet for one application | `AppStyle.make` from `foldkit-mixins/app` |
|
|
682
716
|
| writing a token-backed declaration in a word | `Utilities` from `foldkit-mixins/utilities` |
|
|
683
717
|
|
|
684
|
-
```ts
|
|
718
|
+
```ts standalone
|
|
685
719
|
import { Event, Style, SlotView } from 'foldkit-mixins'
|
|
686
720
|
import { AppStyle } from 'foldkit-mixins/app'
|
|
687
721
|
import { Theme } from 'foldkit-mixins/theme'
|
|
@@ -718,7 +752,9 @@ What each call does, and does not do:
|
|
|
718
752
|
- `AppStyle.make` computes, once: `theme` is `Theme.compose(Theme.tokens, palette)`, `t` is
|
|
719
753
|
`Theme.ref(theme)`, `L` is `Layers.standard`, and `stylesheet` is the text of the layer order,
|
|
720
754
|
`Defaults.reset`, the tokens, the palette and `Defaults.body` (plus any `global` pieces, in the
|
|
721
|
-
`defaults` layer).
|
|
755
|
+
`defaults` layer). The text is built when `stylesheet` is first read, and kept: building it
|
|
756
|
+
costs milliseconds, so a browser whose sheet is a file should not read it (destructuring
|
|
757
|
+
`stylesheet` reads it). It installs nothing and owns no state; a scheme or theme the user picks is
|
|
722
758
|
still a Model fact (see [Theme from a few knobs](#theme-from-a-few-knobs)).
|
|
723
759
|
- `slots(pieces)` is `Style.slots(pieces, { layer: L.layer('app') })`, and `forSlots` is
|
|
724
760
|
`Style.forSlots` with the same layer: the options take a `name`, never a layer. Both
|
|
@@ -736,14 +772,21 @@ step is a type error and the value still follows the `density` knob and theme ov
|
|
|
736
772
|
(`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a palette
|
|
737
773
|
color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
|
|
738
774
|
constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
|
|
739
|
-
`truncate`, `pointer` and `selectNone`, and `
|
|
775
|
+
`truncate`, `srOnly`, `pointer` and `selectNone`, `scriptedOnly` and `plainOnly(display)` (the
|
|
776
|
+
pair for a page in a browser running no scripts: a control only a script drives is hidden there,
|
|
777
|
+
and its plain stand-in, `display: none` until then, is shown as `display`; put `scriptedOnly` last
|
|
778
|
+
in a slot's pieces so it wins over a width's `display`), and `scrollFade(axis)`, a scroller's content dissolving
|
|
740
779
|
toward an edge with more to scroll (a scroll-driven mask: the true ends stay crisp until something
|
|
741
780
|
is past them, and a browser without scroll timelines gets no fade), `scrollDivider(axis)` with
|
|
742
781
|
`scrollTimeline(axis)`, a hairline at each edge with more past it, drawn on a positioned parent's
|
|
743
782
|
`::before` and `::after` (the fade's mask would erase a line inside the scroller) from the timeline
|
|
744
783
|
the scroller names, where the browser has `timeline-scope`, and `steady(weight)`, room for a
|
|
745
784
|
label at a heavier weight, read from the element's `data-label`, so turning bold moves nothing
|
|
746
|
-
beside it
|
|
785
|
+
beside it, and `busyReveal`, busy text said only once a wait is noticeable: on an element marked
|
|
786
|
+
`aria-busy="true"` it fades in after 0.6s, so a read answered sooner never flashes a "Loading…";
|
|
787
|
+
the element renders from the start, holding its space, and without `aria-busy` the piece does
|
|
788
|
+
nothing, so one status Slot also says "Nothing here." plainly. Its fade follows the `motion` knob;
|
|
789
|
+
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
790
|
layer of the style it is composed into, and a plain declaration after it wins per property. A
|
|
748
791
|
value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
|
|
749
792
|
the palette's groups is read through `t`.
|
|
@@ -755,6 +798,61 @@ state. Its attributes are built while resolving from the view's `input` and `h`,
|
|
|
755
798
|
emit Messages from the view's own Message universe. Like an agent capability,
|
|
756
799
|
a Behavior points one way — toward a Message — and never gets a Model setter.
|
|
757
800
|
|
|
801
|
+
<!-- docs-check standalone
|
|
802
|
+
import { Schema } from 'effect'
|
|
803
|
+
import type { HtmlBuilder } from 'foldkit/html'
|
|
804
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
805
|
+
import type { MountAction } from 'foldkit/mount'
|
|
806
|
+
import { expect } from 'vitest'
|
|
807
|
+
import { Projection, Surface } from 'foldkit-surface'
|
|
808
|
+
import { A11y, Attr, Behavior, Capability, Event, Slot, Slots, SlotView, Style } from 'foldkit-mixins'
|
|
809
|
+
const Message = defineMessageUnion({ ChangedValue: { value: Schema.String } })
|
|
810
|
+
type Message = typeof Message.Type
|
|
811
|
+
type FieldInput = { readonly value: string; readonly invalid: boolean }
|
|
812
|
+
const Container = Slot.make({ capability: Capability.Container })
|
|
813
|
+
const FieldSlots = Slots.define({
|
|
814
|
+
root: Container,
|
|
815
|
+
input: Slot.make({
|
|
816
|
+
capability: Capability.TextInput,
|
|
817
|
+
events: [Event.Input],
|
|
818
|
+
attributes: [Attr.AriaInvalid],
|
|
819
|
+
}),
|
|
820
|
+
})
|
|
821
|
+
const FieldStyle = Style.forSlots(FieldSlots)({
|
|
822
|
+
root: Style.compose(Style.class('field'), Style.inline({ display: 'grid' })),
|
|
823
|
+
input: Style.class('field-input'),
|
|
824
|
+
})
|
|
825
|
+
const Validation = Behavior.forSlots(FieldSlots)<FieldInput, Message>({
|
|
826
|
+
input: Behavior.slot({
|
|
827
|
+
requires: { capability: Capability.TextInput, attributes: [Attr.AriaInvalid] },
|
|
828
|
+
attributes: ({ input, h }) => [h.AriaInvalid(input.invalid)],
|
|
829
|
+
}),
|
|
830
|
+
})
|
|
831
|
+
declare const MeasureField: (value: string) => MountAction<Message, never>
|
|
832
|
+
const ListSlots = Slots.define({ root: Container, list: Container, row: Container })
|
|
833
|
+
const ToolbarSlots = Slots.define({ root: Container, tool: Container })
|
|
834
|
+
const PanelSlots = Slots.define({ root: Container, title: Container, count: Container })
|
|
835
|
+
const PageSlots = Slots.define({ header: Container })
|
|
836
|
+
const DialogSlots = Slots.define({ trigger: Slot.make({ capability: Capability.Interactive, events: [Event.Click] }), content: Container })
|
|
837
|
+
const ListParts = SlotView.parts(ListSlots)<{ readonly rows: ReadonlyArray<string> }, Message>()
|
|
838
|
+
const PageModel = Schema.Struct({
|
|
839
|
+
cart: Schema.Array(Schema.String),
|
|
840
|
+
page: Schema.Struct({ title: Schema.String }),
|
|
841
|
+
})
|
|
842
|
+
type PageModel = typeof PageModel.Type
|
|
843
|
+
const App = Surface.application({ Model: PageModel, Message })
|
|
844
|
+
const Counter = SlotView.forMessages<never>().define(
|
|
845
|
+
Slots.define({ root: Container, count: Container }),
|
|
846
|
+
(count: number, slots, h) => h.main(slots.root.attrs(), [h.p(slots.count.attrs(), [String(count)])]),
|
|
847
|
+
)
|
|
848
|
+
const stylesheet = Style.stylesheet()
|
|
849
|
+
declare const slots: SlotView.SlotBuilders<typeof ListSlots, Message> &
|
|
850
|
+
SlotView.SlotBuilders<typeof PageSlots, Message>
|
|
851
|
+
declare const h: HtmlBuilder<Message>
|
|
852
|
+
declare const model: PageModel
|
|
853
|
+
declare const items: ReadonlyArray<{ readonly id: string; readonly label: string }>
|
|
854
|
+
-->
|
|
855
|
+
|
|
758
856
|
```ts
|
|
759
857
|
const Focus = Behavior.forSlots(FieldSlots)<FieldInput, Message>({
|
|
760
858
|
input: Behavior.slot({
|
|
@@ -791,7 +889,10 @@ array once, and a view and the Behaviors on it agree about identity, order, and
|
|
|
791
889
|
```ts
|
|
792
890
|
import { Behaviors } from 'foldkit-mixins'
|
|
793
891
|
|
|
794
|
-
|
|
892
|
+
type ToolbarInput = { readonly tools: ReadonlyArray<{ readonly id: string; readonly disabled: boolean }> }
|
|
893
|
+
declare const toolbar: ToolbarInput
|
|
894
|
+
|
|
895
|
+
const tools = Behaviors.Collection.of(toolbar.tools, {
|
|
795
896
|
id: tool => tool.id,
|
|
796
897
|
disabled: tool => tool.disabled,
|
|
797
898
|
}) // ids, size, at, indexOf, isDisabled, enabled, slotItem
|
|
@@ -802,7 +903,7 @@ const Ids = Behaviors.Collection.behavior(ToolbarSlots)<ToolbarInput, Message>({
|
|
|
802
903
|
posInSet: true,
|
|
803
904
|
})
|
|
804
905
|
|
|
805
|
-
// in the view: slots.tool.attrs([h.Key(tool.id)],
|
|
906
|
+
// in the view: slots.tool.attrs([h.Key(tool.id)], tools.slotItem(index))
|
|
806
907
|
```
|
|
807
908
|
|
|
808
909
|
`of` is pure and refuses two items with one id (`mixins:duplicate-item-id`), since an id is what
|
|
@@ -1103,8 +1204,9 @@ development through the running server and in a build through one of its own. It
|
|
|
1103
1204
|
compiles a module the application owns, through a server, as the page would
|
|
1104
1205
|
compile it, so the build's foundations are the application's rather than a copy.
|
|
1105
1206
|
|
|
1106
|
-
```ts
|
|
1207
|
+
```ts standalone
|
|
1107
1208
|
// vite.config.ts
|
|
1209
|
+
import { defineConfig } from 'vite'
|
|
1108
1210
|
import { foundations } from 'foldkit-mixins/foundations'
|
|
1109
1211
|
|
|
1110
1212
|
export default defineConfig({
|
|
@@ -1118,6 +1220,113 @@ runs from. `loadFoundations(options)` is the same compile without the plugin,
|
|
|
1118
1220
|
returning the text for a caller that writes it itself. The subpath is node-only:
|
|
1119
1221
|
a page that imports it fails fast naming `vite`.
|
|
1120
1222
|
|
|
1223
|
+
## The stylesheet as a file
|
|
1224
|
+
|
|
1225
|
+
Written into every page, the stylesheet is sent again with each response and
|
|
1226
|
+
parsed again by the server's checks of the page. `foldkit-mixins/vite` writes
|
|
1227
|
+
it once, as a hashed file in the browser build, and gives the server its
|
|
1228
|
+
address; the page links it:
|
|
1229
|
+
|
|
1230
|
+
```ts standalone
|
|
1231
|
+
// vite.config.ts
|
|
1232
|
+
import { defineConfig } from 'vite'
|
|
1233
|
+
import { styles } from 'foldkit-mixins/vite'
|
|
1234
|
+
|
|
1235
|
+
export default defineConfig({
|
|
1236
|
+
plugins: [styles({ sheet: '/src/style.ts' })],
|
|
1237
|
+
})
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
```ts sketch
|
|
1241
|
+
// the server entry: a link in the document's head, so the first paint waits for it
|
|
1242
|
+
import { href } from 'virtual:foldkit-styles'
|
|
1243
|
+
|
|
1244
|
+
const head = `<link rel="stylesheet" href="${href}" data-foldkit-styles-href>`
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
`sheet` is a module that exports the stylesheet text as `stylesheet`
|
|
1248
|
+
(`Style.stylesheet(...)`, or an `AppStyle.make` result). The file is that
|
|
1249
|
+
sheet followed by `Style.complete(sheet)`'s addition: every class and global
|
|
1250
|
+
rule the process compiled that the sheet does not hold. The plugin bundles the
|
|
1251
|
+
sheet module (every module it imports is kept, since compiling a Style is a
|
|
1252
|
+
side effect), so import the application's styled modules from it. Keep the
|
|
1253
|
+
module out of the browser's: `examples/foldkit/domains-plus` reads the sheet
|
|
1254
|
+
in `src/server/sheet.ts` alone, so the page never builds the text it links.
|
|
1255
|
+
Declare the virtual module for TypeScript (`declare module 'virtual:foldkit-styles' { export const href: string }`).
|
|
1256
|
+
|
|
1257
|
+
- **Build.** `assets/styles-<hash>.css` is written by the `client` build, named
|
|
1258
|
+
by its content; `href` carries Vite's `base`, which must be absolute. A
|
|
1259
|
+
`?url` import in the sheet (a font) is the address the browser build gives it.
|
|
1260
|
+
- **Dev.** `href` is `/__foldkit-styles.css`, served by the dev server from the
|
|
1261
|
+
modules it has loaded and read again after an edit, so the server entry has
|
|
1262
|
+
one code path.
|
|
1263
|
+
- **Browser.** The `data-foldkit-styles-href` mark tells the injector the link
|
|
1264
|
+
is a stylesheet: once it loads, the injector reads its rules and skips every
|
|
1265
|
+
class and global rule it holds; a class drawn before it loads waits for it. A
|
|
1266
|
+
sheet the browser withholds (cross-origin without CORS) counts as empty, so
|
|
1267
|
+
its classes are injected again rather than lost.
|
|
1268
|
+
- **Without the plugin**, `Style.usedIn(html)` still writes what one page uses.
|
|
1269
|
+
|
|
1270
|
+
### Only the tokens the sheet reads
|
|
1271
|
+
|
|
1272
|
+
`Theme.standard` defines every scale and palette, whether a page draws it or
|
|
1273
|
+
not, and on domains-plus those definitions were most of the sheet. With
|
|
1274
|
+
`prune`, the plugin ships only the `--fk-*` tokens a rule reads, directly or
|
|
1275
|
+
through another kept token, in dev and in the build alike (`Inert.prune` on the
|
|
1276
|
+
completed sheet, from `foldkit-mixins/testing`, so a browser reading `Theme`
|
|
1277
|
+
carries none of it). Domains-plus's sheet went from 15.2 KB to 10.6 KB brotli.
|
|
1278
|
+
|
|
1279
|
+
```ts
|
|
1280
|
+
styles({ sheet: '/src/style.ts', prune: { keep: [] } })
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1283
|
+
A token read outside the sheet is taken too: an inline style built with
|
|
1284
|
+
`Theme.ref`, or a script reading a computed value by name. Name each in `keep`,
|
|
1285
|
+
as `--fk-x` or as `Theme.ref` writes it (`var(--fk-x)`); an entry naming no
|
|
1286
|
+
token throws. Hold it with a test: `Inert.missingTokens(tree, Inert.prune(css,
|
|
1287
|
+
{ keep }))` lists each token a drawn view reads that the pruned sheet does not
|
|
1288
|
+
define. It sees only what is drawn, so a browser test comparing the page's
|
|
1289
|
+
computed styles under both sheets covers the states a server never draws
|
|
1290
|
+
(`examples/foldkit/domains-plus/test/look.browser.test.ts`). It is off unless
|
|
1291
|
+
asked for.
|
|
1292
|
+
|
|
1293
|
+
### Style modules shipped as data
|
|
1294
|
+
|
|
1295
|
+
The sheet already holds every class, but a page that imports its style
|
|
1296
|
+
module still runs the compiler to work out each class's name: the recipes,
|
|
1297
|
+
the theme builder and the rules, about 30 KB brotli on domains-plus. Name the
|
|
1298
|
+
style modules in `modules`, and the production browser build replaces each
|
|
1299
|
+
with what it evaluated to while the sheet was built:
|
|
1300
|
+
|
|
1301
|
+
```ts
|
|
1302
|
+
styles({ sheet: '/src/server/sheet.ts', modules: ['/src/client/style.ts'] })
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
- **What a listed module ships.** Each Style keeps its `name` and its `mixin`,
|
|
1306
|
+
whose Slots draw the classes and inline declarations the Style compiled to;
|
|
1307
|
+
a `Style.slots` declaration keeps its `slots` contract and its `style`. Its
|
|
1308
|
+
other fields (`pieces`, `css`, `rules`) throw when read. A string, or an
|
|
1309
|
+
object of strings such as `t`, ships as it is.
|
|
1310
|
+
- **What fails the build.** An export that is anything else (a function, an
|
|
1311
|
+
`AppStyle`), and a Style using `Style.whenInput` or `Style.perItem`, which
|
|
1312
|
+
choose classes at run time. The error names the module and the export. Keep
|
|
1313
|
+
such a module at run time by leaving it off the list.
|
|
1314
|
+
- **Attach with `SlotView`.** A module that imports `Style` keeps the compiler
|
|
1315
|
+
in the page, so attach a frozen style with `SlotView.attach(Page.style.mixin)`
|
|
1316
|
+
rather than `Style.attach(Page.style)`, and keep the `AppStyle` (its `slots`
|
|
1317
|
+
and `forSlots` are functions) in a module of its own that only the listed
|
|
1318
|
+
module and the sheet import.
|
|
1319
|
+
- **Production and development.** With a module listed, a production browser
|
|
1320
|
+
build's Slots inject nothing: the linked sheet holds every class, and the
|
|
1321
|
+
build fails if a class a frozen module draws has no rule in it. Development
|
|
1322
|
+
is unchanged: modules run as written, and a Slot injects what it draws. The
|
|
1323
|
+
server build is unchanged too.
|
|
1324
|
+
|
|
1325
|
+
On domains-plus the page's JavaScript fell from 217.5 KB to 191.6 KB brotli,
|
|
1326
|
+
and no recipe or rule compiler is left in it (`test/bundle.test.ts`);
|
|
1327
|
+
`test/frozen.test.ts` checks that every frozen export draws what the run-time
|
|
1328
|
+
module does.
|
|
1329
|
+
|
|
1121
1330
|
## `@foldkit/ui`
|
|
1122
1331
|
|
|
1123
1332
|
`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,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
|
|
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;;;;;;WAMrE;;;;;;;;;wBAYK,KAAK,qBAAqB,YAAY,cAAc,sBAClE,SAAS,sBAAsB,MAAM,OACpC,SAAS;wBACI,KAAK,YAAY,cAAc,sBAC7C,SAAS,gBAAgB,OACxB,SAAS;qBA+BC"}
|
package/dist/app.js
CHANGED
|
@@ -18,6 +18,7 @@ function make(options) {
|
|
|
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")}}}`,
|
|
64
|
+
`@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover:not([aria-disabled=true]){background:${v("surface-muted", "ButtonFace")}}}`,
|
|
65
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}`,
|
|
66
|
+
`:where(:is(button,input,select,textarea):disabled,button[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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AO,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{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled,button[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;CA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,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Capability from "./capability.js";
|
|
|
2
2
|
import { Any as AnyCapability, Capability as CapabilityShape, Satisfies } from "./capability.js";
|
|
3
3
|
import * as MetadataToken from "./metadataToken.js";
|
|
4
4
|
import { Layers, Layers as LayersValue, Placement } from "./layers.js";
|
|
5
|
-
import { ContainerSlot, Declared, DeclaredPieces, DeclaredSlots, NamedStyle, SlotPiece, SlotRecipe, SlotRecipeSelection, Style, StyleOptions, StylePieces, StyleValues, StylesheetSource } from "./style.js";
|
|
5
|
+
import { ContainerSlot, Declared, DeclaredPieces, DeclaredSlots, NamedStyle, RecipePieces, SlotPiece, SlotRecipe, SlotRecipeSelection, Style, StyleOptions, StylePieces, StyleValues, StylesheetSource } from "./style.js";
|
|
6
6
|
import { Declarations, Piece, StyleCondition, StyleValue } from "./styleValue.js";
|
|
7
7
|
import { Refs, Theme, Theme as ThemeValue, ThemeTokens } from "./theme/core.js";
|
|
8
8
|
import * as Diagnostics from "./diagnostics.js";
|
|
@@ -34,4 +34,4 @@ import { Contract as SlotsContract } from "./slots.js";
|
|
|
34
34
|
import { StyleRule } from "./styleRules.js";
|
|
35
35
|
import { MixinsDiagnostic, MountFailed } from "./mountFailed.js";
|
|
36
36
|
import { Contribution, ContributionContext, DynamicContribution, InputContribution, SlotContribution, SlotItem, StaticContribution, StaticContributionMap } from "./contribution.js";
|
|
37
|
-
export { A11y, type A11yDiagnostic, type A11yDiagnosticCode, type A11yPattern, type A11yRequirement, type AnyCapability, type AnyMixin, Attr, type AttrToken, type AttributeName, Attributes, Behavior, type BehaviorSlotOptions, type BehaviorSpec, Behaviors, Capability, type CapabilityShape, type ContainerSlot, type Contribution, type ContributionContext, type Declarations, type Declared, type DeclaredPieces, type DeclaredSlots, DevOverlay, type Diagnostic, type DiagnosticCode, Diagnostics, type DynamicContribution, Event, type EventName, type EventToken, type HiddenOf, type InputContribution, Layers, type LayersValue, type MessageSlotView, MetadataToken, Mixin, type MixinFor, type MixinValue, type MixinsDiagnostic, type MountFailed, type NamedBehavior, type NamedStyle, type Piece, type Placement, type Refs, Requirement, type RequirementName, type RequirementToken, type ResolveOptions, Resolver, type Satisfies, Selector, Slot, type SlotAttributes, type SlotBuilder, type SlotBuilders, type SlotContribution, type SlotItem, type SlotPiece, type SlotProtection, type SlotRecipe, type SlotRecipeSelection, type SlotRequirements, SlotView, type SlotViewRender, type SlotViewShape, type SlotViewTransform, type SlotViewTransformFor, Slots, type SlotsContract, type StaticContribution, type StaticContributionMap, type StaticMixin, Style, type StyleCondition, type StyleOptions, type StylePieces, type StyleRule, type StyleValue, type StyleValues, type StylesheetSource, Theme, type ThemeTokens, type ThemeValue, type UnnamedSlot };
|
|
37
|
+
export { A11y, type A11yDiagnostic, type A11yDiagnosticCode, type A11yPattern, type A11yRequirement, type AnyCapability, type AnyMixin, Attr, type AttrToken, type AttributeName, Attributes, Behavior, type BehaviorSlotOptions, type BehaviorSpec, Behaviors, Capability, type CapabilityShape, type ContainerSlot, type Contribution, type ContributionContext, type Declarations, type Declared, type DeclaredPieces, type DeclaredSlots, DevOverlay, type Diagnostic, type DiagnosticCode, Diagnostics, type DynamicContribution, Event, type EventName, type EventToken, type HiddenOf, type InputContribution, Layers, type LayersValue, type MessageSlotView, MetadataToken, Mixin, type MixinFor, type MixinValue, type MixinsDiagnostic, type MountFailed, type NamedBehavior, type NamedStyle, type Piece, type Placement, type RecipePieces, type Refs, Requirement, type RequirementName, type RequirementToken, type ResolveOptions, Resolver, type Satisfies, Selector, Slot, type SlotAttributes, type SlotBuilder, type SlotBuilders, type SlotContribution, type SlotItem, type SlotPiece, type SlotProtection, type SlotRecipe, type SlotRecipeSelection, type SlotRequirements, SlotView, type SlotViewRender, type SlotViewShape, type SlotViewTransform, type SlotViewTransformFor, Slots, type SlotsContract, type StaticContribution, type StaticContributionMap, type StaticMixin, Style, type StyleCondition, type StyleOptions, type StylePieces, type StyleRule, type StyleValue, type StyleValues, type StylesheetSource, Theme, type ThemeTokens, type ThemeValue, type UnnamedSlot };
|
package/dist/inject.d.ts
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* browser's injection recognizes what a server wrote. Called by the compiler.
|
|
5
5
|
*/
|
|
6
6
|
export declare const register: (className: string, css: string, globalCss: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The set a server render collects drawn classes in, under a registered
|
|
9
|
+
* symbol so `foldkit-ssr` can set it without importing this package.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DRAWN_CLASSES: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* The CSS for the compiled classes `classes`, and once each the global CSS of
|
|
14
|
+
* the Styles those classes came from, after the standard layer order. A
|
|
15
|
+
* render that collected the classes it drew needs no scan of its HTML.
|
|
16
|
+
*/
|
|
17
|
+
export declare const usedDrawn: (classes: Iterable<string>) => string;
|
|
7
18
|
/**
|
|
8
19
|
* The CSS for every compiled class that `html` carries, and once each the
|
|
9
20
|
* global CSS of the Styles those classes came from, after the standard layer
|
|
@@ -12,6 +23,13 @@ export declare const register: (className: string, css: string, globalCss: strin
|
|
|
12
23
|
* nothing twice.
|
|
13
24
|
*/
|
|
14
25
|
export declare const usedIn: (html: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* `sheet` followed by every compiled class and global rule it does not hold:
|
|
28
|
+
* a build's complete stylesheet, where `usedIn` finds the classes of one
|
|
29
|
+
* page at request time. Which classes exist is whatever the process has
|
|
30
|
+
* compiled, so load the application's styled modules first.
|
|
31
|
+
*/
|
|
32
|
+
export declare const complete: (sheet: string) => string;
|
|
15
33
|
/**
|
|
16
34
|
* Queues the CSS of each registered class a contribution draws that the page
|
|
17
35
|
* does not carry yet, and its global CSS (keyframes, a theme root) once.
|
package/dist/inject.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.d.ts","names":[],"sources":["../src/inject.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"inject.d.ts","names":[],"sources":["../src/inject.ts"],"mappings":";;;;;qBAqCa,WAAQ,mBAAqB,aAAa;;;;;qBAmB1C;;;;;;qBAgBA,YAAS,SAAa;;;;;;;;qBAqBtB,SAAM;;;;;;;qBASN,WAAQ;;;;;;qBAuJR,SAAM;WACR,UAAU;WACV"}
|