@overdoser/react-toolkit 0.7.0 → 0.8.1
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 +32 -0
- package/components/ActionButton/ActionButton.js +211 -0
- package/components/ActionButton/ActionButton.module.scss.js +47 -0
- package/components/ActionButton/CopyButton.js +66 -0
- package/components/Alert/Alert.js +82 -0
- package/components/Alert/Alert.module.scss.js +25 -0
- package/components/Avatar/Avatar.js +57 -0
- package/components/Avatar/Avatar.module.scss.js +43 -0
- package/components/Badge/Badge.js +38 -0
- package/components/Badge/Badge.module.scss.js +31 -0
- package/components/Breadcrumbs/Breadcrumbs.js +49 -0
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
- package/components/Button/Button.js +57 -0
- package/components/Button/Button.module.scss.js +47 -0
- package/components/Chart/AreaChart.js +244 -0
- package/components/Chart/Axis.js +45 -0
- package/components/Chart/BarChart.js +353 -0
- package/components/Chart/Chart.module.scss.js +61 -0
- package/components/Chart/ChartContainer.js +41 -0
- package/components/Chart/ChartLegend.js +31 -0
- package/components/Chart/ChartTooltip.js +42 -0
- package/components/Chart/LineChart.js +236 -0
- package/components/Chart/PieChart.js +248 -0
- package/components/Chart/RadarChart.js +221 -0
- package/components/Chart/Sparkline.js +69 -0
- package/components/Chart/TradingChart.js +732 -0
- package/components/Chart/scales.js +39 -0
- package/components/Chart/trading/indicators.js +68 -0
- package/components/Chart/trading/period.js +71 -0
- package/components/Chart/useChartDimensions.js +23 -0
- package/components/Divider/Divider.js +36 -0
- package/components/Divider/Divider.module.scss.js +31 -0
- package/components/Draggable/Draggable.js +155 -0
- package/components/Draggable/Draggable.module.scss.js +17 -0
- package/components/Drawer/Drawer.js +126 -0
- package/components/Drawer/Drawer.module.scss.js +117 -0
- package/components/Dropdown/Dropdown.js +142 -0
- package/components/Dropdown/Dropdown.module.scss.js +35 -0
- package/components/Dropdown/DropdownItem.js +31 -0
- package/components/Dropzone/Dropzone.js +107 -0
- package/components/Dropzone/Dropzone.module.scss.js +21 -0
- package/components/Form/Form.js +36 -0
- package/components/Form/Form.module.scss.js +29 -0
- package/components/Form/FormField.js +76 -0
- package/components/Form/FormRow.js +9 -0
- package/components/Form/formFieldDefaults.js +5 -0
- package/components/Link/Link.js +59 -0
- package/components/Link/Link.module.scss.js +16 -0
- package/components/List/List.js +46 -0
- package/components/List/List.module.scss.js +21 -0
- package/components/Modal/Modal.js +114 -0
- package/components/Modal/Modal.module.scss.js +31 -0
- package/components/Pagination/Pagination.js +84 -0
- package/components/Pagination/Pagination.module.scss.js +23 -0
- package/components/Pagination/paginationRange.js +24 -0
- package/components/Popover/Popover.js +138 -0
- package/components/Popover/Popover.module.scss.js +21 -0
- package/components/Skeleton/Skeleton.js +50 -0
- package/components/Skeleton/Skeleton.module.scss.js +25 -0
- package/components/Spinner/Spinner.js +25 -0
- package/components/Spinner/Spinner.module.scss.js +20 -0
- package/components/Table/Table.js +284 -0
- package/components/Table/Table.module.scss.js +59 -0
- package/components/Table/useTableSort.js +44 -0
- package/components/Tabs/Tabs.js +163 -0
- package/components/Tabs/Tabs.module.scss.js +53 -0
- package/components/Timer/Timer.js +159 -0
- package/components/Timer/Timer.module.scss.js +55 -0
- package/components/Toast/Toast.js +133 -0
- package/components/Toast/Toast.module.scss.js +62 -0
- package/components/Toast/toastStore.js +62 -0
- package/components/ToggleIconButton/ToggleIconButton.js +58 -0
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
- package/components/Tooltip/Tooltip.js +86 -0
- package/components/Tooltip/Tooltip.module.scss.js +30 -0
- package/components/Typography/Typography.js +37 -0
- package/components/Typography/Typography.module.scss.js +53 -0
- package/components/inputs/Checkbox/Checkbox.js +50 -0
- package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
- package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
- package/components/inputs/DatePicker/DatePicker.js +229 -0
- package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
- package/components/inputs/DatePicker/dateUtils.js +41 -0
- package/components/inputs/Input/Input.js +50 -0
- package/components/inputs/Input/Input.module.scss.js +25 -0
- package/components/inputs/NumberInput/NumberInput.js +134 -0
- package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
- package/components/inputs/Radio/Radio.js +68 -0
- package/components/inputs/Radio/Radio.module.scss.js +13 -0
- package/components/inputs/Select/Select.js +520 -0
- package/components/inputs/Select/Select.module.scss.js +69 -0
- package/components/inputs/Slider/Slider.js +128 -0
- package/components/inputs/Slider/Slider.module.scss.js +15 -0
- package/components/inputs/Textarea/Textarea.js +58 -0
- package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
- package/hooks/useClickOutside.js +15 -0
- package/hooks/useFocusTrap.js +39 -0
- package/hooks/useKeyboard.js +19 -0
- package/hooks/usePortalPosition.js +20 -0
- package/index.css +1 -1
- package/index.js +119 -7000
- package/index.layered.css +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function p(t) {
|
|
2
|
+
if (t.length === 0) return [0, 1];
|
|
3
|
+
let o = t[0], c = t[0];
|
|
4
|
+
for (let r = 1; r < t.length; r++) {
|
|
5
|
+
const e = t[r];
|
|
6
|
+
e < o && (o = e), e > c && (c = e);
|
|
7
|
+
}
|
|
8
|
+
return [o, c];
|
|
9
|
+
}
|
|
10
|
+
function u(t, o) {
|
|
11
|
+
const [c, r] = t, [e, a] = o, s = r - c || 1, n = a - e, f = (i) => e + (i - c) / s * n;
|
|
12
|
+
return f.invert = (i) => c + (i - e) / n * s, f;
|
|
13
|
+
}
|
|
14
|
+
function M(t, o, c = 0.2) {
|
|
15
|
+
const [r, e] = o, s = (e - r) / Math.max(1, t.length), n = s * (1 - c), f = /* @__PURE__ */ new Map();
|
|
16
|
+
for (let l = 0; l < t.length; l++) f.set(t[l], l);
|
|
17
|
+
const i = (l) => {
|
|
18
|
+
const h = f.get(l);
|
|
19
|
+
return h === void 0 ? r : r + h * s + s / 2;
|
|
20
|
+
};
|
|
21
|
+
return i.bandWidth = () => n, i.step = () => s, i;
|
|
22
|
+
}
|
|
23
|
+
function d(t, o, c = 5) {
|
|
24
|
+
if (t === o)
|
|
25
|
+
return [t];
|
|
26
|
+
const e = (o - t) / Math.max(1, c), a = Math.pow(10, Math.floor(Math.log10(e))), s = e / a;
|
|
27
|
+
let n;
|
|
28
|
+
s < 1.5 ? n = a : s < 3 ? n = 2 * a : s < 7 ? n = 5 * a : n = 10 * a;
|
|
29
|
+
const f = Math.floor(t / n) * n, i = Math.ceil(o / n) * n, l = [];
|
|
30
|
+
for (let h = f; h <= i + n / 2; h += n)
|
|
31
|
+
l.push(Number(h.toFixed(10)));
|
|
32
|
+
return l;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
M as bandScale,
|
|
36
|
+
p as extent,
|
|
37
|
+
u as linearScale,
|
|
38
|
+
d as niceTicks
|
|
39
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function i(n, l) {
|
|
2
|
+
const f = new Array(n.length).fill(null);
|
|
3
|
+
if (l <= 0 || n.length < l) return f;
|
|
4
|
+
let c = 0;
|
|
5
|
+
for (let t = 0; t < l; t++) c += n[t].close;
|
|
6
|
+
f[l - 1] = c / l;
|
|
7
|
+
for (let t = l; t < n.length; t++)
|
|
8
|
+
c += n[t].close - n[t - l].close, f[t] = c / l;
|
|
9
|
+
return f;
|
|
10
|
+
}
|
|
11
|
+
function A(n, l) {
|
|
12
|
+
const f = new Array(n.length).fill(null);
|
|
13
|
+
if (l <= 0 || n.length < l) return f;
|
|
14
|
+
const c = 2 / (l + 1);
|
|
15
|
+
let t = 0;
|
|
16
|
+
for (let e = 0; e < l; e++) t += n[e].close;
|
|
17
|
+
let u = t / l;
|
|
18
|
+
f[l - 1] = u;
|
|
19
|
+
for (let e = l; e < n.length; e++)
|
|
20
|
+
u = n[e].close * c + u * (1 - c), f[e] = u;
|
|
21
|
+
return f;
|
|
22
|
+
}
|
|
23
|
+
function v(n, l, f = 2) {
|
|
24
|
+
const c = n.length, t = new Array(c).fill(null), u = new Array(c).fill(null), e = new Array(c).fill(null);
|
|
25
|
+
if (l <= 0 || c < l) return { middle: t, upper: u, lower: e };
|
|
26
|
+
for (let o = l - 1; o < c; o++) {
|
|
27
|
+
let g = 0;
|
|
28
|
+
for (let s = o - l + 1; s <= o; s++) g += n[s].close;
|
|
29
|
+
const h = g / l;
|
|
30
|
+
let m = 0;
|
|
31
|
+
for (let s = o - l + 1; s <= o; s++) {
|
|
32
|
+
const w = n[s].close - h;
|
|
33
|
+
m += w * w;
|
|
34
|
+
}
|
|
35
|
+
m /= l;
|
|
36
|
+
const r = Math.sqrt(m);
|
|
37
|
+
t[o] = h, u[o] = h + f * r, e[o] = h - f * r;
|
|
38
|
+
}
|
|
39
|
+
return { middle: t, upper: u, lower: e };
|
|
40
|
+
}
|
|
41
|
+
function a(n, l = 14) {
|
|
42
|
+
const f = new Array(n.length).fill(null);
|
|
43
|
+
if (n.length <= l) return f;
|
|
44
|
+
let c = 0, t = 0;
|
|
45
|
+
for (let u = 1; u <= l; u++) {
|
|
46
|
+
const e = n[u].close - n[u - 1].close;
|
|
47
|
+
e >= 0 ? c += e : t -= e;
|
|
48
|
+
}
|
|
49
|
+
c /= l, t /= l, f[l] = y(c, t);
|
|
50
|
+
for (let u = l + 1; u < n.length; u++) {
|
|
51
|
+
const e = n[u].close - n[u - 1].close, o = e > 0 ? e : 0, g = e < 0 ? -e : 0;
|
|
52
|
+
c = (c * (l - 1) + o) / l, t = (t * (l - 1) + g) / l, f[u] = y(c, t);
|
|
53
|
+
}
|
|
54
|
+
return f;
|
|
55
|
+
}
|
|
56
|
+
function y(n, l) {
|
|
57
|
+
return l === 0 ? 100 : 100 - 100 / (1 + n / l);
|
|
58
|
+
}
|
|
59
|
+
function j(n) {
|
|
60
|
+
return n.map((l) => typeof l.volume == "number" ? l.volume : null);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
v as bollinger,
|
|
64
|
+
A as ema,
|
|
65
|
+
a as rsi,
|
|
66
|
+
i as sma,
|
|
67
|
+
j as volume
|
|
68
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function u(e) {
|
|
2
|
+
switch (e) {
|
|
3
|
+
case "1D":
|
|
4
|
+
return 86400;
|
|
5
|
+
case "5D":
|
|
6
|
+
return 5 * 86400;
|
|
7
|
+
case "1M":
|
|
8
|
+
return 30 * 86400;
|
|
9
|
+
case "3M":
|
|
10
|
+
return 90 * 86400;
|
|
11
|
+
case "6M":
|
|
12
|
+
return 180 * 86400;
|
|
13
|
+
case "1Y":
|
|
14
|
+
return 365 * 86400;
|
|
15
|
+
case "5Y":
|
|
16
|
+
return 5 * 365 * 86400;
|
|
17
|
+
case "10Y":
|
|
18
|
+
return 10 * 365 * 86400;
|
|
19
|
+
case "20Y":
|
|
20
|
+
return 20 * 365 * 86400;
|
|
21
|
+
case "MAX":
|
|
22
|
+
return 100 * 365 * 86400;
|
|
23
|
+
}
|
|
24
|
+
const r = /^(\d+)\s*([dDwWmMyYhH])$/.exec(e);
|
|
25
|
+
if (r) {
|
|
26
|
+
const n = Number(r[1]), t = r[2].toLowerCase();
|
|
27
|
+
if (t === "h") return n * 3600;
|
|
28
|
+
if (t === "d") return n * 86400;
|
|
29
|
+
if (t === "w") return n * 7 * 86400;
|
|
30
|
+
if (t === "m") return n * 30 * 86400;
|
|
31
|
+
if (t === "y") return n * 365 * 86400;
|
|
32
|
+
}
|
|
33
|
+
return 30 * 86400;
|
|
34
|
+
}
|
|
35
|
+
function s(e) {
|
|
36
|
+
switch (e) {
|
|
37
|
+
case "1D":
|
|
38
|
+
return "5";
|
|
39
|
+
case "5D":
|
|
40
|
+
return "15";
|
|
41
|
+
case "1M":
|
|
42
|
+
return "60";
|
|
43
|
+
case "3M":
|
|
44
|
+
return "240";
|
|
45
|
+
case "6M":
|
|
46
|
+
return "D";
|
|
47
|
+
case "1Y":
|
|
48
|
+
return "D";
|
|
49
|
+
case "5Y":
|
|
50
|
+
return "W";
|
|
51
|
+
case "10Y":
|
|
52
|
+
return "W";
|
|
53
|
+
case "20Y":
|
|
54
|
+
return "M";
|
|
55
|
+
case "MAX":
|
|
56
|
+
return "M";
|
|
57
|
+
}
|
|
58
|
+
const r = u(e);
|
|
59
|
+
return r >= 3 * 365 * 86400 ? "W" : r >= 180 * 86400 ? "D" : r >= 60 * 86400 ? "240" : r >= 14 * 86400 ? "60" : r >= 3 * 86400 ? "15" : "5";
|
|
60
|
+
}
|
|
61
|
+
function c(e) {
|
|
62
|
+
if (e === "W" || e === "M") return "5Y";
|
|
63
|
+
if (e === "D") return "1Y";
|
|
64
|
+
const r = Number(e);
|
|
65
|
+
return !Number.isFinite(r) || r >= 240 ? "3M" : r >= 60 ? "1M" : r >= 15 || r >= 5 ? "5D" : "1D";
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
u as periodToSeconds,
|
|
69
|
+
c as suggestPeriodForResolution,
|
|
70
|
+
s as suggestResolutionForPeriod
|
|
71
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useState as g, useRef as w, useEffect as m } from "react";
|
|
2
|
+
function b(o, c = { width: 600, height: 300 }) {
|
|
3
|
+
const [f, a] = g(c), r = w(c);
|
|
4
|
+
return m(() => {
|
|
5
|
+
const h = o.current;
|
|
6
|
+
if (!h || typeof ResizeObserver > "u") return;
|
|
7
|
+
const u = (i, n) => {
|
|
8
|
+
const t = Math.max(0, Math.round(i)), s = Math.max(0, Math.round(n));
|
|
9
|
+
r.current.width === t && r.current.height === s || (r.current = { width: t, height: s }, a({ width: t, height: s }));
|
|
10
|
+
}, e = h.getBoundingClientRect();
|
|
11
|
+
(e.width > 0 || e.height > 0) && u(e.width, e.height);
|
|
12
|
+
const d = new ResizeObserver((i) => {
|
|
13
|
+
const n = i[0];
|
|
14
|
+
if (!n) return;
|
|
15
|
+
const t = n.contentRect;
|
|
16
|
+
u(t.width, t.height);
|
|
17
|
+
});
|
|
18
|
+
return d.observe(h), () => d.disconnect();
|
|
19
|
+
}, [o]), f;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
b as useChartDimensions
|
|
23
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as e, jsxs as c, Fragment as h } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as f } from "react";
|
|
3
|
+
import a from "clsx";
|
|
4
|
+
import r from "./Divider.module.scss.js";
|
|
5
|
+
const N = f(
|
|
6
|
+
({ orientation: o = "horizontal", variant: t = "solid", label: n, labelPosition: m = "center", classes: l, className: s, ...p }, d) => {
|
|
7
|
+
const i = n != null && o === "horizontal";
|
|
8
|
+
return /* @__PURE__ */ e(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref: d,
|
|
12
|
+
role: "separator",
|
|
13
|
+
"aria-orientation": o,
|
|
14
|
+
className: a(
|
|
15
|
+
r.root,
|
|
16
|
+
r[o],
|
|
17
|
+
r[t],
|
|
18
|
+
i && r.withLabel,
|
|
19
|
+
i && r[`label_${m}`],
|
|
20
|
+
l?.root,
|
|
21
|
+
s
|
|
22
|
+
),
|
|
23
|
+
...p,
|
|
24
|
+
children: i ? /* @__PURE__ */ c(h, { children: [
|
|
25
|
+
/* @__PURE__ */ e("span", { className: a(r.line, l?.line) }),
|
|
26
|
+
/* @__PURE__ */ e("span", { className: a(r.label, l?.label), children: n }),
|
|
27
|
+
/* @__PURE__ */ e("span", { className: a(r.line, l?.line) })
|
|
28
|
+
] }) : null
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
N.displayName = "Divider";
|
|
34
|
+
export {
|
|
35
|
+
N as Divider
|
|
36
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const l = "crk-root-NGCl-", t = "crk-horizontal-X75Kv", e = "crk-vertical-RMtD4", a = "crk-solid-TBm4T", o = "crk-dashed-SegXI", c = "crk-dotted--Swoe", r = "crk-withLabel-Eu-NF", n = "crk-line-27unV", s = "crk-label-cjRGC", d = "crk-label_start-KQBPQ", b = "crk-label_start-KQBPQ", i = "crk-label_end-i4XW3", k = "crk-label_end-i4XW3", h = {
|
|
2
|
+
root: l,
|
|
3
|
+
horizontal: t,
|
|
4
|
+
vertical: e,
|
|
5
|
+
solid: a,
|
|
6
|
+
dashed: o,
|
|
7
|
+
dotted: c,
|
|
8
|
+
withLabel: r,
|
|
9
|
+
line: n,
|
|
10
|
+
label: s,
|
|
11
|
+
label_start: d,
|
|
12
|
+
labelStart: b,
|
|
13
|
+
label_end: i,
|
|
14
|
+
labelEnd: k
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
o as dashed,
|
|
18
|
+
h as default,
|
|
19
|
+
c as dotted,
|
|
20
|
+
t as horizontal,
|
|
21
|
+
s as label,
|
|
22
|
+
k as labelEnd,
|
|
23
|
+
b as labelStart,
|
|
24
|
+
i as label_end,
|
|
25
|
+
d as label_start,
|
|
26
|
+
n as line,
|
|
27
|
+
l as root,
|
|
28
|
+
a as solid,
|
|
29
|
+
e as vertical,
|
|
30
|
+
r as withLabel
|
|
31
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as Y } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as nt, useRef as H, useState as X, useCallback as s, useEffect as W, useContext as et, createContext as rt } from "react";
|
|
3
|
+
import q from "clsx";
|
|
4
|
+
import c from "./Draggable.module.scss.js";
|
|
5
|
+
const z = rt(null), F = nt(
|
|
6
|
+
({
|
|
7
|
+
children: b,
|
|
8
|
+
defaultPosition: C,
|
|
9
|
+
position: f,
|
|
10
|
+
axis: a = "both",
|
|
11
|
+
bounds: o = "viewport",
|
|
12
|
+
keyboardStep: g = 10,
|
|
13
|
+
disabled: l = !1,
|
|
14
|
+
onDragStart: E,
|
|
15
|
+
onDrag: L,
|
|
16
|
+
onDragEnd: m,
|
|
17
|
+
classes: A,
|
|
18
|
+
className: J,
|
|
19
|
+
style: M,
|
|
20
|
+
...Q
|
|
21
|
+
}, u) => {
|
|
22
|
+
const h = H(null), P = f !== void 0, [T, V] = X(
|
|
23
|
+
C ?? { x: 0, y: 0 }
|
|
24
|
+
), w = P ? f : T, d = H(w);
|
|
25
|
+
d.current = w;
|
|
26
|
+
const [p, B] = X(!1), R = H(null), N = H(0), [$, K] = X(!1), Z = s(() => (N.current += 1, K(!0), () => {
|
|
27
|
+
N.current -= 1, N.current === 0 && K(!1);
|
|
28
|
+
}), []), _ = s(
|
|
29
|
+
(t) => {
|
|
30
|
+
h.current = t, typeof u == "function" ? u(t) : u && (u.current = t);
|
|
31
|
+
},
|
|
32
|
+
[u]
|
|
33
|
+
), x = s((t) => {
|
|
34
|
+
const e = h.current?.getBoundingClientRect();
|
|
35
|
+
return e ? { left: e.left - t.x, top: e.top - t.y, width: e.width, height: e.height } : { left: 0, top: 0, width: 0, height: 0 };
|
|
36
|
+
}, []), v = s(
|
|
37
|
+
(t, e, r) => {
|
|
38
|
+
if (o === "none" || typeof window > "u") return { x: t, y: e };
|
|
39
|
+
const n = o === "parent" && h.current?.parentElement ? h.current.parentElement.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }, i = n.left - r.left, y = n.right - r.width - r.left, U = n.top - r.top, O = n.bottom - r.height - r.top;
|
|
40
|
+
return {
|
|
41
|
+
x: Math.min(Math.max(t, Math.min(i, y)), Math.max(i, y)),
|
|
42
|
+
y: Math.min(Math.max(e, Math.min(U, O)), Math.max(U, O))
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
[o]
|
|
46
|
+
), D = s(
|
|
47
|
+
(t) => {
|
|
48
|
+
d.current = t, P || V(t), L?.(t);
|
|
49
|
+
},
|
|
50
|
+
[P, L]
|
|
51
|
+
), j = s(
|
|
52
|
+
(t) => {
|
|
53
|
+
if (l || t.button > 0) return;
|
|
54
|
+
t.preventDefault();
|
|
55
|
+
const e = d.current;
|
|
56
|
+
R.current = {
|
|
57
|
+
startX: t.clientX,
|
|
58
|
+
startY: t.clientY,
|
|
59
|
+
origin: e,
|
|
60
|
+
base: x(e)
|
|
61
|
+
}, B(!0), E?.(e);
|
|
62
|
+
},
|
|
63
|
+
[l, x, E]
|
|
64
|
+
);
|
|
65
|
+
W(() => {
|
|
66
|
+
if (!p) return;
|
|
67
|
+
const t = (r) => {
|
|
68
|
+
const n = R.current;
|
|
69
|
+
if (!n) return;
|
|
70
|
+
const i = a === "y" ? n.origin.x : n.origin.x + (r.clientX - n.startX), y = a === "x" ? n.origin.y : n.origin.y + (r.clientY - n.startY);
|
|
71
|
+
D(v(i, y, n.base));
|
|
72
|
+
}, e = () => {
|
|
73
|
+
B(!1), R.current = null, m?.(d.current);
|
|
74
|
+
};
|
|
75
|
+
return window.addEventListener("pointermove", t), window.addEventListener("pointerup", e), () => {
|
|
76
|
+
window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", e);
|
|
77
|
+
};
|
|
78
|
+
}, [p, a, v, D, m]);
|
|
79
|
+
const k = s(
|
|
80
|
+
(t) => {
|
|
81
|
+
if (l) return;
|
|
82
|
+
const r = {
|
|
83
|
+
ArrowLeft: [-g, 0],
|
|
84
|
+
ArrowRight: [g, 0],
|
|
85
|
+
ArrowUp: [0, -g],
|
|
86
|
+
ArrowDown: [0, g]
|
|
87
|
+
}[t.key];
|
|
88
|
+
if (!r || a === "x" && r[1] !== 0 || a === "y" && r[0] !== 0) return;
|
|
89
|
+
t.preventDefault();
|
|
90
|
+
const n = d.current, i = v(n.x + r[0], n.y + r[1], x(n));
|
|
91
|
+
D(i), m?.(i);
|
|
92
|
+
},
|
|
93
|
+
[a, v, D, l, x, g, m]
|
|
94
|
+
), S = {
|
|
95
|
+
startPointerDrag: j,
|
|
96
|
+
onHandleKeyDown: k,
|
|
97
|
+
registerHandle: Z,
|
|
98
|
+
handleClassName: A?.handle,
|
|
99
|
+
disabled: l,
|
|
100
|
+
dragging: p
|
|
101
|
+
}, I = `translate(${w.x}px, ${w.y}px)`, tt = {
|
|
102
|
+
...M,
|
|
103
|
+
transform: M?.transform ? `${I} ${M.transform}` : I
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ Y(z.Provider, { value: S, children: /* @__PURE__ */ Y(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
ref: _,
|
|
109
|
+
className: q(
|
|
110
|
+
c.root,
|
|
111
|
+
!$ && !l && c.surfaceDraggable,
|
|
112
|
+
p && c.dragging,
|
|
113
|
+
A?.root,
|
|
114
|
+
J
|
|
115
|
+
),
|
|
116
|
+
style: tt,
|
|
117
|
+
onPointerDown: $ ? void 0 : j,
|
|
118
|
+
...Q,
|
|
119
|
+
children: b
|
|
120
|
+
}
|
|
121
|
+
) });
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
F.displayName = "Draggable";
|
|
125
|
+
function G({ children: b, className: C, style: f, ...a }) {
|
|
126
|
+
const o = et(z);
|
|
127
|
+
if (!o)
|
|
128
|
+
throw new Error("Draggable.Handle must be rendered inside a <Draggable>.");
|
|
129
|
+
return W(() => o.registerHandle(), [o.registerHandle]), /* @__PURE__ */ Y(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: q(
|
|
133
|
+
c.handle,
|
|
134
|
+
o.disabled && c.handleDisabled,
|
|
135
|
+
o.dragging && c.handleDragging,
|
|
136
|
+
o.handleClassName,
|
|
137
|
+
C
|
|
138
|
+
),
|
|
139
|
+
style: f,
|
|
140
|
+
role: "button",
|
|
141
|
+
"aria-label": "Drag handle",
|
|
142
|
+
"aria-disabled": o.disabled || void 0,
|
|
143
|
+
tabIndex: o.disabled ? -1 : 0,
|
|
144
|
+
onPointerDown: o.startPointerDrag,
|
|
145
|
+
onKeyDown: o.onHandleKeyDown,
|
|
146
|
+
...a,
|
|
147
|
+
children: b
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
G.displayName = "Draggable.Handle";
|
|
152
|
+
const lt = Object.assign(F, { Handle: G });
|
|
153
|
+
export {
|
|
154
|
+
lt as Draggable
|
|
155
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const a = "crk-root-5Kdf2", g = "crk-surfaceDraggable-mIpX8", n = "crk-dragging-XtMt7", r = "crk-handle-r4nFh", e = "crk-handleDragging-FRObk", d = "crk-handleDisabled-8t94h", l = {
|
|
2
|
+
root: a,
|
|
3
|
+
surfaceDraggable: g,
|
|
4
|
+
dragging: n,
|
|
5
|
+
handle: r,
|
|
6
|
+
handleDragging: e,
|
|
7
|
+
handleDisabled: d
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
l as default,
|
|
11
|
+
n as dragging,
|
|
12
|
+
r as handle,
|
|
13
|
+
d as handleDisabled,
|
|
14
|
+
e as handleDragging,
|
|
15
|
+
a as root,
|
|
16
|
+
g as surfaceDraggable
|
|
17
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as l, jsxs as W } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as z, useRef as K, useId as q, useState as n, useEffect as p, useMemo as G, createContext as J, useContext as v } from "react";
|
|
3
|
+
import { createPortal as Q } from "react-dom";
|
|
4
|
+
import i from "clsx";
|
|
5
|
+
import { useFocusTrap as U } from "../../hooks/useFocusTrap.js";
|
|
6
|
+
import { useKeyboard as V } from "../../hooks/useKeyboard.js";
|
|
7
|
+
import r from "./Drawer.module.scss.js";
|
|
8
|
+
const u = J({ classes: {}, titleId: "" }), D = ({ children: e, className: o, style: a, onClose: t }) => {
|
|
9
|
+
const { classes: c, titleId: f } = v(u);
|
|
10
|
+
return /* @__PURE__ */ W(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
id: f,
|
|
14
|
+
className: i(r.header, t && r.headerWithClose, c.header, o),
|
|
15
|
+
style: a,
|
|
16
|
+
children: [
|
|
17
|
+
e,
|
|
18
|
+
t && /* @__PURE__ */ l(
|
|
19
|
+
"button",
|
|
20
|
+
{
|
|
21
|
+
type: "button",
|
|
22
|
+
className: i(r.closeButton, c.closeButton),
|
|
23
|
+
onClick: t,
|
|
24
|
+
"aria-label": "Close",
|
|
25
|
+
children: "×"
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
D.displayName = "Drawer.Header";
|
|
33
|
+
const R = ({ children: e, className: o, style: a }) => {
|
|
34
|
+
const { classes: t } = v(u);
|
|
35
|
+
return /* @__PURE__ */ l("div", { className: i(r.body, t.body, o), style: a, children: e });
|
|
36
|
+
};
|
|
37
|
+
R.displayName = "Drawer.Body";
|
|
38
|
+
const S = ({ children: e, className: o, style: a }) => {
|
|
39
|
+
const { classes: t } = v(u);
|
|
40
|
+
return /* @__PURE__ */ l("div", { className: i(r.footer, t.footer, o), style: a, children: e });
|
|
41
|
+
};
|
|
42
|
+
S.displayName = "Drawer.Footer";
|
|
43
|
+
const X = 340, m = z(
|
|
44
|
+
({
|
|
45
|
+
open: e,
|
|
46
|
+
onClose: o,
|
|
47
|
+
side: a = "right",
|
|
48
|
+
size: t = "md",
|
|
49
|
+
variant: c = "temporary",
|
|
50
|
+
closeOnBackdrop: f = !0,
|
|
51
|
+
closeOnEscape: w = !0,
|
|
52
|
+
classes: y,
|
|
53
|
+
className: T,
|
|
54
|
+
style: C,
|
|
55
|
+
children: _,
|
|
56
|
+
"aria-label": h,
|
|
57
|
+
"aria-labelledby": $
|
|
58
|
+
}, A) => {
|
|
59
|
+
const F = K(null), N = A ?? F, H = q(), k = $ ?? `${H}-title`, b = c === "temporary", [s, B] = n(e), [I, g] = n(!1), [x, M] = n(a), [j, E] = n(t);
|
|
60
|
+
p(() => {
|
|
61
|
+
e && (B(!0), g(!1), M(a), E(t));
|
|
62
|
+
}, [e, a, t]), p(() => {
|
|
63
|
+
if (e || !s) return;
|
|
64
|
+
g(!0);
|
|
65
|
+
const d = setTimeout(() => B(!1), X);
|
|
66
|
+
return () => clearTimeout(d);
|
|
67
|
+
}, [e, s]), U(N, s && e && b);
|
|
68
|
+
const O = G(
|
|
69
|
+
() => ({ Escape: () => w && o() }),
|
|
70
|
+
[w, o]
|
|
71
|
+
);
|
|
72
|
+
V(O, e), p(() => {
|
|
73
|
+
if (!s) return;
|
|
74
|
+
const d = document.body.style.overflow;
|
|
75
|
+
return document.body.style.overflow = "hidden", () => {
|
|
76
|
+
document.body.style.overflow = d;
|
|
77
|
+
};
|
|
78
|
+
}, [s]);
|
|
79
|
+
const P = (d) => {
|
|
80
|
+
f && d.target === d.currentTarget && o();
|
|
81
|
+
};
|
|
82
|
+
return s ? Q(
|
|
83
|
+
/* @__PURE__ */ l(
|
|
84
|
+
"div",
|
|
85
|
+
{
|
|
86
|
+
className: i(
|
|
87
|
+
r.backdrop,
|
|
88
|
+
I && r.backdropClosing,
|
|
89
|
+
!b && r.backdropBare,
|
|
90
|
+
y?.backdrop
|
|
91
|
+
),
|
|
92
|
+
onClick: P,
|
|
93
|
+
role: "presentation",
|
|
94
|
+
children: /* @__PURE__ */ l(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
ref: N,
|
|
98
|
+
className: i(
|
|
99
|
+
r.drawer,
|
|
100
|
+
r[`side_${x}`],
|
|
101
|
+
r[`size_${j}`],
|
|
102
|
+
r[`${I ? "slideOut" : "slideIn"}_${x}`],
|
|
103
|
+
y?.drawer,
|
|
104
|
+
T
|
|
105
|
+
),
|
|
106
|
+
style: C,
|
|
107
|
+
role: "dialog",
|
|
108
|
+
"aria-modal": b ? "true" : void 0,
|
|
109
|
+
"aria-label": h,
|
|
110
|
+
"aria-labelledby": h ? void 0 : k,
|
|
111
|
+
children: /* @__PURE__ */ l(u.Provider, { value: { classes: y ?? {}, titleId: k }, children: _ })
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
document.body
|
|
117
|
+
) : null;
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
m.displayName = "Drawer";
|
|
121
|
+
m.Header = D;
|
|
122
|
+
m.Body = R;
|
|
123
|
+
m.Footer = S;
|
|
124
|
+
export {
|
|
125
|
+
m as Drawer
|
|
126
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const r = "crk-backdrop-LBGhN", t = "crk-crk-drawer-fade-in-fnZXU", e = "crk-backdropClosing-0aeyJ", o = "crk-crk-drawer-fade-out-iDYoX", c = "crk-backdropBare-7fB4W", s = "crk-drawer-IKoOm", i = "crk-side_right-sYQoY", d = "crk-side_right-sYQoY", k = "crk-side_left-gAeYL", n = "crk-side_left-gAeYL", l = "crk-side_top-QFjZz", a = "crk-side_top-QFjZz", u = "crk-side_bottom-Y1t6g", _ = "crk-side_bottom-Y1t6g", w = "crk-slideIn_right-HORcg", g = "crk-slideIn_right-HORcg", f = "crk-crk-drawer-in-right-lit2r", p = "crk-slideOut_right-lbnQY", I = "crk-slideOut_right-lbnQY", O = "crk-crk-drawer-out-right-lrub3", m = "crk-slideIn_left-VvJeV", b = "crk-slideIn_left-VvJeV", h = "crk-crk-drawer-in-left-98vE7", z = "crk-slideOut_left-4pc01", D = "crk-slideOut_left-4pc01", L = "crk-crk-drawer-out-left-EI6P3", B = "crk-slideIn_top-ULcWL", T = "crk-slideIn_top-ULcWL", R = "crk-crk-drawer-in-top-8ZkO6", Y = "crk-slideOut_top-00Tue", F = "crk-slideOut_top-00Tue", C = "crk-crk-drawer-out-top-KDkv7", y = "crk-slideIn_bottom-uBTzu", E = "crk-slideIn_bottom-uBTzu", Q = "crk-crk-drawer-in-bottom-b9y67", j = "crk-slideOut_bottom-g6ELp", v = "crk-slideOut_bottom-g6ELp", S = "crk-crk-drawer-out-bottom-IShFs", X = "crk-size_sm-o8tw7", Z = "crk-size_sm-o8tw7", P = "crk-size_md-akgTC", U = "crk-size_md-akgTC", V = "crk-size_lg-Yjulz", W = "crk-size_lg-Yjulz", J = "crk-size_full-DIjPg", K = "crk-size_full-DIjPg", A = "crk-header--OScS", H = "crk-closeButton-WdXyR", M = "crk-body-CXRcE", x = "crk-footer-0kQ83", G = "crk-drawerClosing-9hrsd", N = {
|
|
2
|
+
backdrop: r,
|
|
3
|
+
"crk-drawer-fade-in": "crk-crk-drawer-fade-in-fnZXU",
|
|
4
|
+
crkDrawerFadeIn: t,
|
|
5
|
+
backdropClosing: e,
|
|
6
|
+
"crk-drawer-fade-out": "crk-crk-drawer-fade-out-iDYoX",
|
|
7
|
+
crkDrawerFadeOut: o,
|
|
8
|
+
backdropBare: c,
|
|
9
|
+
drawer: s,
|
|
10
|
+
side_right: i,
|
|
11
|
+
sideRight: d,
|
|
12
|
+
side_left: k,
|
|
13
|
+
sideLeft: n,
|
|
14
|
+
side_top: l,
|
|
15
|
+
sideTop: a,
|
|
16
|
+
side_bottom: u,
|
|
17
|
+
sideBottom: _,
|
|
18
|
+
slideIn_right: w,
|
|
19
|
+
slideInRight: g,
|
|
20
|
+
"crk-drawer-in-right": "crk-crk-drawer-in-right-lit2r",
|
|
21
|
+
crkDrawerInRight: f,
|
|
22
|
+
slideOut_right: p,
|
|
23
|
+
slideOutRight: I,
|
|
24
|
+
"crk-drawer-out-right": "crk-crk-drawer-out-right-lrub3",
|
|
25
|
+
crkDrawerOutRight: O,
|
|
26
|
+
slideIn_left: m,
|
|
27
|
+
slideInLeft: b,
|
|
28
|
+
"crk-drawer-in-left": "crk-crk-drawer-in-left-98vE7",
|
|
29
|
+
crkDrawerInLeft: h,
|
|
30
|
+
slideOut_left: z,
|
|
31
|
+
slideOutLeft: D,
|
|
32
|
+
"crk-drawer-out-left": "crk-crk-drawer-out-left-EI6P3",
|
|
33
|
+
crkDrawerOutLeft: L,
|
|
34
|
+
slideIn_top: B,
|
|
35
|
+
slideInTop: T,
|
|
36
|
+
"crk-drawer-in-top": "crk-crk-drawer-in-top-8ZkO6",
|
|
37
|
+
crkDrawerInTop: R,
|
|
38
|
+
slideOut_top: Y,
|
|
39
|
+
slideOutTop: F,
|
|
40
|
+
"crk-drawer-out-top": "crk-crk-drawer-out-top-KDkv7",
|
|
41
|
+
crkDrawerOutTop: C,
|
|
42
|
+
slideIn_bottom: y,
|
|
43
|
+
slideInBottom: E,
|
|
44
|
+
"crk-drawer-in-bottom": "crk-crk-drawer-in-bottom-b9y67",
|
|
45
|
+
crkDrawerInBottom: Q,
|
|
46
|
+
slideOut_bottom: j,
|
|
47
|
+
slideOutBottom: v,
|
|
48
|
+
"crk-drawer-out-bottom": "crk-crk-drawer-out-bottom-IShFs",
|
|
49
|
+
crkDrawerOutBottom: S,
|
|
50
|
+
size_sm: X,
|
|
51
|
+
sizeSm: Z,
|
|
52
|
+
size_md: P,
|
|
53
|
+
sizeMd: U,
|
|
54
|
+
size_lg: V,
|
|
55
|
+
sizeLg: W,
|
|
56
|
+
size_full: J,
|
|
57
|
+
sizeFull: K,
|
|
58
|
+
header: A,
|
|
59
|
+
closeButton: H,
|
|
60
|
+
body: M,
|
|
61
|
+
footer: x,
|
|
62
|
+
drawerClosing: G
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
r as backdrop,
|
|
66
|
+
c as backdropBare,
|
|
67
|
+
e as backdropClosing,
|
|
68
|
+
M as body,
|
|
69
|
+
H as closeButton,
|
|
70
|
+
t as crkDrawerFadeIn,
|
|
71
|
+
o as crkDrawerFadeOut,
|
|
72
|
+
Q as crkDrawerInBottom,
|
|
73
|
+
h as crkDrawerInLeft,
|
|
74
|
+
f as crkDrawerInRight,
|
|
75
|
+
R as crkDrawerInTop,
|
|
76
|
+
S as crkDrawerOutBottom,
|
|
77
|
+
L as crkDrawerOutLeft,
|
|
78
|
+
O as crkDrawerOutRight,
|
|
79
|
+
C as crkDrawerOutTop,
|
|
80
|
+
N as default,
|
|
81
|
+
s as drawer,
|
|
82
|
+
G as drawerClosing,
|
|
83
|
+
x as footer,
|
|
84
|
+
A as header,
|
|
85
|
+
_ as sideBottom,
|
|
86
|
+
n as sideLeft,
|
|
87
|
+
d as sideRight,
|
|
88
|
+
a as sideTop,
|
|
89
|
+
u as side_bottom,
|
|
90
|
+
k as side_left,
|
|
91
|
+
i as side_right,
|
|
92
|
+
l as side_top,
|
|
93
|
+
K as sizeFull,
|
|
94
|
+
W as sizeLg,
|
|
95
|
+
U as sizeMd,
|
|
96
|
+
Z as sizeSm,
|
|
97
|
+
J as size_full,
|
|
98
|
+
V as size_lg,
|
|
99
|
+
P as size_md,
|
|
100
|
+
X as size_sm,
|
|
101
|
+
E as slideInBottom,
|
|
102
|
+
b as slideInLeft,
|
|
103
|
+
g as slideInRight,
|
|
104
|
+
T as slideInTop,
|
|
105
|
+
y as slideIn_bottom,
|
|
106
|
+
m as slideIn_left,
|
|
107
|
+
w as slideIn_right,
|
|
108
|
+
B as slideIn_top,
|
|
109
|
+
v as slideOutBottom,
|
|
110
|
+
D as slideOutLeft,
|
|
111
|
+
I as slideOutRight,
|
|
112
|
+
F as slideOutTop,
|
|
113
|
+
j as slideOut_bottom,
|
|
114
|
+
z as slideOut_left,
|
|
115
|
+
p as slideOut_right,
|
|
116
|
+
Y as slideOut_top
|
|
117
|
+
};
|