klun-ui 0.1.0 → 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/dist/{chunk-FTYQRXS5.cjs → chunk-2MTDM5CL.cjs} +298 -293
- package/dist/chunk-2MTDM5CL.cjs.map +1 -0
- package/dist/{chunk-XDAR7UMF.js → chunk-DVPY6FDU.js} +298 -293
- package/dist/chunk-DVPY6FDU.js.map +1 -0
- package/dist/index.cjs +143 -143
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +1 -1
- package/dist/styles.css +24 -0
- package/dist/templates/index.cjs +82 -82
- package/dist/templates/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-FTYQRXS5.cjs.map +0 -1
- package/dist/chunk-XDAR7UMF.js.map +0 -1
|
@@ -6681,193 +6681,322 @@ var CounterInput = react.forwardRef(function CounterInput2({
|
|
|
6681
6681
|
);
|
|
6682
6682
|
});
|
|
6683
6683
|
CounterInput.displayName = "CounterInput";
|
|
6684
|
-
var
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6684
|
+
var Input = react.forwardRef(function Input2({
|
|
6685
|
+
size: sizeProp,
|
|
6686
|
+
leadingIcon,
|
|
6687
|
+
trailingIcon,
|
|
6688
|
+
leadingNode,
|
|
6689
|
+
trailingNode,
|
|
6690
|
+
error = false,
|
|
6691
|
+
disabled = false,
|
|
6692
|
+
readOnly = false,
|
|
6693
|
+
loading = false,
|
|
6694
|
+
clearable = false,
|
|
6695
|
+
onClear,
|
|
6696
|
+
className,
|
|
6697
|
+
style,
|
|
6698
|
+
...props
|
|
6699
|
+
}, ref) {
|
|
6700
|
+
const size = useSize(sizeProp);
|
|
6701
|
+
const { input } = useLocale();
|
|
6702
|
+
const innerRef = react.useRef(null);
|
|
6703
|
+
const [hasValue, setHasValue] = react.useState(() => !!(props.value ?? props.defaultValue));
|
|
6704
|
+
react.useEffect(() => {
|
|
6705
|
+
if (props.value !== void 0) setHasValue(!!props.value);
|
|
6706
|
+
}, [props.value]);
|
|
6707
|
+
const setRef = (node) => {
|
|
6708
|
+
innerRef.current = node;
|
|
6709
|
+
if (typeof ref === "function") ref(node);
|
|
6710
|
+
else if (ref) ref.current = node;
|
|
6711
|
+
};
|
|
6712
|
+
const showClear = clearable && hasValue && !disabled && !readOnly && !loading;
|
|
6713
|
+
const clear = () => {
|
|
6714
|
+
const node = innerRef.current;
|
|
6715
|
+
if (node) {
|
|
6716
|
+
node.value = "";
|
|
6717
|
+
node.focus();
|
|
6718
|
+
}
|
|
6719
|
+
setHasValue(false);
|
|
6720
|
+
onClear?.();
|
|
6721
|
+
if (node) {
|
|
6722
|
+
props.onChange?.({
|
|
6723
|
+
...{},
|
|
6724
|
+
target: node,
|
|
6725
|
+
currentTarget: node
|
|
6726
|
+
});
|
|
6727
|
+
}
|
|
6728
|
+
};
|
|
6729
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6730
|
+
"div",
|
|
6731
|
+
{
|
|
6732
|
+
className: chunkTPGAXYFU_cjs.cx(
|
|
6733
|
+
"klun-input",
|
|
6734
|
+
`klun-input--${size}`,
|
|
6735
|
+
error && "klun-input--error",
|
|
6736
|
+
disabled && "klun-input--disabled",
|
|
6737
|
+
readOnly && "klun-input--readonly",
|
|
6738
|
+
className
|
|
6739
|
+
),
|
|
6740
|
+
style,
|
|
6741
|
+
children: [
|
|
6742
|
+
leadingIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__icon", children: leadingIcon }) : null,
|
|
6743
|
+
leadingNode,
|
|
6704
6744
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6745
|
+
"input",
|
|
6746
|
+
{
|
|
6747
|
+
ref: setRef,
|
|
6748
|
+
className: "klun-input__field",
|
|
6749
|
+
disabled,
|
|
6750
|
+
readOnly,
|
|
6751
|
+
...props,
|
|
6752
|
+
onChange: (e) => {
|
|
6753
|
+
setHasValue(!!e.target.value);
|
|
6754
|
+
props.onChange?.(e);
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
),
|
|
6758
|
+
showClear ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6705
6759
|
"button",
|
|
6706
6760
|
{
|
|
6707
6761
|
type: "button",
|
|
6708
|
-
className: "klun-
|
|
6709
|
-
onClick:
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
{
|
|
6713
|
-
d: "M12 6l-4 4 4 4",
|
|
6714
|
-
stroke: "currentColor",
|
|
6715
|
-
strokeWidth: "1.5",
|
|
6716
|
-
strokeLinecap: "round",
|
|
6717
|
-
strokeLinejoin: "round"
|
|
6718
|
-
}
|
|
6719
|
-
) })
|
|
6762
|
+
className: "klun-input__clear",
|
|
6763
|
+
onClick: clear,
|
|
6764
|
+
"aria-label": input.clear,
|
|
6765
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-close-circle-fill" })
|
|
6720
6766
|
}
|
|
6721
|
-
),
|
|
6722
|
-
|
|
6723
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6767
|
+
) : null,
|
|
6768
|
+
trailingNode,
|
|
6769
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__spinner", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "klun-input__spinner-svg", width: 18, height: 18, viewBox: "0 0 20 20", fill: "none", children: [
|
|
6770
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "2.5" }),
|
|
6771
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeDasharray: "44", strokeDashoffset: "31" })
|
|
6772
|
+
] }) }) : trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__icon", children: trailingIcon }) : null
|
|
6773
|
+
]
|
|
6774
|
+
}
|
|
6775
|
+
);
|
|
6776
|
+
});
|
|
6777
|
+
Input.displayName = "Input";
|
|
6778
|
+
var Popover = react.forwardRef(function Popover2({ trigger, children, align = "left", width = 280, className, ...props }, ref) {
|
|
6779
|
+
const [open, setOpen] = react.useState(false);
|
|
6780
|
+
const innerRef = react.useRef(null);
|
|
6781
|
+
react.useEffect(() => {
|
|
6782
|
+
if (!open) return;
|
|
6783
|
+
const h = (e) => {
|
|
6784
|
+
if (innerRef.current && !innerRef.current.contains(e.target)) setOpen(false);
|
|
6785
|
+
};
|
|
6786
|
+
document.addEventListener("mousedown", h);
|
|
6787
|
+
return () => document.removeEventListener("mousedown", h);
|
|
6788
|
+
}, [open]);
|
|
6789
|
+
const setRefs = (node) => {
|
|
6790
|
+
innerRef.current = node;
|
|
6791
|
+
if (typeof ref === "function") ref(node);
|
|
6792
|
+
else if (ref) ref.current = node;
|
|
6793
|
+
};
|
|
6794
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: setRefs, className: chunkTPGAXYFU_cjs.cx("klun-popover", className), ...props, children: [
|
|
6795
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-popover__trigger", onClick: () => setOpen((o) => !o), children: trigger }),
|
|
6796
|
+
open ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6797
|
+
"div",
|
|
6798
|
+
{
|
|
6799
|
+
role: "dialog",
|
|
6800
|
+
className: chunkTPGAXYFU_cjs.cx("klun-popover__panel", `klun-popover__panel--${align}`),
|
|
6801
|
+
style: { width },
|
|
6802
|
+
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
6803
|
+
}
|
|
6804
|
+
) : null
|
|
6805
|
+
] });
|
|
6806
|
+
});
|
|
6807
|
+
Popover.displayName = "Popover";
|
|
6808
|
+
var same = (a, b) => !!a && !!b && a.toDateString() === b.toDateString();
|
|
6809
|
+
var DEFAULT_FORMAT = {
|
|
6810
|
+
year: "numeric",
|
|
6811
|
+
month: "short",
|
|
6812
|
+
day: "numeric"
|
|
6813
|
+
};
|
|
6814
|
+
var Calendar = react.forwardRef(function Calendar2({ value, onPick, className, style }, ref) {
|
|
6815
|
+
const { datePicker } = useLocale();
|
|
6816
|
+
const initial = value ? new Date(value) : /* @__PURE__ */ new Date();
|
|
6817
|
+
const [view, setView] = react.useState(new Date(initial.getFullYear(), initial.getMonth(), 1));
|
|
6818
|
+
const sel = value ? new Date(value) : null;
|
|
6819
|
+
const y = view.getFullYear();
|
|
6820
|
+
const m = view.getMonth();
|
|
6821
|
+
const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
|
|
6822
|
+
const daysInMonth = new Date(y, m + 1, 0).getDate();
|
|
6823
|
+
const today = /* @__PURE__ */ new Date();
|
|
6824
|
+
today.setHours(0, 0, 0, 0);
|
|
6825
|
+
const cells = [];
|
|
6826
|
+
for (let i = 0; i < firstDay; i++) cells.push(null);
|
|
6827
|
+
for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
|
|
6828
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-date-picker", className), style, children: [
|
|
6829
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-date-picker__header", children: [
|
|
6830
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "klun-date-picker__nav", onClick: () => setView(new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 6l-4 4 4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
6831
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-date-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
6832
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "klun-date-picker__nav", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 6l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
6833
|
+
] }),
|
|
6834
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-date-picker__grid", children: [
|
|
6835
|
+
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-date-picker__weekday", children: d }, i)),
|
|
6836
|
+
cells.map((date, i) => {
|
|
6837
|
+
if (!date) return /* @__PURE__ */ jsxRuntime.jsx("span", {}, i);
|
|
6838
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6724
6839
|
"button",
|
|
6725
6840
|
{
|
|
6726
6841
|
type: "button",
|
|
6727
|
-
className: "klun-date-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6842
|
+
className: "klun-date-picker__day",
|
|
6843
|
+
"data-selected": same(date, sel) || void 0,
|
|
6844
|
+
"data-today": same(date, today) || void 0,
|
|
6845
|
+
onClick: () => onPick(date),
|
|
6846
|
+
children: date.getDate()
|
|
6847
|
+
},
|
|
6848
|
+
i
|
|
6849
|
+
);
|
|
6850
|
+
})
|
|
6851
|
+
] })
|
|
6852
|
+
] });
|
|
6853
|
+
});
|
|
6854
|
+
var DatePicker = react.forwardRef(
|
|
6855
|
+
function DatePicker2({ value, onChange, inline, placeholder, format = DEFAULT_FORMAT, align = "left", disabled, className, style, ...props }, ref) {
|
|
6856
|
+
if (inline) {
|
|
6857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Calendar, { ref, value, onPick: (d) => onChange?.(d), className, style });
|
|
6858
|
+
}
|
|
6859
|
+
const sel = value ? new Date(value) : null;
|
|
6860
|
+
const label = sel ? sel.toLocaleDateString(void 0, format) : "";
|
|
6861
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-date-field", className), style, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6862
|
+
Popover,
|
|
6863
|
+
{
|
|
6864
|
+
align,
|
|
6865
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6866
|
+
Input,
|
|
6867
|
+
{
|
|
6868
|
+
readOnly: true,
|
|
6869
|
+
disabled,
|
|
6870
|
+
value: label,
|
|
6871
|
+
placeholder: placeholder ?? "Select date",
|
|
6872
|
+
leadingIcon: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-calendar-line" }),
|
|
6873
|
+
trailingIcon: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-arrow-down-s-line" }),
|
|
6874
|
+
style: { width: "100%", cursor: "pointer" }
|
|
6875
|
+
}
|
|
6876
|
+
),
|
|
6877
|
+
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6878
|
+
Calendar,
|
|
6879
|
+
{
|
|
6880
|
+
className: "klun-date-picker--bare",
|
|
6881
|
+
value,
|
|
6882
|
+
onPick: (d) => {
|
|
6883
|
+
onChange?.(d);
|
|
6884
|
+
close();
|
|
6885
|
+
}
|
|
6739
6886
|
}
|
|
6740
6887
|
)
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-date-picker__weekday", children: d }, i)),
|
|
6744
|
-
cells.map((date, i) => {
|
|
6745
|
-
if (!date) return /* @__PURE__ */ jsxRuntime.jsx("span", {}, i);
|
|
6746
|
-
const isSel = same(date, sel);
|
|
6747
|
-
const isToday = same(date, today);
|
|
6748
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6749
|
-
"button",
|
|
6750
|
-
{
|
|
6751
|
-
type: "button",
|
|
6752
|
-
className: "klun-date-picker__day",
|
|
6753
|
-
"data-selected": isSel || void 0,
|
|
6754
|
-
"data-today": isToday || void 0,
|
|
6755
|
-
onClick: () => onChange?.(date),
|
|
6756
|
-
children: date.getDate()
|
|
6757
|
-
},
|
|
6758
|
-
i
|
|
6759
|
-
);
|
|
6760
|
-
})
|
|
6761
|
-
] })
|
|
6762
|
-
] });
|
|
6888
|
+
}
|
|
6889
|
+
) });
|
|
6763
6890
|
}
|
|
6764
6891
|
);
|
|
6765
6892
|
DatePicker.displayName = "DatePicker";
|
|
6766
6893
|
var norm = (d) => d && new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
6767
|
-
var
|
|
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
|
-
|
|
6806
|
-
|
|
6807
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6808
|
-
"path",
|
|
6809
|
-
{
|
|
6810
|
-
d: "M12 6l-4 4 4 4",
|
|
6811
|
-
stroke: "currentColor",
|
|
6812
|
-
strokeWidth: "1.5",
|
|
6813
|
-
strokeLinecap: "round",
|
|
6814
|
-
strokeLinejoin: "round"
|
|
6815
|
-
}
|
|
6816
|
-
) })
|
|
6817
|
-
}
|
|
6818
|
-
),
|
|
6819
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-date-range-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
6820
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6894
|
+
var DEFAULT_FORMAT2 = { month: "short", day: "numeric" };
|
|
6895
|
+
var RangeCalendar = react.forwardRef(function RangeCalendar2({ start, end, onPick, className, style }, ref) {
|
|
6896
|
+
const { datePicker } = useLocale();
|
|
6897
|
+
const base = start ? new Date(start) : /* @__PURE__ */ new Date();
|
|
6898
|
+
const [view, setView] = react.useState(new Date(base.getFullYear(), base.getMonth(), 1));
|
|
6899
|
+
const s = start ? new Date(start) : null;
|
|
6900
|
+
const e = end ? new Date(end) : null;
|
|
6901
|
+
const y = view.getFullYear();
|
|
6902
|
+
const m = view.getMonth();
|
|
6903
|
+
const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
|
|
6904
|
+
const daysInMonth = new Date(y, m + 1, 0).getDate();
|
|
6905
|
+
const cells = [];
|
|
6906
|
+
for (let i = 0; i < firstDay; i++) cells.push(null);
|
|
6907
|
+
for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
|
|
6908
|
+
const pick = (d) => {
|
|
6909
|
+
if (!s || s && e) return onPick({ start: d, end: null });
|
|
6910
|
+
if (norm(d) < norm(s)) return onPick({ start: d, end: s });
|
|
6911
|
+
onPick({ start: s, end: d });
|
|
6912
|
+
};
|
|
6913
|
+
const inRange = (d) => !!s && !!e && norm(d) > norm(s) && norm(d) < norm(e);
|
|
6914
|
+
const isStart = (d) => !!s && norm(d) === norm(s);
|
|
6915
|
+
const isEnd = (d) => !!e && norm(d) === norm(e);
|
|
6916
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-date-range-picker", className), style, children: [
|
|
6917
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-date-range-picker__header", children: [
|
|
6918
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "klun-date-range-picker__nav", onClick: () => setView(new Date(y, m - 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 6l-4 4 4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
6919
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-date-range-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
|
|
6920
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "klun-date-range-picker__nav", onClick: () => setView(new Date(y, m + 1, 1)), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 6l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
6921
|
+
] }),
|
|
6922
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "klun-date-range-picker__grid", children: [
|
|
6923
|
+
datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "klun-date-range-picker__weekday", children: d }, i)),
|
|
6924
|
+
cells.map((date, i) => {
|
|
6925
|
+
if (!date) return /* @__PURE__ */ jsxRuntime.jsx("span", {}, i);
|
|
6926
|
+
const mid = inRange(date);
|
|
6927
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6928
|
+
"div",
|
|
6929
|
+
{
|
|
6930
|
+
className: "klun-date-range-picker__cell",
|
|
6931
|
+
"data-in-range": mid || void 0,
|
|
6932
|
+
"data-range-edge": isStart(date) || isEnd(date) || void 0,
|
|
6933
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6821
6934
|
"button",
|
|
6822
6935
|
{
|
|
6823
6936
|
type: "button",
|
|
6824
|
-
className: "klun-date-range-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
stroke: "currentColor",
|
|
6831
|
-
strokeWidth: "1.5",
|
|
6832
|
-
strokeLinecap: "round",
|
|
6833
|
-
strokeLinejoin: "round"
|
|
6834
|
-
}
|
|
6835
|
-
) })
|
|
6937
|
+
className: "klun-date-range-picker__day",
|
|
6938
|
+
"data-range-start": isStart(date) || void 0,
|
|
6939
|
+
"data-range-end": isEnd(date) || void 0,
|
|
6940
|
+
"data-in-range": mid || void 0,
|
|
6941
|
+
onClick: () => pick(date),
|
|
6942
|
+
children: date.getDate()
|
|
6836
6943
|
}
|
|
6837
6944
|
)
|
|
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
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6945
|
+
},
|
|
6946
|
+
i
|
|
6947
|
+
);
|
|
6948
|
+
})
|
|
6949
|
+
] })
|
|
6950
|
+
] });
|
|
6951
|
+
});
|
|
6952
|
+
var DateRangePicker = react.forwardRef(
|
|
6953
|
+
function DateRangePicker2({ start, end, onChange, inline, placeholder, format = DEFAULT_FORMAT2, align = "left", disabled, className, style, ...props }, ref) {
|
|
6954
|
+
if (inline) {
|
|
6955
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6956
|
+
RangeCalendar,
|
|
6957
|
+
{
|
|
6958
|
+
ref,
|
|
6959
|
+
start,
|
|
6960
|
+
end,
|
|
6961
|
+
onPick: (r) => onChange?.(r),
|
|
6962
|
+
className,
|
|
6963
|
+
style
|
|
6964
|
+
}
|
|
6965
|
+
);
|
|
6966
|
+
}
|
|
6967
|
+
const f = (d) => d ? new Date(d).toLocaleDateString(void 0, format) : "";
|
|
6968
|
+
const label = start || end ? `${f(start)} \u2013 ${f(end)}` : "";
|
|
6969
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: chunkTPGAXYFU_cjs.cx("klun-date-range-field", className), style, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6970
|
+
Popover,
|
|
6971
|
+
{
|
|
6972
|
+
align,
|
|
6973
|
+
width: 300,
|
|
6974
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6975
|
+
Input,
|
|
6976
|
+
{
|
|
6977
|
+
readOnly: true,
|
|
6978
|
+
disabled,
|
|
6979
|
+
value: label,
|
|
6980
|
+
placeholder: placeholder ?? "Select range",
|
|
6981
|
+
leadingIcon: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-calendar-2-line" }),
|
|
6982
|
+
trailingIcon: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-arrow-down-s-line" }),
|
|
6983
|
+
style: { width: "100%", cursor: "pointer" }
|
|
6984
|
+
}
|
|
6985
|
+
),
|
|
6986
|
+
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6987
|
+
RangeCalendar,
|
|
6988
|
+
{
|
|
6989
|
+
className: "klun-date-range-picker--bare",
|
|
6990
|
+
start,
|
|
6991
|
+
end,
|
|
6992
|
+
onPick: (r) => {
|
|
6993
|
+
onChange?.(r);
|
|
6994
|
+
if (r.start && r.end) close();
|
|
6995
|
+
}
|
|
6996
|
+
}
|
|
6997
|
+
)
|
|
6869
6998
|
}
|
|
6870
|
-
);
|
|
6999
|
+
) });
|
|
6871
7000
|
}
|
|
6872
7001
|
);
|
|
6873
7002
|
DateRangePicker.displayName = "DateRangePicker";
|
|
@@ -7538,100 +7667,6 @@ var InlineSelect = react.forwardRef(
|
|
|
7538
7667
|
}
|
|
7539
7668
|
);
|
|
7540
7669
|
InlineSelect.displayName = "InlineSelect";
|
|
7541
|
-
var Input = react.forwardRef(function Input2({
|
|
7542
|
-
size: sizeProp,
|
|
7543
|
-
leadingIcon,
|
|
7544
|
-
trailingIcon,
|
|
7545
|
-
leadingNode,
|
|
7546
|
-
trailingNode,
|
|
7547
|
-
error = false,
|
|
7548
|
-
disabled = false,
|
|
7549
|
-
readOnly = false,
|
|
7550
|
-
loading = false,
|
|
7551
|
-
clearable = false,
|
|
7552
|
-
onClear,
|
|
7553
|
-
className,
|
|
7554
|
-
style,
|
|
7555
|
-
...props
|
|
7556
|
-
}, ref) {
|
|
7557
|
-
const size = useSize(sizeProp);
|
|
7558
|
-
const { input } = useLocale();
|
|
7559
|
-
const innerRef = react.useRef(null);
|
|
7560
|
-
const [hasValue, setHasValue] = react.useState(() => !!(props.value ?? props.defaultValue));
|
|
7561
|
-
react.useEffect(() => {
|
|
7562
|
-
if (props.value !== void 0) setHasValue(!!props.value);
|
|
7563
|
-
}, [props.value]);
|
|
7564
|
-
const setRef = (node) => {
|
|
7565
|
-
innerRef.current = node;
|
|
7566
|
-
if (typeof ref === "function") ref(node);
|
|
7567
|
-
else if (ref) ref.current = node;
|
|
7568
|
-
};
|
|
7569
|
-
const showClear = clearable && hasValue && !disabled && !readOnly && !loading;
|
|
7570
|
-
const clear = () => {
|
|
7571
|
-
const node = innerRef.current;
|
|
7572
|
-
if (node) {
|
|
7573
|
-
node.value = "";
|
|
7574
|
-
node.focus();
|
|
7575
|
-
}
|
|
7576
|
-
setHasValue(false);
|
|
7577
|
-
onClear?.();
|
|
7578
|
-
if (node) {
|
|
7579
|
-
props.onChange?.({
|
|
7580
|
-
...{},
|
|
7581
|
-
target: node,
|
|
7582
|
-
currentTarget: node
|
|
7583
|
-
});
|
|
7584
|
-
}
|
|
7585
|
-
};
|
|
7586
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7587
|
-
"div",
|
|
7588
|
-
{
|
|
7589
|
-
className: chunkTPGAXYFU_cjs.cx(
|
|
7590
|
-
"klun-input",
|
|
7591
|
-
`klun-input--${size}`,
|
|
7592
|
-
error && "klun-input--error",
|
|
7593
|
-
disabled && "klun-input--disabled",
|
|
7594
|
-
readOnly && "klun-input--readonly",
|
|
7595
|
-
className
|
|
7596
|
-
),
|
|
7597
|
-
style,
|
|
7598
|
-
children: [
|
|
7599
|
-
leadingIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__icon", children: leadingIcon }) : null,
|
|
7600
|
-
leadingNode,
|
|
7601
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7602
|
-
"input",
|
|
7603
|
-
{
|
|
7604
|
-
ref: setRef,
|
|
7605
|
-
className: "klun-input__field",
|
|
7606
|
-
disabled,
|
|
7607
|
-
readOnly,
|
|
7608
|
-
...props,
|
|
7609
|
-
onChange: (e) => {
|
|
7610
|
-
setHasValue(!!e.target.value);
|
|
7611
|
-
props.onChange?.(e);
|
|
7612
|
-
}
|
|
7613
|
-
}
|
|
7614
|
-
),
|
|
7615
|
-
showClear ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
7616
|
-
"button",
|
|
7617
|
-
{
|
|
7618
|
-
type: "button",
|
|
7619
|
-
className: "klun-input__clear",
|
|
7620
|
-
onClick: clear,
|
|
7621
|
-
"aria-label": input.clear,
|
|
7622
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: "ri-close-circle-fill" })
|
|
7623
|
-
}
|
|
7624
|
-
) : null,
|
|
7625
|
-
trailingNode,
|
|
7626
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__spinner", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "klun-input__spinner-svg", width: 18, height: 18, viewBox: "0 0 20 20", fill: "none", children: [
|
|
7627
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeOpacity: "0.25", strokeWidth: "2.5" }),
|
|
7628
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "10", cy: "10", r: "7", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeDasharray: "44", strokeDashoffset: "31" })
|
|
7629
|
-
] }) }) : trailingIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-input__icon", children: trailingIcon }) : null
|
|
7630
|
-
]
|
|
7631
|
-
}
|
|
7632
|
-
);
|
|
7633
|
-
});
|
|
7634
|
-
Input.displayName = "Input";
|
|
7635
7670
|
var Label = react.forwardRef(function Label2({ children, required = false, sublabel, disabled = false, className, ...props }, ref) {
|
|
7636
7671
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7637
7672
|
"label",
|
|
@@ -9975,36 +10010,6 @@ var Popconfirm = react.forwardRef(function Popconfirm2({
|
|
|
9975
10010
|
] });
|
|
9976
10011
|
});
|
|
9977
10012
|
Popconfirm.displayName = "Popconfirm";
|
|
9978
|
-
var Popover = react.forwardRef(function Popover2({ trigger, children, align = "left", width = 280, className, ...props }, ref) {
|
|
9979
|
-
const [open, setOpen] = react.useState(false);
|
|
9980
|
-
const innerRef = react.useRef(null);
|
|
9981
|
-
react.useEffect(() => {
|
|
9982
|
-
if (!open) return;
|
|
9983
|
-
const h = (e) => {
|
|
9984
|
-
if (innerRef.current && !innerRef.current.contains(e.target)) setOpen(false);
|
|
9985
|
-
};
|
|
9986
|
-
document.addEventListener("mousedown", h);
|
|
9987
|
-
return () => document.removeEventListener("mousedown", h);
|
|
9988
|
-
}, [open]);
|
|
9989
|
-
const setRefs = (node) => {
|
|
9990
|
-
innerRef.current = node;
|
|
9991
|
-
if (typeof ref === "function") ref(node);
|
|
9992
|
-
else if (ref) ref.current = node;
|
|
9993
|
-
};
|
|
9994
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: setRefs, className: chunkTPGAXYFU_cjs.cx("klun-popover", className), ...props, children: [
|
|
9995
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "klun-popover__trigger", onClick: () => setOpen((o) => !o), children: trigger }),
|
|
9996
|
-
open ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
9997
|
-
"div",
|
|
9998
|
-
{
|
|
9999
|
-
role: "dialog",
|
|
10000
|
-
className: chunkTPGAXYFU_cjs.cx("klun-popover__panel", `klun-popover__panel--${align}`),
|
|
10001
|
-
style: { width },
|
|
10002
|
-
children: typeof children === "function" ? children(() => setOpen(false)) : children
|
|
10003
|
-
}
|
|
10004
|
-
) : null
|
|
10005
|
-
] });
|
|
10006
|
-
});
|
|
10007
|
-
Popover.displayName = "Popover";
|
|
10008
10013
|
|
|
10009
10014
|
exports.Accordion = Accordion;
|
|
10010
10015
|
exports.Alert = Alert;
|
|
@@ -10148,5 +10153,5 @@ exports.useSize = useSize;
|
|
|
10148
10153
|
exports.viVN = viVN;
|
|
10149
10154
|
exports.zhCN = zhCN;
|
|
10150
10155
|
exports.zhTW = zhTW;
|
|
10151
|
-
//# sourceMappingURL=chunk-
|
|
10152
|
-
//# sourceMappingURL=chunk-
|
|
10156
|
+
//# sourceMappingURL=chunk-2MTDM5CL.cjs.map
|
|
10157
|
+
//# sourceMappingURL=chunk-2MTDM5CL.cjs.map
|