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