klun-ui 0.1.0 → 0.1.2
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 +45 -0
- package/dist/{chunk-FTYQRXS5.cjs → chunk-OPAZ7GAU.cjs} +587 -524
- package/dist/chunk-OPAZ7GAU.cjs.map +1 -0
- package/dist/{chunk-XDAR7UMF.js → chunk-RRE3PQLX.js} +587 -525
- package/dist/chunk-RRE3PQLX.js.map +1 -0
- package/dist/index.cjs +147 -143
- package/dist/index.d.cts +50 -3
- package/dist/index.d.ts +50 -3
- package/dist/index.js +1 -1
- package/dist/styles.css +49 -0
- package/dist/templates/index.cjs +82 -82
- package/dist/templates/index.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-FTYQRXS5.cjs.map +0 -1
- package/dist/chunk-XDAR7UMF.js.map +0 -1
|
@@ -6679,193 +6679,578 @@ var CounterInput = forwardRef(function CounterInput2({
|
|
|
6679
6679
|
);
|
|
6680
6680
|
});
|
|
6681
6681
|
CounterInput.displayName = "CounterInput";
|
|
6682
|
+
var Input = forwardRef(function Input2({
|
|
6683
|
+
size: sizeProp,
|
|
6684
|
+
leadingIcon,
|
|
6685
|
+
trailingIcon,
|
|
6686
|
+
leadingNode,
|
|
6687
|
+
trailingNode,
|
|
6688
|
+
error = false,
|
|
6689
|
+
disabled = false,
|
|
6690
|
+
readOnly = false,
|
|
6691
|
+
loading = false,
|
|
6692
|
+
clearable = false,
|
|
6693
|
+
onClear,
|
|
6694
|
+
className,
|
|
6695
|
+
style,
|
|
6696
|
+
...props
|
|
6697
|
+
}, ref) {
|
|
6698
|
+
const size = useSize(sizeProp);
|
|
6699
|
+
const { input } = useLocale();
|
|
6700
|
+
const innerRef = useRef(null);
|
|
6701
|
+
const [hasValue, setHasValue] = useState(() => !!(props.value ?? props.defaultValue));
|
|
6702
|
+
useEffect(() => {
|
|
6703
|
+
if (props.value !== void 0) setHasValue(!!props.value);
|
|
6704
|
+
}, [props.value]);
|
|
6705
|
+
const setRef = (node) => {
|
|
6706
|
+
innerRef.current = node;
|
|
6707
|
+
if (typeof ref === "function") ref(node);
|
|
6708
|
+
else if (ref) ref.current = node;
|
|
6709
|
+
};
|
|
6710
|
+
const showClear = clearable && hasValue && !disabled && !readOnly && !loading;
|
|
6711
|
+
const clear = () => {
|
|
6712
|
+
const node = innerRef.current;
|
|
6713
|
+
if (node) {
|
|
6714
|
+
node.value = "";
|
|
6715
|
+
node.focus();
|
|
6716
|
+
}
|
|
6717
|
+
setHasValue(false);
|
|
6718
|
+
onClear?.();
|
|
6719
|
+
if (node) {
|
|
6720
|
+
props.onChange?.({
|
|
6721
|
+
...{},
|
|
6722
|
+
target: node,
|
|
6723
|
+
currentTarget: node
|
|
6724
|
+
});
|
|
6725
|
+
}
|
|
6726
|
+
};
|
|
6727
|
+
return /* @__PURE__ */ jsxs(
|
|
6728
|
+
"div",
|
|
6729
|
+
{
|
|
6730
|
+
className: cx(
|
|
6731
|
+
"klun-input",
|
|
6732
|
+
`klun-input--${size}`,
|
|
6733
|
+
error && "klun-input--error",
|
|
6734
|
+
disabled && "klun-input--disabled",
|
|
6735
|
+
readOnly && "klun-input--readonly",
|
|
6736
|
+
className
|
|
6737
|
+
),
|
|
6738
|
+
style,
|
|
6739
|
+
children: [
|
|
6740
|
+
leadingIcon ? /* @__PURE__ */ jsx("span", { className: "klun-input__icon", children: leadingIcon }) : null,
|
|
6741
|
+
leadingNode,
|
|
6742
|
+
/* @__PURE__ */ jsx(
|
|
6743
|
+
"input",
|
|
6744
|
+
{
|
|
6745
|
+
ref: setRef,
|
|
6746
|
+
className: "klun-input__field",
|
|
6747
|
+
disabled,
|
|
6748
|
+
readOnly,
|
|
6749
|
+
...props,
|
|
6750
|
+
onChange: (e) => {
|
|
6751
|
+
setHasValue(!!e.target.value);
|
|
6752
|
+
props.onChange?.(e);
|
|
6753
|
+
}
|
|
6754
|
+
}
|
|
6755
|
+
),
|
|
6756
|
+
showClear ? /* @__PURE__ */ jsx(
|
|
6757
|
+
"button",
|
|
6758
|
+
{
|
|
6759
|
+
type: "button",
|
|
6760
|
+
className: "klun-input__clear",
|
|
6761
|
+
onClick: clear,
|
|
6762
|
+
"aria-label": input.clear,
|
|
6763
|
+
children: /* @__PURE__ */ jsx("i", { className: "ri-close-circle-fill" })
|
|
6764
|
+
}
|
|
6765
|
+
) : null,
|
|
6766
|
+
trailingNode,
|
|
6767
|
+
loading ? /* @__PURE__ */ jsx("span", { className: "klun-input__spinner", "aria-hidden": true, children: /* @__PURE__ */ jsxs("svg", { className: "klun-input__spinner-svg", width: 18, height: 18, viewBox: "0 0 20 20", fill: "none", children: [
|
|
6768
|
+
/* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "2.5" }),
|
|
6769
|
+
/* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeDasharray: "44", strokeDashoffset: "31" })
|
|
6770
|
+
] }) }) : trailingIcon ? /* @__PURE__ */ jsx("span", { className: "klun-input__icon", children: trailingIcon }) : null
|
|
6771
|
+
]
|
|
6772
|
+
}
|
|
6773
|
+
);
|
|
6774
|
+
});
|
|
6775
|
+
Input.displayName = "Input";
|
|
6776
|
+
var Popover = forwardRef(function Popover2({ trigger, children, align = "left", width = 280, className, ...props }, ref) {
|
|
6777
|
+
const [open, setOpen] = useState(false);
|
|
6778
|
+
const innerRef = useRef(null);
|
|
6779
|
+
useEffect(() => {
|
|
6780
|
+
if (!open) return;
|
|
6781
|
+
const h = (e) => {
|
|
6782
|
+
if (innerRef.current && !innerRef.current.contains(e.target)) setOpen(false);
|
|
6783
|
+
};
|
|
6784
|
+
document.addEventListener("mousedown", h);
|
|
6785
|
+
return () => document.removeEventListener("mousedown", h);
|
|
6786
|
+
}, [open]);
|
|
6787
|
+
const setRefs = (node) => {
|
|
6788
|
+
innerRef.current = node;
|
|
6789
|
+
if (typeof ref === "function") ref(node);
|
|
6790
|
+
else if (ref) ref.current = node;
|
|
6791
|
+
};
|
|
6792
|
+
return /* @__PURE__ */ jsxs("span", { ref: setRefs, className: cx("klun-popover", className), ...props, children: [
|
|
6793
|
+
/* @__PURE__ */ jsx("span", { className: "klun-popover__trigger", onClick: () => setOpen((o) => !o), children: trigger }),
|
|
6794
|
+
open ? /* @__PURE__ */ jsx(
|
|
6795
|
+
"div",
|
|
6796
|
+
{
|
|
6797
|
+
role: "dialog",
|
|
6798
|
+
className: cx("klun-popover__panel", `klun-popover__panel--${align}`),
|
|
6799
|
+
style: { width },
|
|
6800
|
+
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
6801
|
+
}
|
|
6802
|
+
) : null
|
|
6803
|
+
] });
|
|
6804
|
+
});
|
|
6805
|
+
Popover.displayName = "Popover";
|
|
6682
6806
|
var same = (a, b) => !!a && !!b && a.toDateString() === b.toDateString();
|
|
6807
|
+
var DEFAULT_FORMAT = {
|
|
6808
|
+
year: "numeric",
|
|
6809
|
+
month: "short",
|
|
6810
|
+
day: "numeric"
|
|
6811
|
+
};
|
|
6812
|
+
var Calendar = forwardRef(function Calendar2({ value, onPick, className, style }, ref) {
|
|
6813
|
+
const { datePicker } = useLocale();
|
|
6814
|
+
const initial = value ? new Date(value) : /* @__PURE__ */ new Date();
|
|
6815
|
+
const [view, setView] = useState(new Date(initial.getFullYear(), initial.getMonth(), 1));
|
|
6816
|
+
const sel = value ? new Date(value) : null;
|
|
6817
|
+
const y = view.getFullYear();
|
|
6818
|
+
const m = view.getMonth();
|
|
6819
|
+
const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
|
|
6820
|
+
const daysInMonth = new Date(y, m + 1, 0).getDate();
|
|
6821
|
+
const today = /* @__PURE__ */ new Date();
|
|
6822
|
+
today.setHours(0, 0, 0, 0);
|
|
6823
|
+
const cells = [];
|
|
6824
|
+
for (let i = 0; i < firstDay; i++) cells.push(null);
|
|
6825
|
+
for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
|
|
6826
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cx("klun-date-picker", className), style, children: [
|
|
6827
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-date-picker__header", children: [
|
|
6828
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "klun-date-picker__nav", onClick: () => setView(new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M12 6l-4 4 4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
6829
|
+
/* @__PURE__ */ jsx("span", { className: "klun-date-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
6830
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "klun-date-picker__nav", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M8 6l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
6831
|
+
] }),
|
|
6832
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-date-picker__grid", children: [
|
|
6833
|
+
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsx("div", { className: "klun-date-picker__weekday", children: d }, i)),
|
|
6834
|
+
cells.map((date, i) => {
|
|
6835
|
+
if (!date) return /* @__PURE__ */ jsx("span", {}, i);
|
|
6836
|
+
return /* @__PURE__ */ jsx(
|
|
6837
|
+
"button",
|
|
6838
|
+
{
|
|
6839
|
+
type: "button",
|
|
6840
|
+
className: "klun-date-picker__day",
|
|
6841
|
+
"data-selected": same(date, sel) || void 0,
|
|
6842
|
+
"data-today": same(date, today) || void 0,
|
|
6843
|
+
onClick: () => onPick(date),
|
|
6844
|
+
children: date.getDate()
|
|
6845
|
+
},
|
|
6846
|
+
i
|
|
6847
|
+
);
|
|
6848
|
+
})
|
|
6849
|
+
] })
|
|
6850
|
+
] });
|
|
6851
|
+
});
|
|
6683
6852
|
var DatePicker = forwardRef(
|
|
6684
|
-
function DatePicker2({ value, onChange, className, style, ...props }, ref) {
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
new Date(initial.getFullYear(), initial.getMonth(), 1)
|
|
6689
|
-
);
|
|
6853
|
+
function DatePicker2({ value, onChange, inline, placeholder, format = DEFAULT_FORMAT, align = "left", disabled, className, style, ...props }, ref) {
|
|
6854
|
+
if (inline) {
|
|
6855
|
+
return /* @__PURE__ */ jsx(Calendar, { ref, value, onPick: (d) => onChange?.(d), className, style });
|
|
6856
|
+
}
|
|
6690
6857
|
const sel = value ? new Date(value) : null;
|
|
6691
|
-
const
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6858
|
+
const label = sel ? sel.toLocaleDateString(void 0, format) : "";
|
|
6859
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cx("klun-date-field", className), style, ...props, children: /* @__PURE__ */ jsx(
|
|
6860
|
+
Popover,
|
|
6861
|
+
{
|
|
6862
|
+
align,
|
|
6863
|
+
trigger: /* @__PURE__ */ jsx(
|
|
6864
|
+
Input,
|
|
6865
|
+
{
|
|
6866
|
+
readOnly: true,
|
|
6867
|
+
disabled,
|
|
6868
|
+
value: label,
|
|
6869
|
+
placeholder: placeholder ?? "Select date",
|
|
6870
|
+
leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-calendar-line" }),
|
|
6871
|
+
trailingIcon: /* @__PURE__ */ jsx("i", { className: "ri-arrow-down-s-line" }),
|
|
6872
|
+
style: { width: "100%", cursor: "pointer" }
|
|
6873
|
+
}
|
|
6874
|
+
),
|
|
6875
|
+
children: (close) => /* @__PURE__ */ jsx(
|
|
6876
|
+
Calendar,
|
|
6877
|
+
{
|
|
6878
|
+
className: "klun-date-picker--bare",
|
|
6879
|
+
value,
|
|
6880
|
+
onPick: (d) => {
|
|
6881
|
+
onChange?.(d);
|
|
6882
|
+
close();
|
|
6883
|
+
}
|
|
6884
|
+
}
|
|
6885
|
+
)
|
|
6886
|
+
}
|
|
6887
|
+
) });
|
|
6888
|
+
}
|
|
6889
|
+
);
|
|
6890
|
+
DatePicker.displayName = "DatePicker";
|
|
6891
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
6892
|
+
var TimePicker = forwardRef(
|
|
6893
|
+
function TimePicker2({ value = "09:00", onChange, className, style, ...props }, ref) {
|
|
6894
|
+
const t = useLocale();
|
|
6895
|
+
const [h, m] = value.split(":").map(Number);
|
|
6896
|
+
const mer = h >= 12 ? "PM" : "AM";
|
|
6897
|
+
const h12 = (h + 11) % 12 + 1;
|
|
6898
|
+
const set = (nh, nm, nmer) => {
|
|
6899
|
+
let hh = nh % 12;
|
|
6900
|
+
if (nmer === "PM") hh += 12;
|
|
6901
|
+
onChange?.(`${pad(hh)}:${pad(nm)}`);
|
|
6902
|
+
};
|
|
6903
|
+
const [open, setOpen] = useState(null);
|
|
6904
|
+
const rootRef = useRef(null);
|
|
6905
|
+
const setRoot = (node) => {
|
|
6906
|
+
rootRef.current = node;
|
|
6907
|
+
if (typeof ref === "function") ref(node);
|
|
6908
|
+
else if (ref) ref.current = node;
|
|
6909
|
+
};
|
|
6910
|
+
useEffect(() => {
|
|
6911
|
+
if (!open) return;
|
|
6912
|
+
const onDown = (e) => {
|
|
6913
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(null);
|
|
6914
|
+
};
|
|
6915
|
+
document.addEventListener("mousedown", onDown);
|
|
6916
|
+
return () => document.removeEventListener("mousedown", onDown);
|
|
6917
|
+
}, [open]);
|
|
6918
|
+
const hourOpts = Array.from({ length: 12 }, (_, i) => ({
|
|
6919
|
+
value: String(i + 1),
|
|
6920
|
+
label: pad(i + 1)
|
|
6921
|
+
}));
|
|
6922
|
+
const minOpts = Array.from({ length: 60 }, (_, i) => ({
|
|
6923
|
+
value: String(i),
|
|
6924
|
+
label: pad(i)
|
|
6925
|
+
}));
|
|
6926
|
+
const merOpts = [
|
|
6927
|
+
{ value: "AM", label: t.timePicker.am },
|
|
6928
|
+
{ value: "PM", label: t.timePicker.pm }
|
|
6929
|
+
];
|
|
6930
|
+
return /* @__PURE__ */ jsxs(
|
|
6931
|
+
"div",
|
|
6932
|
+
{
|
|
6933
|
+
ref: setRoot,
|
|
6934
|
+
className: cx("klun-time-picker", className),
|
|
6935
|
+
style,
|
|
6936
|
+
...props,
|
|
6937
|
+
children: [
|
|
6938
|
+
/* @__PURE__ */ jsx("i", { className: "ri-time-line klun-time-picker__icon" }),
|
|
6939
|
+
/* @__PURE__ */ jsx(
|
|
6940
|
+
TimeColumn,
|
|
6941
|
+
{
|
|
6942
|
+
options: hourOpts,
|
|
6943
|
+
current: String(h12),
|
|
6944
|
+
open: open === "h",
|
|
6945
|
+
onOpen: () => setOpen("h"),
|
|
6946
|
+
onClose: () => setOpen(null),
|
|
6947
|
+
onPick: (v) => {
|
|
6948
|
+
set(Number(v), m, mer);
|
|
6949
|
+
setOpen(null);
|
|
6950
|
+
}
|
|
6951
|
+
}
|
|
6952
|
+
),
|
|
6953
|
+
/* @__PURE__ */ jsx("span", { className: "klun-time-picker__sep", children: ":" }),
|
|
6954
|
+
/* @__PURE__ */ jsx(
|
|
6955
|
+
TimeColumn,
|
|
6956
|
+
{
|
|
6957
|
+
options: minOpts,
|
|
6958
|
+
current: String(m),
|
|
6959
|
+
open: open === "m",
|
|
6960
|
+
onOpen: () => setOpen("m"),
|
|
6961
|
+
onClose: () => setOpen(null),
|
|
6962
|
+
onPick: (v) => {
|
|
6963
|
+
set(h12, Number(v), mer);
|
|
6964
|
+
setOpen(null);
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
6967
|
+
),
|
|
6968
|
+
/* @__PURE__ */ jsx(
|
|
6969
|
+
TimeColumn,
|
|
6970
|
+
{
|
|
6971
|
+
className: "klun-time-picker__col--meridiem",
|
|
6972
|
+
options: merOpts,
|
|
6973
|
+
current: mer,
|
|
6974
|
+
open: open === "mer",
|
|
6975
|
+
onOpen: () => setOpen("mer"),
|
|
6976
|
+
onClose: () => setOpen(null),
|
|
6977
|
+
onPick: (v) => {
|
|
6978
|
+
set(h12, m, v);
|
|
6979
|
+
setOpen(null);
|
|
6980
|
+
}
|
|
6981
|
+
}
|
|
6982
|
+
)
|
|
6983
|
+
]
|
|
6984
|
+
}
|
|
6985
|
+
);
|
|
6986
|
+
}
|
|
6987
|
+
);
|
|
6988
|
+
function TimeColumn({
|
|
6989
|
+
options,
|
|
6990
|
+
current,
|
|
6991
|
+
open,
|
|
6992
|
+
onOpen,
|
|
6993
|
+
onClose,
|
|
6994
|
+
onPick,
|
|
6995
|
+
className
|
|
6996
|
+
}) {
|
|
6997
|
+
const colRef = useRef(null);
|
|
6998
|
+
const [active, setActive] = useState(-1);
|
|
6999
|
+
const selected = options.find((o) => o.value === current);
|
|
7000
|
+
const panel = () => colRef.current?.querySelector(".klun-select-listbox") ?? null;
|
|
7001
|
+
const scrollTo = (i, center) => {
|
|
7002
|
+
requestAnimationFrame(() => {
|
|
7003
|
+
const p = panel();
|
|
7004
|
+
const el = p?.children[i];
|
|
7005
|
+
if (!p || !el) return;
|
|
7006
|
+
if (center) {
|
|
7007
|
+
p.scrollTop = el.offsetTop - p.clientHeight / 2 + el.offsetHeight / 2;
|
|
7008
|
+
} else if (el.offsetTop < p.scrollTop) {
|
|
7009
|
+
p.scrollTop = el.offsetTop - 4;
|
|
7010
|
+
} else if (el.offsetTop + el.offsetHeight > p.scrollTop + p.clientHeight) {
|
|
7011
|
+
p.scrollTop = el.offsetTop + el.offsetHeight - p.clientHeight + 4;
|
|
7012
|
+
}
|
|
7013
|
+
});
|
|
7014
|
+
};
|
|
7015
|
+
useEffect(() => {
|
|
7016
|
+
if (!open) return;
|
|
7017
|
+
const idx = options.findIndex((o) => o.value === current);
|
|
7018
|
+
setActive(idx);
|
|
7019
|
+
scrollTo(idx >= 0 ? idx : 0, true);
|
|
7020
|
+
}, [open]);
|
|
7021
|
+
const step = (dir) => {
|
|
7022
|
+
if (!options.length) return;
|
|
7023
|
+
let i = active;
|
|
7024
|
+
for (let n = 0; n < options.length; n++) {
|
|
7025
|
+
i = (i + dir + options.length) % options.length;
|
|
7026
|
+
if (!options[i].disabled) break;
|
|
7027
|
+
}
|
|
7028
|
+
setActive(i);
|
|
7029
|
+
scrollTo(i, false);
|
|
7030
|
+
};
|
|
7031
|
+
const onKeyDown = (e) => {
|
|
7032
|
+
if (!open) {
|
|
7033
|
+
if (["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key)) {
|
|
7034
|
+
e.preventDefault();
|
|
7035
|
+
onOpen();
|
|
7036
|
+
}
|
|
7037
|
+
return;
|
|
7038
|
+
}
|
|
7039
|
+
switch (e.key) {
|
|
7040
|
+
case "ArrowDown":
|
|
7041
|
+
e.preventDefault();
|
|
7042
|
+
step(1);
|
|
7043
|
+
break;
|
|
7044
|
+
case "ArrowUp":
|
|
7045
|
+
e.preventDefault();
|
|
7046
|
+
step(-1);
|
|
7047
|
+
break;
|
|
7048
|
+
case "Enter":
|
|
7049
|
+
case " ":
|
|
7050
|
+
e.preventDefault();
|
|
7051
|
+
if (options[active]) onPick(options[active].value);
|
|
7052
|
+
break;
|
|
7053
|
+
case "Escape":
|
|
7054
|
+
e.preventDefault();
|
|
7055
|
+
onClose();
|
|
7056
|
+
break;
|
|
7057
|
+
case "Tab":
|
|
7058
|
+
onClose();
|
|
7059
|
+
break;
|
|
7060
|
+
}
|
|
7061
|
+
};
|
|
7062
|
+
return /* @__PURE__ */ jsxs("div", { ref: colRef, className: cx("klun-time-picker__col", className), children: [
|
|
7063
|
+
/* @__PURE__ */ jsx(
|
|
7064
|
+
"button",
|
|
7065
|
+
{
|
|
7066
|
+
type: "button",
|
|
7067
|
+
className: "klun-time-picker__trigger",
|
|
7068
|
+
"aria-haspopup": "listbox",
|
|
7069
|
+
"aria-expanded": open,
|
|
7070
|
+
"data-open": open || void 0,
|
|
7071
|
+
onClick: () => open ? onClose() : onOpen(),
|
|
7072
|
+
onKeyDown,
|
|
7073
|
+
children: selected ? selected.label : ""
|
|
7074
|
+
}
|
|
7075
|
+
),
|
|
7076
|
+
open ? /* @__PURE__ */ jsx(
|
|
7077
|
+
SelectListbox,
|
|
7078
|
+
{
|
|
7079
|
+
className: "klun-time-picker__listbox",
|
|
7080
|
+
options,
|
|
7081
|
+
current,
|
|
7082
|
+
active,
|
|
7083
|
+
onActivate: setActive,
|
|
7084
|
+
onPick: (o) => onPick(o.value)
|
|
7085
|
+
}
|
|
7086
|
+
) : null
|
|
7087
|
+
] });
|
|
7088
|
+
}
|
|
7089
|
+
TimePicker.displayName = "TimePicker";
|
|
7090
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
7091
|
+
var DEFAULT_FORMAT2 = {
|
|
7092
|
+
year: "numeric",
|
|
7093
|
+
month: "short",
|
|
7094
|
+
day: "numeric",
|
|
7095
|
+
hour: "2-digit",
|
|
7096
|
+
minute: "2-digit"
|
|
7097
|
+
};
|
|
7098
|
+
function DateTimePanel({ value, onChange }) {
|
|
7099
|
+
const hhmm = value ? `${pad2(value.getHours())}:${pad2(value.getMinutes())}` : "09:00";
|
|
7100
|
+
const setDate = (d) => {
|
|
7101
|
+
const next = new Date(d);
|
|
7102
|
+
if (value) next.setHours(value.getHours(), value.getMinutes(), 0, 0);
|
|
7103
|
+
else next.setHours(9, 0, 0, 0);
|
|
7104
|
+
onChange(next);
|
|
7105
|
+
};
|
|
7106
|
+
const setTime = (t) => {
|
|
7107
|
+
const [h, m] = t.split(":").map(Number);
|
|
7108
|
+
const next = value ? new Date(value) : /* @__PURE__ */ new Date();
|
|
7109
|
+
next.setHours(h, m, 0, 0);
|
|
7110
|
+
onChange(next);
|
|
7111
|
+
};
|
|
7112
|
+
return /* @__PURE__ */ jsxs("div", { className: "klun-date-time-picker__panel", children: [
|
|
7113
|
+
/* @__PURE__ */ jsx(DatePicker, { inline: true, className: "klun-date-picker--bare", value, onChange: setDate }),
|
|
7114
|
+
/* @__PURE__ */ jsx("div", { className: "klun-date-time-picker__time", children: /* @__PURE__ */ jsx(TimePicker, { value: hhmm, onChange: setTime }) })
|
|
7115
|
+
] });
|
|
7116
|
+
}
|
|
7117
|
+
var DateTimePicker = forwardRef(
|
|
7118
|
+
function DateTimePicker2({ value, onChange, inline, placeholder, format = DEFAULT_FORMAT2, align = "left", disabled, className, style, ...props }, ref) {
|
|
7119
|
+
const date = value ? new Date(value) : null;
|
|
7120
|
+
if (inline) {
|
|
7121
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cx("klun-date-time-picker", className), style, ...props, children: /* @__PURE__ */ jsx(DateTimePanel, { value: date, onChange: (d) => onChange?.(d) }) });
|
|
7122
|
+
}
|
|
7123
|
+
const label = date ? date.toLocaleString(void 0, format) : "";
|
|
7124
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cx("klun-date-time-field", className), style, ...props, children: /* @__PURE__ */ jsx(
|
|
7125
|
+
Popover,
|
|
7126
|
+
{
|
|
7127
|
+
align,
|
|
7128
|
+
width: 300,
|
|
7129
|
+
trigger: /* @__PURE__ */ jsx(
|
|
7130
|
+
Input,
|
|
6704
7131
|
{
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
stroke: "currentColor",
|
|
6713
|
-
strokeWidth: "1.5",
|
|
6714
|
-
strokeLinecap: "round",
|
|
6715
|
-
strokeLinejoin: "round"
|
|
6716
|
-
}
|
|
6717
|
-
) })
|
|
7132
|
+
readOnly: true,
|
|
7133
|
+
disabled,
|
|
7134
|
+
value: label,
|
|
7135
|
+
placeholder: placeholder ?? "Select date & time",
|
|
7136
|
+
leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-calendar-2-line" }),
|
|
7137
|
+
trailingIcon: /* @__PURE__ */ jsx("i", { className: "ri-arrow-down-s-line" }),
|
|
7138
|
+
style: { width: "100%", cursor: "pointer" }
|
|
6718
7139
|
}
|
|
6719
7140
|
),
|
|
6720
|
-
/* @__PURE__ */ jsx(
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
{
|
|
6724
|
-
type: "button",
|
|
6725
|
-
className: "klun-date-picker__nav",
|
|
6726
|
-
onClick: () => setView(new Date(y, m + 1, 1)),
|
|
6727
|
-
children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
6728
|
-
"path",
|
|
6729
|
-
{
|
|
6730
|
-
d: "M8 6l4 4-4 4",
|
|
6731
|
-
stroke: "currentColor",
|
|
6732
|
-
strokeWidth: "1.5",
|
|
6733
|
-
strokeLinecap: "round",
|
|
6734
|
-
strokeLinejoin: "round"
|
|
6735
|
-
}
|
|
6736
|
-
) })
|
|
6737
|
-
}
|
|
6738
|
-
)
|
|
6739
|
-
] }),
|
|
6740
|
-
/* @__PURE__ */ jsxs("div", { className: "klun-date-picker__grid", children: [
|
|
6741
|
-
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsx("div", { className: "klun-date-picker__weekday", children: d }, i)),
|
|
6742
|
-
cells.map((date, i) => {
|
|
6743
|
-
if (!date) return /* @__PURE__ */ jsx("span", {}, i);
|
|
6744
|
-
const isSel = same(date, sel);
|
|
6745
|
-
const isToday = same(date, today);
|
|
6746
|
-
return /* @__PURE__ */ jsx(
|
|
6747
|
-
"button",
|
|
6748
|
-
{
|
|
6749
|
-
type: "button",
|
|
6750
|
-
className: "klun-date-picker__day",
|
|
6751
|
-
"data-selected": isSel || void 0,
|
|
6752
|
-
"data-today": isToday || void 0,
|
|
6753
|
-
onClick: () => onChange?.(date),
|
|
6754
|
-
children: date.getDate()
|
|
6755
|
-
},
|
|
6756
|
-
i
|
|
6757
|
-
);
|
|
6758
|
-
})
|
|
6759
|
-
] })
|
|
6760
|
-
] });
|
|
7141
|
+
children: /* @__PURE__ */ jsx(DateTimePanel, { value: date, onChange: (d) => onChange?.(d) })
|
|
7142
|
+
}
|
|
7143
|
+
) });
|
|
6761
7144
|
}
|
|
6762
7145
|
);
|
|
6763
|
-
|
|
7146
|
+
DateTimePicker.displayName = "DateTimePicker";
|
|
6764
7147
|
var norm = (d) => d && new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
6765
|
-
var
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
"
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsx(
|
|
6806
|
-
"path",
|
|
6807
|
-
{
|
|
6808
|
-
d: "M12 6l-4 4 4 4",
|
|
6809
|
-
stroke: "currentColor",
|
|
6810
|
-
strokeWidth: "1.5",
|
|
6811
|
-
strokeLinecap: "round",
|
|
6812
|
-
strokeLinejoin: "round"
|
|
6813
|
-
}
|
|
6814
|
-
) })
|
|
6815
|
-
}
|
|
6816
|
-
),
|
|
6817
|
-
/* @__PURE__ */ jsx("span", { className: "klun-date-range-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
6818
|
-
/* @__PURE__ */ jsx(
|
|
7148
|
+
var DEFAULT_FORMAT3 = { month: "short", day: "numeric" };
|
|
7149
|
+
var RangeCalendar = forwardRef(function RangeCalendar2({ start, end, onPick, className, style }, ref) {
|
|
7150
|
+
const { datePicker } = useLocale();
|
|
7151
|
+
const base = start ? new Date(start) : /* @__PURE__ */ new Date();
|
|
7152
|
+
const [view, setView] = useState(new Date(base.getFullYear(), base.getMonth(), 1));
|
|
7153
|
+
const s = start ? new Date(start) : null;
|
|
7154
|
+
const e = end ? new Date(end) : null;
|
|
7155
|
+
const y = view.getFullYear();
|
|
7156
|
+
const m = view.getMonth();
|
|
7157
|
+
const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
|
|
7158
|
+
const daysInMonth = new Date(y, m + 1, 0).getDate();
|
|
7159
|
+
const cells = [];
|
|
7160
|
+
for (let i = 0; i < firstDay; i++) cells.push(null);
|
|
7161
|
+
for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
|
|
7162
|
+
const pick = (d) => {
|
|
7163
|
+
if (!s || s && e) return onPick({ start: d, end: null });
|
|
7164
|
+
if (norm(d) < norm(s)) return onPick({ start: d, end: s });
|
|
7165
|
+
onPick({ start: s, end: d });
|
|
7166
|
+
};
|
|
7167
|
+
const inRange = (d) => !!s && !!e && norm(d) > norm(s) && norm(d) < norm(e);
|
|
7168
|
+
const isStart = (d) => !!s && norm(d) === norm(s);
|
|
7169
|
+
const isEnd = (d) => !!e && norm(d) === norm(e);
|
|
7170
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cx("klun-date-range-picker", className), style, children: [
|
|
7171
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__header", children: [
|
|
7172
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "klun-date-range-picker__nav", onClick: () => setView(new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M12 6l-4 4 4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
7173
|
+
/* @__PURE__ */ jsx("span", { className: "klun-date-range-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
7174
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "klun-date-range-picker__nav", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M8 6l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
7175
|
+
] }),
|
|
7176
|
+
/* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__grid", children: [
|
|
7177
|
+
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsx("div", { className: "klun-date-range-picker__weekday", children: d }, i)),
|
|
7178
|
+
cells.map((date, i) => {
|
|
7179
|
+
if (!date) return /* @__PURE__ */ jsx("span", {}, i);
|
|
7180
|
+
const mid = inRange(date);
|
|
7181
|
+
return /* @__PURE__ */ jsx(
|
|
7182
|
+
"div",
|
|
7183
|
+
{
|
|
7184
|
+
className: "klun-date-range-picker__cell",
|
|
7185
|
+
"data-in-range": mid || void 0,
|
|
7186
|
+
"data-range-edge": isStart(date) || isEnd(date) || void 0,
|
|
7187
|
+
children: /* @__PURE__ */ jsx(
|
|
6819
7188
|
"button",
|
|
6820
7189
|
{
|
|
6821
7190
|
type: "button",
|
|
6822
|
-
className: "klun-date-range-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
stroke: "currentColor",
|
|
6829
|
-
strokeWidth: "1.5",
|
|
6830
|
-
strokeLinecap: "round",
|
|
6831
|
-
strokeLinejoin: "round"
|
|
6832
|
-
}
|
|
6833
|
-
) })
|
|
7191
|
+
className: "klun-date-range-picker__day",
|
|
7192
|
+
"data-range-start": isStart(date) || void 0,
|
|
7193
|
+
"data-range-end": isEnd(date) || void 0,
|
|
7194
|
+
"data-in-range": mid || void 0,
|
|
7195
|
+
onClick: () => pick(date),
|
|
7196
|
+
children: date.getDate()
|
|
6834
7197
|
}
|
|
6835
7198
|
)
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
7199
|
+
},
|
|
7200
|
+
i
|
|
7201
|
+
);
|
|
7202
|
+
})
|
|
7203
|
+
] })
|
|
7204
|
+
] });
|
|
7205
|
+
});
|
|
7206
|
+
var DateRangePicker = forwardRef(
|
|
7207
|
+
function DateRangePicker2({ start, end, onChange, inline, placeholder, format = DEFAULT_FORMAT3, align = "left", disabled, className, style, ...props }, ref) {
|
|
7208
|
+
if (inline) {
|
|
7209
|
+
return /* @__PURE__ */ jsx(
|
|
7210
|
+
RangeCalendar,
|
|
7211
|
+
{
|
|
7212
|
+
ref,
|
|
7213
|
+
start,
|
|
7214
|
+
end,
|
|
7215
|
+
onPick: (r) => onChange?.(r),
|
|
7216
|
+
className,
|
|
7217
|
+
style
|
|
7218
|
+
}
|
|
7219
|
+
);
|
|
7220
|
+
}
|
|
7221
|
+
const f = (d) => d ? new Date(d).toLocaleDateString(void 0, format) : "";
|
|
7222
|
+
const label = start || end ? `${f(start)} \u2013 ${f(end)}` : "";
|
|
7223
|
+
return /* @__PURE__ */ jsx("div", { ref, className: cx("klun-date-range-field", className), style, ...props, children: /* @__PURE__ */ jsx(
|
|
7224
|
+
Popover,
|
|
7225
|
+
{
|
|
7226
|
+
align,
|
|
7227
|
+
width: 300,
|
|
7228
|
+
trigger: /* @__PURE__ */ jsx(
|
|
7229
|
+
Input,
|
|
7230
|
+
{
|
|
7231
|
+
readOnly: true,
|
|
7232
|
+
disabled,
|
|
7233
|
+
value: label,
|
|
7234
|
+
placeholder: placeholder ?? "Select range",
|
|
7235
|
+
leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-calendar-2-line" }),
|
|
7236
|
+
trailingIcon: /* @__PURE__ */ jsx("i", { className: "ri-arrow-down-s-line" }),
|
|
7237
|
+
style: { width: "100%", cursor: "pointer" }
|
|
7238
|
+
}
|
|
7239
|
+
),
|
|
7240
|
+
children: (close) => /* @__PURE__ */ jsx(
|
|
7241
|
+
RangeCalendar,
|
|
7242
|
+
{
|
|
7243
|
+
className: "klun-date-range-picker--bare",
|
|
7244
|
+
start,
|
|
7245
|
+
end,
|
|
7246
|
+
onPick: (r) => {
|
|
7247
|
+
onChange?.(r);
|
|
7248
|
+
if (r.start && r.end) close();
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
)
|
|
6867
7252
|
}
|
|
6868
|
-
);
|
|
7253
|
+
) });
|
|
6869
7254
|
}
|
|
6870
7255
|
);
|
|
6871
7256
|
DateRangePicker.displayName = "DateRangePicker";
|
|
@@ -7509,127 +7894,33 @@ var InlineSelect = forwardRef(
|
|
|
7509
7894
|
/* @__PURE__ */ jsx(
|
|
7510
7895
|
"select",
|
|
7511
7896
|
{
|
|
7512
|
-
ref: s.mergeSelectRef(ref),
|
|
7513
|
-
className: "klun-inline-select__native",
|
|
7514
|
-
"aria-hidden": true,
|
|
7515
|
-
tabIndex: -1,
|
|
7516
|
-
defaultValue: String(value ?? defaultValue ?? ""),
|
|
7517
|
-
onChange,
|
|
7518
|
-
disabled,
|
|
7519
|
-
...props,
|
|
7520
|
-
children
|
|
7521
|
-
}
|
|
7522
|
-
),
|
|
7523
|
-
s.open ? /* @__PURE__ */ jsx(
|
|
7524
|
-
SelectListbox,
|
|
7525
|
-
{
|
|
7526
|
-
options: s.options,
|
|
7527
|
-
current: s.current,
|
|
7528
|
-
active: s.active,
|
|
7529
|
-
onActivate: s.setActive,
|
|
7530
|
-
onPick: s.pick
|
|
7531
|
-
}
|
|
7532
|
-
) : null
|
|
7533
|
-
]
|
|
7534
|
-
}
|
|
7535
|
-
);
|
|
7536
|
-
}
|
|
7537
|
-
);
|
|
7538
|
-
InlineSelect.displayName = "InlineSelect";
|
|
7539
|
-
var Input = forwardRef(function Input2({
|
|
7540
|
-
size: sizeProp,
|
|
7541
|
-
leadingIcon,
|
|
7542
|
-
trailingIcon,
|
|
7543
|
-
leadingNode,
|
|
7544
|
-
trailingNode,
|
|
7545
|
-
error = false,
|
|
7546
|
-
disabled = false,
|
|
7547
|
-
readOnly = false,
|
|
7548
|
-
loading = false,
|
|
7549
|
-
clearable = false,
|
|
7550
|
-
onClear,
|
|
7551
|
-
className,
|
|
7552
|
-
style,
|
|
7553
|
-
...props
|
|
7554
|
-
}, ref) {
|
|
7555
|
-
const size = useSize(sizeProp);
|
|
7556
|
-
const { input } = useLocale();
|
|
7557
|
-
const innerRef = useRef(null);
|
|
7558
|
-
const [hasValue, setHasValue] = useState(() => !!(props.value ?? props.defaultValue));
|
|
7559
|
-
useEffect(() => {
|
|
7560
|
-
if (props.value !== void 0) setHasValue(!!props.value);
|
|
7561
|
-
}, [props.value]);
|
|
7562
|
-
const setRef = (node) => {
|
|
7563
|
-
innerRef.current = node;
|
|
7564
|
-
if (typeof ref === "function") ref(node);
|
|
7565
|
-
else if (ref) ref.current = node;
|
|
7566
|
-
};
|
|
7567
|
-
const showClear = clearable && hasValue && !disabled && !readOnly && !loading;
|
|
7568
|
-
const clear = () => {
|
|
7569
|
-
const node = innerRef.current;
|
|
7570
|
-
if (node) {
|
|
7571
|
-
node.value = "";
|
|
7572
|
-
node.focus();
|
|
7573
|
-
}
|
|
7574
|
-
setHasValue(false);
|
|
7575
|
-
onClear?.();
|
|
7576
|
-
if (node) {
|
|
7577
|
-
props.onChange?.({
|
|
7578
|
-
...{},
|
|
7579
|
-
target: node,
|
|
7580
|
-
currentTarget: node
|
|
7581
|
-
});
|
|
7582
|
-
}
|
|
7583
|
-
};
|
|
7584
|
-
return /* @__PURE__ */ jsxs(
|
|
7585
|
-
"div",
|
|
7586
|
-
{
|
|
7587
|
-
className: cx(
|
|
7588
|
-
"klun-input",
|
|
7589
|
-
`klun-input--${size}`,
|
|
7590
|
-
error && "klun-input--error",
|
|
7591
|
-
disabled && "klun-input--disabled",
|
|
7592
|
-
readOnly && "klun-input--readonly",
|
|
7593
|
-
className
|
|
7594
|
-
),
|
|
7595
|
-
style,
|
|
7596
|
-
children: [
|
|
7597
|
-
leadingIcon ? /* @__PURE__ */ jsx("span", { className: "klun-input__icon", children: leadingIcon }) : null,
|
|
7598
|
-
leadingNode,
|
|
7599
|
-
/* @__PURE__ */ jsx(
|
|
7600
|
-
"input",
|
|
7601
|
-
{
|
|
7602
|
-
ref: setRef,
|
|
7603
|
-
className: "klun-input__field",
|
|
7604
|
-
disabled,
|
|
7605
|
-
readOnly,
|
|
7606
|
-
...props,
|
|
7607
|
-
onChange: (e) => {
|
|
7608
|
-
setHasValue(!!e.target.value);
|
|
7609
|
-
props.onChange?.(e);
|
|
7610
|
-
}
|
|
7611
|
-
}
|
|
7612
|
-
),
|
|
7613
|
-
showClear ? /* @__PURE__ */ jsx(
|
|
7614
|
-
"button",
|
|
7615
|
-
{
|
|
7616
|
-
type: "button",
|
|
7617
|
-
className: "klun-input__clear",
|
|
7618
|
-
onClick: clear,
|
|
7619
|
-
"aria-label": input.clear,
|
|
7620
|
-
children: /* @__PURE__ */ jsx("i", { className: "ri-close-circle-fill" })
|
|
7621
|
-
}
|
|
7622
|
-
) : null,
|
|
7623
|
-
trailingNode,
|
|
7624
|
-
loading ? /* @__PURE__ */ jsx("span", { className: "klun-input__spinner", "aria-hidden": true, children: /* @__PURE__ */ jsxs("svg", { className: "klun-input__spinner-svg", width: 18, height: 18, viewBox: "0 0 20 20", fill: "none", children: [
|
|
7625
|
-
/* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "2.5" }),
|
|
7626
|
-
/* @__PURE__ */ jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeDasharray: "44", strokeDashoffset: "31" })
|
|
7627
|
-
] }) }) : trailingIcon ? /* @__PURE__ */ jsx("span", { className: "klun-input__icon", children: trailingIcon }) : null
|
|
7628
|
-
]
|
|
7629
|
-
}
|
|
7630
|
-
);
|
|
7631
|
-
});
|
|
7632
|
-
Input.displayName = "Input";
|
|
7897
|
+
ref: s.mergeSelectRef(ref),
|
|
7898
|
+
className: "klun-inline-select__native",
|
|
7899
|
+
"aria-hidden": true,
|
|
7900
|
+
tabIndex: -1,
|
|
7901
|
+
defaultValue: String(value ?? defaultValue ?? ""),
|
|
7902
|
+
onChange,
|
|
7903
|
+
disabled,
|
|
7904
|
+
...props,
|
|
7905
|
+
children
|
|
7906
|
+
}
|
|
7907
|
+
),
|
|
7908
|
+
s.open ? /* @__PURE__ */ jsx(
|
|
7909
|
+
SelectListbox,
|
|
7910
|
+
{
|
|
7911
|
+
options: s.options,
|
|
7912
|
+
current: s.current,
|
|
7913
|
+
active: s.active,
|
|
7914
|
+
onActivate: s.setActive,
|
|
7915
|
+
onPick: s.pick
|
|
7916
|
+
}
|
|
7917
|
+
) : null
|
|
7918
|
+
]
|
|
7919
|
+
}
|
|
7920
|
+
);
|
|
7921
|
+
}
|
|
7922
|
+
);
|
|
7923
|
+
InlineSelect.displayName = "InlineSelect";
|
|
7633
7924
|
var Label = forwardRef(function Label2({ children, required = false, sublabel, disabled = false, className, ...props }, ref) {
|
|
7634
7925
|
return /* @__PURE__ */ jsxs(
|
|
7635
7926
|
"label",
|
|
@@ -8204,205 +8495,6 @@ var Textarea = forwardRef(function Textarea2({ error = false, disabled = false,
|
|
|
8204
8495
|
);
|
|
8205
8496
|
});
|
|
8206
8497
|
Textarea.displayName = "Textarea";
|
|
8207
|
-
var pad = (n) => String(n).padStart(2, "0");
|
|
8208
|
-
var TimePicker = forwardRef(
|
|
8209
|
-
function TimePicker2({ value = "09:00", onChange, className, style, ...props }, ref) {
|
|
8210
|
-
const t = useLocale();
|
|
8211
|
-
const [h, m] = value.split(":").map(Number);
|
|
8212
|
-
const mer = h >= 12 ? "PM" : "AM";
|
|
8213
|
-
const h12 = (h + 11) % 12 + 1;
|
|
8214
|
-
const set = (nh, nm, nmer) => {
|
|
8215
|
-
let hh = nh % 12;
|
|
8216
|
-
if (nmer === "PM") hh += 12;
|
|
8217
|
-
onChange?.(`${pad(hh)}:${pad(nm)}`);
|
|
8218
|
-
};
|
|
8219
|
-
const [open, setOpen] = useState(null);
|
|
8220
|
-
const rootRef = useRef(null);
|
|
8221
|
-
const setRoot = (node) => {
|
|
8222
|
-
rootRef.current = node;
|
|
8223
|
-
if (typeof ref === "function") ref(node);
|
|
8224
|
-
else if (ref) ref.current = node;
|
|
8225
|
-
};
|
|
8226
|
-
useEffect(() => {
|
|
8227
|
-
if (!open) return;
|
|
8228
|
-
const onDown = (e) => {
|
|
8229
|
-
if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(null);
|
|
8230
|
-
};
|
|
8231
|
-
document.addEventListener("mousedown", onDown);
|
|
8232
|
-
return () => document.removeEventListener("mousedown", onDown);
|
|
8233
|
-
}, [open]);
|
|
8234
|
-
const hourOpts = Array.from({ length: 12 }, (_, i) => ({
|
|
8235
|
-
value: String(i + 1),
|
|
8236
|
-
label: pad(i + 1)
|
|
8237
|
-
}));
|
|
8238
|
-
const minOpts = Array.from({ length: 60 }, (_, i) => ({
|
|
8239
|
-
value: String(i),
|
|
8240
|
-
label: pad(i)
|
|
8241
|
-
}));
|
|
8242
|
-
const merOpts = [
|
|
8243
|
-
{ value: "AM", label: t.timePicker.am },
|
|
8244
|
-
{ value: "PM", label: t.timePicker.pm }
|
|
8245
|
-
];
|
|
8246
|
-
return /* @__PURE__ */ jsxs(
|
|
8247
|
-
"div",
|
|
8248
|
-
{
|
|
8249
|
-
ref: setRoot,
|
|
8250
|
-
className: cx("klun-time-picker", className),
|
|
8251
|
-
style,
|
|
8252
|
-
...props,
|
|
8253
|
-
children: [
|
|
8254
|
-
/* @__PURE__ */ jsx("i", { className: "ri-time-line klun-time-picker__icon" }),
|
|
8255
|
-
/* @__PURE__ */ jsx(
|
|
8256
|
-
TimeColumn,
|
|
8257
|
-
{
|
|
8258
|
-
options: hourOpts,
|
|
8259
|
-
current: String(h12),
|
|
8260
|
-
open: open === "h",
|
|
8261
|
-
onOpen: () => setOpen("h"),
|
|
8262
|
-
onClose: () => setOpen(null),
|
|
8263
|
-
onPick: (v) => {
|
|
8264
|
-
set(Number(v), m, mer);
|
|
8265
|
-
setOpen(null);
|
|
8266
|
-
}
|
|
8267
|
-
}
|
|
8268
|
-
),
|
|
8269
|
-
/* @__PURE__ */ jsx("span", { className: "klun-time-picker__sep", children: ":" }),
|
|
8270
|
-
/* @__PURE__ */ jsx(
|
|
8271
|
-
TimeColumn,
|
|
8272
|
-
{
|
|
8273
|
-
options: minOpts,
|
|
8274
|
-
current: String(m),
|
|
8275
|
-
open: open === "m",
|
|
8276
|
-
onOpen: () => setOpen("m"),
|
|
8277
|
-
onClose: () => setOpen(null),
|
|
8278
|
-
onPick: (v) => {
|
|
8279
|
-
set(h12, Number(v), mer);
|
|
8280
|
-
setOpen(null);
|
|
8281
|
-
}
|
|
8282
|
-
}
|
|
8283
|
-
),
|
|
8284
|
-
/* @__PURE__ */ jsx(
|
|
8285
|
-
TimeColumn,
|
|
8286
|
-
{
|
|
8287
|
-
className: "klun-time-picker__col--meridiem",
|
|
8288
|
-
options: merOpts,
|
|
8289
|
-
current: mer,
|
|
8290
|
-
open: open === "mer",
|
|
8291
|
-
onOpen: () => setOpen("mer"),
|
|
8292
|
-
onClose: () => setOpen(null),
|
|
8293
|
-
onPick: (v) => {
|
|
8294
|
-
set(h12, m, v);
|
|
8295
|
-
setOpen(null);
|
|
8296
|
-
}
|
|
8297
|
-
}
|
|
8298
|
-
)
|
|
8299
|
-
]
|
|
8300
|
-
}
|
|
8301
|
-
);
|
|
8302
|
-
}
|
|
8303
|
-
);
|
|
8304
|
-
function TimeColumn({
|
|
8305
|
-
options,
|
|
8306
|
-
current,
|
|
8307
|
-
open,
|
|
8308
|
-
onOpen,
|
|
8309
|
-
onClose,
|
|
8310
|
-
onPick,
|
|
8311
|
-
className
|
|
8312
|
-
}) {
|
|
8313
|
-
const colRef = useRef(null);
|
|
8314
|
-
const [active, setActive] = useState(-1);
|
|
8315
|
-
const selected = options.find((o) => o.value === current);
|
|
8316
|
-
const panel = () => colRef.current?.querySelector(".klun-select-listbox") ?? null;
|
|
8317
|
-
const scrollTo = (i, center) => {
|
|
8318
|
-
requestAnimationFrame(() => {
|
|
8319
|
-
const p = panel();
|
|
8320
|
-
const el = p?.children[i];
|
|
8321
|
-
if (!p || !el) return;
|
|
8322
|
-
if (center) {
|
|
8323
|
-
p.scrollTop = el.offsetTop - p.clientHeight / 2 + el.offsetHeight / 2;
|
|
8324
|
-
} else if (el.offsetTop < p.scrollTop) {
|
|
8325
|
-
p.scrollTop = el.offsetTop - 4;
|
|
8326
|
-
} else if (el.offsetTop + el.offsetHeight > p.scrollTop + p.clientHeight) {
|
|
8327
|
-
p.scrollTop = el.offsetTop + el.offsetHeight - p.clientHeight + 4;
|
|
8328
|
-
}
|
|
8329
|
-
});
|
|
8330
|
-
};
|
|
8331
|
-
useEffect(() => {
|
|
8332
|
-
if (!open) return;
|
|
8333
|
-
const idx = options.findIndex((o) => o.value === current);
|
|
8334
|
-
setActive(idx);
|
|
8335
|
-
scrollTo(idx >= 0 ? idx : 0, true);
|
|
8336
|
-
}, [open]);
|
|
8337
|
-
const step = (dir) => {
|
|
8338
|
-
if (!options.length) return;
|
|
8339
|
-
let i = active;
|
|
8340
|
-
for (let n = 0; n < options.length; n++) {
|
|
8341
|
-
i = (i + dir + options.length) % options.length;
|
|
8342
|
-
if (!options[i].disabled) break;
|
|
8343
|
-
}
|
|
8344
|
-
setActive(i);
|
|
8345
|
-
scrollTo(i, false);
|
|
8346
|
-
};
|
|
8347
|
-
const onKeyDown = (e) => {
|
|
8348
|
-
if (!open) {
|
|
8349
|
-
if (["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key)) {
|
|
8350
|
-
e.preventDefault();
|
|
8351
|
-
onOpen();
|
|
8352
|
-
}
|
|
8353
|
-
return;
|
|
8354
|
-
}
|
|
8355
|
-
switch (e.key) {
|
|
8356
|
-
case "ArrowDown":
|
|
8357
|
-
e.preventDefault();
|
|
8358
|
-
step(1);
|
|
8359
|
-
break;
|
|
8360
|
-
case "ArrowUp":
|
|
8361
|
-
e.preventDefault();
|
|
8362
|
-
step(-1);
|
|
8363
|
-
break;
|
|
8364
|
-
case "Enter":
|
|
8365
|
-
case " ":
|
|
8366
|
-
e.preventDefault();
|
|
8367
|
-
if (options[active]) onPick(options[active].value);
|
|
8368
|
-
break;
|
|
8369
|
-
case "Escape":
|
|
8370
|
-
e.preventDefault();
|
|
8371
|
-
onClose();
|
|
8372
|
-
break;
|
|
8373
|
-
case "Tab":
|
|
8374
|
-
onClose();
|
|
8375
|
-
break;
|
|
8376
|
-
}
|
|
8377
|
-
};
|
|
8378
|
-
return /* @__PURE__ */ jsxs("div", { ref: colRef, className: cx("klun-time-picker__col", className), children: [
|
|
8379
|
-
/* @__PURE__ */ jsx(
|
|
8380
|
-
"button",
|
|
8381
|
-
{
|
|
8382
|
-
type: "button",
|
|
8383
|
-
className: "klun-time-picker__trigger",
|
|
8384
|
-
"aria-haspopup": "listbox",
|
|
8385
|
-
"aria-expanded": open,
|
|
8386
|
-
"data-open": open || void 0,
|
|
8387
|
-
onClick: () => open ? onClose() : onOpen(),
|
|
8388
|
-
onKeyDown,
|
|
8389
|
-
children: selected ? selected.label : ""
|
|
8390
|
-
}
|
|
8391
|
-
),
|
|
8392
|
-
open ? /* @__PURE__ */ jsx(
|
|
8393
|
-
SelectListbox,
|
|
8394
|
-
{
|
|
8395
|
-
className: "klun-time-picker__listbox",
|
|
8396
|
-
options,
|
|
8397
|
-
current,
|
|
8398
|
-
active,
|
|
8399
|
-
onActivate: setActive,
|
|
8400
|
-
onPick: (o) => onPick(o.value)
|
|
8401
|
-
}
|
|
8402
|
-
) : null
|
|
8403
|
-
] });
|
|
8404
|
-
}
|
|
8405
|
-
TimePicker.displayName = "TimePicker";
|
|
8406
8498
|
var Card = forwardRef(function Card2({ variant = "stroke", padding, className, style, children, ...props }, ref) {
|
|
8407
8499
|
return /* @__PURE__ */ jsx(
|
|
8408
8500
|
"div",
|
|
@@ -9973,37 +10065,7 @@ var Popconfirm = forwardRef(function Popconfirm2({
|
|
|
9973
10065
|
] });
|
|
9974
10066
|
});
|
|
9975
10067
|
Popconfirm.displayName = "Popconfirm";
|
|
9976
|
-
var Popover = forwardRef(function Popover2({ trigger, children, align = "left", width = 280, className, ...props }, ref) {
|
|
9977
|
-
const [open, setOpen] = useState(false);
|
|
9978
|
-
const innerRef = useRef(null);
|
|
9979
|
-
useEffect(() => {
|
|
9980
|
-
if (!open) return;
|
|
9981
|
-
const h = (e) => {
|
|
9982
|
-
if (innerRef.current && !innerRef.current.contains(e.target)) setOpen(false);
|
|
9983
|
-
};
|
|
9984
|
-
document.addEventListener("mousedown", h);
|
|
9985
|
-
return () => document.removeEventListener("mousedown", h);
|
|
9986
|
-
}, [open]);
|
|
9987
|
-
const setRefs = (node) => {
|
|
9988
|
-
innerRef.current = node;
|
|
9989
|
-
if (typeof ref === "function") ref(node);
|
|
9990
|
-
else if (ref) ref.current = node;
|
|
9991
|
-
};
|
|
9992
|
-
return /* @__PURE__ */ jsxs("span", { ref: setRefs, className: cx("klun-popover", className), ...props, children: [
|
|
9993
|
-
/* @__PURE__ */ jsx("span", { className: "klun-popover__trigger", onClick: () => setOpen((o) => !o), children: trigger }),
|
|
9994
|
-
open ? /* @__PURE__ */ jsx(
|
|
9995
|
-
"div",
|
|
9996
|
-
{
|
|
9997
|
-
role: "dialog",
|
|
9998
|
-
className: cx("klun-popover__panel", `klun-popover__panel--${align}`),
|
|
9999
|
-
style: { width },
|
|
10000
|
-
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
10001
|
-
}
|
|
10002
|
-
) : null
|
|
10003
|
-
] });
|
|
10004
|
-
});
|
|
10005
|
-
Popover.displayName = "Popover";
|
|
10006
10068
|
|
|
10007
|
-
export { Accordion, Alert, AutoComplete, Avatar, AvatarGroup, Badge, Banner, Breadcrumb, BulkAction, BulkActionBar, Button, ButtonGroup, Card, Carousel, Cascader, CharacterCounter, ChartLegend, ChartTooltip, Checkbox, CheckboxCard, Chip, CircularProgress, CodeViewer, Col, ColorDot, ColorPicker, ColorSlider, CommandMenu, CompactSelect, CompactSelectForInput, ConfigProvider, Confirm, ContentLabel, CopyButton, CounterInput, DatePicker, DateRangePicker, Descriptions, DigitInput, Divider, Drawer, Dropdown, ExpiryCountdown, FileUpload, Flex, Form, FormItem, FormList, Format, GaugeBar, Grid, Hint, HorizontalFilter, ImageUpload, InlineInput, InlineSelect, Input, Kbd, KeyIcon, Label, Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSider, List, ListItem, LiveDot, LogViewer, Masonry, Menu, Message, Modal, Money, Notification, Pagination, PasswordStrength, Popconfirm, Popover, ProgressBar, Radio, RadioCard, RangeSlider, Rating, RelativeTime, RichEditorToolbar, Row, SegmentedControl, SegmentedProgress, Select, SelectMenu, Skeleton, Slider, Space, Spinner2 as Spinner, Splitter2 as Splitter, SplitterPanel, Statistic, StatusBadge, StatusDot, StepIndicator, Switch, Table, Tabs, Tag, Textarea, TimePicker, Timeline, Toast, Toaster, Tooltip, Tree, Wizard, arSA, deDE, enUS, esES, fmt, frFR, idID, itIT, jaJP, koKR, locales, nlNL, plPL, primaryColorVars, ptBR, ruRU, toast, trTR, useBreakpoint, useConfig, useForm, useLocale, useMappedSize, useMessage, useNotification, useSize, viVN, zhCN, zhTW };
|
|
10008
|
-
//# sourceMappingURL=chunk-
|
|
10009
|
-
//# sourceMappingURL=chunk-
|
|
10069
|
+
export { Accordion, Alert, AutoComplete, Avatar, AvatarGroup, Badge, Banner, Breadcrumb, BulkAction, BulkActionBar, Button, ButtonGroup, Card, Carousel, Cascader, CharacterCounter, ChartLegend, ChartTooltip, Checkbox, CheckboxCard, Chip, CircularProgress, CodeViewer, Col, ColorDot, ColorPicker, ColorSlider, CommandMenu, CompactSelect, CompactSelectForInput, ConfigProvider, Confirm, ContentLabel, CopyButton, CounterInput, DatePicker, DateRangePicker, DateTimePicker, Descriptions, DigitInput, Divider, Drawer, Dropdown, ExpiryCountdown, FileUpload, Flex, Form, FormItem, FormList, Format, GaugeBar, Grid, Hint, HorizontalFilter, ImageUpload, InlineInput, InlineSelect, Input, Kbd, KeyIcon, Label, Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSider, List, ListItem, LiveDot, LogViewer, Masonry, Menu, Message, Modal, Money, Notification, Pagination, PasswordStrength, Popconfirm, Popover, ProgressBar, Radio, RadioCard, RangeSlider, Rating, RelativeTime, RichEditorToolbar, Row, SegmentedControl, SegmentedProgress, Select, SelectMenu, Skeleton, Slider, Space, Spinner2 as Spinner, Splitter2 as Splitter, SplitterPanel, Statistic, StatusBadge, StatusDot, StepIndicator, Switch, Table, Tabs, Tag, Textarea, TimePicker, Timeline, Toast, Toaster, Tooltip, Tree, Wizard, arSA, deDE, enUS, esES, fmt, frFR, idID, itIT, jaJP, koKR, locales, nlNL, plPL, primaryColorVars, ptBR, ruRU, toast, trTR, useBreakpoint, useConfig, useForm, useLocale, useMappedSize, useMessage, useNotification, useSize, viVN, zhCN, zhTW };
|
|
10070
|
+
//# sourceMappingURL=chunk-RRE3PQLX.js.map
|
|
10071
|
+
//# sourceMappingURL=chunk-RRE3PQLX.js.map
|