@nice2dev/ui 1.2.1 → 1.3.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/CHANGELOG.md +476 -0
- package/dist/NiceButton-CnAIqCbd.js +101 -0
- package/dist/NiceButton-DzCqkG5a.cjs +1 -0
- package/dist/NiceCodeEditor-C43xFG8v.cjs +260 -0
- package/dist/NiceCodeEditor-CK6B54mu.js +1215 -0
- package/dist/NiceCodeEditor-CspuYLh6.js +1174 -0
- package/dist/NiceCodeEditor-bJReZPDO.cjs +268 -0
- package/dist/NiceColorPicker-BV3olE3M.cjs +1 -0
- package/dist/NiceColorPicker-CyY-4q89.js +552 -0
- package/dist/NiceDataGrid-BQIqitMM.cjs +10 -0
- package/dist/NiceDataGrid-C1eI6Pso.js +2267 -0
- package/dist/NiceDataGrid-CrD4HPlO.cjs +10 -0
- package/dist/NiceDataGrid-Dfg1DVbU.js +2224 -0
- package/dist/NiceForm-CISJyzoW.cjs +1 -0
- package/dist/NiceForm-CfAPcXdX.cjs +1 -0
- package/dist/NiceForm-DfKYNQti.js +5017 -0
- package/dist/NiceForm-DmH6k1b_.js +4775 -0
- package/dist/NiceGantt-CHnq-n8f.cjs +1 -0
- package/dist/NiceGantt-CX3jVNaF.js +330 -0
- package/dist/NiceGantt-TEXbAELi.js +333 -0
- package/dist/NiceGantt-s2cgt5zD.cjs +1 -0
- package/dist/NiceHtmlEditor-CDZeF_zG.cjs +10 -0
- package/dist/NiceHtmlEditor-CdWgddg3.js +901 -0
- package/dist/NiceHtmlEditor-DeK0Of98.js +883 -0
- package/dist/NiceHtmlEditor-DvVxl4Fu.cjs +10 -0
- package/dist/NiceLoginForm-CHXbz0eu.js +747 -0
- package/dist/NiceLoginForm-DRPldHXa.js +808 -0
- package/dist/NiceLoginForm-IGLUCQUE.cjs +1 -0
- package/dist/NiceLoginForm-ix6J1adA.cjs +1 -0
- package/dist/NiceMention-CgDp0sl9.cjs +430 -0
- package/dist/NiceMention-DBvFvx71.js +11653 -0
- package/dist/NiceMention-DKhk3xdM.js +11321 -0
- package/dist/NiceMention-wp1AJ5oh.cjs +430 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-BbQwiEOp.cjs +1 -0
- package/dist/NiceModal-BlYhFDhP.js +80 -0
- package/dist/NiceModal-DQEfTcnZ.js +85 -0
- package/dist/NiceModal-DmWz2PDM.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-22CEEVbA.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BCd9Wv5Y.js +6825 -0
- package/dist/NiceModuleLifecyclePanel-D8EoXqBy.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-SN6G7t64.js +7189 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BFGt1v0a.js +165 -0
- package/dist/NicePagination-BJS65foT.js +200 -0
- package/dist/NicePagination-D_3GfWp5.cjs +1 -0
- package/dist/NicePagination-DltL3-Sz.cjs +1 -0
- package/dist/NicePivotGrid-BD87Na7P.js +1163 -0
- package/dist/NicePivotGrid-BPmnvbPQ.cjs +152 -0
- package/dist/NicePivotGrid-D_kRF1Dt.js +1180 -0
- package/dist/NicePivotGrid-DqluEkCI.cjs +152 -0
- package/dist/NiceSavedQueryPanel-BSTiZvFg.js +5130 -0
- package/dist/NiceSavedQueryPanel-C2Tn1cMW.js +5311 -0
- package/dist/NiceSavedQueryPanel-DDKtL1AA.cjs +586 -0
- package/dist/NiceSavedQueryPanel-DrR3sw4T.cjs +586 -0
- package/dist/NiceScheduler-DvxJ8N0I.js +1698 -0
- package/dist/NiceScheduler-GJLvkXJ3.cjs +5 -0
- package/dist/NiceScheduler-TIksdF0k.cjs +5 -0
- package/dist/NiceScheduler-UT49u2Vq.js +1710 -0
- package/dist/NiceSelect-CdUHd8rj.cjs +1 -0
- package/dist/NiceSelect-fOelG_QB.js +495 -0
- package/dist/NiceWindow-CqSsTjrS.cjs +1 -0
- package/dist/NiceWindow-DZLPhXbR.js +2223 -0
- package/dist/charts-BYQwl_GS.js +4789 -0
- package/dist/charts-BpELGDXh.cjs +768 -0
- package/dist/charts-C6iOu0H6.cjs +768 -0
- package/dist/charts-M6LuVI7F.js +4776 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +1 -29
- package/dist/charts.mjs +1 -1
- package/dist/core-lazy-B_laOXNf.cjs +1 -0
- package/dist/core-lazy-Ctin_LwS.cjs +1 -0
- package/dist/core-lazy-VQEjdz0L.js +351 -0
- package/dist/core-lazy-iDiropM6.js +351 -0
- package/dist/data-branching-7rpktFJ-.cjs +1 -0
- package/dist/data-branching-BS0aFUMu.js +6428 -0
- package/dist/data-branching-BgIAw01q.cjs +1 -0
- package/dist/data-branching-bvB9K6KS.js +6386 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +3 -3
- package/dist/devops-Bp-_aA-9.js +8682 -0
- package/dist/devops-CFytAJQr.cjs +18 -0
- package/dist/devops-CW8YY_zA.js +9122 -0
- package/dist/devops-CXBSjnyX.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.css +1 -0
- package/dist/devops.mjs +5 -5
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +8 -8
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +21 -16
- package/dist/feedback.mjs +3 -3
- package/dist/index.cjs +199 -194
- package/dist/index.css +1 -1
- package/dist/index.d.ts +378 -48
- package/dist/index.mjs +23248 -21783
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +31 -0
- package/dist/navigation.mjs +404 -354
- package/dist/no-code-BNFk_BDO.js +8275 -0
- package/dist/no-code-BaAI_sJR.js +8318 -0
- package/dist/no-code-CFdTp543.cjs +331 -0
- package/dist/no-code-oQTeAtnW.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +5 -0
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BQi6IEAt.js +661 -0
- package/dist/pickerCommons-CMxFt9SW.js +548 -0
- package/dist/pickerCommons-Dc_hlz-e.cjs +1 -0
- package/dist/pickerCommons-DvQptSPX.cjs +1 -0
- package/dist/style.css +7 -4
- package/package.json +4 -3
|
@@ -0,0 +1,2223 @@
|
|
|
1
|
+
import { jsxs as C, Fragment as Te, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as ze, useComponentDisplayClass as kt, useOverlayFocus as ve, NiceIcon as ee, triggerHaptic as We, useClickOutside as st, useRovingFocus as at, usePan as Et, NiceThemeContext as It, useNiceActions as Tt, triggerNiceAction as zt, useIntent as tt, useInputHints as lt, useControlId as nt, focusCandidates as Mt, useInputEngine as Ct, sanitizeHtml as $t, useNiceAccessMode as Rt } from "@nice2dev/ui-core";
|
|
3
|
+
import St, { useRef as A, useState as B, useCallback as v, useEffect as K, useContext as it, useReducer as Pt, useMemo as Re, createContext as dt, forwardRef as ot, useId as Lt } from "react";
|
|
4
|
+
import { createPortal as Se } from "react-dom";
|
|
5
|
+
const Yt = [], rn = ({
|
|
6
|
+
visible: e,
|
|
7
|
+
onClose: n,
|
|
8
|
+
title: c,
|
|
9
|
+
items: o = Yt,
|
|
10
|
+
showCancelButton: a = !0,
|
|
11
|
+
cancelText: l,
|
|
12
|
+
size: u = "md",
|
|
13
|
+
disabled: p,
|
|
14
|
+
readOnly: m,
|
|
15
|
+
loading: E,
|
|
16
|
+
error: $,
|
|
17
|
+
className: M,
|
|
18
|
+
style: L
|
|
19
|
+
}) => {
|
|
20
|
+
const { t: z } = ze();
|
|
21
|
+
if (!e)
|
|
22
|
+
return null;
|
|
23
|
+
const b = p || E || m;
|
|
24
|
+
return /* @__PURE__ */ C(Te, { children: [
|
|
25
|
+
/* @__PURE__ */ t("div", { role: "presentation", className: "nice-actionsheet__overlay", onClick: n }),
|
|
26
|
+
/* @__PURE__ */ C(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
className: `nice-actionsheet nice-actionsheet--${u} ${p ? "nice-actionsheet--disabled" : ""} ${m ? "nice-actionsheet--readonly" : ""} ${E ? "nice-actionsheet--loading" : ""} ${$ ? "nice-actionsheet--error" : ""} ${M || ""}`,
|
|
30
|
+
style: L,
|
|
31
|
+
"aria-disabled": p || void 0,
|
|
32
|
+
"aria-readonly": m || void 0,
|
|
33
|
+
"aria-busy": E || void 0,
|
|
34
|
+
children: [
|
|
35
|
+
$ && /* @__PURE__ */ t("div", { className: "nice-actionsheet__error", role: "alert", children: $ }),
|
|
36
|
+
E && /* @__PURE__ */ t("span", { className: "nice-actionsheet__spinner", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { className: "nice-spinner nice-spinner--sm" }) }),
|
|
37
|
+
c && /* @__PURE__ */ t("div", { className: "nice-actionsheet__title", children: c }),
|
|
38
|
+
/* @__PURE__ */ t("div", { className: "nice-actionsheet__items", children: o.map((s, d) => /* @__PURE__ */ C(
|
|
39
|
+
"button",
|
|
40
|
+
{
|
|
41
|
+
className: `nice-actionsheet__item ${s.type === "danger" ? "nice-actionsheet__item--danger" : ""}`,
|
|
42
|
+
disabled: s.disabled || b,
|
|
43
|
+
onClick: () => {
|
|
44
|
+
b || (s.onClick?.(), n());
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
s.icon && /* @__PURE__ */ t("span", { className: "nice-actionsheet__icon", children: s.icon }),
|
|
48
|
+
s.text
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
d
|
|
52
|
+
)) }),
|
|
53
|
+
a && /* @__PURE__ */ t("button", { className: "nice-actionsheet__cancel", onClick: n, children: l || z("cancel", "Cancel") })
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] });
|
|
58
|
+
}, sn = ({
|
|
59
|
+
visible: e,
|
|
60
|
+
onClose: n,
|
|
61
|
+
targetRef: c,
|
|
62
|
+
position: o = "bottom",
|
|
63
|
+
title: a,
|
|
64
|
+
showArrow: l = !0,
|
|
65
|
+
width: u,
|
|
66
|
+
children: p,
|
|
67
|
+
className: m,
|
|
68
|
+
style: E,
|
|
69
|
+
displayStyle: $
|
|
70
|
+
}) => {
|
|
71
|
+
kt("tooltip", $);
|
|
72
|
+
const M = A(null), [L, z] = B({ top: 0, left: 0 }), b = v(() => {
|
|
73
|
+
const s = c.current, d = M.current;
|
|
74
|
+
if (!s || !d)
|
|
75
|
+
return;
|
|
76
|
+
const r = s.getBoundingClientRect(), f = d.getBoundingClientRect();
|
|
77
|
+
let y = 0, h = 0;
|
|
78
|
+
const Y = 8;
|
|
79
|
+
switch (o) {
|
|
80
|
+
case "top":
|
|
81
|
+
y = r.top - f.height - Y, h = r.left + (r.width - f.width) / 2;
|
|
82
|
+
break;
|
|
83
|
+
case "bottom":
|
|
84
|
+
y = r.bottom + Y, h = r.left + (r.width - f.width) / 2;
|
|
85
|
+
break;
|
|
86
|
+
case "left":
|
|
87
|
+
y = r.top + (r.height - f.height) / 2, h = r.left - f.width - Y;
|
|
88
|
+
break;
|
|
89
|
+
case "right":
|
|
90
|
+
y = r.top + (r.height - f.height) / 2, h = r.right + Y;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
z({ top: y + window.scrollY, left: h + window.scrollX });
|
|
94
|
+
}, [c, o]);
|
|
95
|
+
return K(() => {
|
|
96
|
+
if (e) {
|
|
97
|
+
requestAnimationFrame(b);
|
|
98
|
+
const s = (d) => {
|
|
99
|
+
const r = d.target;
|
|
100
|
+
(r instanceof Element ? r : r?.parentElement ?? null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]') || M.current && !M.current.contains(r) && c.current && !c.current.contains(r) && n();
|
|
101
|
+
};
|
|
102
|
+
return document.addEventListener("mousedown", s), () => document.removeEventListener("mousedown", s);
|
|
103
|
+
}
|
|
104
|
+
}, [e, b, n, c]), ve(M, { open: e, modal: !1, onClose: () => n() }), e ? /* @__PURE__ */ C(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
ref: M,
|
|
108
|
+
className: `nice-popover nice-popover--${o} ${m || ""}`,
|
|
109
|
+
style: { ...E, position: "absolute", top: L.top, left: L.left, width: u },
|
|
110
|
+
role: "dialog",
|
|
111
|
+
"aria-label": a,
|
|
112
|
+
children: [
|
|
113
|
+
l && /* @__PURE__ */ t("div", { className: `nice-popover__arrow nice-popover__arrow--${o}` }),
|
|
114
|
+
a && /* @__PURE__ */ t("div", { className: "nice-popover__title", children: a }),
|
|
115
|
+
/* @__PURE__ */ t("div", { className: "nice-popover__content", children: p })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
) : null;
|
|
119
|
+
}, an = ({
|
|
120
|
+
visible: e,
|
|
121
|
+
message: n,
|
|
122
|
+
container: c,
|
|
123
|
+
showIndicator: o = !0,
|
|
124
|
+
shading: a = !0,
|
|
125
|
+
className: l,
|
|
126
|
+
style: u
|
|
127
|
+
}) => {
|
|
128
|
+
const { t: p } = ze();
|
|
129
|
+
if (!e)
|
|
130
|
+
return null;
|
|
131
|
+
const m = !!c?.current, E = /* @__PURE__ */ C("div", { className: `nice-loadpanel ${l || ""}`, style: u, children: [
|
|
132
|
+
a && /* @__PURE__ */ t("div", { className: "nice-loadpanel__shade" }),
|
|
133
|
+
/* @__PURE__ */ C("div", { className: "nice-loadpanel__box", children: [
|
|
134
|
+
o && /* @__PURE__ */ t("div", { className: "nice-spinner nice-spinner--md" }),
|
|
135
|
+
/* @__PURE__ */ t("span", { className: "nice-loadpanel__text", children: n || p("loading", "Loading...") })
|
|
136
|
+
] })
|
|
137
|
+
] });
|
|
138
|
+
if (m && c.current) {
|
|
139
|
+
const $ = c.current;
|
|
140
|
+
return $.style.position = $.style.position || "relative", E;
|
|
141
|
+
}
|
|
142
|
+
return E;
|
|
143
|
+
}, ln = ({
|
|
144
|
+
direction: e = "row",
|
|
145
|
+
align: n,
|
|
146
|
+
justify: c,
|
|
147
|
+
wrap: o,
|
|
148
|
+
gap: a,
|
|
149
|
+
flex: l,
|
|
150
|
+
children: u,
|
|
151
|
+
className: p,
|
|
152
|
+
style: m
|
|
153
|
+
}) => /* @__PURE__ */ t(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
className: `nice-box ${p || ""}`,
|
|
157
|
+
style: {
|
|
158
|
+
display: "flex",
|
|
159
|
+
flexDirection: e,
|
|
160
|
+
alignItems: n,
|
|
161
|
+
justifyContent: c,
|
|
162
|
+
flexWrap: o ? "wrap" : void 0,
|
|
163
|
+
gap: a,
|
|
164
|
+
flex: l,
|
|
165
|
+
...m
|
|
166
|
+
},
|
|
167
|
+
children: u
|
|
168
|
+
}
|
|
169
|
+
), Ot = [], dn = ({
|
|
170
|
+
direction: e = "row",
|
|
171
|
+
items: n = Ot,
|
|
172
|
+
gap: c,
|
|
173
|
+
className: o,
|
|
174
|
+
style: a
|
|
175
|
+
}) => /* @__PURE__ */ t(
|
|
176
|
+
"div",
|
|
177
|
+
{
|
|
178
|
+
className: `nice-responsivebox ${o || ""}`,
|
|
179
|
+
style: { display: "flex", flexDirection: e, gap: c, ...a },
|
|
180
|
+
children: n.map((l, u) => /* @__PURE__ */ t(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
style: { flex: l.ratio ?? 1, flexBasis: l.baseSize, flexShrink: l.shrink ?? 1 },
|
|
184
|
+
children: l.children
|
|
185
|
+
},
|
|
186
|
+
u
|
|
187
|
+
))
|
|
188
|
+
}
|
|
189
|
+
), un = ({
|
|
190
|
+
width: e = 200,
|
|
191
|
+
height: n = 200,
|
|
192
|
+
minWidth: c = 50,
|
|
193
|
+
minHeight: o = 50,
|
|
194
|
+
maxWidth: a = 1 / 0,
|
|
195
|
+
maxHeight: l = 1 / 0,
|
|
196
|
+
handles: u = ["right", "bottom", "bottomRight"],
|
|
197
|
+
onResize: p,
|
|
198
|
+
children: m,
|
|
199
|
+
className: E,
|
|
200
|
+
style: $
|
|
201
|
+
}) => {
|
|
202
|
+
const [M, L] = B({ width: e, height: n }), z = A(null), b = (r, f) => {
|
|
203
|
+
f.preventDefault();
|
|
204
|
+
const y = f.clientX, h = f.clientY, Y = M.width, I = M.height, D = {
|
|
205
|
+
n: "top",
|
|
206
|
+
s: "bottom",
|
|
207
|
+
e: "right",
|
|
208
|
+
w: "left",
|
|
209
|
+
ne: "topRight",
|
|
210
|
+
se: "bottomRight",
|
|
211
|
+
sw: "bottomLeft",
|
|
212
|
+
nw: "topLeft"
|
|
213
|
+
}[r] ?? r, R = D === "right" || D === "topRight" || D === "bottomRight", F = D === "left" || D === "topLeft" || D === "bottomLeft", N = D === "bottom" || D === "bottomRight" || D === "bottomLeft", i = D === "top" || D === "topRight" || D === "topLeft", x = (T) => {
|
|
214
|
+
const O = T.clientX - y, q = T.clientY - h;
|
|
215
|
+
let w = Y, U = I;
|
|
216
|
+
R && (w = Y + O), F && (w = Y - O), N && (U = I + q), i && (U = I - q), w = Math.max(c, Math.min(a, w)), U = Math.max(o, Math.min(l, U)), L({ width: w, height: U }), p?.({ width: w, height: U });
|
|
217
|
+
}, k = () => {
|
|
218
|
+
document.removeEventListener("pointermove", x), document.removeEventListener("pointerup", k);
|
|
219
|
+
};
|
|
220
|
+
document.addEventListener("pointermove", x), document.addEventListener("pointerup", k);
|
|
221
|
+
}, s = (r) => {
|
|
222
|
+
switch (r) {
|
|
223
|
+
case "top":
|
|
224
|
+
case "bottom":
|
|
225
|
+
return "ns-resize";
|
|
226
|
+
case "left":
|
|
227
|
+
case "right":
|
|
228
|
+
return "ew-resize";
|
|
229
|
+
case "topLeft":
|
|
230
|
+
case "bottomRight":
|
|
231
|
+
return "nwse-resize";
|
|
232
|
+
case "topRight":
|
|
233
|
+
case "bottomLeft":
|
|
234
|
+
return "nesw-resize";
|
|
235
|
+
default:
|
|
236
|
+
return "default";
|
|
237
|
+
}
|
|
238
|
+
}, d = (r) => {
|
|
239
|
+
const f = { position: "absolute", zIndex: 1 }, y = 8;
|
|
240
|
+
return r === "right" ? {
|
|
241
|
+
...f,
|
|
242
|
+
top: 0,
|
|
243
|
+
right: -y / 2,
|
|
244
|
+
width: y,
|
|
245
|
+
height: "100%",
|
|
246
|
+
cursor: s(r)
|
|
247
|
+
} : r === "bottom" ? {
|
|
248
|
+
...f,
|
|
249
|
+
left: 0,
|
|
250
|
+
bottom: -y / 2,
|
|
251
|
+
width: "100%",
|
|
252
|
+
height: y,
|
|
253
|
+
cursor: s(r)
|
|
254
|
+
} : r === "left" ? { ...f, top: 0, left: -y / 2, width: y, height: "100%", cursor: s(r) } : r === "top" ? { ...f, top: -y / 2, left: 0, width: "100%", height: y, cursor: s(r) } : r === "bottomRight" ? {
|
|
255
|
+
...f,
|
|
256
|
+
bottom: -y / 2,
|
|
257
|
+
right: -y / 2,
|
|
258
|
+
width: y * 2,
|
|
259
|
+
height: y * 2,
|
|
260
|
+
cursor: s(r)
|
|
261
|
+
} : r === "bottomLeft" ? {
|
|
262
|
+
...f,
|
|
263
|
+
bottom: -y / 2,
|
|
264
|
+
left: -y / 2,
|
|
265
|
+
width: y * 2,
|
|
266
|
+
height: y * 2,
|
|
267
|
+
cursor: s(r)
|
|
268
|
+
} : r === "topRight" ? {
|
|
269
|
+
...f,
|
|
270
|
+
top: -y / 2,
|
|
271
|
+
right: -y / 2,
|
|
272
|
+
width: y * 2,
|
|
273
|
+
height: y * 2,
|
|
274
|
+
cursor: s(r)
|
|
275
|
+
} : r === "topLeft" ? {
|
|
276
|
+
...f,
|
|
277
|
+
top: -y / 2,
|
|
278
|
+
left: -y / 2,
|
|
279
|
+
width: y * 2,
|
|
280
|
+
height: y * 2,
|
|
281
|
+
cursor: s(r)
|
|
282
|
+
} : f;
|
|
283
|
+
};
|
|
284
|
+
return /* @__PURE__ */ C(
|
|
285
|
+
"div",
|
|
286
|
+
{
|
|
287
|
+
ref: z,
|
|
288
|
+
className: `nice-resizable ${E || ""}`,
|
|
289
|
+
style: {
|
|
290
|
+
...$,
|
|
291
|
+
width: M.width,
|
|
292
|
+
height: M.height,
|
|
293
|
+
position: "relative",
|
|
294
|
+
overflow: "hidden"
|
|
295
|
+
},
|
|
296
|
+
children: [
|
|
297
|
+
m,
|
|
298
|
+
u.map((r) => /* @__PURE__ */ t("div", { style: d(r), onPointerDown: (f) => b(r, f) }, r))
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}, mn = ({
|
|
303
|
+
direction: e = "vertical",
|
|
304
|
+
showScrollbar: n = "onInteraction",
|
|
305
|
+
width: c,
|
|
306
|
+
height: o,
|
|
307
|
+
onScroll: a,
|
|
308
|
+
children: l,
|
|
309
|
+
className: u,
|
|
310
|
+
style: p
|
|
311
|
+
}) => {
|
|
312
|
+
const m = e === "horizontal" || e === "both" ? "auto" : "hidden", E = e === "vertical" || e === "both" ? "auto" : "hidden";
|
|
313
|
+
return /* @__PURE__ */ t(
|
|
314
|
+
"div",
|
|
315
|
+
{
|
|
316
|
+
className: `nice-scrollview ${n === "never" ? "nice-scrollview--hide-sb" : n === "always" ? "nice-scrollview--show-sb" : ""} ${u || ""}`,
|
|
317
|
+
style: { ...p, width: c, height: o, overflowX: m, overflowY: E },
|
|
318
|
+
onScroll: a,
|
|
319
|
+
children: l
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
}, Dt = [];
|
|
323
|
+
function Pe() {
|
|
324
|
+
const e = it(It);
|
|
325
|
+
return e?.portalTarget ? e.portalTarget : typeof document < "u" ? document.body : null;
|
|
326
|
+
}
|
|
327
|
+
const hn = ({
|
|
328
|
+
open: e,
|
|
329
|
+
onClose: n,
|
|
330
|
+
children: c,
|
|
331
|
+
title: o,
|
|
332
|
+
size: a = "md",
|
|
333
|
+
closeOnBackdropClick: l = !0,
|
|
334
|
+
closeOnEscape: u = !0,
|
|
335
|
+
disableFocusTrap: p = !1,
|
|
336
|
+
disableBodyScroll: m = !0,
|
|
337
|
+
zIndex: E = 1e3,
|
|
338
|
+
className: $,
|
|
339
|
+
style: M
|
|
340
|
+
}) => {
|
|
341
|
+
const L = A(null);
|
|
342
|
+
ve(L, { open: e, modal: !p, onClose: n, closeOnEscape: u });
|
|
343
|
+
const z = Pe();
|
|
344
|
+
K(() => {
|
|
345
|
+
if (!m && e) {
|
|
346
|
+
const d = document.body.style.overflow;
|
|
347
|
+
return document.body.style.overflow = "hidden", () => {
|
|
348
|
+
document.body.style.overflow = d;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}, [e, m]);
|
|
352
|
+
const b = v(
|
|
353
|
+
(d) => {
|
|
354
|
+
l && d.target === d.currentTarget && n();
|
|
355
|
+
},
|
|
356
|
+
[l, n]
|
|
357
|
+
);
|
|
358
|
+
if (!e)
|
|
359
|
+
return null;
|
|
360
|
+
const s = {
|
|
361
|
+
sm: "nice-modal--sm",
|
|
362
|
+
md: "nice-modal--md",
|
|
363
|
+
lg: "nice-modal--lg",
|
|
364
|
+
xl: "nice-modal--xl",
|
|
365
|
+
full: "nice-modal--full"
|
|
366
|
+
}[a];
|
|
367
|
+
return Se(
|
|
368
|
+
/* @__PURE__ */ t(
|
|
369
|
+
"div",
|
|
370
|
+
{
|
|
371
|
+
className: "nice-modal__overlay",
|
|
372
|
+
style: { zIndex: E },
|
|
373
|
+
onClick: b,
|
|
374
|
+
role: "presentation",
|
|
375
|
+
children: /* @__PURE__ */ t(
|
|
376
|
+
"div",
|
|
377
|
+
{
|
|
378
|
+
ref: L,
|
|
379
|
+
className: `nice-modal ${s} ${$ || ""}`,
|
|
380
|
+
role: "dialog",
|
|
381
|
+
"aria-modal": "true",
|
|
382
|
+
"aria-label": o,
|
|
383
|
+
style: M,
|
|
384
|
+
tabIndex: -1,
|
|
385
|
+
children: c
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
z
|
|
391
|
+
);
|
|
392
|
+
}, fn = ({
|
|
393
|
+
children: e,
|
|
394
|
+
showClose: n = !0,
|
|
395
|
+
onClose: c,
|
|
396
|
+
className: o
|
|
397
|
+
}) => {
|
|
398
|
+
const { t: a } = ze();
|
|
399
|
+
return /* @__PURE__ */ C("div", { className: `nice-modal__header ${o || ""}`, children: [
|
|
400
|
+
/* @__PURE__ */ t("div", { className: "nice-modal__title", children: e }),
|
|
401
|
+
n && c && /* @__PURE__ */ t(
|
|
402
|
+
"button",
|
|
403
|
+
{
|
|
404
|
+
type: "button",
|
|
405
|
+
className: "nice-modal__close",
|
|
406
|
+
onClick: c,
|
|
407
|
+
"aria-label": a("overlays.close", "Close"),
|
|
408
|
+
children: /* @__PURE__ */ t(ee, { name: "close", size: 20 })
|
|
409
|
+
}
|
|
410
|
+
)
|
|
411
|
+
] });
|
|
412
|
+
}, pn = ({ children: e, className: n }) => /* @__PURE__ */ t("div", { className: `nice-modal__body ${n || ""}`, children: e }), wn = ({ children: e, className: n }) => /* @__PURE__ */ t("div", { className: `nice-modal__footer ${n || ""}`, children: e }), gn = ({
|
|
413
|
+
open: e,
|
|
414
|
+
onClose: n,
|
|
415
|
+
children: c,
|
|
416
|
+
position: o = "right",
|
|
417
|
+
size: a = 320,
|
|
418
|
+
title: l,
|
|
419
|
+
closeOnBackdropClick: u = !0,
|
|
420
|
+
closeOnEscape: p = !0,
|
|
421
|
+
swipeToClose: m = !0,
|
|
422
|
+
zIndex: E = 1e3,
|
|
423
|
+
className: $,
|
|
424
|
+
style: M
|
|
425
|
+
}) => {
|
|
426
|
+
const L = A(null), [z, b] = B(!1), [s, d] = B(0);
|
|
427
|
+
ve(L, { open: e, onClose: n, closeOnEscape: p });
|
|
428
|
+
const r = Pe(), f = v(
|
|
429
|
+
(R) => {
|
|
430
|
+
let F = 0;
|
|
431
|
+
switch (o) {
|
|
432
|
+
case "left":
|
|
433
|
+
F = Math.min(0, R.deltaX);
|
|
434
|
+
break;
|
|
435
|
+
case "right":
|
|
436
|
+
F = Math.max(0, R.deltaX);
|
|
437
|
+
break;
|
|
438
|
+
case "top":
|
|
439
|
+
F = Math.min(0, R.deltaY);
|
|
440
|
+
break;
|
|
441
|
+
case "bottom":
|
|
442
|
+
F = Math.max(0, R.deltaY);
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
d(F);
|
|
446
|
+
},
|
|
447
|
+
[o]
|
|
448
|
+
), y = v(
|
|
449
|
+
(R) => {
|
|
450
|
+
let N = !1;
|
|
451
|
+
switch (o) {
|
|
452
|
+
case "left":
|
|
453
|
+
N = R.deltaX < -100;
|
|
454
|
+
break;
|
|
455
|
+
case "right":
|
|
456
|
+
N = R.deltaX > 100;
|
|
457
|
+
break;
|
|
458
|
+
case "top":
|
|
459
|
+
N = R.deltaY < -100;
|
|
460
|
+
break;
|
|
461
|
+
case "bottom":
|
|
462
|
+
N = R.deltaY > 100;
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
N && (We("light"), n()), d(0), b(!1);
|
|
466
|
+
},
|
|
467
|
+
[o, n]
|
|
468
|
+
), { ref: h } = Et({
|
|
469
|
+
enabled: m && e,
|
|
470
|
+
onPanStart: () => b(!0),
|
|
471
|
+
onPan: f,
|
|
472
|
+
onPanEnd: y
|
|
473
|
+
}), Y = v(
|
|
474
|
+
(R) => {
|
|
475
|
+
u && R.target === R.currentTarget && n();
|
|
476
|
+
},
|
|
477
|
+
[u, n]
|
|
478
|
+
);
|
|
479
|
+
if (!e)
|
|
480
|
+
return null;
|
|
481
|
+
const I = o === "left" || o === "right", Q = I ? { width: typeof a == "number" ? `${a}px` : a } : { height: typeof a == "number" ? `${a}px` : a }, D = () => {
|
|
482
|
+
if (z)
|
|
483
|
+
return I ? `translateX(${s}px)` : `translateY(${s}px)`;
|
|
484
|
+
};
|
|
485
|
+
return Se(
|
|
486
|
+
/* @__PURE__ */ C(Te, { children: [
|
|
487
|
+
/* @__PURE__ */ t(
|
|
488
|
+
"div",
|
|
489
|
+
{
|
|
490
|
+
role: "presentation",
|
|
491
|
+
className: `nice-drawer__overlay ${e ? "nice-drawer__overlay--visible" : ""}`,
|
|
492
|
+
style: { zIndex: E },
|
|
493
|
+
onClick: Y
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
/* @__PURE__ */ t(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
ref: (R) => {
|
|
500
|
+
L.current = R, h.current = R;
|
|
501
|
+
},
|
|
502
|
+
className: `nice-drawer nice-drawer--${o} ${e ? "nice-drawer--open" : ""} ${$ || ""}`,
|
|
503
|
+
style: {
|
|
504
|
+
...Q,
|
|
505
|
+
zIndex: E + 1,
|
|
506
|
+
transform: D(),
|
|
507
|
+
transition: z ? "none" : void 0,
|
|
508
|
+
...M
|
|
509
|
+
},
|
|
510
|
+
role: "dialog",
|
|
511
|
+
"aria-modal": "true",
|
|
512
|
+
"aria-label": l,
|
|
513
|
+
tabIndex: -1,
|
|
514
|
+
children: c
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
] }),
|
|
518
|
+
r
|
|
519
|
+
);
|
|
520
|
+
}, _n = ({
|
|
521
|
+
open: e,
|
|
522
|
+
onClose: n,
|
|
523
|
+
children: c,
|
|
524
|
+
title: o,
|
|
525
|
+
showHandle: a = !0,
|
|
526
|
+
snapPoints: l = [0.5, 0.9],
|
|
527
|
+
initialSnap: u = 0,
|
|
528
|
+
expandable: p = !0,
|
|
529
|
+
closeOnBackdropClick: m = !0,
|
|
530
|
+
closeOnEscape: E = !0,
|
|
531
|
+
hapticFeedback: $ = !0,
|
|
532
|
+
zIndex: M = 1e3,
|
|
533
|
+
className: L,
|
|
534
|
+
style: z
|
|
535
|
+
}) => {
|
|
536
|
+
const b = A(null), s = A(null), [d, r] = B(u), [f, y] = B(!1), [h, Y] = B(0), I = A(0);
|
|
537
|
+
K(() => {
|
|
538
|
+
e && (r(u), Y(0));
|
|
539
|
+
}, [e, u]), ve(b, { open: e, onClose: n, closeOnEscape: E });
|
|
540
|
+
const Q = Pe();
|
|
541
|
+
K(() => {
|
|
542
|
+
if (e) {
|
|
543
|
+
const k = document.body.style.overflow;
|
|
544
|
+
return document.body.style.overflow = "hidden", () => {
|
|
545
|
+
document.body.style.overflow = k;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
}, [e]);
|
|
549
|
+
const D = v((k) => {
|
|
550
|
+
const T = k.target.closest(".nice-bottom-sheet__handle"), O = s.current, q = !O || O.scrollTop <= 0;
|
|
551
|
+
!T && !q || (y(!0), I.current = k.touches[0].clientY);
|
|
552
|
+
}, []), R = v(
|
|
553
|
+
(k) => {
|
|
554
|
+
if (!f)
|
|
555
|
+
return;
|
|
556
|
+
const T = k.touches[0].clientY - I.current;
|
|
557
|
+
(T > 0 || d < l.length - 1) && Y(T);
|
|
558
|
+
},
|
|
559
|
+
[f, d, l.length]
|
|
560
|
+
), F = v(() => {
|
|
561
|
+
if (!f)
|
|
562
|
+
return;
|
|
563
|
+
const k = window.innerHeight;
|
|
564
|
+
l[d] * k;
|
|
565
|
+
const T = -h, O = k * 0.15;
|
|
566
|
+
T > O && p && d < l.length - 1 ? (r(d + 1), $ && We("selection")) : T < -O && (d > 0 ? (r(d - 1), $ && We("selection")) : ($ && We("light"), n())), y(!1), Y(0);
|
|
567
|
+
}, [f, h, d, l, p, $, n]), N = v(() => {
|
|
568
|
+
m && n();
|
|
569
|
+
}, [m, n]);
|
|
570
|
+
if (!e)
|
|
571
|
+
return null;
|
|
572
|
+
const i = l[d] * 100, x = f ? h : 0;
|
|
573
|
+
return Se(
|
|
574
|
+
/* @__PURE__ */ C(Te, { children: [
|
|
575
|
+
/* @__PURE__ */ t(
|
|
576
|
+
"div",
|
|
577
|
+
{
|
|
578
|
+
role: "presentation",
|
|
579
|
+
className: `nice-bottom-sheet__overlay ${e ? "nice-bottom-sheet__overlay--visible" : ""}`,
|
|
580
|
+
style: { zIndex: M },
|
|
581
|
+
onClick: N
|
|
582
|
+
}
|
|
583
|
+
),
|
|
584
|
+
/* @__PURE__ */ C(
|
|
585
|
+
"div",
|
|
586
|
+
{
|
|
587
|
+
ref: b,
|
|
588
|
+
className: `nice-bottom-sheet ${e ? "nice-bottom-sheet--open" : ""} ${L || ""}`,
|
|
589
|
+
style: {
|
|
590
|
+
zIndex: M + 1,
|
|
591
|
+
height: `${i}vh`,
|
|
592
|
+
transform: `translateY(${Math.max(0, x)}px)`,
|
|
593
|
+
transition: f ? "none" : "transform 0.3s ease-out, height 0.3s ease-out",
|
|
594
|
+
...z
|
|
595
|
+
},
|
|
596
|
+
role: "dialog",
|
|
597
|
+
"aria-modal": "true",
|
|
598
|
+
"aria-label": o,
|
|
599
|
+
tabIndex: -1,
|
|
600
|
+
onTouchStart: D,
|
|
601
|
+
onTouchMove: R,
|
|
602
|
+
onTouchEnd: F,
|
|
603
|
+
children: [
|
|
604
|
+
a && /* @__PURE__ */ t("div", { className: "nice-bottom-sheet__handle", "aria-hidden": "true" }),
|
|
605
|
+
o && /* @__PURE__ */ t("div", { className: "nice-bottom-sheet__title", children: o }),
|
|
606
|
+
/* @__PURE__ */ t("div", { ref: s, className: "nice-bottom-sheet__content", children: c })
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
)
|
|
610
|
+
] }),
|
|
611
|
+
Q
|
|
612
|
+
);
|
|
613
|
+
}, vn = ({
|
|
614
|
+
trigger: e,
|
|
615
|
+
children: n,
|
|
616
|
+
placement: c = "bottom",
|
|
617
|
+
triggerMode: o = "click",
|
|
618
|
+
open: a,
|
|
619
|
+
onOpenChange: l,
|
|
620
|
+
hoverDelay: u = 200,
|
|
621
|
+
offset: p = 8,
|
|
622
|
+
className: m,
|
|
623
|
+
showArrow: E = !0
|
|
624
|
+
}) => {
|
|
625
|
+
const [$, M] = B(!1), L = A(null), z = A(null), b = A(null), s = Pe(), d = a !== void 0, r = d ? a : $, f = v(
|
|
626
|
+
(N) => {
|
|
627
|
+
d || M(N), l?.(N);
|
|
628
|
+
},
|
|
629
|
+
[d, l]
|
|
630
|
+
);
|
|
631
|
+
st(z, () => {
|
|
632
|
+
o !== "manual" && r && f(!1);
|
|
633
|
+
});
|
|
634
|
+
const y = o !== "hover";
|
|
635
|
+
ve(z, {
|
|
636
|
+
open: r && y,
|
|
637
|
+
modal: !1,
|
|
638
|
+
onClose: () => f(!1)
|
|
639
|
+
});
|
|
640
|
+
const h = v(() => {
|
|
641
|
+
o === "click" && f(!r);
|
|
642
|
+
}, [o, r, f]), Y = v(() => {
|
|
643
|
+
o === "hover" && (b.current && window.clearTimeout(b.current), b.current = window.setTimeout(() => f(!0), u));
|
|
644
|
+
}, [o, u, f]), I = v(() => {
|
|
645
|
+
o === "hover" && (b.current && window.clearTimeout(b.current), b.current = window.setTimeout(() => f(!1), u));
|
|
646
|
+
}, [o, u, f]), Q = v(
|
|
647
|
+
(N) => {
|
|
648
|
+
const i = N.relatedTarget;
|
|
649
|
+
!L.current?.contains(i) && !z.current?.contains(i) && I();
|
|
650
|
+
},
|
|
651
|
+
[I]
|
|
652
|
+
), D = v(
|
|
653
|
+
(N) => {
|
|
654
|
+
o === "hover" && r && N.key === "Escape" && (N.preventDefault(), N.stopPropagation(), b.current && window.clearTimeout(b.current), f(!1));
|
|
655
|
+
},
|
|
656
|
+
[o, r, f]
|
|
657
|
+
), [R, F] = B({ top: 0, left: 0 });
|
|
658
|
+
return K(() => {
|
|
659
|
+
if (!r || !L.current || !z.current)
|
|
660
|
+
return;
|
|
661
|
+
const N = L.current.getBoundingClientRect(), i = z.current.getBoundingClientRect(), x = window.innerWidth, k = window.innerHeight;
|
|
662
|
+
let T = 0, O = 0;
|
|
663
|
+
const [q, w = "center"] = c.split("-");
|
|
664
|
+
switch (q) {
|
|
665
|
+
case "top":
|
|
666
|
+
T = N.top - i.height - p, O = N.left + (N.width - i.width) / 2;
|
|
667
|
+
break;
|
|
668
|
+
case "bottom":
|
|
669
|
+
T = N.bottom + p, O = N.left + (N.width - i.width) / 2;
|
|
670
|
+
break;
|
|
671
|
+
case "left":
|
|
672
|
+
T = N.top + (N.height - i.height) / 2, O = N.left - i.width - p;
|
|
673
|
+
break;
|
|
674
|
+
case "right":
|
|
675
|
+
T = N.top + (N.height - i.height) / 2, O = N.right + p;
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
q === "top" || q === "bottom" ? (w === "start" && (O = N.left), w === "end" && (O = N.right - i.width)) : (w === "start" && (T = N.top), w === "end" && (T = N.bottom - i.height)), O = Math.max(8, Math.min(x - i.width - 8, O)), T = Math.max(8, Math.min(k - i.height - 8, T)), F({ top: T, left: O });
|
|
679
|
+
}, [r, c, p]), /* @__PURE__ */ C(Te, { children: [
|
|
680
|
+
/* @__PURE__ */ t(
|
|
681
|
+
"div",
|
|
682
|
+
{
|
|
683
|
+
ref: L,
|
|
684
|
+
className: "nice-popover__trigger",
|
|
685
|
+
onClick: h,
|
|
686
|
+
onMouseEnter: Y,
|
|
687
|
+
onMouseLeave: I,
|
|
688
|
+
onFocus: Y,
|
|
689
|
+
onBlur: Q,
|
|
690
|
+
onKeyDown: D,
|
|
691
|
+
style: { display: "inline-block" },
|
|
692
|
+
children: e
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
r && Se(
|
|
696
|
+
/* @__PURE__ */ C(
|
|
697
|
+
"div",
|
|
698
|
+
{
|
|
699
|
+
ref: z,
|
|
700
|
+
className: `nice-popover nice-popover--${c} ${m || ""}`,
|
|
701
|
+
style: {
|
|
702
|
+
position: "fixed",
|
|
703
|
+
top: R.top,
|
|
704
|
+
left: R.left,
|
|
705
|
+
zIndex: 1100
|
|
706
|
+
},
|
|
707
|
+
onMouseEnter: Y,
|
|
708
|
+
onMouseLeave: I,
|
|
709
|
+
role: y ? "dialog" : "tooltip",
|
|
710
|
+
children: [
|
|
711
|
+
E && /* @__PURE__ */ t("div", { className: "nice-popover__arrow" }),
|
|
712
|
+
/* @__PURE__ */ t("div", { className: "nice-popover__content", children: n })
|
|
713
|
+
]
|
|
714
|
+
}
|
|
715
|
+
),
|
|
716
|
+
s
|
|
717
|
+
)
|
|
718
|
+
] });
|
|
719
|
+
}, bn = ({
|
|
720
|
+
items: e = Dt,
|
|
721
|
+
children: n,
|
|
722
|
+
onOpen: c,
|
|
723
|
+
onClose: o,
|
|
724
|
+
className: a
|
|
725
|
+
}) => {
|
|
726
|
+
const [l, u] = B(!1), [p, m] = B({ x: 0, y: 0 }), E = A(null), $ = A(null), M = Pe();
|
|
727
|
+
st(E, () => {
|
|
728
|
+
l && (u(!1), o?.());
|
|
729
|
+
});
|
|
730
|
+
const L = v(
|
|
731
|
+
(d) => {
|
|
732
|
+
if (d.preventDefault(), d.clientX === 0 && d.clientY === 0 && d.target instanceof Element) {
|
|
733
|
+
const r = d.target.getBoundingClientRect();
|
|
734
|
+
m({ x: r.left, y: r.bottom });
|
|
735
|
+
} else
|
|
736
|
+
m({ x: d.clientX, y: d.clientY });
|
|
737
|
+
u(!0), c?.();
|
|
738
|
+
},
|
|
739
|
+
[c]
|
|
740
|
+
), z = v(() => {
|
|
741
|
+
u(!1), o?.();
|
|
742
|
+
}, [o]), b = v(
|
|
743
|
+
(d) => {
|
|
744
|
+
!d.disabled && d.onClick && (d.onClick(), z());
|
|
745
|
+
},
|
|
746
|
+
[z]
|
|
747
|
+
);
|
|
748
|
+
ve(E, { open: l, modal: !1, onClose: z }), at(E, { orientation: "vertical", wrap: !0, typeahead: !0 });
|
|
749
|
+
const s = (d) => /* @__PURE__ */ t("ul", { className: "nice-context-menu__list", role: "menu", children: d.map((r) => r.divider ? /* @__PURE__ */ t("li", { className: "nice-context-menu__divider", role: "separator" }, r.key) : /* @__PURE__ */ t("li", { role: "presentation", children: /* @__PURE__ */ C(
|
|
750
|
+
"button",
|
|
751
|
+
{
|
|
752
|
+
type: "button",
|
|
753
|
+
className: `nice-context-menu__item ${r.disabled ? "nice-context-menu__item--disabled" : ""} ${r.danger ? "nice-context-menu__item--danger" : ""}`,
|
|
754
|
+
role: "menuitem",
|
|
755
|
+
disabled: r.disabled,
|
|
756
|
+
onClick: () => b(r),
|
|
757
|
+
children: [
|
|
758
|
+
r.icon && /* @__PURE__ */ t("span", { className: "nice-context-menu__icon", children: r.icon }),
|
|
759
|
+
/* @__PURE__ */ t("span", { className: "nice-context-menu__label", children: r.label })
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
) }, r.key)) });
|
|
763
|
+
return /* @__PURE__ */ C(Te, { children: [
|
|
764
|
+
/* @__PURE__ */ t("div", { ref: $, onContextMenu: L, style: { display: "contents" }, children: n }),
|
|
765
|
+
l && Se(
|
|
766
|
+
/* @__PURE__ */ t(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
ref: E,
|
|
770
|
+
className: `nice-context-menu ${a || ""}`,
|
|
771
|
+
style: {
|
|
772
|
+
position: "fixed",
|
|
773
|
+
left: p.x,
|
|
774
|
+
top: p.y,
|
|
775
|
+
zIndex: 1200
|
|
776
|
+
},
|
|
777
|
+
children: s(e)
|
|
778
|
+
}
|
|
779
|
+
),
|
|
780
|
+
M
|
|
781
|
+
)
|
|
782
|
+
] });
|
|
783
|
+
};
|
|
784
|
+
function et(e, n) {
|
|
785
|
+
if (!e)
|
|
786
|
+
return { score: 1, indices: [] };
|
|
787
|
+
const c = e.toLowerCase(), o = n.toLowerCase();
|
|
788
|
+
let a = 0;
|
|
789
|
+
const l = [];
|
|
790
|
+
let u = 0, p = -1;
|
|
791
|
+
for (let m = 0; m < o.length && a < c.length; m++)
|
|
792
|
+
o[m] === c[a] && (l.push(m), p === m - 1 && (u += 3), (m === 0 || /[\s\-_/.]/.test(n[m - 1])) && (u += 5), n[m] === e[a] && (u += 1), u += 1, p = m, a++);
|
|
793
|
+
return a < c.length ? null : (u -= l[0] * 0.1, { score: u, indices: l });
|
|
794
|
+
}
|
|
795
|
+
function Xt(e, n) {
|
|
796
|
+
if (n.length === 0)
|
|
797
|
+
return [e];
|
|
798
|
+
const c = [];
|
|
799
|
+
let o = 0;
|
|
800
|
+
const a = new Set(n);
|
|
801
|
+
for (let l = 0; l < e.length; l++)
|
|
802
|
+
a.has(l) && (o < l && c.push(e.slice(o, l)), c.push(
|
|
803
|
+
St.createElement(
|
|
804
|
+
"mark",
|
|
805
|
+
{ key: `m-${l}`, className: "nice-command-palette__match" },
|
|
806
|
+
e[l]
|
|
807
|
+
)
|
|
808
|
+
), o = l + 1);
|
|
809
|
+
return o < e.length && c.push(e.slice(o)), c;
|
|
810
|
+
}
|
|
811
|
+
function Bt(e, n) {
|
|
812
|
+
switch (n.type) {
|
|
813
|
+
case "REGISTER": {
|
|
814
|
+
const c = new Map(e.commands);
|
|
815
|
+
return c.set(n.command.id, n.command), { ...e, commands: c };
|
|
816
|
+
}
|
|
817
|
+
case "REGISTER_BATCH": {
|
|
818
|
+
const c = new Map(e.commands);
|
|
819
|
+
for (const o of n.commands)
|
|
820
|
+
c.set(o.id, o);
|
|
821
|
+
return { ...e, commands: c };
|
|
822
|
+
}
|
|
823
|
+
case "UNREGISTER": {
|
|
824
|
+
const c = new Map(e.commands);
|
|
825
|
+
return c.delete(n.id), { ...e, commands: c };
|
|
826
|
+
}
|
|
827
|
+
case "OPEN":
|
|
828
|
+
return { ...e, isOpen: !0, query: "", selectedIndex: 0 };
|
|
829
|
+
case "CLOSE":
|
|
830
|
+
return { ...e, isOpen: !1, query: "", selectedIndex: 0 };
|
|
831
|
+
case "SET_QUERY":
|
|
832
|
+
return { ...e, query: n.query, selectedIndex: 0 };
|
|
833
|
+
case "SET_SELECTED":
|
|
834
|
+
return { ...e, selectedIndex: n.index };
|
|
835
|
+
case "ADD_RECENT": {
|
|
836
|
+
const c = e.recentIds.filter((o) => o !== n.id);
|
|
837
|
+
return {
|
|
838
|
+
...e,
|
|
839
|
+
recentIds: [n.id, ...c].slice(0, n.maxRecent)
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
default:
|
|
843
|
+
return e;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
const ut = /* @__PURE__ */ dt(
|
|
847
|
+
null
|
|
848
|
+
);
|
|
849
|
+
function Ht() {
|
|
850
|
+
const e = it(ut);
|
|
851
|
+
if (!e)
|
|
852
|
+
throw new Error("useCommandPalette must be used within NiceCommandPaletteProvider");
|
|
853
|
+
return e;
|
|
854
|
+
}
|
|
855
|
+
const At = ({
|
|
856
|
+
children: e,
|
|
857
|
+
commands: n,
|
|
858
|
+
placeholder: c,
|
|
859
|
+
maxVisible: o = 10,
|
|
860
|
+
maxRecent: a = 5,
|
|
861
|
+
className: l,
|
|
862
|
+
emptyText: u,
|
|
863
|
+
closeOnAction: p = !0,
|
|
864
|
+
onOpen: m,
|
|
865
|
+
onClose: E,
|
|
866
|
+
includeActions: $ = !0
|
|
867
|
+
}) => {
|
|
868
|
+
const { t: M } = ze(), L = Tt(), z = M("commandPalette.general", "General"), b = Pe(), [s, d] = Pt(Bt, {
|
|
869
|
+
commands: new Map(n?.map((_) => [_.id, _]) ?? []),
|
|
870
|
+
isOpen: !1,
|
|
871
|
+
query: "",
|
|
872
|
+
selectedIndex: 0,
|
|
873
|
+
recentIds: []
|
|
874
|
+
}), r = A(null), f = A(null), [y, h] = B(!1), Y = v((_) => {
|
|
875
|
+
d({ type: "REGISTER", command: _ });
|
|
876
|
+
}, []), I = v((_) => {
|
|
877
|
+
d({ type: "UNREGISTER", id: _ });
|
|
878
|
+
}, []), Q = v((_) => {
|
|
879
|
+
d({ type: "REGISTER_BATCH", commands: _ });
|
|
880
|
+
}, []), D = v(() => {
|
|
881
|
+
d({ type: "OPEN" }), m?.();
|
|
882
|
+
}, [m]), R = v(() => {
|
|
883
|
+
d({ type: "CLOSE" }), E?.();
|
|
884
|
+
}, [E]), F = v(() => {
|
|
885
|
+
s.isOpen ? R() : D();
|
|
886
|
+
}, [s.isOpen, R, D]), N = Re(() => {
|
|
887
|
+
const _ = new Map(s.commands);
|
|
888
|
+
if ($)
|
|
889
|
+
for (const S of L) {
|
|
890
|
+
const g = `action:${S.id}`;
|
|
891
|
+
S.palette === !1 || _.has(g) || _.set(g, {
|
|
892
|
+
id: g,
|
|
893
|
+
label: S.label,
|
|
894
|
+
description: S.description,
|
|
895
|
+
category: S.group,
|
|
896
|
+
shortcut: typeof S.keyboard == "string" ? S.keyboard : S.keyboard?.[0],
|
|
897
|
+
disabled: S.when ? !S.when() : !1,
|
|
898
|
+
action: () => {
|
|
899
|
+
zt(S.id, "keyboard");
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
return _;
|
|
904
|
+
}, [s.commands, L, $, s.isOpen]), x = Re(() => {
|
|
905
|
+
const _ = Array.from(N.values()).filter((g) => !g.hidden);
|
|
906
|
+
if (!s.query.trim()) {
|
|
907
|
+
const g = s.recentIds.map((H) => N.get(H)).filter((H) => !!H && !H.hidden), V = _.filter((H) => !s.recentIds.includes(H.id));
|
|
908
|
+
return V.sort((H, ae) => H.label.localeCompare(ae.label)), [...g, ...V].map((H) => ({
|
|
909
|
+
command: H,
|
|
910
|
+
match: null,
|
|
911
|
+
isRecent: s.recentIds.includes(H.id)
|
|
912
|
+
}));
|
|
913
|
+
}
|
|
914
|
+
return _.map((g) => {
|
|
915
|
+
const V = et(s.query, g.label), H = g.description ? et(s.query, g.description) : null, ae = g.keywords?.map((re) => et(s.query, re)).filter(Boolean)[0] ?? null, ue = [V, H, ae].filter(Boolean).sort((re, be) => (be?.score ?? 0) - (re?.score ?? 0))[0] ?? null;
|
|
916
|
+
return { command: g, match: ue, isRecent: !1 };
|
|
917
|
+
}).filter((g) => g.match !== null).sort((g, V) => (V.match?.score ?? 0) - (g.match?.score ?? 0));
|
|
918
|
+
}, [N, s.query, s.recentIds]).slice(0, o), k = v(
|
|
919
|
+
async (_) => {
|
|
920
|
+
const S = N.get(_);
|
|
921
|
+
if (!(!S || S.disabled)) {
|
|
922
|
+
h(!0);
|
|
923
|
+
try {
|
|
924
|
+
await S.action(), d({ type: "ADD_RECENT", id: _, maxRecent: a });
|
|
925
|
+
} finally {
|
|
926
|
+
h(!1), p && R();
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
[N, a, p, R]
|
|
931
|
+
);
|
|
932
|
+
tt("menu", () => F());
|
|
933
|
+
const T = A(null);
|
|
934
|
+
ve(T, { open: s.isOpen, onClose: R, initialFocus: r }), tt(
|
|
935
|
+
["navigate", "activate"],
|
|
936
|
+
(_) => {
|
|
937
|
+
const S = x.length;
|
|
938
|
+
if (_.intent === "activate") {
|
|
939
|
+
const V = x[s.selectedIndex];
|
|
940
|
+
return V && k(V.command.id), !0;
|
|
941
|
+
}
|
|
942
|
+
if (!S || _.direction !== "up" && _.direction !== "down")
|
|
943
|
+
return !1;
|
|
944
|
+
const g = _.direction === "down" ? 1 : -1;
|
|
945
|
+
return d({ type: "SET_SELECTED", index: (s.selectedIndex + g + S) % S }), !0;
|
|
946
|
+
},
|
|
947
|
+
{ ref: T, enabled: s.isOpen }
|
|
948
|
+
), lt(
|
|
949
|
+
T,
|
|
950
|
+
s.isOpen ? [
|
|
951
|
+
{ intent: "navigate", label: M("commandPalette.choose", "Choose") },
|
|
952
|
+
{ intent: "activate", label: M("commandPalette.run", "Run") },
|
|
953
|
+
{ intent: "back", label: M("input.hint.close", "Close") }
|
|
954
|
+
] : []
|
|
955
|
+
);
|
|
956
|
+
const O = v(
|
|
957
|
+
(_) => {
|
|
958
|
+
const S = x.length;
|
|
959
|
+
if (S) {
|
|
960
|
+
if (_.key === "ArrowDown")
|
|
961
|
+
_.preventDefault(), d({ type: "SET_SELECTED", index: (s.selectedIndex + 1) % S });
|
|
962
|
+
else if (_.key === "ArrowUp")
|
|
963
|
+
_.preventDefault(), d({ type: "SET_SELECTED", index: (s.selectedIndex - 1 + S) % S });
|
|
964
|
+
else if (_.key === "Enter") {
|
|
965
|
+
_.preventDefault();
|
|
966
|
+
const g = x[s.selectedIndex];
|
|
967
|
+
g && k(g.command.id);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
[x, s.selectedIndex, k]
|
|
972
|
+
);
|
|
973
|
+
K(() => {
|
|
974
|
+
if (!f.current)
|
|
975
|
+
return;
|
|
976
|
+
f.current.children[s.selectedIndex]?.scrollIntoView?.({ block: "nearest" });
|
|
977
|
+
}, [s.selectedIndex]);
|
|
978
|
+
const q = Re(
|
|
979
|
+
() => ({
|
|
980
|
+
registerCommand: Y,
|
|
981
|
+
unregisterCommand: I,
|
|
982
|
+
registerCommands: Q,
|
|
983
|
+
open: D,
|
|
984
|
+
close: R,
|
|
985
|
+
toggle: F,
|
|
986
|
+
isOpen: s.isOpen,
|
|
987
|
+
executeCommand: k
|
|
988
|
+
}),
|
|
989
|
+
[
|
|
990
|
+
Y,
|
|
991
|
+
I,
|
|
992
|
+
Q,
|
|
993
|
+
D,
|
|
994
|
+
R,
|
|
995
|
+
F,
|
|
996
|
+
s.isOpen,
|
|
997
|
+
k
|
|
998
|
+
]
|
|
999
|
+
), w = Re(() => {
|
|
1000
|
+
const _ = /* @__PURE__ */ new Map();
|
|
1001
|
+
for (const S of x) {
|
|
1002
|
+
const g = S.command.category ?? z;
|
|
1003
|
+
_.has(g) || _.set(g, []), _.get(g).push(S);
|
|
1004
|
+
}
|
|
1005
|
+
return _;
|
|
1006
|
+
}, [x, z]);
|
|
1007
|
+
let U = 0;
|
|
1008
|
+
return /* @__PURE__ */ C(ut.Provider, { value: q, children: [
|
|
1009
|
+
e,
|
|
1010
|
+
s.isOpen && Se(
|
|
1011
|
+
/* @__PURE__ */ t(
|
|
1012
|
+
"div",
|
|
1013
|
+
{
|
|
1014
|
+
className: `nice-command-palette__overlay ${l ?? ""}`,
|
|
1015
|
+
role: "presentation",
|
|
1016
|
+
onClick: (_) => {
|
|
1017
|
+
_.stopPropagation(), _.target === _.currentTarget && R();
|
|
1018
|
+
},
|
|
1019
|
+
children: /* @__PURE__ */ C(
|
|
1020
|
+
"div",
|
|
1021
|
+
{
|
|
1022
|
+
ref: T,
|
|
1023
|
+
className: "nice-command-palette",
|
|
1024
|
+
role: "dialog",
|
|
1025
|
+
"aria-label": M("commandPalette.title", "Command palette"),
|
|
1026
|
+
"aria-modal": "true",
|
|
1027
|
+
children: [
|
|
1028
|
+
/* @__PURE__ */ t("div", { className: "nice-command-palette__input-wrapper", children: /* @__PURE__ */ t(
|
|
1029
|
+
"input",
|
|
1030
|
+
{
|
|
1031
|
+
ref: r,
|
|
1032
|
+
className: "nice-command-palette__input",
|
|
1033
|
+
type: "text",
|
|
1034
|
+
placeholder: c ?? M("commandPalette.placeholder", "Type a command..."),
|
|
1035
|
+
value: s.query,
|
|
1036
|
+
onChange: (_) => d({ type: "SET_QUERY", query: _.target.value }),
|
|
1037
|
+
onKeyDown: O,
|
|
1038
|
+
"aria-label": M("commandPalette.search", "Search commands"),
|
|
1039
|
+
"aria-autocomplete": "list",
|
|
1040
|
+
"aria-controls": "nice-command-palette-list",
|
|
1041
|
+
"aria-activedescendant": x[s.selectedIndex] ? `nice-cmd-${x[s.selectedIndex].command.id}` : void 0
|
|
1042
|
+
}
|
|
1043
|
+
) }),
|
|
1044
|
+
/* @__PURE__ */ C(
|
|
1045
|
+
"div",
|
|
1046
|
+
{
|
|
1047
|
+
ref: f,
|
|
1048
|
+
id: "nice-command-palette-list",
|
|
1049
|
+
className: "nice-command-palette__list",
|
|
1050
|
+
role: "listbox",
|
|
1051
|
+
children: [
|
|
1052
|
+
x.length === 0 && /* @__PURE__ */ t("div", { className: "nice-command-palette__empty", children: u ?? M("commandPalette.empty", "No commands found") }),
|
|
1053
|
+
Array.from(w.entries()).map(([_, S]) => /* @__PURE__ */ C("div", { className: "nice-command-palette__group", children: [
|
|
1054
|
+
/* @__PURE__ */ t("div", { className: "nice-command-palette__category", children: _ }),
|
|
1055
|
+
S.map((g) => {
|
|
1056
|
+
const V = U++, H = V === s.selectedIndex;
|
|
1057
|
+
return (
|
|
1058
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keys: the search field (aria-activedescendant)
|
|
1059
|
+
/* @__PURE__ */ C(
|
|
1060
|
+
"div",
|
|
1061
|
+
{
|
|
1062
|
+
id: `nice-cmd-${g.command.id}`,
|
|
1063
|
+
className: `nice-command-palette__item ${H ? "nice-command-palette__item--selected" : ""} ${g.command.disabled ? "nice-command-palette__item--disabled" : ""}`,
|
|
1064
|
+
role: "option",
|
|
1065
|
+
"aria-selected": H,
|
|
1066
|
+
"aria-disabled": g.command.disabled,
|
|
1067
|
+
onClick: () => !g.command.disabled && k(g.command.id),
|
|
1068
|
+
onMouseEnter: () => d({ type: "SET_SELECTED", index: V }),
|
|
1069
|
+
children: [
|
|
1070
|
+
g.command.icon && /* @__PURE__ */ t("span", { className: "nice-command-palette__icon", children: g.command.icon }),
|
|
1071
|
+
/* @__PURE__ */ C("div", { className: "nice-command-palette__label-group", children: [
|
|
1072
|
+
/* @__PURE__ */ t("span", { className: "nice-command-palette__label", children: g.match && s.query ? Xt(g.command.label, g.match.indices) : g.command.label }),
|
|
1073
|
+
g.command.description && /* @__PURE__ */ t("span", { className: "nice-command-palette__description", children: g.command.description })
|
|
1074
|
+
] }),
|
|
1075
|
+
g.command.shortcut && /* @__PURE__ */ t("kbd", { className: "nice-command-palette__shortcut", children: g.command.shortcut }),
|
|
1076
|
+
g.isRecent && /* @__PURE__ */ t("span", { className: "nice-command-palette__recent-badge", children: M("commandPalette.recent", "Recent") })
|
|
1077
|
+
]
|
|
1078
|
+
},
|
|
1079
|
+
g.command.id
|
|
1080
|
+
)
|
|
1081
|
+
);
|
|
1082
|
+
})
|
|
1083
|
+
] }, _))
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
),
|
|
1087
|
+
y && /* @__PURE__ */ t("div", { className: "nice-command-palette__executing", children: M("commandPalette.executing", "Executing...") })
|
|
1088
|
+
]
|
|
1089
|
+
}
|
|
1090
|
+
)
|
|
1091
|
+
}
|
|
1092
|
+
),
|
|
1093
|
+
b
|
|
1094
|
+
)
|
|
1095
|
+
] });
|
|
1096
|
+
};
|
|
1097
|
+
process.env.NODE_ENV !== "production" && (At.displayName = "NiceCommandPaletteProvider");
|
|
1098
|
+
function yn(e) {
|
|
1099
|
+
const { registerCommands: n, unregisterCommand: c } = Ht();
|
|
1100
|
+
K(() => (n(e), () => {
|
|
1101
|
+
for (const o of e)
|
|
1102
|
+
c(o.id);
|
|
1103
|
+
}), []);
|
|
1104
|
+
}
|
|
1105
|
+
const xn = /* @__PURE__ */ Object.assign(
|
|
1106
|
+
/* @__PURE__ */ ot(
|
|
1107
|
+
({ blocked: e, message: n, spinner: c, blur: o, children: a, className: l, style: u, id: p }, m) => {
|
|
1108
|
+
const E = nt(p);
|
|
1109
|
+
return /* @__PURE__ */ C(
|
|
1110
|
+
"div",
|
|
1111
|
+
{
|
|
1112
|
+
ref: m,
|
|
1113
|
+
id: E,
|
|
1114
|
+
className: `nice-block-ui ${l || ""}`,
|
|
1115
|
+
style: { position: "relative", ...u },
|
|
1116
|
+
children: [
|
|
1117
|
+
a,
|
|
1118
|
+
e && /* @__PURE__ */ t(
|
|
1119
|
+
"div",
|
|
1120
|
+
{
|
|
1121
|
+
className: `nice-block-ui__overlay${o ? " nice-block-ui__overlay--blur" : ""}`,
|
|
1122
|
+
"aria-busy": "true",
|
|
1123
|
+
role: "alert",
|
|
1124
|
+
children: (c || n) && /* @__PURE__ */ C("div", { className: "nice-block-ui__content", children: [
|
|
1125
|
+
c && /* @__PURE__ */ t("div", { className: "nice-block-ui__spinner", "aria-hidden": "true" }),
|
|
1126
|
+
n && /* @__PURE__ */ t("div", { className: "nice-block-ui__message", children: n })
|
|
1127
|
+
] })
|
|
1128
|
+
}
|
|
1129
|
+
)
|
|
1130
|
+
]
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
),
|
|
1135
|
+
{ displayName: "NiceBlockUI" }
|
|
1136
|
+
), Nn = /* @__PURE__ */ Object.assign(
|
|
1137
|
+
/* @__PURE__ */ ot(
|
|
1138
|
+
({
|
|
1139
|
+
windows: e,
|
|
1140
|
+
children: n,
|
|
1141
|
+
onChange: c,
|
|
1142
|
+
onClose: o,
|
|
1143
|
+
onFocus: a,
|
|
1144
|
+
showTaskbar: l = !0,
|
|
1145
|
+
size: u = "md",
|
|
1146
|
+
className: p,
|
|
1147
|
+
style: m,
|
|
1148
|
+
id: E,
|
|
1149
|
+
...$
|
|
1150
|
+
}, M) => {
|
|
1151
|
+
const L = nt(E), { t: z } = ze(), [b, s] = B(null), d = A(null), r = A(null);
|
|
1152
|
+
at(r, {
|
|
1153
|
+
orientation: "horizontal",
|
|
1154
|
+
itemSelector: ".nice-wm__taskbar-btn"
|
|
1155
|
+
});
|
|
1156
|
+
const f = A(null), y = v((i) => {
|
|
1157
|
+
const x = [
|
|
1158
|
+
...d.current?.querySelectorAll("[data-wm-key]") ?? []
|
|
1159
|
+
].find((k) => k.getAttribute("data-wm-key") === i);
|
|
1160
|
+
return x ? ((Mt(x)[0] ?? x).focus(), !0) : !1;
|
|
1161
|
+
}, []);
|
|
1162
|
+
K(() => {
|
|
1163
|
+
const i = f.current;
|
|
1164
|
+
i && y(i) && (f.current = null);
|
|
1165
|
+
});
|
|
1166
|
+
const h = Re(() => e ?? [], [e]), Y = Math.max(1, ...h.map((i) => i.zIndex ?? 1)), I = v(
|
|
1167
|
+
(i, x) => {
|
|
1168
|
+
const k = h.map((T) => T.key === i ? { ...T, ...x } : T);
|
|
1169
|
+
c?.(k);
|
|
1170
|
+
},
|
|
1171
|
+
[h, c]
|
|
1172
|
+
), Q = v(
|
|
1173
|
+
(i) => {
|
|
1174
|
+
I(i, { zIndex: Y + 1 }), a?.(i);
|
|
1175
|
+
},
|
|
1176
|
+
[I, Y, a]
|
|
1177
|
+
), D = v(
|
|
1178
|
+
(i) => {
|
|
1179
|
+
o?.(i), c?.(h.filter((x) => x.key !== i));
|
|
1180
|
+
},
|
|
1181
|
+
[h, c, o]
|
|
1182
|
+
), R = v(
|
|
1183
|
+
(i) => {
|
|
1184
|
+
const x = h.find((k) => k.key === i);
|
|
1185
|
+
x && I(i, { minimized: !x.minimized, maximized: !1 });
|
|
1186
|
+
},
|
|
1187
|
+
[h, I]
|
|
1188
|
+
), F = v(
|
|
1189
|
+
(i) => {
|
|
1190
|
+
const x = h.find((k) => k.key === i);
|
|
1191
|
+
x && I(i, { maximized: !x.maximized, minimized: !1 });
|
|
1192
|
+
},
|
|
1193
|
+
[h, I]
|
|
1194
|
+
);
|
|
1195
|
+
K(() => {
|
|
1196
|
+
if (!b)
|
|
1197
|
+
return;
|
|
1198
|
+
const i = (k) => {
|
|
1199
|
+
const T = h.find((O) => O.key === b.key);
|
|
1200
|
+
if (T)
|
|
1201
|
+
if (b.mode === "move")
|
|
1202
|
+
I(b.key, {
|
|
1203
|
+
x: k.clientX - b.offsetX,
|
|
1204
|
+
y: k.clientY - b.offsetY
|
|
1205
|
+
});
|
|
1206
|
+
else {
|
|
1207
|
+
const q = d.current?.getBoundingClientRect(), w = q?.left ?? 0, U = q?.top ?? 0;
|
|
1208
|
+
I(b.key, {
|
|
1209
|
+
width: Math.max(200, k.clientX - w - T.x),
|
|
1210
|
+
height: Math.max(100, k.clientY - U - T.y)
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
}, x = () => s(null);
|
|
1214
|
+
return document.addEventListener("mousemove", i), document.addEventListener("mouseup", x), () => {
|
|
1215
|
+
document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", x);
|
|
1216
|
+
};
|
|
1217
|
+
}, [b, h, I]);
|
|
1218
|
+
const N = v(
|
|
1219
|
+
(i, x, k) => {
|
|
1220
|
+
x.preventDefault();
|
|
1221
|
+
const T = h.find((O) => O.key === i);
|
|
1222
|
+
T && (Q(i), s({
|
|
1223
|
+
key: i,
|
|
1224
|
+
offsetX: k === "move" ? x.clientX - T.x : 0,
|
|
1225
|
+
offsetY: k === "move" ? x.clientY - T.y : 0,
|
|
1226
|
+
mode: k
|
|
1227
|
+
}));
|
|
1228
|
+
},
|
|
1229
|
+
[h, Q]
|
|
1230
|
+
);
|
|
1231
|
+
return /* @__PURE__ */ C(
|
|
1232
|
+
"div",
|
|
1233
|
+
{
|
|
1234
|
+
ref: (i) => {
|
|
1235
|
+
d.current = i, typeof M == "function" ? M(i) : M && (M.current = i);
|
|
1236
|
+
},
|
|
1237
|
+
id: L,
|
|
1238
|
+
className: `nice-wm nice-wm--${u} ${p ?? ""}`,
|
|
1239
|
+
style: { ...m, position: "relative", overflow: "hidden" },
|
|
1240
|
+
...$,
|
|
1241
|
+
children: [
|
|
1242
|
+
h.map((i) => {
|
|
1243
|
+
if (i.minimized)
|
|
1244
|
+
return null;
|
|
1245
|
+
const x = i.maximized, k = x ? {
|
|
1246
|
+
position: "absolute",
|
|
1247
|
+
top: 0,
|
|
1248
|
+
left: 0,
|
|
1249
|
+
width: "100%",
|
|
1250
|
+
height: "100%",
|
|
1251
|
+
zIndex: i.zIndex ?? 1
|
|
1252
|
+
} : {
|
|
1253
|
+
position: "absolute",
|
|
1254
|
+
top: i.y,
|
|
1255
|
+
left: i.x,
|
|
1256
|
+
width: i.width,
|
|
1257
|
+
height: i.height,
|
|
1258
|
+
zIndex: i.zIndex ?? 1
|
|
1259
|
+
};
|
|
1260
|
+
return (
|
|
1261
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- a press raises the window; focus moving in does it from the keyboard
|
|
1262
|
+
/* @__PURE__ */ C(
|
|
1263
|
+
"div",
|
|
1264
|
+
{
|
|
1265
|
+
className: `nice-wm__window ${x ? "nice-wm__window--maximized" : ""}`,
|
|
1266
|
+
style: k,
|
|
1267
|
+
onMouseDown: () => Q(i.key),
|
|
1268
|
+
onFocus: () => {
|
|
1269
|
+
(i.zIndex ?? 1) < Y && Q(i.key);
|
|
1270
|
+
},
|
|
1271
|
+
role: "dialog",
|
|
1272
|
+
"aria-label": i.title,
|
|
1273
|
+
tabIndex: -1,
|
|
1274
|
+
"data-wm-key": i.key,
|
|
1275
|
+
"data-nice-focus-scope": "spatial",
|
|
1276
|
+
"data-nice-region": i.title,
|
|
1277
|
+
children: [
|
|
1278
|
+
/* @__PURE__ */ C(
|
|
1279
|
+
"div",
|
|
1280
|
+
{
|
|
1281
|
+
className: "nice-wm__titlebar",
|
|
1282
|
+
onMouseDown: (T) => !x && N(i.key, T, "move"),
|
|
1283
|
+
children: [
|
|
1284
|
+
i.icon && /* @__PURE__ */ t("span", { className: "nice-wm__icon", children: i.icon }),
|
|
1285
|
+
/* @__PURE__ */ t("span", { className: "nice-wm__title", children: i.title }),
|
|
1286
|
+
/* @__PURE__ */ C("div", { className: "nice-wm__controls", children: [
|
|
1287
|
+
(i.minimizable ?? !0) && /* @__PURE__ */ t(
|
|
1288
|
+
"button",
|
|
1289
|
+
{
|
|
1290
|
+
type: "button",
|
|
1291
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--min",
|
|
1292
|
+
onClick: () => R(i.key),
|
|
1293
|
+
title: z("wm.minimize", "Minimize"),
|
|
1294
|
+
children: /* @__PURE__ */ t(ee, { name: "minus", size: 14 })
|
|
1295
|
+
}
|
|
1296
|
+
),
|
|
1297
|
+
(i.maximizable ?? !0) && /* @__PURE__ */ t(
|
|
1298
|
+
"button",
|
|
1299
|
+
{
|
|
1300
|
+
type: "button",
|
|
1301
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--max",
|
|
1302
|
+
onClick: () => F(i.key),
|
|
1303
|
+
title: z("wm.maximize", "Maximize"),
|
|
1304
|
+
children: /* @__PURE__ */ t(ee, { name: x ? "copy" : "window", size: 14 })
|
|
1305
|
+
}
|
|
1306
|
+
),
|
|
1307
|
+
(i.closable ?? !0) && /* @__PURE__ */ t(
|
|
1308
|
+
"button",
|
|
1309
|
+
{
|
|
1310
|
+
type: "button",
|
|
1311
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--close",
|
|
1312
|
+
onClick: () => D(i.key),
|
|
1313
|
+
title: z("wm.close", "Close"),
|
|
1314
|
+
children: /* @__PURE__ */ t(ee, { name: "close", size: 14 })
|
|
1315
|
+
}
|
|
1316
|
+
)
|
|
1317
|
+
] })
|
|
1318
|
+
]
|
|
1319
|
+
}
|
|
1320
|
+
),
|
|
1321
|
+
/* @__PURE__ */ t("div", { className: "nice-wm__body", children: i.content }),
|
|
1322
|
+
(i.resizable ?? !0) && !x && /* @__PURE__ */ t(
|
|
1323
|
+
"div",
|
|
1324
|
+
{
|
|
1325
|
+
className: "nice-wm__resize-handle",
|
|
1326
|
+
onMouseDown: (T) => N(i.key, T, "resize")
|
|
1327
|
+
}
|
|
1328
|
+
)
|
|
1329
|
+
]
|
|
1330
|
+
},
|
|
1331
|
+
i.key
|
|
1332
|
+
)
|
|
1333
|
+
);
|
|
1334
|
+
}),
|
|
1335
|
+
e === void 0 && n,
|
|
1336
|
+
l && /* @__PURE__ */ t(
|
|
1337
|
+
"div",
|
|
1338
|
+
{
|
|
1339
|
+
ref: r,
|
|
1340
|
+
className: "nice-wm__taskbar",
|
|
1341
|
+
role: "toolbar",
|
|
1342
|
+
"aria-label": z("wm.taskbar", "Taskbar"),
|
|
1343
|
+
"data-nice-region": z("wm.taskbar", "Taskbar"),
|
|
1344
|
+
children: h.map((i) => /* @__PURE__ */ C(
|
|
1345
|
+
"button",
|
|
1346
|
+
{
|
|
1347
|
+
type: "button",
|
|
1348
|
+
className: `nice-wm__taskbar-btn ${i.minimized ? "nice-wm__taskbar-btn--minimized" : ""}`,
|
|
1349
|
+
onClick: () => {
|
|
1350
|
+
i.minimized && R(i.key), Q(i.key), (i.minimized || !y(i.key)) && (f.current = i.key);
|
|
1351
|
+
},
|
|
1352
|
+
children: [
|
|
1353
|
+
i.icon && /* @__PURE__ */ t("span", { className: "nice-wm__taskbar-icon", children: i.icon }),
|
|
1354
|
+
/* @__PURE__ */ t("span", { className: "nice-wm__taskbar-label", children: i.title })
|
|
1355
|
+
]
|
|
1356
|
+
},
|
|
1357
|
+
i.key
|
|
1358
|
+
))
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
),
|
|
1366
|
+
{ displayName: "NiceWindowManager" }
|
|
1367
|
+
);
|
|
1368
|
+
function Ft(e, n) {
|
|
1369
|
+
const c = document.querySelector(e);
|
|
1370
|
+
if (!c)
|
|
1371
|
+
return null;
|
|
1372
|
+
const o = c.getBoundingClientRect();
|
|
1373
|
+
return {
|
|
1374
|
+
top: o.top - n + window.scrollY,
|
|
1375
|
+
left: o.left - n + window.scrollX,
|
|
1376
|
+
width: o.width + n * 2,
|
|
1377
|
+
height: o.height + n * 2
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
function qt(e, n, c, o) {
|
|
1381
|
+
const l = { w: window.innerWidth, h: window.innerHeight + window.scrollY }, u = {
|
|
1382
|
+
top: {
|
|
1383
|
+
top: e.top - c - 12,
|
|
1384
|
+
left: e.left + e.width / 2 - n / 2
|
|
1385
|
+
},
|
|
1386
|
+
bottom: {
|
|
1387
|
+
top: e.top + e.height + 12,
|
|
1388
|
+
left: e.left + e.width / 2 - n / 2
|
|
1389
|
+
},
|
|
1390
|
+
left: {
|
|
1391
|
+
top: e.top + e.height / 2 - c / 2,
|
|
1392
|
+
left: e.left - n - 12
|
|
1393
|
+
},
|
|
1394
|
+
right: {
|
|
1395
|
+
top: e.top + e.height / 2 - c / 2,
|
|
1396
|
+
left: e.left + e.width + 12
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
if (o && o !== "auto")
|
|
1400
|
+
return { ...u[o], actualPlacement: o };
|
|
1401
|
+
for (const p of ["bottom", "top", "right", "left"]) {
|
|
1402
|
+
const m = u[p];
|
|
1403
|
+
if (m.top >= 0 && m.left >= 0 && m.top + c <= l.h && m.left + n <= l.w)
|
|
1404
|
+
return { ...m, actualPlacement: p };
|
|
1405
|
+
}
|
|
1406
|
+
return { ...u.bottom, actualPlacement: "bottom" };
|
|
1407
|
+
}
|
|
1408
|
+
function Wt() {
|
|
1409
|
+
return /* @__PURE__ */ t(ee, { name: "close", size: 16 });
|
|
1410
|
+
}
|
|
1411
|
+
function Ut() {
|
|
1412
|
+
return /* @__PURE__ */ t(ee, { name: "chevron-left", size: 16 });
|
|
1413
|
+
}
|
|
1414
|
+
function jt() {
|
|
1415
|
+
return /* @__PURE__ */ t(ee, { name: "chevron-right", size: 16 });
|
|
1416
|
+
}
|
|
1417
|
+
function Kt() {
|
|
1418
|
+
return /* @__PURE__ */ t(ee, { name: "skip-forward", size: 16 });
|
|
1419
|
+
}
|
|
1420
|
+
function Vt() {
|
|
1421
|
+
return /* @__PURE__ */ t(ee, { name: "play", size: 16 });
|
|
1422
|
+
}
|
|
1423
|
+
function Gt() {
|
|
1424
|
+
return /* @__PURE__ */ t(ee, { name: "pause", size: 16 });
|
|
1425
|
+
}
|
|
1426
|
+
function qe(e, n, c) {
|
|
1427
|
+
return c === "text" ? /* @__PURE__ */ t("span", { className: "nice-tutorial__btn-label", children: n }) : c === "icon-text" ? /* @__PURE__ */ C(Te, { children: [
|
|
1428
|
+
e,
|
|
1429
|
+
/* @__PURE__ */ t("span", { className: "nice-tutorial__btn-label", children: n })
|
|
1430
|
+
] }) : e;
|
|
1431
|
+
}
|
|
1432
|
+
const Qt = [], mt = ({
|
|
1433
|
+
steps: e = Qt,
|
|
1434
|
+
active: n,
|
|
1435
|
+
onFinish: c,
|
|
1436
|
+
onSkip: o,
|
|
1437
|
+
onStepChange: a,
|
|
1438
|
+
closeOnEscape: l = !0,
|
|
1439
|
+
closeOnOverlayClick: u = !1,
|
|
1440
|
+
showProgress: p = !0,
|
|
1441
|
+
showSkipButton: m = !0,
|
|
1442
|
+
labels: E,
|
|
1443
|
+
animationDuration: $ = 300,
|
|
1444
|
+
overlayOpacity: M = 0.6,
|
|
1445
|
+
zIndex: L = 1e4,
|
|
1446
|
+
buttonsPlacement: z = "floating-bottom",
|
|
1447
|
+
buttonsDisplay: b = "icon",
|
|
1448
|
+
showAutoplay: s = !0,
|
|
1449
|
+
autoplayInterval: d = 5e3,
|
|
1450
|
+
autoplaySpeedRange: r = { min: 2e3, max: 15e3 },
|
|
1451
|
+
onAutoplayChange: f
|
|
1452
|
+
}) => {
|
|
1453
|
+
const { t: y } = ze(), [h, Y] = B(0), [I, Q] = B(null), [D, R] = B({ w: 340, h: 200 }), [F, N] = B(!0), [i, x] = B(!1), [k, T] = B(d), O = A(null), q = A(-1), w = e[h], U = h === e.length - 1, _ = h === 0, S = E?.next ?? "Next", g = E?.back ?? "Back", V = E?.finish ?? "Finish", H = E?.skip ?? "Skip", ae = E?.stepOf ?? "of", ue = E?.play ?? "Play", re = E?.pause ?? "Pause", be = E?.speed ?? "Speed", Be = E?.close ?? "Close";
|
|
1454
|
+
K(() => {
|
|
1455
|
+
n && (Y(0), x(!1), T(d));
|
|
1456
|
+
}, [n, d]), K(() => {
|
|
1457
|
+
if (O.current) {
|
|
1458
|
+
const P = O.current.getBoundingClientRect();
|
|
1459
|
+
R({ w: P.width, h: P.height });
|
|
1460
|
+
}
|
|
1461
|
+
}, [h, n]), K(() => {
|
|
1462
|
+
if (!n || !w)
|
|
1463
|
+
return;
|
|
1464
|
+
const P = w.highlightPadding ?? 0, W = () => {
|
|
1465
|
+
const Z = Ft(w.target, P);
|
|
1466
|
+
Q(Z);
|
|
1467
|
+
};
|
|
1468
|
+
if (W(), w.scrollIntoView !== !1) {
|
|
1469
|
+
document.querySelector(w.target)?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1470
|
+
const Ye = setTimeout(W, 350);
|
|
1471
|
+
return () => clearTimeout(Ye);
|
|
1472
|
+
}
|
|
1473
|
+
}, [n, w, h]), K(() => {
|
|
1474
|
+
!n || !w || q.current !== h && (q.current >= 0 && q.current < e.length && e[q.current]?.onLeave?.(), w.onEnter?.(), q.current = h);
|
|
1475
|
+
}, [n, w, h, e]);
|
|
1476
|
+
const le = v(() => {
|
|
1477
|
+
if (U)
|
|
1478
|
+
w?.onLeave?.(), c?.();
|
|
1479
|
+
else {
|
|
1480
|
+
const P = h + 1;
|
|
1481
|
+
Y(P), a?.(P);
|
|
1482
|
+
}
|
|
1483
|
+
}, [h, U, c, a, w]), ye = v(() => {
|
|
1484
|
+
if (!_) {
|
|
1485
|
+
const P = h - 1;
|
|
1486
|
+
Y(P), a?.(P);
|
|
1487
|
+
}
|
|
1488
|
+
}, [h, _, a]), He = v(
|
|
1489
|
+
(P) => {
|
|
1490
|
+
P !== h && P >= 0 && P < e.length && (Y(P), a?.(P));
|
|
1491
|
+
},
|
|
1492
|
+
[h, e.length, a]
|
|
1493
|
+
);
|
|
1494
|
+
K(() => {
|
|
1495
|
+
if (!n || !w?.advanceOn)
|
|
1496
|
+
return;
|
|
1497
|
+
const P = document.querySelector(w.target);
|
|
1498
|
+
if (!P)
|
|
1499
|
+
return;
|
|
1500
|
+
const W = () => le();
|
|
1501
|
+
return P.addEventListener(w.advanceOn.event, W), () => P.removeEventListener(w.advanceOn.event, W);
|
|
1502
|
+
}, [n, w, h, le]);
|
|
1503
|
+
const xe = A(null), J = !!(n && w);
|
|
1504
|
+
ve(xe, {
|
|
1505
|
+
open: J,
|
|
1506
|
+
modal: !(w?.waitForAction || w?.advanceOn),
|
|
1507
|
+
onClose: () => o?.(),
|
|
1508
|
+
closeOnEscape: l,
|
|
1509
|
+
closeHint: H
|
|
1510
|
+
}), K(() => {
|
|
1511
|
+
const P = xe.current;
|
|
1512
|
+
if (!J || !P)
|
|
1513
|
+
return;
|
|
1514
|
+
const W = (Z) => {
|
|
1515
|
+
if (!(Z.defaultPrevented || Z.target instanceof HTMLInputElement)) {
|
|
1516
|
+
if (Z.key === "ArrowRight")
|
|
1517
|
+
le();
|
|
1518
|
+
else if (Z.key === "ArrowLeft")
|
|
1519
|
+
ye();
|
|
1520
|
+
else if (Z.key === "Home" || Z.key === "End")
|
|
1521
|
+
He(Z.key === "Home" ? 0 : e.length - 1);
|
|
1522
|
+
else
|
|
1523
|
+
return;
|
|
1524
|
+
Z.preventDefault();
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
return P.addEventListener("keydown", W), () => P.removeEventListener("keydown", W);
|
|
1528
|
+
}, [J, le, ye, He, e.length]);
|
|
1529
|
+
const Me = Ct(), j = J ? w?.title : void 0;
|
|
1530
|
+
K(() => {
|
|
1531
|
+
j && h > 0 && Me?.announce(j);
|
|
1532
|
+
}, [Me, j, h]);
|
|
1533
|
+
const Le = Lt(), Ae = `${Le}-content`;
|
|
1534
|
+
tt(
|
|
1535
|
+
["sectionPrev", "sectionNext"],
|
|
1536
|
+
(P) => {
|
|
1537
|
+
if (P.intent === "sectionNext") {
|
|
1538
|
+
if (w?.waitForAction)
|
|
1539
|
+
return !1;
|
|
1540
|
+
le();
|
|
1541
|
+
} else
|
|
1542
|
+
ye();
|
|
1543
|
+
},
|
|
1544
|
+
{ ref: xe, enabled: J }
|
|
1545
|
+
), lt(
|
|
1546
|
+
xe,
|
|
1547
|
+
J ? [
|
|
1548
|
+
..._ ? [] : [{ intent: "sectionPrev", label: g }],
|
|
1549
|
+
...w?.waitForAction ? [] : [{ intent: "sectionNext", label: U ? V : S }]
|
|
1550
|
+
] : []
|
|
1551
|
+
), K(() => {
|
|
1552
|
+
N(!0);
|
|
1553
|
+
const P = setTimeout(() => N(!1), $);
|
|
1554
|
+
return () => clearTimeout(P);
|
|
1555
|
+
}, [h, $]), K(() => {
|
|
1556
|
+
if (!n || !i)
|
|
1557
|
+
return;
|
|
1558
|
+
const P = setInterval(
|
|
1559
|
+
() => {
|
|
1560
|
+
Y((W) => {
|
|
1561
|
+
if (W >= e.length - 1)
|
|
1562
|
+
return x(!1), f?.(!1), e[W]?.onLeave?.(), c?.(), W;
|
|
1563
|
+
const Z = W + 1;
|
|
1564
|
+
return a?.(Z), Z;
|
|
1565
|
+
});
|
|
1566
|
+
},
|
|
1567
|
+
Math.max(500, k)
|
|
1568
|
+
);
|
|
1569
|
+
return () => clearInterval(P);
|
|
1570
|
+
}, [n, i, k, e, f, c, a]);
|
|
1571
|
+
const Ne = v(() => {
|
|
1572
|
+
x((P) => {
|
|
1573
|
+
const W = !P;
|
|
1574
|
+
return f?.(W), W;
|
|
1575
|
+
});
|
|
1576
|
+
}, [f]), oe = Re(() => I ? qt(I, D.w, D.h, w?.placement) : {
|
|
1577
|
+
top: typeof window < "u" ? window.innerHeight / 2 : 0,
|
|
1578
|
+
left: typeof window < "u" ? window.innerWidth / 2 : 0,
|
|
1579
|
+
actualPlacement: "bottom"
|
|
1580
|
+
}, [I, D, w?.placement]), me = e.length === 0 ? 0 : (h + 1) / e.length * 100, ke = v(
|
|
1581
|
+
(P) => {
|
|
1582
|
+
const W = s && e.length > 1, Z = m && !U && /* @__PURE__ */ t(
|
|
1583
|
+
"button",
|
|
1584
|
+
{
|
|
1585
|
+
type: "button",
|
|
1586
|
+
className: `nice-tutorial__btn nice-tutorial__btn--skip nice-tutorial__btn--${b}`,
|
|
1587
|
+
onClick: o,
|
|
1588
|
+
"aria-label": H,
|
|
1589
|
+
title: H,
|
|
1590
|
+
children: qe(/* @__PURE__ */ t(Kt, {}), H, b)
|
|
1591
|
+
}
|
|
1592
|
+
), Ye = !_ && /* @__PURE__ */ t(
|
|
1593
|
+
"button",
|
|
1594
|
+
{
|
|
1595
|
+
type: "button",
|
|
1596
|
+
className: `nice-tutorial__btn nice-tutorial__btn--back nice-tutorial__btn--${b}`,
|
|
1597
|
+
onClick: ye,
|
|
1598
|
+
"aria-label": g,
|
|
1599
|
+
title: g,
|
|
1600
|
+
children: qe(/* @__PURE__ */ t(Ut, {}), g, b)
|
|
1601
|
+
}
|
|
1602
|
+
), Ke = !w?.waitForAction && /* @__PURE__ */ t(
|
|
1603
|
+
"button",
|
|
1604
|
+
{
|
|
1605
|
+
type: "button",
|
|
1606
|
+
className: `nice-tutorial__btn nice-tutorial__btn--next nice-tutorial__btn--${b}`,
|
|
1607
|
+
onClick: le,
|
|
1608
|
+
"aria-label": U ? V : S,
|
|
1609
|
+
title: U ? V : S,
|
|
1610
|
+
children: qe(/* @__PURE__ */ t(jt, {}), U ? V : S, b)
|
|
1611
|
+
}
|
|
1612
|
+
), Ve = W && /* @__PURE__ */ t(
|
|
1613
|
+
"button",
|
|
1614
|
+
{
|
|
1615
|
+
type: "button",
|
|
1616
|
+
className: [
|
|
1617
|
+
"nice-tutorial__btn",
|
|
1618
|
+
"nice-tutorial__btn--play",
|
|
1619
|
+
`nice-tutorial__btn--${b}`,
|
|
1620
|
+
i ? "nice-tutorial__btn--active" : ""
|
|
1621
|
+
].filter(Boolean).join(" "),
|
|
1622
|
+
onClick: Ne,
|
|
1623
|
+
"aria-label": i ? re : ue,
|
|
1624
|
+
title: i ? re : ue,
|
|
1625
|
+
"aria-pressed": i,
|
|
1626
|
+
children: qe(
|
|
1627
|
+
i ? /* @__PURE__ */ t(Gt, {}) : /* @__PURE__ */ t(Vt, {}),
|
|
1628
|
+
i ? re : ue,
|
|
1629
|
+
b
|
|
1630
|
+
)
|
|
1631
|
+
}
|
|
1632
|
+
);
|
|
1633
|
+
return /* @__PURE__ */ C(
|
|
1634
|
+
"div",
|
|
1635
|
+
{
|
|
1636
|
+
className: [
|
|
1637
|
+
"nice-tutorial__controls",
|
|
1638
|
+
P ? "nice-tutorial__controls--inline" : "nice-tutorial__controls--floating-bottom"
|
|
1639
|
+
].join(" "),
|
|
1640
|
+
style: P ? void 0 : { zIndex: L + 2 },
|
|
1641
|
+
role: "group",
|
|
1642
|
+
"aria-label": y("tutorial.tutorialControls", "Tutorial controls"),
|
|
1643
|
+
children: [
|
|
1644
|
+
Z,
|
|
1645
|
+
Ye,
|
|
1646
|
+
p && /* @__PURE__ */ C("span", { className: "nice-tutorial__step-label", "aria-live": "polite", children: [
|
|
1647
|
+
h + 1,
|
|
1648
|
+
" ",
|
|
1649
|
+
ae,
|
|
1650
|
+
" ",
|
|
1651
|
+
e.length
|
|
1652
|
+
] }),
|
|
1653
|
+
Ke,
|
|
1654
|
+
W && /* @__PURE__ */ t(
|
|
1655
|
+
"div",
|
|
1656
|
+
{
|
|
1657
|
+
className: "nice-tutorial__progress-bar",
|
|
1658
|
+
role: "progressbar",
|
|
1659
|
+
"aria-valuenow": Math.round(me),
|
|
1660
|
+
"aria-valuemin": 0,
|
|
1661
|
+
"aria-valuemax": 100,
|
|
1662
|
+
"aria-label": `${h + 1} ${ae} ${e.length}`,
|
|
1663
|
+
children: /* @__PURE__ */ t(
|
|
1664
|
+
"div",
|
|
1665
|
+
{
|
|
1666
|
+
className: "nice-tutorial__progress-bar-fill",
|
|
1667
|
+
style: { width: `${me}%` }
|
|
1668
|
+
}
|
|
1669
|
+
)
|
|
1670
|
+
}
|
|
1671
|
+
),
|
|
1672
|
+
Ve,
|
|
1673
|
+
W && /* @__PURE__ */ C("label", { className: "nice-tutorial__speed", children: [
|
|
1674
|
+
/* @__PURE__ */ t(
|
|
1675
|
+
"input",
|
|
1676
|
+
{
|
|
1677
|
+
type: "range",
|
|
1678
|
+
className: "nice-tutorial__speed-slider",
|
|
1679
|
+
min: r.min,
|
|
1680
|
+
max: r.max,
|
|
1681
|
+
step: 500,
|
|
1682
|
+
value: r.min + r.max - k,
|
|
1683
|
+
onChange: (ce) => T(r.min + r.max - Number(ce.target.value)),
|
|
1684
|
+
"aria-label": be
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
/* @__PURE__ */ C("span", { className: "nice-tutorial__speed-value", children: [
|
|
1688
|
+
(k / 1e3).toFixed(1),
|
|
1689
|
+
"s"
|
|
1690
|
+
] })
|
|
1691
|
+
] })
|
|
1692
|
+
]
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1695
|
+
},
|
|
1696
|
+
[
|
|
1697
|
+
s,
|
|
1698
|
+
m,
|
|
1699
|
+
p,
|
|
1700
|
+
b,
|
|
1701
|
+
_,
|
|
1702
|
+
U,
|
|
1703
|
+
o,
|
|
1704
|
+
H,
|
|
1705
|
+
g,
|
|
1706
|
+
S,
|
|
1707
|
+
V,
|
|
1708
|
+
ue,
|
|
1709
|
+
re,
|
|
1710
|
+
be,
|
|
1711
|
+
ae,
|
|
1712
|
+
ye,
|
|
1713
|
+
le,
|
|
1714
|
+
w,
|
|
1715
|
+
i,
|
|
1716
|
+
Ne,
|
|
1717
|
+
h,
|
|
1718
|
+
e.length,
|
|
1719
|
+
me,
|
|
1720
|
+
k,
|
|
1721
|
+
r,
|
|
1722
|
+
L,
|
|
1723
|
+
y
|
|
1724
|
+
]
|
|
1725
|
+
);
|
|
1726
|
+
if (!n || !w)
|
|
1727
|
+
return null;
|
|
1728
|
+
const Ue = typeof document < "u" ? Math.max(document.documentElement.scrollWidth, window.innerWidth) : 0, je = typeof document < "u" ? Math.max(document.documentElement.scrollHeight, window.innerHeight) : 0;
|
|
1729
|
+
return /* @__PURE__ */ C(
|
|
1730
|
+
"div",
|
|
1731
|
+
{
|
|
1732
|
+
ref: xe,
|
|
1733
|
+
className: "nice-tutorial",
|
|
1734
|
+
style: { zIndex: L },
|
|
1735
|
+
"aria-modal": w.waitForAction || w.advanceOn ? void 0 : !0,
|
|
1736
|
+
role: "dialog",
|
|
1737
|
+
"aria-label": w.title ? void 0 : y("tutorial.tutorial", "Tutorial"),
|
|
1738
|
+
"aria-labelledby": w.title ? Le : void 0,
|
|
1739
|
+
"aria-describedby": w.content ? Ae : void 0,
|
|
1740
|
+
children: [
|
|
1741
|
+
/* @__PURE__ */ C(
|
|
1742
|
+
"svg",
|
|
1743
|
+
{
|
|
1744
|
+
className: "nice-tutorial__overlay",
|
|
1745
|
+
style: {
|
|
1746
|
+
position: "absolute",
|
|
1747
|
+
top: 0,
|
|
1748
|
+
left: 0,
|
|
1749
|
+
width: Ue,
|
|
1750
|
+
height: je,
|
|
1751
|
+
pointerEvents: "auto"
|
|
1752
|
+
},
|
|
1753
|
+
onClick: u ? o : void 0,
|
|
1754
|
+
children: [
|
|
1755
|
+
/* @__PURE__ */ t("defs", { children: /* @__PURE__ */ C("mask", { id: "nice-tutorial-mask", children: [
|
|
1756
|
+
/* @__PURE__ */ t("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "white" }),
|
|
1757
|
+
I && /* @__PURE__ */ t(
|
|
1758
|
+
"rect",
|
|
1759
|
+
{
|
|
1760
|
+
x: I.left,
|
|
1761
|
+
y: I.top,
|
|
1762
|
+
width: I.width,
|
|
1763
|
+
height: I.height,
|
|
1764
|
+
rx: "4",
|
|
1765
|
+
fill: "black",
|
|
1766
|
+
className: F ? "nice-tutorial__spotlight--entering" : ""
|
|
1767
|
+
}
|
|
1768
|
+
)
|
|
1769
|
+
] }) }),
|
|
1770
|
+
/* @__PURE__ */ t(
|
|
1771
|
+
"rect",
|
|
1772
|
+
{
|
|
1773
|
+
x: "0",
|
|
1774
|
+
y: "0",
|
|
1775
|
+
width: "100%",
|
|
1776
|
+
height: "100%",
|
|
1777
|
+
fill: `rgba(0,0,0,${M})`,
|
|
1778
|
+
mask: "url(#nice-tutorial-mask)"
|
|
1779
|
+
}
|
|
1780
|
+
)
|
|
1781
|
+
]
|
|
1782
|
+
}
|
|
1783
|
+
),
|
|
1784
|
+
I && /* @__PURE__ */ t(
|
|
1785
|
+
"div",
|
|
1786
|
+
{
|
|
1787
|
+
className: `nice-tutorial__highlight ${F ? "nice-tutorial__highlight--entering" : ""}`,
|
|
1788
|
+
style: {
|
|
1789
|
+
position: "absolute",
|
|
1790
|
+
top: I.top,
|
|
1791
|
+
left: I.left,
|
|
1792
|
+
width: I.width,
|
|
1793
|
+
height: I.height,
|
|
1794
|
+
transition: `all ${$}ms ease`
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
),
|
|
1798
|
+
w.disableInteraction && I && /* @__PURE__ */ t(
|
|
1799
|
+
"div",
|
|
1800
|
+
{
|
|
1801
|
+
className: "nice-tutorial__blocker",
|
|
1802
|
+
style: {
|
|
1803
|
+
position: "absolute",
|
|
1804
|
+
top: I.top,
|
|
1805
|
+
left: I.left,
|
|
1806
|
+
width: I.width,
|
|
1807
|
+
height: I.height
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
),
|
|
1811
|
+
/* @__PURE__ */ C(
|
|
1812
|
+
"div",
|
|
1813
|
+
{
|
|
1814
|
+
ref: O,
|
|
1815
|
+
className: `nice-tutorial__tooltip nice-tutorial__tooltip--${oe.actualPlacement} ${F ? "nice-tutorial__tooltip--entering" : ""}`,
|
|
1816
|
+
style: {
|
|
1817
|
+
position: "absolute",
|
|
1818
|
+
top: oe.top,
|
|
1819
|
+
left: oe.left,
|
|
1820
|
+
transition: `all ${$}ms ease`,
|
|
1821
|
+
maxWidth: 380,
|
|
1822
|
+
zIndex: L + 1
|
|
1823
|
+
},
|
|
1824
|
+
children: [
|
|
1825
|
+
w.showArrow !== !1 && /* @__PURE__ */ t(
|
|
1826
|
+
"div",
|
|
1827
|
+
{
|
|
1828
|
+
className: `nice-tutorial__arrow nice-tutorial__arrow--${oe.actualPlacement}`
|
|
1829
|
+
}
|
|
1830
|
+
),
|
|
1831
|
+
/* @__PURE__ */ C("div", { className: "nice-tutorial__header", children: [
|
|
1832
|
+
/* @__PURE__ */ t("h4", { id: Le, className: "nice-tutorial__title", children: w.title }),
|
|
1833
|
+
m && /* @__PURE__ */ t(
|
|
1834
|
+
"button",
|
|
1835
|
+
{
|
|
1836
|
+
type: "button",
|
|
1837
|
+
className: "nice-tutorial__close",
|
|
1838
|
+
onClick: o,
|
|
1839
|
+
"aria-label": Be,
|
|
1840
|
+
title: Be,
|
|
1841
|
+
children: /* @__PURE__ */ t(Wt, {})
|
|
1842
|
+
}
|
|
1843
|
+
)
|
|
1844
|
+
] }),
|
|
1845
|
+
/* @__PURE__ */ t(
|
|
1846
|
+
"div",
|
|
1847
|
+
{
|
|
1848
|
+
id: Ae,
|
|
1849
|
+
className: "nice-tutorial__content",
|
|
1850
|
+
dangerouslySetInnerHTML: { __html: $t(w.content) }
|
|
1851
|
+
}
|
|
1852
|
+
),
|
|
1853
|
+
z === "inline" && ke(!0)
|
|
1854
|
+
]
|
|
1855
|
+
}
|
|
1856
|
+
),
|
|
1857
|
+
z === "floating-bottom" && ke(!1)
|
|
1858
|
+
]
|
|
1859
|
+
}
|
|
1860
|
+
);
|
|
1861
|
+
};
|
|
1862
|
+
process.env.NODE_ENV !== "production" && (mt.displayName = "NiceTutorial");
|
|
1863
|
+
const ht = /* @__PURE__ */ dt({
|
|
1864
|
+
startTutorial: () => {
|
|
1865
|
+
},
|
|
1866
|
+
stopTutorial: () => {
|
|
1867
|
+
},
|
|
1868
|
+
isActive: !1,
|
|
1869
|
+
currentStep: 0,
|
|
1870
|
+
nextStep: () => {
|
|
1871
|
+
},
|
|
1872
|
+
prevStep: () => {
|
|
1873
|
+
},
|
|
1874
|
+
goToStep: () => {
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
function kn() {
|
|
1878
|
+
return it(ht);
|
|
1879
|
+
}
|
|
1880
|
+
const Zt = ({ children: e }) => {
|
|
1881
|
+
const [n, c] = B([]), [o, a] = B(!1), [l, u] = B(0), p = v((z) => {
|
|
1882
|
+
c(z), u(0), a(!0);
|
|
1883
|
+
}, []), m = v(() => {
|
|
1884
|
+
a(!1), u(0), c([]);
|
|
1885
|
+
}, []), E = v(() => {
|
|
1886
|
+
u((z) => Math.min(z + 1, n.length - 1));
|
|
1887
|
+
}, [n.length]), $ = v(() => {
|
|
1888
|
+
u((z) => Math.max(z - 1, 0));
|
|
1889
|
+
}, []), M = v(
|
|
1890
|
+
(z) => {
|
|
1891
|
+
u(Math.max(0, Math.min(z, n.length - 1)));
|
|
1892
|
+
},
|
|
1893
|
+
[n.length]
|
|
1894
|
+
), L = {
|
|
1895
|
+
startTutorial: p,
|
|
1896
|
+
stopTutorial: m,
|
|
1897
|
+
isActive: o,
|
|
1898
|
+
currentStep: l,
|
|
1899
|
+
nextStep: E,
|
|
1900
|
+
prevStep: $,
|
|
1901
|
+
goToStep: M
|
|
1902
|
+
};
|
|
1903
|
+
return /* @__PURE__ */ C(ht.Provider, { value: L, children: [
|
|
1904
|
+
e,
|
|
1905
|
+
o && n.length > 0 && /* @__PURE__ */ t(
|
|
1906
|
+
mt,
|
|
1907
|
+
{
|
|
1908
|
+
steps: n,
|
|
1909
|
+
active: o,
|
|
1910
|
+
onFinish: m,
|
|
1911
|
+
onSkip: m,
|
|
1912
|
+
onStepChange: u
|
|
1913
|
+
}
|
|
1914
|
+
)
|
|
1915
|
+
] });
|
|
1916
|
+
};
|
|
1917
|
+
process.env.NODE_ENV !== "production" && (Zt.displayName = "NiceTutorialProvider");
|
|
1918
|
+
function Jt(e, n, c, o, a) {
|
|
1919
|
+
const l = e <= a, u = e + a >= c, p = n <= a, m = n + a >= o;
|
|
1920
|
+
return p && l ? "top-left" : p && u ? "top-right" : m && l ? "bottom-left" : m && u ? "bottom-right" : l ? "left" : u ? "right" : p ? "top" : m ? "bottom" : "none";
|
|
1921
|
+
}
|
|
1922
|
+
function en(e) {
|
|
1923
|
+
switch (e) {
|
|
1924
|
+
case "left":
|
|
1925
|
+
return { left: 0, top: 0, width: "50%", height: "100%" };
|
|
1926
|
+
case "right":
|
|
1927
|
+
return { left: "50%", top: 0, width: "50%", height: "100%" };
|
|
1928
|
+
case "top":
|
|
1929
|
+
return { left: 0, top: 0, width: "100%", height: "50%" };
|
|
1930
|
+
case "bottom":
|
|
1931
|
+
return { left: 0, top: "50%", width: "100%", height: "50%" };
|
|
1932
|
+
case "top-left":
|
|
1933
|
+
return { left: 0, top: 0, width: "50%", height: "50%" };
|
|
1934
|
+
case "top-right":
|
|
1935
|
+
return { left: "50%", top: 0, width: "50%", height: "50%" };
|
|
1936
|
+
case "bottom-left":
|
|
1937
|
+
return { left: 0, top: "50%", width: "50%", height: "50%" };
|
|
1938
|
+
case "bottom-right":
|
|
1939
|
+
return { left: "50%", top: "50%", width: "50%", height: "50%" };
|
|
1940
|
+
default:
|
|
1941
|
+
return null;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
const En = /* @__PURE__ */ Object.assign(
|
|
1945
|
+
/* @__PURE__ */ ot(
|
|
1946
|
+
({
|
|
1947
|
+
windowKey: e,
|
|
1948
|
+
title: n,
|
|
1949
|
+
icon: c,
|
|
1950
|
+
children: o,
|
|
1951
|
+
footer: a,
|
|
1952
|
+
x: l,
|
|
1953
|
+
y: u,
|
|
1954
|
+
defaultPosition: p,
|
|
1955
|
+
width: m = 480,
|
|
1956
|
+
height: E = 360,
|
|
1957
|
+
minWidth: $ = 200,
|
|
1958
|
+
minHeight: M = 120,
|
|
1959
|
+
maxWidth: L,
|
|
1960
|
+
maxHeight: z,
|
|
1961
|
+
zIndex: b = 1,
|
|
1962
|
+
closable: s = !0,
|
|
1963
|
+
minimizable: d = !0,
|
|
1964
|
+
maximizable: r = !0,
|
|
1965
|
+
fullscreenable: f = !1,
|
|
1966
|
+
pinnable: y = !1,
|
|
1967
|
+
resizable: h = !0,
|
|
1968
|
+
draggable: Y = !0,
|
|
1969
|
+
snappable: I = !0,
|
|
1970
|
+
snapThreshold: Q = 20,
|
|
1971
|
+
minimized: D,
|
|
1972
|
+
maximized: R,
|
|
1973
|
+
fullscreen: F,
|
|
1974
|
+
pinned: N,
|
|
1975
|
+
focused: i,
|
|
1976
|
+
onClose: x,
|
|
1977
|
+
onMinimize: k,
|
|
1978
|
+
onMaximize: T,
|
|
1979
|
+
onFullscreen: O,
|
|
1980
|
+
onPin: q,
|
|
1981
|
+
onFocus: w,
|
|
1982
|
+
onMove: U,
|
|
1983
|
+
onResize: _,
|
|
1984
|
+
onSnap: S,
|
|
1985
|
+
onTitleBarDoubleClick: g,
|
|
1986
|
+
size: V = "md",
|
|
1987
|
+
statusBar: H,
|
|
1988
|
+
titleBarActions: ae,
|
|
1989
|
+
className: ue,
|
|
1990
|
+
style: re,
|
|
1991
|
+
id: be,
|
|
1992
|
+
accessMode: Be,
|
|
1993
|
+
...le
|
|
1994
|
+
}, ye) => {
|
|
1995
|
+
const He = nt(be), xe = Rt(Be, be), { t: J } = ze(), Me = A(null);
|
|
1996
|
+
Me.current == null && (Me.current = `nice-window-${Math.random().toString(36).slice(2, 10)}`);
|
|
1997
|
+
const j = e ?? Me.current, Le = l ?? p?.x ?? 100, Ae = u ?? p?.y ?? 100, [Ne, oe] = B({ x: Le, y: Ae }), [me, ke] = B({ width: m, height: E }), [Ue, je] = B(!1), [P, W] = B(!1), [Z, Ye] = B(!1), [Ke, Ve] = B(!1), [ce, Ge] = B("none"), ft = D ?? Ue, se = R ?? P, ne = F ?? Z, Oe = N ?? Ke, Fe = i ?? !0, Ee = Ne.x, Ie = Ne.y, he = me.width, fe = me.height, pe = A(null), ie = A(null), G = A(null), pt = v(() => {
|
|
1998
|
+
x?.(j);
|
|
1999
|
+
}, [j, x]), wt = v(() => {
|
|
2000
|
+
je(!0), k?.(j);
|
|
2001
|
+
}, [j, k]), Qe = v(() => {
|
|
2002
|
+
const X = !se;
|
|
2003
|
+
W(X), !X && G.current ? (oe({ x: G.current.x, y: G.current.y }), ke({ width: G.current.w, height: G.current.h }), G.current = null) : X && (G.current = { x: Ee, y: Ie, w: he, h: fe }), Ge("none"), T?.(j, X);
|
|
2004
|
+
}, [j, se, Ee, Ie, he, fe, T]), Ze = v(() => {
|
|
2005
|
+
const X = !ne;
|
|
2006
|
+
Ye(X), X ? G.current = { x: Ee, y: Ie, w: he, h: fe } : G.current && (oe({ x: G.current.x, y: G.current.y }), ke({ width: G.current.w, height: G.current.h }), G.current = null), O?.(j, X);
|
|
2007
|
+
}, [j, ne, Ee, Ie, he, fe, O]), gt = v(() => {
|
|
2008
|
+
const X = !Oe;
|
|
2009
|
+
Ve(X), q?.(j, X);
|
|
2010
|
+
}, [j, Oe, q]), Ce = v(() => {
|
|
2011
|
+
w?.(j);
|
|
2012
|
+
}, [j, w]), _t = v(() => {
|
|
2013
|
+
g ? g(j) : r && Qe();
|
|
2014
|
+
}, [j, r, Qe, g]);
|
|
2015
|
+
K(() => {
|
|
2016
|
+
const X = (we) => {
|
|
2017
|
+
if (!pe.current)
|
|
2018
|
+
return;
|
|
2019
|
+
const de = we.clientX - pe.current.startX + pe.current.origX, De = we.clientY - pe.current.startY + pe.current.origY;
|
|
2020
|
+
oe({ x: de, y: De }), U?.(j, { x: de, y: De });
|
|
2021
|
+
}, te = (we) => {
|
|
2022
|
+
if (pe.current) {
|
|
2023
|
+
if (I) {
|
|
2024
|
+
const de = Jt(
|
|
2025
|
+
we.clientX,
|
|
2026
|
+
we.clientY,
|
|
2027
|
+
window.innerWidth,
|
|
2028
|
+
window.innerHeight,
|
|
2029
|
+
Q
|
|
2030
|
+
);
|
|
2031
|
+
de !== "none" && (G.current = { x: Ne.x, y: Ne.y, w: he, h: fe }, Ge(de), S?.(j, de));
|
|
2032
|
+
}
|
|
2033
|
+
pe.current = null;
|
|
2034
|
+
}
|
|
2035
|
+
};
|
|
2036
|
+
return document.addEventListener("mousemove", X), document.addEventListener("mouseup", te), () => {
|
|
2037
|
+
document.removeEventListener("mousemove", X), document.removeEventListener("mouseup", te);
|
|
2038
|
+
};
|
|
2039
|
+
});
|
|
2040
|
+
const vt = v(
|
|
2041
|
+
(X) => {
|
|
2042
|
+
!Y || se || ne || (X.preventDefault(), ce !== "none" && (G.current && (oe({ x: G.current.x, y: G.current.y }), ke({ width: G.current.w, height: G.current.h })), Ge("none")), Ce(), pe.current = { startX: X.clientX, startY: X.clientY, origX: Ee, origY: Ie });
|
|
2043
|
+
},
|
|
2044
|
+
[Y, se, ne, ce, Ee, Ie, Ce]
|
|
2045
|
+
);
|
|
2046
|
+
K(() => {
|
|
2047
|
+
const X = (we) => {
|
|
2048
|
+
if (!ie.current)
|
|
2049
|
+
return;
|
|
2050
|
+
const de = we.clientX - ie.current.startX, De = we.clientY - ie.current.startY, $e = ie.current.handle;
|
|
2051
|
+
let ge = ie.current.origW, _e = ie.current.origH;
|
|
2052
|
+
if ($e.includes("e") && (ge = ie.current.origW + de), $e.includes("w") && (ge = ie.current.origW - de), $e.includes("s") && (_e = ie.current.origH + De), $e.includes("n") && (_e = ie.current.origH - De), ge = Math.max($, L ? Math.min(L, ge) : ge), _e = Math.max(M, z ? Math.min(z, _e) : _e), $e.includes("w")) {
|
|
2053
|
+
const Je = me.width - ge;
|
|
2054
|
+
oe((Xe) => ({ ...Xe, x: Xe.x + Je }));
|
|
2055
|
+
}
|
|
2056
|
+
if ($e.includes("n")) {
|
|
2057
|
+
const Je = me.height - _e;
|
|
2058
|
+
oe((Xe) => ({ ...Xe, y: Xe.y + Je }));
|
|
2059
|
+
}
|
|
2060
|
+
ke({ width: ge, height: _e }), _?.(j, { width: ge, height: _e });
|
|
2061
|
+
}, te = () => {
|
|
2062
|
+
ie.current = null;
|
|
2063
|
+
};
|
|
2064
|
+
return document.addEventListener("mousemove", X), document.addEventListener("mouseup", te), () => {
|
|
2065
|
+
document.removeEventListener("mousemove", X), document.removeEventListener("mouseup", te);
|
|
2066
|
+
};
|
|
2067
|
+
});
|
|
2068
|
+
const bt = v(
|
|
2069
|
+
(X, te) => {
|
|
2070
|
+
!h || se || ne || ce !== "none" || (te.preventDefault(), te.stopPropagation(), Ce(), ie.current = { startX: te.clientX, startY: te.clientY, origW: he, origH: fe, handle: X });
|
|
2071
|
+
},
|
|
2072
|
+
[h, se, ne, ce, he, fe, Ce]
|
|
2073
|
+
);
|
|
2074
|
+
if (K(() => {
|
|
2075
|
+
if (!Fe)
|
|
2076
|
+
return;
|
|
2077
|
+
const X = (te) => {
|
|
2078
|
+
te.key === "Escape" && ne && Ze();
|
|
2079
|
+
};
|
|
2080
|
+
return document.addEventListener("keydown", X), () => document.removeEventListener("keydown", X);
|
|
2081
|
+
}, [Fe, ne, Ze]), xe === "hidden" || ft)
|
|
2082
|
+
return null;
|
|
2083
|
+
const ct = ce !== "none" ? en(ce) : null, rt = se || ne, yt = ne ? { position: "fixed", top: 0, left: 0, width: "100vw", height: "100vh", zIndex: 999999 } : se ? { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", zIndex: b } : ct ? { position: "absolute", ...ct, zIndex: b } : { position: "absolute", top: Ie, left: Ee, width: he, height: fe, zIndex: b }, xt = ["n", "e", "s", "w", "ne", "se", "sw", "nw"], Nt = {
|
|
2084
|
+
n: "ns-resize",
|
|
2085
|
+
s: "ns-resize",
|
|
2086
|
+
e: "ew-resize",
|
|
2087
|
+
w: "ew-resize",
|
|
2088
|
+
ne: "nesw-resize",
|
|
2089
|
+
sw: "nesw-resize",
|
|
2090
|
+
nw: "nwse-resize",
|
|
2091
|
+
se: "nwse-resize"
|
|
2092
|
+
};
|
|
2093
|
+
return (
|
|
2094
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- a press raises the window; focus moving in does it from the keyboard
|
|
2095
|
+
/* @__PURE__ */ C(
|
|
2096
|
+
"div",
|
|
2097
|
+
{
|
|
2098
|
+
ref: ye,
|
|
2099
|
+
id: He,
|
|
2100
|
+
className: `nice-window nice-window--${V} ${Fe ? "nice-window--focused" : ""} ${Oe ? "nice-window--pinned" : ""} ${rt ? "nice-window--maximized" : ""} ${ce !== "none" ? `nice-window--snapped-${ce}` : ""} ${ue ?? ""}`,
|
|
2101
|
+
style: { ...yt, ...re },
|
|
2102
|
+
onMouseDown: Ce,
|
|
2103
|
+
onFocus: Fe ? void 0 : Ce,
|
|
2104
|
+
role: "dialog",
|
|
2105
|
+
"aria-label": n,
|
|
2106
|
+
tabIndex: -1,
|
|
2107
|
+
"data-nice-focus-scope": "spatial",
|
|
2108
|
+
"data-nice-region": n,
|
|
2109
|
+
...le,
|
|
2110
|
+
children: [
|
|
2111
|
+
/* @__PURE__ */ C(
|
|
2112
|
+
"div",
|
|
2113
|
+
{
|
|
2114
|
+
className: "nice-window__titlebar",
|
|
2115
|
+
onMouseDown: vt,
|
|
2116
|
+
onDoubleClick: _t,
|
|
2117
|
+
children: [
|
|
2118
|
+
c && /* @__PURE__ */ t("span", { className: "nice-window__icon", children: c }),
|
|
2119
|
+
/* @__PURE__ */ t("span", { className: "nice-window__title", children: n }),
|
|
2120
|
+
/* @__PURE__ */ C("div", { className: "nice-window__actions", children: [
|
|
2121
|
+
ae,
|
|
2122
|
+
y && /* @__PURE__ */ t(
|
|
2123
|
+
"button",
|
|
2124
|
+
{
|
|
2125
|
+
type: "button",
|
|
2126
|
+
className: `nice-window__action nice-window__action--pin ${Oe ? "nice-window__action--active" : ""}`,
|
|
2127
|
+
onClick: gt,
|
|
2128
|
+
title: Oe ? J("window.unpin", "Unpin") : J("window.pin", "Pin"),
|
|
2129
|
+
children: /* @__PURE__ */ t(ee, { name: "paperclip", size: 14 })
|
|
2130
|
+
}
|
|
2131
|
+
),
|
|
2132
|
+
d && /* @__PURE__ */ t(
|
|
2133
|
+
"button",
|
|
2134
|
+
{
|
|
2135
|
+
type: "button",
|
|
2136
|
+
className: "nice-window__action nice-window__action--minimize",
|
|
2137
|
+
onClick: wt,
|
|
2138
|
+
title: J("window.minimize", "Minimize"),
|
|
2139
|
+
children: /* @__PURE__ */ t(ee, { name: "minus", size: 14 })
|
|
2140
|
+
}
|
|
2141
|
+
),
|
|
2142
|
+
r && /* @__PURE__ */ t(
|
|
2143
|
+
"button",
|
|
2144
|
+
{
|
|
2145
|
+
type: "button",
|
|
2146
|
+
className: "nice-window__action nice-window__action--maximize",
|
|
2147
|
+
onClick: Qe,
|
|
2148
|
+
title: se ? J("window.restore", "Restore") : J("window.maximize", "Maximize"),
|
|
2149
|
+
children: /* @__PURE__ */ t(ee, { name: se ? "copy" : "window", size: 14 })
|
|
2150
|
+
}
|
|
2151
|
+
),
|
|
2152
|
+
f && /* @__PURE__ */ t(
|
|
2153
|
+
"button",
|
|
2154
|
+
{
|
|
2155
|
+
type: "button",
|
|
2156
|
+
className: "nice-window__action nice-window__action--fullscreen",
|
|
2157
|
+
onClick: Ze,
|
|
2158
|
+
title: ne ? J("window.exitFullscreen", "Exit Full Screen") : J("window.fullscreen", "Full Screen"),
|
|
2159
|
+
children: /* @__PURE__ */ t(ee, { name: ne ? "collapse" : "expand", size: 14 })
|
|
2160
|
+
}
|
|
2161
|
+
),
|
|
2162
|
+
s && /* @__PURE__ */ t(
|
|
2163
|
+
"button",
|
|
2164
|
+
{
|
|
2165
|
+
type: "button",
|
|
2166
|
+
className: "nice-window__action nice-window__action--close",
|
|
2167
|
+
onClick: pt,
|
|
2168
|
+
title: J("window.close", "Close"),
|
|
2169
|
+
children: /* @__PURE__ */ t(ee, { name: "close", size: 14 })
|
|
2170
|
+
}
|
|
2171
|
+
)
|
|
2172
|
+
] })
|
|
2173
|
+
]
|
|
2174
|
+
}
|
|
2175
|
+
),
|
|
2176
|
+
/* @__PURE__ */ t("div", { className: "nice-window__body", children: o }),
|
|
2177
|
+
a && /* @__PURE__ */ t("div", { className: "nice-window__footer", children: a }),
|
|
2178
|
+
H && /* @__PURE__ */ t("div", { className: "nice-window__statusbar", children: H }),
|
|
2179
|
+
h && !rt && ce === "none" && /* @__PURE__ */ t(Te, { children: xt.map((X) => /* @__PURE__ */ t(
|
|
2180
|
+
"div",
|
|
2181
|
+
{
|
|
2182
|
+
className: `nice-window__resize nice-window__resize--${X}`,
|
|
2183
|
+
style: { cursor: Nt[X] },
|
|
2184
|
+
onMouseDown: (te) => bt(X, te)
|
|
2185
|
+
},
|
|
2186
|
+
X
|
|
2187
|
+
)) })
|
|
2188
|
+
]
|
|
2189
|
+
}
|
|
2190
|
+
)
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2193
|
+
),
|
|
2194
|
+
{ displayName: "NiceWindow" }
|
|
2195
|
+
);
|
|
2196
|
+
export {
|
|
2197
|
+
rn as N,
|
|
2198
|
+
xn as a,
|
|
2199
|
+
ln as b,
|
|
2200
|
+
At as c,
|
|
2201
|
+
an as d,
|
|
2202
|
+
pn as e,
|
|
2203
|
+
wn as f,
|
|
2204
|
+
fn as g,
|
|
2205
|
+
_n as h,
|
|
2206
|
+
bn as i,
|
|
2207
|
+
gn as j,
|
|
2208
|
+
hn as k,
|
|
2209
|
+
vn as l,
|
|
2210
|
+
sn as m,
|
|
2211
|
+
un as n,
|
|
2212
|
+
dn as o,
|
|
2213
|
+
mn as p,
|
|
2214
|
+
mt as q,
|
|
2215
|
+
Zt as r,
|
|
2216
|
+
En as s,
|
|
2217
|
+
Nn as t,
|
|
2218
|
+
Ht as u,
|
|
2219
|
+
yn as v,
|
|
2220
|
+
et as w,
|
|
2221
|
+
Xt as x,
|
|
2222
|
+
kn as y
|
|
2223
|
+
};
|