viewkitjs 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.
Files changed (231) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/package.json +2 -4
  3. package/views/dist/contract.d.ts +6 -289
  4. package/views/dist/contract.js +1 -96
  5. package/views/dist/controls/atoms.d.ts +8 -0
  6. package/views/dist/controls/atoms.js +8 -0
  7. package/views/dist/controls/button/tokens.d.ts +351 -0
  8. package/views/dist/controls/button/tokens.js +90 -0
  9. package/views/dist/controls/checkbox/checkbox.d.ts +28 -0
  10. package/views/dist/controls/checkbox/checkbox.js +15 -0
  11. package/views/dist/controls/checkbox/looks.d.ts +3 -0
  12. package/views/dist/controls/checkbox/looks.js +8 -0
  13. package/views/dist/controls/checkbox/map-checkbox.d.ts +2 -0
  14. package/views/dist/controls/checkbox/map-checkbox.js +5 -0
  15. package/views/dist/controls/checkbox/tokens.d.ts +131 -0
  16. package/views/dist/controls/checkbox/tokens.js +35 -0
  17. package/views/dist/controls/checkbox.css +133 -0
  18. package/views/dist/controls/controls.d.ts +12 -3
  19. package/views/dist/controls/controls.js +13 -1
  20. package/views/dist/controls/field/field.d.ts +94 -0
  21. package/views/dist/controls/field/field.js +46 -0
  22. package/views/dist/controls/field/looks.d.ts +13 -0
  23. package/views/dist/controls/field/looks.js +22 -0
  24. package/views/dist/controls/field/tokens.d.ts +75 -0
  25. package/views/dist/controls/field/tokens.js +21 -0
  26. package/views/dist/controls/field.css +98 -0
  27. package/views/dist/controls/glass-button/glass-button.d.ts +40 -0
  28. package/views/dist/controls/glass-button/glass-button.js +16 -0
  29. package/views/dist/controls/glass-button/looks.d.ts +4 -0
  30. package/views/dist/controls/glass-button/looks.js +4 -0
  31. package/views/dist/controls/glass-button/tokens.d.ts +127 -0
  32. package/views/dist/controls/glass-button/tokens.js +34 -0
  33. package/views/dist/controls/glass-button.css +111 -0
  34. package/views/dist/controls/grip/grip.d.ts +14 -0
  35. package/views/dist/controls/grip/grip.js +9 -0
  36. package/views/dist/controls/index.d.ts +32 -0
  37. package/views/dist/controls/index.js +31 -0
  38. package/views/dist/controls/inline-input/inline-input.d.ts +14 -0
  39. package/views/dist/controls/inline-input/inline-input.js +10 -0
  40. package/views/dist/controls/inline-input/looks.d.ts +3 -0
  41. package/views/dist/controls/inline-input/looks.js +16 -0
  42. package/views/dist/controls/inline-input/tokens.d.ts +79 -0
  43. package/views/dist/controls/inline-input/tokens.js +22 -0
  44. package/views/dist/controls/inline-input.css +78 -0
  45. package/views/dist/controls/input/autofill.d.ts +25 -0
  46. package/views/dist/controls/input/autofill.js +17 -0
  47. package/views/dist/controls/input/input.d.ts +119 -0
  48. package/views/dist/controls/input/input.js +127 -0
  49. package/views/dist/controls/input/looks.d.ts +41 -0
  50. package/views/dist/controls/input/looks.js +48 -0
  51. package/views/dist/controls/input/map-input.d.ts +2 -0
  52. package/views/dist/controls/input/map-input.js +5 -0
  53. package/views/dist/controls/input/tokens.d.ts +171 -0
  54. package/views/dist/controls/input/tokens.js +45 -0
  55. package/views/dist/controls/input.css +381 -0
  56. package/views/dist/controls/internal/anchor.d.ts +16 -0
  57. package/views/dist/controls/internal/anchor.js +8 -0
  58. package/views/dist/controls/internal/close-reason.d.ts +5 -0
  59. package/views/dist/controls/internal/close-reason.js +2 -0
  60. package/views/dist/controls/internal/hold.d.ts +25 -0
  61. package/views/dist/controls/internal/hold.js +81 -0
  62. package/views/dist/controls/internal/icons.d.ts +8 -0
  63. package/views/dist/controls/internal/icons.js +65 -0
  64. package/views/dist/controls/internal/popup-host.d.ts +7 -0
  65. package/views/dist/controls/internal/popup-host.js +10 -0
  66. package/views/dist/controls/internal/read-token.d.ts +6 -0
  67. package/views/dist/controls/internal/read-token.js +11 -0
  68. package/views/dist/controls/internal/reorder.d.ts +44 -0
  69. package/views/dist/controls/internal/reorder.js +83 -0
  70. package/views/dist/controls/internal/scroll.d.ts +11 -0
  71. package/views/dist/controls/internal/scroll.js +14 -0
  72. package/views/dist/controls/kbd/kbd.d.ts +13 -0
  73. package/views/dist/controls/kbd/kbd.js +10 -0
  74. package/views/dist/controls/kbd/looks.d.ts +4 -0
  75. package/views/dist/controls/kbd/looks.js +4 -0
  76. package/views/dist/controls/kbd/tokens.d.ts +47 -0
  77. package/views/dist/controls/kbd/tokens.js +14 -0
  78. package/views/dist/controls/kbd.css +46 -0
  79. package/views/dist/controls/list/tokens.d.ts +139 -0
  80. package/views/dist/controls/list/tokens.js +37 -0
  81. package/views/dist/controls/list.css +188 -0
  82. package/views/dist/controls/menu-list/keys.d.ts +7 -0
  83. package/views/dist/controls/menu-list/keys.js +29 -0
  84. package/views/dist/controls/menu-list/looks.d.ts +4 -0
  85. package/views/dist/controls/menu-list/looks.js +20 -0
  86. package/views/dist/controls/menu-list/menu-list.d.ts +196 -0
  87. package/views/dist/controls/menu-list/menu-list.js +346 -0
  88. package/views/dist/controls/menu-list/tokens.d.ts +187 -0
  89. package/views/dist/controls/menu-list/tokens.js +49 -0
  90. package/views/dist/controls/menu-list.css +259 -0
  91. package/views/dist/controls/number-field/number-field.d.ts +48 -0
  92. package/views/dist/controls/number-field/number-field.js +34 -0
  93. package/views/dist/controls/number-field/tokens.d.ts +47 -0
  94. package/views/dist/controls/number-field/tokens.js +14 -0
  95. package/views/dist/controls/number-field.css +54 -0
  96. package/views/dist/controls/option/atom-tag.d.ts +6 -0
  97. package/views/dist/controls/option/atom-tag.js +6 -0
  98. package/views/dist/controls/option/looks.d.ts +7 -0
  99. package/views/dist/controls/option/looks.js +21 -0
  100. package/views/dist/controls/option/option.d.ts +35 -0
  101. package/views/dist/controls/option/option.js +32 -0
  102. package/views/dist/controls/option/tokens.d.ts +223 -0
  103. package/views/dist/controls/option/tokens.js +58 -0
  104. package/views/dist/controls/option.css +92 -0
  105. package/views/dist/controls/phone-header/header-bar.d.ts +18 -0
  106. package/views/dist/controls/phone-header/header-bar.js +9 -0
  107. package/views/dist/controls/phone-header/looks.d.ts +4 -0
  108. package/views/dist/controls/phone-header/looks.js +4 -0
  109. package/views/dist/controls/phone-header/soft-edge.d.ts +5 -0
  110. package/views/dist/controls/phone-header/soft-edge.js +3 -0
  111. package/views/dist/controls/phone-header/tokens.d.ts +59 -0
  112. package/views/dist/controls/phone-header/tokens.js +17 -0
  113. package/views/dist/controls/phone-header.css +51 -0
  114. package/views/dist/controls/popover/looks.d.ts +4 -0
  115. package/views/dist/controls/popover/looks.js +10 -0
  116. package/views/dist/controls/popover/map-popover.d.ts +3 -0
  117. package/views/dist/controls/popover/map-popover.js +5 -0
  118. package/views/dist/controls/popover/popover.d.ts +74 -0
  119. package/views/dist/controls/popover/popover.js +106 -0
  120. package/views/dist/controls/popover/tokens.d.ts +83 -0
  121. package/views/dist/controls/popover/tokens.js +23 -0
  122. package/views/dist/controls/popover.css +94 -0
  123. package/views/dist/controls/scrollbar/scrollbar.d.ts +10 -0
  124. package/views/dist/controls/scrollbar/scrollbar.js +143 -0
  125. package/views/dist/controls/scrollbar/tokens.d.ts +43 -0
  126. package/views/dist/controls/scrollbar/tokens.js +13 -0
  127. package/views/dist/controls/scrollbar.css +47 -0
  128. package/views/dist/controls/sheet/bottom-sheet.d.ts +98 -0
  129. package/views/dist/controls/sheet/bottom-sheet.js +375 -0
  130. package/views/dist/controls/sheet/forms.d.ts +38 -0
  131. package/views/dist/controls/sheet/forms.js +26 -0
  132. package/views/dist/controls/sheet/looks.d.ts +4 -0
  133. package/views/dist/controls/sheet/looks.js +10 -0
  134. package/views/dist/controls/sheet/map-sheet.d.ts +3 -0
  135. package/views/dist/controls/sheet/map-sheet.js +12 -0
  136. package/views/dist/controls/sheet/spring.d.ts +22 -0
  137. package/views/dist/controls/sheet/spring.js +48 -0
  138. package/views/dist/controls/sheet/tokens.d.ts +143 -0
  139. package/views/dist/controls/sheet/tokens.js +38 -0
  140. package/views/dist/controls/sheet.css +223 -0
  141. package/views/dist/controls/spinner/tokens.d.ts +55 -0
  142. package/views/dist/controls/spinner/tokens.js +16 -0
  143. package/views/dist/controls/status/atom-status-badge.d.ts +10 -0
  144. package/views/dist/controls/status/atom-status-badge.js +13 -0
  145. package/views/dist/controls/status/looks.d.ts +4 -0
  146. package/views/dist/controls/status/looks.js +22 -0
  147. package/views/dist/controls/status/marks.d.ts +26 -0
  148. package/views/dist/controls/status/marks.js +73 -0
  149. package/views/dist/controls/status/status.d.ts +43 -0
  150. package/views/dist/controls/status/status.js +26 -0
  151. package/views/dist/controls/status/tokens.d.ts +407 -0
  152. package/views/dist/controls/status/tokens.js +104 -0
  153. package/views/dist/controls/status.css +164 -0
  154. package/views/dist/controls/switch/looks.d.ts +4 -0
  155. package/views/dist/controls/switch/looks.js +19 -0
  156. package/views/dist/controls/switch/switch.d.ts +15 -0
  157. package/views/dist/controls/switch/switch.js +11 -0
  158. package/views/dist/controls/switch/tokens.d.ts +139 -0
  159. package/views/dist/controls/switch/tokens.js +37 -0
  160. package/views/dist/controls/switch.css +169 -0
  161. package/views/dist/controls/tag/atom-cell-more.d.ts +3 -0
  162. package/views/dist/controls/tag/atom-cell-more.js +5 -0
  163. package/views/dist/controls/tag/looks.d.ts +4 -0
  164. package/views/dist/controls/tag/looks.js +4 -0
  165. package/views/dist/controls/tag/tag.d.ts +25 -0
  166. package/views/dist/controls/tag/tag.js +19 -0
  167. package/views/dist/controls/tag/tokens.d.ts +63 -0
  168. package/views/dist/controls/tag/tokens.js +18 -0
  169. package/views/dist/controls/tag.css +81 -0
  170. package/views/dist/controls/toggle/looks.d.ts +3 -0
  171. package/views/dist/controls/toggle/looks.js +12 -0
  172. package/views/dist/controls/toggle/toggle.d.ts +47 -0
  173. package/views/dist/controls/toggle/toggle.js +23 -0
  174. package/views/dist/controls/toggle/tokens.d.ts +55 -0
  175. package/views/dist/controls/toggle/tokens.js +16 -0
  176. package/views/dist/controls/toggle.css +67 -0
  177. package/views/dist/controls/tokens.d.ts +16 -0
  178. package/views/dist/controls/tokens.js +49 -0
  179. package/views/dist/controls/tooltip/looks.d.ts +4 -0
  180. package/views/dist/controls/tooltip/looks.js +4 -0
  181. package/views/dist/controls/tooltip/map-tooltip.d.ts +3 -0
  182. package/views/dist/controls/tooltip/map-tooltip.js +5 -0
  183. package/views/dist/controls/tooltip/tokens.d.ts +75 -0
  184. package/views/dist/controls/tooltip/tokens.js +21 -0
  185. package/views/dist/controls/tooltip/tooltip.d.ts +54 -0
  186. package/views/dist/controls/tooltip/tooltip.js +78 -0
  187. package/views/dist/controls/tooltip.css +94 -0
  188. package/views/dist/grid/chrome/GridTable.js +21 -19
  189. package/views/dist/grid/chrome/grid-caret-keys.d.ts +7 -0
  190. package/views/dist/grid/chrome/grid-caret-keys.js +22 -0
  191. package/views/dist/grid/chrome/grid-row-window.js +3 -0
  192. package/views/dist/grid/chrome/useGridColumnLayout.d.ts +4 -1
  193. package/views/dist/grid/chrome/useGridColumnLayout.js +17 -2
  194. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +32 -0
  195. package/views/dist/grid/chrome/useGridFittedWidths.js +59 -0
  196. package/views/dist/grid/chrome/useGridKeyboard.js +3 -0
  197. package/views/dist/looks/index.d.ts +16 -0
  198. package/views/dist/looks/index.js +16 -0
  199. package/views/dist/looks/looks.d.ts +10 -9
  200. package/views/dist/looks/pieces.js +38 -2
  201. package/views/dist/model/column-schema.d.ts +3 -2
  202. package/views/dist/model/column-state.d.ts +11 -1
  203. package/views/dist/model/column-state.js +8 -2
  204. package/views/dist/styles.css +2362 -7
  205. package/views/dist/styles.unlayered.css +2362 -7
  206. package/views/docs/contract.md +5 -97
  207. package/views/docs/controls/button.md +93 -0
  208. package/views/docs/controls/checkbox.md +38 -0
  209. package/views/docs/controls/field.md +26 -0
  210. package/views/docs/controls/glass-button.md +37 -0
  211. package/views/docs/controls/inline-input.md +27 -0
  212. package/views/docs/controls/input.md +48 -0
  213. package/views/docs/controls/kbd.md +17 -0
  214. package/views/docs/controls/list.md +40 -0
  215. package/views/docs/controls/menu-list.md +52 -0
  216. package/views/docs/controls/number-field.md +17 -0
  217. package/views/docs/controls/option.md +61 -0
  218. package/views/docs/controls/phone-header.md +20 -0
  219. package/views/docs/controls/popover.md +26 -0
  220. package/views/docs/controls/scrollbar.md +16 -0
  221. package/views/docs/controls/sheet.md +41 -0
  222. package/views/docs/controls/spinner.md +19 -0
  223. package/views/docs/controls/status.md +107 -0
  224. package/views/docs/controls/switch.md +40 -0
  225. package/views/docs/controls/tag.md +21 -0
  226. package/views/docs/controls/toggle.md +19 -0
  227. package/views/docs/controls/tooltip.md +24 -0
  228. package/views/docs/getting-started.md +1 -1
  229. package/views/docs/reference/controls.md +213 -2
  230. package/views/docs/reference/looks.md +70 -3
  231. package/views/docs/reference/views.md +7 -2
@@ -0,0 +1,98 @@
1
+ import * as React from "react";
2
+ import { type CloseReason } from "../internal/close-reason.js";
3
+ import { type SheetForm, type SheetStop } from "./forms.js";
4
+ export type { SheetForm, SheetStop } from "./forms.js";
5
+ /** Closes every sheet open under this one and this one: a choice that finishes the job. A drag, the dim or Back close
6
+ * only the top one. */
7
+ export declare const useSheetCloseAll: () => (() => void) | null;
8
+ /** A close that is a button of its own: a head's Cancel. */
9
+ export declare const SheetClose: ({ children }: {
10
+ children: React.ReactElement;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ export interface SheetHeadProps {
13
+ /** What it is. */
14
+ title: string;
15
+ /** Where its title stands, which each sheet chooses: centred, or at the left. */
16
+ titleAt?: "center" | "left";
17
+ /** A second line under the title, quieter. */
18
+ description?: string;
19
+ /** The X. Left off, the sheet closes by a drag or the dim. */
20
+ close?: boolean;
21
+ /** Back: to the step before, or out of the sheet. In Glass it takes the X's place, and the sheet closes by a drag or the dim. */
22
+ onBack?: () => void;
23
+ /** Buttons left and right of the title, in place of Back and the close. Left, usually a SheetClose. */
24
+ left?: React.ReactNode;
25
+ right?: React.ReactNode;
26
+ /** What stands on its right: a ⋯, or two SheetButtons. */
27
+ children?: React.ReactNode;
28
+ }
29
+ /** A button in its head. Its head is an option on the frame around it, which only sheet.css reads, so both are drawn and it
30
+ * shows one: under Glass the Glass button, under Flat a quiet Button. Primary, for what confirms, is primary in both. It holds
31
+ * an icon, or a word (a head's Cancel): the Glass button with its word under Glass, a quiet Button with it under Flat. */
32
+ export declare function SheetButton({ className, kind, children, ...props }: {
33
+ "aria-label"?: string;
34
+ icon?: React.ReactNode;
35
+ children?: React.ReactNode;
36
+ onClick?: () => void;
37
+ className?: string;
38
+ kind?: "primary";
39
+ disabled?: boolean;
40
+ }): import("react/jsx-runtime").JSX.Element;
41
+ /** Its head, one of its kinds: the one header (HeaderBar), under its handle. Glass has on its left the X, or Back in its place, and on its right one action, or two, as the phone header's Two buttons says.
42
+ * Flat has Back on its left, if there is one, and its action and the X on its right. Or Decide, a button either side of its
43
+ * title. A sheet with no head is its handle alone. */
44
+ export declare function SheetHead({ title, titleAt, description, close, onBack, left, right, children }: SheetHeadProps): import("react/jsx-runtime").JSX.Element;
45
+ /** Its foot: stays at the foot of the screen at every stop, and leaves with the sheet. */
46
+ export declare const SheetFoot: ({ children }: {
47
+ children: React.ReactNode;
48
+ }) => import("react/jsx-runtime").JSX.Element;
49
+ /** What scrolls under the head. At a lower stop it doesn't: a drag raises the sheet, and a wheel or focus under the fold
50
+ * takes it to full. */
51
+ export declare const SheetBody: React.ForwardRefExoticComponent<{
52
+ onScroll?: () => void;
53
+ children: React.ReactNode;
54
+ } & React.RefAttributes<HTMLDivElement>>;
55
+ /** One step of a sheet, floating or full: a row opens the next in its place, with Back, and a floating sheet resizes to it. A step
56
+ * that replaces another starts at its top and takes the focus itself, so what was pressed leaving takes it nowhere; the first step
57
+ * does neither. It slides in without the body scrolling sideways (sheet.css). */
58
+ export declare function SheetStep({ step, back, children }: {
59
+ step: string;
60
+ back?: boolean;
61
+ children: React.ReactNode;
62
+ }): import("react/jsx-runtime").JSX.Element;
63
+ /** Why it closed: a drag, its dim, Escape, its X, a choice that finishes the job. */
64
+ export interface SheetChangeDetails {
65
+ reason: CloseReason;
66
+ }
67
+ export interface SheetProps {
68
+ open: boolean;
69
+ /** It opens or closes, and why: the second argument is there for whoever reads it, and nothing has to. */
70
+ onOpenChange: (open: boolean, details: SheetChangeDetails) => void;
71
+ /** Once it has finished coming or going. */
72
+ onOpenChangeComplete?: (open: boolean) => void;
73
+ /** Its name to screen readers. */
74
+ label: string;
75
+ /** How it looks. */
76
+ form?: SheetForm;
77
+ /** The stops it may rest at, lowest first. Left out, its form's. */
78
+ stops?: SheetStop[];
79
+ /** The stop it opens at. Left out, the lowest. */
80
+ openAt?: SheetStop;
81
+ /** The stop it is at, to move it from code, with onStopChange. */
82
+ stop?: SheetStop;
83
+ onStopChange?: (stop: SheetStop) => void;
84
+ /** What the measured stop rests under, inside what is poured in. */
85
+ mark?: string;
86
+ /** Where it is drawn: over the whole page, or inside an element that holds it as a window holds a page. */
87
+ container?: HTMLElement | null;
88
+ /** It stands in `container`, a screen on a page that shows it, as it would on a phone: what's round that screen stays
89
+ * live and free to scroll, and only a press inside it, on its dim, closes it. The container holds fixed positions
90
+ * itself (a transform). */
91
+ standing?: boolean;
92
+ /** Where focus goes once it shuts. Nothing found, or left out, focus goes back to what opened it. */
93
+ finalFocus?: () => HTMLElement | null;
94
+ /** Its head and its body. */
95
+ children: React.ReactNode;
96
+ }
97
+ /** What rises from the bottom of the phone, in a form, at stops. What it holds is poured in. */
98
+ export declare function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form, stops, openAt, stop, onStopChange, mark: marked, container, standing: stands, finalFocus, children }: SheetProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,375 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Drawer as Base } from "@base-ui/react/drawer";
4
+ import { cx } from "../../internal/cx.js";
5
+ import { Button } from "../button/button.js";
6
+ import { GlassButton } from "../glass-button/glass-button.js";
7
+ import { closeReasonOf } from "../internal/close-reason.js";
8
+ import { drawnAt, typesInto } from "../internal/scroll.js";
9
+ import { HeaderBar } from "../phone-header/header-bar.js";
10
+ import { Scrollbar } from "../scrollbar/scrollbar.js";
11
+ import { FORMS, markBottom, markStop, offsetOf, pointOf, pointsOf, stopAfterFocus, stopAfterWheel, stopOf } from "./forms.js";
12
+ import { settle, springOf } from "./spring.js";
13
+ const glyph = (paths) => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
14
+ const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"], X = ["M18 6l-12 12", "M6 6l12 12"];
15
+ const Body = React.createContext({});
16
+ const CloseAll = React.createContext(null);
17
+ const Standing = React.createContext(false);
18
+ export const useSheetCloseAll = () => React.useContext(CloseAll);
19
+ export const SheetClose = ({ children }) => _jsx(Base.Close, { render: children });
20
+ export function SheetButton({ className, kind, children, ...props }) {
21
+ return _jsxs(_Fragment, { children: [_jsx(GlassButton, { ...props, kind: kind, className: cx("o-sheet-glass", className), children: children }), _jsx(Button, { ...props, kind: kind ?? "quiet", shape: children == null ? "icon" : undefined, className: cx("o-sheet-plain", className), children: children })] });
22
+ }
23
+ export function SheetHead({ title, titleAt, description, close = true, onBack, left, right, children }) {
24
+ const sides = left != null || right != null;
25
+ return (_jsx("div", { className: "o-sheet-head", children: _jsx(HeaderBar, { className: "o-sheet-row", titleAt: titleAt, "data-sides": sides ? "" : undefined, left: sides ? left : onBack ? _jsx(SheetButton, { "aria-label": "Back", className: "o-sheet-back", icon: glyph(BACK), onClick: onBack }) : close && _jsx(Base.Close, { render: _jsx(GlassButton, { "aria-label": "Close", className: "o-sheet-glass", icon: glyph(X) }) }), title: _jsx(Base.Title, { className: "o-sheet-title", children: title }), description: description, descriptionRender: _jsx(Base.Description, {}), right: sides ? right : _jsxs(_Fragment, { children: [children, close && _jsx(Base.Close, { render: _jsx(Button, { kind: "quiet", shape: "icon", "aria-label": "Close", className: "o-sheet-plain", icon: glyph(X) }) })] }) }) }));
26
+ }
27
+ export const SheetFoot = ({ children }) => _jsx("div", { className: "o-sheet-foot", children: children });
28
+ export const SheetBody = React.forwardRef(function SheetBody({ onScroll, children }, ref) {
29
+ const { onBodyWheel, onBodyFocus } = React.useContext(Body);
30
+ return (_jsxs(_Fragment, { children: [_jsx(Base.Content, { ref: ref, className: "o-sheet-body", onScroll: onScroll, onWheel: onBodyWheel, onFocusCapture: onBodyFocus, children: _jsx("div", { className: "o-sheet-content", children: children }) }), _jsx(Scrollbar, {})] }));
31
+ });
32
+ export function SheetStep({ step, back, children }) {
33
+ const el = React.useRef(null), was = React.useRef(step);
34
+ React.useLayoutEffect(() => {
35
+ if (was.current === step)
36
+ return;
37
+ was.current = step;
38
+ const body = el.current?.closest(".o-sheet-body");
39
+ if (body)
40
+ body.scrollTop = 0;
41
+ el.current?.focus({ preventScroll: true });
42
+ }, [step]);
43
+ return _jsx("div", { ref: el, tabIndex: -1, className: "o-sheet-step", "data-back": back ? "" : undefined, children: children }, step);
44
+ }
45
+ const reduced = () => matchMedia("(prefers-reduced-motion: reduce)").matches;
46
+ const CONTROLS = "a, button, input, select, textarea, label, [role='button'], [role='tab'], [role='switch'], [role='checkbox'], [role='combobox'], [role='menuitem']";
47
+ const px = (el, name) => parseFloat(el.style.getPropertyValue(name)) || 0;
48
+ const clamp = (x) => Math.min(1, Math.max(0, x));
49
+ function useFinger(on) {
50
+ const samples = React.useRef([]);
51
+ React.useEffect(() => {
52
+ if (!on)
53
+ return;
54
+ const add = (y, t) => { const s = samples.current; s.push({ t, y }); while (s.length > 2 && t - s[0].t > 120)
55
+ s.shift(); };
56
+ const touch = (e) => { if (e.type === "touchstart")
57
+ samples.current = []; const p = e.touches[0]; if (p)
58
+ add(p.clientY, e.timeStamp); };
59
+ const pointer = (e) => { if (e.pointerType === "touch")
60
+ return; if (e.type === "pointerdown")
61
+ samples.current = []; if (e.buttons)
62
+ add(e.clientY, e.timeStamp); };
63
+ const opts = { capture: true, passive: true };
64
+ ["touchstart", "touchmove"].forEach((n) => window.addEventListener(n, touch, opts));
65
+ ["pointerdown", "pointermove"].forEach((n) => window.addEventListener(n, pointer, opts));
66
+ return () => {
67
+ ["touchstart", "touchmove"].forEach((n) => window.removeEventListener(n, touch, opts));
68
+ ["pointerdown", "pointermove"].forEach((n) => window.removeEventListener(n, pointer, opts));
69
+ };
70
+ }, [on]);
71
+ return React.useCallback((at) => {
72
+ const s = samples.current, last = s[s.length - 1];
73
+ if (!last || s.length < 2 || at - last.t > 80)
74
+ return 0;
75
+ const first = s.find((x) => last.t - x.t <= 80) ?? s[0], dt = last.t - first.t;
76
+ return dt > 0 ? (last.y - first.y) / dt : 0;
77
+ }, []);
78
+ }
79
+ const afterMotion = (els, then) => requestAnimationFrame(() => {
80
+ Promise.all(els.flatMap((el) => (el.isConnected ? el.getAnimations() : [])).map((a) => a.finished.catch(() => { }))).then(then);
81
+ });
82
+ function useSheetMotion({ on, open, form, standing, points, point, popup, viewport, backdrop }) {
83
+ const speed = useFinger(on && open);
84
+ const reach = React.useRef({ offsets: [0], closed: 0, width: 1, height: 1, gap: 0 });
85
+ const leaving = React.useRef(false);
86
+ React.useEffect(() => { if (open)
87
+ leaving.current = false; }, [open]);
88
+ const below = React.useRef(null), colours = React.useRef({ sheet: "", dim: "" });
89
+ const moved = React.useCallback(() => [popup, backdrop.current, below.current], [popup, backdrop]);
90
+ const where = React.useCallback(() => (popup ? px(popup, "--drawer-snap-point-offset") + px(popup, "--drawer-swipe-movement-y") + px(popup, "--sheet-catch") : 0), [popup]);
91
+ const measure = React.useCallback(() => {
92
+ if (!popup || !viewport)
93
+ return;
94
+ const offsets = points.map((p) => offsetOf(p, popup.offsetHeight, viewport.clientHeight)).sort((a, b) => a - b);
95
+ reach.current = { offsets: offsets.length ? offsets : [0], closed: viewport.clientHeight - popup.offsetTop, width: popup.offsetWidth || 1, height: popup.offsetHeight, gap: parseFloat(getComputedStyle(popup).scrollMarginLeft) || 0 };
96
+ }, [popup, viewport, points]);
97
+ const paint = React.useCallback((y) => {
98
+ const { offsets, closed, width, height, gap } = reach.current, top = offsets[0], lowest = offsets[offsets.length - 1];
99
+ const gone = clamp((y - lowest) / Math.max(1, closed - lowest));
100
+ [backdrop.current, below.current].forEach((el) => el?.style.setProperty("--sheet-gone", gone.toFixed(3)));
101
+ popup?.style.setProperty("--sheet-lift", `${Math.max(0, Math.min(y, lowest))}px`);
102
+ if (form !== "blend")
103
+ return;
104
+ const rise = 1 - clamp((y - top) / Math.max(1, (offsets[1] ?? closed) - top)), margin = gap * (1 - rise), scale = (width - 2 * margin) / width;
105
+ popup?.style.setProperty("--sheet-rise", rise.toFixed(3));
106
+ popup?.style.setProperty("--sheet-scale", scale.toFixed(4));
107
+ popup?.style.setProperty("--sheet-cut", `${(height - (height - Math.min(y, lowest) - margin) / scale).toFixed(1)}px`);
108
+ below.current?.style.setProperty("background-color", `color-mix(in srgb, ${colours.current.sheet} ${Math.round(rise * 100)}%, ${colours.current.dim})`);
109
+ }, [popup, backdrop, form]);
110
+ const release = React.useCallback((to, at) => {
111
+ if (!popup || leaving.current)
112
+ return;
113
+ leaving.current = to === "closed";
114
+ const target = to === "closed" ? reach.current.closed : to, y = where();
115
+ popup.style.removeProperty("--sheet-catch");
116
+ if (!reduced()) {
117
+ const css = getComputedStyle(popup), spring = springOf(css.getPropertyValue("--sheet-spring"));
118
+ const v = at === undefined || y < reach.current.offsets[0] ? 0 : speed(at);
119
+ const s = settle(target - y, v, spring, to === "closed" ? { exit: parseFloat(css.getPropertyValue("--sheet-exit")) } : { past: parseFloat(css.getPropertyValue("--sheet-past")) });
120
+ if (s)
121
+ moved().forEach((el) => { el?.style.setProperty("--sheet-ease", s.ease); el?.style.setProperty("--sheet-time", `${s.time}ms`); });
122
+ }
123
+ paint(target);
124
+ }, [popup, moved, where, speed, paint]);
125
+ React.useEffect(() => {
126
+ if (!popup)
127
+ return;
128
+ const done = (e) => { if (e.target === popup && e.propertyName === "transform")
129
+ moved().forEach((el) => { el?.style.removeProperty("--sheet-ease"); el?.style.removeProperty("--sheet-time"); }); };
130
+ popup.addEventListener("transitionend", done);
131
+ return () => popup.removeEventListener("transitionend", done);
132
+ }, [popup, moved]);
133
+ React.useEffect(() => {
134
+ if (!on || !popup || !viewport)
135
+ return;
136
+ const grab = () => {
137
+ if (!popup.getAnimations().some((a) => a.transitionProperty === "transform" && a.playState === "running"))
138
+ return;
139
+ popup.style.setProperty("--sheet-catch", `${new DOMMatrixReadOnly(getComputedStyle(popup).transform).m42 - px(popup, "--drawer-snap-point-offset")}px`);
140
+ };
141
+ const free = () => popup.style.removeProperty("--sheet-catch");
142
+ const opts = { capture: true, passive: true };
143
+ viewport.addEventListener("touchstart", grab, opts);
144
+ viewport.addEventListener("pointerdown", grab, opts);
145
+ ["touchend", "touchcancel", "pointerup", "pointercancel"].forEach((n) => window.addEventListener(n, free));
146
+ return () => {
147
+ viewport.removeEventListener("touchstart", grab, opts);
148
+ viewport.removeEventListener("pointerdown", grab, opts);
149
+ ["touchend", "touchcancel", "pointerup", "pointercancel"].forEach((n) => window.removeEventListener(n, free));
150
+ };
151
+ }, [on, popup, viewport]);
152
+ React.useEffect(() => {
153
+ if (!on || !popup)
154
+ return;
155
+ let frame = 0;
156
+ const tick = () => { if (!popup.hasAttribute("data-swiping")) {
157
+ frame = 0;
158
+ return;
159
+ } paint(where()); frame = requestAnimationFrame(tick); };
160
+ const watch = new MutationObserver(() => { if (popup.hasAttribute("data-swiping") && !frame) {
161
+ measure();
162
+ frame = requestAnimationFrame(tick);
163
+ } });
164
+ watch.observe(popup, { attributes: true, attributeFilter: ["data-swiping"] });
165
+ return () => { watch.disconnect(); cancelAnimationFrame(frame); };
166
+ }, [on, popup, paint, where, measure]);
167
+ React.useEffect(() => {
168
+ const frame = on && form === "blend" ? popup?.closest("[data-sheet-margin]") : null;
169
+ if (!frame)
170
+ return;
171
+ const watch = new MutationObserver(() => { measure(); paint(where()); });
172
+ watch.observe(frame, { attributes: true, attributeFilter: ["data-sheet-margin"] });
173
+ return () => watch.disconnect();
174
+ }, [on, form, popup, paint, where, measure]);
175
+ React.useLayoutEffect(() => {
176
+ if (!on || !open || !popup || standing)
177
+ return;
178
+ const doc = popup.ownerDocument, end = doc.createElement("div");
179
+ end.className = "o-sheet-below";
180
+ end.dataset.sheetForm = form;
181
+ end.setAttribute("aria-hidden", "true");
182
+ end.style.top = `${window.scrollY + window.innerHeight}px`;
183
+ colours.current = { sheet: getComputedStyle(popup.querySelector(".o-sheet-cut") ?? popup).backgroundColor, dim: getComputedStyle(backdrop.current ?? popup).backgroundColor };
184
+ end.style.backgroundColor = form === "full" || form === "edge" ? colours.current.sheet : colours.current.dim;
185
+ const spring = getComputedStyle(popup);
186
+ for (const name of ["--sheet-spring-time", "--sheet-spring-ease"])
187
+ end.style.setProperty(name, spring.getPropertyValue(name).trim());
188
+ doc.body.append(end);
189
+ below.current = end;
190
+ return () => { afterMotion([popup], () => { end.remove(); if (below.current === end)
191
+ below.current = null; }); };
192
+ }, [on, open, popup, form, backdrop, standing]);
193
+ React.useLayoutEffect(() => {
194
+ if (!on || !popup || !viewport)
195
+ return;
196
+ measure();
197
+ if (open)
198
+ paint(offsetOf(point, popup.offsetHeight, viewport.clientHeight));
199
+ else
200
+ paint(reach.current.closed);
201
+ }, [on, open, popup, viewport, point, points, measure, paint]);
202
+ return { release };
203
+ }
204
+ function useFit(on, popup, open) {
205
+ React.useLayoutEffect(() => {
206
+ if (!on || !popup || !open)
207
+ return;
208
+ const body = popup.querySelector(".o-sheet-body"), inner = body?.firstElementChild;
209
+ if (!body || !inner)
210
+ return;
211
+ const read = () => {
212
+ const c = getComputedStyle(body), edges = parseFloat(c.paddingTop) + parseFloat(c.paddingBottom);
213
+ popup.style.setProperty("--sheet-fit", `${popup.offsetHeight - body.offsetHeight + inner.offsetHeight + edges}px`);
214
+ };
215
+ read();
216
+ const watch = new ResizeObserver(read);
217
+ watch.observe(inner);
218
+ return () => watch.disconnect();
219
+ }, [on, popup, open]);
220
+ }
221
+ function useKeyboardFoot(popup, on) {
222
+ const [typing, setTyping] = React.useState(false);
223
+ React.useEffect(() => {
224
+ if (!on || !popup) {
225
+ setTyping(false);
226
+ return;
227
+ }
228
+ const now = popup.ownerDocument.activeElement;
229
+ setTyping(typesInto(now) && popup.contains(now));
230
+ const into = (e) => setTyping(typesInto(e.target));
231
+ const out = (e) => { if (!(typesInto(e.relatedTarget) && popup.contains(e.relatedTarget)))
232
+ setTyping(false); };
233
+ popup.addEventListener("focusin", into);
234
+ popup.addEventListener("focusout", out);
235
+ return () => { popup.removeEventListener("focusin", into); popup.removeEventListener("focusout", out); };
236
+ }, [on, popup]);
237
+ React.useEffect(() => {
238
+ const vv = typeof window === "undefined" ? null : window.visualViewport;
239
+ if (!typing || !popup || !vv)
240
+ return;
241
+ const read = () => popup.style.setProperty("--sheet-keyboard", `${Math.abs(vv.scale - 1) > 0.01 ? 0 : Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop))}px`);
242
+ read();
243
+ vv.addEventListener("resize", read);
244
+ vv.addEventListener("scroll", read);
245
+ return () => { vv.removeEventListener("resize", read); vv.removeEventListener("scroll", read); popup.style.removeProperty("--sheet-keyboard"); };
246
+ }, [typing, popup]);
247
+ }
248
+ export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form = "full", stops, openAt, stop, onStopChange, mark: marked = "[data-sheet-mark]", container, standing: stands, finalFocus, children }) {
249
+ const closeBelow = React.useContext(CloseAll), stacked = closeBelow !== null;
250
+ const standsBelow = React.useContext(Standing), standing = stands || standsBelow;
251
+ const [armed, setArmed] = React.useState(false);
252
+ React.useEffect(() => setArmed(true), []);
253
+ React.useEffect(() => {
254
+ if (!open || standing || !container)
255
+ return;
256
+ const doc = container.ownerDocument, held = [];
257
+ for (let el = container; el && el !== doc.body && el !== doc.documentElement; el = el.parentElement) {
258
+ const y = getComputedStyle(el).overflowY;
259
+ if ((y === "auto" || y === "scroll") && el.scrollHeight > el.clientHeight) {
260
+ held.push([el, el.style.getPropertyValue("overflow-y")]);
261
+ el.style.setProperty("overflow-y", "hidden");
262
+ }
263
+ }
264
+ return () => held.forEach(([el, was]) => { el.style.setProperty("overflow-y", was); });
265
+ }, [open, standing, container]);
266
+ const [popup, setPopup] = React.useState(null), [viewport, setViewport] = React.useState(null);
267
+ const backdrop = React.useRef(null), popupRef = React.useRef(null);
268
+ const bindPopup = React.useCallback((el) => { popupRef.current = el; setPopup(el); }, []);
269
+ const list = stops ?? FORMS[form].stops, first = openAt ?? list[0];
270
+ const [at, setAt] = React.useState(first), [mark, setMark] = React.useState(null);
271
+ const [wasOpen, setWasOpen] = React.useState(open), [coming, setComing] = React.useState(open);
272
+ if (open !== wasOpen) {
273
+ setWasOpen(open);
274
+ if (open) {
275
+ setAt(first);
276
+ setComing(true);
277
+ }
278
+ }
279
+ const current = stop ?? at, measured = list.includes("mark");
280
+ React.useLayoutEffect(() => {
281
+ if (!measured || !popup)
282
+ return;
283
+ const body = popup.querySelector(".o-sheet-body");
284
+ const measure = () => {
285
+ if (popup.hasAttribute("data-nested-drawer-open"))
286
+ return;
287
+ const rise = parseFloat(popup.style.getPropertyValue("--sheet-rise") || "0");
288
+ if (rise > 0 && rise < 1)
289
+ return;
290
+ const el = popup.querySelector(marked);
291
+ const bottom = el ? markBottom(el.getBoundingClientRect().bottom, popup.getBoundingClientRect().top, drawnAt(popup), body?.scrollTop ?? 0, popup.querySelector(".o-sheet-foot")?.offsetHeight ?? 0) : null;
292
+ setMark(markStop({ top: 0, height: popup.offsetHeight }, bottom));
293
+ };
294
+ measure();
295
+ const watch = new ResizeObserver(measure);
296
+ if (body)
297
+ for (const child of body.querySelectorAll(".o-sheet-content, .o-sheet-content > *"))
298
+ watch.observe(child);
299
+ window.addEventListener("resize", measure);
300
+ document.fonts.addEventListener("loadingdone", measure);
301
+ return () => { watch.disconnect(); window.removeEventListener("resize", measure); document.fonts.removeEventListener("loadingdone", measure); };
302
+ }, [measured, popup, children, marked]);
303
+ const points = React.useMemo(() => pointsOf(list, mark), [list, mark]), point = pointOf(current, mark);
304
+ const { release } = useSheetMotion({ on: true, open, form, standing, points, point, popup, viewport, backdrop });
305
+ useFit(form === "floating" || form === "edge", popup, open);
306
+ useKeyboardFoot(popup, open && !standing);
307
+ React.useEffect(() => {
308
+ if (form === "full" || form === "edge" || !popup)
309
+ return;
310
+ const press = (e) => { if (!reduced() && !e.target.closest(CONTROLS))
311
+ popup.setAttribute("data-sheet-pressed", ""); };
312
+ const free = () => popup.removeAttribute("data-sheet-pressed");
313
+ const ends = ["pointerup", "pointercancel"];
314
+ popup.addEventListener("pointerdown", press);
315
+ ends.forEach((n) => window.addEventListener(n, free));
316
+ return () => { popup.removeEventListener("pointerdown", press); ends.forEach((n) => window.removeEventListener(n, free)); };
317
+ }, [form, popup]);
318
+ React.useLayoutEffect(() => {
319
+ if (form === "full" || form === "edge" || standing || !popup)
320
+ return;
321
+ const curve = getComputedStyle(popup).getPropertyValue(`--screen-curve-${Math.min(screen.width, screen.height)}x${Math.max(screen.width, screen.height)}`).trim();
322
+ if (curve)
323
+ popup.style.setProperty("--sheet-screen", curve);
324
+ else
325
+ popup.style.removeProperty("--sheet-screen");
326
+ }, [form, standing, popup]);
327
+ const moveTo = (s) => { setAt(s); onStopChange?.(s); };
328
+ const expanded = current === 1;
329
+ React.useEffect(() => { if (!expanded) {
330
+ const b = popup?.querySelector(".o-sheet-body");
331
+ if (b)
332
+ b.scrollTop = 0;
333
+ } }, [expanded, popup]);
334
+ const close = React.useCallback((reason) => onOpenChange(false, { reason }), [onOpenChange]);
335
+ const closeAll = React.useCallback(() => { closeBelow?.(); release("closed"); close("item-press"); }, [closeBelow, release, close]);
336
+ const body = React.useMemo(() => ({
337
+ onBodyWheel: (e) => { const s = stopAfterWheel(current, e.deltaY); if (s !== current)
338
+ moveTo(s); },
339
+ onBodyFocus: (e) => { const s = stopAfterFocus(current, e.target.getBoundingClientRect().bottom, window.visualViewport?.height ?? window.innerHeight); if (s !== current)
340
+ moveTo(s); },
341
+ }), [current]);
342
+ const focusedIn = React.useRef(true);
343
+ React.useEffect(() => {
344
+ if (!open || !standing)
345
+ return;
346
+ focusedIn.current = true;
347
+ const on = (e) => { const t = e.target; if (t instanceof Element && t !== document.body)
348
+ focusedIn.current = !!(container ?? viewport)?.contains(t); };
349
+ document.addEventListener("focusin", on, true);
350
+ return () => document.removeEventListener("focusin", on, true);
351
+ }, [open, standing, container, viewport]);
352
+ return (_jsx(Base.Root, { open: open && armed, onOpenChangeComplete: (o) => { setComing(false); onOpenChangeComplete?.(o); }, swipeDirection: "down", modal: !standing, disablePointerDismissal: standing, onOpenChange: (o, details) => {
353
+ const from = details.event?.target;
354
+ const elsewhere = from instanceof Element && (from === document.body ? !focusedIn.current : !(container ?? viewport)?.contains(from));
355
+ if (!o && standing && details.reason === "escape-key" && elsewhere) {
356
+ details.cancel();
357
+ return;
358
+ }
359
+ if (!o && details.reason !== "swipe")
360
+ release("closed");
361
+ onOpenChange(o, { reason: closeReasonOf(details.reason) });
362
+ }, snapPoints: points, snapPoint: point, snapToSequentialPoints: true, onSnapPointChange: (p, details) => {
363
+ if (p === null) {
364
+ release("closed", details.event?.timeStamp);
365
+ return;
366
+ }
367
+ if (!open || details.reason !== "swipe")
368
+ return;
369
+ release(offsetOf(p, popup.offsetHeight, viewport.clientHeight), details.event?.timeStamp);
370
+ moveTo(stopOf(p === mark ? "mark" : p, list));
371
+ }, children: _jsxs(Base.Portal, { container: container, children: [_jsx(Base.Backdrop, { ref: backdrop, forceRender: stacked, className: "o-sheet-backdrop", "data-stacked": stacked ? "" : undefined }), _jsxs(Base.Viewport, { ref: setViewport, className: "o-sheet-viewport", "data-sheet-form": form, onClick: standing ? (e) => { if (e.target === e.currentTarget) {
372
+ release("closed");
373
+ close("outside-press");
374
+ } } : undefined, children: [_jsx(Base.Popup, { ref: bindPopup, initialFocus: popupRef, finalFocus: finalFocus ? () => finalFocus() ?? true : undefined, className: "o-sheet o-smooth", "data-sheet-form": form, "aria-label": label, "data-kit": "sheet", children: _jsxs("div", { className: "o-sheet-cut", children: [_jsx("div", { className: "o-sheet-handle", "aria-hidden": "true" }), _jsx(Standing.Provider, { value: standing, children: _jsx(Body.Provider, { value: body, children: _jsx(CloseAll.Provider, { value: closeAll, children: children }) }) })] }) }), coming && _jsx("div", { className: "o-sheet-shield", "aria-hidden": "true", "data-sheet-shield": "", onPointerDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); }, onClick: (e) => e.stopPropagation() })] })] }) }));
375
+ }
@@ -0,0 +1,38 @@
1
+ /** How the sheet looks. Named for that, never for a use: a height is a stop, not a form. */
2
+ export type SheetForm = "full" | "floating" | "blend" | "edge";
3
+ /** A height it rests at, as Base UI reads one: a share of the window up to 1, px above it; 1 is full. "mark" is measured:
4
+ * 16px under the content's mark, so a longer title moves it. */
5
+ export type SheetStop = number | "mark";
6
+ /** The stops a sheet may be given: small and middle for what has no mark; full is 1. */
7
+ export declare const STOPS: {
8
+ readonly small: 0.3;
9
+ readonly middle: 0.55;
10
+ readonly full: 1;
11
+ };
12
+ export declare const FORMS: Record<SheetForm, {
13
+ stops: SheetStop[];
14
+ }>;
15
+ /** px between the content's mark and the measured stop's edge. */
16
+ export declare const MARK_GAP = 16;
17
+ /** The measured stop's height: the sheet shown from its top to 16px under the mark; null with no mark, or when that
18
+ * reaches its full height. */
19
+ export declare function markStop(sheet: {
20
+ top: number;
21
+ height: number;
22
+ }, markBottom: number | null): number | null;
23
+ /** The mark's bottom from the sheet's top, in the sheet's own pixels: both read on screen, so their distance is divided by
24
+ * `k`, the scale the sheet is drawn at, then as if the body were unscrolled (`scrolled`) and clear of the foot
25
+ * that stands over it (`foot`), both its own. */
26
+ export declare function markBottom(markOnScreen: number, sheetTopOnScreen: number, k: number, scrolled: number, foot: number): number;
27
+ /** Base UI's snap points: the stops, the measured one in px, left out until it is known. */
28
+ export declare const pointsOf: (stops: SheetStop[], mark: number | null) => number[];
29
+ /** The snap point for a stop: full when its measure isn't known. */
30
+ export declare const pointOf: (stop: SheetStop, mark: number | null) => number;
31
+ /** Back from Base UI. */
32
+ export declare const stopOf: (point: number | string | null, stops: SheetStop[]) => SheetStop;
33
+ /** The sheet shown at a point, as the offset from its full height, as Base UI places it. */
34
+ export declare function offsetOf(point: number, sheet: number, window: number): number;
35
+ /** A wheel or a scroll down at a lower stop goes to full; nothing else moves. */
36
+ export declare const stopAfterWheel: (stop: SheetStop, deltaY: number) => SheetStop;
37
+ /** Focus on something under the visible part goes to full. */
38
+ export declare const stopAfterFocus: (stop: SheetStop, bottom: number, visible: number) => SheetStop;
@@ -0,0 +1,26 @@
1
+ export const STOPS = { small: 0.3, middle: 0.55, full: 1 };
2
+ export const FORMS = {
3
+ full: { stops: [STOPS.full] },
4
+ floating: { stops: [STOPS.full] },
5
+ blend: { stops: [STOPS.middle, STOPS.full] },
6
+ edge: { stops: [STOPS.full] },
7
+ };
8
+ export const MARK_GAP = 16;
9
+ export function markStop(sheet, markBottom) {
10
+ if (markBottom === null)
11
+ return null;
12
+ const shown = markBottom + MARK_GAP - sheet.top;
13
+ return shown >= sheet.height - 1 ? null : shown;
14
+ }
15
+ export function markBottom(markOnScreen, sheetTopOnScreen, k, scrolled, foot) {
16
+ return (markOnScreen - sheetTopOnScreen) / k + scrolled + foot;
17
+ }
18
+ export const pointsOf = (stops, mark) => stops.flatMap((s) => (s !== "mark" ? [s] : mark === null ? [] : [mark]));
19
+ export const pointOf = (stop, mark) => (stop !== "mark" ? stop : mark ?? 1);
20
+ export const stopOf = (point, stops) => stops.includes(point) ? point : stops.includes("mark") ? "mark" : 1;
21
+ export function offsetOf(point, sheet, window) {
22
+ const height = point <= 1 ? point * window : point;
23
+ return Math.max(0, sheet - Math.min(height, Math.min(sheet, window)));
24
+ }
25
+ export const stopAfterWheel = (stop, deltaY) => (stop !== 1 && deltaY > 0 ? 1 : stop);
26
+ export const stopAfterFocus = (stop, bottom, visible) => (stop !== 1 && bottom > visible ? 1 : stop);
@@ -0,0 +1,4 @@
1
+ import type { PieceLooks } from "../../looks/looks.js";
2
+ export type SheetLookOptionId = "spring" | "corners" | "smoothing" | "margin" | "padding" | "dim";
3
+ /** The Sheet's options. */
4
+ export declare const SHEET_LOOKS: PieceLooks<SheetLookOptionId>;
@@ -0,0 +1,10 @@
1
+ const steps = (ids) => ids.map((id) => ({ id, name: id }));
2
+ const options = [
3
+ { id: "spring", name: "The sheet's spring", def: "quick", values: [{ id: "smooth", name: "Smooth" }, { id: "quick", name: "Quick" }, { id: "lively", name: "Lively" }] },
4
+ { id: "corners", name: "Corners", def: "2xl", kind: "steps", values: steps(["lg", "xl", "2xl", "3xl", "4xl", "5xl"]) },
5
+ { id: "smoothing", name: "Corner smoothing", def: "smooth", values: [{ id: "round", name: "Round" }, { id: "smooth", name: "Smooth" }] },
6
+ { id: "margin", name: "Floating margins", def: "8", kind: "steps", values: steps(["4", "6", "8", "10", "12"]) },
7
+ { id: "padding", name: "Side padding", def: "page", values: [{ id: "page", name: "Page" }, ...steps(["12", "16", "20", "24"])] },
8
+ { id: "dim", name: "The dim", def: "light", values: [{ id: "deep", name: "Dark" }, { id: "light", name: "Light" }] },
9
+ ];
10
+ export const SHEET_LOOKS = { id: "sheet", name: "Sheet", options, looks: [] };
@@ -0,0 +1,3 @@
1
+ import type { ViewsSheetProps } from "../../provider/components.js";
2
+ /** ViewKit's sheet, drawn as the kit's Sheet. */
3
+ export declare function MapSheet({ open, onOpenChange, label, actions, children }: ViewsSheetProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useViews } from "../../provider/context.js";
3
+ import { Sheet, SheetBody, SheetButton, SheetHead } from "./bottom-sheet.js";
4
+ export function MapSheet({ open, onOpenChange, label, actions, children }) {
5
+ const { icons } = useViews();
6
+ const name = label ?? "";
7
+ const left = actions?.back ?? actions?.close;
8
+ const Back = icons.back, Close = icons.close, Check = icons.check;
9
+ return (_jsxs(Sheet, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), label: name, children: [actions && left
10
+ ? _jsx(SheetHead, { title: name, left: _jsx(SheetButton, { "aria-label": left.label, className: actions.back ? "o-sheet-back" : undefined, icon: actions.back ? _jsx(Back, {}) : _jsx(Close, {}), onClick: left.onPress }), right: actions.done ? _jsx(SheetButton, { kind: "primary", "aria-label": actions.done.label, icon: _jsx(Check, {}), onClick: actions.done.onPress }) : _jsx("span", {}) })
11
+ : _jsx(SheetHead, { title: name }), _jsx(SheetBody, { children: children })] }));
12
+ }
@@ -0,0 +1,22 @@
1
+ /** A spring as its token holds it: how long it takes (the response, in seconds) and how much it is damped, 1 for none past. */
2
+ export interface Spring {
3
+ response: number;
4
+ damping: number;
5
+ }
6
+ export interface Settle {
7
+ ease: string;
8
+ time: number;
9
+ }
10
+ /**
11
+ * The settle for a move of `distance` px, leaving at `speed` px/ms along the same axis (a throw the way it is going has
12
+ * the distance's sign). Null when there is nothing to move.
13
+ * - past: how far past rest it may swing, in px; the speed is cut to keep it there.
14
+ * - exit: it is leaving the screen. It ends the moment it arrives, still moving, aiming that many px beyond the edge, so
15
+ * the spring's long tail, which would crawl out of sight, is never played.
16
+ */
17
+ export declare function settle(distance: number, speed: number, spring: Spring, { past, exit }?: {
18
+ past?: number;
19
+ exit?: number;
20
+ }): Settle | null;
21
+ /** A spring token's value ("500ms 1") as a Spring. */
22
+ export declare function springOf(token: string): Spring;