@sprawlify/primitives 0.0.109 → 0.0.111

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/dist/{aria-hidden-BX4SWNE_.mjs → aria-hidden-C72KtklN.mjs} +1 -1
  2. package/dist/{aria-hidden-BAGrxNHt.cjs → aria-hidden-CIBHXlCy.cjs} +1 -1
  3. package/dist/aria-hidden.cjs +2 -2
  4. package/dist/aria-hidden.mjs +2 -2
  5. package/dist/{auto-resize-B1BDDnp1.cjs → auto-resize-BTTNXiml.cjs} +1 -1
  6. package/dist/{auto-resize-CN2vAzdj.mjs → auto-resize-CbNgN0OO.mjs} +1 -1
  7. package/dist/auto-resize.cjs +2 -2
  8. package/dist/auto-resize.mjs +2 -2
  9. package/dist/collection.d.cts +2 -2
  10. package/dist/collection.d.mts +2 -2
  11. package/dist/{core-BmIEKqtP.mjs → core-Ci9Yu6QI.mjs} +1 -1
  12. package/dist/{core-nBg9RC_y.cjs → core-DwdPztGA.cjs} +1 -1
  13. package/dist/core.cjs +2 -2
  14. package/dist/core.mjs +2 -2
  15. package/dist/{dismissable-DWfZGIA7.mjs → dismissable-B9k5K6f9.mjs} +2 -2
  16. package/dist/{dismissable-ChwcJMHk.cjs → dismissable-DxjbwsOf.cjs} +2 -2
  17. package/dist/dismissable.cjs +3 -3
  18. package/dist/dismissable.mjs +3 -3
  19. package/dist/{dom-query-s2ESLR2U.mjs → dom-query-BFuRs3l4.mjs} +1 -1
  20. package/dist/{dom-query-Bd63cRVF.cjs → dom-query-BUO7rGsg.cjs} +1 -1
  21. package/dist/dom-query.cjs +1 -1
  22. package/dist/dom-query.mjs +1 -1
  23. package/dist/{focus-trap-fucc6OU_.cjs → focus-trap-BewqTQFt.cjs} +1 -1
  24. package/dist/{focus-trap-DzBvBlTH.mjs → focus-trap-Do8IUXYh.mjs} +1 -1
  25. package/dist/focus-trap.cjs +2 -2
  26. package/dist/focus-trap.mjs +2 -2
  27. package/dist/{focus-visible-D5qBaAOn.mjs → focus-visible-GXKbbuiq.mjs} +1 -1
  28. package/dist/{focus-visible-75XTctXf.cjs → focus-visible-JdJXqMic.cjs} +1 -1
  29. package/dist/focus-visible.cjs +2 -2
  30. package/dist/focus-visible.mjs +2 -2
  31. package/dist/{i18n-utils-DB-lUfrr.cjs → i18n-utils-BRLqoCq8.cjs} +1 -1
  32. package/dist/{i18n-utils-oWZyUib_.mjs → i18n-utils-DZs1CPj8.mjs} +1 -1
  33. package/dist/i18n-utils.cjs +2 -2
  34. package/dist/i18n-utils.mjs +2 -2
  35. package/dist/{interact-outside-2qkUnl4N.mjs → interact-outside-Ba50N1a5.mjs} +1 -1
  36. package/dist/{interact-outside-Cx4J0EBf.cjs → interact-outside-Bg-QSXqp.cjs} +1 -1
  37. package/dist/interact-outside.cjs +2 -2
  38. package/dist/interact-outside.mjs +2 -2
  39. package/dist/{list-collection-B_8BN0XB.d.cts → list-collection-Cjgbx_9l.d.cts} +1 -1
  40. package/dist/{list-collection-DkRA5LOq.d.mts → list-collection-IF510iNl.d.mts} +1 -1
  41. package/dist/machines/accordion/index.cjs +2 -2
  42. package/dist/machines/accordion/index.mjs +2 -2
  43. package/dist/machines/angle-slider/index.cjs +2 -2
  44. package/dist/machines/angle-slider/index.d.cts +1 -1
  45. package/dist/machines/angle-slider/index.d.mts +1 -1
  46. package/dist/machines/angle-slider/index.mjs +2 -2
  47. package/dist/machines/aspect-ratio/index.cjs +2 -2
  48. package/dist/machines/aspect-ratio/index.mjs +2 -2
  49. package/dist/machines/async-list/index.cjs +2 -2
  50. package/dist/machines/async-list/index.mjs +2 -2
  51. package/dist/machines/avatar/index.cjs +2 -2
  52. package/dist/machines/avatar/index.mjs +2 -2
  53. package/dist/machines/carousel/index.cjs +3 -3
  54. package/dist/machines/carousel/index.d.cts +1 -1
  55. package/dist/machines/carousel/index.d.mts +1 -1
  56. package/dist/machines/carousel/index.mjs +3 -3
  57. package/dist/machines/cascade-select/index.cjs +5 -5
  58. package/dist/machines/cascade-select/index.d.cts +2 -2
  59. package/dist/machines/cascade-select/index.d.mts +2 -2
  60. package/dist/machines/cascade-select/index.mjs +5 -5
  61. package/dist/machines/checkbox/index.cjs +3 -3
  62. package/dist/machines/checkbox/index.d.cts +1 -1
  63. package/dist/machines/checkbox/index.d.mts +1 -1
  64. package/dist/machines/checkbox/index.mjs +3 -3
  65. package/dist/machines/clipboard/index.cjs +2 -2
  66. package/dist/machines/clipboard/index.d.cts +1 -1
  67. package/dist/machines/clipboard/index.d.mts +1 -1
  68. package/dist/machines/clipboard/index.mjs +2 -2
  69. package/dist/machines/collapsible/index.cjs +2 -2
  70. package/dist/machines/collapsible/index.d.cts +1 -1
  71. package/dist/machines/collapsible/index.d.mts +1 -1
  72. package/dist/machines/collapsible/index.mjs +2 -2
  73. package/dist/machines/color-picker/index.cjs +5 -5
  74. package/dist/machines/color-picker/index.d.cts +1 -1
  75. package/dist/machines/color-picker/index.d.mts +1 -1
  76. package/dist/machines/color-picker/index.mjs +5 -5
  77. package/dist/machines/combobox/index.cjs +5 -5
  78. package/dist/machines/combobox/index.d.cts +2 -2
  79. package/dist/machines/combobox/index.d.mts +2 -2
  80. package/dist/machines/combobox/index.mjs +5 -5
  81. package/dist/machines/date-picker/index.cjs +5 -5
  82. package/dist/machines/date-picker/index.d.cts +1 -1
  83. package/dist/machines/date-picker/index.d.mts +1 -1
  84. package/dist/machines/date-picker/index.mjs +5 -5
  85. package/dist/machines/dialog/index.cjs +7 -7
  86. package/dist/machines/dialog/index.d.cts +1 -1
  87. package/dist/machines/dialog/index.d.mts +1 -1
  88. package/dist/machines/dialog/index.mjs +7 -7
  89. package/dist/machines/drawer/index.cjs +1934 -0
  90. package/dist/machines/drawer/index.d.cts +310 -0
  91. package/dist/machines/drawer/index.d.mts +310 -0
  92. package/dist/machines/drawer/index.mjs +1927 -0
  93. package/dist/machines/dropdown-menu/index.cjs +5 -5
  94. package/dist/machines/dropdown-menu/index.d.cts +1 -1
  95. package/dist/machines/dropdown-menu/index.d.mts +1 -1
  96. package/dist/machines/dropdown-menu/index.mjs +5 -5
  97. package/dist/machines/editable/index.cjs +3 -3
  98. package/dist/machines/editable/index.d.cts +1 -1
  99. package/dist/machines/editable/index.d.mts +1 -1
  100. package/dist/machines/editable/index.mjs +3 -3
  101. package/dist/machines/file-upload/index.cjs +3 -3
  102. package/dist/machines/file-upload/index.d.cts +1 -1
  103. package/dist/machines/file-upload/index.d.mts +1 -1
  104. package/dist/machines/file-upload/index.mjs +3 -3
  105. package/dist/machines/floating-panel/index.cjs +2 -2
  106. package/dist/machines/floating-panel/index.d.cts +1 -1
  107. package/dist/machines/floating-panel/index.d.mts +1 -1
  108. package/dist/machines/floating-panel/index.mjs +2 -2
  109. package/dist/machines/hover-card/index.cjs +5 -5
  110. package/dist/machines/hover-card/index.d.cts +1 -1
  111. package/dist/machines/hover-card/index.d.mts +1 -1
  112. package/dist/machines/hover-card/index.mjs +5 -5
  113. package/dist/machines/image-cropper/index.cjs +2 -2
  114. package/dist/machines/image-cropper/index.mjs +2 -2
  115. package/dist/machines/listbox/index.cjs +3 -3
  116. package/dist/machines/listbox/index.d.cts +3 -3
  117. package/dist/machines/listbox/index.d.mts +3 -3
  118. package/dist/machines/listbox/index.mjs +3 -3
  119. package/dist/machines/marquee/index.cjs +2 -2
  120. package/dist/machines/marquee/index.d.cts +3 -3
  121. package/dist/machines/marquee/index.d.mts +3 -3
  122. package/dist/machines/marquee/index.mjs +2 -2
  123. package/dist/machines/navigation-menu/index.cjs +4 -4
  124. package/dist/machines/navigation-menu/index.d.cts +1 -1
  125. package/dist/machines/navigation-menu/index.d.mts +1 -1
  126. package/dist/machines/navigation-menu/index.mjs +4 -4
  127. package/dist/machines/number-input/index.cjs +2 -2
  128. package/dist/machines/number-input/index.d.cts +1 -1
  129. package/dist/machines/number-input/index.d.mts +1 -1
  130. package/dist/machines/number-input/index.mjs +2 -2
  131. package/dist/machines/pagination/index.cjs +2 -2
  132. package/dist/machines/pagination/index.mjs +2 -2
  133. package/dist/machines/password-input/index.cjs +2 -2
  134. package/dist/machines/password-input/index.d.cts +1 -1
  135. package/dist/machines/password-input/index.d.mts +1 -1
  136. package/dist/machines/password-input/index.mjs +2 -2
  137. package/dist/machines/pin-input/index.cjs +2 -2
  138. package/dist/machines/pin-input/index.d.cts +1 -1
  139. package/dist/machines/pin-input/index.d.mts +1 -1
  140. package/dist/machines/pin-input/index.mjs +2 -2
  141. package/dist/machines/popover/index.cjs +8 -8
  142. package/dist/machines/popover/index.d.cts +1 -1
  143. package/dist/machines/popover/index.d.mts +1 -1
  144. package/dist/machines/popover/index.mjs +8 -8
  145. package/dist/machines/presence/index.cjs +2 -2
  146. package/dist/machines/presence/index.mjs +2 -2
  147. package/dist/machines/progress/index.cjs +2 -2
  148. package/dist/machines/progress/index.d.cts +1 -1
  149. package/dist/machines/progress/index.d.mts +1 -1
  150. package/dist/machines/progress/index.mjs +2 -2
  151. package/dist/machines/qr-code/index.cjs +2 -2
  152. package/dist/machines/qr-code/index.mjs +2 -2
  153. package/dist/machines/radio-group/index.cjs +3 -3
  154. package/dist/machines/radio-group/index.d.cts +1 -1
  155. package/dist/machines/radio-group/index.d.mts +1 -1
  156. package/dist/machines/radio-group/index.mjs +3 -3
  157. package/dist/machines/rating-group/index.cjs +2 -2
  158. package/dist/machines/rating-group/index.mjs +2 -2
  159. package/dist/machines/scroll-area/index.cjs +2 -2
  160. package/dist/machines/scroll-area/index.d.cts +1 -1
  161. package/dist/machines/scroll-area/index.d.mts +1 -1
  162. package/dist/machines/scroll-area/index.mjs +2 -2
  163. package/dist/machines/select/index.cjs +6 -6
  164. package/dist/machines/select/index.d.cts +2 -2
  165. package/dist/machines/select/index.d.mts +2 -2
  166. package/dist/machines/select/index.mjs +6 -6
  167. package/dist/machines/separator/index.cjs +2 -2
  168. package/dist/machines/separator/index.mjs +2 -2
  169. package/dist/machines/signature-pad/index.cjs +2 -2
  170. package/dist/machines/signature-pad/index.mjs +2 -2
  171. package/dist/machines/slider/index.cjs +2 -2
  172. package/dist/machines/slider/index.d.cts +1 -1
  173. package/dist/machines/slider/index.d.mts +1 -1
  174. package/dist/machines/slider/index.mjs +2 -2
  175. package/dist/machines/splitter/index.cjs +2 -2
  176. package/dist/machines/splitter/index.mjs +2 -2
  177. package/dist/machines/steps/index.cjs +2 -2
  178. package/dist/machines/steps/index.d.cts +1 -1
  179. package/dist/machines/steps/index.d.mts +1 -1
  180. package/dist/machines/steps/index.mjs +2 -2
  181. package/dist/machines/switch/index.cjs +3 -3
  182. package/dist/machines/switch/index.mjs +3 -3
  183. package/dist/machines/tabs/index.cjs +2 -2
  184. package/dist/machines/tabs/index.d.cts +1 -1
  185. package/dist/machines/tabs/index.d.mts +1 -1
  186. package/dist/machines/tabs/index.mjs +2 -2
  187. package/dist/machines/tags-input/index.cjs +4 -4
  188. package/dist/machines/tags-input/index.d.cts +1 -1
  189. package/dist/machines/tags-input/index.d.mts +1 -1
  190. package/dist/machines/tags-input/index.mjs +4 -4
  191. package/dist/machines/timer/index.cjs +2 -2
  192. package/dist/machines/timer/index.d.cts +1 -1
  193. package/dist/machines/timer/index.d.mts +1 -1
  194. package/dist/machines/timer/index.mjs +2 -2
  195. package/dist/machines/toast/index.cjs +4 -4
  196. package/dist/machines/toast/index.d.cts +1 -1
  197. package/dist/machines/toast/index.d.mts +1 -1
  198. package/dist/machines/toast/index.mjs +4 -4
  199. package/dist/machines/toggle/index.cjs +2 -2
  200. package/dist/machines/toggle/index.mjs +2 -2
  201. package/dist/machines/toggle-group/index.cjs +2 -2
  202. package/dist/machines/toggle-group/index.mjs +2 -2
  203. package/dist/machines/tooltip/index.cjs +4 -4
  204. package/dist/machines/tooltip/index.d.cts +1 -1
  205. package/dist/machines/tooltip/index.d.mts +1 -1
  206. package/dist/machines/tooltip/index.mjs +4 -4
  207. package/dist/machines/tour/index.cjs +6 -6
  208. package/dist/machines/tour/index.d.cts +1 -1
  209. package/dist/machines/tour/index.d.mts +1 -1
  210. package/dist/machines/tour/index.mjs +6 -6
  211. package/dist/machines/tree-view/index.cjs +2 -2
  212. package/dist/machines/tree-view/index.d.cts +1 -1
  213. package/dist/machines/tree-view/index.d.mts +1 -1
  214. package/dist/machines/tree-view/index.mjs +2 -2
  215. package/dist/{popper-BDy37WA0.mjs → popper-BlgbmdAn.mjs} +1 -1
  216. package/dist/{popper-Cx3KHzeT.cjs → popper-viCrafLC.cjs} +1 -1
  217. package/dist/popper.cjs +2 -2
  218. package/dist/popper.mjs +2 -2
  219. package/dist/{remove-scroll-D9FAOapi.cjs → remove-scroll-D4CMJmU2.cjs} +1 -1
  220. package/dist/{remove-scroll-HcSiTbd5.mjs → remove-scroll-D55GZoBb.mjs} +1 -1
  221. package/dist/{scroll-snap-DfSwN3As.mjs → scroll-snap-CdneVP31.mjs} +1 -1
  222. package/dist/{scroll-snap-Dp_2adEa.cjs → scroll-snap-vZ2q6dcN.cjs} +1 -1
  223. package/dist/scroll-snap.cjs +2 -2
  224. package/dist/scroll-snap.mjs +2 -2
  225. package/dist/{selection-DdNvrKbj.d.mts → selection-6urf-c8j.d.mts} +1 -1
  226. package/dist/{selection-Bb_ZSVxe.d.cts → selection-BmS2RDMq.d.cts} +1 -1
  227. package/package.json +11 -11
  228. package/dist/machines/bottom-sheet/index.cjs +0 -667
  229. package/dist/machines/bottom-sheet/index.d.cts +0 -239
  230. package/dist/machines/bottom-sheet/index.d.mts +0 -239
  231. package/dist/machines/bottom-sheet/index.mjs +0 -662
@@ -1,662 +0,0 @@
1
- import { t as createAnatomy } from "../../create-anatomy-Dr0evdYy.mjs";
2
- import { St as isLeftClick, W as raf, ht as getEventTarget, m as resizeObserverBorderBox, pt as getEventPoint, ut as addDomEvent } from "../../dom-query-s2ESLR2U.mjs";
3
- import { t as _defineProperty } from "../../defineProperty-D5oW_HU_.mjs";
4
- import { t as ariaHidden } from "../../aria-hidden-BX4SWNE_.mjs";
5
- import { H as toPx, u as createSplitProps } from "../../utils-VVoZ_v29.mjs";
6
- import { a as createMachine } from "../../core-BmIEKqtP.mjs";
7
- import "../../interact-outside-2qkUnl4N.mjs";
8
- import { n as trackDismissableElement } from "../../dismissable-DWfZGIA7.mjs";
9
- import { t as trapFocus } from "../../focus-trap-DzBvBlTH.mjs";
10
- import { t as createProps } from "../../create-props-DFW8DUsC.mjs";
11
- import { t as preventBodyScroll } from "../../remove-scroll-HcSiTbd5.mjs";
12
- //#region src/machines/bottom-sheet/bottom-sheet.anatomy.ts
13
- const anatomy = createAnatomy("bottom-sheet").parts("content", "title", "trigger", "backdrop", "grabber", "grabberIndicator", "closeTrigger");
14
- const parts = anatomy.build();
15
- //#endregion
16
- //#region src/machines/bottom-sheet/bottom-sheet.dom.ts
17
- const getContentId = (ctx) => ctx.ids?.content ?? `bottom-sheet:${ctx.id}:content`;
18
- const getTitleId = (ctx) => ctx.ids?.title ?? `bottom-sheet:${ctx.id}:title`;
19
- const getTriggerId = (ctx) => ctx.ids?.trigger ?? `bottom-sheet:${ctx.id}:trigger`;
20
- const getBackdropId = (ctx) => ctx.ids?.backdrop ?? `bottom-sheet:${ctx.id}:backdrop`;
21
- const getGrabberId = (ctx) => ctx.ids?.grabber ?? `bottom-sheet:${ctx.id}:grabber`;
22
- const getGrabberIndicatorId = (ctx) => ctx.ids?.grabberIndicator ?? `bottom-sheet:${ctx.id}:grabber-indicator`;
23
- const getCloseTriggerId = (ctx) => ctx.ids?.closeTrigger ?? `bottom-sheet:${ctx.id}:close-trigger`;
24
- const getContentEl = (ctx) => ctx.getById(getContentId(ctx));
25
- const getTriggerEl = (ctx) => ctx.getById(getTriggerId(ctx));
26
- const getCloseTriggerEl = (ctx) => ctx.getById(getCloseTriggerId(ctx));
27
- //#endregion
28
- //#region src/machines/bottom-sheet/bottom-sheet.connect.ts
29
- function connect(service, normalize) {
30
- const { state, send, context, scope, prop } = service;
31
- const open = state.hasTag("open");
32
- const dragOffset = context.get("dragOffset");
33
- const dragging = dragOffset !== null;
34
- const activeSnapPoint = context.get("activeSnapPoint");
35
- const resolvedActiveSnapPoint = context.get("resolvedActiveSnapPoint");
36
- const translate = dragOffset ?? resolvedActiveSnapPoint?.offset;
37
- function onPointerDown(event) {
38
- if (!isLeftClick(event)) return;
39
- const target = getEventTarget(event);
40
- if (target?.hasAttribute("data-no-drag") || target?.closest("[data-no-drag]")) return;
41
- if (state.matches("closing")) return;
42
- send({
43
- type: "POINTER_DOWN",
44
- point: getEventPoint(event)
45
- });
46
- }
47
- return {
48
- open,
49
- dragging,
50
- setOpen(nextOpen) {
51
- if (state.hasTag("open") === nextOpen) return;
52
- send({ type: nextOpen ? "OPEN" : "CLOSE" });
53
- },
54
- snapPoints: prop("snapPoints"),
55
- activeSnapPoint,
56
- setActiveSnapPoint(snapPoint) {
57
- if (context.get("activeSnapPoint") === snapPoint) return;
58
- send({
59
- type: "ACTIVE_SNAP_POINT.SET",
60
- snapPoint
61
- });
62
- },
63
- getOpenPercentage() {
64
- if (!open) return 0;
65
- const contentHeight = context.get("contentHeight");
66
- if (!contentHeight) return 0;
67
- const currentOffset = translate ?? 0;
68
- return Math.max(0, Math.min(1, 1 - currentOffset / contentHeight));
69
- },
70
- getActiveSnapIndex() {
71
- return prop("snapPoints").indexOf(activeSnapPoint);
72
- },
73
- getContentHeight() {
74
- return context.get("contentHeight");
75
- },
76
- getContentProps(props = { draggable: true }) {
77
- return normalize.element({
78
- ...parts.content.attrs,
79
- dir: prop("dir"),
80
- id: getContentId(scope),
81
- tabIndex: -1,
82
- role: "dialog",
83
- "aria-modal": prop("modal"),
84
- "aria-labelledby": getTitleId(scope),
85
- hidden: !open,
86
- "data-state": open ? "open" : "closed",
87
- style: {
88
- transform: "translate3d(0, var(--bottom-sheet-translate, 0), 0)",
89
- transitionDuration: dragging ? "0s" : void 0,
90
- "--bottom-sheet-translate": toPx(translate),
91
- willChange: "transform"
92
- },
93
- onPointerDown(event) {
94
- if (!props.draggable) return;
95
- onPointerDown(event);
96
- }
97
- });
98
- },
99
- getTitleProps() {
100
- return normalize.element({
101
- ...parts.title.attrs,
102
- id: getTitleId(scope),
103
- dir: prop("dir")
104
- });
105
- },
106
- getTriggerProps() {
107
- return normalize.button({
108
- ...parts.trigger.attrs,
109
- id: getTriggerId(scope),
110
- type: "button",
111
- onClick() {
112
- send({ type: open ? "CLOSE" : "OPEN" });
113
- }
114
- });
115
- },
116
- getBackdropProps() {
117
- return normalize.element({
118
- ...parts.backdrop.attrs,
119
- id: getBackdropId(scope),
120
- hidden: !open,
121
- "data-state": open ? "open" : "closed",
122
- style: { willChange: "opacity" }
123
- });
124
- },
125
- getGrabberProps() {
126
- return normalize.element({
127
- ...parts.grabber.attrs,
128
- id: getGrabberId(scope),
129
- onPointerDown(event) {
130
- onPointerDown(event);
131
- },
132
- style: { touchAction: "none" }
133
- });
134
- },
135
- getGrabberIndicatorProps() {
136
- return normalize.element({
137
- ...parts.grabberIndicator.attrs,
138
- id: getGrabberIndicatorId(scope)
139
- });
140
- },
141
- getCloseTriggerProps() {
142
- return normalize.button({
143
- ...parts.closeTrigger.attrs,
144
- id: getCloseTriggerId(scope),
145
- onClick() {
146
- send({ type: "CLOSE" });
147
- }
148
- });
149
- }
150
- };
151
- }
152
- //#endregion
153
- //#region src/machines/bottom-sheet/utils/find-closest-snap-point.ts
154
- function findClosestSnapPoint(offset, snapPoints) {
155
- return snapPoints.reduce((acc, curr) => {
156
- const closestDiff = Math.abs(offset - acc.offset);
157
- return Math.abs(offset - curr.offset) < closestDiff ? curr : acc;
158
- });
159
- }
160
- //#endregion
161
- //#region src/machines/bottom-sheet/utils/get-scroll-info.ts
162
- function isScrollContainer(element) {
163
- const overflow = getComputedStyle(element).overflowY;
164
- return overflow === "auto" || overflow === "scroll";
165
- }
166
- function getScrollInfo(target, container) {
167
- let element = target;
168
- let availableScroll = 0;
169
- let availableScrollTop = 0;
170
- while (element) {
171
- const { clientHeight, scrollTop, scrollHeight } = element;
172
- const scrolled = scrollHeight - scrollTop - clientHeight;
173
- if ((scrollTop !== 0 || scrolled !== 0) && isScrollContainer(element)) {
174
- availableScroll += scrolled;
175
- availableScrollTop += scrollTop;
176
- }
177
- if (element === container || element === document.documentElement) break;
178
- element = element.parentNode;
179
- }
180
- return {
181
- availableScroll,
182
- availableScrollTop
183
- };
184
- }
185
- //#endregion
186
- //#region src/machines/bottom-sheet/utils/drag-manager.ts
187
- const DRAG_START_THRESHOLD = .3;
188
- var DragManager = class {
189
- constructor() {
190
- _defineProperty(this, "pointerStart", null);
191
- _defineProperty(this, "dragOffset", null);
192
- _defineProperty(this, "lastPoint", null);
193
- _defineProperty(this, "lastTimestamp", null);
194
- _defineProperty(this, "velocity", null);
195
- }
196
- setPointerStart(point) {
197
- this.pointerStart = point;
198
- }
199
- clearPointerStart() {
200
- this.pointerStart = null;
201
- }
202
- getPointerStart() {
203
- return this.pointerStart;
204
- }
205
- setDragOffset(point, resolvedActiveSnapPointOffset) {
206
- if (!this.pointerStart) return;
207
- const currentTimestamp = (/* @__PURE__ */ new Date()).getTime();
208
- if (this.lastPoint) {
209
- const dy = point.y - this.lastPoint.y;
210
- if (this.lastTimestamp) {
211
- const dt = currentTimestamp - this.lastTimestamp;
212
- if (dt > 0) {
213
- const calculatedVelocity = dy / dt * 1e3;
214
- this.velocity = Number.isFinite(calculatedVelocity) ? calculatedVelocity : 0;
215
- }
216
- }
217
- }
218
- this.lastPoint = point;
219
- this.lastTimestamp = currentTimestamp;
220
- let delta = this.pointerStart.y - point.y - resolvedActiveSnapPointOffset;
221
- if (delta > 0) delta = 0;
222
- this.dragOffset = -delta;
223
- }
224
- getDragOffset() {
225
- return this.dragOffset;
226
- }
227
- clearDragOffset() {
228
- this.dragOffset = null;
229
- }
230
- getVelocity() {
231
- return this.velocity;
232
- }
233
- clearVelocityTracking() {
234
- this.lastPoint = null;
235
- this.lastTimestamp = null;
236
- this.velocity = null;
237
- }
238
- clear() {
239
- this.clearPointerStart();
240
- this.clearDragOffset();
241
- this.clearVelocityTracking();
242
- }
243
- shouldStartDragging(point, target, container, preventDragOnScroll) {
244
- if (!this.pointerStart || !container) return false;
245
- if (preventDragOnScroll) {
246
- const delta = this.pointerStart.y - point.y;
247
- if (Math.abs(delta) < DRAG_START_THRESHOLD) return false;
248
- const { availableScroll, availableScrollTop } = getScrollInfo(target, container);
249
- if (delta > 0 && Math.abs(availableScroll) > 1 || delta < 0 && Math.abs(availableScrollTop) > 0) return false;
250
- }
251
- return true;
252
- }
253
- findClosestSnapPoint(snapPoints) {
254
- if (this.dragOffset === null) return snapPoints[0]?.value ?? 1;
255
- return findClosestSnapPoint(this.dragOffset, snapPoints).value;
256
- }
257
- shouldDismiss(contentHeight, snapPoints, swipeVelocityThreshold, closeThreshold) {
258
- if (this.dragOffset === null || this.velocity === null || contentHeight === null) return false;
259
- const visibleHeight = contentHeight - this.dragOffset;
260
- const smallestSnapPoint = snapPoints.reduce((acc, curr) => curr.offset > acc.offset ? curr : acc);
261
- const isFastSwipe = this.velocity > 0 && this.velocity >= swipeVelocityThreshold;
262
- const closeThresholdInPixels = contentHeight * (1 - closeThreshold);
263
- const isBelowSmallestSnapPoint = visibleHeight < contentHeight - smallestSnapPoint.offset;
264
- return isFastSwipe || visibleHeight < closeThresholdInPixels && isBelowSmallestSnapPoint || visibleHeight === 0;
265
- }
266
- };
267
- //#endregion
268
- //#region src/machines/bottom-sheet/utils/resolve-snap-point.ts
269
- function resolveSnapPoint(snapPoint, containerHeight) {
270
- if (typeof snapPoint === "number") return {
271
- value: snapPoint,
272
- offset: containerHeight - snapPoint * containerHeight
273
- };
274
- if (typeof snapPoint === "string") return {
275
- value: snapPoint,
276
- offset: containerHeight - parseFloat(snapPoint)
277
- };
278
- throw new Error(`Invalid snap point: ${snapPoint}`);
279
- }
280
- //#endregion
281
- //#region src/machines/bottom-sheet/bottom-sheet.machine.ts
282
- const machine = createMachine({
283
- props({ props, scope }) {
284
- const initialFocusEl = props.role === "alertdialog" ? () => getCloseTriggerEl(scope) : void 0;
285
- const modal = typeof props.modal === "boolean" ? props.modal : true;
286
- return {
287
- modal,
288
- trapFocus: modal,
289
- preventScroll: modal,
290
- closeOnInteractOutside: true,
291
- closeOnEscape: true,
292
- restoreFocus: true,
293
- initialFocusEl,
294
- snapPoints: [1],
295
- defaultActiveSnapPoint: 1,
296
- swipeVelocityThreshold: 700,
297
- closeThreshold: .25,
298
- preventDragOnScroll: true,
299
- ...props
300
- };
301
- },
302
- context({ bindable, prop }) {
303
- return {
304
- dragOffset: bindable(() => ({ defaultValue: null })),
305
- activeSnapPoint: bindable(() => ({
306
- defaultValue: prop("defaultActiveSnapPoint"),
307
- value: prop("activeSnapPoint"),
308
- onChange(value) {
309
- return prop("onActiveSnapPointChange")?.({ snapPoint: value });
310
- }
311
- })),
312
- resolvedActiveSnapPoint: bindable(() => ({ defaultValue: null })),
313
- contentHeight: bindable(() => ({ defaultValue: null }))
314
- };
315
- },
316
- refs() {
317
- return { dragManager: new DragManager() };
318
- },
319
- computed: { resolvedSnapPoints({ context, prop }) {
320
- const contentHeight = context.get("contentHeight");
321
- if (contentHeight === null) return [];
322
- return prop("snapPoints").map((snapPoint) => resolveSnapPoint(snapPoint, contentHeight));
323
- } },
324
- watch({ track, context, prop, action }) {
325
- track([() => context.get("activeSnapPoint"), () => context.get("contentHeight")], () => {
326
- const activeSnapPoint = context.get("activeSnapPoint");
327
- const contentHeight = context.get("contentHeight");
328
- if (contentHeight === null) return;
329
- const resolvedActiveSnapPoint = resolveSnapPoint(activeSnapPoint, contentHeight);
330
- context.set("resolvedActiveSnapPoint", resolvedActiveSnapPoint);
331
- });
332
- track([() => prop("open")], () => {
333
- action(["toggleVisibility"]);
334
- });
335
- },
336
- initialState({ prop }) {
337
- return prop("open") || prop("defaultOpen") ? "open" : "closed";
338
- },
339
- on: { "ACTIVE_SNAP_POINT.SET": { actions: ["setActiveSnapPoint"] } },
340
- states: {
341
- open: {
342
- tags: ["open"],
343
- effects: [
344
- "trackDismissableElement",
345
- "preventScroll",
346
- "trapFocus",
347
- "hideContentBelow",
348
- "trackPointerMove",
349
- "trackContentHeight"
350
- ],
351
- on: {
352
- "CONTROLLED.CLOSE": { target: "closed" },
353
- POINTER_DOWN: { actions: ["setPointerStart"] },
354
- POINTER_MOVE: [{
355
- guard: "isDragging",
356
- actions: ["setDragOffset"]
357
- }, {
358
- guard: "shouldStartDragging",
359
- actions: ["setDragOffset"]
360
- }],
361
- POINTER_UP: [
362
- {
363
- guard: "shouldCloseOnSwipe",
364
- target: "closing"
365
- },
366
- {
367
- guard: "isDragging",
368
- actions: [
369
- "setClosestSnapPoint",
370
- "clearPointerStart",
371
- "clearDragOffset"
372
- ]
373
- },
374
- { actions: ["clearPointerStart", "clearDragOffset"] }
375
- ],
376
- CLOSE: [{
377
- guard: "isOpenControlled",
378
- actions: ["invokeOnClose"]
379
- }, {
380
- target: "closing",
381
- actions: ["invokeOnClose"]
382
- }]
383
- }
384
- },
385
- closing: {
386
- effects: ["trackExitAnimation"],
387
- on: { ANIMATION_END: {
388
- target: "closed",
389
- actions: [
390
- "invokeOnClose",
391
- "clearPointerStart",
392
- "clearDragOffset",
393
- "clearActiveSnapPoint",
394
- "clearResolvedActiveSnapPoint",
395
- "clearContentHeight",
396
- "clearVelocityTracking"
397
- ]
398
- } }
399
- },
400
- closed: {
401
- tags: ["closed"],
402
- on: {
403
- "CONTROLLED.OPEN": { target: "open" },
404
- OPEN: [{
405
- guard: "isOpenControlled",
406
- actions: ["invokeOnOpen"]
407
- }, {
408
- target: "open",
409
- actions: ["invokeOnOpen"]
410
- }]
411
- }
412
- }
413
- },
414
- implementations: {
415
- guards: {
416
- isOpenControlled: ({ prop }) => prop("open") !== void 0,
417
- isDragging({ context }) {
418
- return context.get("dragOffset") !== null;
419
- },
420
- shouldStartDragging({ prop, refs, event, scope }) {
421
- return refs.get("dragManager").shouldStartDragging(event.point, event.target, getContentEl(scope), prop("preventDragOnScroll"));
422
- },
423
- shouldCloseOnSwipe({ prop, context, computed, refs }) {
424
- return refs.get("dragManager").shouldDismiss(context.get("contentHeight"), computed("resolvedSnapPoints"), prop("swipeVelocityThreshold"), prop("closeThreshold"));
425
- }
426
- },
427
- actions: {
428
- invokeOnOpen({ prop }) {
429
- prop("onOpenChange")?.({ open: true });
430
- },
431
- invokeOnClose({ prop }) {
432
- prop("onOpenChange")?.({ open: false });
433
- },
434
- setActiveSnapPoint({ context, event }) {
435
- context.set("activeSnapPoint", event.snapPoint);
436
- },
437
- setPointerStart({ event, refs }) {
438
- refs.get("dragManager").setPointerStart(event.point);
439
- },
440
- setDragOffset({ context, event, refs }) {
441
- const dragManager = refs.get("dragManager");
442
- dragManager.setDragOffset(event.point, context.get("resolvedActiveSnapPoint")?.offset || 0);
443
- context.set("dragOffset", dragManager.getDragOffset());
444
- },
445
- setClosestSnapPoint({ computed, context, refs }) {
446
- const snapPoints = computed("resolvedSnapPoints");
447
- const contentHeight = context.get("contentHeight");
448
- if (!snapPoints.length || contentHeight === null) return;
449
- const closestSnapPoint = refs.get("dragManager").findClosestSnapPoint(snapPoints);
450
- context.set("activeSnapPoint", closestSnapPoint);
451
- const resolved = resolveSnapPoint(closestSnapPoint, contentHeight);
452
- context.set("resolvedActiveSnapPoint", resolved);
453
- },
454
- clearDragOffset({ context, refs }) {
455
- refs.get("dragManager").clearDragOffset();
456
- context.set("dragOffset", null);
457
- },
458
- clearActiveSnapPoint({ context, prop }) {
459
- context.set("activeSnapPoint", prop("defaultActiveSnapPoint"));
460
- },
461
- clearResolvedActiveSnapPoint({ context }) {
462
- context.set("resolvedActiveSnapPoint", null);
463
- },
464
- clearPointerStart({ refs }) {
465
- refs.get("dragManager").clearPointerStart();
466
- },
467
- clearContentHeight({ context }) {
468
- context.set("contentHeight", null);
469
- },
470
- clearVelocityTracking({ refs }) {
471
- refs.get("dragManager").clearVelocityTracking();
472
- },
473
- toggleVisibility({ event, send, prop }) {
474
- send({
475
- type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
476
- previousEvent: event
477
- });
478
- }
479
- },
480
- effects: {
481
- trackDismissableElement({ scope, prop, send }) {
482
- const getContentEl$1 = () => getContentEl(scope);
483
- return trackDismissableElement(getContentEl$1, {
484
- defer: true,
485
- exclude: [getTriggerEl(scope)],
486
- onInteractOutside(event) {
487
- prop("onInteractOutside")?.(event);
488
- if (!prop("closeOnInteractOutside")) event.preventDefault();
489
- },
490
- onFocusOutside: prop("onFocusOutside"),
491
- onEscapeKeyDown(event) {
492
- prop("onEscapeKeyDown")?.(event);
493
- if (!prop("closeOnEscape")) event.preventDefault();
494
- },
495
- onPointerDownOutside: prop("onPointerDownOutside"),
496
- onRequestDismiss: prop("onRequestDismiss"),
497
- onDismiss() {
498
- send({
499
- type: "CLOSE",
500
- src: "interact-outside"
501
- });
502
- }
503
- });
504
- },
505
- preventScroll({ scope, prop }) {
506
- if (!prop("preventScroll")) return;
507
- return preventBodyScroll(scope.getDoc());
508
- },
509
- trapFocus({ scope, prop }) {
510
- if (!prop("trapFocus")) return;
511
- const contentEl = () => getContentEl(scope);
512
- return trapFocus(contentEl, {
513
- preventScroll: true,
514
- returnFocusOnDeactivate: !!prop("restoreFocus"),
515
- initialFocus: prop("initialFocusEl"),
516
- setReturnFocus: (el) => prop("finalFocusEl")?.() || el,
517
- getShadowRoot: true
518
- });
519
- },
520
- hideContentBelow({ scope, prop }) {
521
- if (!prop("modal")) return;
522
- const getElements = () => [getContentEl(scope)];
523
- return ariaHidden(getElements, { defer: true });
524
- },
525
- trackPointerMove({ scope, send, prop }) {
526
- let lastY = 0;
527
- function onPointerMove(event) {
528
- send({
529
- type: "POINTER_MOVE",
530
- point: getEventPoint(event),
531
- target: getEventTarget(event)
532
- });
533
- }
534
- function onPointerUp(event) {
535
- if (event.pointerType === "touch") return;
536
- send({
537
- type: "POINTER_UP",
538
- point: getEventPoint(event)
539
- });
540
- }
541
- function onTouchStart(event) {
542
- if (!event.touches[0]) return;
543
- lastY = event.touches[0].clientY;
544
- }
545
- function onTouchMove(event) {
546
- if (!event.touches[0]) return;
547
- const point = getEventPoint(event);
548
- const target = event.target;
549
- if (!prop("preventDragOnScroll")) {
550
- send({
551
- type: "POINTER_MOVE",
552
- point,
553
- target
554
- });
555
- return;
556
- }
557
- const contentEl = getContentEl(scope);
558
- if (!contentEl) return;
559
- let el = target;
560
- while (el && el !== contentEl && el.scrollHeight <= el.clientHeight) el = el.parentElement;
561
- if (el && el !== contentEl) {
562
- const scrollTop = el.scrollTop;
563
- const y = event.touches[0].clientY;
564
- if (scrollTop <= 0 && y > lastY) event.preventDefault();
565
- lastY = y;
566
- }
567
- send({
568
- type: "POINTER_MOVE",
569
- point,
570
- target
571
- });
572
- }
573
- function onTouchEnd(event) {
574
- if (event.touches.length !== 0) return;
575
- send({
576
- type: "POINTER_UP",
577
- point: getEventPoint(event)
578
- });
579
- }
580
- const doc = scope.getDoc();
581
- const cleanups = [
582
- addDomEvent(doc, "pointermove", onPointerMove),
583
- addDomEvent(doc, "pointerup", onPointerUp),
584
- addDomEvent(doc, "touchstart", onTouchStart, { passive: false }),
585
- addDomEvent(doc, "touchmove", onTouchMove, { passive: false }),
586
- addDomEvent(doc, "touchend", onTouchEnd)
587
- ];
588
- return () => {
589
- cleanups.forEach((cleanup) => cleanup());
590
- };
591
- },
592
- trackContentHeight({ context, scope }) {
593
- const contentEl = getContentEl(scope);
594
- if (!contentEl) return;
595
- const updateHeight = () => {
596
- const rect = contentEl.getBoundingClientRect();
597
- context.set("contentHeight", rect.height);
598
- };
599
- updateHeight();
600
- return resizeObserverBorderBox.observe(contentEl, updateHeight);
601
- },
602
- trackExitAnimation({ send, scope }) {
603
- let cleanup;
604
- const rafCleanup = raf(() => {
605
- const contentEl = getContentEl(scope);
606
- if (!contentEl) return;
607
- const animationName = getComputedStyle(contentEl).animationName;
608
- if (!animationName || animationName === "none") {
609
- send({ type: "ANIMATION_END" });
610
- return;
611
- }
612
- const onEnd = (event) => {
613
- if (getEventTarget(event) === contentEl) send({ type: "ANIMATION_END" });
614
- };
615
- contentEl.addEventListener("animationend", onEnd);
616
- cleanup = () => {
617
- contentEl.removeEventListener("animationend", onEnd);
618
- };
619
- });
620
- return () => {
621
- rafCleanup();
622
- cleanup?.();
623
- };
624
- }
625
- }
626
- }
627
- });
628
- //#endregion
629
- //#region src/machines/bottom-sheet/bottom-sheet.props.ts
630
- const props = createProps()([
631
- "id",
632
- "ids",
633
- "dir",
634
- "modal",
635
- "initialFocusEl",
636
- "finalFocusEl",
637
- "open",
638
- "defaultOpen",
639
- "getRootNode",
640
- "snapPoints",
641
- "swipeVelocityThreshold",
642
- "closeThreshold",
643
- "preventDragOnScroll",
644
- "closeOnEscape",
645
- "closeOnInteractOutside",
646
- "onEscapeKeyDown",
647
- "onFocusOutside",
648
- "onInteractOutside",
649
- "onOpenChange",
650
- "onPointerDownOutside",
651
- "onRequestDismiss",
652
- "preventScroll",
653
- "restoreFocus",
654
- "role",
655
- "trapFocus",
656
- "defaultActiveSnapPoint",
657
- "activeSnapPoint",
658
- "onActiveSnapPointChange"
659
- ]);
660
- const splitProps = createSplitProps(props);
661
- //#endregion
662
- export { anatomy, connect, machine, props, splitProps };