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