@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,5 +1,14 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEvent, ReactNode } from 'react';
2
2
  import { SortConfig } from './useTableSort';
3
+ export type TableRowKey = string | number;
4
+ export interface TableBulkActionsContext<T> {
5
+ /** Keys of the selected rows (from `rowKey`). */
6
+ selectedKeys: TableRowKey[];
7
+ /** The selected rows that are present in `data`. */
8
+ selectedRows: T[];
9
+ /** Clear the selection. */
10
+ clear: () => void;
11
+ }
3
12
  export interface ColumnDef<T> {
4
13
  /** Object key on each row to read the cell value from. */
5
14
  key: keyof T & string;
@@ -66,6 +75,24 @@ export interface TableClasses {
66
75
  emptyCell: string;
67
76
  paginator: string;
68
77
  pageButton: string;
78
+ /** Rows that react to `onRowClick`. */
79
+ rowClickable: string;
80
+ /** Rows whose key is in the selection. */
81
+ rowSelected: string;
82
+ /** The leading checkbox cell of each row (`selectable`). */
83
+ selectCell: string;
84
+ /** The select-all header cell (`selectable`). */
85
+ selectHeaderCell: string;
86
+ /** Bar above the table shown while rows are selected. */
87
+ bulkBar: string;
88
+ /** "N selected" text in the bulk bar. */
89
+ bulkLabel: string;
90
+ /** "Clear" button in the bulk bar. */
91
+ bulkClear: string;
92
+ /** Slot holding `bulkActions` in the bulk bar. */
93
+ bulkActions: string;
94
+ /** Skeleton rows rendered while `loading` with no data. */
95
+ loadingRow: string;
69
96
  }
70
97
  export interface TableProps<T extends Record<string, unknown>> {
71
98
  /** Row data. */
@@ -125,6 +152,57 @@ export interface TableProps<T extends Record<string, unknown>> {
125
152
  emptyMessage?: ReactNode;
126
153
  /** When provided, renders a paginator below the table. */
127
154
  pagination?: PaginationConfig;
155
+ /**
156
+ * Show a loading overlay over the rows (they stay mounted and keep their
157
+ * height, so the page doesn't jump on refetch). With no `data` yet, renders
158
+ * `loadingRows` skeleton rows instead of `emptyMessage`. Sets `aria-busy`.
159
+ * @default false
160
+ */
161
+ loading?: boolean;
162
+ /** Skeleton rows rendered while `loading` and `data` is empty. @default 3 */
163
+ loadingRows?: number;
164
+ /**
165
+ * Makes rows clickable: pointer cursor, hover highlight, `tabIndex=0` and
166
+ * Enter / Space activation. Clicks that originate from an interactive
167
+ * element inside the row (button, link, input, checkbox…) are ignored, so
168
+ * per-row action buttons keep working.
169
+ */
170
+ onRowClick?: (row: T, index: number, event: MouseEvent<HTMLTableRowElement>) => void;
171
+ /**
172
+ * Adds a leading checkbox column with a select-all header. Selection keys
173
+ * come from `rowKey` (set it — without it the row index is used, which
174
+ * breaks across pages and sorts). Shift-click selects a range.
175
+ * @default false
176
+ */
177
+ selectable?: boolean;
178
+ /** Controlled selection (row keys). Pair with `onSelectionChange`. */
179
+ selectedKeys?: TableRowKey[];
180
+ /** Initial selection for the uncontrolled case. @default [] */
181
+ defaultSelectedKeys?: TableRowKey[];
182
+ /** Fires with the next selection and the matching rows from `data`. */
183
+ onSelectionChange?: (keys: TableRowKey[], rows: T[]) => void;
184
+ /** Return `false` to disable the checkbox for a row. */
185
+ isRowSelectable?: (row: T) => boolean;
186
+ /**
187
+ * Rendered in a bar above the table while something is selected, next to
188
+ * the "N selected" label and a "Clear" button. A function receives
189
+ * `{ selectedKeys, selectedRows, clear }`.
190
+ */
191
+ bulkActions?: ReactNode | ((ctx: TableBulkActionsContext<T>) => ReactNode);
192
+ /** Text for the bulk bar. @default (n) => `${n} selected` */
193
+ selectionLabel?: (count: number) => ReactNode;
194
+ /**
195
+ * Hide columns by key without filtering `columns` (so sort config and
196
+ * widths stay stable): `{ email: false }` hides the `email` column; keys
197
+ * that are missing or `true` stay visible. Build the picker yourself
198
+ * (`CheckboxGroup`, or `DropdownItem checked`).
199
+ */
200
+ columnVisibility?: Record<string, boolean>;
201
+ /**
202
+ * `'fixed'` sets `table-layout: fixed` so live-updating cell content never
203
+ * reflows column widths (give columns a `width`). @default 'auto'
204
+ */
205
+ layout?: 'auto' | 'fixed';
128
206
  /** Override class names on internal elements. */
129
207
  classes?: Partial<TableClasses>;
130
208
  }
@@ -146,7 +224,27 @@ export interface TableProps<T extends Record<string, unknown>> {
146
224
  * `sticky: true` on the first column pins it to the left edge. Per-cell
147
225
  * styling (e.g. value-bucket shading) via `cellClassName`/`cellStyle` on
148
226
  * the column.
227
+ *
228
+ * **Loading**: `loading` overlays the rows without changing their height
229
+ * (skeleton rows when there is no data yet). **Clickable rows**:
230
+ * `onRowClick`. **Selection**: `selectable` + `rowKey` (+ `selectedKeys` /
231
+ * `onSelectionChange` to control it) with a select-all header, shift-range
232
+ * and a `bulkActions` bar. **Column visibility**: `columnVisibility` map.
233
+ * `layout="fixed"` stops live cell updates from reflowing column widths.
234
+ *
235
+ * @example
236
+ * <Table
237
+ * data={users}
238
+ * columns={columns}
239
+ * rowKey="id"
240
+ * loading={isFetching}
241
+ * onRowClick={(user) => navigate(`/users/${user.id}`)}
242
+ * selectable
243
+ * bulkActions={({ selectedRows, clear }) => (
244
+ * <Button size="sm" variant="danger" onClick={() => { archive(selectedRows); clear(); }}>Archive</Button>
245
+ * )}
246
+ * />
149
247
  */
150
- declare function TableInner<T extends Record<string, unknown>>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, scrollable, dragScroll, striped, hoverable, compact, className, style, rowKey, rowClassName, rowStyle, emptyMessage, pagination, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
248
+ declare function TableInner<T extends Record<string, unknown>>({ data, columns, sortConfig: controlledSortConfig, onSort, multiSort, scrollable, dragScroll, striped, hoverable, compact, className, style, rowKey, rowClassName, rowStyle, emptyMessage, pagination, loading, loadingRows, onRowClick, selectable, selectedKeys: controlledSelectedKeys, defaultSelectedKeys, onSelectionChange, isRowSelectable, bulkActions, selectionLabel, columnVisibility, layout, classes, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
151
249
  export declare const Table: typeof TableInner;
152
250
  export {};