@overdoser/react-toolkit 0.17.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 (160) hide show
  1. package/AGENTS.md +51 -7
  2. package/CHANGELOG.md +149 -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/Loader/Loader.d.ts +104 -0
  68. package/components/Loader/Loader.js +186 -0
  69. package/components/Loader/Loader.module.scss.js +70 -0
  70. package/components/Loader/index.d.ts +2 -0
  71. package/components/Modal/Modal.d.ts +1 -0
  72. package/components/Modal/Modal.js +40 -41
  73. package/components/Modal/Modal.module.scss.js +18 -16
  74. package/components/PageHeader/PageHeader.d.ts +61 -0
  75. package/components/PageHeader/PageHeader.js +73 -0
  76. package/components/PageHeader/PageHeader.module.scss.js +43 -0
  77. package/components/PageHeader/index.d.ts +2 -0
  78. package/components/ProgressBar/ProgressBar.d.ts +74 -0
  79. package/components/ProgressBar/ProgressBar.js +90 -0
  80. package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
  81. package/components/ProgressBar/index.d.ts +2 -0
  82. package/components/RelativeTime/RelativeTime.d.ts +45 -0
  83. package/components/RelativeTime/RelativeTime.js +43 -0
  84. package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
  85. package/components/RelativeTime/index.d.ts +2 -0
  86. package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
  87. package/components/SegmentedControl/SegmentedControl.js +131 -0
  88. package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
  89. package/components/SegmentedControl/index.d.ts +2 -0
  90. package/components/SplitPane/SplitPane.d.ts +61 -0
  91. package/components/SplitPane/SplitPane.js +171 -0
  92. package/components/SplitPane/SplitPane.module.scss.js +25 -0
  93. package/components/SplitPane/index.d.ts +2 -0
  94. package/components/StatCard/StatCard.d.ts +105 -0
  95. package/components/StatCard/StatCard.js +127 -0
  96. package/components/StatCard/StatCard.module.scss.js +72 -0
  97. package/components/StatCard/index.d.ts +2 -0
  98. package/components/StatusDot/StatusDot.d.ts +33 -0
  99. package/components/StatusDot/StatusDot.js +39 -0
  100. package/components/StatusDot/StatusDot.module.scss.js +32 -0
  101. package/components/StatusDot/index.d.ts +2 -0
  102. package/components/Table/Table.d.ts +100 -2
  103. package/components/Table/Table.js +371 -210
  104. package/components/Table/Table.module.scss.js +68 -46
  105. package/components/Table/index.d.ts +1 -1
  106. package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
  107. package/components/ThemeToggle/ThemeToggle.js +97 -0
  108. package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
  109. package/components/ThemeToggle/index.d.ts +2 -0
  110. package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
  111. package/components/inputs/Checkbox/Checkbox.js +29 -28
  112. package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
  113. package/components/inputs/Input/Input.d.ts +33 -1
  114. package/components/inputs/Input/Input.js +94 -35
  115. package/components/inputs/Input/Input.module.scss.js +14 -12
  116. package/components/inputs/Radio/Radio.d.ts +5 -4
  117. package/components/inputs/Radio/Radio.js +55 -50
  118. package/components/inputs/Radio/Radio.module.scss.js +12 -10
  119. package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
  120. package/components/inputs/SearchInput/SearchInput.js +116 -0
  121. package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
  122. package/components/inputs/SearchInput/index.d.ts +2 -0
  123. package/components/inputs/Select/Select.d.ts +52 -0
  124. package/components/inputs/Select/Select.js +494 -385
  125. package/components/inputs/Select/Select.module.scss.js +34 -30
  126. package/components/inputs/Switch/Switch.d.ts +15 -0
  127. package/components/inputs/Switch/Switch.js +8 -0
  128. package/components/inputs/Switch/index.d.ts +2 -0
  129. package/hooks/useDebouncedValue.d.ts +15 -0
  130. package/hooks/useDebouncedValue.js +15 -0
  131. package/hooks/useElementSize.d.ts +20 -0
  132. package/hooks/useElementSize.js +23 -0
  133. package/hooks/useKeyboard.d.ts +49 -5
  134. package/hooks/useKeyboard.js +66 -16
  135. package/hooks/useMediaQuery.d.ts +14 -0
  136. package/hooks/useMediaQuery.js +16 -0
  137. package/hooks/useNow.d.ts +14 -0
  138. package/hooks/useNow.js +35 -0
  139. package/hooks/usePersistedState.d.ts +30 -0
  140. package/hooks/usePersistedState.js +96 -0
  141. package/hooks/useResizable.d.ts +66 -0
  142. package/hooks/useResizable.js +105 -0
  143. package/hooks/useTheme.d.ts +33 -0
  144. package/hooks/useTheme.js +27 -0
  145. package/index.css +1 -1
  146. package/index.d.ts +60 -4
  147. package/index.js +208 -130
  148. package/index.layered.css +1 -1
  149. package/llms.txt +659 -25
  150. package/manifest.json +1797 -76
  151. package/package.json +1 -1
  152. package/recipes/confirm-modal.tsx +65 -53
  153. package/recipes/floating-copy-button.tsx +32 -28
  154. package/utils/formatBytes.d.ts +21 -0
  155. package/utils/formatBytes.js +14 -0
  156. package/utils/index.d.ts +6 -0
  157. package/utils/themeScript.d.ts +17 -0
  158. package/utils/themeScript.js +9 -0
  159. package/utils/timeAgo.d.ts +33 -0
  160. package/utils/timeAgo.js +37 -0
@@ -1,59 +1,81 @@
1
- const t = "crk-wrapper-zxjMt", r = "crk-scrollable-Apjbs", e = "crk-root-Gf85-", o = "crk-paginator-UlYIY", c = "crk-dragging-dAaIR", a = "crk-headerCell-ePPZW", l = "crk-headerCellSticky-Qwz3q", n = "crk-cellSticky-LwmbD", s = "crk-headerCellSortable-NMybk", p = "crk-sortIndicator-WGD2S", i = "crk-sortArrow-1-ok4", k = "crk-sortArrowActive-yhWrO", g = "crk-sortIndex-HGoca", d = "crk-row-H0wL1", w = "crk-cell-ZfnbG", S = "crk-emptyRow-AoPfj", y = "crk-emptyCell-99-7C", A = "crk-striped-6Qckq", h = "crk-hoverable-ljU9B", b = "crk-compact-2-UWr", C = "crk-paginatorInfo-BVca4", v = "crk-paginatorText-sqWS0", I = "crk-pageSizeSelect-yhqJQ", m = "crk-paginatorNav-MDSui", u = "crk-pageButton-1PX-g", x = "crk-pageButtonActive--D7Q7", B = "crk-pageEllipsis-en59J", f = {
2
- wrapper: t,
1
+ const e = "crk-wrapper-zxjMt", r = "crk-scrollable-Apjbs", t = "crk-root-Gf85-", o = "crk-paginator-UlYIY", c = "crk-dragging-dAaIR", l = "crk-headerCell-ePPZW", a = "crk-headerCellSticky-Qwz3q", s = "crk-cellSticky-LwmbD", n = "crk-headerCellSortable-NMybk", k = "crk-sortIndicator-WGD2S", i = "crk-sortArrow-1-ok4", p = "crk-sortArrowActive-yhWrO", d = "crk-sortIndex-HGoca", g = "crk-row-H0wL1", b = "crk-cell-ZfnbG", w = "crk-emptyRow-AoPfj", u = "crk-emptyCell-99-7C", C = "crk-loaderWrap-Bug3B", S = "crk-loadingRow-i25F2", y = "crk-rowClickable--9VTD", A = "crk-rowSelected-ucID4", h = "crk-hoverable-ljU9B", B = "crk-selectHeaderCell-sK1ej", m = "crk-selectCell-4A3ho", v = "crk-layoutFixed-PUK1R", I = "crk-bulkBar-OPem5", x = "crk-bulkLabel-Z5fZQ", f = "crk-bulkClear--wKbf", R = "crk-bulkActions-jm9bq", W = "crk-striped-6Qckq", j = "crk-compact-2-UWr", D = "crk-paginatorInfo-BVca4", P = "crk-paginatorText-sqWS0", q = "crk-pageSizeSelect-yhqJQ", z = "crk-paginatorNav-MDSui", H = "crk-pageButton-1PX-g", L = "crk-pageButtonActive--D7Q7", Q = "crk-pageEllipsis-en59J", F = {
2
+ wrapper: e,
3
3
  scrollable: r,
4
- root: e,
4
+ root: t,
5
5
  paginator: o,
6
6
  dragging: c,
7
- headerCell: a,
8
- headerCellSticky: l,
9
- cellSticky: n,
10
- headerCellSortable: s,
11
- sortIndicator: p,
7
+ headerCell: l,
8
+ headerCellSticky: a,
9
+ cellSticky: s,
10
+ headerCellSortable: n,
11
+ sortIndicator: k,
12
12
  sortArrow: i,
13
- sortArrowActive: k,
14
- sortIndex: g,
15
- row: d,
16
- cell: w,
17
- emptyRow: S,
18
- emptyCell: y,
19
- striped: A,
13
+ sortArrowActive: p,
14
+ sortIndex: d,
15
+ row: g,
16
+ cell: b,
17
+ emptyRow: w,
18
+ emptyCell: u,
19
+ loaderWrap: C,
20
+ loadingRow: S,
21
+ rowClickable: y,
22
+ rowSelected: A,
20
23
  hoverable: h,
21
- compact: b,
22
- paginatorInfo: C,
23
- paginatorText: v,
24
- pageSizeSelect: I,
25
- paginatorNav: m,
26
- pageButton: u,
27
- pageButtonActive: x,
28
- pageEllipsis: B
24
+ selectHeaderCell: B,
25
+ selectCell: m,
26
+ layoutFixed: v,
27
+ bulkBar: I,
28
+ bulkLabel: x,
29
+ bulkClear: f,
30
+ bulkActions: R,
31
+ striped: W,
32
+ compact: j,
33
+ paginatorInfo: D,
34
+ paginatorText: P,
35
+ pageSizeSelect: q,
36
+ paginatorNav: z,
37
+ pageButton: H,
38
+ pageButtonActive: L,
39
+ pageEllipsis: Q
29
40
  };
30
41
  export {
31
- w as cell,
32
- n as cellSticky,
33
- b as compact,
34
- f as default,
42
+ R as bulkActions,
43
+ I as bulkBar,
44
+ f as bulkClear,
45
+ x as bulkLabel,
46
+ b as cell,
47
+ s as cellSticky,
48
+ j as compact,
49
+ F as default,
35
50
  c as dragging,
36
- y as emptyCell,
37
- S as emptyRow,
38
- a as headerCell,
39
- s as headerCellSortable,
40
- l as headerCellSticky,
51
+ u as emptyCell,
52
+ w as emptyRow,
53
+ l as headerCell,
54
+ n as headerCellSortable,
55
+ a as headerCellSticky,
41
56
  h as hoverable,
42
- u as pageButton,
43
- x as pageButtonActive,
44
- B as pageEllipsis,
45
- I as pageSizeSelect,
57
+ v as layoutFixed,
58
+ C as loaderWrap,
59
+ S as loadingRow,
60
+ H as pageButton,
61
+ L as pageButtonActive,
62
+ Q as pageEllipsis,
63
+ q as pageSizeSelect,
46
64
  o as paginator,
47
- C as paginatorInfo,
48
- m as paginatorNav,
49
- v as paginatorText,
50
- e as root,
51
- d as row,
65
+ D as paginatorInfo,
66
+ z as paginatorNav,
67
+ P as paginatorText,
68
+ t as root,
69
+ g as row,
70
+ y as rowClickable,
71
+ A as rowSelected,
52
72
  r as scrollable,
73
+ m as selectCell,
74
+ B as selectHeaderCell,
53
75
  i as sortArrow,
54
- k as sortArrowActive,
55
- g as sortIndex,
56
- p as sortIndicator,
57
- A as striped,
58
- t as wrapper
76
+ p as sortArrowActive,
77
+ d as sortIndex,
78
+ k as sortIndicator,
79
+ W as striped,
80
+ e as wrapper
59
81
  };
@@ -1,4 +1,4 @@
1
1
  export { Table } from './Table';
2
- export type { TableProps, TableClasses, ColumnDef, PaginationConfig } from './Table';
2
+ export type { TableProps, TableClasses, ColumnDef, PaginationConfig, TableRowKey, TableBulkActionsContext } from './Table';
3
3
  export { useTableSort } from './useTableSort';
4
4
  export type { SortConfig } from './useTableSort';
@@ -0,0 +1,38 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { Theme } from '../../hooks/useTheme';
3
+ export interface ThemeToggleClasses {
4
+ root: string;
5
+ icon: string;
6
+ label: string;
7
+ option: string;
8
+ optionSelected: string;
9
+ }
10
+ export interface ThemeToggleProps extends Omit<ComponentPropsWithRef<'button'>, 'onChange'> {
11
+ /** Offer "system" (follow the OS) as a third state. @default true */
12
+ allowSystem?: boolean;
13
+ /**
14
+ * `'icon'`: one button cycling light → dark → system.
15
+ * `'segmented'`: a radiogroup with one option per theme.
16
+ * @default 'icon'
17
+ */
18
+ variant?: 'icon' | 'segmented';
19
+ /** @default 'md' */
20
+ size?: 'sm' | 'md';
21
+ /** Human labels per theme (also used for aria). @default { light: 'Light', dark: 'Dark', system: 'System' } */
22
+ labels?: Partial<Record<Theme, string>>;
23
+ /** Render the label text next to the icon. @default false */
24
+ showLabel?: boolean;
25
+ /** localStorage key passed to `useTheme`. @default 'crk-theme' */
26
+ storageKey?: string;
27
+ /** Override class names on internal elements. */
28
+ classes?: Partial<ThemeToggleClasses>;
29
+ }
30
+ /**
31
+ * Light / dark / system switch wired to `useTheme`. Drop it in a header;
32
+ * every instance on the page stays in sync and the choice persists.
33
+ *
34
+ * @example
35
+ * <ThemeToggle />
36
+ * <ThemeToggle variant="segmented" showLabel />
37
+ */
38
+ export declare const ThemeToggle: import('react').ForwardRefExoticComponent<Omit<ThemeToggleProps, "ref"> & import('react').RefAttributes<HTMLButtonElement | HTMLDivElement>>;
@@ -0,0 +1,97 @@
1
+ import { jsx as r, jsxs as p } from "react/jsx-runtime";
2
+ import { forwardRef as D } from "react";
3
+ import a from "clsx";
4
+ import t from "./ThemeToggle.module.scss.js";
5
+ import { useTheme as S } from "../../hooks/useTheme.js";
6
+ const B = { light: "Light", dark: "Dark", system: "System" }, T = {
7
+ light: /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
8
+ /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "4" }),
9
+ /* @__PURE__ */ r("path", { d: "M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41" })
10
+ ] }),
11
+ dark: /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" }) }),
12
+ system: /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
13
+ /* @__PURE__ */ r("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
14
+ /* @__PURE__ */ r("path", { d: "M8 21h8M12 17v4" })
15
+ ] })
16
+ }, $ = D(
17
+ ({
18
+ allowSystem: w = !0,
19
+ variant: L = "icon",
20
+ size: g = "md",
21
+ labels: A,
22
+ showLabel: c = !1,
23
+ storageKey: N,
24
+ classes: n,
25
+ className: k,
26
+ style: f,
27
+ onClick: j,
28
+ ...v
29
+ }, x) => {
30
+ const { theme: y, setTheme: u } = S({ storageKey: N }), i = { ...B, ...A }, e = w ? ["light", "dark", "system"] : ["light", "dark"], l = e.includes(y) ? y : "light", b = e[(e.indexOf(l) + 1) % e.length];
31
+ if (L === "segmented") {
32
+ const { "aria-label": s, ...C } = v;
33
+ return /* @__PURE__ */ r(
34
+ "div",
35
+ {
36
+ ref: x,
37
+ role: "radiogroup",
38
+ "aria-label": s ?? "Theme",
39
+ className: a(t.group, t[g], n?.root, k),
40
+ style: f,
41
+ ...C,
42
+ children: e.map((o) => {
43
+ const m = o === l;
44
+ return /* @__PURE__ */ p(
45
+ "button",
46
+ {
47
+ type: "button",
48
+ role: "radio",
49
+ "aria-checked": m,
50
+ "aria-label": c ? void 0 : i[o],
51
+ title: c ? void 0 : i[o],
52
+ tabIndex: m ? 0 : -1,
53
+ className: a(t.option, m && t.optionSelected, n?.option, m && n?.optionSelected),
54
+ onClick: () => u(o),
55
+ onKeyDown: (d) => {
56
+ const M = e.indexOf(o);
57
+ let h;
58
+ (d.key === "ArrowRight" || d.key === "ArrowDown") && (h = e[(M + 1) % e.length]), (d.key === "ArrowLeft" || d.key === "ArrowUp") && (h = e[(M - 1 + e.length) % e.length]), h && (d.preventDefault(), u(h), d.currentTarget.parentElement?.querySelector(`[data-theme-option="${h}"]`)?.focus());
59
+ },
60
+ "data-theme-option": o,
61
+ children: [
62
+ /* @__PURE__ */ r("span", { className: a(t.icon, n?.icon), children: T[o] }),
63
+ c && /* @__PURE__ */ r("span", { className: a(t.label, n?.label), children: i[o] })
64
+ ]
65
+ },
66
+ o
67
+ );
68
+ })
69
+ }
70
+ );
71
+ }
72
+ return /* @__PURE__ */ p(
73
+ "button",
74
+ {
75
+ ref: x,
76
+ type: "button",
77
+ "aria-label": `Theme: ${i[l]}, switch to ${i[b]}`,
78
+ title: `Theme: ${i[l]}`,
79
+ "data-theme-value": l,
80
+ className: a(t.root, t[g], c && t.withLabel, n?.root, k),
81
+ style: f,
82
+ onClick: (s) => {
83
+ j?.(s), s.defaultPrevented || u(b);
84
+ },
85
+ ...v,
86
+ children: [
87
+ /* @__PURE__ */ r("span", { className: a(t.icon, n?.icon), children: T[l] }),
88
+ c && /* @__PURE__ */ r("span", { className: a(t.label, n?.label), children: i[l] })
89
+ ]
90
+ }
91
+ );
92
+ }
93
+ );
94
+ $.displayName = "ThemeToggle";
95
+ export {
96
+ $ as ThemeToggle
97
+ };
@@ -0,0 +1,23 @@
1
+ const o = "crk-root-UhmGj", t = "crk-option-NaLkU", c = "crk-sm-7EFQ8", n = "crk-icon--PHn2", e = "crk-md-xWcBl", l = "crk-withLabel-QbVAa", r = "crk-label-C5ZXw", s = "crk-group-ZLXl1", i = "crk-optionSelected-Qi1Pu", a = {
2
+ root: o,
3
+ option: t,
4
+ sm: c,
5
+ icon: n,
6
+ md: e,
7
+ withLabel: l,
8
+ label: r,
9
+ group: s,
10
+ optionSelected: i
11
+ };
12
+ export {
13
+ a as default,
14
+ s as group,
15
+ n as icon,
16
+ r as label,
17
+ e as md,
18
+ t as option,
19
+ i as optionSelected,
20
+ o as root,
21
+ c as sm,
22
+ l as withLabel
23
+ };
@@ -0,0 +1,2 @@
1
+ export { ThemeToggle } from './ThemeToggle';
2
+ export type { ThemeToggleProps, ThemeToggleClasses } from './ThemeToggle';
@@ -15,6 +15,8 @@ export interface CheckboxProps extends ComponentPropsWithRef<'input'> {
15
15
  variant?: 'checkbox' | 'switch';
16
16
  /** Sets the DOM `indeterminate` property; visually distinct from checked/unchecked. Ignored when `variant="switch"`. @default false */
17
17
  indeterminate?: boolean;
18
+ /** Apply error styling (set automatically by `FormField` when the field is invalid). @default false */
19
+ error?: boolean;
18
20
  /** Override class names on internal elements. */
19
21
  classes?: Partial<CheckboxClasses>;
20
22
  }
@@ -1,50 +1,51 @@
1
- import { jsxs as x, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as b, useRef as d, useEffect as w } from "react";
1
+ import { jsxs as b, jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as d, useRef as w, useEffect as k } from "react";
3
3
  import s from "clsx";
4
- import t from "./Checkbox.module.scss.js";
5
- const k = b(
4
+ import e from "./Checkbox.module.scss.js";
5
+ const y = d(
6
6
  ({
7
- label: m,
8
- variant: f = "checkbox",
9
- indeterminate: l = !1,
7
+ label: a,
8
+ variant: l = "checkbox",
9
+ indeterminate: m = !1,
10
+ error: p = !1,
10
11
  classes: r,
11
- className: p,
12
- style: u,
13
- ...h
14
- }, e) => {
15
- const i = d(null), n = f === "switch", c = l && !n;
16
- return w(() => {
17
- i.current && (i.current.indeterminate = c);
18
- }, [c]), /* @__PURE__ */ x(
12
+ className: u,
13
+ style: h,
14
+ ...x
15
+ }, t) => {
16
+ const i = w(null), n = l === "switch", o = m && !n;
17
+ return k(() => {
18
+ i.current && (i.current.indeterminate = o);
19
+ }, [o]), /* @__PURE__ */ b(
19
20
  "label",
20
21
  {
21
22
  className: s(
22
- t.root,
23
- n && t.switchRoot,
24
- c && t.indeterminate,
23
+ e.root,
24
+ n && e.switchRoot,
25
+ o && e.indeterminate,
25
26
  r?.root,
26
- p
27
+ u
27
28
  ),
28
- style: u,
29
+ style: h,
29
30
  children: [
30
- /* @__PURE__ */ a(
31
+ /* @__PURE__ */ f(
31
32
  "input",
32
33
  {
33
- ref: (o) => {
34
- i.current = o, typeof e == "function" ? e(o) : e && (e.current = o);
34
+ ref: (c) => {
35
+ i.current = c, typeof t == "function" ? t(c) : t && (t.current = c);
35
36
  },
36
37
  type: "checkbox",
37
- className: s(t.input, n && t.switchInput, r?.input),
38
- ...h
38
+ className: s(e.input, n && e.switchInput, p && e.error, r?.input),
39
+ ...x
39
40
  }
40
41
  ),
41
- m && /* @__PURE__ */ a("span", { className: s(t.label, r?.label), children: m })
42
+ a && /* @__PURE__ */ f("span", { className: s(e.label, r?.label), children: a })
42
43
  ]
43
44
  }
44
45
  );
45
46
  }
46
47
  );
47
- k.displayName = "Checkbox";
48
+ y.displayName = "Checkbox";
48
49
  export {
49
- k as Checkbox
50
+ y as Checkbox
50
51
  };
@@ -1,15 +1,17 @@
1
- const t = "crk-root-61cKD", n = "crk-input-bAjPU", e = "crk-switchInput-Ichse", c = "crk-label-W9IeS", o = "crk-indeterminate-mLarv", r = {
1
+ const t = "crk-root-61cKD", r = "crk-input-bAjPU", e = "crk-error-8Cdk6", n = "crk-switchInput-Ichse", c = "crk-label-W9IeS", o = "crk-indeterminate-mLarv", s = {
2
2
  root: t,
3
- input: n,
4
- switchInput: e,
3
+ input: r,
4
+ error: e,
5
+ switchInput: n,
5
6
  label: c,
6
7
  indeterminate: o
7
8
  };
8
9
  export {
9
- r as default,
10
+ s as default,
11
+ e as error,
10
12
  o as indeterminate,
11
- n as input,
13
+ r as input,
12
14
  c as label,
13
15
  t as root,
14
- e as switchInput
16
+ n as switchInput
15
17
  };
@@ -4,6 +4,10 @@ export interface InputClasses {
4
4
  wrapper: string;
5
5
  prefix: string;
6
6
  suffix: string;
7
+ /** The show/hide password toggle (`revealable`). */
8
+ reveal: string;
9
+ /** The clear button (`clearable`). */
10
+ clear: string;
7
11
  }
8
12
  export interface InputProps extends Omit<ComponentPropsWithRef<'input'>, 'prefix'> {
9
13
  /** Toolkit size scale (independent of the native `size` HTML attribute). @default 'md' */
@@ -14,12 +18,40 @@ export interface InputProps extends Omit<ComponentPropsWithRef<'input'>, 'prefix
14
18
  prefix?: ReactNode;
15
19
  /** Content rendered inside the input wrapper, after the field. */
16
20
  suffix?: ReactNode;
21
+ /**
22
+ * For `type="password"`: render a show/hide toggle after the field that
23
+ * switches it between `password` and `text`. Uncontrolled (hidden by
24
+ * default) unless `revealed` is passed. @default false
25
+ */
26
+ revealable?: boolean;
27
+ /** Controlled reveal state (`revealable` only). */
28
+ revealed?: boolean;
29
+ /** Fires when the reveal toggle is used (`revealable` only). */
30
+ onRevealedChange?: (revealed: boolean) => void;
31
+ /** Accessible labels for the reveal toggle. @default { show: 'Show password', hide: 'Hide password' } */
32
+ revealLabels?: {
33
+ show: string;
34
+ hide: string;
35
+ };
36
+ /**
37
+ * Render a "×" button after the field while it has a value. Clearing fires
38
+ * `onChange` with an empty value (so controlled inputs and `FormField`
39
+ * update) and `onClear`. Hidden while `disabled` or `readOnly`. @default false
40
+ */
41
+ clearable?: boolean;
42
+ /** Accessible label for the clear button. @default 'Clear' */
43
+ clearLabel?: string;
44
+ /** Fires after the field was cleared through the clear button. */
45
+ onClear?: () => void;
17
46
  /** Override class names on internal elements. */
18
47
  classes?: Partial<InputClasses>;
19
48
  }
20
49
  /**
21
- * Themed text input with optional `prefix`/`suffix` slots.
50
+ * Themed text input with optional `prefix`/`suffix` slots, a show/hide
51
+ * toggle for passwords (`revealable`) and a clear button (`clearable`).
22
52
  *
23
53
  * @example <Input type="email" inputSize="lg" prefix="@" placeholder="username" />
54
+ * @example <Input type="password" revealable autoComplete="current-password" />
55
+ * @example <Input clearable value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search" />
24
56
  */
25
57
  export declare const Input: import('react').ForwardRefExoticComponent<Omit<InputProps, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
@@ -1,50 +1,109 @@
1
- import { jsx as n, jsxs as h } from "react/jsx-runtime";
2
- import { forwardRef as N } from "react";
3
- import a from "clsx";
4
- import r from "./Input.module.scss.js";
5
- const u = N(
1
+ import { jsx as n, jsxs as f } from "react/jsx-runtime";
2
+ import { forwardRef as K, useRef as Q, useCallback as U, useState as E } from "react";
3
+ import r from "clsx";
4
+ import t from "./Input.module.scss.js";
5
+ const X = /* @__PURE__ */ f("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: [
6
+ /* @__PURE__ */ n("path", { d: "M1.5 10S4.5 4.5 10 4.5 18.5 10 18.5 10 15.5 15.5 10 15.5 1.5 10 1.5 10z", strokeLinejoin: "round" }),
7
+ /* @__PURE__ */ n("circle", { cx: "10", cy: "10", r: "2.5" })
8
+ ] }), Y = /* @__PURE__ */ f("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: [
9
+ /* @__PURE__ */ n("path", { d: "M3 3l14 14", strokeLinecap: "round" }),
10
+ /* @__PURE__ */ n("path", { d: "M8.2 5.1A8.6 8.6 0 0110 4.9c5.5 0 8.5 5.1 8.5 5.1a14.4 14.4 0 01-2.6 3.1M11.9 11.9a2.5 2.5 0 01-3.6-3.5M5.1 6.3C2.8 7.9 1.5 10 1.5 10S4.5 15.1 10 15.1c1.2 0 2.3-.2 3.3-.6", strokeLinecap: "round", strokeLinejoin: "round" })
11
+ ] }), Z = /* @__PURE__ */ n("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M10 18a8 8 0 100-16 8 8 0 000 16zM7.3 7.3a1 1 0 011.4 0L10 8.6l1.3-1.3a1 1 0 111.4 1.4L11.4 10l1.3 1.3a1 1 0 01-1.4 1.4L10 11.4l-1.3 1.3a1 1 0 01-1.4-1.4L8.6 10 7.3 8.7a1 1 0 010-1.4z" }) }), _ = K(
6
12
  ({
7
- inputSize: e = "md",
8
- error: p = !1,
9
- prefix: o,
10
- suffix: t,
11
- classes: m,
12
- className: d,
13
- style: l,
14
- ...i
15
- }, c) => {
16
- const s = /* @__PURE__ */ n(
13
+ inputSize: v = "md",
14
+ error: w = !1,
15
+ prefix: l,
16
+ suffix: i,
17
+ revealable: N = !1,
18
+ revealed: m,
19
+ onRevealedChange: S,
20
+ revealLabels: j,
21
+ clearable: c = !1,
22
+ clearLabel: D = "Clear",
23
+ onClear: O,
24
+ classes: o,
25
+ className: g,
26
+ style: b,
27
+ type: k,
28
+ onChange: x,
29
+ ...y
30
+ }, a) => {
31
+ const I = Q(null), V = U(
32
+ (e) => {
33
+ I.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
34
+ },
35
+ [a]
36
+ ), d = N && k === "password", [H, W] = E(!1), s = m ?? H, z = () => {
37
+ const e = !s;
38
+ m === void 0 && W(e), S?.(e);
39
+ }, P = d && s ? "text" : k, C = j ?? { show: "Show password", hide: "Hide password" }, { value: u, defaultValue: p, disabled: M, readOnly: T } = y, [A, L] = E(
40
+ () => p != null && String(p).length > 0
41
+ ), F = u != null ? String(u).length > 0 : A, q = c && F && !M && !T, G = c ? (e) => {
42
+ L(e.target.value.length > 0), x?.(e);
43
+ } : x, J = () => {
44
+ const e = I.current;
45
+ if (!e) return;
46
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), L(!1), O?.(), e.focus();
47
+ }, R = (e) => e.preventDefault(), h = !!(l || i || d || c), B = /* @__PURE__ */ n(
17
48
  "input",
18
49
  {
19
- ref: c,
20
- className: a(
21
- r.root,
22
- r[e],
23
- p && r.error,
24
- o && r.hasPrefix,
25
- t && r.hasSuffix,
26
- m?.root,
27
- !o && !t && d
50
+ ref: V,
51
+ type: P,
52
+ className: r(
53
+ t.root,
54
+ t[v],
55
+ w && t.error,
56
+ (l || void 0) && t.hasPrefix,
57
+ (i || d || c) && t.hasSuffix,
58
+ o?.root,
59
+ !h && g
28
60
  ),
29
- style: !o && !t ? l : void 0,
30
- ...i
61
+ style: h ? void 0 : b,
62
+ onChange: G,
63
+ ...y
31
64
  }
32
65
  );
33
- return o || t ? /* @__PURE__ */ h(
66
+ return h ? /* @__PURE__ */ f(
34
67
  "div",
35
68
  {
36
- className: a(r.wrapper, r[e], p && r.error, m?.wrapper, d),
37
- style: l,
69
+ className: r(t.wrapper, t[v], w && t.error, o?.wrapper, g),
70
+ style: b,
38
71
  children: [
39
- o && /* @__PURE__ */ n("span", { className: a(r.prefix, m?.prefix), children: o }),
40
- s,
41
- t && /* @__PURE__ */ n("span", { className: a(r.suffix, m?.suffix), children: t })
72
+ l && /* @__PURE__ */ n("span", { className: r(t.prefix, o?.prefix), children: l }),
73
+ B,
74
+ i && /* @__PURE__ */ n("span", { className: r(t.suffix, o?.suffix), children: i }),
75
+ q && /* @__PURE__ */ n(
76
+ "button",
77
+ {
78
+ type: "button",
79
+ className: r(t.sideButton, t.clear, o?.clear),
80
+ "aria-label": D,
81
+ onMouseDown: R,
82
+ onClick: J,
83
+ tabIndex: -1,
84
+ children: Z
85
+ }
86
+ ),
87
+ d && /* @__PURE__ */ n(
88
+ "button",
89
+ {
90
+ type: "button",
91
+ className: r(t.sideButton, t.reveal, o?.reveal),
92
+ "aria-label": s ? C.hide : C.show,
93
+ "aria-pressed": s,
94
+ onMouseDown: R,
95
+ onClick: z,
96
+ disabled: M,
97
+ tabIndex: 0,
98
+ children: s ? Y : X
99
+ }
100
+ )
42
101
  ]
43
102
  }
44
- ) : s;
103
+ ) : B;
45
104
  }
46
105
  );
47
- u.displayName = "Input";
106
+ _.displayName = "Input";
48
107
  export {
49
- u as Input
108
+ _ as Input
50
109
  };
@@ -1,25 +1,27 @@
1
- const r = "crk-root-rSgdy", s = "crk-wrapper-GHy8V", c = "crk-sm-DptM5", f = "crk-md-F4B0G", o = "crk-lg-pBxwX", t = "crk-error-fucxe", e = "crk-prefix-w53Md", x = "crk-suffix-fcNgR", i = "crk-hasPrefix--bqPD", n = "crk-hasSuffix-zO0nX", p = {
1
+ const r = "crk-root-rSgdy", s = "crk-wrapper-GHy8V", c = "crk-sm-DptM5", o = "crk-md-F4B0G", t = "crk-lg-pBxwX", f = "crk-error-fucxe", e = "crk-prefix-w53Md", n = "crk-suffix-fcNgR", i = "crk-hasPrefix--bqPD", x = "crk-hasSuffix-zO0nX", p = "crk-sideButton-H3GC-", a = {
2
2
  root: r,
3
3
  wrapper: s,
4
4
  sm: c,
5
- md: f,
6
- lg: o,
7
- error: t,
5
+ md: o,
6
+ lg: t,
7
+ error: f,
8
8
  prefix: e,
9
- suffix: x,
9
+ suffix: n,
10
10
  hasPrefix: i,
11
- hasSuffix: n
11
+ hasSuffix: x,
12
+ sideButton: p
12
13
  };
13
14
  export {
14
- p as default,
15
- t as error,
15
+ a as default,
16
+ f as error,
16
17
  i as hasPrefix,
17
- n as hasSuffix,
18
- o as lg,
19
- f as md,
18
+ x as hasSuffix,
19
+ t as lg,
20
+ o as md,
20
21
  e as prefix,
21
22
  r as root,
23
+ p as sideButton,
22
24
  c as sm,
23
- x as suffix,
25
+ n as suffix,
24
26
  s as wrapper
25
27
  };