@overdoser/react-toolkit 0.18.0 → 0.19.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.
Files changed (156) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +129 -0
  3. package/components/Accordion/Accordion.d.ts +94 -0
  4. package/components/Accordion/Accordion.js +180 -0
  5. package/components/Accordion/Accordion.module.scss.js +36 -0
  6. package/components/Accordion/index.d.ts +2 -0
  7. package/components/Alert/Alert.d.ts +29 -1
  8. package/components/Alert/Alert.js +44 -30
  9. package/components/Alert/Alert.module.scss.js +24 -16
  10. package/components/Alert/index.d.ts +1 -1
  11. package/components/Card/Card.d.ts +86 -0
  12. package/components/Card/Card.js +132 -0
  13. package/components/Card/Card.module.scss.js +60 -0
  14. package/components/Card/index.d.ts +2 -0
  15. package/components/Chip/Chip.d.ts +86 -0
  16. package/components/Chip/Chip.js +141 -0
  17. package/components/Chip/Chip.module.scss.js +59 -0
  18. package/components/Chip/index.d.ts +2 -0
  19. package/components/CodeBlock/CodeBlock.d.ts +78 -0
  20. package/components/CodeBlock/CodeBlock.js +120 -0
  21. package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
  22. package/components/CodeBlock/index.d.ts +2 -0
  23. package/components/CommandPalette/CommandPalette.d.ts +141 -0
  24. package/components/CommandPalette/CommandPalette.js +397 -0
  25. package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
  26. package/components/CommandPalette/index.d.ts +2 -0
  27. package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
  28. package/components/ConfirmDialog/ConfirmDialog.js +201 -0
  29. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
  30. package/components/ConfirmDialog/index.d.ts +2 -0
  31. package/components/Drawer/Drawer.d.ts +1 -0
  32. package/components/Drawer/Drawer.js +35 -36
  33. package/components/Drawer/Drawer.module.scss.js +20 -18
  34. package/components/Dropdown/Dropdown.d.ts +47 -7
  35. package/components/Dropdown/Dropdown.js +174 -81
  36. package/components/Dropdown/Dropdown.module.scss.js +40 -22
  37. package/components/Dropdown/DropdownItem.d.ts +31 -2
  38. package/components/Dropdown/DropdownItem.js +54 -27
  39. package/components/Dropdown/DropdownLabel.d.ts +11 -0
  40. package/components/Dropdown/DropdownLabel.js +11 -0
  41. package/components/Dropdown/DropdownSeparator.d.ts +12 -0
  42. package/components/Dropdown/DropdownSeparator.js +11 -0
  43. package/components/Dropdown/dropdownContext.d.ts +6 -0
  44. package/components/Dropdown/dropdownContext.js +5 -0
  45. package/components/Dropdown/index.d.ts +8 -2
  46. package/components/Dropdown/useContextMenu.d.ts +32 -0
  47. package/components/Dropdown/useContextMenu.js +18 -0
  48. package/components/EmptyState/EmptyState.d.ts +53 -0
  49. package/components/EmptyState/EmptyState.js +55 -0
  50. package/components/EmptyState/EmptyState.module.scss.js +25 -0
  51. package/components/EmptyState/index.d.ts +2 -0
  52. package/components/Form/FormField.js +25 -24
  53. package/components/ImageViewer/ImageViewer.d.ts +105 -0
  54. package/components/ImageViewer/ImageViewer.js +201 -0
  55. package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
  56. package/components/ImageViewer/index.d.ts +4 -0
  57. package/components/ImageViewer/useZoomPan.d.ts +94 -0
  58. package/components/ImageViewer/useZoomPan.js +141 -0
  59. package/components/Kbd/Kbd.d.ts +26 -0
  60. package/components/Kbd/Kbd.js +22 -0
  61. package/components/Kbd/Kbd.module.scss.js +17 -0
  62. package/components/Kbd/index.d.ts +2 -0
  63. package/components/KeyValueList/KeyValueList.d.ts +84 -0
  64. package/components/KeyValueList/KeyValueList.js +127 -0
  65. package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
  66. package/components/KeyValueList/index.d.ts +2 -0
  67. package/components/Modal/Modal.d.ts +1 -0
  68. package/components/Modal/Modal.js +40 -41
  69. package/components/Modal/Modal.module.scss.js +18 -16
  70. package/components/PageHeader/PageHeader.d.ts +61 -0
  71. package/components/PageHeader/PageHeader.js +73 -0
  72. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  73. package/components/PageHeader/index.d.ts +2 -0
  74. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  75. package/components/ProgressBar/ProgressBar.js +90 -0
  76. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  77. package/components/ProgressBar/index.d.ts +2 -0
  78. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  79. package/components/RelativeTime/RelativeTime.js +43 -0
  80. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  81. package/components/RelativeTime/index.d.ts +2 -0
  82. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  83. package/components/SegmentedControl/SegmentedControl.js +131 -0
  84. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  85. package/components/SegmentedControl/index.d.ts +2 -0
  86. package/components/SplitPane/SplitPane.d.ts +61 -0
  87. package/components/SplitPane/SplitPane.js +171 -0
  88. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  89. package/components/SplitPane/index.d.ts +2 -0
  90. package/components/StatCard/StatCard.d.ts +105 -0
  91. package/components/StatCard/StatCard.js +127 -0
  92. package/components/StatCard/StatCard.module.scss.js +72 -0
  93. package/components/StatCard/index.d.ts +2 -0
  94. package/components/StatusDot/StatusDot.d.ts +33 -0
  95. package/components/StatusDot/StatusDot.js +39 -0
  96. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  97. package/components/StatusDot/index.d.ts +2 -0
  98. package/components/Table/Table.d.ts +100 -2
  99. package/components/Table/Table.js +371 -210
  100. package/components/Table/Table.module.scss.js +68 -46
  101. package/components/Table/index.d.ts +1 -1
  102. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  103. package/components/ThemeToggle/ThemeToggle.js +97 -0
  104. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  105. package/components/ThemeToggle/index.d.ts +2 -0
  106. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  107. package/components/inputs/Checkbox/Checkbox.js +29 -28
  108. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  109. package/components/inputs/Input/Input.d.ts +33 -1
  110. package/components/inputs/Input/Input.js +94 -35
  111. package/components/inputs/Input/Input.module.scss.js +14 -12
  112. package/components/inputs/Radio/Radio.d.ts +5 -4
  113. package/components/inputs/Radio/Radio.js +55 -50
  114. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  115. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  116. package/components/inputs/SearchInput/SearchInput.js +116 -0
  117. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  118. package/components/inputs/SearchInput/index.d.ts +2 -0
  119. package/components/inputs/Select/Select.d.ts +52 -0
  120. package/components/inputs/Select/Select.js +494 -385
  121. package/components/inputs/Select/Select.module.scss.js +34 -30
  122. package/components/inputs/Switch/Switch.d.ts +15 -0
  123. package/components/inputs/Switch/Switch.js +8 -0
  124. package/components/inputs/Switch/index.d.ts +2 -0
  125. package/hooks/useDebouncedValue.d.ts +15 -0
  126. package/hooks/useDebouncedValue.js +15 -0
  127. package/hooks/useElementSize.d.ts +20 -0
  128. package/hooks/useElementSize.js +23 -0
  129. package/hooks/useKeyboard.d.ts +49 -5
  130. package/hooks/useKeyboard.js +66 -16
  131. package/hooks/useMediaQuery.d.ts +14 -0
  132. package/hooks/useMediaQuery.js +16 -0
  133. package/hooks/useNow.d.ts +14 -0
  134. package/hooks/useNow.js +35 -0
  135. package/hooks/usePersistedState.d.ts +30 -0
  136. package/hooks/usePersistedState.js +96 -0
  137. package/hooks/useResizable.d.ts +66 -0
  138. package/hooks/useResizable.js +105 -0
  139. package/hooks/useTheme.d.ts +33 -0
  140. package/hooks/useTheme.js +27 -0
  141. package/index.css +1 -1
  142. package/index.d.ts +58 -4
  143. package/index.js +208 -132
  144. package/index.layered.css +1 -1
  145. package/llms.txt +619 -25
  146. package/manifest.json +1739 -91
  147. package/package.json +1 -1
  148. package/recipes/confirm-modal.tsx +65 -53
  149. package/recipes/floating-copy-button.tsx +32 -28
  150. package/utils/formatBytes.d.ts +21 -0
  151. package/utils/formatBytes.js +14 -0
  152. package/utils/index.d.ts +6 -0
  153. package/utils/themeScript.d.ts +17 -0
  154. package/utils/themeScript.js +9 -0
  155. package/utils/timeAgo.d.ts +33 -0
  156. package/utils/timeAgo.js +37 -0
@@ -15,6 +15,8 @@ export interface RadioGroupProps {
15
15
  'aria-labelledby'?: string;
16
16
  /** Marks the group as required (`aria-required`). */
17
17
  required?: boolean;
18
+ /** Apply error styling to every `Radio` in the group (set automatically by `FormField` when the field is invalid). @default false */
19
+ error?: boolean;
18
20
  }
19
21
  /**
20
22
  * Manages selection state and `name` attribute for a group of `<Radio>`s via context.
@@ -26,10 +28,7 @@ export interface RadioGroupProps {
26
28
  * <Radio value="pro" label="Pro" />
27
29
  * </RadioGroup>
28
30
  */
29
- export declare const RadioGroup: {
30
- ({ name, value, onChange, className, style, children, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, required, }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
31
- displayName: string;
32
- };
31
+ export declare const RadioGroup: import('react').ForwardRefExoticComponent<RadioGroupProps & import('react').RefAttributes<HTMLDivElement>>;
33
32
  export interface RadioClasses {
34
33
  root: string;
35
34
  input: string;
@@ -40,6 +39,8 @@ export interface RadioProps extends Omit<ComponentPropsWithRef<'input'>, 'type'>
40
39
  label?: ReactNode;
41
40
  /** Value of this option. Required (used to identify the radio in the group). */
42
41
  value: string;
42
+ /** Apply error styling (set automatically by `FormField` when the field is invalid). @default false */
43
+ error?: boolean;
43
44
  /** Override class names on internal elements. */
44
45
  classes?: Partial<RadioClasses>;
45
46
  }
@@ -1,68 +1,73 @@
1
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as g, useContext as y, createContext as R } from "react";
3
- import l from "clsx";
4
- import n from "./Radio.module.scss.js";
5
- const b = R(null), v = ({
6
- name: o,
7
- value: e,
8
- onChange: a,
9
- className: i,
10
- style: d,
11
- children: s,
12
- id: p,
13
- "aria-label": c,
14
- "aria-labelledby": m,
15
- required: u
16
- }) => /* @__PURE__ */ t(b.Provider, { value: { name: o, value: e, onChange: a }, children: /* @__PURE__ */ t(
17
- "div",
18
- {
19
- id: p,
20
- className: l(n.group, i),
1
+ import { jsxs as y, jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as h, useContext as R, createContext as G } from "react";
3
+ import n from "clsx";
4
+ import a from "./Radio.module.scss.js";
5
+ const f = G(null), j = h(
6
+ ({
7
+ name: l,
8
+ value: r,
9
+ onChange: o,
10
+ className: i,
21
11
  style: d,
22
- role: "radiogroup",
23
- tabIndex: -1,
24
- "aria-label": c,
12
+ children: s,
13
+ id: c,
14
+ "aria-label": p,
25
15
  "aria-labelledby": m,
26
- "aria-required": u || void 0,
27
- children: s
28
- }
29
- ) });
30
- v.displayName = "RadioGroup";
31
- const G = g(
16
+ required: u,
17
+ error: b = !1
18
+ }, e) => /* @__PURE__ */ t(f.Provider, { value: { name: l, value: r, onChange: o, error: b }, children: /* @__PURE__ */ t(
19
+ "div",
20
+ {
21
+ ref: e,
22
+ id: c,
23
+ className: n(a.group, i),
24
+ style: d,
25
+ role: "radiogroup",
26
+ tabIndex: -1,
27
+ "aria-label": p,
28
+ "aria-labelledby": m,
29
+ "aria-required": u || void 0,
30
+ children: s
31
+ }
32
+ ) })
33
+ );
34
+ j.displayName = "RadioGroup";
35
+ const k = h(
32
36
  ({
33
- label: o,
34
- value: e,
35
- classes: a,
37
+ label: l,
38
+ value: r,
39
+ classes: o,
36
40
  className: i,
37
41
  style: d,
38
42
  onChange: s,
39
- checked: p,
40
- name: c,
41
- ...m
42
- }, u) => {
43
- const r = y(b), h = r?.name ?? c, x = r ? r.value === e : p, C = (N) => {
44
- r?.onChange?.(e), s?.(N);
43
+ checked: c,
44
+ name: p,
45
+ error: m = !1,
46
+ ...u
47
+ }, b) => {
48
+ const e = R(f), x = e?.name ?? p, C = e ? e.value === r : c, N = m || !!e?.error, g = (v) => {
49
+ e?.onChange?.(r), s?.(v);
45
50
  };
46
- return /* @__PURE__ */ f("label", { className: l(n.root, a?.root, i), style: d, children: [
51
+ return /* @__PURE__ */ y("label", { className: n(a.root, o?.root, i), style: d, children: [
47
52
  /* @__PURE__ */ t(
48
53
  "input",
49
54
  {
50
- ref: u,
55
+ ref: b,
51
56
  type: "radio",
52
- className: l(n.input, a?.input),
53
- name: h,
54
- value: e,
55
- checked: x,
56
- onChange: C,
57
- ...m
57
+ className: n(a.input, N && a.error, o?.input),
58
+ name: x,
59
+ value: r,
60
+ checked: C,
61
+ onChange: g,
62
+ ...u
58
63
  }
59
64
  ),
60
- o && /* @__PURE__ */ t("span", { className: l(n.label, a?.label), children: o })
65
+ l && /* @__PURE__ */ t("span", { className: n(a.label, o?.label), children: l })
61
66
  ] });
62
67
  }
63
68
  );
64
- G.displayName = "Radio";
69
+ k.displayName = "Radio";
65
70
  export {
66
- G as Radio,
67
- v as RadioGroup
71
+ k as Radio,
72
+ j as RadioGroup
68
73
  };
@@ -1,13 +1,15 @@
1
- const o = "crk-group-NNwCD", t = "crk-root-7fGik", r = "crk-input-43PQW", c = "crk-label-aW30x", l = {
2
- group: o,
3
- root: t,
4
- input: r,
5
- label: c
1
+ const r = "crk-group-NNwCD", o = "crk-root-7fGik", t = "crk-input-43PQW", c = "crk-error-Xb8Jc", e = "crk-label-aW30x", n = {
2
+ group: r,
3
+ root: o,
4
+ input: t,
5
+ error: c,
6
+ label: e
6
7
  };
7
8
  export {
8
- l as default,
9
- o as group,
10
- r as input,
11
- c as label,
12
- t as root
9
+ n as default,
10
+ c as error,
11
+ r as group,
12
+ t as input,
13
+ e as label,
14
+ o as root
13
15
  };
@@ -0,0 +1,57 @@
1
+ import { InputClasses, InputProps } from '../Input/Input';
2
+ export interface SearchInputClasses extends InputClasses {
3
+ /** The leading magnifier icon. */
4
+ icon: string;
5
+ /** The `loading` spinner. */
6
+ spinner: string;
7
+ /** The hotkey hint (`<Kbd>`). */
8
+ hint: string;
9
+ }
10
+ export interface SearchInputProps extends Omit<InputProps, 'prefix' | 'type' | 'clearable' | 'classes'> {
11
+ /** Fires with the text on every keystroke and with `''` on clear/Escape-clear. */
12
+ onValueChange?: (value: string) => void;
13
+ /**
14
+ * Fires with the *debounced* text once it has been quiet for `debounce` ms,
15
+ * immediately on Enter, and with `''` on clear. Never fires on mount, and
16
+ * never twice in a row with the same value.
17
+ */
18
+ onSearch?: (value: string) => void;
19
+ /** Quiet period before `onSearch` fires, in ms. `0` fires on every change. @default 300 */
20
+ debounce?: number;
21
+ /** Show a small spinner in the field while results load. @default false */
22
+ loading?: boolean;
23
+ /**
24
+ * Global shortcut that focuses the field (`'/'`, `'mod+k'`…, any
25
+ * `useKeyboard` chord). A key-cap hint is shown while the field is empty
26
+ * and unfocused. @default false
27
+ */
28
+ hotkey?: string | false;
29
+ /** Render the `hotkey` hint in the field. @default true */
30
+ showHotkeyHint?: boolean;
31
+ /**
32
+ * What Escape does inside the field: `'clear'` clears the text when there is
33
+ * any (and blurs when already empty), `'blur'` always blurs, `'none'` leaves
34
+ * it to your `onKeyDown`. @default 'clear'
35
+ */
36
+ onEscape?: 'clear' | 'blur' | 'none';
37
+ /** `aria-label` used unless you pass `aria-label` / `aria-labelledby`. @default 'Search' */
38
+ searchLabel?: string;
39
+ /** Override class names on internal elements. */
40
+ classes?: Partial<SearchInputClasses>;
41
+ }
42
+ /** `'mod+k'` → `'⌘K'` on macOS, `'Ctrl K'` elsewhere; `'/'` → `'/'`. */
43
+ export declare function formatHotkey(chord: string): string;
44
+ /**
45
+ * Search field: magnifier icon, clear button, debounced `onSearch`, optional
46
+ * loading spinner and a global focus hotkey with an in-field key-cap hint.
47
+ * The forwarded ref is the `<input>`, so `ref.current.focus()` works.
48
+ *
49
+ * @example
50
+ * <SearchInput
51
+ * placeholder="Search projects…"
52
+ * hotkey="/"
53
+ * loading={isFetching}
54
+ * onSearch={(q) => setQuery(q)}
55
+ * />
56
+ */
57
+ export declare const SearchInput: import('react').ForwardRefExoticComponent<Omit<SearchInputProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,116 @@
1
+ import { jsxs as F, Fragment as X, jsx as c } from "react/jsx-runtime";
2
+ import { forwardRef as Y, useRef as g, useCallback as S, useState as B, useEffect as Z } from "react";
3
+ import m from "clsx";
4
+ import d from "./SearchInput.module.scss.js";
5
+ import { Input as _ } from "../Input/Input.js";
6
+ import { Spinner as $ } from "../../Spinner/Spinner.js";
7
+ import { Kbd as V } from "../../Kbd/Kbd.js";
8
+ import { useDebouncedValue as q } from "../../../hooks/useDebouncedValue.js";
9
+ import { useKeyboard as ee } from "../../../hooks/useKeyboard.js";
10
+ const te = ({ className: o }) => /* @__PURE__ */ F(
11
+ "svg",
12
+ {
13
+ className: o,
14
+ viewBox: "0 0 20 20",
15
+ fill: "none",
16
+ stroke: "currentColor",
17
+ strokeWidth: "1.8",
18
+ "aria-hidden": "true",
19
+ children: [
20
+ /* @__PURE__ */ c("circle", { cx: "8.5", cy: "8.5", r: "5.5" }),
21
+ /* @__PURE__ */ c("path", { d: "M12.8 12.8L17 17", strokeLinecap: "round" })
22
+ ]
23
+ }
24
+ ), re = () => typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform ?? "");
25
+ function ne(o) {
26
+ const n = re(), i = o.split("+").map((r) => r.trim()).filter(Boolean);
27
+ return o.endsWith("+") && i.push("+"), i.map((r) => {
28
+ const t = r.toLowerCase();
29
+ return t === "mod" ? n ? "⌘" : "Ctrl" : t === "meta" || t === "cmd" || t === "command" ? n ? "⌘" : "Win" : t === "ctrl" || t === "control" ? n ? "⌃" : "Ctrl" : t === "alt" || t === "option" ? n ? "⌥" : "Alt" : t === "shift" ? n ? "⇧" : "Shift" : t === "esc" || t === "escape" ? "Esc" : t === "space" ? "Space" : r.length === 1 ? r.toUpperCase() : r;
30
+ }).join(n ? "" : " ");
31
+ }
32
+ const oe = Y(
33
+ ({
34
+ onValueChange: o,
35
+ onSearch: n,
36
+ debounce: i = 300,
37
+ loading: h = !1,
38
+ hotkey: r = !1,
39
+ showHotkeyHint: t = !0,
40
+ onEscape: y = "clear",
41
+ searchLabel: L = "Search",
42
+ classes: l,
43
+ suffix: C,
44
+ value: u,
45
+ defaultValue: b,
46
+ onChange: P,
47
+ onClear: R,
48
+ onKeyDown: j,
49
+ onFocus: K,
50
+ onBlur: M,
51
+ ...f
52
+ }, a) => {
53
+ const p = g(null), T = S(
54
+ (e) => {
55
+ p.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
56
+ },
57
+ [a]
58
+ ), [k, H] = B(() => b == null ? "" : String(b)), x = u != null, v = x ? String(u) : k, D = g(v), w = g(n);
59
+ w.current = n;
60
+ const s = S((e) => {
61
+ D.current !== e && (D.current = e, w.current?.(e));
62
+ }, []), E = q(v, i);
63
+ Z(() => {
64
+ s(E);
65
+ }, [E, s]);
66
+ const [O, I] = B(!1), W = (e) => {
67
+ x || H(e.target.value), P?.(e), o?.(e.target.value);
68
+ }, z = () => {
69
+ s(""), R?.();
70
+ }, A = () => {
71
+ const e = p.current;
72
+ if (!e) return;
73
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), s("");
74
+ }, U = (e) => {
75
+ j?.(e), !e.defaultPrevented && (e.key === "Enter" ? (e.preventDefault(), s(e.currentTarget.value)) : e.key === "Escape" && y !== "none" && (y === "clear" && e.currentTarget.value.length > 0 ? (e.preventDefault(), A()) : e.currentTarget.blur()));
76
+ }, G = S(() => {
77
+ p.current?.focus(), p.current?.select();
78
+ }, []);
79
+ ee(r ? { [r]: G } : {}, { active: !!r, preventDefault: !0 });
80
+ const N = !!r && t && v.length === 0 && !O, J = h || N || C ? /* @__PURE__ */ F(X, { children: [
81
+ h && /* @__PURE__ */ c($, { size: "sm", label: "Searching", className: m(d.spinner, l?.spinner) }),
82
+ N && /* @__PURE__ */ c(V, { size: "sm", className: m(d.hint, l?.hint), "aria-hidden": "true", children: ne(r) }),
83
+ C
84
+ ] }) : void 0, Q = f["aria-label"] !== void 0 || f["aria-labelledby"] !== void 0;
85
+ return /* @__PURE__ */ c(
86
+ _,
87
+ {
88
+ ref: T,
89
+ type: "search",
90
+ clearable: !0,
91
+ prefix: /* @__PURE__ */ c(te, { className: m(d.icon, l?.icon) }),
92
+ suffix: J,
93
+ value: u,
94
+ defaultValue: b,
95
+ onChange: W,
96
+ onClear: z,
97
+ onKeyDown: U,
98
+ onFocus: (e) => {
99
+ I(!0), K?.(e);
100
+ },
101
+ onBlur: (e) => {
102
+ I(!1), M?.(e);
103
+ },
104
+ "aria-label": Q ? void 0 : L,
105
+ classes: l,
106
+ ...f,
107
+ className: m(d.root, f.className)
108
+ }
109
+ );
110
+ }
111
+ );
112
+ oe.displayName = "SearchInput";
113
+ export {
114
+ oe as SearchInput,
115
+ ne as formatHotkey
116
+ };
@@ -0,0 +1,13 @@
1
+ const n = "crk-root-J798f", o = "crk-icon-qlYVE", t = "crk-spinner-2Q0Ra", c = "crk-hint-V22-E", r = {
2
+ root: n,
3
+ icon: o,
4
+ spinner: t,
5
+ hint: c
6
+ };
7
+ export {
8
+ r as default,
9
+ c as hint,
10
+ o as icon,
11
+ n as root,
12
+ t as spinner
13
+ };
@@ -0,0 +1,2 @@
1
+ export { SearchInput, formatHotkey } from './SearchInput';
2
+ export type { SearchInputProps, SearchInputClasses } from './SearchInput';
@@ -18,6 +18,12 @@ export interface SelectClasses {
18
18
  item: string;
19
19
  chip: string;
20
20
  chipRemove: string;
21
+ /** Spinner shown in the control while `loading`. */
22
+ spinner: string;
23
+ /** `<mark>` around the matched substring when `highlightMatches` is set. */
24
+ match: string;
25
+ /** Non-option rows in the menu: "No results", "Loading…", the search prompt. */
26
+ message: string;
21
27
  }
22
28
  export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onChange' | 'value'> {
23
29
  /** Toolkit size scale (independent of the native `size` HTML attribute). @default 'md' */
@@ -70,6 +76,44 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onCh
70
76
  * @default (q) => `Create "${q}"`
71
77
  */
72
78
  createLabel?: (query: string) => React.ReactNode;
79
+ /**
80
+ * Searchable / multi modes. **Remote mode**: when set, the Select stops
81
+ * filtering `options` itself and instead calls `onSearch` with the
82
+ * debounced query (and with `''` when the menu opens empty, so defaults can
83
+ * be loaded). You fetch and pass the matching `options`. Never called twice
84
+ * in a row with the same query.
85
+ */
86
+ onSearch?: (query: string) => void;
87
+ /** Remote mode: quiet period before `onSearch` fires; `0` = every keystroke. @default 250 */
88
+ searchDebounce?: number;
89
+ /**
90
+ * Remote mode: queries shorter than this don't call `onSearch`; the menu
91
+ * shows `searchPrompt` instead. @default 0
92
+ */
93
+ minSearchLength?: number;
94
+ /** Row shown while the query is shorter than `minSearchLength`. @default 'Type to search' */
95
+ searchPrompt?: React.ReactNode;
96
+ /**
97
+ * Searchable / multi modes: show a spinner in the control and a
98
+ * `loadingMessage` row in the menu (instead of "No results"). @default false
99
+ */
100
+ loading?: boolean;
101
+ /** Menu row while `loading`. @default 'Loading…' */
102
+ loadingMessage?: React.ReactNode;
103
+ /** Menu row when nothing matches. @default 'No results' */
104
+ noResultsMessage?: React.ReactNode;
105
+ /**
106
+ * Local filter mode: wrap the matched substring of each string `label` in a
107
+ * `<mark>` (semibold, inherits colour). Options with `content` are left as
108
+ * is. @default false
109
+ */
110
+ highlightMatches?: boolean;
111
+ /**
112
+ * Fallback labels for selected values whose option is not in the current
113
+ * `options` — remote search results that moved on, or values created via
114
+ * `allowCreate`. Falls back to the raw value when missing.
115
+ */
116
+ selectedLabels?: Record<string, React.ReactNode>;
73
117
  /**
74
118
  * Render the open menu in a portal at `document.body` so it escapes
75
119
  * `overflow: hidden` ancestors (Modal body, scroll containers, etc.).
@@ -86,6 +130,13 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onCh
86
130
  * - **Searchable**: set `searchable`. Custom dropdown with text filter.
87
131
  * - **Multi**: set `multiple`. Chip-based multi-select with text filter.
88
132
  *
133
+ * The searchable and multi modes filter `options` locally by default. Pass
134
+ * `onSearch` for **remote** search: the query (debounced by `searchDebounce`)
135
+ * is handed to you, you fetch and pass back `options`, and `loading` shows a
136
+ * spinner + a "Loading…" row meanwhile. `selectedLabels` keeps chips / the
137
+ * trigger labelled for values whose option is no longer in `options`;
138
+ * `minSearchLength` + `searchPrompt` gate short queries.
139
+ *
89
140
  * In the searchable and multi modes `name` / `form` go to a hidden native
90
141
  * `<select>` (so the value is submitted with `FormData`), `aria-*` / `data-*`
91
142
  * go to the visible control, `required` becomes `aria-required`, and
@@ -94,5 +145,6 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onCh
94
145
  * @example Native: <Select options={[{ value: 'a', label: 'A' }]} onValueChange={setValue} />
95
146
  * @example Searchable: <Select searchable options={users} value={id} onValueChange={setId} />
96
147
  * @example Multi: <Select multiple options={tags} value={selected} onValuesChange={setSelected} />
148
+ * @example Remote: <Select searchable options={results} loading={isFetching} onSearch={fetchUsers} value={id} onValueChange={setId} selectedLabels={{ [id]: name }} />
97
149
  */
98
150
  export declare const Select: import('react').ForwardRefExoticComponent<Omit<SelectProps, "ref"> & import('react').RefAttributes<HTMLSelectElement>>;