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.
@@ -6679,193 +6679,322 @@ var CounterInput = forwardRef(function CounterInput2({
6679
6679
  );
6680
6680
  });
6681
6681
  CounterInput.displayName = "CounterInput";
6682
- var same = (a, b) => !!a && !!b && a.toDateString() === b.toDateString();
6683
- var DatePicker = forwardRef(
6684
- function DatePicker2({ value, onChange, className, style, ...props }, ref) {
6685
- const { datePicker } = useLocale();
6686
- const initial = value ? new Date(value) : /* @__PURE__ */ new Date();
6687
- const [view, setView] = useState(
6688
- new Date(initial.getFullYear(), initial.getMonth(), 1)
6689
- );
6690
- const sel = value ? new Date(value) : null;
6691
- const y = view.getFullYear();
6692
- const m = view.getMonth();
6693
- const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
6694
- const daysInMonth = new Date(y, m + 1, 0).getDate();
6695
- const today = /* @__PURE__ */ new Date();
6696
- today.setHours(0, 0, 0, 0);
6697
- const cells = [];
6698
- for (let i = 0; i < firstDay; i++) cells.push(null);
6699
- for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
6700
- return /* @__PURE__ */ jsxs("div", { ref, className: cx("klun-date-picker", className), style, ...props, children: [
6701
- /* @__PURE__ */ jsxs("div", { className: "klun-date-picker__header", children: [
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,
6702
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(
6703
6757
  "button",
6704
6758
  {
6705
6759
  type: "button",
6706
- className: "klun-date-picker__nav",
6707
- onClick: () => setView(new Date(y, m - 1, 1)),
6708
- children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
6709
- "path",
6710
- {
6711
- d: "M12 6l-4 4 4 4",
6712
- stroke: "currentColor",
6713
- strokeWidth: "1.5",
6714
- strokeLinecap: "round",
6715
- strokeLinejoin: "round"
6716
- }
6717
- ) })
6760
+ className: "klun-input__clear",
6761
+ onClick: clear,
6762
+ "aria-label": input.clear,
6763
+ children: /* @__PURE__ */ jsx("i", { className: "ri-close-circle-fill" })
6718
6764
  }
6719
- ),
6720
- /* @__PURE__ */ jsx("span", { className: "klun-date-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
6721
- /* @__PURE__ */ jsx(
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";
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(
6722
6837
  "button",
6723
6838
  {
6724
6839
  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
- ) })
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
+ });
6852
+ var DatePicker = forwardRef(
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
+ }
6857
+ const sel = value ? new Date(value) : null;
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
+ }
6737
6884
  }
6738
6885
  )
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
- ] });
6886
+ }
6887
+ ) });
6761
6888
  }
6762
6889
  );
6763
6890
  DatePicker.displayName = "DatePicker";
6764
6891
  var norm = (d) => d && new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
6765
- var DateRangePicker = forwardRef(
6766
- function DateRangePicker2({ start, end, onChange, className, style, ...props }, ref) {
6767
- const { datePicker } = useLocale();
6768
- const base = start ? new Date(start) : /* @__PURE__ */ new Date();
6769
- const [view, setView] = useState(
6770
- new Date(base.getFullYear(), base.getMonth(), 1)
6771
- );
6772
- const s = start ? new Date(start) : null;
6773
- const e = end ? new Date(end) : null;
6774
- const y = view.getFullYear();
6775
- const m = view.getMonth();
6776
- const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
6777
- const daysInMonth = new Date(y, m + 1, 0).getDate();
6778
- const cells = [];
6779
- for (let i = 0; i < firstDay; i++) cells.push(null);
6780
- for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
6781
- const pick = (d) => {
6782
- if (!s || s && e) return onChange?.({ start: d, end: null });
6783
- if (norm(d) < norm(s)) return onChange?.({ start: d, end: s });
6784
- onChange?.({ start: s, end: d });
6785
- };
6786
- const inRange = (d) => !!s && !!e && norm(d) > norm(s) && norm(d) < norm(e);
6787
- const isStart = (d) => !!s && norm(d) === norm(s);
6788
- const isEnd = (d) => !!e && norm(d) === norm(e);
6789
- const isEdge = (d) => isStart(d) || isEnd(d);
6790
- return /* @__PURE__ */ jsxs(
6791
- "div",
6792
- {
6793
- ref,
6794
- className: cx("klun-date-range-picker", className),
6795
- style,
6796
- ...props,
6797
- children: [
6798
- /* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__header", children: [
6799
- /* @__PURE__ */ jsx(
6800
- "button",
6801
- {
6802
- type: "button",
6803
- className: "klun-date-range-picker__nav",
6804
- onClick: () => setView(new Date(y, m - 1, 1)),
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(
6892
+ var DEFAULT_FORMAT2 = { month: "short", day: "numeric" };
6893
+ var RangeCalendar = forwardRef(function RangeCalendar2({ start, end, onPick, className, style }, ref) {
6894
+ const { datePicker } = useLocale();
6895
+ const base = start ? new Date(start) : /* @__PURE__ */ new Date();
6896
+ const [view, setView] = useState(new Date(base.getFullYear(), base.getMonth(), 1));
6897
+ const s = start ? new Date(start) : null;
6898
+ const e = end ? new Date(end) : null;
6899
+ const y = view.getFullYear();
6900
+ const m = view.getMonth();
6901
+ const firstDay = (new Date(y, m, 1).getDay() + 6) % 7;
6902
+ const daysInMonth = new Date(y, m + 1, 0).getDate();
6903
+ const cells = [];
6904
+ for (let i = 0; i < firstDay; i++) cells.push(null);
6905
+ for (let d = 1; d <= daysInMonth; d++) cells.push(new Date(y, m, d));
6906
+ const pick = (d) => {
6907
+ if (!s || s && e) return onPick({ start: d, end: null });
6908
+ if (norm(d) < norm(s)) return onPick({ start: d, end: s });
6909
+ onPick({ start: s, end: d });
6910
+ };
6911
+ const inRange = (d) => !!s && !!e && norm(d) > norm(s) && norm(d) < norm(e);
6912
+ const isStart = (d) => !!s && norm(d) === norm(s);
6913
+ const isEnd = (d) => !!e && norm(d) === norm(e);
6914
+ return /* @__PURE__ */ jsxs("div", { ref, className: cx("klun-date-range-picker", className), style, children: [
6915
+ /* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__header", children: [
6916
+ /* @__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" }) }) }),
6917
+ /* @__PURE__ */ jsx("span", { className: "klun-date-range-picker__title", children: fmt(datePicker.title, { month: datePicker.months[m], year: y }) }),
6918
+ /* @__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" }) }) })
6919
+ ] }),
6920
+ /* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__grid", children: [
6921
+ datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsx("div", { className: "klun-date-range-picker__weekday", children: d }, i)),
6922
+ cells.map((date, i) => {
6923
+ if (!date) return /* @__PURE__ */ jsx("span", {}, i);
6924
+ const mid = inRange(date);
6925
+ return /* @__PURE__ */ jsx(
6926
+ "div",
6927
+ {
6928
+ className: "klun-date-range-picker__cell",
6929
+ "data-in-range": mid || void 0,
6930
+ "data-range-edge": isStart(date) || isEnd(date) || void 0,
6931
+ children: /* @__PURE__ */ jsx(
6819
6932
  "button",
6820
6933
  {
6821
6934
  type: "button",
6822
- className: "klun-date-range-picker__nav",
6823
- onClick: () => setView(new Date(y, m + 1, 1)),
6824
- children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ jsx(
6825
- "path",
6826
- {
6827
- d: "M8 6l4 4-4 4",
6828
- stroke: "currentColor",
6829
- strokeWidth: "1.5",
6830
- strokeLinecap: "round",
6831
- strokeLinejoin: "round"
6832
- }
6833
- ) })
6935
+ className: "klun-date-range-picker__day",
6936
+ "data-range-start": isStart(date) || void 0,
6937
+ "data-range-end": isEnd(date) || void 0,
6938
+ "data-in-range": mid || void 0,
6939
+ onClick: () => pick(date),
6940
+ children: date.getDate()
6834
6941
  }
6835
6942
  )
6836
- ] }),
6837
- /* @__PURE__ */ jsxs("div", { className: "klun-date-range-picker__grid", children: [
6838
- datePicker.weekdaysShort.map((d, i) => /* @__PURE__ */ jsx("div", { className: "klun-date-range-picker__weekday", children: d }, i)),
6839
- cells.map((date, i) => {
6840
- if (!date) return /* @__PURE__ */ jsx("span", {}, i);
6841
- const edge = isEdge(date);
6842
- const mid = inRange(date);
6843
- return /* @__PURE__ */ jsx(
6844
- "div",
6845
- {
6846
- className: "klun-date-range-picker__cell",
6847
- "data-in-range": mid || void 0,
6848
- "data-range-edge": edge || void 0,
6849
- children: /* @__PURE__ */ jsx(
6850
- "button",
6851
- {
6852
- type: "button",
6853
- className: "klun-date-range-picker__day",
6854
- "data-range-start": isStart(date) || void 0,
6855
- "data-range-end": isEnd(date) || void 0,
6856
- "data-in-range": mid || void 0,
6857
- onClick: () => pick(date),
6858
- children: date.getDate()
6859
- }
6860
- )
6861
- },
6862
- i
6863
- );
6864
- })
6865
- ] })
6866
- ]
6943
+ },
6944
+ i
6945
+ );
6946
+ })
6947
+ ] })
6948
+ ] });
6949
+ });
6950
+ var DateRangePicker = forwardRef(
6951
+ function DateRangePicker2({ start, end, onChange, inline, placeholder, format = DEFAULT_FORMAT2, align = "left", disabled, className, style, ...props }, ref) {
6952
+ if (inline) {
6953
+ return /* @__PURE__ */ jsx(
6954
+ RangeCalendar,
6955
+ {
6956
+ ref,
6957
+ start,
6958
+ end,
6959
+ onPick: (r) => onChange?.(r),
6960
+ className,
6961
+ style
6962
+ }
6963
+ );
6964
+ }
6965
+ const f = (d) => d ? new Date(d).toLocaleDateString(void 0, format) : "";
6966
+ const label = start || end ? `${f(start)} \u2013 ${f(end)}` : "";
6967
+ return /* @__PURE__ */ jsx("div", { ref, className: cx("klun-date-range-field", className), style, ...props, children: /* @__PURE__ */ jsx(
6968
+ Popover,
6969
+ {
6970
+ align,
6971
+ width: 300,
6972
+ trigger: /* @__PURE__ */ jsx(
6973
+ Input,
6974
+ {
6975
+ readOnly: true,
6976
+ disabled,
6977
+ value: label,
6978
+ placeholder: placeholder ?? "Select range",
6979
+ leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-calendar-2-line" }),
6980
+ trailingIcon: /* @__PURE__ */ jsx("i", { className: "ri-arrow-down-s-line" }),
6981
+ style: { width: "100%", cursor: "pointer" }
6982
+ }
6983
+ ),
6984
+ children: (close) => /* @__PURE__ */ jsx(
6985
+ RangeCalendar,
6986
+ {
6987
+ className: "klun-date-range-picker--bare",
6988
+ start,
6989
+ end,
6990
+ onPick: (r) => {
6991
+ onChange?.(r);
6992
+ if (r.start && r.end) close();
6993
+ }
6994
+ }
6995
+ )
6867
6996
  }
6868
- );
6997
+ ) });
6869
6998
  }
6870
6999
  );
6871
7000
  DateRangePicker.displayName = "DateRangePicker";
@@ -7536,100 +7665,6 @@ var InlineSelect = forwardRef(
7536
7665
  }
7537
7666
  );
7538
7667
  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";
7633
7668
  var Label = forwardRef(function Label2({ children, required = false, sublabel, disabled = false, className, ...props }, ref) {
7634
7669
  return /* @__PURE__ */ jsxs(
7635
7670
  "label",
@@ -9973,37 +10008,7 @@ var Popconfirm = forwardRef(function Popconfirm2({
9973
10008
  ] });
9974
10009
  });
9975
10010
  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
10011
 
10007
10012
  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-XDAR7UMF.js.map
10009
- //# sourceMappingURL=chunk-XDAR7UMF.js.map
10013
+ //# sourceMappingURL=chunk-DVPY6FDU.js.map
10014
+ //# sourceMappingURL=chunk-DVPY6FDU.js.map