@ktnpm_devops/react-component 0.0.1 → 0.1.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/README.md +16 -5
- package/dist/composites/ChartExpandModal/ChartExpandModal.d.ts +21 -0
- package/dist/composites/ChartExpandModal/ChartExpandModal.d.ts.map +1 -0
- package/dist/composites/ChartExpandModal/index.d.ts +3 -0
- package/dist/composites/ChartExpandModal/index.d.ts.map +1 -0
- package/dist/composites/ContextMenu/ContextMenu.d.ts +20 -0
- package/dist/composites/ContextMenu/ContextMenu.d.ts.map +1 -0
- package/dist/composites/ContextMenu/index.d.ts +3 -0
- package/dist/composites/ContextMenu/index.d.ts.map +1 -0
- package/dist/composites/CustomRangePicker/CustomRangePicker.d.ts +13 -0
- package/dist/composites/CustomRangePicker/CustomRangePicker.d.ts.map +1 -0
- package/dist/composites/CustomRangePicker/index.d.ts +3 -0
- package/dist/composites/CustomRangePicker/index.d.ts.map +1 -0
- package/dist/composites/MultiSelectDropdown/MultiSelectDropdown.d.ts +29 -0
- package/dist/composites/MultiSelectDropdown/MultiSelectDropdown.d.ts.map +1 -0
- package/dist/composites/MultiSelectDropdown/index.d.ts +3 -0
- package/dist/composites/MultiSelectDropdown/index.d.ts.map +1 -0
- package/dist/composites/ResizableSplitPanel/ResizableSplitPanel.d.ts +16 -0
- package/dist/composites/ResizableSplitPanel/ResizableSplitPanel.d.ts.map +1 -0
- package/dist/composites/ResizableSplitPanel/index.d.ts +3 -0
- package/dist/composites/ResizableSplitPanel/index.d.ts.map +1 -0
- package/dist/composites/SingleSelectDropdown/SingleSelectDropdown.d.ts +23 -0
- package/dist/composites/SingleSelectDropdown/SingleSelectDropdown.d.ts.map +1 -0
- package/dist/composites/SingleSelectDropdown/index.d.ts +3 -0
- package/dist/composites/SingleSelectDropdown/index.d.ts.map +1 -0
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index10.cjs +2 -2
- package/dist/index10.js +2 -2
- package/dist/index11.cjs +2 -2
- package/dist/index11.js +2 -2
- package/dist/index12.cjs +99 -7
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +101 -9
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +87 -35
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +87 -35
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +120 -7
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +122 -9
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +8 -6
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +8 -6
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +38 -8
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +39 -9
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +226 -16
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +225 -15
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +79 -18
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +78 -17
- package/dist/index18.js.map +1 -1
- package/dist/index19.cjs +10 -10
- package/dist/index19.cjs.map +1 -1
- package/dist/index19.js +9 -9
- package/dist/index19.js.map +1 -1
- package/dist/index20.cjs +144 -6
- package/dist/index20.cjs.map +1 -1
- package/dist/index20.js +143 -5
- package/dist/index20.js.map +1 -1
- package/dist/index21.cjs +8 -7
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +7 -6
- package/dist/index21.js.map +1 -1
- package/dist/index22.cjs +10 -28
- package/dist/index22.cjs.map +1 -1
- package/dist/index22.js +9 -27
- package/dist/index22.js.map +1 -1
- package/dist/index23.cjs +15 -6
- package/dist/index23.cjs.map +1 -1
- package/dist/index23.js +15 -6
- package/dist/index23.js.map +1 -1
- package/dist/index24.cjs +22 -10
- package/dist/index24.cjs.map +1 -1
- package/dist/index24.js +23 -11
- package/dist/index24.js.map +1 -1
- package/dist/index25.cjs +13 -19
- package/dist/index25.cjs.map +1 -1
- package/dist/index25.js +13 -19
- package/dist/index25.js.map +1 -1
- package/dist/index26.cjs +2 -11
- package/dist/index26.cjs.map +1 -1
- package/dist/index26.js +3 -12
- package/dist/index26.js.map +1 -1
- package/dist/index27.cjs +12 -0
- package/dist/index27.cjs.map +1 -0
- package/dist/index27.js +12 -0
- package/dist/index27.js.map +1 -0
- package/dist/index28.cjs +9 -0
- package/dist/index28.cjs.map +1 -0
- package/dist/index28.js +9 -0
- package/dist/index28.js.map +1 -0
- package/dist/index29.cjs +18 -0
- package/dist/index29.cjs.map +1 -0
- package/dist/index29.js +18 -0
- package/dist/index29.js.map +1 -0
- package/dist/index30.cjs +30 -0
- package/dist/index30.cjs.map +1 -0
- package/dist/index30.js +30 -0
- package/dist/index30.js.map +1 -0
- package/dist/index31.cjs +87 -0
- package/dist/index31.cjs.map +1 -0
- package/dist/index31.js +87 -0
- package/dist/index31.js.map +1 -0
- package/dist/index32.cjs +60 -0
- package/dist/index32.cjs.map +1 -0
- package/dist/index32.js +60 -0
- package/dist/index32.js.map +1 -0
- package/dist/index33.cjs +27 -0
- package/dist/index33.cjs.map +1 -0
- package/dist/index33.js +27 -0
- package/dist/index33.js.map +1 -0
- package/dist/index34.cjs +21 -0
- package/dist/index34.cjs.map +1 -0
- package/dist/index34.js +21 -0
- package/dist/index34.js.map +1 -0
- package/dist/index35.cjs +36 -0
- package/dist/index35.cjs.map +1 -0
- package/dist/index35.js +36 -0
- package/dist/index35.js.map +1 -0
- package/dist/index36.cjs +42 -0
- package/dist/index36.cjs.map +1 -0
- package/dist/index36.js +42 -0
- package/dist/index36.js.map +1 -0
- package/dist/index37.cjs +9 -0
- package/dist/index37.cjs.map +1 -0
- package/dist/index37.js +9 -0
- package/dist/index37.js.map +1 -0
- package/dist/index38.cjs +21 -0
- package/dist/index38.cjs.map +1 -0
- package/dist/index38.js +21 -0
- package/dist/index38.js.map +1 -0
- package/dist/index39.cjs +18 -0
- package/dist/index39.cjs.map +1 -0
- package/dist/index39.js +18 -0
- package/dist/index39.js.map +1 -0
- package/dist/index8.cjs +2 -2
- package/dist/index8.js +2 -2
- package/dist/index9.cjs +2 -2
- package/dist/index9.js +2 -2
- package/dist/style.css +755 -36
- package/dist/tokens/orbit-tokens.css +11 -11
- package/dist/tokens/semantic-tokens.css +53 -2
- package/package.json +19 -20
package/dist/index14.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index14.cjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index14.cjs","sources":["../src/composites/CustomRangePicker/CustomRangePicker.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, useCallback } from 'react';\nimport clsx from 'clsx';\nimport { useClickOutside } from '../../hooks/useClickOutside';\nimport { useEscapeKey } from '../../hooks/useEscapeKey';\nimport { formatLocalISOString } from '../../utils/format';\nimport styles from './CustomRangePicker.module.css';\n\nexport interface CustomRangePickerProps {\n /** Start of the current range (ISO string). */\n from?: string;\n /** End of the current range (ISO string). */\n to?: string;\n /** Called when user applies a valid range. */\n onApply: (range: { from: string; to: string }) => void;\n}\n\nconst formatInputValue = (iso?: string): string => {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n const y = date.getFullYear();\n const m = `${date.getMonth() + 1}`.padStart(2, '0');\n const d = `${date.getDate()}`.padStart(2, '0');\n const h = `${date.getHours()}`.padStart(2, '0');\n const min = `${date.getMinutes()}`.padStart(2, '0');\n return `${y}-${m}-${d}T${h}:${min}`;\n};\n\nconst toLocalTimestamp = (value: string): string | null => {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return formatLocalISOString(date);\n};\n\nexport const CustomRangePicker = ({ from, to, onApply }: CustomRangePickerProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [startValue, setStartValue] = useState(() => formatInputValue(from));\n const [endValue, setEndValue] = useState(() => formatInputValue(to));\n const [error, setError] = useState<string | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const isActive = Boolean(from && to);\n\n const close = useCallback(() => setIsOpen(false), []);\n useClickOutside(containerRef, close);\n useEscapeKey(close, isOpen);\n\n useEffect(() => {\n if (!isOpen) return;\n setStartValue(formatInputValue(from));\n setEndValue(formatInputValue(to));\n setError(null);\n }, [from, to, isOpen]);\n\n const summary = useMemo(() => {\n if (!from || !to) return null;\n const s = new Date(from);\n const e = new Date(to);\n if (Number.isNaN(s.getTime()) || Number.isNaN(e.getTime())) return null;\n const fmt = new Intl.DateTimeFormat(undefined, {\n year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit',\n });\n return `${fmt.format(s)} – ${fmt.format(e)}`;\n }, [from, to]);\n\n const handleApply = () => {\n const startIso = toLocalTimestamp(startValue);\n const endIso = toLocalTimestamp(endValue);\n if (!startIso || !endIso) {\n setError('Both start and end date are required.');\n return;\n }\n if (startIso >= endIso) {\n setError('End of range must be after the start.');\n return;\n }\n onApply({ from: startIso, to: endIso });\n setIsOpen(false);\n };\n\n const handleCancel = () => {\n setStartValue(formatInputValue(from));\n setEndValue(formatInputValue(to));\n setError(null);\n setIsOpen(false);\n };\n\n return (\n <div className={styles.root} ref={containerRef}>\n <button\n type=\"button\"\n className={clsx(styles.chip, { [styles.active]: isActive })}\n onClick={() => setIsOpen((v) => !v)}\n >\n Custom\n </button>\n {summary && <span className={styles.summary}>{summary}</span>}\n\n {isOpen && (\n <div className={styles.popover} role=\"dialog\" aria-modal=\"false\">\n <header className={styles.popoverHeader}>\n <h4>Custom Time Range</h4>\n </header>\n <div className={styles.fields}>\n <label className={styles.field}>\n <span>Start</span>\n <input\n type=\"datetime-local\"\n value={startValue}\n onChange={(e) => setStartValue(e.target.value)}\n max={endValue || undefined}\n />\n </label>\n <label className={styles.field}>\n <span>End</span>\n <input\n type=\"datetime-local\"\n value={endValue}\n onChange={(e) => setEndValue(e.target.value)}\n min={startValue || undefined}\n />\n </label>\n </div>\n {error && <p className={styles.error}>{error}</p>}\n <footer className={styles.actions}>\n <button type=\"button\" className={styles.btnGhost} onClick={handleCancel}>\n Cancel\n </button>\n <button type=\"button\" className={styles.btnPrimary} onClick={handleApply}>\n Apply\n </button>\n </footer>\n </div>\n )}\n </div>\n );\n};\n"],"names":["formatLocalISOString","useState","useRef","useCallback","useClickOutside","useEscapeKey","useEffect","useMemo","styles","jsx","clsx","jsxs"],"mappings":";;;;;;;;;AAgBA,MAAM,mBAAmB,CAAC,QAAyB;AACjD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IAAI,KAAK,GAAG;AACzB,MAAI,OAAO,MAAM,KAAK,QAAA,CAAS,EAAG,QAAO;AACzC,QAAM,IAAI,KAAK,YAAA;AACf,QAAM,IAAI,GAAG,KAAK,SAAA,IAAa,CAAC,GAAG,SAAS,GAAG,GAAG;AAClD,QAAM,IAAI,GAAG,KAAK,QAAA,CAAS,GAAG,SAAS,GAAG,GAAG;AAC7C,QAAM,IAAI,GAAG,KAAK,SAAA,CAAU,GAAG,SAAS,GAAG,GAAG;AAC9C,QAAM,MAAM,GAAG,KAAK,WAAA,CAAY,GAAG,SAAS,GAAG,GAAG;AAClD,SAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG;AACnC;AAEA,MAAM,mBAAmB,CAAC,UAAiC;AACzD,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,OAAO,MAAM,KAAK,QAAA,CAAS,EAAG,QAAO;AACzC,SAAOA,OAAAA,qBAAqB,IAAI;AAClC;AAEO,MAAM,oBAAoB,CAAC,EAAE,MAAM,IAAI,cAAsC;AAClF,QAAM,CAAC,QAAQ,SAAS,IAAIC,MAAAA,SAAS,KAAK;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI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AO,KAAK;AAAA,cAC7C,KAAK,YAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACnB,GACF;AAAA,QACAE,2BAAAA,KAAC,SAAA,EAAM,WAAWH,yBAAAA,QAAO,OACvB,UAAA;AAAA,UAAAC,2BAAAA,IAAC,UAAK,UAAA,MAAA,CAAG;AAAA,UACTA,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,OAAO;AAAA,cACP,UAAU,CAAC,MAAM,YAAY,EAAE,OAAO,KAAK;AAAA,cAC3C,KAAK,cAAc;AAAA,YAAA;AAAA,UAAA;AAAA,QACrB,EAAA,CACF;AAAA,MAAA,GACF;AAAA,MACC,SAASA,2BAAAA,IAAC,KAAA,EAAE,WAAWD,yBAAAA,QAAO,OAAQ,UAAA,OAAM;AAAA,MAC7CG,2BAAAA,KAAC,UAAA,EAAO,WAAWH,yBAAAA,QAAO,SACxB,UAAA;AAAA,QAAAC,2BAAAA,IAAC,UAAA,EAAO,MAAK,UAAS,WAAWD,iCAAO,UAAU,SAAS,cAAc,UAAA,SAAA,CAEzE;AAAA,QACAC,2BAAAA,IAAC,YAAO,MAAK,UAAS,WAAWD,iCAAO,YAAY,SAAS,aAAa,UAAA,QAAA,CAE1E;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;;"}
|
package/dist/index14.js
CHANGED
|
@@ -1,12 +1,125 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { clsx } from "./
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { clsx } from "./index23.js";
|
|
4
|
+
import { useClickOutside } from "./index3.js";
|
|
5
|
+
import { useEscapeKey } from "./index4.js";
|
|
6
|
+
import { formatLocalISOString } from "./index6.js";
|
|
7
|
+
import styles from "./index36.js";
|
|
8
|
+
const formatInputValue = (iso) => {
|
|
9
|
+
if (!iso) return "";
|
|
10
|
+
const date = new Date(iso);
|
|
11
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
12
|
+
const y = date.getFullYear();
|
|
13
|
+
const m = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
14
|
+
const d = `${date.getDate()}`.padStart(2, "0");
|
|
15
|
+
const h = `${date.getHours()}`.padStart(2, "0");
|
|
16
|
+
const min = `${date.getMinutes()}`.padStart(2, "0");
|
|
17
|
+
return `${y}-${m}-${d}T${h}:${min}`;
|
|
18
|
+
};
|
|
19
|
+
const toLocalTimestamp = (value) => {
|
|
20
|
+
if (!value) return null;
|
|
21
|
+
const date = new Date(value);
|
|
22
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
23
|
+
return formatLocalISOString(date);
|
|
24
|
+
};
|
|
25
|
+
const CustomRangePicker = ({ from, to, onApply }) => {
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
const [startValue, setStartValue] = useState(() => formatInputValue(from));
|
|
28
|
+
const [endValue, setEndValue] = useState(() => formatInputValue(to));
|
|
29
|
+
const [error, setError] = useState(null);
|
|
30
|
+
const containerRef = useRef(null);
|
|
31
|
+
const isActive = Boolean(from && to);
|
|
32
|
+
const close = useCallback(() => setIsOpen(false), []);
|
|
33
|
+
useClickOutside(containerRef, close);
|
|
34
|
+
useEscapeKey(close, isOpen);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!isOpen) return;
|
|
37
|
+
setStartValue(formatInputValue(from));
|
|
38
|
+
setEndValue(formatInputValue(to));
|
|
39
|
+
setError(null);
|
|
40
|
+
}, [from, to, isOpen]);
|
|
41
|
+
const summary = useMemo(() => {
|
|
42
|
+
if (!from || !to) return null;
|
|
43
|
+
const s = new Date(from);
|
|
44
|
+
const e = new Date(to);
|
|
45
|
+
if (Number.isNaN(s.getTime()) || Number.isNaN(e.getTime())) return null;
|
|
46
|
+
const fmt = new Intl.DateTimeFormat(void 0, {
|
|
47
|
+
year: "numeric",
|
|
48
|
+
month: "short",
|
|
49
|
+
day: "numeric",
|
|
50
|
+
hour: "2-digit",
|
|
51
|
+
minute: "2-digit"
|
|
52
|
+
});
|
|
53
|
+
return `${fmt.format(s)} – ${fmt.format(e)}`;
|
|
54
|
+
}, [from, to]);
|
|
55
|
+
const handleApply = () => {
|
|
56
|
+
const startIso = toLocalTimestamp(startValue);
|
|
57
|
+
const endIso = toLocalTimestamp(endValue);
|
|
58
|
+
if (!startIso || !endIso) {
|
|
59
|
+
setError("Both start and end date are required.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (startIso >= endIso) {
|
|
63
|
+
setError("End of range must be after the start.");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
onApply({ from: startIso, to: endIso });
|
|
67
|
+
setIsOpen(false);
|
|
68
|
+
};
|
|
69
|
+
const handleCancel = () => {
|
|
70
|
+
setStartValue(formatInputValue(from));
|
|
71
|
+
setEndValue(formatInputValue(to));
|
|
72
|
+
setError(null);
|
|
73
|
+
setIsOpen(false);
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.root, ref: containerRef, children: [
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
type: "button",
|
|
80
|
+
className: clsx(styles.chip, { [styles.active]: isActive }),
|
|
81
|
+
onClick: () => setIsOpen((v) => !v),
|
|
82
|
+
children: "Custom"
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
summary && /* @__PURE__ */ jsx("span", { className: styles.summary, children: summary }),
|
|
86
|
+
isOpen && /* @__PURE__ */ jsxs("div", { className: styles.popover, role: "dialog", "aria-modal": "false", children: [
|
|
87
|
+
/* @__PURE__ */ jsx("header", { className: styles.popoverHeader, children: /* @__PURE__ */ jsx("h4", { children: "Custom Time Range" }) }),
|
|
88
|
+
/* @__PURE__ */ jsxs("div", { className: styles.fields, children: [
|
|
89
|
+
/* @__PURE__ */ jsxs("label", { className: styles.field, children: [
|
|
90
|
+
/* @__PURE__ */ jsx("span", { children: "Start" }),
|
|
91
|
+
/* @__PURE__ */ jsx(
|
|
92
|
+
"input",
|
|
93
|
+
{
|
|
94
|
+
type: "datetime-local",
|
|
95
|
+
value: startValue,
|
|
96
|
+
onChange: (e) => setStartValue(e.target.value),
|
|
97
|
+
max: endValue || void 0
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
] }),
|
|
101
|
+
/* @__PURE__ */ jsxs("label", { className: styles.field, children: [
|
|
102
|
+
/* @__PURE__ */ jsx("span", { children: "End" }),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
"input",
|
|
105
|
+
{
|
|
106
|
+
type: "datetime-local",
|
|
107
|
+
value: endValue,
|
|
108
|
+
onChange: (e) => setEndValue(e.target.value),
|
|
109
|
+
min: startValue || void 0
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] })
|
|
113
|
+
] }),
|
|
114
|
+
error && /* @__PURE__ */ jsx("p", { className: styles.error, children: error }),
|
|
115
|
+
/* @__PURE__ */ jsxs("footer", { className: styles.actions, children: [
|
|
116
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: styles.btnGhost, onClick: handleCancel, children: "Cancel" }),
|
|
117
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: styles.btnPrimary, onClick: handleApply, children: "Apply" })
|
|
118
|
+
] })
|
|
119
|
+
] })
|
|
120
|
+
] });
|
|
121
|
+
};
|
|
9
122
|
export {
|
|
10
|
-
|
|
123
|
+
CustomRangePicker
|
|
11
124
|
};
|
|
12
125
|
//# sourceMappingURL=index14.js.map
|
package/dist/index14.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index14.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index14.js","sources":["../src/composites/CustomRangePicker/CustomRangePicker.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState, useCallback } from 'react';\nimport clsx from 'clsx';\nimport { useClickOutside } from '../../hooks/useClickOutside';\nimport { useEscapeKey } from '../../hooks/useEscapeKey';\nimport { formatLocalISOString } from '../../utils/format';\nimport styles from './CustomRangePicker.module.css';\n\nexport interface CustomRangePickerProps {\n /** Start of the current range (ISO string). */\n from?: string;\n /** End of the current range (ISO string). */\n to?: string;\n /** Called when user applies a valid range. */\n onApply: (range: { from: string; to: string }) => void;\n}\n\nconst formatInputValue = (iso?: string): string => {\n if (!iso) return '';\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return '';\n const y = date.getFullYear();\n const m = `${date.getMonth() + 1}`.padStart(2, '0');\n const d = `${date.getDate()}`.padStart(2, '0');\n const h = `${date.getHours()}`.padStart(2, '0');\n const min = `${date.getMinutes()}`.padStart(2, '0');\n return `${y}-${m}-${d}T${h}:${min}`;\n};\n\nconst toLocalTimestamp = (value: string): string | null => {\n if (!value) return null;\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n return formatLocalISOString(date);\n};\n\nexport const CustomRangePicker = ({ from, to, onApply }: CustomRangePickerProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [startValue, setStartValue] = useState(() => formatInputValue(from));\n const [endValue, setEndValue] = useState(() => formatInputValue(to));\n const [error, setError] = useState<string | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n const isActive = Boolean(from && to);\n\n const close = useCallback(() => setIsOpen(false), []);\n useClickOutside(containerRef, close);\n useEscapeKey(close, isOpen);\n\n useEffect(() => {\n if (!isOpen) return;\n setStartValue(formatInputValue(from));\n setEndValue(formatInputValue(to));\n setError(null);\n }, [from, to, isOpen]);\n\n const summary = useMemo(() => {\n if (!from || !to) return null;\n const s = new Date(from);\n const e = new Date(to);\n if (Number.isNaN(s.getTime()) || Number.isNaN(e.getTime())) return null;\n const fmt = new Intl.DateTimeFormat(undefined, {\n year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit',\n });\n return `${fmt.format(s)} – ${fmt.format(e)}`;\n }, [from, to]);\n\n const handleApply = () => {\n const startIso = toLocalTimestamp(startValue);\n const endIso = toLocalTimestamp(endValue);\n if (!startIso || !endIso) {\n setError('Both start and end date are required.');\n return;\n }\n if (startIso >= endIso) {\n setError('End of range must be after the start.');\n return;\n }\n onApply({ from: startIso, to: endIso });\n setIsOpen(false);\n };\n\n const handleCancel = () => {\n setStartValue(formatInputValue(from));\n setEndValue(formatInputValue(to));\n setError(null);\n setIsOpen(false);\n };\n\n return (\n <div className={styles.root} ref={containerRef}>\n <button\n type=\"button\"\n className={clsx(styles.chip, { [styles.active]: isActive })}\n onClick={() => setIsOpen((v) => !v)}\n >\n Custom\n </button>\n {summary && <span className={styles.summary}>{summary}</span>}\n\n {isOpen && (\n <div className={styles.popover} role=\"dialog\" aria-modal=\"false\">\n <header className={styles.popoverHeader}>\n <h4>Custom Time Range</h4>\n </header>\n <div className={styles.fields}>\n <label className={styles.field}>\n <span>Start</span>\n <input\n type=\"datetime-local\"\n value={startValue}\n onChange={(e) => setStartValue(e.target.value)}\n max={endValue || undefined}\n />\n </label>\n <label className={styles.field}>\n <span>End</span>\n <input\n type=\"datetime-local\"\n value={endValue}\n onChange={(e) => setEndValue(e.target.value)}\n min={startValue || undefined}\n />\n </label>\n </div>\n {error && <p className={styles.error}>{error}</p>}\n <footer className={styles.actions}>\n <button type=\"button\" className={styles.btnGhost} onClick={handleCancel}>\n Cancel\n </button>\n <button type=\"button\" className={styles.btnPrimary} onClick={handleApply}>\n Apply\n </button>\n </footer>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAgBA,MAAM,mBAAmB,CAAC,QAAyB;AACjD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IAAI,KAAK,GAAG;AACzB,MAAI,OAAO,MAAM,KAAK,QAAA,CAAS,EAAG,QAAO;AACzC,QAAM,IA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dist/index15.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const clsx = require("./index23.cjs");
|
|
6
|
+
const Input_module = require("./index37.cjs");
|
|
7
|
+
const Input = react.forwardRef(
|
|
8
|
+
({ className, type = "text", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("input", { ref, type, className: clsx.clsx(Input_module.default.root, className), ...props })
|
|
9
|
+
);
|
|
10
|
+
Input.displayName = "Input";
|
|
11
|
+
exports.Input = Input;
|
|
10
12
|
//# sourceMappingURL=index15.cjs.map
|
package/dist/index15.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index15.cjs","sources":["../src/primitives/
|
|
1
|
+
{"version":3,"file":"index15.cjs","sources":["../src/primitives/Input/Input.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './Input.module.css';\n\nexport interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n ({ className, type = 'text', ...props }, ref) => (\n <input ref={ref} type={type} className={clsx(styles.root, className)} {...props} />\n ),\n);\n\nInput.displayName = 'Input';\n"],"names":["forwardRef","jsx","clsx","styles"],"mappings":";;;;;;AAMO,MAAM,QAAQA,MAAAA;AAAAA,EACnB,CAAC,EAAE,WAAW,OAAO,QAAQ,GAAG,SAAS,QACvCC,2BAAAA,IAAC,WAAM,KAAU,MAAY,WAAWC,UAAKC,aAAAA,QAAO,MAAM,SAAS,GAAI,GAAG,MAAA,CAAO;AAErF;AAEA,MAAM,cAAc;;"}
|
package/dist/index15.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { clsx } from "./index23.js";
|
|
4
|
+
import styles from "./index37.js";
|
|
5
|
+
const Input = forwardRef(
|
|
6
|
+
({ className, type = "text", ...props }, ref) => /* @__PURE__ */ jsx("input", { ref, type, className: clsx(styles.root, className), ...props })
|
|
7
|
+
);
|
|
8
|
+
Input.displayName = "Input";
|
|
6
9
|
export {
|
|
7
|
-
|
|
8
|
-
TableContainer
|
|
10
|
+
Input
|
|
9
11
|
};
|
|
10
12
|
//# sourceMappingURL=index15.js.map
|
package/dist/index15.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index15.js","sources":["../src/primitives/
|
|
1
|
+
{"version":3,"file":"index15.js","sources":["../src/primitives/Input/Input.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './Input.module.css';\n\nexport interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n ({ className, type = 'text', ...props }, ref) => (\n <input ref={ref} type={type} className={clsx(styles.root, className)} {...props} />\n ),\n);\n\nInput.displayName = 'Input';\n"],"names":[],"mappings":";;;;AAMO,MAAM,QAAQ;AAAA,EACnB,CAAC,EAAE,WAAW,OAAO,QAAQ,GAAG,SAAS,QACvC,oBAAC,WAAM,KAAU,MAAY,WAAW,KAAK,OAAO,MAAM,SAAS,GAAI,GAAG,MAAA,CAAO;AAErF;AAEA,MAAM,cAAc;"}
|
package/dist/index16.cjs
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const clsx = require("./
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const reactDom = require("react-dom");
|
|
5
|
+
const clsx = require("./index23.cjs");
|
|
6
|
+
const useEscapeKey = require("./index4.cjs");
|
|
7
|
+
const Modal_module = require("./index33.cjs");
|
|
8
|
+
const Modal = ({
|
|
9
|
+
open,
|
|
10
|
+
title,
|
|
11
|
+
onClose,
|
|
12
|
+
children,
|
|
13
|
+
footer,
|
|
14
|
+
portalTarget,
|
|
15
|
+
className,
|
|
16
|
+
bodyClassName,
|
|
17
|
+
style,
|
|
18
|
+
closeLabel = "×"
|
|
19
|
+
}) => {
|
|
20
|
+
useEscapeKey.useEscapeKey(onClose, open);
|
|
21
|
+
if (!open) return null;
|
|
22
|
+
const modalContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module.default.overlay, role: "dialog", "aria-modal": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx.clsx(Modal_module.default.root, className), style, children: [
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: Modal_module.default.header, children: [
|
|
24
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx("h2", { className: Modal_module.default.title, children: title }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26
|
+
"button",
|
|
27
|
+
{
|
|
28
|
+
type: "button",
|
|
29
|
+
onClick: onClose,
|
|
30
|
+
className: Modal_module.default.closeBtn,
|
|
31
|
+
"aria-label": "Close modal",
|
|
32
|
+
children: closeLabel
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
] }),
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx.clsx(Modal_module.default.body, bodyClassName), children }),
|
|
37
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module.default.footer, children: footer })
|
|
38
|
+
] }) });
|
|
39
|
+
return reactDom.createPortal(modalContent, portalTarget ?? document.body);
|
|
40
|
+
};
|
|
41
|
+
exports.Modal = Modal;
|
|
12
42
|
//# sourceMappingURL=index16.cjs.map
|
package/dist/index16.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index16.cjs","sources":["../src/primitives/
|
|
1
|
+
{"version":3,"file":"index16.cjs","sources":["../src/primitives/Modal/Modal.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\nimport { useEscapeKey } from '../../hooks/useEscapeKey';\nimport styles from './Modal.module.css';\n\nexport interface ModalProps {\n open: boolean;\n title?: ReactNode;\n onClose: () => void;\n children: ReactNode;\n footer?: ReactNode;\n portalTarget?: HTMLElement;\n className?: string;\n bodyClassName?: string;\n style?: CSSProperties;\n closeLabel?: ReactNode;\n}\n\nexport const Modal = ({\n open,\n title,\n onClose,\n children,\n footer,\n portalTarget,\n className,\n bodyClassName,\n style,\n closeLabel = '\\u00D7',\n}: ModalProps) => {\n useEscapeKey(onClose, open);\n\n if (!open) return null;\n\n const modalContent = (\n <div className={styles.overlay} role=\"dialog\" aria-modal=\"true\">\n <div className={clsx(styles.root, className)} style={style}>\n <div className={styles.header}>\n {title ? <h2 className={styles.title}>{title}</h2> : <span />}\n <button\n type=\"button\"\n onClick={onClose}\n className={styles.closeBtn}\n aria-label=\"Close modal\"\n >\n {closeLabel}\n </button>\n </div>\n <div className={clsx(styles.body, bodyClassName)}>{children}</div>\n {footer && <div className={styles.footer}>{footer}</div>}\n </div>\n </div>\n );\n\n return createPortal(modalContent, portalTarget ?? document.body);\n};\n"],"names":["useEscapeKey","jsx","styles","jsxs","clsx","createPortal"],"mappings":";;;;;;;AAmBO,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,MAAkB;AAChBA,eAAAA,aAAa,SAAS,IAAI;AAE1B,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,eACJC,+BAAC,OAAA,EAAI,WAAWC,aAAAA,QAAO,SAAS,MAAK,UAAS,cAAW,QACvD,UAAAC,gCAAC,SAAI,WAAWC,KAAAA,KAAKF,qBAAO,MAAM,SAAS,GAAG,OAC5C,UAAA;AAAA,IAAAC,2BAAAA,KAAC,OAAA,EAAI,WAAWD,aAAAA,QAAO,QACpB,UAAA;AAAA,MAAA,QAAQD,2BAAAA,IAAC,QAAG,WAAWC,aAAAA,QAAO,OAAQ,UAAA,MAAA,CAAM,mCAAS,QAAA,CAAA,CAAK;AAAA,MAC3DD,2BAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS;AAAA,UACT,WAAWC,aAAAA,QAAO;AAAA,UAClB,cAAW;AAAA,UAEV,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,IACAD,+BAAC,SAAI,WAAWG,KAAAA,KAAKF,aAAAA,QAAO,MAAM,aAAa,GAAI,UAAS;AAAA,IAC3D,UAAUD,2BAAAA,IAAC,OAAA,EAAI,WAAWC,aAAAA,QAAO,QAAS,UAAA,OAAA,CAAO;AAAA,EAAA,EAAA,CACpD,EAAA,CACF;AAGF,SAAOG,SAAAA,aAAa,cAAc,gBAAgB,SAAS,IAAI;AACjE;;"}
|
package/dist/index16.js
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { clsx } from "./
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { clsx } from "./index23.js";
|
|
4
|
+
import { useEscapeKey } from "./index4.js";
|
|
5
|
+
import styles from "./index33.js";
|
|
6
|
+
const Modal = ({
|
|
7
|
+
open,
|
|
8
|
+
title,
|
|
9
|
+
onClose,
|
|
10
|
+
children,
|
|
11
|
+
footer,
|
|
12
|
+
portalTarget,
|
|
13
|
+
className,
|
|
14
|
+
bodyClassName,
|
|
15
|
+
style,
|
|
16
|
+
closeLabel = "×"
|
|
17
|
+
}) => {
|
|
18
|
+
useEscapeKey(onClose, open);
|
|
19
|
+
if (!open) return null;
|
|
20
|
+
const modalContent = /* @__PURE__ */ jsx("div", { className: styles.overlay, role: "dialog", "aria-modal": "true", children: /* @__PURE__ */ jsxs("div", { className: clsx(styles.root, className), style, children: [
|
|
21
|
+
/* @__PURE__ */ jsxs("div", { className: styles.header, children: [
|
|
22
|
+
title ? /* @__PURE__ */ jsx("h2", { className: styles.title, children: title }) : /* @__PURE__ */ jsx("span", {}),
|
|
23
|
+
/* @__PURE__ */ jsx(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
onClick: onClose,
|
|
28
|
+
className: styles.closeBtn,
|
|
29
|
+
"aria-label": "Close modal",
|
|
30
|
+
children: closeLabel
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: clsx(styles.body, bodyClassName), children }),
|
|
35
|
+
footer && /* @__PURE__ */ jsx("div", { className: styles.footer, children: footer })
|
|
36
|
+
] }) });
|
|
37
|
+
return createPortal(modalContent, portalTarget ?? document.body);
|
|
38
|
+
};
|
|
9
39
|
export {
|
|
10
|
-
|
|
40
|
+
Modal
|
|
11
41
|
};
|
|
12
42
|
//# sourceMappingURL=index16.js.map
|
package/dist/index16.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index16.js","sources":["../src/primitives/
|
|
1
|
+
{"version":3,"file":"index16.js","sources":["../src/primitives/Modal/Modal.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\nimport { useEscapeKey } from '../../hooks/useEscapeKey';\nimport styles from './Modal.module.css';\n\nexport interface ModalProps {\n open: boolean;\n title?: ReactNode;\n onClose: () => void;\n children: ReactNode;\n footer?: ReactNode;\n portalTarget?: HTMLElement;\n className?: string;\n bodyClassName?: string;\n style?: CSSProperties;\n closeLabel?: ReactNode;\n}\n\nexport const Modal = ({\n open,\n title,\n onClose,\n children,\n footer,\n portalTarget,\n className,\n bodyClassName,\n style,\n closeLabel = '\\u00D7',\n}: ModalProps) => {\n useEscapeKey(onClose, open);\n\n if (!open) return null;\n\n const modalContent = (\n <div className={styles.overlay} role=\"dialog\" aria-modal=\"true\">\n <div className={clsx(styles.root, className)} style={style}>\n <div className={styles.header}>\n {title ? <h2 className={styles.title}>{title}</h2> : <span />}\n <button\n type=\"button\"\n onClick={onClose}\n className={styles.closeBtn}\n aria-label=\"Close modal\"\n >\n {closeLabel}\n </button>\n </div>\n <div className={clsx(styles.body, bodyClassName)}>{children}</div>\n {footer && <div className={styles.footer}>{footer}</div>}\n </div>\n </div>\n );\n\n return createPortal(modalContent, portalTarget ?? document.body);\n};\n"],"names":[],"mappings":";;;;;AAmBO,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AACf,MAAkB;AAChB,eAAa,SAAS,IAAI;AAE1B,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,eACJ,oBAAC,OAAA,EAAI,WAAW,OAAO,SAAS,MAAK,UAAS,cAAW,QACvD,UAAA,qBAAC,SAAI,WAAW,KAAK,OAAO,MAAM,SAAS,GAAG,OAC5C,UAAA;AAAA,IAAA,qBAAC,OAAA,EAAI,WAAW,OAAO,QACpB,UAAA;AAAA,MAAA,QAAQ,oBAAC,QAAG,WAAW,OAAO,OAAQ,UAAA,MAAA,CAAM,wBAAS,QAAA,CAAA,CAAK;AAAA,MAC3D;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS;AAAA,UACT,WAAW,OAAO;AAAA,UAClB,cAAW;AAAA,UAEV,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACH,GACF;AAAA,IACA,oBAAC,SAAI,WAAW,KAAK,OAAO,MAAM,aAAa,GAAI,UAAS;AAAA,IAC3D,UAAU,oBAAC,OAAA,EAAI,WAAW,OAAO,QAAS,UAAA,OAAA,CAAO;AAAA,EAAA,EAAA,CACpD,EAAA,CACF;AAGF,SAAO,aAAa,cAAc,gBAAgB,SAAS,IAAI;AACjE;"}
|
package/dist/index17.cjs
CHANGED
|
@@ -1,18 +1,228 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const clsx = require("./index23.cjs");
|
|
6
|
+
const useClickOutside = require("./index3.cjs");
|
|
7
|
+
const constants = require("./index30.cjs");
|
|
8
|
+
const MultiSelectDropdown_module = require("./index31.cjs");
|
|
9
|
+
const arraysMatch = (a, b) => {
|
|
10
|
+
if (a.length !== b.length) return false;
|
|
11
|
+
const set = new Set(b);
|
|
12
|
+
return a.every((v) => set.has(v));
|
|
13
|
+
};
|
|
14
|
+
const MultiSelectDropdown = ({
|
|
15
|
+
label,
|
|
16
|
+
options,
|
|
17
|
+
selected,
|
|
18
|
+
onApply,
|
|
19
|
+
isLoading = false,
|
|
20
|
+
error = null,
|
|
21
|
+
allowCustomValues = false,
|
|
22
|
+
customTriggerLabel,
|
|
23
|
+
selectionMode
|
|
24
|
+
}) => {
|
|
25
|
+
const [isOpen, setIsOpen] = react.useState(false);
|
|
26
|
+
const [searchTerm, setSearchTerm] = react.useState("");
|
|
27
|
+
const containerRef = react.useRef(null);
|
|
28
|
+
const normalizedOptions = react.useMemo(() => {
|
|
29
|
+
const map = /* @__PURE__ */ new Map();
|
|
30
|
+
options.forEach((opt) => map.set(opt.value, opt));
|
|
31
|
+
if (Array.isArray(selected)) {
|
|
32
|
+
selected.forEach((v) => {
|
|
33
|
+
if (v && !map.has(v)) map.set(v, { value: v });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return Array.from(map.values());
|
|
37
|
+
}, [options, selected]);
|
|
38
|
+
const filteredOptions = react.useMemo(() => {
|
|
39
|
+
if (!searchTerm.trim()) return normalizedOptions;
|
|
40
|
+
const term = searchTerm.trim().toLowerCase();
|
|
41
|
+
return normalizedOptions.filter((opt) => {
|
|
42
|
+
const lbl = opt.label ?? opt.value;
|
|
43
|
+
return lbl.toLowerCase().includes(term) || opt.value.toLowerCase().includes(term);
|
|
44
|
+
});
|
|
45
|
+
}, [normalizedOptions, searchTerm]);
|
|
46
|
+
const allOptionValues = react.useMemo(() => normalizedOptions.map((o) => o.value), [normalizedOptions]);
|
|
47
|
+
const initialSelection = react.useMemo(
|
|
48
|
+
() => Array.isArray(selected) && selected.length ? Array.from(new Set(selected)) : allOptionValues,
|
|
49
|
+
[selected, allOptionValues]
|
|
50
|
+
);
|
|
51
|
+
const [pendingSelection, setPendingSelection] = react.useState(initialSelection);
|
|
52
|
+
const closeAndReset = react.useCallback(() => {
|
|
53
|
+
setIsOpen(false);
|
|
54
|
+
setPendingSelection(initialSelection);
|
|
55
|
+
setSearchTerm("");
|
|
56
|
+
}, [initialSelection]);
|
|
57
|
+
useClickOutside.useClickOutside(containerRef, closeAndReset);
|
|
58
|
+
react.useEffect(() => {
|
|
59
|
+
if (isOpen) {
|
|
60
|
+
setPendingSelection(initialSelection);
|
|
61
|
+
setSearchTerm("");
|
|
62
|
+
}
|
|
63
|
+
}, [isOpen, initialSelection]);
|
|
64
|
+
react.useEffect(() => {
|
|
65
|
+
if (!isOpen) setPendingSelection(initialSelection);
|
|
66
|
+
}, [initialSelection, isOpen]);
|
|
67
|
+
const handleToggleOption = (value) => {
|
|
68
|
+
setPendingSelection((prev) => {
|
|
69
|
+
const unique = Array.from(new Set(prev));
|
|
70
|
+
return unique.includes(value) ? unique.filter((v) => v !== value) : [...unique, value];
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const handleSelectAll = () => {
|
|
74
|
+
if (filteredOptions.length === 0) {
|
|
75
|
+
setPendingSelection([]);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
setPendingSelection(filteredOptions.map((o) => o.value));
|
|
79
|
+
};
|
|
80
|
+
const handleClearAll = () => setPendingSelection([]);
|
|
81
|
+
const handleApply = () => {
|
|
82
|
+
const unique = Array.from(new Set(pendingSelection));
|
|
83
|
+
const mode = unique.length === 0 || unique.length === normalizedOptions.length ? "all" : "custom";
|
|
84
|
+
onApply(unique, { selectionMode: mode });
|
|
85
|
+
setIsOpen(false);
|
|
86
|
+
};
|
|
87
|
+
const handleCancel = () => {
|
|
88
|
+
setPendingSelection(Array.from(new Set(Array.isArray(selected) ? selected : [])));
|
|
89
|
+
setIsOpen(false);
|
|
90
|
+
};
|
|
91
|
+
const pendingSet = react.useMemo(() => new Set(pendingSelection), [pendingSelection]);
|
|
92
|
+
const selectedSet = react.useMemo(() => new Set(Array.isArray(selected) ? selected : []), [selected]);
|
|
93
|
+
const hasChanges = !arraysMatch(Array.from(pendingSet), Array.from(selectedSet));
|
|
94
|
+
const totalOptions = normalizedOptions.length;
|
|
95
|
+
const selectedSize = selectedSet.size;
|
|
96
|
+
const pendingSize = pendingSet.size;
|
|
97
|
+
const isSelectedAll = selectedSize === 0 || selectedSize === totalOptions;
|
|
98
|
+
const isPendingAll = pendingSize === 0 || pendingSize === totalOptions;
|
|
99
|
+
const selectedCountValue = isSelectedAll ? totalOptions : selectedSize;
|
|
100
|
+
const pendingCountValue = isPendingAll ? totalOptions : pendingSize;
|
|
101
|
+
const isActiveFilter = selectionMode !== void 0 ? selectionMode === "custom" : !isSelectedAll;
|
|
102
|
+
const getSelectedLabel = () => {
|
|
103
|
+
if (isSelectedAll) return "All";
|
|
104
|
+
if (selectedSize === 1) {
|
|
105
|
+
const val = Array.from(selectedSet)[0];
|
|
106
|
+
const opt = normalizedOptions.find((o) => o.value === val);
|
|
107
|
+
return (opt == null ? void 0 : opt.label) || (opt == null ? void 0 : opt.value) || String(selectedCountValue);
|
|
108
|
+
}
|
|
109
|
+
return String(selectedCountValue);
|
|
110
|
+
};
|
|
111
|
+
const shouldDisableControls = isLoading || options.length === 0;
|
|
112
|
+
const normalizedSearch = searchTerm.trim();
|
|
113
|
+
const canCreateCustom = allowCustomValues && normalizedSearch.length > 0 && !normalizedOptions.some((o) => o.value.toLowerCase() === normalizedSearch.toLowerCase());
|
|
114
|
+
const handleCreateCustom = () => {
|
|
115
|
+
if (!normalizedSearch) return;
|
|
116
|
+
setPendingSelection((prev) => Array.from(/* @__PURE__ */ new Set([...prev, normalizedSearch])));
|
|
117
|
+
setSearchTerm("");
|
|
118
|
+
};
|
|
119
|
+
const handleClearFilter = (e) => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
onApply([], { selectionMode: "all" });
|
|
123
|
+
};
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.root, ref: containerRef, children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
type: "button",
|
|
129
|
+
className: clsx.clsx(MultiSelectDropdown_module.default.trigger, { [MultiSelectDropdown_module.default.active]: isOpen }),
|
|
130
|
+
onClick: () => setIsOpen((prev) => !prev),
|
|
131
|
+
"aria-expanded": isOpen,
|
|
132
|
+
"aria-haspopup": "listbox",
|
|
133
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.triggerContent, children: [
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: MultiSelectDropdown_module.default.chevron, width: constants.ICON_SIZE.MD, height: constants.ICON_SIZE.MD, viewBox: constants.SVG_VIEWBOX, fill: "none", stroke: "currentColor", strokeWidth: constants.SVG_STROKE_WIDTH, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "6 9 12 15 18 9" }) }),
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: MultiSelectDropdown_module.default.label, children: label }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.valueGroup, children: [
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: MultiSelectDropdown_module.default.value, children: customTriggerLabel || getSelectedLabel() }),
|
|
138
|
+
isActiveFilter && /* @__PURE__ */ jsxRuntime.jsx("span", { className: MultiSelectDropdown_module.default.badge, children: selectedCountValue }),
|
|
139
|
+
isActiveFilter && /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
role: "button",
|
|
143
|
+
tabIndex: 0,
|
|
144
|
+
className: MultiSelectDropdown_module.default.clear,
|
|
145
|
+
onClick: handleClearFilter,
|
|
146
|
+
onKeyDown: (e) => {
|
|
147
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
handleClearFilter(e);
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"aria-label": `Clear ${label} filter`,
|
|
153
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: constants.ICON_SIZE.SM, height: constants.ICON_SIZE.SM, viewBox: constants.SVG_VIEWBOX, fill: "none", stroke: "currentColor", strokeWidth: constants.SVG_STROKE_WIDTH, strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
156
|
+
] })
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] })
|
|
160
|
+
] })
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.panel, role: "dialog", "aria-label": `${label} filter`, children: [
|
|
164
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.header, children: [
|
|
165
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
166
|
+
"input",
|
|
167
|
+
{
|
|
168
|
+
type: "search",
|
|
169
|
+
className: MultiSelectDropdown_module.default.search,
|
|
170
|
+
placeholder: `Search ${label.toLowerCase()}`,
|
|
171
|
+
value: searchTerm,
|
|
172
|
+
onChange: (e) => setSearchTerm(e.target.value),
|
|
173
|
+
disabled: shouldDisableControls
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.headerActions, children: [
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: MultiSelectDropdown_module.default.chip, onClick: handleSelectAll, disabled: shouldDisableControls, children: "Select all" }),
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: clsx.clsx(MultiSelectDropdown_module.default.chip, MultiSelectDropdown_module.default.chipGhost), onClick: handleClearAll, disabled: pendingSize === 0, children: "Deselect all" })
|
|
179
|
+
] })
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.list, role: "listbox", children: [
|
|
182
|
+
isLoading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: MultiSelectDropdown_module.default.status, children: "Loading options..." }),
|
|
183
|
+
!isLoading && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: clsx.clsx(MultiSelectDropdown_module.default.status, MultiSelectDropdown_module.default.statusError), children: error }),
|
|
184
|
+
!isLoading && !error && filteredOptions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: MultiSelectDropdown_module.default.status, children: "No matches" }),
|
|
185
|
+
!isLoading && !error && filteredOptions.map((opt) => {
|
|
186
|
+
const checked = pendingSet.has(opt.value);
|
|
187
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: MultiSelectDropdown_module.default.option, children: [
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
189
|
+
"input",
|
|
190
|
+
{
|
|
191
|
+
type: "checkbox",
|
|
192
|
+
checked,
|
|
193
|
+
onChange: () => handleToggleOption(opt.value),
|
|
194
|
+
"aria-checked": checked
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: MultiSelectDropdown_module.default.optionLabel, children: [
|
|
198
|
+
opt.label ?? opt.value,
|
|
199
|
+
opt.count !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: MultiSelectDropdown_module.default.optionCount, children: opt.count })
|
|
200
|
+
] })
|
|
201
|
+
] }, opt.value);
|
|
202
|
+
}),
|
|
203
|
+
!isLoading && !error && canCreateCustom && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: MultiSelectDropdown_module.default.create, onClick: handleCreateCustom, children: [
|
|
204
|
+
'Use "',
|
|
205
|
+
normalizedSearch,
|
|
206
|
+
'"'
|
|
207
|
+
] })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.footer, children: [
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: MultiSelectDropdown_module.default.selection, children: [
|
|
211
|
+
isPendingAll ? "All selected" : `${pendingCountValue} selected`,
|
|
212
|
+
hasChanges && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: MultiSelectDropdown_module.default.selectionDelta, children: [
|
|
213
|
+
"(",
|
|
214
|
+
pendingCountValue - selectedCountValue >= 0 ? "+" : "",
|
|
215
|
+
pendingCountValue - selectedCountValue,
|
|
216
|
+
")"
|
|
217
|
+
] })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: MultiSelectDropdown_module.default.footerActions, children: [
|
|
220
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: clsx.clsx(MultiSelectDropdown_module.default.chip, MultiSelectDropdown_module.default.chipGhost), onClick: handleCancel, children: "Cancel" }),
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: MultiSelectDropdown_module.default.chip, onClick: handleApply, disabled: !hasChanges, children: "Apply" })
|
|
222
|
+
] })
|
|
223
|
+
] })
|
|
224
|
+
] })
|
|
225
|
+
] });
|
|
226
|
+
};
|
|
227
|
+
exports.MultiSelectDropdown = MultiSelectDropdown;
|
|
18
228
|
//# sourceMappingURL=index17.cjs.map
|