foldkit-mixins-ui 0.2.0 → 0.4.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/dist/index.mjs CHANGED
@@ -1,5 +1,46 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Attr, Capability, Event, Slot, SlotView, Slots } from "foldkit-mixins";
2
+ import { Effect, Schema, Stream } from "effect";
3
+ import { AnchorConfig, anchorSetup } from "@foldkit/ui/anchor";
4
+ import * as Mount from "foldkit/mount";
5
+ import { A11y, Attr, Behavior, Capability, Event, Layers, Slot, SlotView, Slots, Style } from "foldkit-mixins";
6
+ import { Theme } from "foldkit-mixins/theme";
7
+ //#region src/anchor.ts
8
+ /**
9
+ * `@foldkit/ui`'s anchor positioning as a Mount and a Behavior: the floating
10
+ * element is placed against the button whose id is given, with placement,
11
+ * gap, offset, padding, portal and flip handled by `anchorSetup`, which also
12
+ * releases on unmount. The Mount writes `position`, `top` and `left` on the
13
+ * element itself, imperatively; a Style on the same slot must leave those
14
+ * alone, and `data-placement` is written by `@foldkit/ui` for styling.
15
+ */
16
+ var anchor_exports = /* @__PURE__ */ __exportAll({
17
+ Anchor: () => Anchor,
18
+ behavior: () => behavior
19
+ });
20
+ const Anchor = Mount.defineStream("Anchor", {
21
+ messages: [Schema.Never],
22
+ args: {
23
+ /** The id of the element the floating one is placed against. */
24
+ buttonId: Schema.String,
25
+ anchor: AnchorConfig,
26
+ interceptTab: Schema.optional(Schema.Boolean),
27
+ focusAfterPosition: Schema.optional(Schema.Boolean),
28
+ focusSelector: Schema.optional(Schema.String),
29
+ arrowId: Schema.optional(Schema.String),
30
+ arrowPadding: Schema.optional(Schema.Number)
31
+ },
32
+ execute: ({ element, buttonId, anchor, ...optional }) => Stream.callback(() => Effect.acquireRelease(Effect.sync(() => anchorSetup(element, {
33
+ buttonId,
34
+ anchor,
35
+ ...Object.fromEntries(Object.entries(optional).filter(([key, value]) => key !== "viewStateChanges" && value !== void 0))
36
+ })), (release) => Effect.sync(() => release())))
37
+ });
38
+ /** Mounts the anchor on the floating slot with the config the input gives. */
39
+ const behavior = (slots) => (options) => Behavior.forSlots(slots)({ [options.floating]: Behavior.slot({
40
+ requires: { capability: Capability.Container },
41
+ mount: (input) => Anchor(options.config(input))
42
+ }) }, { name: "Anchor" });
43
+ //#endregion
3
44
  //#region src/resolve.ts
4
45
  const resolveFor = (slots, mixins, context) => (base) => {
5
46
  const builders = SlotView.buildersFor(slots, mixins, context);
@@ -11,7 +52,7 @@ const resolveFor = (slots, mixins, context) => (base) => {
11
52
  //#region src/button.ts
12
53
  var button_exports = /* @__PURE__ */ __exportAll({
13
54
  ButtonSlots: () => ButtonSlots,
14
- resolve: () => resolve$14
55
+ resolve: () => resolve$15
15
56
  });
16
57
  /**
17
58
  * The button publishes one slot. `click` is owned by the base `OnClick` when
@@ -27,12 +68,12 @@ const ButtonSlots = Slots.define({ button: Slot.make({
27
68
  Attr.Disabled
28
69
  ]
29
70
  }) });
30
- const resolve$14 = (attributes, mixins, context) => resolveFor(ButtonSlots, mixins, context)(attributes);
71
+ const resolve$15 = (attributes, mixins, context) => resolveFor(ButtonSlots, mixins, context)(attributes);
31
72
  //#endregion
32
73
  //#region src/calendar.ts
33
74
  var calendar_exports = /* @__PURE__ */ __exportAll({
34
75
  CalendarSlots: () => CalendarSlots,
35
- resolve: () => resolve$13
76
+ resolve: () => resolve$14
36
77
  });
37
78
  /**
38
79
  * Calendar is a nested Submodel whose shape depends on `model.viewMode`. The
@@ -143,7 +184,7 @@ const CalendarSlots = Slots.define({
143
184
  })
144
185
  });
145
186
  /** Resolves every mode's nested groups, preserving the `_tag` and heading data. */
146
- const resolve$13 = (render, mixins, context) => {
187
+ const resolve$14 = (render, mixins, context) => {
147
188
  const builders = SlotView.buildersFor(CalendarSlots, mixins, context);
148
189
  const root = builders.root.attrs(render.root);
149
190
  const grid = builders.grid.attrs(render.grid);
@@ -202,7 +243,7 @@ const resolve$13 = (render, mixins, context) => {
202
243
  //#region src/checkbox.ts
203
244
  var checkbox_exports = /* @__PURE__ */ __exportAll({
204
245
  CheckboxSlots: () => CheckboxSlots,
205
- resolve: () => resolve$12
246
+ resolve: () => resolve$13
206
247
  });
207
248
  /**
208
249
  * Both the control and its label carry the base toggle handlers, so both own
@@ -230,12 +271,12 @@ const CheckboxSlots = Slots.define({
230
271
  attributes: [Attr.Value]
231
272
  })
232
273
  });
233
- const resolve$12 = (attributes, mixins, context) => resolveFor(CheckboxSlots, mixins, context)(attributes);
274
+ const resolve$13 = (attributes, mixins, context) => resolveFor(CheckboxSlots, mixins, context)(attributes);
234
275
  //#endregion
235
276
  //#region src/dialog.ts
236
277
  var dialog_exports = /* @__PURE__ */ __exportAll({
237
278
  DialogSlots: () => DialogSlots,
238
- resolve: () => resolve$11
279
+ resolve: () => resolve$12
239
280
  });
240
281
  /**
241
282
  * Dialog is a Submodel: each published bundle is a `ChildAttribute` group that
@@ -268,12 +309,12 @@ const DialogSlots = Slots.define({
268
309
  })
269
310
  });
270
311
  /** Resolves the dialog's render groups; `isVisible` passes through unchanged. */
271
- const resolve$11 = (render, mixins, context) => resolveFor(DialogSlots, mixins, context)(render);
312
+ const resolve$12 = (render, mixins, context) => resolveFor(DialogSlots, mixins, context)(render);
272
313
  //#endregion
273
314
  //#region src/disclosure.ts
274
315
  var disclosure_exports = /* @__PURE__ */ __exportAll({
275
316
  DisclosureSlots: () => DisclosureSlots,
276
- resolve: () => resolve$10
317
+ resolve: () => resolve$11
277
318
  });
278
319
  const DisclosureSlots = Slots.define({
279
320
  button: Slot.make({
@@ -289,12 +330,12 @@ const DisclosureSlots = Slots.define({
289
330
  panel: Slot.make({ capability: Capability.Container })
290
331
  });
291
332
  /** `animatePanel` is not an attribute bundle, so it passes through unchanged. */
292
- const resolve$10 = (attributes, mixins, context) => resolveFor(DisclosureSlots, mixins, context)(attributes);
333
+ const resolve$11 = (attributes, mixins, context) => resolveFor(DisclosureSlots, mixins, context)(attributes);
293
334
  //#endregion
294
335
  //#region src/fieldset.ts
295
336
  var fieldset_exports = /* @__PURE__ */ __exportAll({
296
337
  FieldsetSlots: () => FieldsetSlots,
297
- resolve: () => resolve$9
338
+ resolve: () => resolve$10
298
339
  });
299
340
  const FieldsetSlots = Slots.define({
300
341
  fieldset: Slot.make({
@@ -304,7 +345,40 @@ const FieldsetSlots = Slots.define({
304
345
  legend: Slot.make({ capability: Capability.Container }),
305
346
  description: Slot.make({ capability: Capability.Container })
306
347
  });
307
- const resolve$9 = (attributes, mixins, context) => resolveFor(FieldsetSlots, mixins, context)(attributes);
348
+ const resolve$10 = (attributes, mixins, context) => resolveFor(FieldsetSlots, mixins, context)(attributes);
349
+ //#endregion
350
+ //#region src/hoverIntent.ts
351
+ var hoverIntent_exports = /* @__PURE__ */ __exportAll({
352
+ HoverIntentSlots: () => HoverIntentSlots,
353
+ resolve: () => resolve$9
354
+ });
355
+ /**
356
+ * HoverIntent is a Submodel: open and close delays with intent, for a hover
357
+ * card or a menu that should not flicker. Both bundles are `ChildAttribute`
358
+ * groups: `trigger` owns the pointer and focus entry points, `panel` owns
359
+ * its own so moving into the panel keeps it open. `resolve` preserves each
360
+ * group by identity.
361
+ */
362
+ const HoverIntentSlots = Slots.define({
363
+ trigger: Slot.make({
364
+ capability: Capability.Interactive,
365
+ events: [
366
+ Event.Hover,
367
+ Event.Focus,
368
+ Event.Blur
369
+ ]
370
+ }),
371
+ panel: Slot.make({
372
+ capability: Capability.Container,
373
+ events: [
374
+ Event.Hover,
375
+ Event.Focus,
376
+ Event.Blur
377
+ ]
378
+ })
379
+ });
380
+ /** Resolves the hover-intent render groups; `isVisible` passes through unchanged. */
381
+ const resolve$9 = (render, mixins, context) => resolveFor(HoverIntentSlots, mixins, context)(render);
308
382
  //#endregion
309
383
  //#region src/input.ts
310
384
  var input_exports = /* @__PURE__ */ __exportAll({
@@ -618,6 +692,730 @@ const TooltipSlots = Slots.define({
618
692
  /** Resolves the tooltip's render groups; `isVisible` passes through unchanged. */
619
693
  const resolve = (render, mixins, context) => resolveFor(TooltipSlots, mixins, context)(render);
620
694
  //#endregion
621
- export { button_exports as Button, ButtonSlots, calendar_exports as Calendar, CalendarSlots, checkbox_exports as Checkbox, CheckboxSlots, dialog_exports as Dialog, DialogSlots, disclosure_exports as Disclosure, DisclosureSlots, fieldset_exports as Fieldset, FieldsetSlots, input_exports as Input, InputSlots, popover_exports as Popover, PopoverSlots, radioGroup_exports as RadioGroup, RadioGroupSlots, select_exports as Select, SelectSlots, slider_exports as Slider, SliderSlots, switch_exports as Switch, SwitchSlots, tabs_exports as Tabs, TabsSlots, textarea_exports as Textarea, TextareaSlots, tooltip_exports as Tooltip, TooltipSlots, resolveFor as resolve };
695
+ //#region src/patterns.ts
696
+ /**
697
+ * An accessibility pattern per adapter: the slots a widget of that kind must
698
+ * publish, with the capability, events and attributes each must expose, as
699
+ * `A11y.pattern` contracts. `catalog` lists them with their tier, the ARIA
700
+ * roles involved, and the platform floor: what the widget relies on the
701
+ * browser for, so a reader or an agent can ask. The gate test validates
702
+ * every adapter's Slots against its pattern; a custom view built from
703
+ * `foldkit-primitives/interaction` entries validates against the same one.
704
+ */
705
+ var patterns_exports = /* @__PURE__ */ __exportAll({
706
+ Button: () => Button$1,
707
+ Calendar: () => Calendar,
708
+ Checkbox: () => Checkbox$1,
709
+ Dialog: () => Dialog$1,
710
+ Disclosure: () => Disclosure,
711
+ Fieldset: () => Fieldset,
712
+ Input: () => Input$1,
713
+ Popover: () => Popover,
714
+ RadioGroup: () => RadioGroup,
715
+ Select: () => Select,
716
+ Slider: () => Slider,
717
+ Switch: () => Switch$1,
718
+ Tabs: () => Tabs$1,
719
+ Textarea: () => Textarea$1,
720
+ Tooltip: () => Tooltip,
721
+ catalog: () => catalog
722
+ });
723
+ const Button$1 = A11y.pattern({ button: {
724
+ capability: Capability.Interactive,
725
+ events: [Event.Click],
726
+ attributes: [Attr.Role]
727
+ } });
728
+ const Input$1 = A11y.pattern({
729
+ input: {
730
+ capability: Capability.TextInput,
731
+ events: [Event.Input, Event.Blur],
732
+ attributes: [Attr.AriaInvalid]
733
+ },
734
+ label: { capability: Capability.Container },
735
+ description: {
736
+ capability: Capability.Container,
737
+ optional: true
738
+ }
739
+ });
740
+ const Textarea$1 = A11y.pattern({
741
+ textarea: {
742
+ capability: Capability.TextInput,
743
+ events: [Event.Input, Event.Blur],
744
+ attributes: [Attr.AriaInvalid]
745
+ },
746
+ label: { capability: Capability.Container },
747
+ description: {
748
+ capability: Capability.Container,
749
+ optional: true
750
+ }
751
+ });
752
+ const Select = A11y.pattern({
753
+ select: {
754
+ capability: Capability.Interactive,
755
+ events: [Event.Change],
756
+ attributes: [Attr.AriaInvalid]
757
+ },
758
+ label: { capability: Capability.Container },
759
+ description: {
760
+ capability: Capability.Container,
761
+ optional: true
762
+ }
763
+ });
764
+ const Checkbox$1 = A11y.pattern({
765
+ checkbox: {
766
+ capability: Capability.Interactive,
767
+ events: [Event.Click],
768
+ attributes: [Attr.Role]
769
+ },
770
+ label: { capability: Capability.Container },
771
+ hiddenInput: {
772
+ capability: Capability.Base,
773
+ attributes: [Attr.Value],
774
+ optional: true
775
+ }
776
+ });
777
+ const Switch$1 = A11y.pattern({
778
+ button: {
779
+ capability: Capability.Interactive,
780
+ events: [Event.Click],
781
+ attributes: [Attr.Role]
782
+ },
783
+ label: { capability: Capability.Container },
784
+ hiddenInput: {
785
+ capability: Capability.Base,
786
+ attributes: [Attr.Value],
787
+ optional: true
788
+ }
789
+ });
790
+ const Fieldset = A11y.pattern({
791
+ fieldset: { capability: Capability.Container },
792
+ legend: { capability: Capability.Container }
793
+ });
794
+ const Disclosure = A11y.pattern({
795
+ button: {
796
+ capability: Capability.Interactive,
797
+ events: [Event.Click],
798
+ attributes: [Attr.AriaExpanded]
799
+ },
800
+ panel: { capability: Capability.Container }
801
+ });
802
+ const Dialog$1 = A11y.pattern({
803
+ dialog: {
804
+ capability: Capability.Container,
805
+ events: [Event.Cancel]
806
+ },
807
+ panel: { capability: Capability.Container },
808
+ title: { capability: Capability.Container },
809
+ description: {
810
+ capability: Capability.Container,
811
+ optional: true
812
+ },
813
+ closeButton: {
814
+ capability: Capability.Interactive,
815
+ events: [Event.Click],
816
+ optional: true
817
+ }
818
+ });
819
+ const Popover = A11y.pattern({
820
+ button: {
821
+ capability: Capability.Interactive,
822
+ events: [Event.Click],
823
+ attributes: [Attr.AriaExpanded]
824
+ },
825
+ panel: { capability: Capability.Container }
826
+ });
827
+ const Tooltip = A11y.pattern({
828
+ trigger: {
829
+ capability: Capability.Interactive,
830
+ events: [Event.Focus, Event.Blur]
831
+ },
832
+ panel: {
833
+ capability: Capability.Container,
834
+ attributes: [Attr.Role]
835
+ }
836
+ });
837
+ const Slider = A11y.pattern({
838
+ root: { capability: Capability.Container },
839
+ track: {
840
+ capability: Capability.Container,
841
+ events: [Event.PointerDown]
842
+ },
843
+ thumb: {
844
+ capability: Capability.Focusable,
845
+ attributes: [Attr.Role]
846
+ },
847
+ label: { capability: Capability.Container }
848
+ });
849
+ const Tabs$1 = A11y.pattern({
850
+ tablist: {
851
+ capability: Capability.Container,
852
+ attributes: [Attr.Role]
853
+ },
854
+ tab: {
855
+ capability: Capability.Interactive,
856
+ events: [Event.Click],
857
+ attributes: [Attr.Role, Attr.AriaSelected]
858
+ },
859
+ panel: {
860
+ capability: Capability.Container,
861
+ attributes: [Attr.Role]
862
+ }
863
+ });
864
+ const RadioGroup = A11y.pattern({
865
+ group: {
866
+ capability: Capability.Container,
867
+ attributes: [Attr.Role]
868
+ },
869
+ option: {
870
+ capability: Capability.Interactive,
871
+ events: [Event.Click],
872
+ attributes: [Attr.Role]
873
+ },
874
+ label: { capability: Capability.Container }
875
+ });
876
+ const Calendar = A11y.pattern({
877
+ root: { capability: Capability.Container },
878
+ grid: {
879
+ capability: Capability.Container,
880
+ attributes: [Attr.Role]
881
+ },
882
+ previousMonthButton: {
883
+ capability: Capability.Interactive,
884
+ events: [Event.Click]
885
+ },
886
+ nextMonthButton: {
887
+ capability: Capability.Interactive,
888
+ events: [Event.Click]
889
+ }
890
+ });
891
+ const entry = (name, pattern, slots, tier, roles, floor = []) => Object.freeze({
892
+ name,
893
+ pattern,
894
+ slots,
895
+ tier,
896
+ roles,
897
+ floor
898
+ });
899
+ /** Every adapted widget, for the gate, DevTools, and agents. */
900
+ const catalog = Object.freeze([
901
+ entry("button", Button$1, ButtonSlots, "stateless", ["button"], ["native-control"]),
902
+ entry("input", Input$1, InputSlots, "stateless", ["textbox"], ["native-control", "form-submission"]),
903
+ entry("textarea", Textarea$1, TextareaSlots, "stateless", ["textbox"], ["native-control", "form-submission"]),
904
+ entry("select", Select, SelectSlots, "stateless", ["combobox"], ["native-control", "form-submission"]),
905
+ entry("checkbox", Checkbox$1, CheckboxSlots, "stateless", ["checkbox"], ["form-submission"]),
906
+ entry("switch", Switch$1, SwitchSlots, "stateless", ["switch"], ["form-submission"]),
907
+ entry("fieldset", Fieldset, FieldsetSlots, "stateless", ["group"], ["native-control"]),
908
+ entry("disclosure", Disclosure, DisclosureSlots, "stateless", ["button"]),
909
+ entry("dialog", Dialog$1, DialogSlots, "stateful", ["dialog", "button"], [
910
+ "focus-trap",
911
+ "escape-dismiss",
912
+ "inert-outside",
913
+ "top-layer",
914
+ "backdrop"
915
+ ]),
916
+ entry("popover", Popover, PopoverSlots, "stateful", ["dialog", "button"], ["top-layer", "escape-dismiss"]),
917
+ entry("tooltip", Tooltip, TooltipSlots, "stateful", ["tooltip"]),
918
+ entry("slider", Slider, SliderSlots, "stateful", ["slider"], ["form-submission"]),
919
+ entry("tabs", Tabs$1, TabsSlots, "stateful", [
920
+ "tablist",
921
+ "tab",
922
+ "tabpanel"
923
+ ]),
924
+ entry("radioGroup", RadioGroup, RadioGroupSlots, "stateful", ["radiogroup", "radio"], ["form-submission"]),
925
+ entry("calendar", Calendar, CalendarSlots, "stateful", [
926
+ "grid",
927
+ "gridcell",
928
+ "button"
929
+ ])
930
+ ]);
931
+ //#endregion
932
+ //#region src/recipes/design.ts
933
+ /**
934
+ * What every recipe shares: typed token references, the layer each piece is
935
+ * emitted in, and the focus and disabled treatments. The recipes assume a page
936
+ * that ships `Theme.root` of `Theme.tokens` and a `Theme.oklch` palette from
937
+ * `foldkit-mixins/theme`; a token name either lacks is a type error here.
938
+ */
939
+ /**
940
+ * `var(--fk-group-name)` for every token the shipped scales and palette
941
+ * define. The palette is built only for its names: `Theme.ref` never reads a
942
+ * value, so the accent here is irrelevant and the page's own palette applies.
943
+ */
944
+ const ref = Theme.ref(Theme.compose(Theme.tokens, Theme.oklch({ accent: {
945
+ h: 0,
946
+ c: 0,
947
+ l: "50%"
948
+ } })));
949
+ /** The base of a recipe, in the `components` layer. */
950
+ const component = (...pieces) => Layers.standard.in("components", Style.compose(...pieces));
951
+ /** A variant or compound, in the `variants` layer, so it beats the base. */
952
+ const variant = (...pieces) => Layers.standard.in("variants", Style.compose(...pieces));
953
+ /** A hover rule that skips a disabled element. */
954
+ const hover = (declarations) => Style.pseudo(":hover:not([aria-disabled=\"true\"], :disabled)", declarations);
955
+ const focusRing = Style.pseudo(":focus-visible", {
956
+ outline: `${ref.border.thick} solid ${ref.outline.focus}`,
957
+ outlineOffset: "2px"
958
+ });
959
+ const disabled = Style.pseudo(":is([aria-disabled=\"true\"], :disabled)", {
960
+ opacity: "0.5",
961
+ cursor: "not-allowed"
962
+ });
963
+ const transition = (properties) => ({
964
+ transitionProperty: properties,
965
+ transitionDuration: ref.motion.fast,
966
+ transitionTimingFunction: ref.motion.ease
967
+ });
968
+ const tone = (value) => variant(Style.self({
969
+ "--_fk-tone-fill": value.fill,
970
+ "--_fk-tone-fill-hover": value.fillHover,
971
+ "--_fk-tone-on-fill": value.onFill,
972
+ "--_fk-tone-ink": value.ink,
973
+ "--_fk-tone-wash": value.wash
974
+ }));
975
+ const toneVar = (name) => `var(--_fk-tone-${name})`;
976
+ const tones = {
977
+ accent: tone({
978
+ fill: ref.accent.default,
979
+ fillHover: ref.accent.hover,
980
+ onFill: ref.accent.text,
981
+ ink: ref.text.link,
982
+ wash: ref.accent.subtle
983
+ }),
984
+ neutral: tone({
985
+ fill: ref.surface.default,
986
+ fillHover: ref.surface.overt,
987
+ onFill: ref.text.overt,
988
+ ink: ref.text.default,
989
+ wash: ref.surface.muted
990
+ }),
991
+ danger: tone({
992
+ fill: ref.error.default,
993
+ fillHover: ref.error.outline,
994
+ onFill: ref.error.text,
995
+ ink: ref.error.outline,
996
+ wash: ref.error.subtle
997
+ })
998
+ };
999
+ //#endregion
1000
+ //#region src/recipes/button.ts
1001
+ /**
1002
+ * A button: `tone` picks the colors, `variant` how they are applied, `size`
1003
+ * the density. Tone and variant are independent because a tone only sets the
1004
+ * private custom properties the variants read.
1005
+ */
1006
+ const size$2 = (block, inline, font) => variant(Style.self({
1007
+ paddingBlock: block,
1008
+ paddingInline: inline,
1009
+ fontSize: font
1010
+ }));
1011
+ const Button = Style.recipeFor(ButtonSlots)({
1012
+ base: { button: component(Style.self({
1013
+ display: "inline-flex",
1014
+ alignItems: "center",
1015
+ justifyContent: "center",
1016
+ gap: ref.space.xs,
1017
+ border: `${ref.border.thin} solid transparent`,
1018
+ borderRadius: ref.radius.md,
1019
+ font: "inherit",
1020
+ fontWeight: ref.weight.medium,
1021
+ lineHeight: ref.leading.tight,
1022
+ cursor: "pointer",
1023
+ ...transition("background-color, border-color, color")
1024
+ }), focusRing, disabled) },
1025
+ variants: {
1026
+ tone: {
1027
+ accent: { button: tones.accent },
1028
+ neutral: { button: tones.neutral },
1029
+ danger: { button: tones.danger }
1030
+ },
1031
+ variant: {
1032
+ solid: { button: variant(Style.self({
1033
+ background: toneVar("fill"),
1034
+ color: toneVar("on-fill")
1035
+ }), hover({ background: toneVar("fill-hover") })) },
1036
+ outline: { button: variant(Style.self({
1037
+ background: "transparent",
1038
+ color: toneVar("ink"),
1039
+ borderColor: toneVar("fill")
1040
+ }), hover({ background: toneVar("wash") })) },
1041
+ ghost: { button: variant(Style.self({
1042
+ background: "transparent",
1043
+ color: toneVar("ink")
1044
+ }), hover({ background: toneVar("wash") })) }
1045
+ },
1046
+ size: {
1047
+ sm: { button: size$2(ref.space["2xs"], ref.space.sm, ref.size.sm) },
1048
+ md: { button: size$2(ref.space.xs, ref.space.md, ref.size.md) },
1049
+ lg: { button: size$2(ref.space.sm, ref.space.lg, ref.size.lg) }
1050
+ }
1051
+ },
1052
+ defaults: {
1053
+ tone: "accent",
1054
+ variant: "solid",
1055
+ size: "md"
1056
+ },
1057
+ compound: [{
1058
+ when: {
1059
+ tone: "danger",
1060
+ variant: "solid"
1061
+ },
1062
+ style: { button: variant(Style.pseudo(":focus-visible", { outlineColor: ref.error.outline })) }
1063
+ }, {
1064
+ when: {
1065
+ variant: "ghost",
1066
+ size: "sm"
1067
+ },
1068
+ style: { button: variant(Style.self({ paddingInline: ref.space["2xs"] })) }
1069
+ }]
1070
+ });
1071
+ //#endregion
1072
+ //#region src/recipes/dialog.ts
1073
+ /**
1074
+ * A modal dialog: the backdrop dims the page and the panel is a raised
1075
+ * surface. `size` is the panel's maximum width.
1076
+ */
1077
+ const width = (max) => variant(Style.self({ maxInlineSize: `min(${max}, 100% - 2rem)` }));
1078
+ const Dialog = Style.recipeFor(DialogSlots)({
1079
+ base: {
1080
+ dialog: component(Style.self({
1081
+ padding: "0",
1082
+ border: "0",
1083
+ background: "transparent",
1084
+ color: ref.text.default,
1085
+ maxInlineSize: "100%",
1086
+ maxBlockSize: "100%"
1087
+ }), Style.pseudo("::backdrop", { background: "transparent" })),
1088
+ backdrop: component(Style.self({
1089
+ position: "fixed",
1090
+ inset: "0",
1091
+ background: `color-mix(in oklch, ${ref.surface.bedrock} 45%, transparent)`
1092
+ })),
1093
+ panel: component(Style.self({
1094
+ position: "relative",
1095
+ display: "grid",
1096
+ gap: ref.space.sm,
1097
+ inlineSize: "100%",
1098
+ marginInline: "auto",
1099
+ padding: ref.space.lg,
1100
+ border: `${ref.border.thin} solid ${ref.outline.subtle}`,
1101
+ borderRadius: ref.radius.lg,
1102
+ background: ref.surface.base,
1103
+ boxShadow: `0 1rem 3rem color-mix(in oklch, ${ref.surface.bedrock} 25%, transparent)`
1104
+ })),
1105
+ title: component(Style.self({
1106
+ margin: "0",
1107
+ color: ref.text.overt,
1108
+ fontFamily: ref.font.heading,
1109
+ fontSize: ref.size.xl,
1110
+ fontWeight: ref.weight.semibold,
1111
+ lineHeight: ref.leading.tight
1112
+ })),
1113
+ description: component(Style.self({
1114
+ margin: "0",
1115
+ color: ref.text.muted
1116
+ })),
1117
+ closeButton: component(Style.self({
1118
+ position: "absolute",
1119
+ insetBlockStart: ref.space.sm,
1120
+ insetInlineEnd: ref.space.sm,
1121
+ padding: ref.space["2xs"],
1122
+ border: "0",
1123
+ borderRadius: ref.radius.sm,
1124
+ background: "transparent",
1125
+ color: ref.text.muted,
1126
+ cursor: "pointer"
1127
+ }), hover({
1128
+ background: ref.surface.muted,
1129
+ color: ref.text.overt
1130
+ }), focusRing)
1131
+ },
1132
+ variants: { size: {
1133
+ sm: { panel: width("24rem") },
1134
+ md: { panel: width("32rem") },
1135
+ lg: { panel: width("48rem") }
1136
+ } },
1137
+ defaults: { size: "md" }
1138
+ });
1139
+ //#endregion
1140
+ //#region src/recipes/field.ts
1141
+ /**
1142
+ * Text fields: `Input` and `Textarea` publish the same regions under
1143
+ * different control names, so both recipes are built from these pieces.
1144
+ */
1145
+ const control = component(Style.self({
1146
+ display: "block",
1147
+ inlineSize: "100%",
1148
+ border: `${ref.border.thin} solid ${ref.outline.default}`,
1149
+ borderRadius: ref.radius.md,
1150
+ background: ref.surface.base,
1151
+ color: ref.text.default,
1152
+ font: "inherit",
1153
+ lineHeight: ref.leading.normal,
1154
+ ...transition("border-color, background-color")
1155
+ }), Style.pseudo(":hover:not(:focus, :disabled)", { borderColor: ref.outline.overt }), Style.pseudo("::placeholder", { color: ref.text.muted }), Style.pseudo("[aria-invalid=\"true\"]", { borderColor: ref.error.outline }), focusRing, disabled);
1156
+ const label$1 = component(Style.self({
1157
+ display: "block",
1158
+ marginBlockEnd: ref.space["2xs"],
1159
+ color: ref.text.overt,
1160
+ fontSize: ref.size.sm,
1161
+ fontWeight: ref.weight.medium
1162
+ }));
1163
+ const description$1 = component(Style.self({
1164
+ marginBlockStart: ref.space["2xs"],
1165
+ color: ref.text.muted,
1166
+ fontSize: ref.size.sm
1167
+ }));
1168
+ const size$1 = (block, inline, font) => variant(Style.self({
1169
+ paddingBlock: block,
1170
+ paddingInline: inline,
1171
+ fontSize: font
1172
+ }));
1173
+ const sizes$1 = {
1174
+ sm: size$1(ref.space["2xs"], ref.space.xs, ref.size.sm),
1175
+ md: size$1(ref.space.xs, ref.space.sm, ref.size.md),
1176
+ lg: size$1(ref.space.sm, ref.space.md, ref.size.lg)
1177
+ };
1178
+ const filled = variant(Style.self({
1179
+ background: ref.surface.subtle,
1180
+ borderColor: "transparent"
1181
+ }));
1182
+ const outlined = variant(Style.self({ background: ref.surface.base }));
1183
+ const Input = Style.recipeFor(InputSlots)({
1184
+ base: {
1185
+ input: control,
1186
+ label: label$1,
1187
+ description: description$1
1188
+ },
1189
+ variants: {
1190
+ size: {
1191
+ sm: { input: sizes$1.sm },
1192
+ md: { input: sizes$1.md },
1193
+ lg: { input: sizes$1.lg }
1194
+ },
1195
+ variant: {
1196
+ outline: { input: outlined },
1197
+ filled: { input: filled }
1198
+ }
1199
+ },
1200
+ defaults: {
1201
+ size: "md",
1202
+ variant: "outline"
1203
+ }
1204
+ });
1205
+ const Textarea = Style.recipeFor(TextareaSlots)({
1206
+ base: {
1207
+ textarea: Style.compose(control, component(Style.self({ resize: "vertical" }))),
1208
+ label: label$1,
1209
+ description: description$1
1210
+ },
1211
+ variants: {
1212
+ size: {
1213
+ sm: { textarea: sizes$1.sm },
1214
+ md: { textarea: sizes$1.md },
1215
+ lg: { textarea: sizes$1.lg }
1216
+ },
1217
+ variant: {
1218
+ outline: { textarea: outlined },
1219
+ filled: { textarea: filled }
1220
+ }
1221
+ },
1222
+ defaults: {
1223
+ size: "md",
1224
+ variant: "outline"
1225
+ }
1226
+ });
1227
+ //#endregion
1228
+ //#region src/recipes/tabs.ts
1229
+ /**
1230
+ * Tabs: the selected tab is `aria-selected`, which `@foldkit/ui` writes.
1231
+ * `variant` is an underline under a rule or a pill in a tray; `size` the
1232
+ * density of each tab.
1233
+ */
1234
+ const selected = "[aria-selected=\"true\"]";
1235
+ const size = (block, inline, font) => variant(Style.self({
1236
+ paddingBlock: block,
1237
+ paddingInline: inline,
1238
+ fontSize: font
1239
+ }));
1240
+ const Tabs = Style.recipeFor(TabsSlots)({
1241
+ base: {
1242
+ tablist: component(Style.self({
1243
+ display: "flex",
1244
+ gap: ref.space["2xs"]
1245
+ })),
1246
+ tab: component(Style.self({
1247
+ border: "0",
1248
+ background: "transparent",
1249
+ color: ref.text.muted,
1250
+ font: "inherit",
1251
+ fontWeight: ref.weight.medium,
1252
+ cursor: "pointer",
1253
+ ...transition("background-color, color, box-shadow")
1254
+ }), hover({ color: ref.text.overt }), Style.pseudo(selected, { color: ref.text.overt }), focusRing, disabled),
1255
+ panel: component(Style.self({ paddingBlock: ref.space.md }))
1256
+ },
1257
+ variants: {
1258
+ variant: {
1259
+ line: {
1260
+ tablist: variant(Style.self({ boxShadow: `inset 0 calc(-1 * ${ref.border.thin}) 0 ${ref.outline.default}` })),
1261
+ tab: variant(Style.pseudo(selected, { boxShadow: `inset 0 calc(-1 * ${ref.border.thick}) 0 ${ref.accent.default}` }))
1262
+ },
1263
+ pill: {
1264
+ tablist: variant(Style.self({
1265
+ inlineSize: "fit-content",
1266
+ padding: ref.space["3xs"],
1267
+ borderRadius: ref.radius.lg,
1268
+ background: ref.surface.muted
1269
+ })),
1270
+ tab: variant(Style.self({ borderRadius: ref.radius.md }), Style.pseudo(selected, { background: ref.surface.base }))
1271
+ }
1272
+ },
1273
+ size: {
1274
+ sm: { tab: size(ref.space["2xs"], ref.space.sm, ref.size.sm) },
1275
+ md: { tab: size(ref.space.xs, ref.space.md, ref.size.md) }
1276
+ }
1277
+ },
1278
+ defaults: {
1279
+ variant: "line",
1280
+ size: "md"
1281
+ }
1282
+ });
1283
+ //#endregion
1284
+ //#region src/recipes/toggle.ts
1285
+ /**
1286
+ * Checkbox and Switch: controls whose state is `aria-checked`, which
1287
+ * `@foldkit/ui` writes, so the checked look needs no input condition. `tone`
1288
+ * is the checked fill; `size` the control's box. The check mark and the
1289
+ * switch thumb are pseudo-elements, so the view renders an empty control.
1290
+ */
1291
+ const checked = "[aria-checked=\"true\"]";
1292
+ const label = component(Style.self({
1293
+ color: ref.text.default,
1294
+ fontSize: ref.size.md,
1295
+ cursor: "pointer"
1296
+ }));
1297
+ const description = component(Style.self({
1298
+ color: ref.text.muted,
1299
+ fontSize: ref.size.sm
1300
+ }));
1301
+ /** The control's edge length; the check mark and the thumb scale from it. */
1302
+ const box = (length) => variant(Style.self({ "--_fk-toggle-size": length }));
1303
+ const sizes = {
1304
+ sm: box("0.875rem"),
1305
+ md: box("1rem"),
1306
+ lg: box("1.25rem")
1307
+ };
1308
+ const edge = "var(--_fk-toggle-size)";
1309
+ const Checkbox = Style.recipeFor(CheckboxSlots)({
1310
+ base: {
1311
+ checkbox: component(Style.self({
1312
+ position: "relative",
1313
+ display: "inline-block",
1314
+ flexShrink: "0",
1315
+ inlineSize: edge,
1316
+ blockSize: edge,
1317
+ padding: "0",
1318
+ border: `${ref.border.thin} solid ${ref.outline.overt}`,
1319
+ borderRadius: ref.radius.sm,
1320
+ background: ref.surface.base,
1321
+ cursor: "pointer",
1322
+ ...transition("background-color, border-color")
1323
+ }), Style.pseudo(`:is(${checked}, [aria-checked="mixed"])`, {
1324
+ background: toneVar("fill"),
1325
+ borderColor: toneVar("fill")
1326
+ }), Style.pseudo(`${checked}::after`, {
1327
+ content: "\"\"",
1328
+ position: "absolute",
1329
+ insetBlockStart: "12%",
1330
+ insetInlineStart: "32%",
1331
+ inlineSize: "32%",
1332
+ blockSize: "56%",
1333
+ border: `solid ${toneVar("on-fill")}`,
1334
+ borderWidth: "0 2px 2px 0",
1335
+ rotate: "45deg"
1336
+ }), Style.pseudo("[aria-checked=\"mixed\"]::after", {
1337
+ content: "\"\"",
1338
+ position: "absolute",
1339
+ inset: "45% 20%",
1340
+ background: toneVar("on-fill")
1341
+ }), focusRing, disabled),
1342
+ label,
1343
+ description
1344
+ },
1345
+ variants: {
1346
+ tone: {
1347
+ accent: { checkbox: tones.accent },
1348
+ neutral: { checkbox: tones.neutral }
1349
+ },
1350
+ size: {
1351
+ sm: { checkbox: sizes.sm },
1352
+ md: { checkbox: sizes.md },
1353
+ lg: { checkbox: sizes.lg }
1354
+ }
1355
+ },
1356
+ defaults: {
1357
+ tone: "accent",
1358
+ size: "md"
1359
+ }
1360
+ });
1361
+ const Switch = Style.recipeFor(SwitchSlots)({
1362
+ base: {
1363
+ button: component(Style.self({
1364
+ position: "relative",
1365
+ display: "inline-block",
1366
+ flexShrink: "0",
1367
+ inlineSize: `calc(${edge} * 1.8)`,
1368
+ blockSize: edge,
1369
+ padding: "0",
1370
+ border: "0",
1371
+ borderRadius: ref.radius.full,
1372
+ background: ref.outline.overt,
1373
+ cursor: "pointer",
1374
+ ...transition("background-color")
1375
+ }), Style.pseudo("::before", {
1376
+ content: "\"\"",
1377
+ position: "absolute",
1378
+ insetBlockStart: "2px",
1379
+ insetInlineStart: "2px",
1380
+ inlineSize: `calc(${edge} - 4px)`,
1381
+ blockSize: `calc(${edge} - 4px)`,
1382
+ borderRadius: ref.radius.full,
1383
+ background: ref.surface.base,
1384
+ transitionProperty: "translate",
1385
+ transitionDuration: ref.motion.fast,
1386
+ transitionTimingFunction: ref.motion.ease
1387
+ }), Style.pseudo(checked, { background: toneVar("fill") }), Style.pseudo(`${checked}::before`, { translate: `calc(${edge} * 0.8) 0` }), focusRing, disabled),
1388
+ label,
1389
+ description
1390
+ },
1391
+ variants: {
1392
+ tone: {
1393
+ accent: { button: tones.accent },
1394
+ neutral: { button: tones.neutral }
1395
+ },
1396
+ size: {
1397
+ sm: { button: sizes.sm },
1398
+ md: { button: sizes.md },
1399
+ lg: { button: sizes.lg }
1400
+ }
1401
+ },
1402
+ defaults: {
1403
+ tone: "accent",
1404
+ size: "md"
1405
+ }
1406
+ });
1407
+ //#endregion
1408
+ //#region src/recipes/index.ts
1409
+ var recipes_exports = /* @__PURE__ */ __exportAll({
1410
+ Button: () => Button,
1411
+ Checkbox: () => Checkbox,
1412
+ Dialog: () => Dialog,
1413
+ Input: () => Input,
1414
+ Switch: () => Switch,
1415
+ Tabs: () => Tabs,
1416
+ Textarea: () => Textarea
1417
+ });
1418
+ //#endregion
1419
+ export { anchor_exports as Anchor, button_exports as Button, ButtonSlots, calendar_exports as Calendar, CalendarSlots, checkbox_exports as Checkbox, CheckboxSlots, dialog_exports as Dialog, DialogSlots, disclosure_exports as Disclosure, DisclosureSlots, fieldset_exports as Fieldset, FieldsetSlots, hoverIntent_exports as HoverIntent, HoverIntentSlots, input_exports as Input, InputSlots, patterns_exports as Patterns, popover_exports as Popover, PopoverSlots, radioGroup_exports as RadioGroup, RadioGroupSlots, recipes_exports as Recipes, select_exports as Select, SelectSlots, slider_exports as Slider, SliderSlots, switch_exports as Switch, SwitchSlots, tabs_exports as Tabs, TabsSlots, textarea_exports as Textarea, TextareaSlots, tooltip_exports as Tooltip, TooltipSlots, resolveFor as resolve };
622
1420
 
623
1421
  //# sourceMappingURL=index.mjs.map