@overdoser/react-toolkit 0.19.0 → 0.20.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/AGENTS.md +1 -1
- package/CHANGELOG.md +33 -0
- package/components/Table/Table.d.ts +41 -16
- package/components/Table/Table.js +256 -245
- package/components/Table/index.d.ts +1 -1
- package/components/Table/useTableSort.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
- package/components/ThemeToggle/ThemeToggle.js +12 -11
- package/hooks/usePersistedState.js +40 -37
- package/hooks/useTheme.d.ts +2 -2
- package/hooks/useTheme.js +13 -15
- package/index.css +1 -1
- package/index.d.ts +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +6 -6
- package/manifest.json +58 -10
- package/package.json +1 -1
- package/utils/themeScript.d.ts +2 -0
- package/utils/themeScript.js +6 -6
package/AGENTS.md
CHANGED
|
@@ -25,7 +25,7 @@ For exhaustive component reference (every prop, every variant, every signature),
|
|
|
25
25
|
```
|
|
26
26
|
It wraps all toolkit CSS in a `crk` cascade layer, so any of your own *unlayered* rules beat it deterministically. See "Customizing styles" below.
|
|
27
27
|
|
|
28
|
-
4. **Dark mode (optional):** put `THEME_INIT_SCRIPT` in `<head>`
|
|
28
|
+
4. **Dark mode (optional, opt-in):** with no `data-theme` the toolkit is light, so upgrading never changes an app's look. To offer dark mode put `THEME_INIT_SCRIPT` in `<head>` (applies the stored choice before first paint; writes `system` when nothing is stored) and drop `<ThemeToggle />` in the header. A dark-only app just sets `data-theme="dark"` on `<html>`. `data-theme` on any element forces a theme for that subtree. Never hand-roll a theme switch or a second token set.
|
|
29
29
|
|
|
30
30
|
## Import rules
|
|
31
31
|
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,39 @@ All notable changes to `@overdoser/react-toolkit` are documented here.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.20.0]
|
|
8
|
+
|
|
9
|
+
Follow-ups from rolling 0.19.0 out to sixteen apps. Dark mode becomes opt-in
|
|
10
|
+
(a light-only app no longer turns dark on a dark-OS machine), the accent
|
|
11
|
+
tokens follow the app's primary, and `Table` gets a proper display-column
|
|
12
|
+
type. Apps that relied on 0.19.0 following the OS with no attribute must now
|
|
13
|
+
set `data-theme="system"` on `<html>`.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **Dark mode is opt-in.** With no `data-theme` the toolkit is light again;
|
|
18
|
+
`data-theme="system"` on `<html>` follows the OS. 0.19.0 followed the OS
|
|
19
|
+
by default, which flipped light-only apps to dark on dark-OS machines.
|
|
20
|
+
`useTheme`, `ThemeToggle` and `THEME_INIT_SCRIPT` now write `system`
|
|
21
|
+
instead of removing the attribute, so apps that adopted them are
|
|
22
|
+
unaffected. `ThemeToggle` and `getThemeInitScript` take `defaultTheme`.
|
|
23
|
+
- **`Table`** — `ColumnDef` is now `DataColumnDef | DisplayColumnDef`: a
|
|
24
|
+
data column keeps `key: keyof T` (a misspelled key is a type error again), a
|
|
25
|
+
column with no backing field (`'actions'`) is `{ id, render(row, index) }`
|
|
26
|
+
with a required renderer and row-typed callbacks. Rows may be any `object`
|
|
27
|
+
(interface-typed rows no longer fail `Record<string, unknown>`);
|
|
28
|
+
`useTableSort` is relaxed the same way.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- **Tokens** — `--crk-color-primary-text` and `--crk-color-primary-selected`
|
|
33
|
+
derive from `--crk-color-primary` with `color-mix` instead of fixed indigo,
|
|
34
|
+
so an app's accent carries into tints and dark mode.
|
|
35
|
+
- **`THEME_INIT_SCRIPT`** — a storage read that throws (blocked cookies,
|
|
36
|
+
sandboxed iframe) no longer skips the fallback theme.
|
|
37
|
+
- **`usePersistedState`** — two hooks on the same empty key each got the
|
|
38
|
+
first hook's initial value; each now falls back to its own.
|
|
39
|
+
|
|
7
40
|
## [0.19.0]
|
|
8
41
|
|
|
9
42
|
The survey release: everything the ~/GITCRK projects kept hand-rolling, plus
|
|
@@ -9,26 +9,13 @@ export interface TableBulkActionsContext<T> {
|
|
|
9
9
|
/** Clear the selection. */
|
|
10
10
|
clear: () => void;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
/** Object key on each row to read the cell value from. */
|
|
14
|
-
key: keyof T & string;
|
|
12
|
+
interface ColumnCommon {
|
|
15
13
|
/**
|
|
16
14
|
* Header content (string or any ReactNode). Interactive elements (e.g. a
|
|
17
15
|
* remove button) are allowed; inside a `sortable` column they must call
|
|
18
16
|
* `e.stopPropagation()` in their click handler so the click doesn't sort.
|
|
19
17
|
*/
|
|
20
18
|
header: ReactNode;
|
|
21
|
-
/** Enable click-to-sort on the header. */
|
|
22
|
-
sortable?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Direction the sort cycle starts with when this column is first clicked:
|
|
25
|
-
* `none → defaultSortDirection → opposite → none`. Use `'desc'` for
|
|
26
|
-
* columns where "highest first" is the natural question (scores, amounts).
|
|
27
|
-
* @default 'asc'
|
|
28
|
-
*/
|
|
29
|
-
defaultSortDirection?: 'asc' | 'desc';
|
|
30
|
-
/** Custom cell renderer; defaults to rendering `row[key]`. */
|
|
31
|
-
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
32
19
|
/** Column width (CSS value). */
|
|
33
20
|
width?: string | number;
|
|
34
21
|
/** Text alignment for cells in this column. */
|
|
@@ -41,6 +28,23 @@ export interface ColumnDef<T> {
|
|
|
41
28
|
* @default false
|
|
42
29
|
*/
|
|
43
30
|
sticky?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** A column backed by a row field: `key` names the field, `render` is optional. */
|
|
33
|
+
export interface DataColumnDef<T> extends ColumnCommon {
|
|
34
|
+
/** Object key on each row to read the cell value from. */
|
|
35
|
+
key: keyof T & string;
|
|
36
|
+
id?: never;
|
|
37
|
+
/** Enable click-to-sort on the header. */
|
|
38
|
+
sortable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Direction the sort cycle starts with when this column is first clicked:
|
|
41
|
+
* `none → defaultSortDirection → opposite → none`. Use `'desc'` for
|
|
42
|
+
* columns where "highest first" is the natural question (scores, amounts).
|
|
43
|
+
* @default 'asc'
|
|
44
|
+
*/
|
|
45
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
46
|
+
/** Custom cell renderer; defaults to rendering `row[key]`. */
|
|
47
|
+
render?: (value: T[keyof T], row: T, index: number) => ReactNode;
|
|
44
48
|
/**
|
|
45
49
|
* Per-cell class name for this column. Pass a string to apply the same
|
|
46
50
|
* class to every cell, or a function `(value, row, index) => className` to
|
|
@@ -54,6 +58,27 @@ export interface ColumnDef<T> {
|
|
|
54
58
|
*/
|
|
55
59
|
cellStyle?: React.CSSProperties | ((value: T[keyof T], row: T, index: number) => React.CSSProperties | undefined);
|
|
56
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* A column with no backing field (`'actions'`, `'select'`): `id` identifies it
|
|
63
|
+
* and `render` is required and receives the row. Not sortable.
|
|
64
|
+
*/
|
|
65
|
+
export interface DisplayColumnDef<T> extends ColumnCommon {
|
|
66
|
+
/** Unique id for the column (React key, `columnVisibility` key). */
|
|
67
|
+
id: string;
|
|
68
|
+
key?: never;
|
|
69
|
+
/** Renders the cell from the row. */
|
|
70
|
+
render: (row: T, index: number) => ReactNode;
|
|
71
|
+
/** Per-cell class name: a string, or `(row, index) => className`. */
|
|
72
|
+
cellClassName?: string | ((row: T, index: number) => string | undefined);
|
|
73
|
+
/** Per-cell inline style: an object, or `(row, index) => style`. */
|
|
74
|
+
cellStyle?: React.CSSProperties | ((row: T, index: number) => React.CSSProperties | undefined);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A table column: either a {@link DataColumnDef} (`key` names a row field) or
|
|
78
|
+
* a {@link DisplayColumnDef} (`id` + a required `render(row)`). A misspelled
|
|
79
|
+
* `key` is a type error; a display column's callbacks never receive a value.
|
|
80
|
+
*/
|
|
81
|
+
export type ColumnDef<T> = DataColumnDef<T> | DisplayColumnDef<T>;
|
|
57
82
|
export interface PaginationConfig {
|
|
58
83
|
/** Current page (1-based) */
|
|
59
84
|
page: number;
|
|
@@ -94,7 +119,7 @@ export interface TableClasses {
|
|
|
94
119
|
/** Skeleton rows rendered while `loading` with no data. */
|
|
95
120
|
loadingRow: string;
|
|
96
121
|
}
|
|
97
|
-
export interface TableProps<T extends
|
|
122
|
+
export interface TableProps<T extends object> {
|
|
98
123
|
/** Row data. */
|
|
99
124
|
data: T[];
|
|
100
125
|
/** Column definitions. */
|
|
@@ -245,6 +270,6 @@ export interface TableProps<T extends Record<string, unknown>> {
|
|
|
245
270
|
* )}
|
|
246
271
|
* />
|
|
247
272
|
*/
|
|
248
|
-
declare function TableInner<T extends
|
|
273
|
+
declare function TableInner<T extends object>({ 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;
|
|
249
274
|
export declare const Table: typeof TableInner;
|
|
250
275
|
export {};
|