@fragiola/primitives 0.0.0-stage → 0.0.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.
Files changed (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/dist/async-list-Bv6ff5Oj.js +81 -0
  4. package/dist/async-list-Bv6ff5Oj.js.map +1 -0
  5. package/dist/async-list.d.ts +2 -0
  6. package/dist/async-list.js +1 -0
  7. package/dist/calendar-keys-DGYpjLwv.d.ts +12 -0
  8. package/dist/calendar-system-B5U5HcPQ.d.ts +415 -0
  9. package/dist/calendar-systems-Daa6Q_ca.js +659 -0
  10. package/dist/calendar-systems-Daa6Q_ca.js.map +1 -0
  11. package/dist/calendar-systems.d.ts +3 -0
  12. package/dist/calendar-systems.js +1 -0
  13. package/dist/carousel-LRbWqbAx.js +375 -0
  14. package/dist/carousel-LRbWqbAx.js.map +1 -0
  15. package/dist/carousel.d.ts +2 -0
  16. package/dist/carousel.js +1 -0
  17. package/dist/cascade-B155Xvvv.js +64 -0
  18. package/dist/cascade-B155Xvvv.js.map +1 -0
  19. package/dist/cascade.d.ts +2 -0
  20. package/dist/cascade.js +1 -0
  21. package/dist/clipboard-Cy2cbGEW.js +33 -0
  22. package/dist/clipboard-Cy2cbGEW.js.map +1 -0
  23. package/dist/clipboard.d.ts +2 -0
  24. package/dist/clipboard.js +1 -0
  25. package/dist/collection-Dbk-PB5S.js +609 -0
  26. package/dist/collection-Dbk-PB5S.js.map +1 -0
  27. package/dist/collection.d.ts +2 -0
  28. package/dist/collection.js +3 -0
  29. package/dist/color-sURV5Irg.js +699 -0
  30. package/dist/color-sURV5Irg.js.map +1 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +1 -0
  33. package/dist/command-DueCXi65.js +104 -0
  34. package/dist/command-DueCXi65.js.map +1 -0
  35. package/dist/command.d.ts +2 -0
  36. package/dist/command.js +1 -0
  37. package/dist/date-CrbFSJKQ.js +215 -0
  38. package/dist/date-CrbFSJKQ.js.map +1 -0
  39. package/dist/date.d.ts +4 -0
  40. package/dist/date.js +1 -0
  41. package/dist/direction-CTnVLpmd.d.ts +8 -0
  42. package/dist/direction-DJDPvnxJ.js +13 -0
  43. package/dist/direction-DJDPvnxJ.js.map +1 -0
  44. package/dist/direction.d.ts +2 -0
  45. package/dist/direction.js +1 -0
  46. package/dist/drag-session-CSr06B5v.js +41 -0
  47. package/dist/drag-session-CSr06B5v.js.map +1 -0
  48. package/dist/file-DSLtfzbi.js +263 -0
  49. package/dist/file-DSLtfzbi.js.map +1 -0
  50. package/dist/file.d.ts +2 -0
  51. package/dist/file.js +1 -0
  52. package/dist/focus-BI-VvM0f.js +75 -0
  53. package/dist/focus-BI-VvM0f.js.map +1 -0
  54. package/dist/focus.d.ts +2 -0
  55. package/dist/focus.js +3 -0
  56. package/dist/form-DovwKtqz.js +501 -0
  57. package/dist/form-DovwKtqz.js.map +1 -0
  58. package/dist/form.d.ts +2 -0
  59. package/dist/form.js +1 -0
  60. package/dist/hover-BakyPYnC.js +62 -0
  61. package/dist/hover-BakyPYnC.js.map +1 -0
  62. package/dist/hover.d.ts +2 -0
  63. package/dist/hover.js +1 -0
  64. package/dist/id-B0Y8iZrc.js +13 -0
  65. package/dist/id-B0Y8iZrc.js.map +1 -0
  66. package/dist/id.d.ts +2 -0
  67. package/dist/id.js +1 -0
  68. package/dist/image-D4X_yRYw.js +44 -0
  69. package/dist/image-D4X_yRYw.js.map +1 -0
  70. package/dist/image.d.ts +2 -0
  71. package/dist/image.js +1 -0
  72. package/dist/index-B0rwIZw9.d.ts +51 -0
  73. package/dist/index-B4wF1isn.d.ts +128 -0
  74. package/dist/index-BHiBRE01.d.ts +20 -0
  75. package/dist/index-BNlMm-0u.d.ts +17 -0
  76. package/dist/index-BapNrjY9.d.ts +48 -0
  77. package/dist/index-Bd-tVb7C.d.ts +6 -0
  78. package/dist/index-BjE8nDiX.d.ts +125 -0
  79. package/dist/index-BpbT-FsX.d.ts +117 -0
  80. package/dist/index-CBgGcTeX.d.ts +37 -0
  81. package/dist/index-CGThV_Md.d.ts +100 -0
  82. package/dist/index-CMig3TXL.d.ts +28 -0
  83. package/dist/index-CWFRduRd.d.ts +212 -0
  84. package/dist/index-CkrHWyU_.d.ts +33 -0
  85. package/dist/index-Cwu6f7y1.d.ts +18 -0
  86. package/dist/index-D10LDdR6.d.ts +139 -0
  87. package/dist/index-D146vm21.d.ts +104 -0
  88. package/dist/index-DGKhEvNr.d.ts +107 -0
  89. package/dist/index-DbAu4s16.d.ts +48 -0
  90. package/dist/index-DdaCj6IO.d.ts +54 -0
  91. package/dist/index-DeHcNdjC.d.ts +68 -0
  92. package/dist/index-DeR4ncrW.d.ts +93 -0
  93. package/dist/index-HIksgK0e.d.ts +70 -0
  94. package/dist/index-IZB0mlZl.d.ts +71 -0
  95. package/dist/index-IfDZj87U.d.ts +28 -0
  96. package/dist/index-SrTuVBms.d.ts +75 -0
  97. package/dist/index-T9UcYvkf.d.ts +339 -0
  98. package/dist/index-fRTojAoR.d.ts +31 -0
  99. package/dist/index-fuLUke9n.d.ts +6 -0
  100. package/dist/index-l63esAck.d.ts +104 -0
  101. package/dist/index-raSUg9U7.d.ts +38 -0
  102. package/dist/index-twgzPKvZ.d.ts +278 -0
  103. package/dist/index-wBpjRykh.d.ts +125 -0
  104. package/dist/index.d.ts +39 -0
  105. package/dist/index.js +42 -0
  106. package/dist/inert-DlGToy3q.js +80 -0
  107. package/dist/inert-DlGToy3q.js.map +1 -0
  108. package/dist/inert.d.ts +2 -0
  109. package/dist/inert.js +1 -0
  110. package/dist/layer-stack-BEtzaFC1.js +118 -0
  111. package/dist/layer-stack-BEtzaFC1.js.map +1 -0
  112. package/dist/layers-C-N4rrZX.js +24 -0
  113. package/dist/layers-C-N4rrZX.js.map +1 -0
  114. package/dist/layers.d.ts +2 -0
  115. package/dist/layers.js +3 -0
  116. package/dist/list-navigation-CbWv4DK5.js +40 -0
  117. package/dist/list-navigation-CbWv4DK5.js.map +1 -0
  118. package/dist/month-year-BG5imFUq.js +108 -0
  119. package/dist/month-year-BG5imFUq.js.map +1 -0
  120. package/dist/month-year.d.ts +3 -0
  121. package/dist/month-year.js +1 -0
  122. package/dist/number-BFUio97d.js +316 -0
  123. package/dist/number-BFUio97d.js.map +1 -0
  124. package/dist/number.d.ts +2 -0
  125. package/dist/number.js +1 -0
  126. package/dist/overlay-BwPyiM3T.js +78 -0
  127. package/dist/overlay-BwPyiM3T.js.map +1 -0
  128. package/dist/overlay.d.ts +2 -0
  129. package/dist/overlay.js +1 -0
  130. package/dist/pagination-BkVzaIGP.js +51 -0
  131. package/dist/pagination-BkVzaIGP.js.map +1 -0
  132. package/dist/pagination.d.ts +2 -0
  133. package/dist/pagination.js +1 -0
  134. package/dist/plain-date-idQH1P6X.d.ts +29 -0
  135. package/dist/plain-date-time-B8PGahhe.d.ts +99 -0
  136. package/dist/pointer-CuDtD9XA.js +189 -0
  137. package/dist/pointer-CuDtD9XA.js.map +1 -0
  138. package/dist/pointer.d.ts +2 -0
  139. package/dist/pointer.js +3 -0
  140. package/dist/positioning-DDUQ75mB.js +148 -0
  141. package/dist/positioning-DDUQ75mB.js.map +1 -0
  142. package/dist/positioning.d.ts +2 -0
  143. package/dist/positioning.js +1 -0
  144. package/dist/presence-BhKDOmII.js +86 -0
  145. package/dist/presence-BhKDOmII.js.map +1 -0
  146. package/dist/presence.d.ts +2 -0
  147. package/dist/presence.js +1 -0
  148. package/dist/range-o0_GBhyY.js +158 -0
  149. package/dist/range-o0_GBhyY.js.map +1 -0
  150. package/dist/range.d.ts +2 -0
  151. package/dist/range.js +1 -0
  152. package/dist/scroll-area-BYNhv36t.js +447 -0
  153. package/dist/scroll-area-BYNhv36t.js.map +1 -0
  154. package/dist/scroll-area.d.ts +2 -0
  155. package/dist/scroll-area.js +1 -0
  156. package/dist/scroll-lock-JzRNOA1O.js +42 -0
  157. package/dist/scroll-lock-JzRNOA1O.js.map +1 -0
  158. package/dist/scroll-lock.d.ts +2 -0
  159. package/dist/scroll-lock.js +1 -0
  160. package/dist/segments-eRu5G_Bd.js +587 -0
  161. package/dist/segments-eRu5G_Bd.js.map +1 -0
  162. package/dist/segments.d.ts +3 -0
  163. package/dist/segments.js +1 -0
  164. package/dist/selection-Cor67w_V.js +287 -0
  165. package/dist/selection-Cor67w_V.js.map +1 -0
  166. package/dist/selection.d.ts +2 -0
  167. package/dist/selection.js +1 -0
  168. package/dist/swipe.d.ts +2 -0
  169. package/dist/swipe.js +1 -0
  170. package/dist/tabbable-BPiLssIv.js +35 -0
  171. package/dist/tabbable-BPiLssIv.js.map +1 -0
  172. package/dist/time-Ct6oq9kt.js +208 -0
  173. package/dist/time-Ct6oq9kt.js.map +1 -0
  174. package/dist/time-zone-DegkzwST.js +305 -0
  175. package/dist/time-zone-DegkzwST.js.map +1 -0
  176. package/dist/time-zone.d.ts +2 -0
  177. package/dist/time-zone.js +1 -0
  178. package/dist/time.d.ts +2 -0
  179. package/dist/time.js +1 -0
  180. package/dist/toast-BjRpJalM.js +400 -0
  181. package/dist/toast-BjRpJalM.js.map +1 -0
  182. package/dist/toast.d.ts +2 -0
  183. package/dist/toast.js +1 -0
  184. package/dist/unit-grid-DJy8lb5D.d.ts +21 -0
  185. package/dist/virtual-BlX1RuHD.js +306 -0
  186. package/dist/virtual-BlX1RuHD.js.map +1 -0
  187. package/dist/virtual.d.ts +2 -0
  188. package/dist/virtual.js +1 -0
  189. package/dist/watch-swipe-BIucfr9O.js +301 -0
  190. package/dist/watch-swipe-BIucfr9O.js.map +1 -0
  191. package/package.json +234 -3
@@ -0,0 +1,139 @@
1
+ /** One option of a list collection (spec/listbox.md, "The collections mechanism"). */
2
+ interface ListNode {
3
+ /** The option's key: its value. */
4
+ key: string;
5
+ /** The text typeahead matches. */
6
+ textValue: string;
7
+ /** Takes focus, never the selection. */
8
+ disabled?: boolean;
9
+ }
10
+ /**
11
+ * The options of a list in order, with their indexes (spec/listbox.md): what the selection rules
12
+ * and the key map read. Built from what a framework registered, in document order.
13
+ */
14
+ interface ListModel {
15
+ readonly nodes: readonly ListNode[];
16
+ readonly size: number;
17
+ /** The index of `key`, or -1. */
18
+ indexOf(key: string | null): number;
19
+ /** Whether `key` names a disabled option (an unknown key is not disabled). */
20
+ isDisabled(key: string): boolean;
21
+ /** The keys of the enabled options, in order. */
22
+ readonly enabledKeys: readonly string[];
23
+ /** The labels, in order (the typeahead's input). */
24
+ readonly labels: readonly string[];
25
+ }
26
+ /** The list model of `nodes`, in their order; a repeated key keeps its first place. */
27
+ declare function createListModel(nodes: readonly ListNode[]): ListModel;
28
+ /** How many options a list selects (spec/listbox.md, "API"). */
29
+ type SelectionMode = "none" | "single" | "multiple";
30
+ /**
31
+ * The APG's two multiple selection models (spec/listbox.md, "Keyboard"): `toggle`, the
32
+ * recommended one (a move never selects, Space toggles); `replace`, the alternative one (the
33
+ * selection follows the focus, Ctrl moves without selecting).
34
+ */
35
+ type SelectionBehavior = "toggle" | "replace";
36
+ /** A list's selection: the selected keys, in the model's order, and the range anchor. */
37
+ interface SelectionState {
38
+ selected: readonly string[];
39
+ /** The option the last toggle or replace selected: where a range starts. */
40
+ anchor: string | null;
41
+ }
42
+ /**
43
+ * A change of the selection: `toggle` one option, `replace` the selection with one option, select
44
+ * the `range` from the anchor (or `from`) to `key`, or select `all` (none, when every enabled
45
+ * option already is).
46
+ */
47
+ type SelectionChange = {
48
+ type: "toggle";
49
+ key: string;
50
+ } | {
51
+ type: "replace";
52
+ key: string;
53
+ } | {
54
+ type: "range";
55
+ key: string;
56
+ from?: string;
57
+ } | {
58
+ type: "all";
59
+ };
60
+ interface SelectionOptions {
61
+ mode: SelectionMode;
62
+ behavior: SelectionBehavior;
63
+ }
64
+ /** `keys` in the model's order; keys the model does not know stay at the end, in their order. */
65
+ declare function inModelOrder(model: ListModel, keys: Iterable<string>): string[];
66
+ /**
67
+ * The selection after `change` (spec/listbox.md, "Keyboard" and "Pointer"), or `state` itself
68
+ * when nothing changes. A disabled option is never selected: a change aimed at one does nothing,
69
+ * a range and `all` pass over them (a disabled option already selected, by a controlled value,
70
+ * stays). `single`: every change but `all` selects its option alone (the selected one stays
71
+ * selected). `multiple`: `toggle` flips an option and makes it the anchor; `replace` makes it the
72
+ * only one and the anchor; a `range` adds to the selection with `toggle`, replaces it with
73
+ * `replace`, and moves the anchor only when it starts `from` a given key; `all` selects every
74
+ * enabled option, or unselects them when they all are. `none`: nothing changes.
75
+ */
76
+ declare function applySelection(model: ListModel, state: SelectionState, change: SelectionChange, options: SelectionOptions): SelectionState;
77
+ /** Whether two selections hold the same keys in the same order. */
78
+ declare function sameSelection(a: readonly string[], b: readonly string[]): boolean;
79
+ /** The keys of a listbox's key event that matter (a `KeyboardEvent`, or a framework's). */
80
+ interface ListKeyEvent {
81
+ key: string;
82
+ shiftKey: boolean;
83
+ ctrlKey: boolean;
84
+ metaKey: boolean;
85
+ altKey: boolean;
86
+ }
87
+ interface ListKeyOptions {
88
+ orientation: "horizontal" | "vertical";
89
+ rtl: boolean;
90
+ /** Wrap from the last option to the first, and back (`loopFocus`). */
91
+ loop: boolean;
92
+ mode: SelectionMode;
93
+ behavior: SelectionBehavior;
94
+ /** The option a page away from `index` (PageDown `1`, PageUp `-1`); default: the last / first. */
95
+ page?: (index: number, delta: 1 | -1) => number;
96
+ /** The option the typeahead moves to for a printable character, or -1. */
97
+ typeahead?: (character: string, index: number) => number;
98
+ }
99
+ /** What a key does: the option it focuses (`index`, maybe the focused one) and its selection change. */
100
+ interface ListKeyResult {
101
+ index: number;
102
+ selection: SelectionChange | null;
103
+ }
104
+ /**
105
+ * What a key does in a listbox (spec/listbox.md, "Keyboard"), from the focused option `index`:
106
+ * `null` for a key it does not handle (Tab, Alt, the other orientation's arrows, a character no
107
+ * option starts with). A focus move (the arrows, Home, End, PageUp, PageDown, the typeahead)
108
+ * selects the option it lands on in the `replace` model, unless Ctrl (or Meta) is held; Shift with
109
+ * an arrow toggles the option it lands on (multiple); Space and Enter select (single), toggle
110
+ * (`toggle`) or replace (`replace`), Ctrl + Space toggles, Shift + Space selects the range from the
111
+ * anchor; Ctrl + Shift + Home / End the range from the focused option to the end, which it focuses;
112
+ * Ctrl + A selects all (multiple). Disabled options take focus; `applySelection` keeps them out.
113
+ */
114
+ declare function listKeyTarget(event: ListKeyEvent, model: ListModel, index: number, options: ListKeyOptions): ListKeyResult | null;
115
+ /** What a press on an option does (spec/listbox.md, "Pointer"), with its modifiers. */
116
+ declare function listPressSelection(key: string, event: {
117
+ shiftKey: boolean;
118
+ ctrlKey: boolean;
119
+ metaKey: boolean;
120
+ }, options: {
121
+ mode: SelectionMode;
122
+ behavior: SelectionBehavior;
123
+ }): SelectionChange | null;
124
+ /**
125
+ * The option a page away from `current` (spec/listbox.md, "Keyboard": PageDown `1`, PageUp
126
+ * `-1`): the farthest option whose far edge is within the scroll container's visible size from
127
+ * the current option's near edge, along the orientation; the last (first) option when the list
128
+ * does not scroll. Measured on the elements (their bounding boxes), so it follows any layout.
129
+ */
130
+ declare function pageTarget(elements: readonly HTMLElement[], current: number, delta: 1 | -1, container: HTMLElement, orientation?: "horizontal" | "vertical"): number;
131
+ /**
132
+ * The option in the row above (`delta` -1) or below (`delta` 1) the option at `index`, in a list
133
+ * laid out in wrapping rows (spec/color-swatch-picker.md, "Keyboard"): measured on the rendered
134
+ * boxes, the nearest row on that side, and in it the option whose horizontal center is the closest
135
+ * to the current one's (the first of two as close). `index` itself when there is no row on that
136
+ * side (the arrows stop at the first and last rows), or -1 when `index` names no option.
137
+ */
138
+ declare function rowTarget(elements: readonly Element[], index: number, delta: 1 | -1): number;
139
+ export { ListNode as _, ListKeyResult as a, SelectionBehavior as c, SelectionOptions as d, SelectionState as f, ListModel as g, sameSelection as h, ListKeyOptions as i, SelectionChange as l, inModelOrder as m, pageTarget as n, listKeyTarget as o, applySelection as p, ListKeyEvent as r, listPressSelection as s, rowTarget as t, SelectionMode as u, createListModel as v };
@@ -0,0 +1,104 @@
1
+ import { t as Direction } from "./direction-CTnVLpmd.js";
2
+ interface CarouselPagesOptions {
3
+ /** The number of slides. */
4
+ slideCount: number;
5
+ /** The slides a page shows side by side (default `1`). */
6
+ slidesPerPage?: number | undefined;
7
+ /** The slides a page moves by (default `slidesPerPage`). */
8
+ slidesPerMove?: number | undefined;
9
+ }
10
+ /**
11
+ * The first slide of every page, in order (spec/carousel.md, "The pages"): slide 0, then every
12
+ * `slidesPerMove` slides while a page still shows `slidesPerPage` slides, and the last page at
13
+ * `slideCount - slidesPerPage`, so every page is full (a snapped scroll ends there). Pure math;
14
+ * always at least one page.
15
+ */
16
+ declare function carouselPages({ slideCount, slidesPerPage, slidesPerMove }: CarouselPagesOptions): number[];
17
+ /** `page` kept within the pages (`0` to `pageCount - 1`); a fraction is rounded down. */
18
+ declare function clampCarouselPage(page: number, pageCount: number): number;
19
+ /** The slides a page shows: `slidesPerPage` slides from its first, within the slides. */
20
+ declare function slidesInView(pages: readonly number[], page: number, slideCount: number, slidesPerPage: number | undefined): number[];
21
+ /**
22
+ * The page a move from `page` reaches (`1` next, `-1` previous), or `null` at an edge; with `loop`
23
+ * the edges wrap.
24
+ */
25
+ declare function stepCarouselPage(page: number, pageCount: number, step: 1 | -1, loop: boolean): number | null;
26
+ type CarouselOrientation = "horizontal" | "vertical";
27
+ /**
28
+ * Where `group` must be scrolled for `slide` to sit at its start (spec/carousel.md, "Pointer"):
29
+ * the `scrollLeft` (or `scrollTop`) that aligns the slide's inline-start edge (its top) with the
30
+ * group's, less the group's padding there. In RTL the start is the right edge and Chromium's
31
+ * `scrollLeft` runs from `0` to negative values, so the same subtraction holds.
32
+ */
33
+ declare function slideScrollPosition(group: HTMLElement, slide: HTMLElement, orientation: CarouselOrientation, direction?: Direction | null): number;
34
+ /** The group's scroll position on its axis. */
35
+ declare function groupScrollPosition(group: HTMLElement, orientation: CarouselOrientation): number;
36
+ /**
37
+ * The page whose first slide is nearest the group's scroll position (`pages` holds each page's
38
+ * first slide; `slide(index)` gives a slide's element): the page a scroll settled on.
39
+ */
40
+ declare function nearestCarouselPage(group: HTMLElement, pages: readonly number[], slide: (index: number) => HTMLElement | null, orientation: CarouselOrientation, direction?: Direction | null): number;
41
+ interface RotationTimer {
42
+ /** Starts the delay again from its whole length; `onElapse` runs once it passed. */
43
+ start: (delay: number, onElapse: () => void) => void;
44
+ /** Holds the running delay, keeping the time it has left. */
45
+ pause: () => void;
46
+ /** Runs a held delay on for the time it had left. */
47
+ resume: () => void;
48
+ /** Clears the delay. */
49
+ stop: () => void;
50
+ }
51
+ /**
52
+ * The delay of a carousel's rotation (spec/carousel.md, "The rotation"), on `element`'s window
53
+ * timers: it decides nothing, the framework starts it on every page while playing, and pauses it
54
+ * while a hover pauses the rotation, which resumes with the time it had left (Toast's pause rule).
55
+ */
56
+ declare function createRotationTimer(element: Element): RotationTimer;
57
+ interface CarouselWatchOptions {
58
+ orientation: () => CarouselOrientation;
59
+ /** The direction a DirectionProvider gives, `null` without one. */
60
+ direction: () => Direction | null;
61
+ /** Whether a mouse drag scrolls the slides. */
62
+ allowMouseDrag: () => boolean;
63
+ /** Each page's first slide, in order (`carouselPages`). */
64
+ pages: () => readonly number[];
65
+ /** The current page, which a drag moves from. */
66
+ page: () => number;
67
+ /** A slide's element, by its index. */
68
+ slide: (index: number) => HTMLElement | null;
69
+ /**
70
+ * The AutoplayTrigger: the pointer over it does not pause the rotation, and a pointer press
71
+ * focusing it does not stop it (the press toggles it).
72
+ */
73
+ hoverExempt?: (target: Element) => boolean;
74
+ /** The pointer started or stopped hovering the carousel (but an exempt element). */
75
+ onHoverChange: (hovered: boolean) => void;
76
+ /** Focus entered the carousel from outside it. */
77
+ onFocusIn: (event: FocusEvent) => void;
78
+ /** A mouse drag started or ended. */
79
+ onDraggingChange: (dragging: boolean) => void;
80
+ /**
81
+ * A scroll the user made settled on `page`: `swipe` for any native scroll (touch, a trackpad,
82
+ * the wheel), `drag` for a mouse drag. The group already scrolls to it.
83
+ */
84
+ onPageSettle: (page: number, reason: "swipe" | "drag", event: Event | undefined) => void;
85
+ }
86
+ interface CarouselController {
87
+ /**
88
+ * Whether the group needs a tab stop of its own: it holds no element Tab reaches (the
89
+ * out-of-view slides are `inert`), so a keyboard can still scroll it (ScrollArea's rule).
90
+ */
91
+ needsTabStop: () => boolean;
92
+ /** Scrolls the group to a page's first slide: smoothly, or at once (`instant`). */
93
+ scrollToPage: (page: number, instant?: boolean) => void;
94
+ destroy: () => void;
95
+ }
96
+ /**
97
+ * The DOM side of a carousel (spec/carousel.md): native listeners on its `root` and its slides'
98
+ * scroll container `group`, so a framework's own event system (Vue's invoker under a fixed test
99
+ * clock) never drops one. It scrolls the group to a page, reports the page a user's scroll settled
100
+ * on, runs the mouse drag (`/pointer`'s drag session, snapping off while it runs), and reports
101
+ * the hover and the focus entering. It holds no page and no playing state: the framework does.
102
+ */
103
+ declare function watchCarousel(root: HTMLElement, group: HTMLElement, options: CarouselWatchOptions): CarouselController;
104
+ export { createRotationTimer as a, nearestCarouselPage as c, carouselPages as d, clampCarouselPage as f, RotationTimer as i, slideScrollPosition as l, stepCarouselPage as m, CarouselWatchOptions as n, CarouselOrientation as o, slidesInView as p, watchCarousel as r, groupScrollPosition as s, CarouselController as t, CarouselPagesOptions as u };
@@ -0,0 +1,107 @@
1
+ import { D as SegmentType, S as SegmentFormat, b as EditableSegmentType, c as SegmentValues } from "./calendar-system-B5U5HcPQ.js";
2
+ /**
3
+ * The digits typed into the focused segment so far (ASCII), so the next digit continues them
4
+ * (`1` then `2` is month 12). A field keeps it while the segment stays focused, and drops it on
5
+ * blur, a step or a move.
6
+ */
7
+ interface SegmentEdit {
8
+ readonly type: EditableSegmentType;
9
+ readonly text: string;
10
+ }
11
+ interface SegmentTypeResult {
12
+ readonly values: SegmentValues;
13
+ /** What to keep for the next key; `null` once the segment is complete. */
14
+ readonly edit: SegmentEdit | null;
15
+ /** The segment is complete: focus moves on to the next one. */
16
+ readonly advance: boolean;
17
+ }
18
+ interface SegmentEraseResult {
19
+ readonly values: SegmentValues;
20
+ readonly edit: SegmentEdit | null;
21
+ /** The segment was already empty: focus moves back to the previous one. */
22
+ readonly retreat: boolean;
23
+ }
24
+ /** The digit a character is in the locale's numbering system or a shared one; `null` for none. */
25
+ declare function segmentDigit(format: SegmentFormat, character: string): number | null;
26
+ /**
27
+ * Types one character into a segment (spec/date-field.md, "Typing"). A digit continues the
28
+ * segment's typed digits, or starts again when the number would leave the range; the segment is
29
+ * set once the number is in range (`0` alone in a month waits for the next digit), and complete
30
+ * (`advance`) when no further digit could fit: `4` in a month, `12`, or a year's fourth digit. A
31
+ * day period takes a letter: the first letter of its AM or PM text. Anything else is refused
32
+ * (`null`).
33
+ */
34
+ declare function typeSegment(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, character: string, edit: SegmentEdit | null, seed?: SegmentValues): SegmentTypeResult | null;
35
+ /**
36
+ * Backspace (or Delete) in a segment: removes its last digit (a day period is cleared at once);
37
+ * a segment left with no digit is a placeholder. An empty segment reports `retreat`.
38
+ */
39
+ declare function eraseSegment(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, edit: SegmentEdit | null): SegmentEraseResult;
40
+ /** One segment as a field renders it (spec/date-field.md, "Segments"). */
41
+ interface DateSegment {
42
+ readonly type: SegmentType;
43
+ /** Its place in the format: a stable key among the field's segments. */
44
+ readonly index: number;
45
+ /**
46
+ * What it shows: its value as `Intl` writes it, the digits being typed, a placeholder (one
47
+ * `–` per digit), or a literal's text.
48
+ */
49
+ readonly text: string;
50
+ /** An editable segment (a `spinbutton`); literals and eras are not. */
51
+ readonly editable: boolean;
52
+ /** An editable segment with no value yet. */
53
+ readonly placeholder: boolean;
54
+ /** Its value in the unit it shows (`aria-valuenow`); `null` for a placeholder or a literal. */
55
+ readonly value: number | null;
56
+ readonly min: number | null;
57
+ readonly max: number | null;
58
+ /** `aria-valuetext`: its text, a month's name; `null` for a placeholder or a literal. */
59
+ readonly valueText: string | null;
60
+ /** Its name from `Intl.DisplayNames` ("month"), its default `aria-label`; `null` for none. */
61
+ readonly label: string | null;
62
+ }
63
+ /** The text of a placeholder: one en dash per digit, two for a day period (no language). */
64
+ declare const SEGMENT_PLACEHOLDER = "–";
65
+ /**
66
+ * The segments of a field (spec/date-field.md, "Segments"): its format's parts in order, each
67
+ * editable one with its text, value, range, value text and name, the literals with their text.
68
+ * `edit` shows the digits being typed into a segment that is not set yet (`0` of a month).
69
+ */
70
+ declare function dateSegments(format: SegmentFormat, values: SegmentValues, edit?: SegmentEdit | null): DateSegment[];
71
+ /** Where a key moves the focus among a field's segments (spec/date-field.md, "Keyboard"). */
72
+ type SegmentMove = "next" | "previous" | "left" | "right" | "first";
73
+ /**
74
+ * The segment a move reaches from `segment`: `next` and `previous` in the locale's order (the
75
+ * document's), `left` and `right` on screen, wherever the bidirectional text placed the segments
76
+ * (a he-IL date reads left to right in a right-to-left page), `first` the group's first.
77
+ * `null` when there is none that way. With no layout (every box empty), `right` is `next` and
78
+ * `left` is `previous`. `groups` makes several groups one sequence (a range field's start and end,
79
+ * spec/date-range-field.md "Typing and keys"); by default the moves stay in the segment's group.
80
+ */
81
+ declare function segmentTarget(segment: HTMLElement, move: SegmentMove, groups?: readonly Element[]): HTMLElement | null;
82
+ /**
83
+ * Focuses the first segment when its field's label is pressed (spec/date-field.md, "In a Field":
84
+ * a label names a group, which no `for` can point at). A press the consumer prevented does
85
+ * nothing. Returns the cleanup.
86
+ */
87
+ declare function focusOnLabelPress(label: HTMLElement, target: () => HTMLElement | null): () => void;
88
+ interface SegmentKeyResult {
89
+ /** `step` (the arrows, Page Up and Down, Home, End), `erase` (Backspace, Delete) or `move`. */
90
+ readonly kind: "step" | "erase" | "move";
91
+ readonly values: SegmentValues;
92
+ readonly edit: SegmentEdit | null;
93
+ /** Where the focus goes, if anywhere. */
94
+ readonly move: SegmentMove | null;
95
+ }
96
+ /**
97
+ * The effect of a key on a focused segment (spec/date-field.md, "Keyboard", the APG spinbutton):
98
+ * ArrowUp / ArrowDown step by one, Page Up / Page Down by the segment's page step, both wrapping
99
+ * within the segment; Home / End go to its minimum / maximum; ArrowLeft / ArrowRight move to the
100
+ * segment on that side; Backspace and Delete erase a digit, or move back from an empty segment.
101
+ * `null` for any other key. A read-only field only moves.
102
+ */
103
+ declare function segmentKeyDown(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, key: string, edit: SegmentEdit | null, options?: {
104
+ readonly seed?: SegmentValues;
105
+ readonly readOnly?: boolean;
106
+ }): SegmentKeyResult | null;
107
+ export { segmentTarget as a, dateSegments as c, SegmentTypeResult as d, eraseSegment as f, focusOnLabelPress as i, SegmentEdit as l, typeSegment as m, segmentKeyDown as n, DateSegment as o, segmentDigit as p, SegmentMove as r, SEGMENT_PLACEHOLDER as s, SegmentKeyResult as t, SegmentEraseResult as u };
@@ -0,0 +1,48 @@
1
+ /** A panel's content size in pixels (spec/collapsible.md, "Animation"). */
2
+ interface PanelSize {
3
+ height: number;
4
+ width: number;
5
+ }
6
+ /**
7
+ * The size of a panel's content: its `scrollHeight` and `scrollWidth`, which a panel held at
8
+ * `height: 0` by its starting style (with `overflow: hidden`) still reports. The panel must not be
9
+ * `hidden` (a `display: none` element measures 0).
10
+ */
11
+ declare function measurePanelSize(element: HTMLElement): PanelSize;
12
+ /**
13
+ * Writes a panel's size into its size variables (`--<prefix>-panel-height` and `-width`, in
14
+ * pixels) and applies the styles at once (a style flush), so a transition that starts next (the
15
+ * opening frame without `data-starting-style`, or `data-ending-style`) starts from a length,
16
+ * never from `auto` (spec/collapsible.md, "Animation"). Returns the size, for the framework's
17
+ * state to render the same values.
18
+ */
19
+ declare function freezePanelSize(element: HTMLElement, prefix: string): PanelSize;
20
+ /** The size variables' values (`auto` for no size): what a panel renders. */
21
+ declare function panelSizeVariables(prefix: string, size: PanelSize | null): Record<string, string>;
22
+ interface BeforeMatchOptions {
23
+ /** Called when the browser's find-in-page matched the panel's content (`beforematch`). */
24
+ onMatch: (event: Event) => void;
25
+ /** Whether the panel is open now: read after the match, to hide a panel the app kept closed. */
26
+ isOpen: () => boolean;
27
+ }
28
+ /**
29
+ * Opens a `hidden="until-found"` panel on a find-in-page match (spec/collapsible.md, "Find in
30
+ * page"): the browser fires `beforematch` and removes `hidden`; `onMatch` opens the component.
31
+ * When the component is still closed a task later (a controlled `open` the app kept `false`), the
32
+ * panel gets `hidden="until-found"` back. Returns the cleanup.
33
+ */
34
+ declare function watchBeforeMatch(element: HTMLElement, options: BeforeMatchOptions): () => void;
35
+ /** Runs `callback` on the next animation frame of the element's window. Returns the cancel. */
36
+ declare function nextFrame(element: Element, callback: () => void): () => void;
37
+ /**
38
+ * Resolves when every animation and transition running on the element has finished, or at once
39
+ * when there is none (spec/dialog.md, "Animation": unmount after the exit animation).
40
+ */
41
+ declare function waitForAnimations(element: Element): Promise<void>;
42
+ /**
43
+ * Whether an animation or a transition runs on the element now (reading them applies its pending
44
+ * styles): an exit with none ends at once, in the render that started it, never a painted frame
45
+ * later (spec/collapsible.md and tabs.md, "Animation").
46
+ */
47
+ declare function isAnimating(element: Element): boolean;
48
+ export { PanelSize as a, panelSizeVariables as c, BeforeMatchOptions as i, watchBeforeMatch as l, nextFrame as n, freezePanelSize as o, waitForAnimations as r, measurePanelSize as s, isAnimating as t };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Where an async list is: `loading` (the first page, or a new filter text), `loading-more` (the
3
+ * next page), `error` (the last load failed), `idle`.
4
+ */
5
+ type AsyncListStatus = "idle" | "loading" | "loading-more" | "error";
6
+ interface AsyncListState<Item> {
7
+ items: readonly Item[];
8
+ /** The text the items were asked for (sent to the loader). */
9
+ filterText: string;
10
+ status: AsyncListStatus;
11
+ /** What the last failed load threw (`undefined` unless `status` is `error`). */
12
+ error: unknown;
13
+ /** Whether the loader gave a cursor for a next page. */
14
+ hasMore: boolean;
15
+ }
16
+ /** What the loader is asked: its abort signal, the filter text and the next page's cursor. */
17
+ interface AsyncListRequest<Cursor> {
18
+ /** Aborted when a newer load replaces this one: a stale load's result is never used. */
19
+ signal: AbortSignal;
20
+ filterText: string;
21
+ /** `undefined` for the first page, else the cursor the previous page gave. */
22
+ cursor: Cursor | undefined;
23
+ }
24
+ /** A page of items, and the cursor of the next one (`null` or absent: no next page). */
25
+ interface AsyncListPage<Item, Cursor> {
26
+ items: readonly Item[];
27
+ cursor?: Cursor | null;
28
+ }
29
+ type AsyncListLoad<Item, Cursor> = (request: AsyncListRequest<Cursor>) => Promise<AsyncListPage<Item, Cursor>>;
30
+ interface AsyncListOptions<Item, Cursor> {
31
+ load: AsyncListLoad<Item, Cursor>;
32
+ /** The first filter text (default `""`). */
33
+ filterText?: string;
34
+ /** The state changed. */
35
+ onChange?: (state: AsyncListState<Item>) => void;
36
+ }
37
+ /**
38
+ * An async list (spec/README.md, "Async lists"): loads the first page, the next pages and the
39
+ * pages of a new filter text through the consumer's loader, aborting a stale load, and keeps the
40
+ * items, the status and the error. Framework-free; a framework wraps it in its own state.
41
+ */
42
+ interface AsyncList<Item> {
43
+ state(): AsyncListState<Item>;
44
+ /** Loads the first page again (aborting a load in flight). */
45
+ reload(): void;
46
+ /** Loads the next page, unless one is loading, the last load failed, or there is none. */
47
+ loadMore(): void;
48
+ /** Loads the first page for a new text (aborting a load in flight); the items stay until it arrives. */
49
+ setFilterText(text: string): void;
50
+ /** Aborts a load in flight (the list goes back to `idle`). */
51
+ abort(): void;
52
+ }
53
+ declare function createAsyncList<Item, Cursor = unknown>(options: AsyncListOptions<Item, Cursor>): AsyncList<Item>;
54
+ export { AsyncListRequest as a, createAsyncList as c, AsyncListPage as i, AsyncListLoad as n, AsyncListState as o, AsyncListOptions as r, AsyncListStatus as s, AsyncList as t };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Calls `onFocusOutside` when focus moves to an element outside every element of `elements()`
3
+ * (spec/popover.md: a non-modal overlay closes when focus leaves it). Returns the cleanup.
4
+ */
5
+ declare function watchFocusOutside(doc: Document, elements: () => readonly (Element | null | undefined)[], onFocusOutside: (event: FocusEvent) => void): () => void;
6
+ /**
7
+ * Calls `onEscape` on Escape before the document's overlay layers see the key, and consumes it
8
+ * (spec/tooltip.md: "Escape closes it and stops there"). It listens in the capture phase of the
9
+ * document's window, which runs before the layer stack's listener on the document; the key is
10
+ * then prevented and stopped, and the stack ignores a prevented key, so an enclosing dialog,
11
+ * popover or menu stays open. `when` limits it to some keys (a RangeCalendar takes only the
12
+ * Escape pressed inside its grid, spec/calendar.md); the others go on to the layers. Returns the
13
+ * cleanup.
14
+ */
15
+ declare function interceptEscape(doc: Document, onEscape: (event: KeyboardEvent) => void, options?: {
16
+ when?: (event: KeyboardEvent) => boolean;
17
+ }): () => void;
18
+ /**
19
+ * The tree of open overlays of a document (spec/README.md, "The nested overlay tree"). A layer's
20
+ * parent is decided when it is pushed: the newest open layer that contains one of its owner
21
+ * elements (the triggers it was opened from), else the newest that contains the focused element,
22
+ * else none. So a trigger inside a portaled popup makes its overlay a child of that popup's
23
+ * overlay, wherever the child's own portal sits in the DOM.
24
+ *
25
+ * - Escape closes the newest layer (with an `onEscape`) only;
26
+ * - an outside press keeps the deepest layer that contains the press (its elements, or its
27
+ * `ignore` list: a press on an overlay's own trigger toggles it itself) and its ancestors, and
28
+ * dismisses every other open layer, newest first; a press outside every layer dismisses all;
29
+ * - but while a `modal` layer is open (a dialog, which makes the page inert), a press outside the
30
+ * newest modal layer and its descendants lands in that layer's parent: the layers it was opened
31
+ * from stay open, the modal layer and the other layers above them are dismissed;
32
+ * - removing a layer re-parents its children to its parent, and tells each descendant still open
33
+ * that an ancestor closed (`onParentClose`), newest first.
34
+ */
35
+ type Elements = () => readonly (Element | null | undefined)[];
36
+ interface LayerOptions {
37
+ /** The elements that make up the layer (its popup, positioner). */
38
+ elements: Elements;
39
+ /** Elements a press on does not dismiss the layer (its trigger, which toggles it itself). */
40
+ ignore?: Elements;
41
+ /**
42
+ * Elements that cover the page under the layer (a dialog's backdrop and viewport): a press on
43
+ * one is outside this layer, but inside its parent.
44
+ */
45
+ backdrops?: Elements;
46
+ /** The elements the overlay was opened from (its triggers), which decide its parent. */
47
+ owner?: Elements;
48
+ /**
49
+ * A modal layer (a dialog: the page under it is inert, so a press outside it reaches no
50
+ * layer): while it is the newest modal layer open, a press outside it and its descendants
51
+ * counts as a press inside its parent, which keeps the layers it was opened from.
52
+ */
53
+ modal?: boolean;
54
+ onEscape?: (event: KeyboardEvent) => void;
55
+ onOutsidePress?: (event: PointerEvent) => void;
56
+ /** An ancestor layer was removed while this one is still open. */
57
+ onParentClose?: () => void;
58
+ }
59
+ interface Layer {
60
+ /** Whether the layer is the newest open layer of its document. */
61
+ isTop: () => boolean;
62
+ /** The elements of the layer's descendants (its child layers, recursively). */
63
+ elementsAbove: () => Element[];
64
+ remove: () => void;
65
+ }
66
+ /** Pushes a layer on its document's tree; `remove` takes it out (in any order). */
67
+ declare function pushLayer(doc: Document, options: LayerOptions): Layer;
68
+ export { watchFocusOutside as a, interceptEscape as i, LayerOptions as n, pushLayer as r, Layer as t };
@@ -0,0 +1,93 @@
1
+ import { t as Direction } from "./direction-CTnVLpmd.js";
2
+ type ScrollAreaOrientation = "vertical" | "horizontal";
3
+ /** How far from each edge, in pixels, the content must be scrolled before its edge is set. */
4
+ interface ScrollAreaThreshold {
5
+ xStart: number;
6
+ xEnd: number;
7
+ yStart: number;
8
+ yEnd: number;
9
+ }
10
+ /** A threshold for every edge, or per edge (a missing edge is `0`). */
11
+ type ScrollAreaThresholdInput = number | Partial<ScrollAreaThreshold>;
12
+ /** What a ScrollArea renders (spec/scroll-area.md, "State attributes and ARIA"). */
13
+ interface ScrollAreaState {
14
+ /** The first measurement ran (never on a server). */
15
+ measured: boolean;
16
+ hasOverflowX: boolean;
17
+ hasOverflowY: boolean;
18
+ overflowXStart: boolean;
19
+ overflowXEnd: boolean;
20
+ overflowYStart: boolean;
21
+ overflowYEnd: boolean;
22
+ /** The user scrolls the horizontal axis (until 500 ms after the last scroll). */
23
+ scrollingX: boolean;
24
+ scrollingY: boolean;
25
+ /** A mouse or pen is over the Root. */
26
+ hovering: boolean;
27
+ /** The Viewport needs a tab stop: it overflows and holds nothing focusable. */
28
+ focusable: boolean;
29
+ }
30
+ /** The parts the controller measures and listens to, registered as they mount. */
31
+ type ScrollAreaPart = "viewport" | "content" | "scrollbar-x" | "scrollbar-y" | "thumb-x" | "thumb-y";
32
+ interface ScrollAreaOptions {
33
+ /** The DirectionProvider's direction, read at each measurement (`null`: the Viewport's own). */
34
+ direction?: (() => Direction | null) | undefined;
35
+ /** The Root's `overflowEdgeThreshold`, read at each measurement. */
36
+ threshold?: (() => ScrollAreaThresholdInput | undefined) | undefined;
37
+ /** Every change of the state, with the whole new state. */
38
+ onStateChange: (state: ScrollAreaState) => void;
39
+ }
40
+ interface ScrollAreaController {
41
+ /** Registers a part's element (`null` when it unmounts), and measures. */
42
+ setPart: (part: ScrollAreaPart, element: HTMLElement | null) => void;
43
+ /** Measures again (the direction or the threshold changed). */
44
+ update: () => void;
45
+ /** Removes every listener, observer and timer, and ends a drag. */
46
+ destroy: () => void;
47
+ }
48
+ /** The state before any measurement: what a server renders. */
49
+ declare function initialScrollAreaState(): ScrollAreaState;
50
+ /** The threshold of every edge, each at least `0`. */
51
+ declare function normalizeScrollAreaThreshold(input: ScrollAreaThresholdInput | undefined): ScrollAreaThreshold;
52
+ /**
53
+ * A ScrollArea's DOM side (spec/scroll-area.md): it measures the Viewport and its Content (on
54
+ * mount, on scroll, on resize through a `ResizeObserver`), writes the measured CSS variables and
55
+ * each Thumb's transform, and runs the Scrollbars' pointer (thumb drag, track press, wheel) and
56
+ * the Root's hover, all with native listeners. It reports the state the framework renders; it
57
+ * holds no value and renders nothing.
58
+ */
59
+ declare function createScrollArea(root: HTMLElement, options: ScrollAreaOptions): ScrollAreaController;
60
+ /** The smallest thumb, in pixels (spec/scroll-area.md, "Measurement"; Base UI's). */
61
+ declare const MIN_THUMB_SIZE = 16;
62
+ /**
63
+ * A scroll position as a distance from the start of its range, clamped to `[0, max]`, and moved
64
+ * onto an edge when it is within 1 px of it (subpixel scrolling ends a pixel short).
65
+ */
66
+ declare function scrollFromStart(position: number, max: number): number;
67
+ interface ThumbGeometryInput {
68
+ /** The viewport's size along the axis (`clientHeight`, `clientWidth`). */
69
+ clientSize: number;
70
+ /** The content's size along the axis (`scrollHeight`, `scrollWidth`). */
71
+ scrollSize: number;
72
+ /** The scroll's distance from the start of its range (`scrollFromStart`). */
73
+ fromStart: number;
74
+ /** The track's room: its size less its padding and the thumb's margins. */
75
+ room: number;
76
+ }
77
+ interface ThumbGeometry {
78
+ /** The thumb's size along the axis, in pixels. */
79
+ size: number;
80
+ /** Its offset from the start of the track's room, in pixels. */
81
+ offset: number;
82
+ }
83
+ /**
84
+ * A thumb's size (the room times the visible fraction, at least `MIN_THUMB_SIZE`) and offset (the
85
+ * scroll's fraction of its range times the room the thumb leaves).
86
+ */
87
+ declare function thumbGeometry({ clientSize, scrollSize, fromStart, room }: ThumbGeometryInput): ThumbGeometry;
88
+ /**
89
+ * The scroll distance from the start that a thumb offset stands for (a drag's or a track
90
+ * press's), clamped to the range.
91
+ */
92
+ declare function scrollForThumbOffset(offset: number, free: number, max: number): number;
93
+ export { scrollFromStart as a, ScrollAreaOptions as c, ScrollAreaState as d, ScrollAreaThreshold as f, normalizeScrollAreaThreshold as g, initialScrollAreaState as h, scrollForThumbOffset as i, ScrollAreaOrientation as l, createScrollArea as m, ThumbGeometry as n, thumbGeometry as o, ScrollAreaThresholdInput as p, ThumbGeometryInput as r, ScrollAreaController as s, MIN_THUMB_SIZE as t, ScrollAreaPart as u };