@nice2dev/ui 1.0.21 → 1.0.22
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 +144 -0
- package/dist/NiceErrorBoundary-B0262Ffc.js +770 -0
- package/dist/NiceErrorBoundary-BXOLv-zG.cjs +1 -0
- package/dist/NiceErrorBoundary-DsreAsON.cjs +1 -0
- package/dist/NiceErrorBoundary-HMfrXIir.js +770 -0
- package/dist/NiceForm-B7D1MASh.js +5383 -0
- package/dist/NiceForm-BA9zZdm8.cjs +382 -0
- package/dist/NiceForm-Ba9rvBoT.cjs +382 -0
- package/dist/NiceForm-DAGMJpgx.js +5383 -0
- package/dist/NiceModal-BVT9cZbf.cjs +1 -0
- package/dist/NiceModal-CiOYOWJy.cjs +1 -0
- package/dist/NiceModal-DZbHCdKq.js +95 -0
- package/dist/NiceModal-MeC1cNtW.js +95 -0
- package/dist/NiceModuleLifecyclePanel-BiX4KxaK.js +6781 -0
- package/dist/NiceModuleLifecyclePanel-CDo0iVfr.js +6781 -0
- package/dist/NiceModuleLifecyclePanel-DEJpoz5a.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DrDTpH6K.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-C8gx6Bcl.js +171 -0
- package/dist/NicePagination-CNxEAb4C.cjs +1 -0
- package/dist/NicePagination-Cg_WEf-R.cjs +1 -0
- package/dist/NicePagination-DQXdzx7W.js +171 -0
- package/dist/NicePinCodeInput-3WugpLHi.js +12240 -0
- package/dist/NicePinCodeInput-CSfRHs4v.cjs +419 -0
- package/dist/NicePinCodeInput-CjwFvOEQ.js +13092 -0
- package/dist/NicePinCodeInput-DoBQnMj9.cjs +694 -0
- package/dist/NiceSavedQueryPanel-DFDDuKWd.js +6597 -0
- package/dist/NiceSavedQueryPanel-DTU4eiIH.cjs +596 -0
- package/dist/NiceSavedQueryPanel-qtWETcRP.cjs +596 -0
- package/dist/NiceSavedQueryPanel-z29D7N_A.js +6584 -0
- package/dist/NiceTabs-B4dM77y_.js +1657 -0
- package/dist/NiceTabs-BTVTtRZR.cjs +1 -0
- package/dist/NiceTabs-BXGmot7J.cjs +1 -0
- package/dist/NiceTabs-DJdhKste.js +1657 -0
- package/dist/NiceWindow-Cs6-Dbci.js +1592 -0
- package/dist/NiceWindow-DYw4NCeb.js +1592 -0
- package/dist/NiceWindow-O_g8StvA.cjs +1 -0
- package/dist/NiceWindow-a4wB_m30.cjs +1 -0
- package/dist/NiceWindow.css +1 -0
- package/dist/charts-BDr6B81L.js +4657 -0
- package/dist/charts-Ci_KrAoU.cjs +761 -0
- package/dist/charts-ClxW-i5q.js +4657 -0
- package/dist/charts-Dr_FIPZT.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-BIz6zQ5u.cjs +122 -0
- package/dist/core-BYxnKGOi.js +23141 -0
- package/dist/core-Cjw8oBvC.cjs +96 -0
- package/dist/core-xcuNJ-DB.js +24948 -0
- package/dist/data-branching-Byz79mmA.cjs +1 -0
- package/dist/data-branching-DjuerHfS.js +6133 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.d.ts +3 -0
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +10 -7
- package/dist/data.mjs +1 -1
- package/dist/devops-DYFov8j3.js +7684 -0
- package/dist/devops-g4qcLXah.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +5 -0
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +172 -1
- package/dist/editors.mjs +44 -41
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +1 -2
- package/dist/feedback.mjs +2 -2
- package/dist/index-AEO3cK4T.cjs +5194 -0
- package/dist/index-BMQ-F0zE.js +65054 -0
- package/dist/index-BNb9q4Ll.cjs +5490 -0
- package/dist/index-CjdfogVa.js +66711 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +504 -25
- package/dist/index.mjs +979 -963
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +11 -0
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.mjs +34 -34
- package/dist/no-code-Dl3ima61.cjs +332 -0
- package/dist/no-code-ktRzFaET.js +7133 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +11 -0
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +38 -0
- package/dist/overlays.mjs +48 -48
- package/dist/style.css +5 -2
- package/package.json +1 -1
|
@@ -0,0 +1,1592 @@
|
|
|
1
|
+
import { jsxs as g, Fragment as Ae, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Z as Pe, M as wt, D as Fe, T as _t, a as gt } from "./core-xcuNJ-DB.js";
|
|
3
|
+
import vt, { useRef as V, useState as X, useCallback as x, useEffect as A, useReducer as bt, useMemo as $e, useContext as je, createContext as Ge, forwardRef as He } from "react";
|
|
4
|
+
const Wt = ({
|
|
5
|
+
visible: e,
|
|
6
|
+
onClose: n,
|
|
7
|
+
title: i,
|
|
8
|
+
items: s,
|
|
9
|
+
showCancelButton: u = !0,
|
|
10
|
+
cancelText: m,
|
|
11
|
+
className: p,
|
|
12
|
+
style: w
|
|
13
|
+
}) => {
|
|
14
|
+
const { t: f } = Pe();
|
|
15
|
+
return e ? /* @__PURE__ */ g(Ae, { children: [
|
|
16
|
+
/* @__PURE__ */ t("div", { className: "nice-actionsheet__overlay", onClick: n }),
|
|
17
|
+
/* @__PURE__ */ g("div", { className: `nice-actionsheet ${p || ""}`, style: w, children: [
|
|
18
|
+
i && /* @__PURE__ */ t("div", { className: "nice-actionsheet__title", children: i }),
|
|
19
|
+
/* @__PURE__ */ t("div", { className: "nice-actionsheet__items", children: s.map((b, l) => /* @__PURE__ */ g(
|
|
20
|
+
"button",
|
|
21
|
+
{
|
|
22
|
+
className: `nice-actionsheet__item ${b.type === "danger" ? "nice-actionsheet__item--danger" : ""}`,
|
|
23
|
+
disabled: b.disabled,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
b.onClick?.(), n();
|
|
26
|
+
},
|
|
27
|
+
children: [
|
|
28
|
+
b.icon && /* @__PURE__ */ t("span", { className: "nice-actionsheet__icon", children: b.icon }),
|
|
29
|
+
b.text
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
l
|
|
33
|
+
)) }),
|
|
34
|
+
u && /* @__PURE__ */ t("button", { className: "nice-actionsheet__cancel", onClick: n, children: m || f("cancel", "Cancel") })
|
|
35
|
+
] })
|
|
36
|
+
] }) : null;
|
|
37
|
+
}, At = ({
|
|
38
|
+
visible: e,
|
|
39
|
+
onClose: n,
|
|
40
|
+
targetRef: i,
|
|
41
|
+
position: s = "bottom",
|
|
42
|
+
title: u,
|
|
43
|
+
showArrow: m = !0,
|
|
44
|
+
width: p,
|
|
45
|
+
children: w,
|
|
46
|
+
className: f,
|
|
47
|
+
style: b,
|
|
48
|
+
displayStyle: l
|
|
49
|
+
}) => {
|
|
50
|
+
wt("tooltip", l);
|
|
51
|
+
const k = V(null), [B, L] = X({ top: 0, left: 0 }), I = x(() => {
|
|
52
|
+
const R = i.current, O = k.current;
|
|
53
|
+
if (!R || !O)
|
|
54
|
+
return;
|
|
55
|
+
const c = R.getBoundingClientRect(), v = O.getBoundingClientRect();
|
|
56
|
+
let r = 0, E = 0;
|
|
57
|
+
const _ = 8;
|
|
58
|
+
switch (s) {
|
|
59
|
+
case "top":
|
|
60
|
+
r = c.top - v.height - _, E = c.left + (c.width - v.width) / 2;
|
|
61
|
+
break;
|
|
62
|
+
case "bottom":
|
|
63
|
+
r = c.bottom + _, E = c.left + (c.width - v.width) / 2;
|
|
64
|
+
break;
|
|
65
|
+
case "left":
|
|
66
|
+
r = c.top + (c.height - v.height) / 2, E = c.left - v.width - _;
|
|
67
|
+
break;
|
|
68
|
+
case "right":
|
|
69
|
+
r = c.top + (c.height - v.height) / 2, E = c.right + _;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
L({ top: r + window.scrollY, left: E + window.scrollX });
|
|
73
|
+
}, [i, s]);
|
|
74
|
+
return A(() => {
|
|
75
|
+
if (e) {
|
|
76
|
+
requestAnimationFrame(I);
|
|
77
|
+
const R = (O) => {
|
|
78
|
+
k.current && !k.current.contains(O.target) && i.current && !i.current.contains(O.target) && n();
|
|
79
|
+
};
|
|
80
|
+
return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
|
|
81
|
+
}
|
|
82
|
+
}, [e, I, n, i]), e ? /* @__PURE__ */ g(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
ref: k,
|
|
86
|
+
className: `nice-popover nice-popover--${s} ${f || ""}`,
|
|
87
|
+
style: { ...b, position: "absolute", top: B.top, left: B.left, width: p },
|
|
88
|
+
children: [
|
|
89
|
+
m && /* @__PURE__ */ t("div", { className: `nice-popover__arrow nice-popover__arrow--${s}` }),
|
|
90
|
+
u && /* @__PURE__ */ t("div", { className: "nice-popover__title", children: u }),
|
|
91
|
+
/* @__PURE__ */ t("div", { className: "nice-popover__content", children: w })
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
) : null;
|
|
95
|
+
}, Ft = ({
|
|
96
|
+
visible: e,
|
|
97
|
+
message: n,
|
|
98
|
+
container: i,
|
|
99
|
+
showIndicator: s = !0,
|
|
100
|
+
shading: u = !0,
|
|
101
|
+
className: m,
|
|
102
|
+
style: p
|
|
103
|
+
}) => {
|
|
104
|
+
const { t: w } = Pe();
|
|
105
|
+
if (!e)
|
|
106
|
+
return null;
|
|
107
|
+
const f = !!i?.current, b = /* @__PURE__ */ g("div", { className: `nice-loadpanel ${m || ""}`, style: p, children: [
|
|
108
|
+
u && /* @__PURE__ */ t("div", { className: "nice-loadpanel__shade" }),
|
|
109
|
+
/* @__PURE__ */ g("div", { className: "nice-loadpanel__box", children: [
|
|
110
|
+
s && /* @__PURE__ */ t("div", { className: "nice-spinner nice-spinner--md" }),
|
|
111
|
+
/* @__PURE__ */ t("span", { className: "nice-loadpanel__text", children: n || w("loading", "Loading...") })
|
|
112
|
+
] })
|
|
113
|
+
] });
|
|
114
|
+
if (f && i.current) {
|
|
115
|
+
const l = i.current;
|
|
116
|
+
return l.style.position = l.style.position || "relative", b;
|
|
117
|
+
}
|
|
118
|
+
return b;
|
|
119
|
+
}, Ht = ({
|
|
120
|
+
direction: e = "row",
|
|
121
|
+
align: n,
|
|
122
|
+
justify: i,
|
|
123
|
+
wrap: s,
|
|
124
|
+
gap: u,
|
|
125
|
+
flex: m,
|
|
126
|
+
children: p,
|
|
127
|
+
className: w,
|
|
128
|
+
style: f
|
|
129
|
+
}) => /* @__PURE__ */ t(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: `nice-box ${w || ""}`,
|
|
133
|
+
style: {
|
|
134
|
+
display: "flex",
|
|
135
|
+
flexDirection: e,
|
|
136
|
+
alignItems: n,
|
|
137
|
+
justifyContent: i,
|
|
138
|
+
flexWrap: s ? "wrap" : void 0,
|
|
139
|
+
gap: u,
|
|
140
|
+
flex: m,
|
|
141
|
+
...f
|
|
142
|
+
},
|
|
143
|
+
children: p
|
|
144
|
+
}
|
|
145
|
+
), Ut = ({
|
|
146
|
+
direction: e = "row",
|
|
147
|
+
items: n,
|
|
148
|
+
gap: i,
|
|
149
|
+
className: s,
|
|
150
|
+
style: u
|
|
151
|
+
}) => /* @__PURE__ */ t(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
className: `nice-responsivebox ${s || ""}`,
|
|
155
|
+
style: { display: "flex", flexDirection: e, gap: i, ...u },
|
|
156
|
+
children: n.map((m, p) => /* @__PURE__ */ t(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
style: { flex: m.ratio ?? 1, flexBasis: m.baseSize, flexShrink: m.shrink ?? 1 },
|
|
160
|
+
children: m.children
|
|
161
|
+
},
|
|
162
|
+
p
|
|
163
|
+
))
|
|
164
|
+
}
|
|
165
|
+
), Kt = ({
|
|
166
|
+
width: e = 200,
|
|
167
|
+
height: n = 200,
|
|
168
|
+
minWidth: i = 50,
|
|
169
|
+
minHeight: s = 50,
|
|
170
|
+
maxWidth: u = 1 / 0,
|
|
171
|
+
maxHeight: m = 1 / 0,
|
|
172
|
+
handles: p = ["right", "bottom", "bottomRight"],
|
|
173
|
+
onResize: w,
|
|
174
|
+
children: f,
|
|
175
|
+
className: b,
|
|
176
|
+
style: l
|
|
177
|
+
}) => {
|
|
178
|
+
const [k, B] = X({ width: e, height: n }), L = V(null), I = (c, v) => {
|
|
179
|
+
v.preventDefault();
|
|
180
|
+
const r = v.clientX, E = v.clientY, _ = k.width, G = k.height, S = {
|
|
181
|
+
n: "top",
|
|
182
|
+
s: "bottom",
|
|
183
|
+
e: "right",
|
|
184
|
+
w: "left",
|
|
185
|
+
ne: "topRight",
|
|
186
|
+
se: "bottomRight",
|
|
187
|
+
sw: "bottomLeft",
|
|
188
|
+
nw: "topLeft"
|
|
189
|
+
}[c] ?? c, o = S === "right" || S === "topRight" || S === "bottomRight", z = S === "left" || S === "topLeft" || S === "bottomLeft", N = S === "bottom" || S === "bottomRight" || S === "bottomLeft", T = S === "top" || S === "topRight" || S === "topLeft", a = (d) => {
|
|
190
|
+
const $ = d.clientX - r, h = d.clientY - E;
|
|
191
|
+
let Y = _, F = G;
|
|
192
|
+
o && (Y = _ + $), z && (Y = _ - $), N && (F = G + h), T && (F = G - h), Y = Math.max(i, Math.min(u, Y)), F = Math.max(s, Math.min(m, F)), B({ width: Y, height: F }), w?.({ width: Y, height: F });
|
|
193
|
+
}, y = () => {
|
|
194
|
+
document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", y);
|
|
195
|
+
};
|
|
196
|
+
document.addEventListener("pointermove", a), document.addEventListener("pointerup", y);
|
|
197
|
+
}, R = (c) => {
|
|
198
|
+
switch (c) {
|
|
199
|
+
case "top":
|
|
200
|
+
case "bottom":
|
|
201
|
+
return "ns-resize";
|
|
202
|
+
case "left":
|
|
203
|
+
case "right":
|
|
204
|
+
return "ew-resize";
|
|
205
|
+
case "topLeft":
|
|
206
|
+
case "bottomRight":
|
|
207
|
+
return "nwse-resize";
|
|
208
|
+
case "topRight":
|
|
209
|
+
case "bottomLeft":
|
|
210
|
+
return "nesw-resize";
|
|
211
|
+
default:
|
|
212
|
+
return "default";
|
|
213
|
+
}
|
|
214
|
+
}, O = (c) => {
|
|
215
|
+
const v = { position: "absolute", zIndex: 1 }, r = 8;
|
|
216
|
+
return c === "right" ? {
|
|
217
|
+
...v,
|
|
218
|
+
top: 0,
|
|
219
|
+
right: -r / 2,
|
|
220
|
+
width: r,
|
|
221
|
+
height: "100%",
|
|
222
|
+
cursor: R(c)
|
|
223
|
+
} : c === "bottom" ? {
|
|
224
|
+
...v,
|
|
225
|
+
left: 0,
|
|
226
|
+
bottom: -r / 2,
|
|
227
|
+
width: "100%",
|
|
228
|
+
height: r,
|
|
229
|
+
cursor: R(c)
|
|
230
|
+
} : c === "left" ? { ...v, top: 0, left: -r / 2, width: r, height: "100%", cursor: R(c) } : c === "top" ? { ...v, top: -r / 2, left: 0, width: "100%", height: r, cursor: R(c) } : c === "bottomRight" ? {
|
|
231
|
+
...v,
|
|
232
|
+
bottom: -r / 2,
|
|
233
|
+
right: -r / 2,
|
|
234
|
+
width: r * 2,
|
|
235
|
+
height: r * 2,
|
|
236
|
+
cursor: R(c)
|
|
237
|
+
} : c === "bottomLeft" ? {
|
|
238
|
+
...v,
|
|
239
|
+
bottom: -r / 2,
|
|
240
|
+
left: -r / 2,
|
|
241
|
+
width: r * 2,
|
|
242
|
+
height: r * 2,
|
|
243
|
+
cursor: R(c)
|
|
244
|
+
} : c === "topRight" ? {
|
|
245
|
+
...v,
|
|
246
|
+
top: -r / 2,
|
|
247
|
+
right: -r / 2,
|
|
248
|
+
width: r * 2,
|
|
249
|
+
height: r * 2,
|
|
250
|
+
cursor: R(c)
|
|
251
|
+
} : c === "topLeft" ? {
|
|
252
|
+
...v,
|
|
253
|
+
top: -r / 2,
|
|
254
|
+
left: -r / 2,
|
|
255
|
+
width: r * 2,
|
|
256
|
+
height: r * 2,
|
|
257
|
+
cursor: R(c)
|
|
258
|
+
} : v;
|
|
259
|
+
};
|
|
260
|
+
return /* @__PURE__ */ g(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
ref: L,
|
|
264
|
+
className: `nice-resizable ${b || ""}`,
|
|
265
|
+
style: {
|
|
266
|
+
...l,
|
|
267
|
+
width: k.width,
|
|
268
|
+
height: k.height,
|
|
269
|
+
position: "relative",
|
|
270
|
+
overflow: "hidden"
|
|
271
|
+
},
|
|
272
|
+
children: [
|
|
273
|
+
f,
|
|
274
|
+
p.map((c) => /* @__PURE__ */ t("div", { style: O(c), onPointerDown: (v) => I(c, v) }, c))
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}, jt = ({
|
|
279
|
+
direction: e = "vertical",
|
|
280
|
+
showScrollbar: n = "onInteraction",
|
|
281
|
+
width: i,
|
|
282
|
+
height: s,
|
|
283
|
+
onScroll: u,
|
|
284
|
+
children: m,
|
|
285
|
+
className: p,
|
|
286
|
+
style: w
|
|
287
|
+
}) => {
|
|
288
|
+
const f = e === "horizontal" || e === "both" ? "auto" : "hidden", b = e === "vertical" || e === "both" ? "auto" : "hidden";
|
|
289
|
+
return /* @__PURE__ */ t(
|
|
290
|
+
"div",
|
|
291
|
+
{
|
|
292
|
+
className: `nice-scrollview ${n === "never" ? "nice-scrollview--hide-sb" : n === "always" ? "nice-scrollview--show-sb" : ""} ${p || ""}`,
|
|
293
|
+
style: { ...w, width: i, height: s, overflowX: f, overflowY: b },
|
|
294
|
+
onScroll: u,
|
|
295
|
+
children: m
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
function We(e, n) {
|
|
300
|
+
if (!e)
|
|
301
|
+
return { score: 1, indices: [] };
|
|
302
|
+
const i = e.toLowerCase(), s = n.toLowerCase();
|
|
303
|
+
let u = 0;
|
|
304
|
+
const m = [];
|
|
305
|
+
let p = 0, w = -1;
|
|
306
|
+
for (let f = 0; f < s.length && u < i.length; f++)
|
|
307
|
+
s[f] === i[u] && (m.push(f), w === f - 1 && (p += 3), (f === 0 || /[\s\-_/.]/.test(n[f - 1])) && (p += 5), n[f] === e[u] && (p += 1), p += 1, w = f, u++);
|
|
308
|
+
return u < i.length ? null : (p -= m[0] * 0.1, { score: p, indices: m });
|
|
309
|
+
}
|
|
310
|
+
function yt(e, n) {
|
|
311
|
+
if (n.length === 0)
|
|
312
|
+
return [e];
|
|
313
|
+
const i = [];
|
|
314
|
+
let s = 0;
|
|
315
|
+
const u = new Set(n);
|
|
316
|
+
for (let m = 0; m < e.length; m++)
|
|
317
|
+
u.has(m) && (s < m && i.push(e.slice(s, m)), i.push(
|
|
318
|
+
vt.createElement(
|
|
319
|
+
"mark",
|
|
320
|
+
{ key: `m-${m}`, className: "nice-command-palette__match" },
|
|
321
|
+
e[m]
|
|
322
|
+
)
|
|
323
|
+
), s = m + 1);
|
|
324
|
+
return s < e.length && i.push(e.slice(s)), i;
|
|
325
|
+
}
|
|
326
|
+
function xt(e, n) {
|
|
327
|
+
switch (n.type) {
|
|
328
|
+
case "REGISTER": {
|
|
329
|
+
const i = new Map(e.commands);
|
|
330
|
+
return i.set(n.command.id, n.command), { ...e, commands: i };
|
|
331
|
+
}
|
|
332
|
+
case "REGISTER_BATCH": {
|
|
333
|
+
const i = new Map(e.commands);
|
|
334
|
+
for (const s of n.commands)
|
|
335
|
+
i.set(s.id, s);
|
|
336
|
+
return { ...e, commands: i };
|
|
337
|
+
}
|
|
338
|
+
case "UNREGISTER": {
|
|
339
|
+
const i = new Map(e.commands);
|
|
340
|
+
return i.delete(n.id), { ...e, commands: i };
|
|
341
|
+
}
|
|
342
|
+
case "OPEN":
|
|
343
|
+
return { ...e, isOpen: !0, query: "", selectedIndex: 0 };
|
|
344
|
+
case "CLOSE":
|
|
345
|
+
return { ...e, isOpen: !1, query: "", selectedIndex: 0 };
|
|
346
|
+
case "SET_QUERY":
|
|
347
|
+
return { ...e, query: n.query, selectedIndex: 0 };
|
|
348
|
+
case "SET_SELECTED":
|
|
349
|
+
return { ...e, selectedIndex: n.index };
|
|
350
|
+
case "ADD_RECENT": {
|
|
351
|
+
const i = e.recentIds.filter((s) => s !== n.id);
|
|
352
|
+
return {
|
|
353
|
+
...e,
|
|
354
|
+
recentIds: [n.id, ...i].slice(0, n.maxRecent)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
default:
|
|
358
|
+
return e;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const Ve = Ge(null);
|
|
362
|
+
function Nt() {
|
|
363
|
+
const e = je(Ve);
|
|
364
|
+
if (!e)
|
|
365
|
+
throw new Error("useCommandPalette must be used within NiceCommandPaletteProvider");
|
|
366
|
+
return e;
|
|
367
|
+
}
|
|
368
|
+
const kt = ({
|
|
369
|
+
children: e,
|
|
370
|
+
commands: n,
|
|
371
|
+
placeholder: i = "Type a command...",
|
|
372
|
+
maxVisible: s = 10,
|
|
373
|
+
maxRecent: u = 5,
|
|
374
|
+
className: m,
|
|
375
|
+
emptyText: p = "No commands found",
|
|
376
|
+
closeOnAction: w = !0,
|
|
377
|
+
onOpen: f,
|
|
378
|
+
onClose: b
|
|
379
|
+
}) => {
|
|
380
|
+
const [l, k] = bt(xt, {
|
|
381
|
+
commands: new Map(n?.map((a) => [a.id, a]) ?? []),
|
|
382
|
+
isOpen: !1,
|
|
383
|
+
query: "",
|
|
384
|
+
selectedIndex: 0,
|
|
385
|
+
recentIds: []
|
|
386
|
+
}), B = V(null), L = V(null), [I, R] = X(!1), O = x((a) => {
|
|
387
|
+
k({ type: "REGISTER", command: a });
|
|
388
|
+
}, []), c = x((a) => {
|
|
389
|
+
k({ type: "UNREGISTER", id: a });
|
|
390
|
+
}, []), v = x((a) => {
|
|
391
|
+
k({ type: "REGISTER_BATCH", commands: a });
|
|
392
|
+
}, []), r = x(() => {
|
|
393
|
+
k({ type: "OPEN" }), f?.();
|
|
394
|
+
}, [f]), E = x(() => {
|
|
395
|
+
k({ type: "CLOSE" }), b?.();
|
|
396
|
+
}, [b]), _ = x(() => {
|
|
397
|
+
l.isOpen ? E() : r();
|
|
398
|
+
}, [l.isOpen, E, r]), W = $e(() => {
|
|
399
|
+
const a = Array.from(l.commands.values()).filter((d) => !d.hidden);
|
|
400
|
+
if (!l.query.trim()) {
|
|
401
|
+
const d = l.recentIds.map((h) => l.commands.get(h)).filter((h) => !!h && !h.hidden), $ = a.filter((h) => !l.recentIds.includes(h.id));
|
|
402
|
+
return $.sort((h, Y) => h.label.localeCompare(Y.label)), [...d, ...$].map((h) => ({
|
|
403
|
+
command: h,
|
|
404
|
+
match: null,
|
|
405
|
+
isRecent: l.recentIds.includes(h.id)
|
|
406
|
+
}));
|
|
407
|
+
}
|
|
408
|
+
return a.map((d) => {
|
|
409
|
+
const $ = We(l.query, d.label), h = d.description ? We(l.query, d.description) : null, Y = d.keywords?.map((Z) => We(l.query, Z)).filter(Boolean)[0] ?? null, F = [$, h, Y].filter(Boolean).sort((Z, ne) => (ne?.score ?? 0) - (Z?.score ?? 0))[0];
|
|
410
|
+
return { command: d, match: F, isRecent: !1 };
|
|
411
|
+
}).filter((d) => d.match !== null).sort((d, $) => ($.match?.score ?? 0) - (d.match?.score ?? 0));
|
|
412
|
+
}, [l.commands, l.query, l.recentIds]).slice(0, s), S = x(
|
|
413
|
+
async (a) => {
|
|
414
|
+
const y = l.commands.get(a);
|
|
415
|
+
if (!(!y || y.disabled)) {
|
|
416
|
+
R(!0);
|
|
417
|
+
try {
|
|
418
|
+
await y.action(), k({ type: "ADD_RECENT", id: a, maxRecent: u });
|
|
419
|
+
} finally {
|
|
420
|
+
R(!1), w && E();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
[l.commands, u, w, E]
|
|
425
|
+
);
|
|
426
|
+
A(() => {
|
|
427
|
+
const a = (y) => {
|
|
428
|
+
(y.metaKey || y.ctrlKey) && y.key === "k" && (y.preventDefault(), _()), y.key === "Escape" && l.isOpen && (y.preventDefault(), E());
|
|
429
|
+
};
|
|
430
|
+
return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
|
|
431
|
+
}, [_, l.isOpen, E]), A(() => {
|
|
432
|
+
l.isOpen && requestAnimationFrame(() => B.current?.focus());
|
|
433
|
+
}, [l.isOpen]);
|
|
434
|
+
const o = x(
|
|
435
|
+
(a) => {
|
|
436
|
+
const y = W.length;
|
|
437
|
+
if (y) {
|
|
438
|
+
if (a.key === "ArrowDown")
|
|
439
|
+
a.preventDefault(), k({ type: "SET_SELECTED", index: (l.selectedIndex + 1) % y });
|
|
440
|
+
else if (a.key === "ArrowUp")
|
|
441
|
+
a.preventDefault(), k({ type: "SET_SELECTED", index: (l.selectedIndex - 1 + y) % y });
|
|
442
|
+
else if (a.key === "Enter") {
|
|
443
|
+
a.preventDefault();
|
|
444
|
+
const d = W[l.selectedIndex];
|
|
445
|
+
d && S(d.command.id);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
[W, l.selectedIndex, S]
|
|
450
|
+
);
|
|
451
|
+
A(() => {
|
|
452
|
+
if (!L.current)
|
|
453
|
+
return;
|
|
454
|
+
L.current.children[l.selectedIndex]?.scrollIntoView({ block: "nearest" });
|
|
455
|
+
}, [l.selectedIndex]);
|
|
456
|
+
const z = $e(
|
|
457
|
+
() => ({
|
|
458
|
+
registerCommand: O,
|
|
459
|
+
unregisterCommand: c,
|
|
460
|
+
registerCommands: v,
|
|
461
|
+
open: r,
|
|
462
|
+
close: E,
|
|
463
|
+
toggle: _,
|
|
464
|
+
isOpen: l.isOpen,
|
|
465
|
+
executeCommand: S
|
|
466
|
+
}),
|
|
467
|
+
[
|
|
468
|
+
O,
|
|
469
|
+
c,
|
|
470
|
+
v,
|
|
471
|
+
r,
|
|
472
|
+
E,
|
|
473
|
+
_,
|
|
474
|
+
l.isOpen,
|
|
475
|
+
S
|
|
476
|
+
]
|
|
477
|
+
), N = $e(() => {
|
|
478
|
+
const a = /* @__PURE__ */ new Map();
|
|
479
|
+
for (const y of W) {
|
|
480
|
+
const d = y.command.category ?? "General";
|
|
481
|
+
a.has(d) || a.set(d, []), a.get(d).push(y);
|
|
482
|
+
}
|
|
483
|
+
return a;
|
|
484
|
+
}, [W]);
|
|
485
|
+
let T = 0;
|
|
486
|
+
return /* @__PURE__ */ g(Ve.Provider, { value: z, children: [
|
|
487
|
+
e,
|
|
488
|
+
l.isOpen && /* @__PURE__ */ t("div", { className: `nice-command-palette__overlay ${m ?? ""}`, onClick: E, children: /* @__PURE__ */ g(
|
|
489
|
+
"div",
|
|
490
|
+
{
|
|
491
|
+
className: "nice-command-palette",
|
|
492
|
+
role: "dialog",
|
|
493
|
+
"aria-label": "Command Palette",
|
|
494
|
+
"aria-modal": "true",
|
|
495
|
+
onClick: (a) => a.stopPropagation(),
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ t("div", { className: "nice-command-palette__input-wrapper", children: /* @__PURE__ */ t(
|
|
498
|
+
"input",
|
|
499
|
+
{
|
|
500
|
+
ref: B,
|
|
501
|
+
className: "nice-command-palette__input",
|
|
502
|
+
type: "text",
|
|
503
|
+
placeholder: i,
|
|
504
|
+
value: l.query,
|
|
505
|
+
onChange: (a) => k({ type: "SET_QUERY", query: a.target.value }),
|
|
506
|
+
onKeyDown: o,
|
|
507
|
+
"aria-label": "Search commands",
|
|
508
|
+
"aria-autocomplete": "list",
|
|
509
|
+
"aria-controls": "nice-command-palette-list",
|
|
510
|
+
"aria-activedescendant": W[l.selectedIndex] ? `nice-cmd-${W[l.selectedIndex].command.id}` : void 0
|
|
511
|
+
}
|
|
512
|
+
) }),
|
|
513
|
+
/* @__PURE__ */ g(
|
|
514
|
+
"div",
|
|
515
|
+
{
|
|
516
|
+
ref: L,
|
|
517
|
+
id: "nice-command-palette-list",
|
|
518
|
+
className: "nice-command-palette__list",
|
|
519
|
+
role: "listbox",
|
|
520
|
+
children: [
|
|
521
|
+
W.length === 0 && /* @__PURE__ */ t("div", { className: "nice-command-palette__empty", children: p }),
|
|
522
|
+
Array.from(N.entries()).map(([a, y]) => /* @__PURE__ */ g("div", { className: "nice-command-palette__group", children: [
|
|
523
|
+
/* @__PURE__ */ t("div", { className: "nice-command-palette__category", children: a }),
|
|
524
|
+
y.map((d) => {
|
|
525
|
+
const $ = T++, h = $ === l.selectedIndex;
|
|
526
|
+
return /* @__PURE__ */ g(
|
|
527
|
+
"div",
|
|
528
|
+
{
|
|
529
|
+
id: `nice-cmd-${d.command.id}`,
|
|
530
|
+
className: `nice-command-palette__item ${h ? "nice-command-palette__item--selected" : ""} ${d.command.disabled ? "nice-command-palette__item--disabled" : ""}`,
|
|
531
|
+
role: "option",
|
|
532
|
+
"aria-selected": h,
|
|
533
|
+
"aria-disabled": d.command.disabled,
|
|
534
|
+
onClick: () => !d.command.disabled && S(d.command.id),
|
|
535
|
+
onMouseEnter: () => k({ type: "SET_SELECTED", index: $ }),
|
|
536
|
+
children: [
|
|
537
|
+
d.command.icon && /* @__PURE__ */ t("span", { className: "nice-command-palette__icon", children: d.command.icon }),
|
|
538
|
+
/* @__PURE__ */ g("div", { className: "nice-command-palette__label-group", children: [
|
|
539
|
+
/* @__PURE__ */ t("span", { className: "nice-command-palette__label", children: d.match && l.query ? yt(d.command.label, d.match.indices) : d.command.label }),
|
|
540
|
+
d.command.description && /* @__PURE__ */ t("span", { className: "nice-command-palette__description", children: d.command.description })
|
|
541
|
+
] }),
|
|
542
|
+
d.command.shortcut && /* @__PURE__ */ t("kbd", { className: "nice-command-palette__shortcut", children: d.command.shortcut }),
|
|
543
|
+
d.isRecent && /* @__PURE__ */ t("span", { className: "nice-command-palette__recent-badge", children: "Recent" })
|
|
544
|
+
]
|
|
545
|
+
},
|
|
546
|
+
d.command.id
|
|
547
|
+
);
|
|
548
|
+
})
|
|
549
|
+
] }, a))
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
),
|
|
553
|
+
I && /* @__PURE__ */ t("div", { className: "nice-command-palette__executing", children: "Executing..." })
|
|
554
|
+
]
|
|
555
|
+
}
|
|
556
|
+
) })
|
|
557
|
+
] });
|
|
558
|
+
};
|
|
559
|
+
kt.displayName = "NiceCommandPaletteProvider";
|
|
560
|
+
function Gt(e) {
|
|
561
|
+
const { registerCommands: n, unregisterCommand: i } = Nt();
|
|
562
|
+
A(() => (n(e), () => {
|
|
563
|
+
for (const s of e)
|
|
564
|
+
i(s.id);
|
|
565
|
+
}), []);
|
|
566
|
+
}
|
|
567
|
+
const Et = He(
|
|
568
|
+
({ blocked: e, message: n, children: i, className: s, style: u, id: m }, p) => {
|
|
569
|
+
const w = Fe(m);
|
|
570
|
+
return /* @__PURE__ */ g(
|
|
571
|
+
"div",
|
|
572
|
+
{
|
|
573
|
+
ref: p,
|
|
574
|
+
id: w,
|
|
575
|
+
className: `nice-block-ui ${s || ""}`,
|
|
576
|
+
style: { position: "relative", ...u },
|
|
577
|
+
children: [
|
|
578
|
+
i,
|
|
579
|
+
e && /* @__PURE__ */ t("div", { className: "nice-block-ui__overlay", "aria-busy": "true", role: "alert", children: n && /* @__PURE__ */ t("div", { className: "nice-block-ui__message", children: n }) })
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
Et.displayName = "NiceBlockUI";
|
|
586
|
+
const zt = He(
|
|
587
|
+
({
|
|
588
|
+
windows: e,
|
|
589
|
+
children: n,
|
|
590
|
+
onChange: i,
|
|
591
|
+
onClose: s,
|
|
592
|
+
onFocus: u,
|
|
593
|
+
showTaskbar: m = !0,
|
|
594
|
+
size: p = "md",
|
|
595
|
+
className: w,
|
|
596
|
+
style: f,
|
|
597
|
+
id: b,
|
|
598
|
+
...l
|
|
599
|
+
}, k) => {
|
|
600
|
+
const B = Fe(b), { t: L } = Pe(), [I, R] = X(null), O = V(null), c = e ?? [], v = Math.max(1, ...c.map((o) => o.zIndex ?? 1)), r = x(
|
|
601
|
+
(o, z) => {
|
|
602
|
+
const N = c.map((T) => T.key === o ? { ...T, ...z } : T);
|
|
603
|
+
i?.(N);
|
|
604
|
+
},
|
|
605
|
+
[c, i]
|
|
606
|
+
), E = x(
|
|
607
|
+
(o) => {
|
|
608
|
+
r(o, { zIndex: v + 1 }), u?.(o);
|
|
609
|
+
},
|
|
610
|
+
[r, v, u]
|
|
611
|
+
), _ = x(
|
|
612
|
+
(o) => {
|
|
613
|
+
s?.(o), i?.(c.filter((z) => z.key !== o));
|
|
614
|
+
},
|
|
615
|
+
[c, i, s]
|
|
616
|
+
), G = x(
|
|
617
|
+
(o) => {
|
|
618
|
+
const z = c.find((N) => N.key === o);
|
|
619
|
+
z && r(o, { minimized: !z.minimized, maximized: !1 });
|
|
620
|
+
},
|
|
621
|
+
[c, r]
|
|
622
|
+
), W = x(
|
|
623
|
+
(o) => {
|
|
624
|
+
const z = c.find((N) => N.key === o);
|
|
625
|
+
z && r(o, { maximized: !z.maximized, minimized: !1 });
|
|
626
|
+
},
|
|
627
|
+
[c, r]
|
|
628
|
+
);
|
|
629
|
+
A(() => {
|
|
630
|
+
if (!I)
|
|
631
|
+
return;
|
|
632
|
+
const o = (N) => {
|
|
633
|
+
const T = c.find((a) => a.key === I.key);
|
|
634
|
+
if (T)
|
|
635
|
+
if (I.mode === "move")
|
|
636
|
+
r(I.key, {
|
|
637
|
+
x: N.clientX - I.offsetX,
|
|
638
|
+
y: N.clientY - I.offsetY
|
|
639
|
+
});
|
|
640
|
+
else {
|
|
641
|
+
const y = O.current?.getBoundingClientRect(), d = y?.left ?? 0, $ = y?.top ?? 0;
|
|
642
|
+
r(I.key, {
|
|
643
|
+
width: Math.max(200, N.clientX - d - T.x),
|
|
644
|
+
height: Math.max(100, N.clientY - $ - T.y)
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
}, z = () => R(null);
|
|
648
|
+
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", z), () => {
|
|
649
|
+
document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", z);
|
|
650
|
+
};
|
|
651
|
+
}, [I, c, r]);
|
|
652
|
+
const S = x(
|
|
653
|
+
(o, z, N) => {
|
|
654
|
+
z.preventDefault();
|
|
655
|
+
const T = c.find((a) => a.key === o);
|
|
656
|
+
T && (E(o), R({
|
|
657
|
+
key: o,
|
|
658
|
+
offsetX: N === "move" ? z.clientX - T.x : 0,
|
|
659
|
+
offsetY: N === "move" ? z.clientY - T.y : 0,
|
|
660
|
+
mode: N
|
|
661
|
+
}));
|
|
662
|
+
},
|
|
663
|
+
[c, E]
|
|
664
|
+
);
|
|
665
|
+
return /* @__PURE__ */ g(
|
|
666
|
+
"div",
|
|
667
|
+
{
|
|
668
|
+
ref: (o) => {
|
|
669
|
+
O.current = o, typeof k == "function" ? k(o) : k && (k.current = o);
|
|
670
|
+
},
|
|
671
|
+
id: B,
|
|
672
|
+
className: `nice-wm nice-wm--${p} ${w ?? ""}`,
|
|
673
|
+
style: { ...f, position: "relative", overflow: "hidden" },
|
|
674
|
+
...l,
|
|
675
|
+
children: [
|
|
676
|
+
c.map((o) => {
|
|
677
|
+
if (o.minimized)
|
|
678
|
+
return null;
|
|
679
|
+
const z = o.maximized, N = z ? {
|
|
680
|
+
position: "absolute",
|
|
681
|
+
top: 0,
|
|
682
|
+
left: 0,
|
|
683
|
+
width: "100%",
|
|
684
|
+
height: "100%",
|
|
685
|
+
zIndex: o.zIndex ?? 1
|
|
686
|
+
} : {
|
|
687
|
+
position: "absolute",
|
|
688
|
+
top: o.y,
|
|
689
|
+
left: o.x,
|
|
690
|
+
width: o.width,
|
|
691
|
+
height: o.height,
|
|
692
|
+
zIndex: o.zIndex ?? 1
|
|
693
|
+
};
|
|
694
|
+
return /* @__PURE__ */ g(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: `nice-wm__window ${z ? "nice-wm__window--maximized" : ""}`,
|
|
698
|
+
style: N,
|
|
699
|
+
onMouseDown: () => E(o.key),
|
|
700
|
+
role: "dialog",
|
|
701
|
+
"aria-label": o.title,
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ g(
|
|
704
|
+
"div",
|
|
705
|
+
{
|
|
706
|
+
className: "nice-wm__titlebar",
|
|
707
|
+
onMouseDown: (T) => !z && S(o.key, T, "move"),
|
|
708
|
+
children: [
|
|
709
|
+
o.icon && /* @__PURE__ */ t("span", { className: "nice-wm__icon", children: o.icon }),
|
|
710
|
+
/* @__PURE__ */ t("span", { className: "nice-wm__title", children: o.title }),
|
|
711
|
+
/* @__PURE__ */ g("div", { className: "nice-wm__controls", children: [
|
|
712
|
+
(o.minimizable ?? !0) && /* @__PURE__ */ t(
|
|
713
|
+
"button",
|
|
714
|
+
{
|
|
715
|
+
type: "button",
|
|
716
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--min",
|
|
717
|
+
onClick: () => G(o.key),
|
|
718
|
+
title: L("wm.minimize", "Minimize"),
|
|
719
|
+
children: "─"
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
(o.maximizable ?? !0) && /* @__PURE__ */ t(
|
|
723
|
+
"button",
|
|
724
|
+
{
|
|
725
|
+
type: "button",
|
|
726
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--max",
|
|
727
|
+
onClick: () => W(o.key),
|
|
728
|
+
title: L("wm.maximize", "Maximize"),
|
|
729
|
+
children: z ? "❐" : "☐"
|
|
730
|
+
}
|
|
731
|
+
),
|
|
732
|
+
(o.closable ?? !0) && /* @__PURE__ */ t(
|
|
733
|
+
"button",
|
|
734
|
+
{
|
|
735
|
+
type: "button",
|
|
736
|
+
className: "nice-wm__ctrl-btn nice-wm__ctrl-btn--close",
|
|
737
|
+
onClick: () => _(o.key),
|
|
738
|
+
title: L("wm.close", "Close"),
|
|
739
|
+
children: "✕"
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
] })
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
),
|
|
746
|
+
/* @__PURE__ */ t("div", { className: "nice-wm__body", children: o.content }),
|
|
747
|
+
(o.resizable ?? !0) && !z && /* @__PURE__ */ t(
|
|
748
|
+
"div",
|
|
749
|
+
{
|
|
750
|
+
className: "nice-wm__resize-handle",
|
|
751
|
+
onMouseDown: (T) => S(o.key, T, "resize")
|
|
752
|
+
}
|
|
753
|
+
)
|
|
754
|
+
]
|
|
755
|
+
},
|
|
756
|
+
o.key
|
|
757
|
+
);
|
|
758
|
+
}),
|
|
759
|
+
e === void 0 && n,
|
|
760
|
+
m && /* @__PURE__ */ t("div", { className: "nice-wm__taskbar", role: "toolbar", "aria-label": L("wm.taskbar", "Taskbar"), children: c.map((o) => /* @__PURE__ */ g(
|
|
761
|
+
"button",
|
|
762
|
+
{
|
|
763
|
+
type: "button",
|
|
764
|
+
className: `nice-wm__taskbar-btn ${o.minimized ? "nice-wm__taskbar-btn--minimized" : ""}`,
|
|
765
|
+
onClick: () => {
|
|
766
|
+
o.minimized && G(o.key), E(o.key);
|
|
767
|
+
},
|
|
768
|
+
children: [
|
|
769
|
+
o.icon && /* @__PURE__ */ t("span", { className: "nice-wm__taskbar-icon", children: o.icon }),
|
|
770
|
+
/* @__PURE__ */ t("span", { className: "nice-wm__taskbar-label", children: o.title })
|
|
771
|
+
]
|
|
772
|
+
},
|
|
773
|
+
o.key
|
|
774
|
+
)) })
|
|
775
|
+
]
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
zt.displayName = "NiceWindowManager";
|
|
781
|
+
function Ct(e, n) {
|
|
782
|
+
const i = document.querySelector(e);
|
|
783
|
+
if (!i)
|
|
784
|
+
return null;
|
|
785
|
+
const s = i.getBoundingClientRect();
|
|
786
|
+
return {
|
|
787
|
+
top: s.top - n + window.scrollY,
|
|
788
|
+
left: s.left - n + window.scrollX,
|
|
789
|
+
width: s.width + n * 2,
|
|
790
|
+
height: s.height + n * 2
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function It(e, n, i, s) {
|
|
794
|
+
const m = { w: window.innerWidth, h: window.innerHeight + window.scrollY }, p = {
|
|
795
|
+
top: {
|
|
796
|
+
top: e.top - i - 12,
|
|
797
|
+
left: e.left + e.width / 2 - n / 2
|
|
798
|
+
},
|
|
799
|
+
bottom: {
|
|
800
|
+
top: e.top + e.height + 12,
|
|
801
|
+
left: e.left + e.width / 2 - n / 2
|
|
802
|
+
},
|
|
803
|
+
left: {
|
|
804
|
+
top: e.top + e.height / 2 - i / 2,
|
|
805
|
+
left: e.left - n - 12
|
|
806
|
+
},
|
|
807
|
+
right: {
|
|
808
|
+
top: e.top + e.height / 2 - i / 2,
|
|
809
|
+
left: e.left + e.width + 12
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
if (s && s !== "auto")
|
|
813
|
+
return { ...p[s], actualPlacement: s };
|
|
814
|
+
for (const w of ["bottom", "top", "right", "left"]) {
|
|
815
|
+
const f = p[w];
|
|
816
|
+
if (f.top >= 0 && f.left >= 0 && f.top + i <= m.h && f.left + n <= m.w)
|
|
817
|
+
return { ...f, actualPlacement: w };
|
|
818
|
+
}
|
|
819
|
+
return { ...p.bottom, actualPlacement: "bottom" };
|
|
820
|
+
}
|
|
821
|
+
const Ne = {
|
|
822
|
+
width: 16,
|
|
823
|
+
height: 16,
|
|
824
|
+
viewBox: "0 0 24 24",
|
|
825
|
+
fill: "none",
|
|
826
|
+
stroke: "currentColor",
|
|
827
|
+
strokeWidth: 2,
|
|
828
|
+
strokeLinecap: "round",
|
|
829
|
+
strokeLinejoin: "round",
|
|
830
|
+
"aria-hidden": !0
|
|
831
|
+
};
|
|
832
|
+
function Mt() {
|
|
833
|
+
return /* @__PURE__ */ g("svg", { ...Ne, children: [
|
|
834
|
+
/* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
835
|
+
/* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
836
|
+
] });
|
|
837
|
+
}
|
|
838
|
+
function Lt() {
|
|
839
|
+
return /* @__PURE__ */ t("svg", { ...Ne, children: /* @__PURE__ */ t("polyline", { points: "15 18 9 12 15 6" }) });
|
|
840
|
+
}
|
|
841
|
+
function Rt() {
|
|
842
|
+
return /* @__PURE__ */ t("svg", { ...Ne, children: /* @__PURE__ */ t("polyline", { points: "9 18 15 12 9 6" }) });
|
|
843
|
+
}
|
|
844
|
+
function St() {
|
|
845
|
+
return /* @__PURE__ */ g("svg", { ...Ne, children: [
|
|
846
|
+
/* @__PURE__ */ t("polygon", { points: "5 4 15 12 5 20 5 4" }),
|
|
847
|
+
/* @__PURE__ */ t("line", { x1: "19", y1: "5", x2: "19", y2: "19" })
|
|
848
|
+
] });
|
|
849
|
+
}
|
|
850
|
+
function Tt() {
|
|
851
|
+
return /* @__PURE__ */ t("svg", { ...Ne, children: /* @__PURE__ */ t("polygon", { points: "6 4 20 12 6 20 6 4", fill: "currentColor" }) });
|
|
852
|
+
}
|
|
853
|
+
function $t() {
|
|
854
|
+
return /* @__PURE__ */ g("svg", { ...Ne, children: [
|
|
855
|
+
/* @__PURE__ */ t("rect", { x: "6", y: "4", width: "4", height: "16", fill: "currentColor" }),
|
|
856
|
+
/* @__PURE__ */ t("rect", { x: "14", y: "4", width: "4", height: "16", fill: "currentColor" })
|
|
857
|
+
] });
|
|
858
|
+
}
|
|
859
|
+
function Te(e, n, i) {
|
|
860
|
+
return i === "text" ? /* @__PURE__ */ t("span", { className: "nice-tutorial__btn-label", children: n }) : i === "icon-text" ? /* @__PURE__ */ g(Ae, { children: [
|
|
861
|
+
e,
|
|
862
|
+
/* @__PURE__ */ t("span", { className: "nice-tutorial__btn-label", children: n })
|
|
863
|
+
] }) : e;
|
|
864
|
+
}
|
|
865
|
+
const Ze = ({
|
|
866
|
+
steps: e,
|
|
867
|
+
active: n,
|
|
868
|
+
onFinish: i,
|
|
869
|
+
onSkip: s,
|
|
870
|
+
onStepChange: u,
|
|
871
|
+
closeOnEscape: m = !0,
|
|
872
|
+
closeOnOverlayClick: p = !1,
|
|
873
|
+
showProgress: w = !0,
|
|
874
|
+
showSkipButton: f = !0,
|
|
875
|
+
labels: b,
|
|
876
|
+
animationDuration: l = 300,
|
|
877
|
+
overlayOpacity: k = 0.6,
|
|
878
|
+
zIndex: B = 1e4,
|
|
879
|
+
buttonsPlacement: L = "floating-bottom",
|
|
880
|
+
buttonsDisplay: I = "icon",
|
|
881
|
+
showAutoplay: R = !0,
|
|
882
|
+
autoplayInterval: O = 5e3,
|
|
883
|
+
autoplaySpeedRange: c = { min: 2e3, max: 15e3 },
|
|
884
|
+
onAutoplayChange: v
|
|
885
|
+
}) => {
|
|
886
|
+
const [r, E] = X(0), [_, G] = X(null), [W, S] = X({ w: 340, h: 200 }), [o, z] = X(!0), [N, T] = X(!1), [a, y] = X(O), d = V(null), $ = V(-1), h = e[r], Y = r === e.length - 1, F = r === 0, Z = b?.next ?? "Next", ne = b?.back ?? "Back", ie = b?.finish ?? "Finish", fe = b?.skip ?? "Skip", pe = b?.stepOf ?? "of", we = b?.play ?? "Play", _e = b?.pause ?? "Pause", Re = b?.speed ?? "Speed", ke = b?.close ?? "Close";
|
|
887
|
+
A(() => {
|
|
888
|
+
n && (E(0), T(!1), y(O));
|
|
889
|
+
}, [n, O]), A(() => {
|
|
890
|
+
if (d.current) {
|
|
891
|
+
const M = d.current.getBoundingClientRect();
|
|
892
|
+
S({ w: M.width, h: M.height });
|
|
893
|
+
}
|
|
894
|
+
}, [r, n]), A(() => {
|
|
895
|
+
if (!n || !h)
|
|
896
|
+
return;
|
|
897
|
+
const M = h.highlightPadding ?? 0, P = () => {
|
|
898
|
+
const U = Ct(h.target, M);
|
|
899
|
+
G(U);
|
|
900
|
+
};
|
|
901
|
+
if (P(), h.scrollIntoView !== !1) {
|
|
902
|
+
document.querySelector(h.target)?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
903
|
+
const Q = setTimeout(P, 350);
|
|
904
|
+
return () => clearTimeout(Q);
|
|
905
|
+
}
|
|
906
|
+
}, [n, h, r]), A(() => {
|
|
907
|
+
!n || !h || $.current !== r && ($.current >= 0 && $.current < e.length && e[$.current]?.onLeave?.(), h.onEnter?.(), $.current = r);
|
|
908
|
+
}, [n, h, r, e]);
|
|
909
|
+
const oe = x(() => {
|
|
910
|
+
if (Y)
|
|
911
|
+
h?.onLeave?.(), i?.();
|
|
912
|
+
else {
|
|
913
|
+
const M = r + 1;
|
|
914
|
+
E(M), u?.(M);
|
|
915
|
+
}
|
|
916
|
+
}, [r, Y, i, u, h]), ge = x(() => {
|
|
917
|
+
if (!F) {
|
|
918
|
+
const M = r - 1;
|
|
919
|
+
E(M), u?.(M);
|
|
920
|
+
}
|
|
921
|
+
}, [r, F, u]);
|
|
922
|
+
A(() => {
|
|
923
|
+
if (!n || !h?.advanceOn)
|
|
924
|
+
return;
|
|
925
|
+
const M = document.querySelector(h.target);
|
|
926
|
+
if (!M)
|
|
927
|
+
return;
|
|
928
|
+
const P = () => oe();
|
|
929
|
+
return M.addEventListener(h.advanceOn.event, P), () => M.removeEventListener(h.advanceOn.event, P);
|
|
930
|
+
}, [n, h, r, oe]), A(() => {
|
|
931
|
+
if (!n)
|
|
932
|
+
return;
|
|
933
|
+
const M = (P) => {
|
|
934
|
+
P.key === "Escape" && m ? s?.() : P.key === "ArrowRight" ? oe() : P.key === "ArrowLeft" && ge();
|
|
935
|
+
};
|
|
936
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
937
|
+
}, [n, r, m, oe, ge, s]), A(() => {
|
|
938
|
+
z(!0);
|
|
939
|
+
const M = setTimeout(() => z(!1), l);
|
|
940
|
+
return () => clearTimeout(M);
|
|
941
|
+
}, [r, l]), A(() => {
|
|
942
|
+
if (!n || !N)
|
|
943
|
+
return;
|
|
944
|
+
const M = setInterval(
|
|
945
|
+
() => {
|
|
946
|
+
E((P) => {
|
|
947
|
+
if (P >= e.length - 1)
|
|
948
|
+
return T(!1), v?.(!1), e[P]?.onLeave?.(), i?.(), P;
|
|
949
|
+
const U = P + 1;
|
|
950
|
+
return u?.(U), U;
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
Math.max(500, a)
|
|
954
|
+
);
|
|
955
|
+
return () => clearInterval(M);
|
|
956
|
+
}, [n, N, a, e, v, i, u]);
|
|
957
|
+
const Se = x(() => {
|
|
958
|
+
T((M) => {
|
|
959
|
+
const P = !M;
|
|
960
|
+
return v?.(P), P;
|
|
961
|
+
});
|
|
962
|
+
}, [v]), ve = $e(() => _ ? It(_, W.w, W.h, h?.placement) : {
|
|
963
|
+
top: typeof window < "u" ? window.innerHeight / 2 : 0,
|
|
964
|
+
left: typeof window < "u" ? window.innerWidth / 2 : 0,
|
|
965
|
+
actualPlacement: "bottom"
|
|
966
|
+
}, [_, W, h?.placement]), Ee = e.length === 0 ? 0 : (r + 1) / e.length * 100, ce = x(
|
|
967
|
+
(M) => {
|
|
968
|
+
const P = R && e.length > 1, U = f && !Y && /* @__PURE__ */ t(
|
|
969
|
+
"button",
|
|
970
|
+
{
|
|
971
|
+
type: "button",
|
|
972
|
+
className: `nice-tutorial__btn nice-tutorial__btn--skip nice-tutorial__btn--${I}`,
|
|
973
|
+
onClick: s,
|
|
974
|
+
"aria-label": fe,
|
|
975
|
+
title: fe,
|
|
976
|
+
children: Te(/* @__PURE__ */ t(St, {}), fe, I)
|
|
977
|
+
}
|
|
978
|
+
), Q = !F && /* @__PURE__ */ t(
|
|
979
|
+
"button",
|
|
980
|
+
{
|
|
981
|
+
type: "button",
|
|
982
|
+
className: `nice-tutorial__btn nice-tutorial__btn--back nice-tutorial__btn--${I}`,
|
|
983
|
+
onClick: ge,
|
|
984
|
+
"aria-label": ne,
|
|
985
|
+
title: ne,
|
|
986
|
+
children: Te(/* @__PURE__ */ t(Lt, {}), ne, I)
|
|
987
|
+
}
|
|
988
|
+
), be = !h?.waitForAction && /* @__PURE__ */ t(
|
|
989
|
+
"button",
|
|
990
|
+
{
|
|
991
|
+
type: "button",
|
|
992
|
+
className: `nice-tutorial__btn nice-tutorial__btn--next nice-tutorial__btn--${I}`,
|
|
993
|
+
onClick: oe,
|
|
994
|
+
"aria-label": Y ? ie : Z,
|
|
995
|
+
title: Y ? ie : Z,
|
|
996
|
+
children: Te(/* @__PURE__ */ t(Rt, {}), Y ? ie : Z, I)
|
|
997
|
+
}
|
|
998
|
+
), ye = P && /* @__PURE__ */ t(
|
|
999
|
+
"button",
|
|
1000
|
+
{
|
|
1001
|
+
type: "button",
|
|
1002
|
+
className: [
|
|
1003
|
+
"nice-tutorial__btn",
|
|
1004
|
+
"nice-tutorial__btn--play",
|
|
1005
|
+
`nice-tutorial__btn--${I}`,
|
|
1006
|
+
N ? "nice-tutorial__btn--active" : ""
|
|
1007
|
+
].filter(Boolean).join(" "),
|
|
1008
|
+
onClick: Se,
|
|
1009
|
+
"aria-label": N ? _e : we,
|
|
1010
|
+
title: N ? _e : we,
|
|
1011
|
+
"aria-pressed": N,
|
|
1012
|
+
children: Te(
|
|
1013
|
+
N ? /* @__PURE__ */ t($t, {}) : /* @__PURE__ */ t(Tt, {}),
|
|
1014
|
+
N ? _e : we,
|
|
1015
|
+
I
|
|
1016
|
+
)
|
|
1017
|
+
}
|
|
1018
|
+
);
|
|
1019
|
+
return /* @__PURE__ */ g(
|
|
1020
|
+
"div",
|
|
1021
|
+
{
|
|
1022
|
+
className: [
|
|
1023
|
+
"nice-tutorial__controls",
|
|
1024
|
+
M ? "nice-tutorial__controls--inline" : "nice-tutorial__controls--floating-bottom"
|
|
1025
|
+
].join(" "),
|
|
1026
|
+
style: M ? void 0 : { zIndex: B + 2 },
|
|
1027
|
+
role: "group",
|
|
1028
|
+
"aria-label": "Tutorial controls",
|
|
1029
|
+
children: [
|
|
1030
|
+
U,
|
|
1031
|
+
Q,
|
|
1032
|
+
w && /* @__PURE__ */ g("span", { className: "nice-tutorial__step-label", "aria-live": "polite", children: [
|
|
1033
|
+
r + 1,
|
|
1034
|
+
" ",
|
|
1035
|
+
pe,
|
|
1036
|
+
" ",
|
|
1037
|
+
e.length
|
|
1038
|
+
] }),
|
|
1039
|
+
be,
|
|
1040
|
+
P && /* @__PURE__ */ t(
|
|
1041
|
+
"div",
|
|
1042
|
+
{
|
|
1043
|
+
className: "nice-tutorial__progress-bar",
|
|
1044
|
+
role: "progressbar",
|
|
1045
|
+
"aria-valuenow": Math.round(Ee),
|
|
1046
|
+
"aria-valuemin": 0,
|
|
1047
|
+
"aria-valuemax": 100,
|
|
1048
|
+
"aria-label": `${r + 1} ${pe} ${e.length}`,
|
|
1049
|
+
children: /* @__PURE__ */ t(
|
|
1050
|
+
"div",
|
|
1051
|
+
{
|
|
1052
|
+
className: "nice-tutorial__progress-bar-fill",
|
|
1053
|
+
style: { width: `${Ee}%` }
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
ye,
|
|
1059
|
+
P && /* @__PURE__ */ g("label", { className: "nice-tutorial__speed", children: [
|
|
1060
|
+
/* @__PURE__ */ t(
|
|
1061
|
+
"input",
|
|
1062
|
+
{
|
|
1063
|
+
type: "range",
|
|
1064
|
+
className: "nice-tutorial__speed-slider",
|
|
1065
|
+
min: c.min,
|
|
1066
|
+
max: c.max,
|
|
1067
|
+
step: 500,
|
|
1068
|
+
value: c.min + c.max - a,
|
|
1069
|
+
onChange: (Ye) => y(c.min + c.max - Number(Ye.target.value)),
|
|
1070
|
+
"aria-label": Re
|
|
1071
|
+
}
|
|
1072
|
+
),
|
|
1073
|
+
/* @__PURE__ */ g("span", { className: "nice-tutorial__speed-value", children: [
|
|
1074
|
+
(a / 1e3).toFixed(1),
|
|
1075
|
+
"s"
|
|
1076
|
+
] })
|
|
1077
|
+
] })
|
|
1078
|
+
]
|
|
1079
|
+
}
|
|
1080
|
+
);
|
|
1081
|
+
},
|
|
1082
|
+
[
|
|
1083
|
+
R,
|
|
1084
|
+
f,
|
|
1085
|
+
w,
|
|
1086
|
+
I,
|
|
1087
|
+
F,
|
|
1088
|
+
Y,
|
|
1089
|
+
s,
|
|
1090
|
+
fe,
|
|
1091
|
+
ne,
|
|
1092
|
+
Z,
|
|
1093
|
+
ie,
|
|
1094
|
+
we,
|
|
1095
|
+
_e,
|
|
1096
|
+
Re,
|
|
1097
|
+
pe,
|
|
1098
|
+
ge,
|
|
1099
|
+
oe,
|
|
1100
|
+
h,
|
|
1101
|
+
N,
|
|
1102
|
+
Se,
|
|
1103
|
+
r,
|
|
1104
|
+
e.length,
|
|
1105
|
+
Ee,
|
|
1106
|
+
a,
|
|
1107
|
+
c,
|
|
1108
|
+
B
|
|
1109
|
+
]
|
|
1110
|
+
);
|
|
1111
|
+
if (!n || !h)
|
|
1112
|
+
return null;
|
|
1113
|
+
const ze = typeof document < "u" ? Math.max(document.documentElement.scrollWidth, window.innerWidth) : 0, q = typeof document < "u" ? Math.max(document.documentElement.scrollHeight, window.innerHeight) : 0;
|
|
1114
|
+
return /* @__PURE__ */ g(
|
|
1115
|
+
"div",
|
|
1116
|
+
{
|
|
1117
|
+
className: "nice-tutorial",
|
|
1118
|
+
style: { zIndex: B },
|
|
1119
|
+
"aria-modal": "true",
|
|
1120
|
+
role: "dialog",
|
|
1121
|
+
"aria-label": "Tutorial",
|
|
1122
|
+
children: [
|
|
1123
|
+
/* @__PURE__ */ g(
|
|
1124
|
+
"svg",
|
|
1125
|
+
{
|
|
1126
|
+
className: "nice-tutorial__overlay",
|
|
1127
|
+
style: {
|
|
1128
|
+
position: "absolute",
|
|
1129
|
+
top: 0,
|
|
1130
|
+
left: 0,
|
|
1131
|
+
width: ze,
|
|
1132
|
+
height: q,
|
|
1133
|
+
pointerEvents: "auto"
|
|
1134
|
+
},
|
|
1135
|
+
onClick: p ? s : void 0,
|
|
1136
|
+
children: [
|
|
1137
|
+
/* @__PURE__ */ t("defs", { children: /* @__PURE__ */ g("mask", { id: "nice-tutorial-mask", children: [
|
|
1138
|
+
/* @__PURE__ */ t("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: "white" }),
|
|
1139
|
+
_ && /* @__PURE__ */ t(
|
|
1140
|
+
"rect",
|
|
1141
|
+
{
|
|
1142
|
+
x: _.left,
|
|
1143
|
+
y: _.top,
|
|
1144
|
+
width: _.width,
|
|
1145
|
+
height: _.height,
|
|
1146
|
+
rx: "4",
|
|
1147
|
+
fill: "black",
|
|
1148
|
+
className: o ? "nice-tutorial__spotlight--entering" : ""
|
|
1149
|
+
}
|
|
1150
|
+
)
|
|
1151
|
+
] }) }),
|
|
1152
|
+
/* @__PURE__ */ t(
|
|
1153
|
+
"rect",
|
|
1154
|
+
{
|
|
1155
|
+
x: "0",
|
|
1156
|
+
y: "0",
|
|
1157
|
+
width: "100%",
|
|
1158
|
+
height: "100%",
|
|
1159
|
+
fill: `rgba(0,0,0,${k})`,
|
|
1160
|
+
mask: "url(#nice-tutorial-mask)"
|
|
1161
|
+
}
|
|
1162
|
+
)
|
|
1163
|
+
]
|
|
1164
|
+
}
|
|
1165
|
+
),
|
|
1166
|
+
_ && /* @__PURE__ */ t(
|
|
1167
|
+
"div",
|
|
1168
|
+
{
|
|
1169
|
+
className: `nice-tutorial__highlight ${o ? "nice-tutorial__highlight--entering" : ""}`,
|
|
1170
|
+
style: {
|
|
1171
|
+
position: "absolute",
|
|
1172
|
+
top: _.top,
|
|
1173
|
+
left: _.left,
|
|
1174
|
+
width: _.width,
|
|
1175
|
+
height: _.height,
|
|
1176
|
+
transition: `all ${l}ms ease`
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
),
|
|
1180
|
+
h.disableInteraction && _ && /* @__PURE__ */ t(
|
|
1181
|
+
"div",
|
|
1182
|
+
{
|
|
1183
|
+
className: "nice-tutorial__blocker",
|
|
1184
|
+
style: {
|
|
1185
|
+
position: "absolute",
|
|
1186
|
+
top: _.top,
|
|
1187
|
+
left: _.left,
|
|
1188
|
+
width: _.width,
|
|
1189
|
+
height: _.height
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
),
|
|
1193
|
+
/* @__PURE__ */ g(
|
|
1194
|
+
"div",
|
|
1195
|
+
{
|
|
1196
|
+
ref: d,
|
|
1197
|
+
className: `nice-tutorial__tooltip nice-tutorial__tooltip--${ve.actualPlacement} ${o ? "nice-tutorial__tooltip--entering" : ""}`,
|
|
1198
|
+
style: {
|
|
1199
|
+
position: "absolute",
|
|
1200
|
+
top: ve.top,
|
|
1201
|
+
left: ve.left,
|
|
1202
|
+
transition: `all ${l}ms ease`,
|
|
1203
|
+
maxWidth: 380,
|
|
1204
|
+
zIndex: B + 1
|
|
1205
|
+
},
|
|
1206
|
+
children: [
|
|
1207
|
+
h.showArrow !== !1 && /* @__PURE__ */ t(
|
|
1208
|
+
"div",
|
|
1209
|
+
{
|
|
1210
|
+
className: `nice-tutorial__arrow nice-tutorial__arrow--${ve.actualPlacement}`
|
|
1211
|
+
}
|
|
1212
|
+
),
|
|
1213
|
+
/* @__PURE__ */ g("div", { className: "nice-tutorial__header", children: [
|
|
1214
|
+
/* @__PURE__ */ t("h4", { className: "nice-tutorial__title", children: h.title }),
|
|
1215
|
+
f && /* @__PURE__ */ t(
|
|
1216
|
+
"button",
|
|
1217
|
+
{
|
|
1218
|
+
type: "button",
|
|
1219
|
+
className: "nice-tutorial__close",
|
|
1220
|
+
onClick: s,
|
|
1221
|
+
"aria-label": ke,
|
|
1222
|
+
title: ke,
|
|
1223
|
+
children: /* @__PURE__ */ t(Mt, {})
|
|
1224
|
+
}
|
|
1225
|
+
)
|
|
1226
|
+
] }),
|
|
1227
|
+
/* @__PURE__ */ t(
|
|
1228
|
+
"div",
|
|
1229
|
+
{
|
|
1230
|
+
className: "nice-tutorial__content",
|
|
1231
|
+
dangerouslySetInnerHTML: { __html: _t(h.content) }
|
|
1232
|
+
}
|
|
1233
|
+
),
|
|
1234
|
+
L === "inline" && ce(!0)
|
|
1235
|
+
]
|
|
1236
|
+
}
|
|
1237
|
+
),
|
|
1238
|
+
L === "floating-bottom" && ce(!1)
|
|
1239
|
+
]
|
|
1240
|
+
}
|
|
1241
|
+
);
|
|
1242
|
+
};
|
|
1243
|
+
Ze.displayName = "NiceTutorial";
|
|
1244
|
+
const Qe = Ge({
|
|
1245
|
+
startTutorial: () => {
|
|
1246
|
+
},
|
|
1247
|
+
stopTutorial: () => {
|
|
1248
|
+
},
|
|
1249
|
+
isActive: !1,
|
|
1250
|
+
currentStep: 0,
|
|
1251
|
+
nextStep: () => {
|
|
1252
|
+
},
|
|
1253
|
+
prevStep: () => {
|
|
1254
|
+
},
|
|
1255
|
+
goToStep: () => {
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
function Vt() {
|
|
1259
|
+
return je(Qe);
|
|
1260
|
+
}
|
|
1261
|
+
const Pt = ({ children: e }) => {
|
|
1262
|
+
const [n, i] = X([]), [s, u] = X(!1), [m, p] = X(0), w = x((L) => {
|
|
1263
|
+
i(L), p(0), u(!0);
|
|
1264
|
+
}, []), f = x(() => {
|
|
1265
|
+
u(!1), p(0), i([]);
|
|
1266
|
+
}, []), b = x(() => {
|
|
1267
|
+
p((L) => Math.min(L + 1, n.length - 1));
|
|
1268
|
+
}, [n.length]), l = x(() => {
|
|
1269
|
+
p((L) => Math.max(L - 1, 0));
|
|
1270
|
+
}, []), k = x(
|
|
1271
|
+
(L) => {
|
|
1272
|
+
p(Math.max(0, Math.min(L, n.length - 1)));
|
|
1273
|
+
},
|
|
1274
|
+
[n.length]
|
|
1275
|
+
), B = {
|
|
1276
|
+
startTutorial: w,
|
|
1277
|
+
stopTutorial: f,
|
|
1278
|
+
isActive: s,
|
|
1279
|
+
currentStep: m,
|
|
1280
|
+
nextStep: b,
|
|
1281
|
+
prevStep: l,
|
|
1282
|
+
goToStep: k
|
|
1283
|
+
};
|
|
1284
|
+
return /* @__PURE__ */ g(Qe.Provider, { value: B, children: [
|
|
1285
|
+
e,
|
|
1286
|
+
s && n.length > 0 && /* @__PURE__ */ t(
|
|
1287
|
+
Ze,
|
|
1288
|
+
{
|
|
1289
|
+
steps: n,
|
|
1290
|
+
active: s,
|
|
1291
|
+
onFinish: f,
|
|
1292
|
+
onSkip: f,
|
|
1293
|
+
onStepChange: p
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
] });
|
|
1297
|
+
};
|
|
1298
|
+
Pt.displayName = "NiceTutorialProvider";
|
|
1299
|
+
function Yt(e, n, i, s, u) {
|
|
1300
|
+
const m = e <= u, p = e + u >= i, w = n <= u, f = n + u >= s;
|
|
1301
|
+
return w && m ? "top-left" : w && p ? "top-right" : f && m ? "bottom-left" : f && p ? "bottom-right" : m ? "left" : p ? "right" : w ? "top" : f ? "bottom" : "none";
|
|
1302
|
+
}
|
|
1303
|
+
function Dt(e) {
|
|
1304
|
+
switch (e) {
|
|
1305
|
+
case "left":
|
|
1306
|
+
return { left: 0, top: 0, width: "50%", height: "100%" };
|
|
1307
|
+
case "right":
|
|
1308
|
+
return { left: "50%", top: 0, width: "50%", height: "100%" };
|
|
1309
|
+
case "top":
|
|
1310
|
+
return { left: 0, top: 0, width: "100%", height: "50%" };
|
|
1311
|
+
case "bottom":
|
|
1312
|
+
return { left: 0, top: "50%", width: "100%", height: "50%" };
|
|
1313
|
+
case "top-left":
|
|
1314
|
+
return { left: 0, top: 0, width: "50%", height: "50%" };
|
|
1315
|
+
case "top-right":
|
|
1316
|
+
return { left: "50%", top: 0, width: "50%", height: "50%" };
|
|
1317
|
+
case "bottom-left":
|
|
1318
|
+
return { left: 0, top: "50%", width: "50%", height: "50%" };
|
|
1319
|
+
case "bottom-right":
|
|
1320
|
+
return { left: "50%", top: "50%", width: "50%", height: "50%" };
|
|
1321
|
+
default:
|
|
1322
|
+
return null;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
const Xt = He(
|
|
1326
|
+
({
|
|
1327
|
+
windowKey: e,
|
|
1328
|
+
title: n,
|
|
1329
|
+
icon: i,
|
|
1330
|
+
children: s,
|
|
1331
|
+
footer: u,
|
|
1332
|
+
x: m,
|
|
1333
|
+
y: p,
|
|
1334
|
+
defaultPosition: w,
|
|
1335
|
+
width: f = 480,
|
|
1336
|
+
height: b = 360,
|
|
1337
|
+
minWidth: l = 200,
|
|
1338
|
+
minHeight: k = 120,
|
|
1339
|
+
maxWidth: B,
|
|
1340
|
+
maxHeight: L,
|
|
1341
|
+
zIndex: I = 1,
|
|
1342
|
+
closable: R = !0,
|
|
1343
|
+
minimizable: O = !0,
|
|
1344
|
+
maximizable: c = !0,
|
|
1345
|
+
fullscreenable: v = !1,
|
|
1346
|
+
pinnable: r = !1,
|
|
1347
|
+
resizable: E = !0,
|
|
1348
|
+
draggable: _ = !0,
|
|
1349
|
+
snappable: G = !0,
|
|
1350
|
+
snapThreshold: W = 20,
|
|
1351
|
+
minimized: S,
|
|
1352
|
+
maximized: o,
|
|
1353
|
+
fullscreen: z,
|
|
1354
|
+
pinned: N,
|
|
1355
|
+
focused: T,
|
|
1356
|
+
onClose: a,
|
|
1357
|
+
onMinimize: y,
|
|
1358
|
+
onMaximize: d,
|
|
1359
|
+
onFullscreen: $,
|
|
1360
|
+
onPin: h,
|
|
1361
|
+
onFocus: Y,
|
|
1362
|
+
onMove: F,
|
|
1363
|
+
onResize: Z,
|
|
1364
|
+
onSnap: ne,
|
|
1365
|
+
onTitleBarDoubleClick: ie,
|
|
1366
|
+
size: fe = "md",
|
|
1367
|
+
statusBar: pe,
|
|
1368
|
+
titleBarActions: we,
|
|
1369
|
+
className: _e,
|
|
1370
|
+
style: Re,
|
|
1371
|
+
id: ke,
|
|
1372
|
+
accessMode: oe,
|
|
1373
|
+
...ge
|
|
1374
|
+
}, Se) => {
|
|
1375
|
+
const ve = Fe(ke), Ee = gt(oe, ke), { t: ce } = Pe(), ze = V(null);
|
|
1376
|
+
ze.current == null && (ze.current = `nice-window-${Math.random().toString(36).slice(2, 10)}`);
|
|
1377
|
+
const q = e ?? ze.current, M = m ?? w?.x ?? 100, P = p ?? w?.y ?? 100;
|
|
1378
|
+
if (Ee === "hidden")
|
|
1379
|
+
return null;
|
|
1380
|
+
const [U, Q] = X({ x: M, y: P }), [be, ye] = X({ width: f, height: b }), [Ye, Je] = X(!1), [et, tt] = X(!1), [nt, it] = X(!1), [ot, ct] = X(!1), [ee, De] = X("none"), rt = S ?? Ye, J = o ?? et, K = z ?? nt, Ce = N ?? ot, Xe = T ?? !0, me = U.x, he = U.y, re = be.width, se = be.height, le = V(
|
|
1381
|
+
null
|
|
1382
|
+
), j = V(null), D = V(null), st = x(() => {
|
|
1383
|
+
a?.(q);
|
|
1384
|
+
}, [q, a]), lt = x(() => {
|
|
1385
|
+
Je(!0), y?.(q);
|
|
1386
|
+
}, [q, y]), Be = x(() => {
|
|
1387
|
+
const C = !J;
|
|
1388
|
+
tt(C), !C && D.current ? (Q({ x: D.current.x, y: D.current.y }), ye({ width: D.current.w, height: D.current.h }), D.current = null) : C && (D.current = { x: me, y: he, w: re, h: se }), De("none"), d?.(q, C);
|
|
1389
|
+
}, [q, J, me, he, re, se, d]), Oe = x(() => {
|
|
1390
|
+
const C = !K;
|
|
1391
|
+
it(C), C ? D.current = { x: me, y: he, w: re, h: se } : D.current && (Q({ x: D.current.x, y: D.current.y }), ye({ width: D.current.w, height: D.current.h }), D.current = null), $?.(q, C);
|
|
1392
|
+
}, [q, K, me, he, re, se, $]), at = x(() => {
|
|
1393
|
+
const C = !Ce;
|
|
1394
|
+
ct(C), h?.(q, C);
|
|
1395
|
+
}, [q, Ce, h]), Ie = x(() => {
|
|
1396
|
+
Y?.(q);
|
|
1397
|
+
}, [q, Y]), dt = x(() => {
|
|
1398
|
+
ie ? ie(q) : c && Be();
|
|
1399
|
+
}, [q, c, Be, ie]);
|
|
1400
|
+
A(() => {
|
|
1401
|
+
const C = (ae) => {
|
|
1402
|
+
if (!le.current)
|
|
1403
|
+
return;
|
|
1404
|
+
const te = ae.clientX - le.current.startX + le.current.origX, Me = ae.clientY - le.current.startY + le.current.origY;
|
|
1405
|
+
Q({ x: te, y: Me }), F?.(q, { x: te, y: Me });
|
|
1406
|
+
}, H = (ae) => {
|
|
1407
|
+
if (le.current) {
|
|
1408
|
+
if (G) {
|
|
1409
|
+
const te = Yt(
|
|
1410
|
+
ae.clientX,
|
|
1411
|
+
ae.clientY,
|
|
1412
|
+
window.innerWidth,
|
|
1413
|
+
window.innerHeight,
|
|
1414
|
+
W
|
|
1415
|
+
);
|
|
1416
|
+
te !== "none" && (D.current = { x: U.x, y: U.y, w: re, h: se }, De(te), ne?.(q, te));
|
|
1417
|
+
}
|
|
1418
|
+
le.current = null;
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
return document.addEventListener("mousemove", C), document.addEventListener("mouseup", H), () => {
|
|
1422
|
+
document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", H);
|
|
1423
|
+
};
|
|
1424
|
+
});
|
|
1425
|
+
const ut = x(
|
|
1426
|
+
(C) => {
|
|
1427
|
+
!_ || J || K || (C.preventDefault(), ee !== "none" && (D.current && (Q({ x: D.current.x, y: D.current.y }), ye({ width: D.current.w, height: D.current.h })), De("none")), Ie(), le.current = { startX: C.clientX, startY: C.clientY, origX: me, origY: he });
|
|
1428
|
+
},
|
|
1429
|
+
[_, J, K, ee, me, he, Ie]
|
|
1430
|
+
);
|
|
1431
|
+
A(() => {
|
|
1432
|
+
const C = (ae) => {
|
|
1433
|
+
if (!j.current)
|
|
1434
|
+
return;
|
|
1435
|
+
const te = ae.clientX - j.current.startX, Me = ae.clientY - j.current.startY, xe = j.current.handle;
|
|
1436
|
+
let de = j.current.origW, ue = j.current.origH;
|
|
1437
|
+
if (xe.includes("e") && (de = j.current.origW + te), xe.includes("w") && (de = j.current.origW - te), xe.includes("s") && (ue = j.current.origH + Me), xe.includes("n") && (ue = j.current.origH - Me), de = Math.max(l, B ? Math.min(B, de) : de), ue = Math.max(k, L ? Math.min(L, ue) : ue), xe.includes("w")) {
|
|
1438
|
+
const qe = be.width - de;
|
|
1439
|
+
Q((Le) => ({ ...Le, x: Le.x + qe }));
|
|
1440
|
+
}
|
|
1441
|
+
if (xe.includes("n")) {
|
|
1442
|
+
const qe = be.height - ue;
|
|
1443
|
+
Q((Le) => ({ ...Le, y: Le.y + qe }));
|
|
1444
|
+
}
|
|
1445
|
+
ye({ width: de, height: ue }), Z?.(q, { width: de, height: ue });
|
|
1446
|
+
}, H = () => {
|
|
1447
|
+
j.current = null;
|
|
1448
|
+
};
|
|
1449
|
+
return document.addEventListener("mousemove", C), document.addEventListener("mouseup", H), () => {
|
|
1450
|
+
document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", H);
|
|
1451
|
+
};
|
|
1452
|
+
});
|
|
1453
|
+
const mt = x(
|
|
1454
|
+
(C, H) => {
|
|
1455
|
+
!E || J || K || ee !== "none" || (H.preventDefault(), H.stopPropagation(), Ie(), j.current = { startX: H.clientX, startY: H.clientY, origW: re, origH: se, handle: C });
|
|
1456
|
+
},
|
|
1457
|
+
[E, J, K, ee, re, se, Ie]
|
|
1458
|
+
);
|
|
1459
|
+
if (A(() => {
|
|
1460
|
+
if (!Xe)
|
|
1461
|
+
return;
|
|
1462
|
+
const C = (H) => {
|
|
1463
|
+
H.key === "Escape" && K && Oe();
|
|
1464
|
+
};
|
|
1465
|
+
return document.addEventListener("keydown", C), () => document.removeEventListener("keydown", C);
|
|
1466
|
+
}, [Xe, K, Oe]), rt)
|
|
1467
|
+
return null;
|
|
1468
|
+
const Ue = ee !== "none" ? Dt(ee) : null, Ke = J || K, ht = K ? { position: "fixed", top: 0, left: 0, width: "100vw", height: "100vh", zIndex: 999999 } : J ? { position: "absolute", top: 0, left: 0, width: "100%", height: "100%", zIndex: I } : Ue ? { position: "absolute", ...Ue, zIndex: I } : { position: "absolute", top: he, left: me, width: re, height: se, zIndex: I }, ft = ["n", "e", "s", "w", "ne", "se", "sw", "nw"], pt = {
|
|
1469
|
+
n: "ns-resize",
|
|
1470
|
+
s: "ns-resize",
|
|
1471
|
+
e: "ew-resize",
|
|
1472
|
+
w: "ew-resize",
|
|
1473
|
+
ne: "nesw-resize",
|
|
1474
|
+
sw: "nesw-resize",
|
|
1475
|
+
nw: "nwse-resize",
|
|
1476
|
+
se: "nwse-resize"
|
|
1477
|
+
};
|
|
1478
|
+
return /* @__PURE__ */ g(
|
|
1479
|
+
"div",
|
|
1480
|
+
{
|
|
1481
|
+
ref: Se,
|
|
1482
|
+
id: ve,
|
|
1483
|
+
className: `nice-window nice-window--${fe} ${Xe ? "nice-window--focused" : ""} ${Ce ? "nice-window--pinned" : ""} ${Ke ? "nice-window--maximized" : ""} ${ee !== "none" ? `nice-window--snapped-${ee}` : ""} ${_e ?? ""}`,
|
|
1484
|
+
style: { ...ht, ...Re },
|
|
1485
|
+
onMouseDown: Ie,
|
|
1486
|
+
role: "dialog",
|
|
1487
|
+
"aria-label": n,
|
|
1488
|
+
...ge,
|
|
1489
|
+
children: [
|
|
1490
|
+
/* @__PURE__ */ g(
|
|
1491
|
+
"div",
|
|
1492
|
+
{
|
|
1493
|
+
className: "nice-window__titlebar",
|
|
1494
|
+
onMouseDown: ut,
|
|
1495
|
+
onDoubleClick: dt,
|
|
1496
|
+
children: [
|
|
1497
|
+
i && /* @__PURE__ */ t("span", { className: "nice-window__icon", children: i }),
|
|
1498
|
+
/* @__PURE__ */ t("span", { className: "nice-window__title", children: n }),
|
|
1499
|
+
/* @__PURE__ */ g("div", { className: "nice-window__actions", children: [
|
|
1500
|
+
we,
|
|
1501
|
+
r && /* @__PURE__ */ t(
|
|
1502
|
+
"button",
|
|
1503
|
+
{
|
|
1504
|
+
type: "button",
|
|
1505
|
+
className: `nice-window__action nice-window__action--pin ${Ce ? "nice-window__action--active" : ""}`,
|
|
1506
|
+
onClick: at,
|
|
1507
|
+
title: ce("window.pin", Ce ? "Unpin" : "Pin"),
|
|
1508
|
+
children: "📌"
|
|
1509
|
+
}
|
|
1510
|
+
),
|
|
1511
|
+
O && /* @__PURE__ */ t(
|
|
1512
|
+
"button",
|
|
1513
|
+
{
|
|
1514
|
+
type: "button",
|
|
1515
|
+
className: "nice-window__action nice-window__action--minimize",
|
|
1516
|
+
onClick: lt,
|
|
1517
|
+
title: ce("window.minimize", "Minimize"),
|
|
1518
|
+
children: "─"
|
|
1519
|
+
}
|
|
1520
|
+
),
|
|
1521
|
+
c && /* @__PURE__ */ t(
|
|
1522
|
+
"button",
|
|
1523
|
+
{
|
|
1524
|
+
type: "button",
|
|
1525
|
+
className: "nice-window__action nice-window__action--maximize",
|
|
1526
|
+
onClick: Be,
|
|
1527
|
+
title: ce("window.maximize", J ? "Restore" : "Maximize"),
|
|
1528
|
+
children: J ? "❐" : "☐"
|
|
1529
|
+
}
|
|
1530
|
+
),
|
|
1531
|
+
v && /* @__PURE__ */ t(
|
|
1532
|
+
"button",
|
|
1533
|
+
{
|
|
1534
|
+
type: "button",
|
|
1535
|
+
className: "nice-window__action nice-window__action--fullscreen",
|
|
1536
|
+
onClick: Oe,
|
|
1537
|
+
title: ce("window.fullscreen", K ? "Exit Full Screen" : "Full Screen"),
|
|
1538
|
+
children: K ? "⇲" : "⇱"
|
|
1539
|
+
}
|
|
1540
|
+
),
|
|
1541
|
+
R && /* @__PURE__ */ t(
|
|
1542
|
+
"button",
|
|
1543
|
+
{
|
|
1544
|
+
type: "button",
|
|
1545
|
+
className: "nice-window__action nice-window__action--close",
|
|
1546
|
+
onClick: st,
|
|
1547
|
+
title: ce("window.close", "Close"),
|
|
1548
|
+
children: "✕"
|
|
1549
|
+
}
|
|
1550
|
+
)
|
|
1551
|
+
] })
|
|
1552
|
+
]
|
|
1553
|
+
}
|
|
1554
|
+
),
|
|
1555
|
+
/* @__PURE__ */ t("div", { className: "nice-window__body", children: s }),
|
|
1556
|
+
u && /* @__PURE__ */ t("div", { className: "nice-window__footer", children: u }),
|
|
1557
|
+
pe && /* @__PURE__ */ t("div", { className: "nice-window__statusbar", children: pe }),
|
|
1558
|
+
E && !Ke && ee === "none" && /* @__PURE__ */ t(Ae, { children: ft.map((C) => /* @__PURE__ */ t(
|
|
1559
|
+
"div",
|
|
1560
|
+
{
|
|
1561
|
+
className: `nice-window__resize nice-window__resize--${C}`,
|
|
1562
|
+
style: { cursor: pt[C] },
|
|
1563
|
+
onMouseDown: (H) => mt(C, H)
|
|
1564
|
+
},
|
|
1565
|
+
C
|
|
1566
|
+
)) })
|
|
1567
|
+
]
|
|
1568
|
+
}
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
);
|
|
1572
|
+
Xt.displayName = "NiceWindow";
|
|
1573
|
+
export {
|
|
1574
|
+
Wt as N,
|
|
1575
|
+
Et as a,
|
|
1576
|
+
Ht as b,
|
|
1577
|
+
kt as c,
|
|
1578
|
+
Ft as d,
|
|
1579
|
+
At as e,
|
|
1580
|
+
Kt as f,
|
|
1581
|
+
Ut as g,
|
|
1582
|
+
jt as h,
|
|
1583
|
+
Ze as i,
|
|
1584
|
+
Pt as j,
|
|
1585
|
+
Xt as k,
|
|
1586
|
+
zt as l,
|
|
1587
|
+
Gt as m,
|
|
1588
|
+
We as n,
|
|
1589
|
+
yt as o,
|
|
1590
|
+
Vt as p,
|
|
1591
|
+
Nt as u
|
|
1592
|
+
};
|