@geomak/ui 5.3.0 → 5.5.0

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/index.cjs CHANGED
@@ -16,6 +16,7 @@ var Popover = require('@radix-ui/react-popover');
16
16
  var SwitchPrimitive = require('@radix-ui/react-switch');
17
17
  var CheckboxPrimitive = require('@radix-ui/react-checkbox');
18
18
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
19
+ var SliderPrimitive = require('@radix-ui/react-slider');
19
20
 
20
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
22
 
@@ -49,6 +50,7 @@ var Popover__namespace = /*#__PURE__*/_interopNamespace(Popover);
49
50
  var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
50
51
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
51
52
  var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
53
+ var SliderPrimitive__namespace = /*#__PURE__*/_interopNamespace(SliderPrimitive);
52
54
 
53
55
  var Moon = ({ color = "gray" }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: color, viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: color, className: "w-8 h-8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" }) });
54
56
  var Sun = ({ color = "yellow" }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: color, viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: color, className: "w-8 h-8", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" }) });
@@ -1833,8 +1835,8 @@ function CatalogCarousel({ items, buttonText, onOpen }) {
1833
1835
  )
1834
1836
  ] }) });
1835
1837
  }
1836
- function Catalog({ display = "grid", items = [], buttonText, onOpen }) {
1837
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full", children: display === "grid" ? /* @__PURE__ */ jsxRuntime.jsx(CatalogGrid, { items, buttonText, onOpen }) : /* @__PURE__ */ jsxRuntime.jsx(CatalogCarousel, { items, buttonText, onOpen }) });
1838
+ function Catalog({ display: display2 = "grid", items = [], buttonText, onOpen }) {
1839
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full", children: display2 === "grid" ? /* @__PURE__ */ jsxRuntime.jsx(CatalogGrid, { items, buttonText, onOpen }) : /* @__PURE__ */ jsxRuntime.jsx(CatalogCarousel, { items, buttonText, onOpen }) });
1838
1840
  }
1839
1841
  function ContextMenu({ items, children }) {
1840
1842
  return /* @__PURE__ */ jsxRuntime.jsxs(ContextMenuPrimitive__namespace.Root, { children: [
@@ -4663,6 +4665,1017 @@ function ChevronLeft() {
4663
4665
  function ChevronRight3() {
4664
4666
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "w-4 h-4", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) });
4665
4667
  }
4668
+ var LINE_HEIGHT_PX = 21;
4669
+ function TextArea({
4670
+ value,
4671
+ onChange,
4672
+ onBlur,
4673
+ disabled,
4674
+ label,
4675
+ htmlFor,
4676
+ placeholder,
4677
+ name,
4678
+ layout = "vertical",
4679
+ size = "md",
4680
+ rows = 4,
4681
+ autoGrow = false,
4682
+ maxRows = 12,
4683
+ maxLength,
4684
+ showCount = false,
4685
+ resize,
4686
+ errorMessage,
4687
+ required,
4688
+ style,
4689
+ inputStyle
4690
+ }) {
4691
+ const errorId = React8.useId();
4692
+ const hasError = errorMessage != null;
4693
+ const ref = React8.useRef(null);
4694
+ React8.useLayoutEffect(() => {
4695
+ if (!autoGrow) return;
4696
+ const el = ref.current;
4697
+ if (!el) return;
4698
+ el.style.height = "auto";
4699
+ const maxH = maxRows * LINE_HEIGHT_PX + 16;
4700
+ el.style.height = `${Math.min(el.scrollHeight, maxH)}px`;
4701
+ el.style.overflowY = el.scrollHeight > maxH ? "auto" : "hidden";
4702
+ }, [value, autoGrow, maxRows]);
4703
+ const count = typeof value === "string" ? value.length : 0;
4704
+ const resizeClass = (resize ?? (autoGrow ? "none" : "vertical")) === "none" ? "resize-none" : (resize ?? "vertical") === "horizontal" ? "resize-x" : (resize ?? "vertical") === "both" ? "resize" : "resize-y";
4705
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4706
+ Field,
4707
+ {
4708
+ label,
4709
+ htmlFor,
4710
+ errorId,
4711
+ errorMessage,
4712
+ layout,
4713
+ required,
4714
+ children: [
4715
+ /* @__PURE__ */ jsxRuntime.jsx(
4716
+ "textarea",
4717
+ {
4718
+ ref,
4719
+ disabled,
4720
+ value,
4721
+ onChange,
4722
+ onBlur,
4723
+ name,
4724
+ id: htmlFor,
4725
+ rows,
4726
+ maxLength,
4727
+ placeholder: placeholder ?? "",
4728
+ "aria-invalid": hasError || void 0,
4729
+ "aria-describedby": hasError ? errorId : void 0,
4730
+ className: `${fieldShell({ size, hasError, disabled, sized: false })} px-3 py-2 leading-normal ${resizeClass}`,
4731
+ style: { ...style, ...inputStyle }
4732
+ }
4733
+ ),
4734
+ showCount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-right text-xs text-foreground-muted tabular-nums", children: maxLength != null ? `${count} / ${maxLength}` : count })
4735
+ ]
4736
+ }
4737
+ );
4738
+ }
4739
+ var SIZE = {
4740
+ sm: { h: "h-control-sm", text: "text-xs", pad: "px-2.5" },
4741
+ md: { h: "h-control-md", text: "text-sm", pad: "px-3.5" },
4742
+ lg: { h: "h-control-lg", text: "text-sm", pad: "px-4" }
4743
+ };
4744
+ function SegmentedControl({
4745
+ options,
4746
+ value,
4747
+ defaultValue,
4748
+ onChange,
4749
+ size = "md",
4750
+ fullWidth = false,
4751
+ disabled,
4752
+ "aria-label": ariaLabel
4753
+ }) {
4754
+ const sz = SIZE[size];
4755
+ return /* @__PURE__ */ jsxRuntime.jsx(
4756
+ ToggleGroup__namespace.Root,
4757
+ {
4758
+ type: "single",
4759
+ value,
4760
+ defaultValue,
4761
+ onValueChange: (v) => {
4762
+ if (v) onChange?.(v);
4763
+ },
4764
+ disabled,
4765
+ "aria-label": ariaLabel,
4766
+ className: [
4767
+ "inline-flex items-center gap-1 rounded-lg border border-border bg-surface-raised p-1",
4768
+ sz.h,
4769
+ fullWidth ? "flex w-full" : "",
4770
+ disabled ? "opacity-60 cursor-not-allowed" : ""
4771
+ ].filter(Boolean).join(" "),
4772
+ children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs(
4773
+ ToggleGroup__namespace.Item,
4774
+ {
4775
+ value: opt.value,
4776
+ disabled: opt.disabled,
4777
+ className: [
4778
+ "inline-flex items-center justify-center gap-1.5 rounded-md select-none whitespace-nowrap",
4779
+ "transition-colors duration-150 h-full",
4780
+ sz.text,
4781
+ sz.pad,
4782
+ fullWidth ? "flex-1" : "",
4783
+ // Resting: muted text, transparent. Hover lifts the text.
4784
+ "text-foreground-secondary hover:text-foreground",
4785
+ // Active: surface-white pill + accent text + subtle shadow.
4786
+ "data-[state=on]:bg-surface data-[state=on]:text-accent data-[state=on]:shadow-sm",
4787
+ "focus:outline-none focus-visible:ring-[3px] focus-visible:ring-focus-ring",
4788
+ "disabled:opacity-40 disabled:cursor-not-allowed"
4789
+ ].filter(Boolean).join(" "),
4790
+ children: [
4791
+ opt.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: opt.icon }),
4792
+ opt.label
4793
+ ]
4794
+ },
4795
+ opt.value
4796
+ ))
4797
+ }
4798
+ );
4799
+ }
4800
+ var TRACK_H = { sm: "h-1", md: "h-1.5", lg: "h-2" };
4801
+ var THUMB = { sm: "h-3.5 w-3.5", md: "h-4 w-4", lg: "h-5 w-5" };
4802
+ var toArray = (v) => v == null ? void 0 : Array.isArray(v) ? v : [v];
4803
+ function Slider({
4804
+ value,
4805
+ defaultValue,
4806
+ onChange,
4807
+ onChangeEnd,
4808
+ min = 0,
4809
+ max = 100,
4810
+ step = 1,
4811
+ label,
4812
+ showValue = false,
4813
+ formatValue = (n) => String(n),
4814
+ marks,
4815
+ tooltip = false,
4816
+ size = "md",
4817
+ disabled,
4818
+ errorMessage,
4819
+ name,
4820
+ htmlFor
4821
+ }) {
4822
+ const errorId = React8.useId();
4823
+ const hasError = errorMessage != null;
4824
+ const isRange = Array.isArray(value ?? defaultValue);
4825
+ const [internal, setInternal] = React8.useState(
4826
+ () => toArray(value) ?? toArray(defaultValue) ?? [min]
4827
+ );
4828
+ const current = toArray(value) ?? internal;
4829
+ const [dragging, setDragging] = React8.useState(false);
4830
+ const emit = (arr) => {
4831
+ setInternal(arr);
4832
+ const next = isRange ? [arr[0], arr[1]] : arr[0];
4833
+ onChange?.(next);
4834
+ };
4835
+ const valueText = current.map(formatValue).join(" \u2013 ");
4836
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { label: void 0, errorId, errorMessage, children: [
4837
+ (label || showValue) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
4838
+ label && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor, className: "text-sm font-medium text-foreground select-none", children: label }),
4839
+ showValue && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-foreground-secondary tabular-nums", children: valueText })
4840
+ ] }),
4841
+ /* @__PURE__ */ jsxRuntime.jsxs(
4842
+ SliderPrimitive__namespace.Root,
4843
+ {
4844
+ id: htmlFor,
4845
+ name,
4846
+ value: toArray(value),
4847
+ defaultValue: toArray(defaultValue),
4848
+ min,
4849
+ max,
4850
+ step,
4851
+ disabled,
4852
+ "aria-invalid": hasError || void 0,
4853
+ "aria-describedby": hasError ? errorId : void 0,
4854
+ onValueChange: (v) => {
4855
+ emit(v);
4856
+ setDragging(true);
4857
+ },
4858
+ onValueCommit: (v) => {
4859
+ setDragging(false);
4860
+ onChangeEnd?.(isRange ? [v[0], v[1]] : v[0]);
4861
+ },
4862
+ className: "relative flex items-center select-none touch-none w-full h-5",
4863
+ children: [
4864
+ /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: `relative grow rounded-full bg-surface-raised border border-border ${TRACK_H[size]}`, children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full rounded-full bg-accent" }) }),
4865
+ current.map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
4866
+ SliderPrimitive__namespace.Thumb,
4867
+ {
4868
+ className: `group relative block ${THUMB[size]} rounded-full border-2 border-accent bg-surface shadow-sm transition-shadow
4869
+ focus:outline-none focus-visible:ring-[3px] focus-visible:ring-focus-ring
4870
+ disabled:cursor-not-allowed`,
4871
+ children: tooltip && /* @__PURE__ */ jsxRuntime.jsx(
4872
+ "span",
4873
+ {
4874
+ className: `pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 rounded-md bg-foreground px-1.5 py-0.5 text-xs text-background tabular-nums whitespace-nowrap transition-opacity ${dragging ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100"}`,
4875
+ children: formatValue(current[i])
4876
+ }
4877
+ )
4878
+ },
4879
+ i
4880
+ ))
4881
+ ]
4882
+ }
4883
+ ),
4884
+ marks && marks.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative mt-2 h-4", children: marks.map((m) => {
4885
+ const pct = (m.value - min) / (max - min) * 100;
4886
+ return /* @__PURE__ */ jsxRuntime.jsx(
4887
+ "span",
4888
+ {
4889
+ className: "absolute -translate-x-1/2 text-xs text-foreground-muted tabular-nums",
4890
+ style: { left: `${pct}%` },
4891
+ children: m.label ?? m.value
4892
+ },
4893
+ m.value
4894
+ );
4895
+ }) })
4896
+ ] });
4897
+ }
4898
+ function TagsInput({
4899
+ value,
4900
+ defaultValue,
4901
+ onChange,
4902
+ label,
4903
+ htmlFor,
4904
+ name,
4905
+ placeholder = "Add and press Enter",
4906
+ layout = "vertical",
4907
+ size = "md",
4908
+ disabled,
4909
+ errorMessage,
4910
+ required,
4911
+ maxTags,
4912
+ dedupe = true,
4913
+ validate,
4914
+ separators = ["Enter", ","]
4915
+ }) {
4916
+ const errorId = React8.useId();
4917
+ const inputRef = React8.useRef(null);
4918
+ const [internal, setInternal] = React8.useState(defaultValue ?? []);
4919
+ const [draft, setDraft] = React8.useState("");
4920
+ const [localError, setLocalError] = React8.useState(null);
4921
+ const tags = value ?? internal;
4922
+ const hasError = errorMessage != null || localError != null;
4923
+ const errorText = errorMessage ?? localError ?? void 0;
4924
+ const commitTags = (next) => {
4925
+ setInternal(next);
4926
+ onChange?.(next);
4927
+ };
4928
+ const addTag = (raw) => {
4929
+ const tag = raw.trim();
4930
+ if (!tag) return false;
4931
+ if (maxTags != null && tags.length >= maxTags) return false;
4932
+ if (dedupe && tags.some((t) => t.toLowerCase() === tag.toLowerCase())) {
4933
+ setLocalError(`"${tag}" is already added`);
4934
+ return false;
4935
+ }
4936
+ if (validate) {
4937
+ const res = validate(tag, tags);
4938
+ if (res !== true) {
4939
+ setLocalError(typeof res === "string" ? res : `"${tag}" is not valid`);
4940
+ return false;
4941
+ }
4942
+ }
4943
+ setLocalError(null);
4944
+ commitTags([...tags, tag]);
4945
+ return true;
4946
+ };
4947
+ const removeTag = (idx) => {
4948
+ commitTags(tags.filter((_, i) => i !== idx));
4949
+ setLocalError(null);
4950
+ };
4951
+ const onKeyDown = (e) => {
4952
+ if (separators.includes(e.key)) {
4953
+ e.preventDefault();
4954
+ if (addTag(draft)) setDraft("");
4955
+ } else if (e.key === "Backspace" && draft === "" && tags.length > 0) {
4956
+ removeTag(tags.length - 1);
4957
+ }
4958
+ };
4959
+ const onPaste = (e) => {
4960
+ const text = e.clipboardData.getData("text");
4961
+ const parts = text.split(/[\n,;]+/).map((p) => p.trim()).filter(Boolean);
4962
+ if (parts.length > 1) {
4963
+ e.preventDefault();
4964
+ let added = false;
4965
+ for (const p of parts) added = addTag(p) || added;
4966
+ if (added) setDraft("");
4967
+ }
4968
+ };
4969
+ const atMax = maxTags != null && tags.length >= maxTags;
4970
+ return /* @__PURE__ */ jsxRuntime.jsx(
4971
+ Field,
4972
+ {
4973
+ label,
4974
+ htmlFor,
4975
+ errorId,
4976
+ errorMessage: errorText,
4977
+ layout,
4978
+ required,
4979
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
4980
+ "div",
4981
+ {
4982
+ className: `flex flex-wrap items-center gap-1.5 min-h-[36px] ${fieldShell({ size, hasError, disabled, focusWithin: true, sized: false })} px-2 py-1.5`,
4983
+ onClick: () => inputRef.current?.focus(),
4984
+ children: [
4985
+ tags.map((tag, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
4986
+ "span",
4987
+ {
4988
+ className: "inline-flex items-center gap-1 rounded-md bg-surface-raised text-foreground text-xs pl-2 pr-1 py-0.5 border border-border",
4989
+ children: [
4990
+ tag,
4991
+ /* @__PURE__ */ jsxRuntime.jsx(
4992
+ "button",
4993
+ {
4994
+ type: "button",
4995
+ disabled,
4996
+ onClick: (e) => {
4997
+ e.stopPropagation();
4998
+ removeTag(idx);
4999
+ },
5000
+ "aria-label": `Remove ${tag}`,
5001
+ className: "inline-flex items-center justify-center w-4 h-4 rounded text-foreground-muted hover:text-status-error hover:bg-surface transition-colors focus:outline-none focus-visible:ring-1 focus-visible:ring-accent",
5002
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 5L5 15M5 5l10 10", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })
5003
+ }
5004
+ )
5005
+ ]
5006
+ },
5007
+ `${tag}-${idx}`
5008
+ )),
5009
+ /* @__PURE__ */ jsxRuntime.jsx(
5010
+ "input",
5011
+ {
5012
+ ref: inputRef,
5013
+ id: htmlFor,
5014
+ name,
5015
+ disabled: disabled || atMax,
5016
+ value: draft,
5017
+ onChange: (e) => {
5018
+ setDraft(e.target.value);
5019
+ if (localError) setLocalError(null);
5020
+ },
5021
+ onKeyDown,
5022
+ onPaste,
5023
+ onBlur: () => {
5024
+ if (addTag(draft)) setDraft("");
5025
+ },
5026
+ placeholder: atMax ? "" : tags.length === 0 ? placeholder : "",
5027
+ "aria-invalid": hasError || void 0,
5028
+ "aria-describedby": hasError ? errorId : void 0,
5029
+ autoComplete: "off",
5030
+ className: "flex-1 min-w-[6rem] bg-transparent outline-none text-sm placeholder:text-foreground-muted disabled:cursor-not-allowed"
5031
+ }
5032
+ )
5033
+ ]
5034
+ }
5035
+ )
5036
+ }
5037
+ );
5038
+ }
5039
+ var BOX_SIZE = {
5040
+ sm: "h-9 w-8 text-sm",
5041
+ md: "h-11 w-10 text-base",
5042
+ lg: "h-14 w-12 text-lg"
5043
+ };
5044
+ function OtpInput({
5045
+ length = 6,
5046
+ value = "",
5047
+ onChange,
5048
+ onComplete,
5049
+ label,
5050
+ htmlFor,
5051
+ name,
5052
+ mode = "numeric",
5053
+ masked = false,
5054
+ size = "md",
5055
+ disabled,
5056
+ errorMessage,
5057
+ required,
5058
+ groupAfter
5059
+ }) {
5060
+ const errorId = React8.useId();
5061
+ const hasError = errorMessage != null;
5062
+ const refs = React8.useRef([]);
5063
+ const chars = Array.from({ length }, (_, i) => value[i] ?? "");
5064
+ const pattern = mode === "numeric" ? /[0-9]/ : /[a-zA-Z0-9]/;
5065
+ const emit = (next) => {
5066
+ onChange?.(next);
5067
+ if (next.length === length && !next.includes(" ") && [...next].every(Boolean)) {
5068
+ onComplete?.(next);
5069
+ }
5070
+ };
5071
+ const setCharAt = (idx, char) => {
5072
+ const arr = chars.slice();
5073
+ arr[idx] = char;
5074
+ emit(arr.join(""));
5075
+ };
5076
+ const focusBox = (idx) => {
5077
+ const el = refs.current[Math.max(0, Math.min(length - 1, idx))];
5078
+ el?.focus();
5079
+ el?.select();
5080
+ };
5081
+ const onBoxChange = (idx, raw) => {
5082
+ const char = raw.slice(-1);
5083
+ if (char && !pattern.test(char)) return;
5084
+ setCharAt(idx, char);
5085
+ if (char) focusBox(idx + 1);
5086
+ };
5087
+ const onKeyDown = (idx, e) => {
5088
+ if (e.key === "Backspace") {
5089
+ if (chars[idx]) {
5090
+ setCharAt(idx, "");
5091
+ } else if (idx > 0) {
5092
+ setCharAt(idx - 1, "");
5093
+ focusBox(idx - 1);
5094
+ }
5095
+ } else if (e.key === "ArrowLeft") {
5096
+ e.preventDefault();
5097
+ focusBox(idx - 1);
5098
+ } else if (e.key === "ArrowRight") {
5099
+ e.preventDefault();
5100
+ focusBox(idx + 1);
5101
+ }
5102
+ };
5103
+ const onPaste = (e) => {
5104
+ e.preventDefault();
5105
+ const text = e.clipboardData.getData("text").trim();
5106
+ const valid = [...text].filter((c) => pattern.test(c)).slice(0, length);
5107
+ if (valid.length === 0) return;
5108
+ emit(valid.join(""));
5109
+ focusBox(valid.length);
5110
+ };
5111
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, htmlFor, errorId, errorMessage, required, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", role: "group", "aria-label": typeof label === "string" ? label : "One-time code", children: chars.map((char, idx) => /* @__PURE__ */ jsxRuntime.jsxs(React8__default.default.Fragment, { children: [
5112
+ /* @__PURE__ */ jsxRuntime.jsx(
5113
+ "input",
5114
+ {
5115
+ ref: (el) => {
5116
+ refs.current[idx] = el;
5117
+ },
5118
+ id: idx === 0 ? htmlFor : void 0,
5119
+ name: idx === 0 ? name : void 0,
5120
+ value: char,
5121
+ disabled,
5122
+ inputMode: mode === "numeric" ? "numeric" : "text",
5123
+ autoComplete: idx === 0 ? "one-time-code" : "off",
5124
+ type: masked && char ? "password" : "text",
5125
+ maxLength: 1,
5126
+ "aria-label": `Digit ${idx + 1}`,
5127
+ "aria-invalid": hasError || void 0,
5128
+ "aria-describedby": hasError ? errorId : void 0,
5129
+ onChange: (e) => onBoxChange(idx, e.target.value),
5130
+ onKeyDown: (e) => onKeyDown(idx, e),
5131
+ onPaste,
5132
+ onFocus: (e) => e.target.select(),
5133
+ className: [
5134
+ BOX_SIZE[size],
5135
+ "text-center font-medium rounded-lg border bg-surface text-foreground",
5136
+ "transition-[border-color,box-shadow] duration-150",
5137
+ hasError ? "border-status-error" : "border-border",
5138
+ "hover:border-border-strong",
5139
+ "focus:outline-none focus:border-accent focus:ring-[3px] focus:ring-focus-ring",
5140
+ "disabled:bg-surface-raised disabled:text-foreground-muted disabled:cursor-not-allowed"
5141
+ ].join(" ")
5142
+ }
5143
+ ),
5144
+ groupAfter && (idx + 1) % groupAfter === 0 && idx < length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-2 text-center text-foreground-muted", "aria-hidden": "true", children: "\xB7" })
5145
+ ] }, idx)) }) });
5146
+ }
5147
+ var ICON_SIZE = { sm: "w-4 h-4", md: "w-5 h-5", lg: "w-7 h-7" };
5148
+ var Star = (filled) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: filled ? "currentColor" : "none", stroke: "currentColor", strokeWidth: filled ? 0 : 1.5, className: "w-full h-full", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M11.48 3.5a.56.56 0 011.04 0l2.13 4.77 5.18.5a.56.56 0 01.32.97l-3.9 3.46 1.15 5.1a.56.56 0 01-.83.6L12 16.8l-4.57 2.6a.56.56 0 01-.83-.6l1.15-5.1-3.9-3.46a.56.56 0 01.32-.97l5.18-.5L11.48 3.5z" }) });
5149
+ function Rating({
5150
+ value,
5151
+ defaultValue = 0,
5152
+ onChange,
5153
+ count = 5,
5154
+ allowHalf = false,
5155
+ readOnly = false,
5156
+ clearable = true,
5157
+ label,
5158
+ size = "md",
5159
+ disabled,
5160
+ icon = Star,
5161
+ errorMessage,
5162
+ name
5163
+ }) {
5164
+ const errorId = React8.useId();
5165
+ const [internal, setInternal] = React8.useState(defaultValue);
5166
+ const [hover, setHover] = React8.useState(null);
5167
+ const current = value ?? internal;
5168
+ const display2 = hover ?? current;
5169
+ const interactive = !readOnly && !disabled;
5170
+ const commit = (next) => {
5171
+ const v = clearable && next === current ? 0 : next;
5172
+ setInternal(v);
5173
+ onChange?.(v);
5174
+ };
5175
+ const onKeyDown = (e) => {
5176
+ if (!interactive) return;
5177
+ const step = allowHalf ? 0.5 : 1;
5178
+ if (e.key === "ArrowRight" || e.key === "ArrowUp") {
5179
+ e.preventDefault();
5180
+ commit(Math.min(count, current + step));
5181
+ } else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
5182
+ e.preventDefault();
5183
+ commit(Math.max(0, current - step));
5184
+ } else if (e.key === "Home") {
5185
+ e.preventDefault();
5186
+ commit(0);
5187
+ } else if (e.key === "End") {
5188
+ e.preventDefault();
5189
+ commit(count);
5190
+ }
5191
+ };
5192
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, errorId, errorMessage, children: /* @__PURE__ */ jsxRuntime.jsxs(
5193
+ "div",
5194
+ {
5195
+ role: interactive ? "slider" : "img",
5196
+ "aria-label": typeof label === "string" ? label : "Rating",
5197
+ "aria-valuenow": interactive ? current : void 0,
5198
+ "aria-valuemin": interactive ? 0 : void 0,
5199
+ "aria-valuemax": interactive ? count : void 0,
5200
+ "aria-valuetext": `${current} of ${count}`,
5201
+ tabIndex: interactive ? 0 : -1,
5202
+ onKeyDown,
5203
+ onMouseLeave: () => setHover(null),
5204
+ className: "inline-flex items-center gap-1 text-accent focus:outline-none focus-visible:ring-[3px] focus-visible:ring-focus-ring rounded-md w-max",
5205
+ children: [
5206
+ name && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: current }),
5207
+ Array.from({ length: count }, (_, i) => {
5208
+ const starValue = i + 1;
5209
+ const fillFraction = Math.max(0, Math.min(1, display2 - i));
5210
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5211
+ "span",
5212
+ {
5213
+ className: `relative ${ICON_SIZE[size]} ${interactive ? "cursor-pointer" : ""} ${disabled ? "opacity-50" : ""}`,
5214
+ onMouseMove: (e) => {
5215
+ if (!interactive) return;
5216
+ if (allowHalf) {
5217
+ const rect = e.currentTarget.getBoundingClientRect();
5218
+ const half = e.clientX - rect.left < rect.width / 2;
5219
+ setHover(i + (half ? 0.5 : 1));
5220
+ } else {
5221
+ setHover(starValue);
5222
+ }
5223
+ },
5224
+ onClick: (e) => {
5225
+ if (!interactive) return;
5226
+ if (allowHalf) {
5227
+ const rect = e.currentTarget.getBoundingClientRect();
5228
+ const half = e.clientX - rect.left < rect.width / 2;
5229
+ commit(i + (half ? 0.5 : 1));
5230
+ } else {
5231
+ commit(starValue);
5232
+ }
5233
+ },
5234
+ children: [
5235
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-0 text-foreground-muted", children: icon(false) }),
5236
+ /* @__PURE__ */ jsxRuntime.jsx(
5237
+ "span",
5238
+ {
5239
+ className: "absolute inset-0 overflow-hidden",
5240
+ style: { width: `${fillFraction * 100}%` },
5241
+ children: icon(true)
5242
+ }
5243
+ )
5244
+ ]
5245
+ },
5246
+ i
5247
+ );
5248
+ })
5249
+ ]
5250
+ }
5251
+ ) });
5252
+ }
5253
+ var pad = (n) => n.toString().padStart(2, "0");
5254
+ function parse(value) {
5255
+ if (!value) return null;
5256
+ const [h, m, s] = value.split(":").map(Number);
5257
+ if (Number.isNaN(h) || Number.isNaN(m)) return null;
5258
+ return { h, m, s: Number.isNaN(s) ? 0 : s };
5259
+ }
5260
+ function display(value, use12, withSeconds) {
5261
+ const p = parse(value);
5262
+ if (!p) return "";
5263
+ if (use12) {
5264
+ const period = p.h >= 12 ? "PM" : "AM";
5265
+ const h12 = p.h % 12 === 0 ? 12 : p.h % 12;
5266
+ return `${h12}:${pad(p.m)}${withSeconds ? `:${pad(p.s)}` : ""} ${period}`;
5267
+ }
5268
+ return `${pad(p.h)}:${pad(p.m)}${withSeconds ? `:${pad(p.s)}` : ""}`;
5269
+ }
5270
+ function TimePicker({
5271
+ value,
5272
+ onChange,
5273
+ label,
5274
+ htmlFor,
5275
+ name,
5276
+ placeholder = "Select a time\u2026",
5277
+ layout = "vertical",
5278
+ size = "md",
5279
+ use12Hours = false,
5280
+ withSeconds = false,
5281
+ minuteStep = 1,
5282
+ disabled,
5283
+ errorMessage,
5284
+ required,
5285
+ style
5286
+ }) {
5287
+ const errorId = React8.useId();
5288
+ const hasError = errorMessage != null;
5289
+ const [open, setOpen] = React8.useState(false);
5290
+ const parsed = parse(value) ?? { h: 0, m: 0, s: 0 };
5291
+ const update = (next) => {
5292
+ const merged = { ...parsed, ...next };
5293
+ onChange?.(`${pad(merged.h)}:${pad(merged.m)}${withSeconds ? `:${pad(merged.s)}` : ""}`);
5294
+ };
5295
+ const hours = use12Hours ? Array.from({ length: 12 }, (_, i) => i + 1) : Array.from({ length: 24 }, (_, i) => i);
5296
+ const minutes = Array.from({ length: Math.ceil(60 / minuteStep) }, (_, i) => i * minuteStep);
5297
+ const seconds = Array.from({ length: 60 }, (_, i) => i);
5298
+ const selectedHourCol = use12Hours ? parsed.h % 12 === 0 ? 12 : parsed.h % 12 : parsed.h;
5299
+ const period = parsed.h >= 12 ? "PM" : "AM";
5300
+ const setHour12 = (h12, p) => {
5301
+ const h24 = p === "AM" ? h12 === 12 ? 0 : h12 : h12 === 12 ? 12 : h12 + 12;
5302
+ update({ h: h24 });
5303
+ };
5304
+ const Column = ({ items, selected, onPick, fmt }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col overflow-y-auto max-h-48 w-14 hidden-scrollbar", role: "listbox", children: items.map((n) => /* @__PURE__ */ jsxRuntime.jsx(
5305
+ "button",
5306
+ {
5307
+ type: "button",
5308
+ role: "option",
5309
+ "aria-selected": selected === n,
5310
+ onClick: () => onPick(n),
5311
+ className: `py-1.5 text-sm rounded-md text-center transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${selected === n ? "bg-accent text-accent-fg" : "text-foreground hover:bg-surface-raised"}`,
5312
+ children: fmt ? fmt(n) : pad(n)
5313
+ },
5314
+ n
5315
+ )) });
5316
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { label, htmlFor, errorId, errorMessage, layout, required, children: [
5317
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
5318
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
5319
+ "button",
5320
+ {
5321
+ id: htmlFor,
5322
+ type: "button",
5323
+ disabled,
5324
+ style,
5325
+ "aria-invalid": hasError || void 0,
5326
+ "aria-describedby": hasError ? errorId : void 0,
5327
+ className: `flex items-center justify-between cursor-pointer select-none ${!style?.width ? "min-w-[160px]" : ""} ${fieldShell({ size, hasError, disabled })}`,
5328
+ children: [
5329
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-sm truncate ${value ? "" : "text-foreground-muted"}`, children: display(value, use12Hours, withSeconds) || placeholder }),
5330
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, className: "w-4 h-4 flex-shrink-0 text-foreground-muted ml-2", "aria-hidden": "true", children: [
5331
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9" }),
5332
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 7v5l3 2", strokeLinecap: "round" })
5333
+ ] })
5334
+ ]
5335
+ }
5336
+ ) }),
5337
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
5338
+ Popover__namespace.Content,
5339
+ {
5340
+ align: "start",
5341
+ sideOffset: 4,
5342
+ className: "bg-surface text-foreground border border-border rounded-lg shadow-md z-50 p-2 flex gap-1 animate-in fade-in-0 zoom-in-95",
5343
+ children: [
5344
+ /* @__PURE__ */ jsxRuntime.jsx(
5345
+ Column,
5346
+ {
5347
+ items: hours,
5348
+ selected: selectedHourCol,
5349
+ onPick: (h) => use12Hours ? setHour12(h, period) : update({ h }),
5350
+ fmt: use12Hours ? (n) => String(n) : pad
5351
+ }
5352
+ ),
5353
+ /* @__PURE__ */ jsxRuntime.jsx(Column, { items: minutes, selected: parsed.m, onPick: (m) => update({ m }) }),
5354
+ withSeconds && /* @__PURE__ */ jsxRuntime.jsx(Column, { items: seconds, selected: parsed.s, onPick: (s) => update({ s }) }),
5355
+ use12Hours && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 w-12", children: ["AM", "PM"].map((p) => /* @__PURE__ */ jsxRuntime.jsx(
5356
+ "button",
5357
+ {
5358
+ type: "button",
5359
+ onClick: () => setHour12(selectedHourCol, p),
5360
+ className: `py-1.5 text-sm rounded-md transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${period === p ? "bg-accent text-accent-fg" : "text-foreground hover:bg-surface-raised"}`,
5361
+ children: p
5362
+ },
5363
+ p
5364
+ )) })
5365
+ ]
5366
+ }
5367
+ ) })
5368
+ ] }),
5369
+ name && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: value ?? "" })
5370
+ ] });
5371
+ }
5372
+ var MONTH_NAMES2 = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
5373
+ var WEEKDAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
5374
+ var startOfMonth2 = (d) => new Date(d.getFullYear(), d.getMonth(), 1);
5375
+ var addMonths2 = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1);
5376
+ var addDays2 = (d, n) => {
5377
+ const c = new Date(d);
5378
+ c.setDate(c.getDate() + n);
5379
+ return c;
5380
+ };
5381
+ var isSameDay2 = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
5382
+ var startOfDay = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
5383
+ var defaultFmt = (d) => `${d.getFullYear()}-${`${d.getMonth() + 1}`.padStart(2, "0")}-${`${d.getDate()}`.padStart(2, "0")}`;
5384
+ function buildGrid2(viewMonth, weekStartsOn) {
5385
+ const first = startOfMonth2(viewMonth);
5386
+ const offset = (first.getDay() - weekStartsOn + 7) % 7;
5387
+ const gridStart = addDays2(first, -offset);
5388
+ return Array.from({ length: 42 }, (_, i) => {
5389
+ const d = addDays2(gridStart, i);
5390
+ return { date: d, outside: d.getMonth() !== viewMonth.getMonth() };
5391
+ });
5392
+ }
5393
+ function DateRangePicker({
5394
+ value = { start: null, end: null },
5395
+ onChange,
5396
+ label,
5397
+ htmlFor,
5398
+ placeholder = "Select a date range\u2026",
5399
+ layout = "vertical",
5400
+ size = "md",
5401
+ min,
5402
+ max,
5403
+ weekStartsOn = 0,
5404
+ presets,
5405
+ format = defaultFmt,
5406
+ disabled,
5407
+ errorMessage,
5408
+ required,
5409
+ style
5410
+ }) {
5411
+ const errorId = React8.useId();
5412
+ const hasError = errorMessage != null;
5413
+ const [open, setOpen] = React8.useState(false);
5414
+ const [leftMonth, setLeftMonth] = React8.useState(() => startOfMonth2(value.start ?? /* @__PURE__ */ new Date()));
5415
+ const [pendingStart, setPendingStart] = React8.useState(null);
5416
+ const [hoverDate, setHoverDate] = React8.useState(null);
5417
+ const weekdays = React8.useMemo(
5418
+ () => WEEKDAY.slice(weekStartsOn).concat(WEEKDAY.slice(0, weekStartsOn)),
5419
+ [weekStartsOn]
5420
+ );
5421
+ const isDisabled = (d) => min && d < startOfDay(min) || max && d > startOfDay(max);
5422
+ const effective = pendingStart ? { start: pendingStart, end: hoverDate } : value;
5423
+ const inRange = (d) => {
5424
+ const { start, end } = effective;
5425
+ if (!start || !end) return false;
5426
+ const [a, b] = start <= end ? [start, end] : [end, start];
5427
+ return d >= startOfDay(a) && d <= startOfDay(b);
5428
+ };
5429
+ const onDayClick = (d) => {
5430
+ if (isDisabled(d)) return;
5431
+ if (!pendingStart) {
5432
+ setPendingStart(d);
5433
+ setHoverDate(d);
5434
+ onChange?.({ start: d, end: null });
5435
+ } else {
5436
+ const [start, end] = pendingStart <= d ? [pendingStart, d] : [d, pendingStart];
5437
+ onChange?.({ start, end });
5438
+ setPendingStart(null);
5439
+ setHoverDate(null);
5440
+ setOpen(false);
5441
+ }
5442
+ };
5443
+ const triggerText = value.start && value.end ? `${format(value.start)} \u2013 ${format(value.end)}` : value.start ? `${format(value.start)} \u2013 \u2026` : "";
5444
+ const renderMonth = (viewMonth) => {
5445
+ const cells = buildGrid2(viewMonth, weekStartsOn);
5446
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5447
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-semibold text-center mb-2 select-none", children: [
5448
+ MONTH_NAMES2[viewMonth.getMonth()],
5449
+ " ",
5450
+ viewMonth.getFullYear()
5451
+ ] }),
5452
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-7 gap-y-1", children: [
5453
+ weekdays.map((w) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] font-medium text-foreground-muted uppercase text-center", children: w }, w)),
5454
+ cells.map(({ date, outside }) => {
5455
+ const dis = isDisabled(date);
5456
+ const isStart = effective.start && isSameDay2(date, effective.start);
5457
+ const isEnd = effective.end && isSameDay2(date, effective.end);
5458
+ const within = inRange(date) && !isStart && !isEnd;
5459
+ return /* @__PURE__ */ jsxRuntime.jsx(
5460
+ "button",
5461
+ {
5462
+ type: "button",
5463
+ disabled: dis,
5464
+ onMouseEnter: () => pendingStart && setHoverDate(date),
5465
+ onClick: () => onDayClick(date),
5466
+ className: [
5467
+ "h-8 text-xs font-medium transition-colors",
5468
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
5469
+ "disabled:opacity-30 disabled:cursor-not-allowed",
5470
+ isStart || isEnd ? "bg-accent text-accent-fg rounded-md" : within ? "bg-surface-raised text-foreground rounded-none" : outside ? "text-foreground-muted hover:bg-surface-raised rounded-md" : "text-foreground hover:bg-surface-raised rounded-md"
5471
+ ].join(" "),
5472
+ children: date.getDate()
5473
+ },
5474
+ defaultFmt(date)
5475
+ );
5476
+ })
5477
+ ] })
5478
+ ] });
5479
+ };
5480
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, htmlFor, errorId, errorMessage, layout, required, children: /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => {
5481
+ if (!disabled) {
5482
+ setOpen(o);
5483
+ if (!o) {
5484
+ setPendingStart(null);
5485
+ setHoverDate(null);
5486
+ }
5487
+ }
5488
+ }, children: [
5489
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
5490
+ "button",
5491
+ {
5492
+ id: htmlFor,
5493
+ type: "button",
5494
+ disabled,
5495
+ style,
5496
+ "aria-invalid": hasError || void 0,
5497
+ "aria-describedby": hasError ? errorId : void 0,
5498
+ className: `flex items-center justify-between cursor-pointer select-none ${!style?.width ? "min-w-[240px]" : ""} ${fieldShell({ size, hasError, disabled })}`,
5499
+ children: [
5500
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `text-sm truncate ${triggerText ? "" : "text-foreground-muted"}`, children: triggerText || placeholder }),
5501
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, className: "w-4 h-4 flex-shrink-0 text-foreground-muted ml-2", "aria-hidden": "true", children: [
5502
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "5", width: "18", height: "16", rx: "2" }),
5503
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 9h18M8 3v4M16 3v4", strokeLinecap: "round" })
5504
+ ] })
5505
+ ]
5506
+ }
5507
+ ) }),
5508
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
5509
+ Popover__namespace.Content,
5510
+ {
5511
+ align: "start",
5512
+ sideOffset: 4,
5513
+ className: "bg-surface text-foreground border border-border rounded-lg shadow-md z-50 p-3 flex gap-3 animate-in fade-in-0 zoom-in-95",
5514
+ children: [
5515
+ presets && presets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 pr-3 border-r border-border min-w-[120px]", children: presets.map((p) => /* @__PURE__ */ jsxRuntime.jsx(
5516
+ "button",
5517
+ {
5518
+ type: "button",
5519
+ onClick: () => {
5520
+ onChange?.(p.range());
5521
+ setOpen(false);
5522
+ },
5523
+ className: "text-left text-xs px-2 py-1.5 rounded-md text-foreground-secondary hover:bg-surface-raised hover:text-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
5524
+ children: p.label
5525
+ },
5526
+ p.label
5527
+ )) }),
5528
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4", children: [
5529
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5530
+ /* @__PURE__ */ jsxRuntime.jsx(
5531
+ "button",
5532
+ {
5533
+ type: "button",
5534
+ onClick: () => setLeftMonth(addMonths2(leftMonth, -1)),
5535
+ "aria-label": "Previous month",
5536
+ className: "absolute -top-1 left-0 w-7 h-7 inline-flex items-center justify-center rounded-md hover:bg-surface-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
5537
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "w-4 h-4", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 19l-7-7 7-7" }) })
5538
+ }
5539
+ ),
5540
+ renderMonth(leftMonth)
5541
+ ] }),
5542
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5543
+ /* @__PURE__ */ jsxRuntime.jsx(
5544
+ "button",
5545
+ {
5546
+ type: "button",
5547
+ onClick: () => setLeftMonth(addMonths2(leftMonth, 1)),
5548
+ "aria-label": "Next month",
5549
+ className: "absolute -top-1 right-0 w-7 h-7 inline-flex items-center justify-center rounded-md hover:bg-surface-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-accent",
5550
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, className: "w-4 h-4", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) })
5551
+ }
5552
+ ),
5553
+ renderMonth(addMonths2(leftMonth, 1))
5554
+ ] })
5555
+ ] })
5556
+ ]
5557
+ }
5558
+ ) })
5559
+ ] }) });
5560
+ }
5561
+ var DEFAULT_SWATCHES = [
5562
+ "#0466c8",
5563
+ "#1e8449",
5564
+ "#d68910",
5565
+ "#c0392b",
5566
+ "#8e44ad",
5567
+ "#16a085",
5568
+ "#2c3e50",
5569
+ "#7f8c8d",
5570
+ "#e84393",
5571
+ "#00b894",
5572
+ "#fdcb6e",
5573
+ "#0a1929"
5574
+ ];
5575
+ var HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
5576
+ function ColorPicker({
5577
+ value = "",
5578
+ onChange,
5579
+ label,
5580
+ htmlFor,
5581
+ name,
5582
+ layout = "vertical",
5583
+ size = "md",
5584
+ swatches = DEFAULT_SWATCHES,
5585
+ allowCustom = true,
5586
+ disabled,
5587
+ errorMessage,
5588
+ required,
5589
+ placeholder = "Pick a colour\u2026"
5590
+ }) {
5591
+ const errorId = React8.useId();
5592
+ const hasError = errorMessage != null;
5593
+ const [open, setOpen] = React8.useState(false);
5594
+ const [draft, setDraft] = React8.useState(value);
5595
+ const valid = HEX_RE.test(value);
5596
+ const pick = (hex) => {
5597
+ onChange?.(hex);
5598
+ setDraft(hex);
5599
+ };
5600
+ const commitDraft = (raw) => {
5601
+ const hex = raw.startsWith("#") ? raw : `#${raw}`;
5602
+ setDraft(hex);
5603
+ if (HEX_RE.test(hex)) onChange?.(hex);
5604
+ };
5605
+ return /* @__PURE__ */ jsxRuntime.jsxs(Field, { label, htmlFor, errorId, errorMessage, layout, required, children: [
5606
+ /* @__PURE__ */ jsxRuntime.jsxs(Popover__namespace.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
5607
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
5608
+ "button",
5609
+ {
5610
+ id: htmlFor,
5611
+ type: "button",
5612
+ disabled,
5613
+ "aria-invalid": hasError || void 0,
5614
+ "aria-describedby": hasError ? errorId : void 0,
5615
+ className: `flex items-center gap-2 cursor-pointer select-none ${fieldShell({ size, hasError, disabled })}`,
5616
+ children: [
5617
+ /* @__PURE__ */ jsxRuntime.jsx(
5618
+ "span",
5619
+ {
5620
+ className: "h-4 w-4 flex-shrink-0 rounded border border-border",
5621
+ style: { backgroundColor: valid ? value : "transparent" },
5622
+ "aria-hidden": "true"
5623
+ }
5624
+ ),
5625
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `flex-1 text-left text-sm truncate ${valid ? "text-foreground" : "text-foreground-muted"}`, children: valid ? value.toLowerCase() : placeholder })
5626
+ ]
5627
+ }
5628
+ ) }),
5629
+ /* @__PURE__ */ jsxRuntime.jsx(Popover__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
5630
+ Popover__namespace.Content,
5631
+ {
5632
+ align: "start",
5633
+ sideOffset: 4,
5634
+ className: "bg-surface text-foreground border border-border rounded-lg shadow-md z-50 p-3 w-56 animate-in fade-in-0 zoom-in-95",
5635
+ children: [
5636
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-6 gap-2 mb-3", children: swatches.map((sw) => /* @__PURE__ */ jsxRuntime.jsx(
5637
+ "button",
5638
+ {
5639
+ type: "button",
5640
+ onClick: () => {
5641
+ pick(sw);
5642
+ setOpen(false);
5643
+ },
5644
+ "aria-label": sw,
5645
+ className: `h-7 w-7 rounded-md border transition-transform hover:scale-110 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent ${value.toLowerCase() === sw.toLowerCase() ? "border-accent ring-2 ring-focus-ring" : "border-border"}`,
5646
+ style: { backgroundColor: sw }
5647
+ },
5648
+ sw
5649
+ )) }),
5650
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5651
+ /* @__PURE__ */ jsxRuntime.jsx(
5652
+ "input",
5653
+ {
5654
+ value: draft,
5655
+ onChange: (e) => commitDraft(e.target.value),
5656
+ placeholder: "#0466c8",
5657
+ "aria-label": "Hex colour",
5658
+ className: `flex-1 ${fieldShell({ size: "sm" })}`
5659
+ }
5660
+ ),
5661
+ allowCustom && /* @__PURE__ */ jsxRuntime.jsx(
5662
+ "input",
5663
+ {
5664
+ type: "color",
5665
+ value: valid ? value : "#000000",
5666
+ onChange: (e) => pick(e.target.value),
5667
+ "aria-label": "Custom colour",
5668
+ className: "h-7 w-9 rounded-md border border-border bg-surface cursor-pointer p-0.5"
5669
+ }
5670
+ )
5671
+ ] })
5672
+ ]
5673
+ }
5674
+ ) })
5675
+ ] }),
5676
+ name && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: valid ? value : "" })
5677
+ ] });
5678
+ }
4666
5679
 
4667
5680
  Object.defineProperty(exports, "COLORS", {
4668
5681
  enumerable: true,
@@ -4689,7 +5702,9 @@ exports.Catalog = Catalog;
4689
5702
  exports.CatalogCarousel = CatalogCarousel;
4690
5703
  exports.CatalogGrid = CatalogGrid;
4691
5704
  exports.Checkbox = Checkbox;
5705
+ exports.ColorPicker = ColorPicker;
4692
5706
  exports.ContextMenu = ContextMenu;
5707
+ exports.DateRangePicker = DateRangePicker;
4693
5708
  exports.Drawer = Drawer;
4694
5709
  exports.Dropdown = Dropdown;
4695
5710
  exports.FadingBase = FadingBase;
@@ -4706,23 +5721,30 @@ exports.Modal = Modal;
4706
5721
  exports.NotificationProvider = NotificationProvider;
4707
5722
  exports.NumberInput = NumberInput;
4708
5723
  exports.OpaqueGridCard = OpaqueGridCard;
5724
+ exports.OtpInput = OtpInput;
4709
5725
  exports.Password = Password;
4710
5726
  exports.Portal = Portal;
4711
5727
  exports.RadioGroup = RadioGroup;
5728
+ exports.Rating = Rating;
4712
5729
  exports.ScalableContainer = ScalableContainer;
4713
5730
  exports.SearchInput = SearchInput_default;
5731
+ exports.SegmentedControl = SegmentedControl;
4714
5732
  exports.Sidebar = Sidebar;
4715
5733
  exports.SkeletonBox = SkeletonBox;
4716
5734
  exports.SkeletonCard = SkeletonCard;
4717
5735
  exports.SkeletonCircle = SkeletonCircle;
4718
5736
  exports.SkeletonText = SkeletonText;
5737
+ exports.Slider = Slider;
4719
5738
  exports.Switch = Switch;
4720
5739
  exports.Table = Table;
4721
5740
  exports.Tabs = Tabs;
5741
+ exports.TagsInput = TagsInput;
4722
5742
  exports.Temporal = DatePicker;
5743
+ exports.TextArea = TextArea;
4723
5744
  exports.TextInput = TextInput;
4724
5745
  exports.ThemeProvider = ThemeProvider;
4725
5746
  exports.ThemeSwitch = ThemeSwitch;
5747
+ exports.TimePicker = TimePicker;
4726
5748
  exports.ToggleButton = ToggleButton;
4727
5749
  exports.Tooltip = Tooltip;
4728
5750
  exports.TooltipProvider = TooltipProvider;