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