@ark-ui/solid 5.15.1 → 5.15.3

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 (183) hide show
  1. package/README.md +1 -0
  2. package/dist/chunk/6ATAHZBX.js +193 -0
  3. package/dist/chunk/I7VQFKYT.jsx +172 -0
  4. package/dist/chunk/{KAYDBHSW.jsx → IDNDLSEV.jsx} +4 -4
  5. package/dist/chunk/L5XYJCAK.jsx +264 -0
  6. package/dist/chunk/{VL4J24YY.js → NEP3K5KL.js} +2 -2
  7. package/dist/chunk/P5BHXVYK.js +126 -0
  8. package/dist/chunk/TBR4XVH2.js +172 -0
  9. package/dist/chunk/{NCRPFSNO.jsx → VR5BNKL7.jsx} +4 -4
  10. package/dist/chunk/ZHLQWQXX.jsx +253 -0
  11. package/dist/chunk/{SWUMYWUU.js → ZLUEV2MH.js} +2 -2
  12. package/dist/components/accordion/index.js +1 -1
  13. package/dist/components/accordion/index.jsx +3 -3
  14. package/dist/components/angle-slider/index.js +1 -1
  15. package/dist/components/angle-slider/index.jsx +2 -2
  16. package/dist/components/avatar/index.js +1 -1
  17. package/dist/components/avatar/index.jsx +2 -2
  18. package/dist/components/carousel/index.js +1 -1
  19. package/dist/components/carousel/index.jsx +2 -2
  20. package/dist/components/checkbox/index.js +1 -1
  21. package/dist/components/checkbox/index.jsx +2 -2
  22. package/dist/components/clipboard/index.jsx +1 -1
  23. package/dist/components/collapsible/index.js +1 -1
  24. package/dist/components/collapsible/index.jsx +2 -2
  25. package/dist/components/color-picker/index.js +1 -1
  26. package/dist/components/color-picker/index.jsx +2 -2
  27. package/dist/components/combobox/index.js +1 -1
  28. package/dist/components/combobox/index.jsx +4 -4
  29. package/dist/components/date-picker/index.js +1 -1
  30. package/dist/components/date-picker/index.jsx +2 -2
  31. package/dist/components/dialog/index.js +1 -1
  32. package/dist/components/dialog/index.jsx +2 -2
  33. package/dist/components/download-trigger/index.jsx +1 -1
  34. package/dist/components/editable/index.js +1 -1
  35. package/dist/components/editable/index.jsx +2 -2
  36. package/dist/components/field/index.jsx +1 -1
  37. package/dist/components/fieldset/index.jsx +1 -1
  38. package/dist/components/file-upload/index.js +1 -1
  39. package/dist/components/file-upload/index.jsx +2 -2
  40. package/dist/components/floating-panel/index.js +1 -1
  41. package/dist/components/floating-panel/index.jsx +2 -3
  42. package/dist/components/format/index.jsx +1 -1
  43. package/dist/components/frame/index.jsx +1 -1
  44. package/dist/components/hover-card/index.js +1 -1
  45. package/dist/components/hover-card/index.jsx +2 -2
  46. package/dist/components/index.js +44 -44
  47. package/dist/components/index.jsx +404 -405
  48. package/dist/components/listbox/index.js +1 -1
  49. package/dist/components/listbox/index.jsx +2 -3
  50. package/dist/components/menu/index.js +1 -1
  51. package/dist/components/menu/index.jsx +2 -2
  52. package/dist/components/number-input/index.js +1 -1
  53. package/dist/components/number-input/index.jsx +2 -2
  54. package/dist/components/pagination/index.js +1 -1
  55. package/dist/components/pagination/index.jsx +2 -2
  56. package/dist/components/password-input/index.js +1 -1
  57. package/dist/components/password-input/index.jsx +2 -3
  58. package/dist/components/pin-input/index.js +1 -1
  59. package/dist/components/pin-input/index.jsx +2 -2
  60. package/dist/components/popover/index.js +1 -1
  61. package/dist/components/popover/index.jsx +2 -2
  62. package/dist/components/progress/index.js +1 -1
  63. package/dist/components/progress/index.jsx +2 -2
  64. package/dist/components/qr-code/index.js +1 -1
  65. package/dist/components/qr-code/index.jsx +2 -2
  66. package/dist/components/radio-group/index.js +1 -1
  67. package/dist/components/radio-group/index.jsx +2 -2
  68. package/dist/components/rating-group/index.js +1 -1
  69. package/dist/components/rating-group/index.jsx +2 -2
  70. package/dist/components/segment-group/index.js +1 -1
  71. package/dist/components/segment-group/index.jsx +2 -2
  72. package/dist/components/select/index.js +1 -1
  73. package/dist/components/select/index.jsx +4 -4
  74. package/dist/components/signature-pad/index.js +1 -1
  75. package/dist/components/signature-pad/index.jsx +2 -2
  76. package/dist/components/slider/index.js +1 -1
  77. package/dist/components/slider/index.jsx +2 -2
  78. package/dist/components/splitter/index.js +1 -1
  79. package/dist/components/splitter/index.jsx +2 -2
  80. package/dist/components/steps/index.js +1 -1
  81. package/dist/components/steps/index.jsx +2 -2
  82. package/dist/components/switch/index.js +1 -1
  83. package/dist/components/switch/index.jsx +2 -2
  84. package/dist/components/tabs/index.js +1 -1
  85. package/dist/components/tabs/index.jsx +2 -2
  86. package/dist/components/tags-input/index.js +1 -1
  87. package/dist/components/tags-input/index.jsx +2 -2
  88. package/dist/components/time-picker/index.js +1 -1
  89. package/dist/components/time-picker/index.jsx +2 -2
  90. package/dist/components/timer/index.jsx +1 -1
  91. package/dist/components/toast/index.js +1 -1
  92. package/dist/components/toast/index.jsx +2 -2
  93. package/dist/components/toggle-group/index.js +1 -1
  94. package/dist/components/toggle-group/index.jsx +2 -2
  95. package/dist/components/tooltip/index.js +1 -1
  96. package/dist/components/tooltip/index.jsx +2 -2
  97. package/dist/components/tour/index.js +1 -1
  98. package/dist/components/tour/index.jsx +2 -2
  99. package/dist/components/tree-view/index.js +1 -1
  100. package/dist/components/tree-view/index.jsx +3 -3
  101. package/dist/index.js +45 -45
  102. package/dist/index.jsx +407 -408
  103. package/dist/providers/index.js +1 -1
  104. package/dist/providers/index.jsx +4 -4
  105. package/package.json +58 -53
  106. package/dist/chunk/4NULU2IK.jsx +0 -1818
  107. package/dist/chunk/A62XIWGT.js +0 -1071
  108. package/dist/chunk/AUU5NNSJ.js +0 -1706
  109. package/dist/chunk/AWEBBQKG.js +0 -352
  110. package/dist/chunk/ETB2BIQZ.jsx +0 -30
  111. package/dist/chunk/KOMUYUJE.jsx +0 -1144
  112. package/dist/chunk/MTT5ESIK.jsx +0 -400
  113. package/dist/chunk/PKUUD527.js +0 -25
  114. package/dist/chunk/{DAORON6X.js → 25PYT2EL.js} +1 -1
  115. package/dist/chunk/{OF23HNNE.js → 4B42LT3B.js} +1 -1
  116. package/dist/chunk/{VQ3I3Z7G.js → 4B53AHD6.js} +1 -1
  117. package/dist/chunk/{XUH2TAUG.jsx → 4L4266PL.jsx} +3 -3
  118. package/dist/chunk/{AKYIM67Z.jsx → 4T2T3PMU.jsx} +3 -3
  119. package/dist/chunk/{I6UGYR2R.js → 4V2VMH2Z.js} +1 -1
  120. package/dist/chunk/{HHGCJUZP.js → 5UKLBKNF.js} +1 -1
  121. package/dist/chunk/{2WR5J3OZ.jsx → 6XAZQVOY.jsx} +3 -3
  122. package/dist/chunk/{WI6PP4EF.js → 74W4D3KY.js} +1 -1
  123. package/dist/chunk/{NQSCRM4A.js → 7E5K2JFP.js} +1 -1
  124. package/dist/chunk/{HP3ZGMDZ.jsx → 7FASJWDK.jsx} +3 -3
  125. package/dist/chunk/{ZTNABPZL.jsx → 7OXBQSIZ.jsx} +3 -3
  126. package/dist/chunk/{YAOPG62Z.jsx → 7RYPC5LL.jsx} +3 -3
  127. package/dist/chunk/{4FUKCXPR.jsx → 7UNWOGPT.jsx} +3 -3
  128. package/dist/chunk/{OKT2RIHV.js → 7YHVIYNP.js} +1 -1
  129. package/dist/chunk/{AD6K3UTR.js → ASBQTDT2.js} +1 -1
  130. package/dist/chunk/{6QX2AKIJ.js → ASEDJSVN.js} +1 -1
  131. package/dist/chunk/{UK24ZAUL.js → CDA7SUTE.js} +1 -1
  132. package/dist/chunk/{35XSFKD5.jsx → CINP4S7J.jsx} +3 -3
  133. package/dist/chunk/{MTVQZNY6.js → D65IYCJS.js} +1 -1
  134. package/dist/chunk/{QSOUO2RW.js → D6MFUKUH.js} +1 -1
  135. package/dist/chunk/{PPQSRJ6X.jsx → DLZTFD37.jsx} +3 -3
  136. package/dist/chunk/{2MXPLL4O.js → EJDY3MNV.js} +1 -1
  137. package/dist/chunk/{4UNGYCFT.jsx → FG427CLW.jsx} +3 -3
  138. package/dist/chunk/{2UVDYZIY.jsx → FOIEK72O.jsx} +3 -3
  139. package/dist/chunk/{WZ75PULC.js → FQGMWBGA.js} +1 -1
  140. package/dist/chunk/{BOR6VUN5.js → GAB5O55Q.js} +1 -1
  141. package/dist/chunk/{HDKSS6KE.jsx → GLN6WFQR.jsx} +3 -3
  142. package/dist/chunk/{WOUVNHGI.jsx → H4MJ4254.jsx} +3 -3
  143. package/dist/chunk/{LORIOKHL.js → HKFF76YQ.js} +1 -1
  144. package/dist/chunk/{3DOPQCHJ.jsx → JK6QXH6B.jsx} +3 -3
  145. package/dist/chunk/{UW5WJ2LL.jsx → JKM73NGJ.jsx} +3 -3
  146. package/dist/chunk/{T7GUEJBF.js → JXJHXSF4.js} +1 -1
  147. package/dist/chunk/{JEPST7BN.jsx → KJ353BY6.jsx} +3 -3
  148. package/dist/chunk/{AUVF4L3Q.jsx → KNVMVQG6.jsx} +3 -3
  149. package/dist/chunk/{72JQEDEW.js → L4PQJRRA.js} +1 -1
  150. package/dist/chunk/{364QFYBV.js → LNLL2OTD.js} +1 -1
  151. package/dist/chunk/{NPHS6PVV.jsx → MJTOTU2A.jsx} +3 -3
  152. package/dist/chunk/{3VOFK5T4.jsx → N3W3K2ZD.jsx} +3 -3
  153. package/dist/chunk/{IWBBR7PD.js → N65DCNIH.js} +1 -1
  154. package/dist/chunk/{4HQIDBKB.js → O5A5KQPC.js} +1 -1
  155. package/dist/chunk/{T4JGZ7KR.js → OA4CU2PL.js} +1 -1
  156. package/dist/chunk/{OKNWZYMH.jsx → OM7DNJ6L.jsx} +3 -3
  157. package/dist/chunk/{JUBTXT4B.jsx → OM7V7VVC.jsx} +3 -3
  158. package/dist/chunk/{H5DXY5W4.js → OVFUGKNG.js} +1 -1
  159. package/dist/chunk/{74TH35IC.js → P7WR6WX5.js} +1 -1
  160. package/dist/chunk/{5U4KEVIU.jsx → PRA2XFQE.jsx} +3 -3
  161. package/dist/chunk/{FJ5JNMAY.js → QJQKZL6X.js} +1 -1
  162. package/dist/chunk/{MM6NNI6M.jsx → QXYWHKF7.jsx} +3 -3
  163. package/dist/chunk/{OPAESICE.js → SFEMNN6F.js} +1 -1
  164. package/dist/chunk/{ROUJC6XC.js → SGY2KGDL.js} +1 -1
  165. package/dist/chunk/{LDOGINY6.js → TECDLRTB.js} +1 -1
  166. package/dist/chunk/{XIT3ASUI.jsx → U7QDCJXT.jsx} +3 -3
  167. package/dist/chunk/{DPP7XCXL.js → UAANHQJZ.js} +1 -1
  168. package/dist/chunk/{3IJ5QLEM.js → UU6XEYFI.js} +1 -1
  169. package/dist/chunk/{QC5C6JJA.jsx → V6S3C3U7.jsx} +3 -3
  170. package/dist/chunk/{LKPEYZZO.jsx → V75EMOIC.jsx} +3 -3
  171. package/dist/chunk/{RVK7FAUI.js → VEV5HF3M.js} +1 -1
  172. package/dist/chunk/{S4OS4UYL.jsx → VXQNQSLM.jsx} +3 -3
  173. package/dist/chunk/{ZNBZTQ46.jsx → WBLWV2L4.jsx} +3 -3
  174. package/dist/chunk/{LB3LJBHI.js → WTNRGPVN.js} +1 -1
  175. package/dist/chunk/{POJRD725.jsx → X5GWQYGE.jsx} +3 -3
  176. package/dist/chunk/{WG67YHCV.jsx → XENPQFEN.jsx} +3 -3
  177. package/dist/chunk/{LRA73ZZJ.js → XQNGFJ2M.js} +1 -1
  178. package/dist/chunk/{N3H47LNB.jsx → XSGHIZ6Q.jsx} +3 -3
  179. package/dist/chunk/{L64MXP66.jsx → Y2LC36B4.jsx} +3 -3
  180. package/dist/chunk/{XKBIT7L5.jsx → YJX4W6VT.jsx} +3 -3
  181. package/dist/chunk/{RC4UV6HP.jsx → YM35RFYG.jsx} +3 -3
  182. package/dist/chunk/{WHXDBQDP.jsx → Z2BXVXSV.jsx} +3 -3
  183. package/dist/chunk/{33DAWPKS.js → ZRSPQAUK.js} +1 -1
@@ -1,1818 +0,0 @@
1
- import {
2
- createGuards,
3
- createMachine
4
- } from "./ETB2BIQZ.jsx";
5
- import {
6
- PresenceProvider,
7
- splitPresenceProps,
8
- usePresence,
9
- usePresenceContext
10
- } from "./WC2HBDLJ.jsx";
11
- import {
12
- createSplitProps
13
- } from "./6WEDGJKQ.jsx";
14
- import {
15
- ark
16
- } from "./UFYZ7HLU.jsx";
17
- import {
18
- useEnvironmentContext
19
- } from "./E2L62MKC.jsx";
20
- import {
21
- useLocaleContext
22
- } from "./YUC6JE7K.jsx";
23
- import {
24
- createContext
25
- } from "./TVCIHLER.jsx";
26
- import {
27
- runIfFn
28
- } from "./KGOB2IMX.jsx";
29
- import {
30
- __export
31
- } from "./7IUG3E2V.jsx";
32
-
33
- // src/components/floating-panel/floating-panel-body.tsx
34
- import { mergeProps } from "@zag-js/solid";
35
-
36
- // src/components/floating-panel/use-floating-panel-context.ts
37
- var [FloatingPanelProvider, useFloatingPanelContext] = createContext({
38
- hookName: "useFloatingPanelContext",
39
- providerName: "<FloatingPanelProvider />"
40
- });
41
-
42
- // src/components/floating-panel/floating-panel-body.tsx
43
- var FloatingPanelBody = (props2) => {
44
- const floatingPanel = useFloatingPanelContext();
45
- const mergedProps = mergeProps(() => floatingPanel().getBodyProps(), props2);
46
- return <ark.div {...mergedProps} />;
47
- };
48
-
49
- // src/components/floating-panel/floating-panel-close-trigger.tsx
50
- import { mergeProps as mergeProps2 } from "@zag-js/solid";
51
- var FloatingPanelCloseTrigger = (props2) => {
52
- const floatingPanel = useFloatingPanelContext();
53
- const mergedProps = mergeProps2(() => floatingPanel().getCloseTriggerProps(), props2);
54
- return <ark.button {...mergedProps} />;
55
- };
56
-
57
- // src/components/floating-panel/floating-panel-content.tsx
58
- import { mergeProps as mergeProps3 } from "@zag-js/solid";
59
- var FloatingPanelContent = (props2) => {
60
- const floatingPanel = useFloatingPanelContext();
61
- const presence = usePresenceContext();
62
- const mergedProps = mergeProps3(
63
- () => floatingPanel().getContentProps(),
64
- () => presence().presenceProps,
65
- props2
66
- );
67
- if (presence().unmounted) {
68
- return null;
69
- }
70
- return <ark.div {...mergedProps} />;
71
- };
72
-
73
- // src/components/floating-panel/floating-panel-context.tsx
74
- var FloatingPanelContext = (props2) => props2.children(useFloatingPanelContext());
75
-
76
- // src/components/floating-panel/floating-panel-drag-trigger.tsx
77
- import { mergeProps as mergeProps4 } from "@zag-js/solid";
78
- var FloatingPanelDragTrigger = (props2) => {
79
- const floatingPanel = useFloatingPanelContext();
80
- const mergedProps = mergeProps4(() => floatingPanel().getDragTriggerProps(), props2);
81
- return <ark.div {...mergedProps} />;
82
- };
83
-
84
- // src/components/floating-panel/floating-panel-header.tsx
85
- import { mergeProps as mergeProps5 } from "@zag-js/solid";
86
- var FloatingPanelHeader = (props2) => {
87
- const floatingPanel = useFloatingPanelContext();
88
- const mergedProps = mergeProps5(() => floatingPanel().getHeaderProps(), props2);
89
- return <ark.div {...mergedProps} />;
90
- };
91
-
92
- // src/components/floating-panel/floating-panel-positioner.tsx
93
- import { mergeProps as mergeProps6 } from "@zag-js/solid";
94
- var FloatingPanelPositioner = (props2) => {
95
- const floatingPanel = useFloatingPanelContext();
96
- const mergedProps = mergeProps6(() => floatingPanel().getPositionerProps(), props2);
97
- const presence = usePresenceContext();
98
- if (presence().unmounted) {
99
- return null;
100
- }
101
- return <ark.div {...mergedProps} />;
102
- };
103
-
104
- // src/components/floating-panel/floating-panel-resize-trigger.tsx
105
- import { mergeProps as mergeProps7 } from "@zag-js/solid";
106
- var FloatingPanelResizeTrigger = (props2) => {
107
- const [resizeProps, localProps] = createSplitProps()(props2, ["axis"]);
108
- const floatingPanel = useFloatingPanelContext();
109
- const mergedProps = mergeProps7(() => floatingPanel().getResizeTriggerProps(resizeProps), localProps);
110
- return <ark.div {...mergedProps} />;
111
- };
112
-
113
- // src/components/floating-panel/floating-panel-stage-trigger.tsx
114
- import { mergeProps as mergeProps8 } from "@zag-js/solid";
115
- var FloatingPanelStageTrigger = (props2) => {
116
- const [stage, localProps] = createSplitProps()(props2, ["stage"]);
117
- const floatingPanel = useFloatingPanelContext();
118
- const mergedProps = mergeProps8(() => floatingPanel().getStageTriggerProps(stage), localProps);
119
- return <ark.button {...mergedProps} />;
120
- };
121
-
122
- // src/components/floating-panel/floating-panel-root.tsx
123
- import { mergeProps as mergeProps9 } from "@zag-js/solid";
124
-
125
- // ../../node_modules/@zag-js/floating-panel/dist/index.mjs
126
- import { createAnatomy } from "@zag-js/anatomy";
127
- import { raf, isHTMLElement, addDomEvent, trackPointerMove, dataAttr, isLeftClick, getEventTarget, isSelfTarget, getEventStep, getEventKey } from "@zag-js/dom-query";
128
-
129
- // ../../node_modules/@zag-js/rect-utils/dist/index.mjs
130
- var __defProp = Object.defineProperty;
131
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
132
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
133
- var AffineTransform = class _AffineTransform {
134
- constructor([m00, m01, m02, m10, m11, m12] = [0, 0, 0, 0, 0, 0]) {
135
- __publicField(this, "m00");
136
- __publicField(this, "m01");
137
- __publicField(this, "m02");
138
- __publicField(this, "m10");
139
- __publicField(this, "m11");
140
- __publicField(this, "m12");
141
- __publicField(this, "rotate", (...args) => {
142
- return this.prepend(_AffineTransform.rotate(...args));
143
- });
144
- __publicField(this, "scale", (...args) => {
145
- return this.prepend(_AffineTransform.scale(...args));
146
- });
147
- __publicField(this, "translate", (...args) => {
148
- return this.prepend(_AffineTransform.translate(...args));
149
- });
150
- this.m00 = m00;
151
- this.m01 = m01;
152
- this.m02 = m02;
153
- this.m10 = m10;
154
- this.m11 = m11;
155
- this.m12 = m12;
156
- }
157
- applyTo(point) {
158
- const { x, y } = point;
159
- const { m00, m01, m02, m10, m11, m12 } = this;
160
- return {
161
- x: m00 * x + m01 * y + m02,
162
- y: m10 * x + m11 * y + m12
163
- };
164
- }
165
- prepend(other) {
166
- return new _AffineTransform([
167
- this.m00 * other.m00 + this.m01 * other.m10,
168
- // m00
169
- this.m00 * other.m01 + this.m01 * other.m11,
170
- // m01
171
- this.m00 * other.m02 + this.m01 * other.m12 + this.m02,
172
- // m02
173
- this.m10 * other.m00 + this.m11 * other.m10,
174
- // m10
175
- this.m10 * other.m01 + this.m11 * other.m11,
176
- // m11
177
- this.m10 * other.m02 + this.m11 * other.m12 + this.m12
178
- // m12
179
- ]);
180
- }
181
- append(other) {
182
- return new _AffineTransform([
183
- other.m00 * this.m00 + other.m01 * this.m10,
184
- // m00
185
- other.m00 * this.m01 + other.m01 * this.m11,
186
- // m01
187
- other.m00 * this.m02 + other.m01 * this.m12 + other.m02,
188
- // m02
189
- other.m10 * this.m00 + other.m11 * this.m10,
190
- // m10
191
- other.m10 * this.m01 + other.m11 * this.m11,
192
- // m11
193
- other.m10 * this.m02 + other.m11 * this.m12 + other.m12
194
- // m12
195
- ]);
196
- }
197
- get determinant() {
198
- return this.m00 * this.m11 - this.m01 * this.m10;
199
- }
200
- get isInvertible() {
201
- const det = this.determinant;
202
- return isFinite(det) && isFinite(this.m02) && isFinite(this.m12) && det !== 0;
203
- }
204
- invert() {
205
- const det = this.determinant;
206
- return new _AffineTransform([
207
- this.m11 / det,
208
- // m00
209
- -this.m01 / det,
210
- // m01
211
- (this.m01 * this.m12 - this.m11 * this.m02) / det,
212
- // m02
213
- -this.m10 / det,
214
- // m10
215
- this.m00 / det,
216
- // m11
217
- (this.m10 * this.m02 - this.m00 * this.m12) / det
218
- // m12
219
- ]);
220
- }
221
- get array() {
222
- return [this.m00, this.m01, this.m02, this.m10, this.m11, this.m12, 0, 0, 1];
223
- }
224
- get float32Array() {
225
- return new Float32Array(this.array);
226
- }
227
- // Static
228
- static get identity() {
229
- return new _AffineTransform([1, 0, 0, 0, 1, 0]);
230
- }
231
- static rotate(theta, origin) {
232
- const rotation = new _AffineTransform([Math.cos(theta), -Math.sin(theta), 0, Math.sin(theta), Math.cos(theta), 0]);
233
- if (origin && (origin.x !== 0 || origin.y !== 0)) {
234
- return _AffineTransform.multiply(
235
- _AffineTransform.translate(origin.x, origin.y),
236
- rotation,
237
- _AffineTransform.translate(-origin.x, -origin.y)
238
- );
239
- }
240
- return rotation;
241
- }
242
- static scale(sx, sy = sx, origin = { x: 0, y: 0 }) {
243
- const scale = new _AffineTransform([sx, 0, 0, 0, sy, 0]);
244
- if (origin.x !== 0 || origin.y !== 0) {
245
- return _AffineTransform.multiply(
246
- _AffineTransform.translate(origin.x, origin.y),
247
- scale,
248
- _AffineTransform.translate(-origin.x, -origin.y)
249
- );
250
- }
251
- return scale;
252
- }
253
- static translate(tx, ty) {
254
- return new _AffineTransform([1, 0, tx, 0, 1, ty]);
255
- }
256
- static multiply(...[first, ...rest]) {
257
- if (!first) return _AffineTransform.identity;
258
- return rest.reduce((result, item) => result.prepend(item), first);
259
- }
260
- get a() {
261
- return this.m00;
262
- }
263
- get b() {
264
- return this.m10;
265
- }
266
- get c() {
267
- return this.m01;
268
- }
269
- get d() {
270
- return this.m11;
271
- }
272
- get tx() {
273
- return this.m02;
274
- }
275
- get ty() {
276
- return this.m12;
277
- }
278
- get scaleComponents() {
279
- return { x: this.a, y: this.d };
280
- }
281
- get translationComponents() {
282
- return { x: this.tx, y: this.ty };
283
- }
284
- get skewComponents() {
285
- return { x: this.c, y: this.b };
286
- }
287
- toString() {
288
- return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
289
- }
290
- };
291
- var clamp = (value, min3, max2) => Math.min(Math.max(value, min3), max2);
292
- var clampPoint = (position, size, boundaryRect) => {
293
- const x = clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width);
294
- const y = clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height);
295
- return { x, y };
296
- };
297
- var defaultMinSize = {
298
- width: 0,
299
- height: 0
300
- };
301
- var defaultMaxSize = {
302
- width: Infinity,
303
- height: Infinity
304
- };
305
- var clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
306
- return {
307
- width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
308
- height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
309
- };
310
- };
311
- var createPoint = (x, y) => ({ x, y });
312
- var subtractPoints = (a, b) => {
313
- if (!b) return a;
314
- return createPoint(a.x - b.x, a.y - b.y);
315
- };
316
- var addPoints = (a, b) => createPoint(a.x + b.x, a.y + b.y);
317
- function createRect(r) {
318
- const { x, y, width, height } = r;
319
- const midX = x + width / 2;
320
- const midY = y + height / 2;
321
- return {
322
- x,
323
- y,
324
- width,
325
- height,
326
- minX: x,
327
- minY: y,
328
- maxX: x + width,
329
- maxY: y + height,
330
- midX,
331
- midY,
332
- center: createPoint(midX, midY)
333
- };
334
- }
335
- var constrainRect = (rect, boundary) => {
336
- const left = Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width));
337
- const top = Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height));
338
- return {
339
- x: left,
340
- y: top,
341
- width: Math.min(rect.width, boundary.width),
342
- height: Math.min(rect.height, boundary.height)
343
- };
344
- };
345
- var isSizeEqual = (a, b) => {
346
- return a.width === b?.width && a.height === b?.height;
347
- };
348
- var isPointEqual = (a, b) => {
349
- return a.x === b?.x && a.y === b?.y;
350
- };
351
- var styleCache = /* @__PURE__ */ new WeakMap();
352
- function getCacheComputedStyle(el) {
353
- if (!styleCache.has(el)) {
354
- const win = el.ownerDocument.defaultView || window;
355
- styleCache.set(el, win.getComputedStyle(el));
356
- }
357
- return styleCache.get(el);
358
- }
359
- function getElementRect(el, opts = {}) {
360
- return createRect(getClientRect(el, opts));
361
- }
362
- function getClientRect(el, opts = {}) {
363
- const { excludeScrollbar = false, excludeBorders = false } = opts;
364
- const { x, y, width, height } = el.getBoundingClientRect();
365
- const r = { x, y, width, height };
366
- const style = getCacheComputedStyle(el);
367
- const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = style;
368
- const borderXWidth = sum(borderLeftWidth, borderRightWidth);
369
- const borderYWidth = sum(borderTopWidth, borderBottomWidth);
370
- if (excludeBorders) {
371
- r.width -= borderXWidth;
372
- r.height -= borderYWidth;
373
- r.x += px(borderLeftWidth);
374
- r.y += px(borderTopWidth);
375
- }
376
- if (excludeScrollbar) {
377
- const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
378
- const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
379
- r.width -= scrollbarWidth;
380
- r.height -= scrollbarHeight;
381
- }
382
- return r;
383
- }
384
- var px = (v) => parseFloat(v.replace("px", ""));
385
- var sum = (...vals) => vals.reduce((sum2, v) => sum2 + (v ? px(v) : 0), 0);
386
- var { min, max } = Math;
387
- function getWindowRect(win, opts = {}) {
388
- return createRect(getViewportRect(win, opts));
389
- }
390
- function getViewportRect(win, opts) {
391
- const { excludeScrollbar = false } = opts;
392
- const { innerWidth, innerHeight, document: doc, visualViewport } = win;
393
- const width = visualViewport?.width || innerWidth;
394
- const height = visualViewport?.height || innerHeight;
395
- const rect = { x: 0, y: 0, width, height };
396
- if (excludeScrollbar) {
397
- const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
398
- const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
399
- rect.width -= scrollbarWidth;
400
- rect.height -= scrollbarHeight;
401
- }
402
- return rect;
403
- }
404
- var compassDirectionMap = {
405
- n: { x: 0.5, y: 0 },
406
- ne: { x: 1, y: 0 },
407
- e: { x: 1, y: 0.5 },
408
- se: { x: 1, y: 1 },
409
- s: { x: 0.5, y: 1 },
410
- sw: { x: 0, y: 1 },
411
- w: { x: 0, y: 0.5 },
412
- nw: { x: 0, y: 0 }
413
- };
414
- var oppositeDirectionMap = {
415
- n: "s",
416
- ne: "sw",
417
- e: "w",
418
- se: "nw",
419
- s: "n",
420
- sw: "ne",
421
- w: "e",
422
- nw: "se"
423
- };
424
- var { sign, abs, min: min2 } = Math;
425
- function getRectExtentPoint(rect, direction) {
426
- const { minX, minY, maxX, maxY, midX, midY } = rect;
427
- const x = direction.includes("w") ? minX : direction.includes("e") ? maxX : midX;
428
- const y = direction.includes("n") ? minY : direction.includes("s") ? maxY : midY;
429
- return { x, y };
430
- }
431
- function getOppositeDirection(direction) {
432
- return oppositeDirectionMap[direction];
433
- }
434
- function resizeRect(rect, offset, direction, opts) {
435
- const { scalingOriginMode, lockAspectRatio } = opts;
436
- const extent = getRectExtentPoint(rect, direction);
437
- const oppositeDirection = getOppositeDirection(direction);
438
- const oppositeExtent = getRectExtentPoint(rect, oppositeDirection);
439
- if (scalingOriginMode === "center") {
440
- offset = { x: offset.x * 2, y: offset.y * 2 };
441
- }
442
- const newExtent = {
443
- x: extent.x + offset.x,
444
- y: extent.y + offset.y
445
- };
446
- const multiplier = {
447
- x: compassDirectionMap[direction].x * 2 - 1,
448
- y: compassDirectionMap[direction].y * 2 - 1
449
- };
450
- const newSize = {
451
- width: newExtent.x - oppositeExtent.x,
452
- height: newExtent.y - oppositeExtent.y
453
- };
454
- const scaleX = multiplier.x * newSize.width / rect.width;
455
- const scaleY = multiplier.y * newSize.height / rect.height;
456
- const largestMagnitude = abs(scaleX) > abs(scaleY) ? scaleX : scaleY;
457
- const scale = lockAspectRatio ? { x: largestMagnitude, y: largestMagnitude } : {
458
- x: extent.x === oppositeExtent.x ? 1 : scaleX,
459
- y: extent.y === oppositeExtent.y ? 1 : scaleY
460
- };
461
- if (extent.y === oppositeExtent.y) {
462
- scale.y = abs(scale.y);
463
- } else if (sign(scale.y) !== sign(scaleY)) {
464
- scale.y *= -1;
465
- }
466
- if (extent.x === oppositeExtent.x) {
467
- scale.x = abs(scale.x);
468
- } else if (sign(scale.x) !== sign(scaleX)) {
469
- scale.x *= -1;
470
- }
471
- switch (scalingOriginMode) {
472
- case "extent":
473
- return transformRect(rect, AffineTransform.scale(scale.x, scale.y, oppositeExtent), false);
474
- case "center":
475
- return transformRect(
476
- rect,
477
- AffineTransform.scale(scale.x, scale.y, {
478
- x: rect.midX,
479
- y: rect.midY
480
- }),
481
- false
482
- );
483
- }
484
- }
485
- function createRectFromPoints(initialPoint, finalPoint, normalized = true) {
486
- if (normalized) {
487
- return {
488
- x: min2(finalPoint.x, initialPoint.x),
489
- y: min2(finalPoint.y, initialPoint.y),
490
- width: abs(finalPoint.x - initialPoint.x),
491
- height: abs(finalPoint.y - initialPoint.y)
492
- };
493
- }
494
- return {
495
- x: initialPoint.x,
496
- y: initialPoint.y,
497
- width: finalPoint.x - initialPoint.x,
498
- height: finalPoint.y - initialPoint.y
499
- };
500
- }
501
- function transformRect(rect, transform, normalized = true) {
502
- const p1 = transform.applyTo({ x: rect.minX, y: rect.minY });
503
- const p2 = transform.applyTo({ x: rect.maxX, y: rect.maxY });
504
- return createRectFromPoints(p1, p2, normalized);
505
- }
506
-
507
- // ../../node_modules/@zag-js/floating-panel/dist/index.mjs
508
- import { invariant, match, pick, clampValue, ensureProps, createSplitProps as createSplitProps2, toPx } from "@zag-js/utils";
509
-
510
- // ../../node_modules/proxy-compare/dist/index.js
511
- var TRACK_MEMO_SYMBOL = Symbol();
512
- var GET_ORIGINAL_SYMBOL = Symbol();
513
- var getProto = Object.getPrototypeOf;
514
- var objectsToTrack = /* @__PURE__ */ new WeakMap();
515
- var isObjectToTrack = (obj) => obj && (objectsToTrack.has(obj) ? objectsToTrack.get(obj) : getProto(obj) === Object.prototype || getProto(obj) === Array.prototype);
516
- var getUntracked = (obj) => {
517
- if (isObjectToTrack(obj)) {
518
- return obj[GET_ORIGINAL_SYMBOL] || null;
519
- }
520
- return null;
521
- };
522
- var markToTrack = (obj, mark = true) => {
523
- objectsToTrack.set(obj, mark);
524
- };
525
-
526
- // ../../node_modules/@zag-js/store/dist/index.mjs
527
- function glob() {
528
- if (typeof globalThis !== "undefined") return globalThis;
529
- if (typeof self !== "undefined") return self;
530
- if (typeof window !== "undefined") return window;
531
- if (typeof global !== "undefined") return global;
532
- }
533
- function globalRef(key, value) {
534
- const g = glob();
535
- if (!g) return value();
536
- g[key] || (g[key] = value());
537
- return g[key];
538
- }
539
- var refSet = globalRef("__zag__refSet", () => /* @__PURE__ */ new WeakSet());
540
- var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
541
- var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
542
- var isDOMElement = (x) => typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeName === "string";
543
- var isElement = (x) => isReactElement(x) || isVueElement(x) || isDOMElement(x);
544
- var isObject = (x) => x !== null && typeof x === "object";
545
- var canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !isElement(x) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer) && !(x instanceof Promise);
546
- var isDev = () => true;
547
- var proxyStateMap = globalRef("__zag__proxyStateMap", () => /* @__PURE__ */ new WeakMap());
548
- var buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version) => {
549
- const cache = snapCache.get(target);
550
- if (cache?.[0] === version) {
551
- return cache[1];
552
- }
553
- const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
554
- markToTrack(snap, true);
555
- snapCache.set(target, [version, snap]);
556
- Reflect.ownKeys(target).forEach((key) => {
557
- const value = Reflect.get(target, key);
558
- if (refSet.has(value)) {
559
- markToTrack(value, false);
560
- snap[key] = value;
561
- } else if (proxyStateMap.has(value)) {
562
- snap[key] = snapshot(value);
563
- } else {
564
- snap[key] = value;
565
- }
566
- });
567
- return Object.freeze(snap);
568
- }, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
569
- if (!isObject(initialObject)) {
570
- throw new Error("object required");
571
- }
572
- const found = proxyCache.get(initialObject);
573
- if (found) {
574
- return found;
575
- }
576
- let version = versionHolder[0];
577
- const listeners = /* @__PURE__ */ new Set();
578
- const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
579
- if (version !== nextVersion) {
580
- version = nextVersion;
581
- listeners.forEach((listener) => listener(op, nextVersion));
582
- }
583
- };
584
- let checkVersion = versionHolder[1];
585
- const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
586
- if (checkVersion !== nextCheckVersion && !listeners.size) {
587
- checkVersion = nextCheckVersion;
588
- propProxyStates.forEach(([propProxyState]) => {
589
- const propVersion = propProxyState[1](nextCheckVersion);
590
- if (propVersion > version) {
591
- version = propVersion;
592
- }
593
- });
594
- }
595
- return version;
596
- };
597
- const createPropListener = (prop) => (op, nextVersion) => {
598
- const newOp = [...op];
599
- newOp[1] = [prop, ...newOp[1]];
600
- notifyUpdate(newOp, nextVersion);
601
- };
602
- const propProxyStates = /* @__PURE__ */ new Map();
603
- const addPropListener = (prop, propProxyState) => {
604
- if (isDev() && propProxyStates.has(prop)) {
605
- throw new Error("prop listener already exists");
606
- }
607
- if (listeners.size) {
608
- const remove = propProxyState[3](createPropListener(prop));
609
- propProxyStates.set(prop, [propProxyState, remove]);
610
- } else {
611
- propProxyStates.set(prop, [propProxyState]);
612
- }
613
- };
614
- const removePropListener = (prop) => {
615
- const entry = propProxyStates.get(prop);
616
- if (entry) {
617
- propProxyStates.delete(prop);
618
- entry[1]?.();
619
- }
620
- };
621
- const addListener = (listener) => {
622
- listeners.add(listener);
623
- if (listeners.size === 1) {
624
- propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
625
- if (isDev() && prevRemove) {
626
- throw new Error("remove already exists");
627
- }
628
- const remove = propProxyState[3](createPropListener(prop));
629
- propProxyStates.set(prop, [propProxyState, remove]);
630
- });
631
- }
632
- const removeListener = () => {
633
- listeners.delete(listener);
634
- if (listeners.size === 0) {
635
- propProxyStates.forEach(([propProxyState, remove], prop) => {
636
- if (remove) {
637
- remove();
638
- propProxyStates.set(prop, [propProxyState]);
639
- }
640
- });
641
- }
642
- };
643
- return removeListener;
644
- };
645
- const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
646
- const handler = {
647
- deleteProperty(target, prop) {
648
- const prevValue = Reflect.get(target, prop);
649
- removePropListener(prop);
650
- const deleted = Reflect.deleteProperty(target, prop);
651
- if (deleted) {
652
- notifyUpdate(["delete", [prop], prevValue]);
653
- }
654
- return deleted;
655
- },
656
- set(target, prop, value, receiver) {
657
- const hasPrevValue = Reflect.has(target, prop);
658
- const prevValue = Reflect.get(target, prop, receiver);
659
- if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
660
- return true;
661
- }
662
- removePropListener(prop);
663
- if (isObject(value)) {
664
- value = getUntracked(value) || value;
665
- }
666
- let nextValue = value;
667
- if (Object.getOwnPropertyDescriptor(target, prop)?.set) ;
668
- else {
669
- if (!proxyStateMap.has(value) && canProxy(value)) {
670
- nextValue = proxy(value);
671
- }
672
- const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
673
- if (childProxyState) {
674
- addPropListener(prop, childProxyState);
675
- }
676
- }
677
- Reflect.set(target, prop, nextValue, receiver);
678
- notifyUpdate(["set", [prop], value, prevValue]);
679
- return true;
680
- }
681
- };
682
- const proxyObject = newProxy(baseObject, handler);
683
- proxyCache.set(initialObject, proxyObject);
684
- const proxyState = [baseObject, ensureVersion, createSnapshot, addListener];
685
- proxyStateMap.set(proxyObject, proxyState);
686
- Reflect.ownKeys(initialObject).forEach((key) => {
687
- const desc = Object.getOwnPropertyDescriptor(initialObject, key);
688
- if (desc.get || desc.set) {
689
- Object.defineProperty(baseObject, key, desc);
690
- } else {
691
- proxyObject[key] = initialObject[key];
692
- }
693
- });
694
- return proxyObject;
695
- }) => [
696
- // public functions
697
- proxyFunction2,
698
- // shared state
699
- proxyStateMap,
700
- refSet,
701
- // internal things
702
- objectIs,
703
- newProxy,
704
- canProxy,
705
- snapCache,
706
- createSnapshot,
707
- proxyCache,
708
- versionHolder
709
- ];
710
- var [proxyFunction] = buildProxyFunction();
711
- function proxy(initialObject = {}) {
712
- return proxyFunction(initialObject);
713
- }
714
- function subscribe(proxyObject, callback, notifyInSync) {
715
- const proxyState = proxyStateMap.get(proxyObject);
716
- if (isDev() && !proxyState) {
717
- }
718
- let promise;
719
- const ops = [];
720
- const addListener = proxyState[3];
721
- let isListenerActive = false;
722
- const listener = (op) => {
723
- ops.push(op);
724
- if (notifyInSync) {
725
- callback(ops.splice(0));
726
- return;
727
- }
728
- if (!promise) {
729
- promise = Promise.resolve().then(() => {
730
- promise = void 0;
731
- if (isListenerActive) {
732
- callback(ops.splice(0));
733
- }
734
- });
735
- }
736
- };
737
- const removeListener = addListener(listener);
738
- isListenerActive = true;
739
- return () => {
740
- isListenerActive = false;
741
- removeListener();
742
- };
743
- }
744
- function snapshot(proxyObject) {
745
- const proxyState = proxyStateMap.get(proxyObject);
746
- if (isDev() && !proxyState) {
747
- }
748
- const [target, ensureVersion, createSnapshot] = proxyState;
749
- return createSnapshot(target, ensureVersion());
750
- }
751
-
752
- // ../../node_modules/@zag-js/floating-panel/dist/index.mjs
753
- import { createProps } from "@zag-js/types";
754
- var anatomy = createAnatomy("floating-panel").parts(
755
- "trigger",
756
- "positioner",
757
- "content",
758
- "header",
759
- "body",
760
- "title",
761
- "resizeTrigger",
762
- "dragTrigger",
763
- "stageTrigger",
764
- "closeTrigger",
765
- "control"
766
- );
767
- var parts = anatomy.build();
768
- var getTriggerId = (ctx) => ctx.ids?.trigger ?? `float:${ctx.id}:trigger`;
769
- var getPositionerId = (ctx) => ctx.ids?.positioner ?? `float:${ctx.id}:positioner`;
770
- var getContentId = (ctx) => ctx.ids?.content ?? `float:${ctx.id}:content`;
771
- var getTitleId = (ctx) => ctx.ids?.title ?? `float:${ctx.id}:title`;
772
- var getHeaderId = (ctx) => ctx.ids?.header ?? `float:${ctx.id}:header`;
773
- var getTriggerEl = (ctx) => ctx.getById(getTriggerId(ctx));
774
- var getPositionerEl = (ctx) => ctx.getById(getPositionerId(ctx));
775
- var getContentEl = (ctx) => ctx.getById(getContentId(ctx));
776
- var getHeaderEl = (ctx) => ctx.getById(getHeaderId(ctx));
777
- var getBoundaryRect = (ctx, boundaryEl, allowOverflow) => {
778
- let boundaryRect;
779
- if (isHTMLElement(boundaryEl)) {
780
- boundaryRect = getElementRect(boundaryEl);
781
- } else {
782
- boundaryRect = getWindowRect(ctx.getWin());
783
- }
784
- if (allowOverflow) {
785
- boundaryRect = createRect({
786
- x: -boundaryRect.width,
787
- // empty(left)
788
- y: boundaryRect.minY,
789
- width: boundaryRect.width * 3,
790
- // empty(left) + win + empty(right)
791
- height: boundaryRect.height * 2
792
- // win + empty(bottom)
793
- });
794
- }
795
- return pick(boundaryRect, ["x", "y", "width", "height"]);
796
- };
797
- function getResizeAxisStyle(axis) {
798
- switch (axis) {
799
- case "n":
800
- return {
801
- cursor: "n-resize",
802
- width: "100%",
803
- left: "50%",
804
- translate: "-50%"
805
- };
806
- case "e":
807
- return {
808
- cursor: "e-resize",
809
- height: "100%",
810
- right: 0,
811
- top: "50%",
812
- translate: "0 -50%"
813
- };
814
- case "s":
815
- return {
816
- cursor: "s-resize",
817
- width: "100%",
818
- bottom: 0,
819
- left: "50%",
820
- translate: "-50%"
821
- };
822
- case "w":
823
- return {
824
- cursor: "w-resize",
825
- height: "100%",
826
- left: 0,
827
- top: "50%",
828
- translate: "0 -50%"
829
- };
830
- case "se":
831
- return {
832
- cursor: "se-resize",
833
- bottom: 0,
834
- right: 0
835
- };
836
- case "sw":
837
- return {
838
- cursor: "sw-resize",
839
- bottom: 0,
840
- left: 0
841
- };
842
- case "ne":
843
- return {
844
- cursor: "ne-resize",
845
- top: 0,
846
- right: 0
847
- };
848
- case "nw":
849
- return {
850
- cursor: "nw-resize",
851
- top: 0,
852
- left: 0
853
- };
854
- default:
855
- throw new Error(`Invalid axis: ${axis}`);
856
- }
857
- }
858
- var validStages = /* @__PURE__ */ new Set(["minimized", "maximized", "default"]);
859
- function connect(service, normalize) {
860
- const { state, send, scope, prop, computed, context } = service;
861
- const open = state.hasTag("open");
862
- const dragging = state.matches("open.dragging");
863
- const resizing = state.matches("open.resizing");
864
- const isTopmost = context.get("isTopmost");
865
- const size = context.get("size");
866
- const position = context.get("position");
867
- const isMaximized = computed("isMaximized");
868
- const isMinimized = computed("isMinimized");
869
- const isStaged = computed("isStaged");
870
- const canResize = computed("canResize");
871
- const canDrag = computed("canDrag");
872
- return {
873
- open,
874
- resizable: prop("resizable"),
875
- draggable: prop("draggable"),
876
- setOpen(nextOpen) {
877
- const open2 = state.hasTag("open");
878
- if (open2 === nextOpen) return;
879
- send({ type: nextOpen ? "OPEN" : "CLOSE" });
880
- },
881
- dragging,
882
- resizing,
883
- position,
884
- size,
885
- setPosition(position2) {
886
- send({ type: "SET_POSITION", position: position2 });
887
- },
888
- setSize(size2) {
889
- send({ type: "SET_SIZE", size: size2 });
890
- },
891
- minimize() {
892
- send({ type: "MINIMIZE" });
893
- },
894
- maximize() {
895
- send({ type: "MAXIMIZE" });
896
- },
897
- restore() {
898
- send({ type: "RESTORE" });
899
- },
900
- getTriggerProps() {
901
- return normalize.button({
902
- ...parts.trigger.attrs,
903
- type: "button",
904
- disabled: prop("disabled"),
905
- id: getTriggerId(scope),
906
- "data-state": open ? "open" : "closed",
907
- "data-dragging": dataAttr(dragging),
908
- "aria-controls": getContentId(scope),
909
- onClick(event) {
910
- if (event.defaultPrevented) return;
911
- if (prop("disabled")) return;
912
- const open2 = state.hasTag("open");
913
- send({ type: open2 ? "CLOSE" : "OPEN", src: "trigger" });
914
- }
915
- });
916
- },
917
- getPositionerProps() {
918
- return normalize.element({
919
- ...parts.positioner.attrs,
920
- id: getPositionerId(scope),
921
- style: {
922
- "--width": toPx(size?.width),
923
- "--height": toPx(size?.height),
924
- "--x": toPx(position?.x),
925
- "--y": toPx(position?.y),
926
- position: prop("strategy"),
927
- top: "var(--y)",
928
- left: "var(--x)"
929
- }
930
- });
931
- },
932
- getContentProps() {
933
- return normalize.element({
934
- ...parts.content.attrs,
935
- role: "dialog",
936
- tabIndex: 0,
937
- hidden: !open,
938
- id: getContentId(scope),
939
- "aria-labelledby": getTitleId(scope),
940
- "data-state": open ? "open" : "closed",
941
- "data-dragging": dataAttr(dragging),
942
- "data-topmost": dataAttr(isTopmost),
943
- "data-behind": dataAttr(!isTopmost),
944
- style: {
945
- width: "var(--width)",
946
- height: "var(--height)",
947
- overflow: isMinimized ? "hidden" : void 0
948
- },
949
- onFocus() {
950
- send({ type: "CONTENT_FOCUS" });
951
- },
952
- onKeyDown(event) {
953
- if (event.defaultPrevented) return;
954
- if (!isSelfTarget(event)) return;
955
- const step = getEventStep(event) * prop("gridSize");
956
- const keyMap = {
957
- Escape() {
958
- if (!isTopmost) return;
959
- send({ type: "ESCAPE" });
960
- },
961
- ArrowLeft() {
962
- send({ type: "MOVE", direction: "left", step });
963
- },
964
- ArrowRight() {
965
- send({ type: "MOVE", direction: "right", step });
966
- },
967
- ArrowUp() {
968
- send({ type: "MOVE", direction: "up", step });
969
- },
970
- ArrowDown() {
971
- send({ type: "MOVE", direction: "down", step });
972
- }
973
- };
974
- const handler = keyMap[getEventKey(event, { dir: prop("dir") })];
975
- if (handler) {
976
- event.preventDefault();
977
- handler(event);
978
- }
979
- }
980
- });
981
- },
982
- getCloseTriggerProps() {
983
- return normalize.button({
984
- ...parts.closeTrigger.attrs,
985
- disabled: prop("disabled"),
986
- "aria-label": "Close Window",
987
- type: "button",
988
- onClick(event) {
989
- if (event.defaultPrevented) return;
990
- send({ type: "CLOSE" });
991
- }
992
- });
993
- },
994
- getStageTriggerProps(props2) {
995
- if (!validStages.has(props2.stage)) {
996
- throw new Error(`[zag-js] Invalid stage: ${props2.stage}. Must be one of: ${Array.from(validStages).join(", ")}`);
997
- }
998
- const translations = prop("translations");
999
- const actionProps = match(props2.stage, {
1000
- minimized: () => ({
1001
- "aria-label": translations.minimize,
1002
- hidden: isStaged
1003
- }),
1004
- maximized: () => ({
1005
- "aria-label": translations.maximize,
1006
- hidden: isStaged
1007
- }),
1008
- default: () => ({
1009
- "aria-label": translations.restore,
1010
- hidden: !isStaged
1011
- })
1012
- });
1013
- return normalize.button({
1014
- ...parts.stageTrigger.attrs,
1015
- disabled: prop("disabled"),
1016
- ...actionProps,
1017
- type: "button",
1018
- onClick(event) {
1019
- if (event.defaultPrevented) return;
1020
- const type = match(props2.stage, {
1021
- minimized: () => "MINIMIZE",
1022
- maximized: () => "MAXIMIZE",
1023
- default: () => "RESTORE"
1024
- });
1025
- send({ type: type.toUpperCase() });
1026
- }
1027
- });
1028
- },
1029
- getResizeTriggerProps(props2) {
1030
- return normalize.element({
1031
- ...parts.resizeTrigger.attrs,
1032
- "data-disabled": dataAttr(!canResize),
1033
- "data-axis": props2.axis,
1034
- onPointerDown(event) {
1035
- if (!canResize) return;
1036
- if (!isLeftClick(event)) return;
1037
- event.currentTarget.setPointerCapture(event.pointerId);
1038
- event.stopPropagation();
1039
- send({
1040
- type: "RESIZE_START",
1041
- axis: props2.axis,
1042
- position: { x: event.clientX, y: event.clientY }
1043
- });
1044
- },
1045
- onPointerUp(event) {
1046
- if (!canResize) return;
1047
- const node = event.currentTarget;
1048
- if (node.hasPointerCapture(event.pointerId)) {
1049
- node.releasePointerCapture(event.pointerId);
1050
- }
1051
- },
1052
- style: {
1053
- position: "absolute",
1054
- touchAction: "none",
1055
- ...getResizeAxisStyle(props2.axis)
1056
- }
1057
- });
1058
- },
1059
- getDragTriggerProps() {
1060
- return normalize.element({
1061
- ...parts.dragTrigger.attrs,
1062
- "data-disabled": dataAttr(!canDrag),
1063
- onPointerDown(event) {
1064
- if (!canDrag) return;
1065
- if (!isLeftClick(event)) return;
1066
- const target = getEventTarget(event);
1067
- if (target?.closest("button") || target?.closest("[data-no-drag]")) {
1068
- return;
1069
- }
1070
- event.currentTarget.setPointerCapture(event.pointerId);
1071
- event.stopPropagation();
1072
- send({
1073
- type: "DRAG_START",
1074
- pointerId: event.pointerId,
1075
- position: { x: event.clientX, y: event.clientY }
1076
- });
1077
- },
1078
- onPointerUp(event) {
1079
- if (!canDrag) return;
1080
- const node = event.currentTarget;
1081
- if (node.hasPointerCapture(event.pointerId)) {
1082
- node.releasePointerCapture(event.pointerId);
1083
- }
1084
- },
1085
- onDoubleClick() {
1086
- send({ type: isMaximized ? "RESTORE" : "MAXIMIZE" });
1087
- },
1088
- style: {
1089
- WebkitUserSelect: "none",
1090
- userSelect: "none",
1091
- touchAction: "none",
1092
- cursor: "move"
1093
- }
1094
- });
1095
- },
1096
- getControlProps() {
1097
- return normalize.element({
1098
- ...parts.control.attrs,
1099
- "data-disabled": dataAttr(prop("disabled")),
1100
- "data-stage": context.get("stage")
1101
- });
1102
- },
1103
- getTitleProps() {
1104
- return normalize.element({
1105
- ...parts.title.attrs,
1106
- id: getTitleId(scope)
1107
- });
1108
- },
1109
- getHeaderProps() {
1110
- return normalize.element({
1111
- ...parts.header.attrs,
1112
- id: getHeaderId(scope),
1113
- "data-dragging": dataAttr(dragging),
1114
- "data-topmost": dataAttr(isTopmost),
1115
- "data-behind": dataAttr(!isTopmost)
1116
- });
1117
- },
1118
- getBodyProps() {
1119
- return normalize.element({
1120
- ...parts.body.attrs,
1121
- "data-dragging": dataAttr(dragging),
1122
- hidden: isMinimized
1123
- });
1124
- }
1125
- };
1126
- }
1127
- var panelStack = proxy({
1128
- stack: [],
1129
- count() {
1130
- return this.stack.length;
1131
- },
1132
- add(panelId) {
1133
- if (this.stack.includes(panelId)) return;
1134
- this.stack.push(panelId);
1135
- },
1136
- remove(panelId) {
1137
- const index = this.stack.indexOf(panelId);
1138
- if (index < 0) return;
1139
- this.stack.splice(index, 1);
1140
- },
1141
- bringToFront(id) {
1142
- this.remove(id);
1143
- this.add(id);
1144
- },
1145
- isTopmost(id) {
1146
- return this.stack[this.stack.length - 1] === id;
1147
- },
1148
- indexOf(id) {
1149
- return this.stack.indexOf(id);
1150
- }
1151
- });
1152
- var { not, and } = createGuards();
1153
- var defaultTranslations = {
1154
- minimize: "Minimize window",
1155
- maximize: "Maximize window",
1156
- restore: "Restore window"
1157
- };
1158
- var machine = createMachine({
1159
- props({ props: props2 }) {
1160
- ensureProps(props2, ["id"], "floating-panel");
1161
- return {
1162
- strategy: "fixed",
1163
- gridSize: 1,
1164
- defaultSize: { width: 320, height: 240 },
1165
- defaultPosition: { x: 300, y: 100 },
1166
- allowOverflow: true,
1167
- resizable: true,
1168
- draggable: true,
1169
- ...props2,
1170
- hasSpecifiedPosition: !!props2.defaultPosition || !!props2.position,
1171
- translations: {
1172
- ...defaultTranslations,
1173
- ...props2.translations
1174
- }
1175
- };
1176
- },
1177
- initialState({ prop }) {
1178
- const open = prop("open") || prop("defaultOpen");
1179
- return open ? "open" : "closed";
1180
- },
1181
- context({ prop, bindable }) {
1182
- return {
1183
- size: bindable(() => ({
1184
- defaultValue: prop("defaultSize"),
1185
- value: prop("size"),
1186
- isEqual: isSizeEqual,
1187
- sync: true,
1188
- hash(v) {
1189
- return `W:${v.width} H:${v.height}`;
1190
- },
1191
- onChange(value) {
1192
- prop("onSizeChange")?.({ size: value });
1193
- }
1194
- })),
1195
- position: bindable(() => ({
1196
- defaultValue: prop("defaultPosition"),
1197
- value: prop("position"),
1198
- isEqual: isPointEqual,
1199
- sync: true,
1200
- hash(v) {
1201
- return `X:${v.x} Y:${v.y}`;
1202
- },
1203
- onChange(value) {
1204
- prop("onPositionChange")?.({ position: value });
1205
- }
1206
- })),
1207
- stage: bindable(() => ({
1208
- defaultValue: "default",
1209
- onChange(value) {
1210
- prop("onStageChange")?.({ stage: value });
1211
- }
1212
- })),
1213
- lastEventPosition: bindable(() => ({
1214
- defaultValue: null
1215
- })),
1216
- prevPosition: bindable(() => ({
1217
- defaultValue: null
1218
- })),
1219
- prevSize: bindable(() => ({
1220
- defaultValue: null
1221
- })),
1222
- isTopmost: bindable(() => ({
1223
- defaultValue: void 0
1224
- }))
1225
- };
1226
- },
1227
- computed: {
1228
- isMaximized: ({ context }) => context.get("stage") === "maximized",
1229
- isMinimized: ({ context }) => context.get("stage") === "minimized",
1230
- isStaged: ({ context }) => context.get("stage") !== "default",
1231
- canResize: ({ context, prop }) => (prop("resizable") || !prop("disabled")) && context.get("stage") === "default",
1232
- canDrag: ({ prop, computed }) => (prop("draggable") || !prop("disabled")) && !computed("isMaximized")
1233
- },
1234
- watch({ track, context, action, prop }) {
1235
- track([() => context.hash("position")], () => {
1236
- action(["setPositionStyle"]);
1237
- });
1238
- track([() => context.hash("size")], () => {
1239
- action(["setSizeStyle"]);
1240
- });
1241
- track([() => prop("open")], () => {
1242
- action(["toggleVisibility"]);
1243
- });
1244
- },
1245
- effects: ["trackPanelStack"],
1246
- on: {
1247
- CONTENT_FOCUS: {
1248
- actions: ["bringToFrontOfPanelStack"]
1249
- },
1250
- SET_POSITION: {
1251
- actions: ["setPosition"]
1252
- },
1253
- SET_SIZE: {
1254
- actions: ["setSize"]
1255
- }
1256
- },
1257
- states: {
1258
- closed: {
1259
- tags: ["closed"],
1260
- on: {
1261
- "CONTROLLED.OPEN": {
1262
- target: "open",
1263
- actions: ["setAnchorPosition", "setPositionStyle", "setSizeStyle", "focusContentEl"]
1264
- },
1265
- OPEN: [
1266
- {
1267
- guard: "isOpenControlled",
1268
- actions: ["invokeOnOpen"]
1269
- },
1270
- {
1271
- target: "open",
1272
- actions: ["invokeOnOpen", "setAnchorPosition", "setPositionStyle", "setSizeStyle", "focusContentEl"]
1273
- }
1274
- ]
1275
- }
1276
- },
1277
- open: {
1278
- tags: ["open"],
1279
- entry: ["bringToFrontOfPanelStack"],
1280
- effects: ["trackBoundaryRect"],
1281
- on: {
1282
- DRAG_START: {
1283
- guard: not("isMaximized"),
1284
- target: "open.dragging",
1285
- actions: ["setPrevPosition"]
1286
- },
1287
- RESIZE_START: {
1288
- guard: not("isMinimized"),
1289
- target: "open.resizing",
1290
- actions: ["setPrevSize"]
1291
- },
1292
- "CONTROLLED.CLOSE": {
1293
- target: "closed",
1294
- actions: ["resetRect", "focusTriggerEl"]
1295
- },
1296
- CLOSE: [
1297
- {
1298
- guard: "isOpenControlled",
1299
- target: "closed",
1300
- actions: ["invokeOnClose"]
1301
- },
1302
- {
1303
- target: "closed",
1304
- actions: ["invokeOnClose", "resetRect", "focusTriggerEl"]
1305
- }
1306
- ],
1307
- ESCAPE: [
1308
- {
1309
- guard: and("isOpenControlled", "closeOnEsc"),
1310
- actions: ["invokeOnClose"]
1311
- },
1312
- {
1313
- guard: "closeOnEsc",
1314
- target: "closed",
1315
- actions: ["invokeOnClose", "resetRect", "focusTriggerEl"]
1316
- }
1317
- ],
1318
- MINIMIZE: {
1319
- actions: ["setMinimized"]
1320
- },
1321
- MAXIMIZE: {
1322
- actions: ["setMaximized"]
1323
- },
1324
- RESTORE: {
1325
- actions: ["setRestored"]
1326
- },
1327
- MOVE: {
1328
- actions: ["setPositionFromKeyboard"]
1329
- }
1330
- }
1331
- },
1332
- "open.dragging": {
1333
- tags: ["open"],
1334
- effects: ["trackPointerMove"],
1335
- exit: ["clearPrevPosition"],
1336
- on: {
1337
- DRAG: {
1338
- actions: ["setPosition"]
1339
- },
1340
- DRAG_END: {
1341
- target: "open",
1342
- actions: ["invokeOnDragEnd"]
1343
- },
1344
- "CONTROLLED.CLOSE": {
1345
- target: "closed",
1346
- actions: ["resetRect"]
1347
- },
1348
- CLOSE: [
1349
- {
1350
- guard: "isOpenControlled",
1351
- target: "closed",
1352
- actions: ["invokeOnClose"]
1353
- },
1354
- {
1355
- target: "closed",
1356
- actions: ["invokeOnClose", "resetRect"]
1357
- }
1358
- ],
1359
- ESCAPE: {
1360
- target: "open"
1361
- }
1362
- }
1363
- },
1364
- "open.resizing": {
1365
- tags: ["open"],
1366
- effects: ["trackPointerMove"],
1367
- exit: ["clearPrevSize"],
1368
- on: {
1369
- DRAG: {
1370
- actions: ["setSize"]
1371
- },
1372
- DRAG_END: {
1373
- target: "open",
1374
- actions: ["invokeOnResizeEnd"]
1375
- },
1376
- "CONTROLLED.CLOSE": {
1377
- target: "closed",
1378
- actions: ["resetRect"]
1379
- },
1380
- CLOSE: [
1381
- {
1382
- guard: "isOpenControlled",
1383
- target: "closed",
1384
- actions: ["invokeOnClose"]
1385
- },
1386
- {
1387
- target: "closed",
1388
- actions: ["invokeOnClose", "resetRect"]
1389
- }
1390
- ],
1391
- ESCAPE: {
1392
- target: "open"
1393
- }
1394
- }
1395
- }
1396
- },
1397
- implementations: {
1398
- guards: {
1399
- closeOnEsc: ({ prop }) => !!prop("closeOnEscape"),
1400
- isMaximized: ({ context }) => context.get("stage") === "maximized",
1401
- isMinimized: ({ context }) => context.get("stage") === "minimized",
1402
- isOpenControlled: ({ prop }) => prop("open") != void 0
1403
- },
1404
- effects: {
1405
- trackPointerMove({ scope, send, event: evt, prop }) {
1406
- const doc = scope.getDoc();
1407
- const boundaryEl = prop("getBoundaryEl")?.();
1408
- const boundaryRect = getBoundaryRect(scope, boundaryEl, false);
1409
- return trackPointerMove(doc, {
1410
- onPointerMove({ point, event }) {
1411
- const { altKey, shiftKey } = event;
1412
- let x = clampValue(point.x, boundaryRect.x, boundaryRect.x + boundaryRect.width);
1413
- let y = clampValue(point.y, boundaryRect.y, boundaryRect.y + boundaryRect.height);
1414
- send({ type: "DRAG", position: { x, y }, axis: evt.axis, altKey, shiftKey });
1415
- },
1416
- onPointerUp() {
1417
- send({ type: "DRAG_END" });
1418
- }
1419
- });
1420
- },
1421
- trackBoundaryRect({ context, scope, prop, computed }) {
1422
- const win = scope.getWin();
1423
- let skip = true;
1424
- const exec = () => {
1425
- if (skip) {
1426
- skip = false;
1427
- return;
1428
- }
1429
- const boundaryEl2 = prop("getBoundaryEl")?.();
1430
- let boundaryRect = getBoundaryRect(scope, boundaryEl2, false);
1431
- if (!computed("isMaximized")) {
1432
- const rect = { ...context.get("position"), ...context.get("size") };
1433
- boundaryRect = constrainRect(rect, boundaryRect);
1434
- }
1435
- context.set("size", pick(boundaryRect, ["width", "height"]));
1436
- context.set("position", pick(boundaryRect, ["x", "y"]));
1437
- };
1438
- const boundaryEl = prop("getBoundaryEl")?.();
1439
- if (isHTMLElement(boundaryEl)) {
1440
- const obs = new win.ResizeObserver(exec);
1441
- obs.observe(boundaryEl);
1442
- return () => obs.disconnect();
1443
- }
1444
- return addDomEvent(win, "resize", exec);
1445
- },
1446
- trackPanelStack({ context, scope }) {
1447
- const unsub = subscribe(panelStack, () => {
1448
- context.set("isTopmost", panelStack.isTopmost(scope.id));
1449
- const contentEl = getContentEl(scope);
1450
- if (!contentEl) return;
1451
- const index = panelStack.indexOf(scope.id);
1452
- if (index === -1) return;
1453
- contentEl.style.setProperty("--z-index", `${index + 1}`);
1454
- });
1455
- return () => {
1456
- panelStack.remove(scope.id);
1457
- unsub();
1458
- };
1459
- }
1460
- },
1461
- actions: {
1462
- setAnchorPosition({ context, prop, scope }) {
1463
- if (prop("hasSpecifiedPosition")) return;
1464
- const hasPrevRect = context.get("prevPosition") || context.get("prevSize");
1465
- if (prop("persistRect") && hasPrevRect) return;
1466
- raf(() => {
1467
- const triggerRect = getTriggerEl(scope);
1468
- const boundaryRect = getBoundaryRect(scope, prop("getBoundaryEl")?.(), false);
1469
- let anchorPosition = prop("getAnchorPosition")?.({
1470
- triggerRect: triggerRect ? DOMRect.fromRect(getElementRect(triggerRect)) : null,
1471
- boundaryRect: DOMRect.fromRect(boundaryRect)
1472
- });
1473
- if (!anchorPosition) {
1474
- const size = context.get("size");
1475
- anchorPosition = {
1476
- x: boundaryRect.x + (boundaryRect.width - size.width) / 2,
1477
- y: boundaryRect.y + (boundaryRect.height - size.height) / 2
1478
- };
1479
- }
1480
- if (!anchorPosition) return;
1481
- context.set("position", anchorPosition);
1482
- });
1483
- },
1484
- setPrevPosition({ context, event }) {
1485
- context.set("prevPosition", { ...context.get("position") });
1486
- context.set("lastEventPosition", event.position);
1487
- },
1488
- clearPrevPosition({ context, prop }) {
1489
- if (!prop("persistRect")) context.set("prevPosition", null);
1490
- context.set("lastEventPosition", null);
1491
- },
1492
- setPosition({ context, event, prop, scope }) {
1493
- let diff = subtractPoints(event.position, context.get("lastEventPosition"));
1494
- diff.x = Math.round(diff.x / prop("gridSize")) * prop("gridSize");
1495
- diff.y = Math.round(diff.y / prop("gridSize")) * prop("gridSize");
1496
- const prevPosition = context.get("prevPosition");
1497
- if (!prevPosition) return;
1498
- let position = addPoints(prevPosition, diff);
1499
- const boundaryEl = prop("getBoundaryEl")?.();
1500
- const boundaryRect = getBoundaryRect(scope, boundaryEl, prop("allowOverflow"));
1501
- position = clampPoint(position, context.get("size"), boundaryRect);
1502
- context.set("position", position);
1503
- },
1504
- setPositionStyle({ scope, context }) {
1505
- const el = getPositionerEl(scope);
1506
- const position = context.get("position");
1507
- el?.style.setProperty("--x", `${position.x}px`);
1508
- el?.style.setProperty("--y", `${position.y}px`);
1509
- },
1510
- resetRect({ context, prop }) {
1511
- context.set("stage", "default");
1512
- if (!prop("persistRect")) {
1513
- context.set("position", context.initial("position"));
1514
- context.set("size", context.initial("size"));
1515
- }
1516
- },
1517
- setPrevSize({ context, event }) {
1518
- context.set("prevSize", { ...context.get("size") });
1519
- context.set("prevPosition", { ...context.get("position") });
1520
- context.set("lastEventPosition", event.position);
1521
- },
1522
- clearPrevSize({ context }) {
1523
- context.set("prevSize", null);
1524
- context.set("prevPosition", null);
1525
- context.set("lastEventPosition", null);
1526
- },
1527
- setSize({ context, event, scope, prop }) {
1528
- const prevSize = context.get("prevSize");
1529
- const prevPosition = context.get("prevPosition");
1530
- const lastEventPosition = context.get("lastEventPosition");
1531
- if (!prevSize || !prevPosition || !lastEventPosition) return;
1532
- const prevRect = createRect({ ...prevPosition, ...prevSize });
1533
- const offset = subtractPoints(event.position, lastEventPosition);
1534
- const nextRect = resizeRect(prevRect, offset, event.axis, {
1535
- scalingOriginMode: event.altKey ? "center" : "extent",
1536
- lockAspectRatio: !!prop("lockAspectRatio") || event.shiftKey
1537
- });
1538
- let nextSize = pick(nextRect, ["width", "height"]);
1539
- let nextPosition = pick(nextRect, ["x", "y"]);
1540
- const boundaryEl = prop("getBoundaryEl")?.();
1541
- const boundaryRect = getBoundaryRect(scope, boundaryEl, false);
1542
- nextSize = clampSize(nextSize, prop("minSize"), prop("maxSize"));
1543
- nextSize = clampSize(nextSize, prop("minSize"), boundaryRect);
1544
- context.set("size", nextSize);
1545
- if (nextPosition) {
1546
- const point = clampPoint(nextPosition, nextSize, boundaryRect);
1547
- context.set("position", point);
1548
- }
1549
- },
1550
- setSizeStyle({ scope, context }) {
1551
- queueMicrotask(() => {
1552
- const el = getPositionerEl(scope);
1553
- const size = context.get("size");
1554
- el?.style.setProperty("--width", `${size.width}px`);
1555
- el?.style.setProperty("--height", `${size.height}px`);
1556
- });
1557
- },
1558
- setMaximized({ context, prop, scope }) {
1559
- context.set("stage", "maximized");
1560
- context.set("prevSize", context.get("size"));
1561
- context.set("prevPosition", context.get("position"));
1562
- const boundaryEl = prop("getBoundaryEl")?.();
1563
- const boundaryRect = getBoundaryRect(scope, boundaryEl, false);
1564
- context.set("position", pick(boundaryRect, ["x", "y"]));
1565
- context.set("size", pick(boundaryRect, ["height", "width"]));
1566
- },
1567
- setMinimized({ context, scope }) {
1568
- context.set("stage", "minimized");
1569
- context.set("prevSize", context.get("size"));
1570
- context.set("prevPosition", context.get("position"));
1571
- const headerEl = getHeaderEl(scope);
1572
- if (!headerEl) return;
1573
- const size = {
1574
- ...context.get("size"),
1575
- height: headerEl?.offsetHeight
1576
- };
1577
- context.set("size", size);
1578
- },
1579
- setRestored({ context, prop, scope }) {
1580
- const boundaryRect = getBoundaryRect(scope, prop("getBoundaryEl")?.(), false);
1581
- context.set("stage", "default");
1582
- const prevSize = context.get("prevSize");
1583
- if (prevSize) {
1584
- let nextSize = prevSize;
1585
- nextSize = clampSize(nextSize, prop("minSize"), prop("maxSize"));
1586
- nextSize = clampSize(nextSize, prop("minSize"), boundaryRect);
1587
- context.set("size", nextSize);
1588
- context.set("prevSize", null);
1589
- }
1590
- if (context.get("prevPosition")) {
1591
- let nextPosition = context.get("prevPosition");
1592
- nextPosition = clampPoint(nextPosition, context.get("size"), boundaryRect);
1593
- context.set("position", nextPosition);
1594
- context.set("prevPosition", null);
1595
- }
1596
- },
1597
- setPositionFromKeyboard({ context, event, prop, scope }) {
1598
- invariant(event.step == null, "step is required");
1599
- const position = context.get("position");
1600
- const step = event.step;
1601
- let nextPosition = match(event.direction, {
1602
- left: { x: position.x - step, y: position.y },
1603
- right: { x: position.x + step, y: position.y },
1604
- up: { x: position.x, y: position.y - step },
1605
- down: { x: position.x, y: position.y + step }
1606
- });
1607
- const boundaryEl = prop("getBoundaryEl")?.();
1608
- const boundaryRect = getBoundaryRect(scope, boundaryEl, false);
1609
- nextPosition = clampPoint(nextPosition, context.get("size"), boundaryRect);
1610
- context.set("position", nextPosition);
1611
- },
1612
- bringToFrontOfPanelStack({ prop }) {
1613
- panelStack.bringToFront(prop("id"));
1614
- },
1615
- invokeOnOpen({ prop }) {
1616
- prop("onOpenChange")?.({ open: true });
1617
- },
1618
- invokeOnClose({ prop }) {
1619
- prop("onOpenChange")?.({ open: false });
1620
- },
1621
- invokeOnDragEnd({ context, prop }) {
1622
- prop("onPositionChangeEnd")?.({ position: context.get("position") });
1623
- },
1624
- invokeOnResizeEnd({ context, prop }) {
1625
- prop("onSizeChangeEnd")?.({ size: context.get("size") });
1626
- },
1627
- focusTriggerEl({ scope }) {
1628
- raf(() => {
1629
- getTriggerEl(scope)?.focus();
1630
- });
1631
- },
1632
- focusContentEl({ scope }) {
1633
- raf(() => {
1634
- getContentEl(scope)?.focus();
1635
- });
1636
- },
1637
- toggleVisibility({ send, prop, event }) {
1638
- send({ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: event });
1639
- }
1640
- }
1641
- }
1642
- });
1643
- var props = createProps()([
1644
- "allowOverflow",
1645
- "closeOnEscape",
1646
- "defaultOpen",
1647
- "defaultPosition",
1648
- "defaultSize",
1649
- "dir",
1650
- "disabled",
1651
- "draggable",
1652
- "getAnchorPosition",
1653
- "getBoundaryEl",
1654
- "getRootNode",
1655
- "gridSize",
1656
- "id",
1657
- "ids",
1658
- "lockAspectRatio",
1659
- "maxSize",
1660
- "minSize",
1661
- "onOpenChange",
1662
- "onPositionChange",
1663
- "onPositionChangeEnd",
1664
- "onSizeChange",
1665
- "onSizeChangeEnd",
1666
- "onStageChange",
1667
- "open",
1668
- "persistRect",
1669
- "position",
1670
- "resizable",
1671
- "size",
1672
- "strategy",
1673
- "translations"
1674
- ]);
1675
- var splitProps = createSplitProps2(props);
1676
- var resizeTriggerProps = createProps()(["axis"]);
1677
- var splitResizeTriggerProps = createSplitProps2(resizeTriggerProps);
1678
-
1679
- // src/components/floating-panel/use-floating-panel.ts
1680
- import { normalizeProps, useMachine } from "@zag-js/solid";
1681
- import { createMemo, createUniqueId } from "solid-js";
1682
- var useFloatingPanel = (props2 = {}) => {
1683
- const env = useEnvironmentContext();
1684
- const locale = useLocaleContext();
1685
- const id = createUniqueId();
1686
- const machineProps = createMemo(() => ({
1687
- id,
1688
- dir: locale().dir,
1689
- getRootNode: env().getRootNode,
1690
- ...runIfFn(props2)
1691
- }));
1692
- const service = useMachine(machine, machineProps);
1693
- return createMemo(() => connect(service, normalizeProps));
1694
- };
1695
-
1696
- // src/components/floating-panel/floating-panel-root.tsx
1697
- var FloatingPanelRoot = (props2) => {
1698
- const [presenceProps, otherProps] = splitPresenceProps(props2);
1699
- const [useFloatingPanelProps, localProps] = createSplitProps()(otherProps, [
1700
- "allowOverflow",
1701
- "closeOnEscape",
1702
- "defaultOpen",
1703
- "defaultPosition",
1704
- "defaultSize",
1705
- "dir",
1706
- "disabled",
1707
- "draggable",
1708
- "getAnchorPosition",
1709
- "getBoundaryEl",
1710
- "gridSize",
1711
- "id",
1712
- "ids",
1713
- "lockAspectRatio",
1714
- "maxSize",
1715
- "minSize",
1716
- "onOpenChange",
1717
- "onPositionChange",
1718
- "onPositionChangeEnd",
1719
- "onSizeChange",
1720
- "onSizeChangeEnd",
1721
- "onStageChange",
1722
- "open",
1723
- "persistRect",
1724
- "position",
1725
- "resizable",
1726
- "size",
1727
- "strategy",
1728
- "translations"
1729
- ]);
1730
- const floatingPanel = useFloatingPanel(useFloatingPanelProps);
1731
- const usePresenceProps = mergeProps9(() => ({ present: floatingPanel().open }), presenceProps);
1732
- const presence = usePresence(usePresenceProps);
1733
- return <FloatingPanelProvider value={floatingPanel}>
1734
- <PresenceProvider value={presence}>{localProps.children}</PresenceProvider>
1735
- </FloatingPanelProvider>;
1736
- };
1737
-
1738
- // src/components/floating-panel/floating-panel-root-provider.tsx
1739
- import { mergeProps as mergeProps10 } from "@zag-js/solid";
1740
- var FloatingPanelRootProvider = (props2) => {
1741
- const [presenceProps, baseProps] = splitPresenceProps(props2);
1742
- const [rootProps, localProps] = createSplitProps()(baseProps, ["value"]);
1743
- const presence = usePresence(mergeProps10(() => ({ present: rootProps.value().open }), presenceProps));
1744
- return <FloatingPanelProvider value={rootProps.value}>
1745
- <PresenceProvider value={presence}>{localProps.children}</PresenceProvider>
1746
- </FloatingPanelProvider>;
1747
- };
1748
-
1749
- // src/components/floating-panel/floating-panel-title.tsx
1750
- import { mergeProps as mergeProps11 } from "@zag-js/solid";
1751
- var FloatingPanelTitle = (props2) => {
1752
- const floatingPanel = useFloatingPanelContext();
1753
- const mergedProps = mergeProps11(() => floatingPanel().getTitleProps(), props2);
1754
- return <ark.h2 {...mergedProps} />;
1755
- };
1756
-
1757
- // src/components/floating-panel/floating-panel-trigger.tsx
1758
- import { mergeProps as mergeProps12 } from "@zag-js/solid";
1759
- var FloatingPanelTrigger = (props2) => {
1760
- const floatingPanel = useFloatingPanelContext();
1761
- const presence = usePresenceContext();
1762
- const mergedProps = mergeProps12(() => {
1763
- const triggerProps = floatingPanel().getTriggerProps();
1764
- return {
1765
- ...triggerProps,
1766
- "aria-controls": presence().unmounted ? void 0 : triggerProps["aria-controls"]
1767
- };
1768
- }, props2);
1769
- return <ark.button {...mergedProps} />;
1770
- };
1771
-
1772
- // src/components/floating-panel/floating-panel-control.tsx
1773
- import { mergeProps as mergeProps13 } from "@zag-js/solid";
1774
- var FloatingPanelControl = (props2) => {
1775
- const floatingPanel = useFloatingPanelContext();
1776
- const mergedProps = mergeProps13(() => floatingPanel().getControlProps(), props2);
1777
- return <ark.div {...mergedProps} />;
1778
- };
1779
-
1780
- // src/components/floating-panel/floating-panel.ts
1781
- var floating_panel_exports = {};
1782
- __export(floating_panel_exports, {
1783
- Body: () => FloatingPanelBody,
1784
- CloseTrigger: () => FloatingPanelCloseTrigger,
1785
- Content: () => FloatingPanelContent,
1786
- Context: () => FloatingPanelContext,
1787
- Control: () => FloatingPanelControl,
1788
- DragTrigger: () => FloatingPanelDragTrigger,
1789
- Header: () => FloatingPanelHeader,
1790
- Positioner: () => FloatingPanelPositioner,
1791
- ResizeTrigger: () => FloatingPanelResizeTrigger,
1792
- Root: () => FloatingPanelRoot,
1793
- RootProvider: () => FloatingPanelRootProvider,
1794
- StageTrigger: () => FloatingPanelStageTrigger,
1795
- Title: () => FloatingPanelTitle,
1796
- Trigger: () => FloatingPanelTrigger
1797
- });
1798
-
1799
- export {
1800
- useFloatingPanelContext,
1801
- FloatingPanelBody,
1802
- FloatingPanelCloseTrigger,
1803
- FloatingPanelContent,
1804
- FloatingPanelContext,
1805
- FloatingPanelDragTrigger,
1806
- FloatingPanelHeader,
1807
- FloatingPanelPositioner,
1808
- FloatingPanelResizeTrigger,
1809
- FloatingPanelStageTrigger,
1810
- anatomy,
1811
- useFloatingPanel,
1812
- FloatingPanelRoot,
1813
- FloatingPanelRootProvider,
1814
- FloatingPanelTitle,
1815
- FloatingPanelTrigger,
1816
- FloatingPanelControl,
1817
- floating_panel_exports
1818
- };