@dashforge/tw 0.5.0-beta → 0.6.0-beta
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/CHANGELOG.md +268 -0
- package/dist/index.esm.js +1553 -4
- package/dist/src/components/Table/Table.d.ts +24 -0
- package/dist/src/components/Table/Table.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/getNestedValue.d.ts +20 -0
- package/dist/src/components/Table/_internal/getNestedValue.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useColumnAutoDetect.d.ts +45 -0
- package/dist/src/components/Table/_internal/useColumnAutoDetect.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useControllableState.d.ts +23 -0
- package/dist/src/components/Table/_internal/useControllableState.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useDebouncedValue.d.ts +10 -0
- package/dist/src/components/Table/_internal/useDebouncedValue.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useTableFilter.d.ts +13 -0
- package/dist/src/components/Table/_internal/useTableFilter.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useTableSearch.d.ts +23 -0
- package/dist/src/components/Table/_internal/useTableSearch.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useTableSelection.d.ts +25 -0
- package/dist/src/components/Table/_internal/useTableSelection.d.ts.map +1 -0
- package/dist/src/components/Table/_internal/useTableSort.d.ts +20 -0
- package/dist/src/components/Table/_internal/useTableSort.d.ts.map +1 -0
- package/dist/src/components/Table/cells/RenderButton.d.ts +13 -0
- package/dist/src/components/Table/cells/RenderButton.d.ts.map +1 -0
- package/dist/src/components/Table/cells/RenderChip.d.ts +80 -0
- package/dist/src/components/Table/cells/RenderChip.d.ts.map +1 -0
- package/dist/src/components/Table/cells/RenderText.d.ts +21 -0
- package/dist/src/components/Table/cells/RenderText.d.ts.map +1 -0
- package/dist/src/components/Table/cells/RenderTwoLine.d.ts +20 -0
- package/dist/src/components/Table/cells/RenderTwoLine.d.ts.map +1 -0
- package/dist/src/components/Table/cells/RowActionsMenu.d.ts +36 -0
- package/dist/src/components/Table/cells/RowActionsMenu.d.ts.map +1 -0
- package/dist/src/components/Table/cells/index.d.ts +11 -0
- package/dist/src/components/Table/cells/index.d.ts.map +1 -0
- package/dist/src/components/Table/table.types.d.ts +304 -0
- package/dist/src/components/Table/table.types.d.ts.map +1 -0
- package/dist/src/components/Table/table.variants.d.ts +285 -0
- package/dist/src/components/Table/table.variants.d.ts.map +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Table/Table.test.tsx +603 -0
- package/src/components/Table/Table.tsx +816 -0
- package/src/components/Table/_internal/getNestedValue.test.ts +50 -0
- package/src/components/Table/_internal/getNestedValue.ts +32 -0
- package/src/components/Table/_internal/themeIdentity.test.ts +84 -0
- package/src/components/Table/_internal/useColumnAutoDetect.test.ts +123 -0
- package/src/components/Table/_internal/useColumnAutoDetect.ts +100 -0
- package/src/components/Table/_internal/useControllableState.ts +48 -0
- package/src/components/Table/_internal/useDebouncedValue.ts +24 -0
- package/src/components/Table/_internal/useTableFilter.ts +37 -0
- package/src/components/Table/_internal/useTableSearch.test.ts +115 -0
- package/src/components/Table/_internal/useTableSearch.ts +66 -0
- package/src/components/Table/_internal/useTableSelection.test.ts +100 -0
- package/src/components/Table/_internal/useTableSelection.ts +100 -0
- package/src/components/Table/_internal/useTableSort.test.ts +150 -0
- package/src/components/Table/_internal/useTableSort.ts +141 -0
- package/src/components/Table/cells/RenderButton.tsx +23 -0
- package/src/components/Table/cells/RenderChip.tsx +103 -0
- package/src/components/Table/cells/RenderText.tsx +37 -0
- package/src/components/Table/cells/RenderTwoLine.tsx +34 -0
- package/src/components/Table/cells/RowActionsMenu.tsx +147 -0
- package/src/components/Table/cells/index.ts +14 -0
- package/src/components/Table/table.types.ts +337 -0
- package/src/components/Table/table.variants.ts +207 -0
- package/src/index.ts +43 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TableProps } from './table.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dashforge TW `<Table>` — declarative-first, market-grounded table.
|
|
4
|
+
*
|
|
5
|
+
* Design references:
|
|
6
|
+
* - Visual: Stripe (clean line dividers, hover row actions, sticky header)
|
|
7
|
+
* - Density: Pencil & Paper UX research (compact / comfortable / spacious)
|
|
8
|
+
* - A11Y: W3C WAI Table tutorial (semantic `<table>`, scope, aria-sort)
|
|
9
|
+
* - Column model: extended from Dashforge MUI Table existing API
|
|
10
|
+
*
|
|
11
|
+
* Smart defaults: column types auto-detected → numbers right-aligned
|
|
12
|
+
* + tabular-nums, dates monospace, booleans center-aligned. Override
|
|
13
|
+
* via explicit `align` / `monospace` per column.
|
|
14
|
+
*
|
|
15
|
+
* State (sort / search / filter / selection / expansion) is internal
|
|
16
|
+
* by default; pass the controlled prop + matching change handler to
|
|
17
|
+
* lift state up — same pattern as `<TextField>` value.
|
|
18
|
+
*
|
|
19
|
+
* i18n: pass `header: t('users.name')` for column headers; pass
|
|
20
|
+
* `labels={{ searchPlaceholder: t('...'), ... }}` for internal default
|
|
21
|
+
* strings.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Table<T extends object>(props: TableProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
24
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,kBAAkB,CAAC;AA0B1B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,kDAgW3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walk a dotted path through an object and return the value, or
|
|
3
|
+
* `undefined` if any segment is missing / nullish.
|
|
4
|
+
*
|
|
5
|
+
* Bug fix from the MUI-side Table (Sprint 4.1 motivation): the
|
|
6
|
+
* existing wrapper typed `field: NestedKeyOf<T>` but performed a
|
|
7
|
+
* flat `row[col.field]` lookup at runtime — nested keys silently
|
|
8
|
+
* returned `undefined`. This helper makes the runtime match the
|
|
9
|
+
* type contract.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* getNestedValue({ user: { name: 'Jane' } }, 'user.name') // 'Jane'
|
|
14
|
+
* getNestedValue({ user: null }, 'user.name') // undefined
|
|
15
|
+
* getNestedValue({}, 'a.b.c') // undefined
|
|
16
|
+
* getNestedValue({ a: { b: 0 } }, 'a.b') // 0 (NOT undefined)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNestedValue<T extends object>(row: T, path: string): unknown;
|
|
20
|
+
//# sourceMappingURL=getNestedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNestedValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/getNestedValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,MAAM,GACX,OAAO,CAUT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TableColumn, TableColumnInferredType } from '../table.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-detects the primitive type of each column by scanning the
|
|
4
|
+
* first non-null value across the supplied rows. Drives smart
|
|
5
|
+
* defaults for `align` and `monospace` on the cell render path.
|
|
6
|
+
*
|
|
7
|
+
* Scans only the first N rows (default 50) for performance — if the
|
|
8
|
+
* dataset's first 50 rows are unrepresentative, the consumer can
|
|
9
|
+
* override per-column via explicit `align` / `monospace` props.
|
|
10
|
+
*
|
|
11
|
+
* Returns `Map<columnField, inferredType>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useColumnAutoDetect<T extends object>(rows: T[], cols: TableColumn<T>[], sampleSize?: number): Map<string, TableColumnInferredType>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the effective `align` for a column, honoring explicit
|
|
16
|
+
* `col.align` first and falling back to the inferred type.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveAlign(col: {
|
|
19
|
+
align?: 'left' | 'right' | 'center';
|
|
20
|
+
}, inferred: TableColumnInferredType | undefined): 'left' | 'right' | 'center';
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the effective `tabularNums` flag for a column.
|
|
23
|
+
*
|
|
24
|
+
* `tabular-nums` is a `font-variant-numeric` rule that makes every
|
|
25
|
+
* digit occupy the same width — it does NOT change the font family.
|
|
26
|
+
* Auto-applied for `number` and `date` columns so currency values
|
|
27
|
+
* and ISO dates align cleanly. Explicit `col.tabularNums` wins.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveTabularNums(col: {
|
|
30
|
+
tabularNums?: boolean;
|
|
31
|
+
}, inferred: TableColumnInferredType | undefined): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the effective `monospace` flag for a column.
|
|
34
|
+
*
|
|
35
|
+
* `font-mono` changes the font FAMILY to a monospace stack, which
|
|
36
|
+
* would override the consumer's theme `font-sans`. The library
|
|
37
|
+
* never auto-applies it — only an explicit `col.monospace: true`
|
|
38
|
+
* opts in. Consumers wanting a custom mono stack configure it
|
|
39
|
+
* through Tailwind's `theme.extend.fontFamily.mono` in their own
|
|
40
|
+
* preset (the dashforgePreset does not own the `fontFamily` axis).
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveMonospace(col: {
|
|
43
|
+
monospace?: boolean;
|
|
44
|
+
}): boolean;
|
|
45
|
+
//# sourceMappingURL=useColumnAutoDetect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useColumnAutoDetect.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useColumnAutoDetect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,UAAU,SAAK,GACd,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAiBtC;AAcD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;CAAE,EAC5C,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAC5C,MAAM,GAAG,OAAO,GAAG,QAAQ,CAU7B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,EAC9B,QAAQ,EAAE,uBAAuB,GAAG,SAAS,GAC5C,OAAO,CAGT;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAET"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic "controllable" state hook — switches between controlled
|
|
3
|
+
* (via parent-supplied value + setter) and uncontrolled (internal
|
|
4
|
+
* `useState`).
|
|
5
|
+
*
|
|
6
|
+
* - If `controlledValue !== undefined`, the hook is in **controlled**
|
|
7
|
+
* mode: the internal state is ignored; the returned setter calls
|
|
8
|
+
* `onControlledChange` only.
|
|
9
|
+
* - Otherwise it's in **uncontrolled** mode: internal `useState`,
|
|
10
|
+
* defaulting to `defaultValue`. The optional `onControlledChange`
|
|
11
|
+
* is still fired on every change so the parent can react.
|
|
12
|
+
*
|
|
13
|
+
* The control mode is determined per-render. Mixing modes (passing
|
|
14
|
+
* `controlledValue` undefined sometimes) is a consumer bug — we don't
|
|
15
|
+
* try to "remember" the last mode (React's rules-of-hooks make that
|
|
16
|
+
* unsafe).
|
|
17
|
+
*/
|
|
18
|
+
export declare function useControllableState<T>(args: {
|
|
19
|
+
controlledValue: T | undefined;
|
|
20
|
+
defaultValue: T;
|
|
21
|
+
onChange?: (value: T) => void;
|
|
22
|
+
}): [T, (next: T | ((prev: T) => T)) => void];
|
|
23
|
+
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useControllableState.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE;IAC5C,eAAe,EAAE,CAAC,GAAG,SAAS,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAwB5C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a debounced version of `value` — only updates after `delayMs`
|
|
3
|
+
* of no further changes. Used by the search input so we don't re-filter
|
|
4
|
+
* the entire row set on every keystroke.
|
|
5
|
+
*
|
|
6
|
+
* `delayMs <= 0` short-circuits to the input value (no debounce —
|
|
7
|
+
* useful for tests).
|
|
8
|
+
*/
|
|
9
|
+
export declare function useDebouncedValue<T>(value: T, delayMs: number): T;
|
|
10
|
+
//# sourceMappingURL=useDebouncedValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebouncedValue.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useDebouncedValue.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAajE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TableFilterModel } from '../table.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Filters `rows` by the per-column filter model. v1 only supports
|
|
4
|
+
* the `contains` operator (text substring) — additional ops
|
|
5
|
+
* (`equals`, `in`, `gte`, `lte`, `between`, `before`, `after`)
|
|
6
|
+
* land in v1-bis once the filter UI surface for each shape is
|
|
7
|
+
* fleshed out.
|
|
8
|
+
*
|
|
9
|
+
* AND semantics across columns: a row must match EVERY active
|
|
10
|
+
* filter. Within a single filter, the op decides the predicate.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTableFilter<T extends object>(rows: T[], filterModel: TableFilterModel): T[];
|
|
13
|
+
//# sourceMappingURL=useTableFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableFilter.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableFilter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,CAAC,EAAE,EACT,WAAW,EAAE,gBAAgB,GAC5B,CAAC,EAAE,CAkBL"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TableColumn } from '../table.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Stringify any value into a search-comparable form. Handles all
|
|
4
|
+
* the edge cases that bit the MUI-side Table:
|
|
5
|
+
*
|
|
6
|
+
* - `null` / `undefined` → `''`
|
|
7
|
+
* - `string` → as-is
|
|
8
|
+
* - `number` / `bigint` → `String(value)`
|
|
9
|
+
* - `boolean` → `'true'` / `'false'`
|
|
10
|
+
* - `Date` → ISO 8601
|
|
11
|
+
* - `Array` / object → `JSON.stringify` (best effort)
|
|
12
|
+
*/
|
|
13
|
+
export declare function stringifyForSearch(value: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* Filters `rows` by `query` against the columns flagged
|
|
16
|
+
* `searchable: true`. Empty / whitespace-only query is a no-op
|
|
17
|
+
* (returns the original rows).
|
|
18
|
+
*
|
|
19
|
+
* Case-insensitive substring match. The caller is responsible for
|
|
20
|
+
* debouncing the input (use `useDebouncedValue`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function useTableSearch<T extends object>(rows: T[], cols: TableColumn<T>[], query: string): T[];
|
|
23
|
+
//# sourceMappingURL=useTableSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableSearch.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSearch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAqBzD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,KAAK,EAAE,MAAM,GACZ,CAAC,EAAE,CAeL"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TableRowSelectionMode } from '../table.types.js';
|
|
2
|
+
export interface UseTableSelectionResult {
|
|
3
|
+
selectedRowIds: string[];
|
|
4
|
+
isSelected: (rowId: string) => boolean;
|
|
5
|
+
toggleRow: (rowId: string) => void;
|
|
6
|
+
toggleAll: (allRowIds: string[]) => void;
|
|
7
|
+
clearSelection: () => void;
|
|
8
|
+
/** True when EVERY id in `allRowIds` is selected. */
|
|
9
|
+
isAllSelected: (allRowIds: string[]) => boolean;
|
|
10
|
+
/** True when at least one (but not all) of `allRowIds` is selected. */
|
|
11
|
+
isIndeterminate: (allRowIds: string[]) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Selection logic helper. Given the controllable selection state +
|
|
15
|
+
* the setter (from `useControllableState`), exposes ergonomic
|
|
16
|
+
* helpers the Table calls from its render path.
|
|
17
|
+
*
|
|
18
|
+
* - `single` mode: at most one row selected. Toggling another
|
|
19
|
+
* replaces the previous.
|
|
20
|
+
* - `multiple` mode: any subset selectable; toggling adds/removes.
|
|
21
|
+
* - `none` mode: every toggle is a no-op (the Table shouldn't
|
|
22
|
+
* render the checkbox cells anyway, but this is defensive).
|
|
23
|
+
*/
|
|
24
|
+
export declare function useTableSelection(mode: TableRowSelectionMode, selectedRowIds: string[], setSelectedRowIds: (next: string[] | ((prev: string[]) => string[])) => void): UseTableSelectionResult;
|
|
25
|
+
//# sourceMappingURL=useTableSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableSelection.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,qDAAqD;IACrD,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;IAChD,uEAAuE;IACvE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC;CACnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,cAAc,EAAE,MAAM,EAAE,EACxB,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC,KAAK,IAAI,GAC3E,uBAAuB,CAqEzB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TableColumn, TableSortModel } from '../table.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Applies the `sortModel` to `rows`. Returns a NEW sorted array
|
|
4
|
+
* (does not mutate input). Stable sort guaranteed by the underlying
|
|
5
|
+
* `Array.prototype.sort` in modern engines.
|
|
6
|
+
*
|
|
7
|
+
* Multi-column sort: items earlier in `sortModel` have higher
|
|
8
|
+
* precedence. Equal values fall through to the next sort item; if
|
|
9
|
+
* all sort items tie, the original order is preserved (stable).
|
|
10
|
+
*/
|
|
11
|
+
export declare function useTableSort<T extends object>(rows: T[], cols: TableColumn<T>[], sortModel: TableSortModel): T[];
|
|
12
|
+
/**
|
|
13
|
+
* Three-state sort cycler: `none` → `asc` → `desc` → `none`.
|
|
14
|
+
*
|
|
15
|
+
* Used by the header click handler. Returns the next sort model
|
|
16
|
+
* to apply, given the current model + the clicked field + whether
|
|
17
|
+
* the user is multi-sorting (shift key).
|
|
18
|
+
*/
|
|
19
|
+
export declare function cycleSortFor(current: TableSortModel, field: string, multi: boolean): TableSortModel;
|
|
20
|
+
//# sourceMappingURL=useTableSort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableSort.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/_internal/useTableSort.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EAEf,MAAM,mBAAmB,CAAC;AA+C3B;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,IAAI,EAAE,CAAC,EAAE,EACT,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EACtB,SAAS,EAAE,cAAc,GACxB,CAAC,EAAE,CA2CL;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,GACb,cAAc,CAkBhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import type { ButtonProps } from '../../Button/button.types.js';
|
|
3
|
+
export interface RenderButtonProps extends Pick<ButtonProps, 'variant' | 'color' | 'size' | 'disabled' | 'access'> {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Inline button cell renderer. Thin wrapper over `<Button>` with
|
|
9
|
+
* the size narrowed to `sm` by default (table density expects compact
|
|
10
|
+
* controls).
|
|
11
|
+
*/
|
|
12
|
+
export declare function RenderButton(props: RenderButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=RenderButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/RenderButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC/E,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAC1D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAOpD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
3
|
+
/**
|
|
4
|
+
* Internal mini-chip used by the cell renderer library. Not exported
|
|
5
|
+
* from `@dashforge/tw` as a standalone component (per Sprint 4.1
|
|
6
|
+
* scope decision — a standalone `<Chip>` may ship in Sprint 5 if
|
|
7
|
+
* demand emerges).
|
|
8
|
+
*
|
|
9
|
+
* Variants:
|
|
10
|
+
* - `color`: 7 intents (neutral / primary / success / warning /
|
|
11
|
+
* danger / info / secondary)
|
|
12
|
+
* - `variant`: `soft` (default) / `solid` / `outline`
|
|
13
|
+
* - `size`: `sm` / `md`
|
|
14
|
+
*/
|
|
15
|
+
declare const chipVariants: import("tailwind-variants").TVReturnType<{
|
|
16
|
+
color: {
|
|
17
|
+
neutral: string;
|
|
18
|
+
primary: string;
|
|
19
|
+
success: string;
|
|
20
|
+
warning: string;
|
|
21
|
+
danger: string;
|
|
22
|
+
info: string;
|
|
23
|
+
secondary: string;
|
|
24
|
+
};
|
|
25
|
+
variant: {
|
|
26
|
+
soft: string;
|
|
27
|
+
solid: string;
|
|
28
|
+
outline: string;
|
|
29
|
+
};
|
|
30
|
+
size: {
|
|
31
|
+
sm: string;
|
|
32
|
+
md: string;
|
|
33
|
+
};
|
|
34
|
+
}, undefined, string[], {
|
|
35
|
+
color: {
|
|
36
|
+
neutral: string;
|
|
37
|
+
primary: string;
|
|
38
|
+
success: string;
|
|
39
|
+
warning: string;
|
|
40
|
+
danger: string;
|
|
41
|
+
info: string;
|
|
42
|
+
secondary: string;
|
|
43
|
+
};
|
|
44
|
+
variant: {
|
|
45
|
+
soft: string;
|
|
46
|
+
solid: string;
|
|
47
|
+
outline: string;
|
|
48
|
+
};
|
|
49
|
+
size: {
|
|
50
|
+
sm: string;
|
|
51
|
+
md: string;
|
|
52
|
+
};
|
|
53
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
54
|
+
color: {
|
|
55
|
+
neutral: string;
|
|
56
|
+
primary: string;
|
|
57
|
+
success: string;
|
|
58
|
+
warning: string;
|
|
59
|
+
danger: string;
|
|
60
|
+
info: string;
|
|
61
|
+
secondary: string;
|
|
62
|
+
};
|
|
63
|
+
variant: {
|
|
64
|
+
soft: string;
|
|
65
|
+
solid: string;
|
|
66
|
+
outline: string;
|
|
67
|
+
};
|
|
68
|
+
size: {
|
|
69
|
+
sm: string;
|
|
70
|
+
md: string;
|
|
71
|
+
};
|
|
72
|
+
}, undefined, string[], unknown, unknown, undefined>>;
|
|
73
|
+
type ChipVariants = VariantProps<typeof chipVariants>;
|
|
74
|
+
export interface RenderChipProps extends ChipVariants {
|
|
75
|
+
children: ReactNode;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
export declare function RenderChip(props: RenderChipProps): import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=RenderChip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderChip.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/RenderChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG1D;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qDAsEhB,CAAC;AAEH,KAAK,YAAY,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAOhD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface RenderTextProps {
|
|
3
|
+
value: ReactNode;
|
|
4
|
+
/** Truncate to one line with ellipsis on overflow. @default false */
|
|
5
|
+
truncate?: boolean;
|
|
6
|
+
/** Secondary text color (less prominent). @default false */
|
|
7
|
+
muted?: boolean;
|
|
8
|
+
/** Extra class merged via `tailwind-merge`. */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Plain text cell renderer. Wraps the value in a `<span>` and
|
|
13
|
+
* optionally truncates on overflow. Use this for the most common
|
|
14
|
+
* case: render a single string value.
|
|
15
|
+
*
|
|
16
|
+
* The Table component does NOT use this by default for plain
|
|
17
|
+
* string columns — it just renders `{value}` directly. Use
|
|
18
|
+
* `RenderText` when you need the truncate / muted styling.
|
|
19
|
+
*/
|
|
20
|
+
export declare function RenderText(props: RenderTextProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=RenderText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderText.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/RenderText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,2CAchD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface RenderTwoLineProps {
|
|
3
|
+
primary: ReactNode;
|
|
4
|
+
secondary: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Two-line cell renderer: a bold primary line stacked above a muted
|
|
9
|
+
* secondary line. Useful for `Name + email`, `Title + ID`, etc.
|
|
10
|
+
*
|
|
11
|
+
* Replaces the MUI-side `RenderTwoLineCell` without the magic-number
|
|
12
|
+
* vertical-align fudges (`mt: 0.8 / 0.2`) — flexbox handles the
|
|
13
|
+
* vertical layout cleanly.
|
|
14
|
+
*
|
|
15
|
+
* Dashforge identity rule: text colors auto-invert via the
|
|
16
|
+
* `dashforgePreset()` CSS-variable swap. No `dark:` variants needed
|
|
17
|
+
* on neutral palette.
|
|
18
|
+
*/
|
|
19
|
+
export declare function RenderTwoLine(props: RenderTwoLineProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=RenderTwoLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderTwoLine.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/RenderTwoLine.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAYtD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { AccessRequirement } from '@dashforge/rbac';
|
|
3
|
+
/**
|
|
4
|
+
* Single action definition for `<RowActionsMenu>`.
|
|
5
|
+
*
|
|
6
|
+
* `access` (optional) gates the action via RBAC:
|
|
7
|
+
* - `onUnauthorized: 'hide'` → action not rendered
|
|
8
|
+
* - `onUnauthorized: 'disable'` → action visible, disabled
|
|
9
|
+
* - `onUnauthorized: 'readonly'` → action visible, disabled
|
|
10
|
+
*/
|
|
11
|
+
export interface TableRowAction<T> {
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
onClick: (row: T) => void;
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
color?: 'default' | 'danger' | 'warning';
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
access?: AccessRequirement;
|
|
18
|
+
}
|
|
19
|
+
export interface RowActionsMenuProps<T> {
|
|
20
|
+
row: T;
|
|
21
|
+
actions: TableRowAction<T>[];
|
|
22
|
+
/** Custom trigger element. Defaults to a ⋮ icon button. */
|
|
23
|
+
trigger?: ReactNode;
|
|
24
|
+
/** Aria-label for the default trigger. */
|
|
25
|
+
ariaLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 3-dot row actions menu. Renders a trigger button that opens a
|
|
29
|
+
* Popover (Sprint 3 component) with a list of action menu items.
|
|
30
|
+
*
|
|
31
|
+
* Replaces the MUI-side `RowActions.tsx` (IconButton + Menu) with
|
|
32
|
+
* the TW equivalents. Per-action RBAC honored: hidden actions are
|
|
33
|
+
* filtered out, disabled actions render disabled.
|
|
34
|
+
*/
|
|
35
|
+
export declare function RowActionsMenu<T>(props: RowActionsMenuProps<T>): import("react/jsx-runtime").JSX.Element | null;
|
|
36
|
+
//# sourceMappingURL=RowActionsMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowActionsMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/RowActionsMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKzD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,GAAG,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,kDA8D9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { RenderText } from './RenderText.js';
|
|
2
|
+
export type { RenderTextProps } from './RenderText.js';
|
|
3
|
+
export { RenderTwoLine } from './RenderTwoLine.js';
|
|
4
|
+
export type { RenderTwoLineProps } from './RenderTwoLine.js';
|
|
5
|
+
export { RenderChip } from './RenderChip.js';
|
|
6
|
+
export type { RenderChipProps } from './RenderChip.js';
|
|
7
|
+
export { RenderButton } from './RenderButton.js';
|
|
8
|
+
export type { RenderButtonProps } from './RenderButton.js';
|
|
9
|
+
export { RowActionsMenu } from './RowActionsMenu.js';
|
|
10
|
+
export type { RowActionsMenuProps, TableRowAction } from './RowActionsMenu.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/cells/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|