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