@lavalogic/scoria 0.40.2 → 0.40.4
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/dist/Components/Contexts/Tooltip.svelte +2 -0
- package/dist/Components/HorizontalTabGroup.svelte +24 -4
- package/dist/Components/HorizontalTabGroup.svelte.d.ts +2 -2
- package/dist/Components/HorizontalTabGroupProps.d.ts +8 -0
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +39 -7
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +35 -1
- package/dist/Components/Table/Body/Rows/TableRow.svelte +6 -1
- package/dist/Components/Table/ColumnFactory.svelte.js +6 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +4 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +3 -0
- package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +5 -1
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +6 -2
- package/dist/Components/Table/Types/Context/TableInitOptions.d.ts +2 -0
- package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +9 -0
- package/dist/Components/Table/Types/Public/CreateTableOptions.d.ts +9 -0
- package/dist/Components/Table/createTable.svelte.js +1 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import HorizontalTabGroupButton from './HorizontalTabGroupButton.svelte';
|
|
10
10
|
import type { HorizontalTabGroupProps } from './HorizontalTabGroupProps.js';
|
|
11
11
|
import TextInput from './TextInput.svelte';
|
|
12
|
-
|
|
12
|
+
let {
|
|
13
13
|
tabComponent,
|
|
14
14
|
tabs,
|
|
15
15
|
selected,
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
dense = false,
|
|
19
19
|
filterable = false,
|
|
20
20
|
filterFn,
|
|
21
|
+
searchValue = $bindable(''),
|
|
22
|
+
searchInfo,
|
|
23
|
+
searchPlaceholder,
|
|
21
24
|
}: HorizontalTabGroupProps<CommonDenominator> = $props();
|
|
22
25
|
|
|
23
|
-
let searchValue = $state('');
|
|
24
|
-
|
|
25
26
|
// Debounce only the search value, not the tabs array. This way a parent
|
|
26
27
|
// rebuilding `tabs` shows the new list immediately, while typing still
|
|
27
28
|
// pays the 300ms cost.
|
|
@@ -51,9 +52,15 @@
|
|
|
51
52
|
<div class="searchbar">
|
|
52
53
|
<TextInput
|
|
53
54
|
bind:value={searchValue}
|
|
54
|
-
placeholder=
|
|
55
|
+
placeholder={searchPlaceholder ?? `Search any keyword to find matches${ellipses}`}
|
|
55
56
|
rightIcon={{ name: 'search-1', colour: Colour['$ui-blue-4'] }}
|
|
56
57
|
/>
|
|
58
|
+
{#if searchInfo}
|
|
59
|
+
<span class="search-info">
|
|
60
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
61
|
+
{@render searchInfo()}
|
|
62
|
+
</span>
|
|
63
|
+
{/if}
|
|
57
64
|
</div>
|
|
58
65
|
{/if}
|
|
59
66
|
</div>
|
|
@@ -81,11 +88,24 @@
|
|
|
81
88
|
|
|
82
89
|
<style>.searchbar {
|
|
83
90
|
display: flex;
|
|
91
|
+
flex-flow: row nowrap;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: 0.5rem;
|
|
84
94
|
width: 100%;
|
|
85
95
|
padding: 0.5rem;
|
|
86
96
|
background-color: #ffffff;
|
|
87
97
|
min-width: 20.625rem;
|
|
88
98
|
}
|
|
99
|
+
.searchbar :global(> *:first-child) {
|
|
100
|
+
flex: 1 1 auto;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.search-info {
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
flex: 0 0 auto;
|
|
107
|
+
align-items: center;
|
|
108
|
+
}
|
|
89
109
|
|
|
90
110
|
.wrapper {
|
|
91
111
|
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1333333333);
|
|
@@ -2,7 +2,7 @@ import type { HorizontalTabGroupProps } from './HorizontalTabGroupProps.js';
|
|
|
2
2
|
declare function $$render<CommonDenominator>(): {
|
|
3
3
|
props: HorizontalTabGroupProps<CommonDenominator>;
|
|
4
4
|
exports: {};
|
|
5
|
-
bindings: "";
|
|
5
|
+
bindings: "searchValue";
|
|
6
6
|
slots: {};
|
|
7
7
|
events: {};
|
|
8
8
|
};
|
|
@@ -10,7 +10,7 @@ declare class __sveltets_Render<CommonDenominator> {
|
|
|
10
10
|
props(): ReturnType<typeof $$render<CommonDenominator>>['props'];
|
|
11
11
|
events(): ReturnType<typeof $$render<CommonDenominator>>['events'];
|
|
12
12
|
slots(): ReturnType<typeof $$render<CommonDenominator>>['slots'];
|
|
13
|
-
bindings(): "";
|
|
13
|
+
bindings(): "searchValue";
|
|
14
14
|
exports(): {};
|
|
15
15
|
}
|
|
16
16
|
interface $$IsomorphicComponent {
|
|
@@ -35,6 +35,14 @@ interface HorizontalTabGroupPropsBase<CommonDenominator> {
|
|
|
35
35
|
filterable?: boolean;
|
|
36
36
|
/** Predicate used to filter tabs on each keystroke (debounced by 300ms). */
|
|
37
37
|
filterFn?: (item: TabOption<CommonDenominator>, filterValue: string) => boolean;
|
|
38
|
+
/** Bindable current value of the search box. Lets the parent read/drive
|
|
39
|
+
* the search term (e.g. to highlight matches elsewhere). */
|
|
40
|
+
searchValue?: string;
|
|
41
|
+
/** Optional content rendered beside the search input (e.g. an info icon
|
|
42
|
+
* with a tooltip). Only shown when `filterable`. */
|
|
43
|
+
searchInfo?: Snippet;
|
|
44
|
+
/** Override the search box placeholder. */
|
|
45
|
+
searchPlaceholder?: string;
|
|
38
46
|
}
|
|
39
47
|
export interface HorizontalTabGroupPropsWithoutSearch<CommonDenominator> extends HorizontalTabGroupPropsBase<CommonDenominator> {
|
|
40
48
|
filterable?: false;
|
|
@@ -30,6 +30,36 @@
|
|
|
30
30
|
cell.column.columnDef.isEnabled(cell.row.original, cell.row.originalIndex)
|
|
31
31
|
);
|
|
32
32
|
|
|
33
|
+
// Per-row toggle visibility. When `isVisible` resolves false the toggle is
|
|
34
|
+
// omitted entirely (rather than disabled). Sync booleans are used directly
|
|
35
|
+
// so non-visible rows never flash the icon; promises resolve into state.
|
|
36
|
+
const visibleRaw: boolean | Promise<boolean> = $derived(
|
|
37
|
+
cell.column.columnDef.isVisible
|
|
38
|
+
? cell.column.columnDef.isVisible(cell.row.original, cell.row.originalIndex)
|
|
39
|
+
: true
|
|
40
|
+
);
|
|
41
|
+
let visibleAsyncResolved = $state(true);
|
|
42
|
+
let visibleCounter = 0;
|
|
43
|
+
$effect(() => {
|
|
44
|
+
const raw = visibleRaw;
|
|
45
|
+
if (typeof raw === 'boolean') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const local = (visibleCounter = visibleCounter + 1);
|
|
49
|
+
raw
|
|
50
|
+
.then((v) => {
|
|
51
|
+
if (visibleCounter === local) {
|
|
52
|
+
visibleAsyncResolved = v;
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.catch(() => {
|
|
56
|
+
if (visibleCounter === local) {
|
|
57
|
+
visibleAsyncResolved = false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const visible = $derived(typeof visibleRaw === 'boolean' ? visibleRaw : visibleAsyncResolved);
|
|
62
|
+
|
|
33
63
|
let validity: Validity = $state(Validity.Valid);
|
|
34
64
|
$effect(() => {
|
|
35
65
|
const validityPromise = focusDetails.validity;
|
|
@@ -81,13 +111,15 @@
|
|
|
81
111
|
class:multifocus={focusDetails.isMultiFocused}
|
|
82
112
|
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
83
113
|
>
|
|
84
|
-
{#
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
114
|
+
{#if visible}
|
|
115
|
+
{#await enabled}
|
|
116
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
117
|
+
{@render action(false)}
|
|
118
|
+
{:then enabled}
|
|
119
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
120
|
+
{@render action(enabled)}
|
|
121
|
+
{/await}
|
|
122
|
+
{/if}
|
|
91
123
|
</div>
|
|
92
124
|
</div>
|
|
93
125
|
|
|
@@ -23,6 +23,31 @@
|
|
|
23
23
|
tableContext._focus.getFocusDetailsFor(cell)
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
+
// Resolve the column's (possibly async) `isEditable` predicate for this
|
|
27
|
+
// row. A non-editable checkbox renders disabled (read-only) rather than
|
|
28
|
+
// toggling — mirrors how the inline-edit cells gate on `isEditable`.
|
|
29
|
+
const editableAsync = $derived(
|
|
30
|
+
cell.column.columnDef.isEditable(cell.row.original, cell.row.originalIndex)
|
|
31
|
+
);
|
|
32
|
+
let editable = $state(false);
|
|
33
|
+
let editableCounter = 0;
|
|
34
|
+
$effect(() => {
|
|
35
|
+
void editableAsync;
|
|
36
|
+
const local = (editableCounter = editableCounter + 1);
|
|
37
|
+
(async () => {
|
|
38
|
+
try {
|
|
39
|
+
const resolved = await editableAsync;
|
|
40
|
+
if (editableCounter === local) {
|
|
41
|
+
editable = resolved;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
if (editableCounter === local) {
|
|
45
|
+
editable = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})().catch(devCatch);
|
|
49
|
+
});
|
|
50
|
+
|
|
26
51
|
let inputRef: HTMLInputElement | undefined = $state();
|
|
27
52
|
|
|
28
53
|
/**
|
|
@@ -32,6 +57,9 @@
|
|
|
32
57
|
* already showed the new checked state.
|
|
33
58
|
*/
|
|
34
59
|
const onchange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
|
60
|
+
if (!editable) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
35
63
|
tableContext
|
|
36
64
|
.onEditCell(
|
|
37
65
|
cell.row.original,
|
|
@@ -84,7 +112,7 @@
|
|
|
84
112
|
}
|
|
85
113
|
}}
|
|
86
114
|
onkeyup={(e: KeyboardEvent) => {
|
|
87
|
-
if (e.key === 'Enter') {
|
|
115
|
+
if (e.key === 'Enter' && editable) {
|
|
88
116
|
e.stopPropagation();
|
|
89
117
|
tableContext.onEditCell(cell.row.original, focusDetails.coordinates, !value).catch(devCatch);
|
|
90
118
|
}
|
|
@@ -119,6 +147,7 @@
|
|
|
119
147
|
{onchange}
|
|
120
148
|
type="checkbox"
|
|
121
149
|
checked={value}
|
|
150
|
+
disabled={!editable}
|
|
122
151
|
/>
|
|
123
152
|
</label>
|
|
124
153
|
</div>
|
|
@@ -198,4 +227,9 @@ label.multifocus.multifocus-start {
|
|
|
198
227
|
.input-cell.error,
|
|
199
228
|
.select-cell.error {
|
|
200
229
|
background-color: #f9e9e9;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
input:disabled {
|
|
233
|
+
cursor: not-allowed;
|
|
234
|
+
opacity: 0.45;
|
|
201
235
|
}</style>
|
|
@@ -85,7 +85,12 @@
|
|
|
85
85
|
const firstCell = $derived(leftCells.at(0) ?? centreCells.at(0) ?? rightCells.at(0));
|
|
86
86
|
const rowIndex = $derived(firstCell?.row.visibleIndex);
|
|
87
87
|
let id = $state<RowIdType | undefined>();
|
|
88
|
-
|
|
88
|
+
// Transient click/copy highlight OR the declarative, persistent
|
|
89
|
+
// `highlightRow` predicate (reactive; survives data/pagination resets).
|
|
90
|
+
const highlighted = $derived(
|
|
91
|
+
(id != undefined && tableContext.highlightedItems.has(id)) ||
|
|
92
|
+
(tableContext.highlightRow ? tableContext.highlightRow(row.original, rowIndex ?? 0) : false)
|
|
93
|
+
);
|
|
89
94
|
|
|
90
95
|
$effect(() => {
|
|
91
96
|
void row.original;
|
|
@@ -232,6 +232,11 @@ export function createColumnFactory() {
|
|
|
232
232
|
const def = new CheckboxDef({
|
|
233
233
|
id: opts.id,
|
|
234
234
|
...commonProps(opts, 'checkbox'),
|
|
235
|
+
// Checkboxes are interactive by default (the base ColumnDef
|
|
236
|
+
// default is read-only); only an explicit `isEditable` gates
|
|
237
|
+
// them. Keeps existing checkboxes editable while letting callers
|
|
238
|
+
// disable per row.
|
|
239
|
+
isEditable: opts.isEditable ?? (() => true),
|
|
235
240
|
accessorFn: opts.accessor,
|
|
236
241
|
getDisplayValue: opts.getDisplayValue,
|
|
237
242
|
filterValueType: FilterValueType.Bool,
|
|
@@ -522,6 +527,7 @@ export function createColumnFactory() {
|
|
|
522
527
|
allowCopy: opts.inner?.allowCopy,
|
|
523
528
|
},
|
|
524
529
|
onActivate: opts.onActivate,
|
|
530
|
+
isVisible: opts.isVisible,
|
|
525
531
|
});
|
|
526
532
|
// Expand has no public width option — apply the per-kind default.
|
|
527
533
|
def.width = KIND_DEFAULT_WIDTHS.expand;
|
|
@@ -13,6 +13,8 @@ import { ColumnDef, type ColumnDefProps } from '../ColumnDef.svelte.js';
|
|
|
13
13
|
export interface ExpandDefProps<T extends object, R extends object, InnerIdType extends Primitive = Primitive, in FilterValueType = unknown> extends ColumnDefProps<T, FilterValueType> {
|
|
14
14
|
/** Per-row enable predicate for the expansion affordance. */
|
|
15
15
|
isEnabled: (item: T, index: number) => boolean | Promise<boolean>;
|
|
16
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
17
|
+
isVisible?: (item: T, index: number) => boolean | Promise<boolean>;
|
|
16
18
|
/** Builds the inner table's column defs. Invoked per expansion. */
|
|
17
19
|
getInnerColumnDefs: (item: T, index: number) => DefsWrapper<R>;
|
|
18
20
|
/** Header icon name on the expand-toggle button. */
|
|
@@ -49,6 +51,8 @@ export declare class ExpandDef<T extends object, R extends object, InnerIdType e
|
|
|
49
51
|
readonly headerIcon: IconProps['name'];
|
|
50
52
|
/** Per-row enable predicate for the expansion affordance. */
|
|
51
53
|
readonly isEnabled: (item: T, index: number) => boolean | Promise<boolean>;
|
|
54
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
55
|
+
readonly isVisible?: (item: T, index: number) => boolean | Promise<boolean>;
|
|
52
56
|
/** Init options for the inner table. */
|
|
53
57
|
readonly innerTableOptions: TableInitOptions<R, InnerIdType>;
|
|
54
58
|
/** Navigate-instead-of-expand callback; undefined for normal expand. */
|
|
@@ -17,6 +17,7 @@ export class ExpandDef extends ColumnDef {
|
|
|
17
17
|
this.innerTableName = $derived(props.innerTableName);
|
|
18
18
|
this.innerTableOptions = $derived(props.innerTableOptions);
|
|
19
19
|
this.onActivate = $derived(props.onActivate);
|
|
20
|
+
this.isVisible = $derived(props.isVisible);
|
|
20
21
|
}
|
|
21
22
|
/** Expand columns are never filtered. */
|
|
22
23
|
filterFn = undefined;
|
|
@@ -28,6 +29,8 @@ export class ExpandDef extends ColumnDef {
|
|
|
28
29
|
headerIcon;
|
|
29
30
|
/** Per-row enable predicate for the expansion affordance. */
|
|
30
31
|
isEnabled;
|
|
32
|
+
/** Per-row predicate for whether the toggle renders at all. */
|
|
33
|
+
isVisible;
|
|
31
34
|
/** Init options for the inner table. */
|
|
32
35
|
innerTableOptions;
|
|
33
36
|
/** Navigate-instead-of-expand callback; undefined for normal expand. */
|
|
@@ -60,6 +60,8 @@ export declare class TableContext<T extends object, RowIdType extends Primitive>
|
|
|
60
60
|
allowAdvancedFiltering: boolean;
|
|
61
61
|
toolbarPosition: ToolbarPosition;
|
|
62
62
|
displayFooter: boolean;
|
|
63
|
+
/** Declarative persistent row-highlight predicate (see CreateTableOptions). */
|
|
64
|
+
readonly highlightRow: TableInitOptions<T, RowIdType>['highlightRow'];
|
|
63
65
|
selectionExtractor: TableInitOptions<T, RowIdType>['selectionExtractor'];
|
|
64
66
|
getUserId: () => string | undefined;
|
|
65
67
|
private _onEditCell;
|
|
@@ -86,7 +88,9 @@ export declare class TableContext<T extends object, RowIdType extends Primitive>
|
|
|
86
88
|
* `init`.
|
|
87
89
|
*/
|
|
88
90
|
static init<T extends object, RowIdType extends Primitive>(defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, options: TableInitOptions<T, RowIdType>): TableContext<T, RowIdType>;
|
|
89
|
-
protected constructor(INTERNAL_ONLY: symbol, defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, allowCopy: boolean, enableResize: boolean, allowColumnReordering: boolean, allowQuickFiltering: boolean, showQuickFilterByDefault: boolean, allowAdvancedFiltering: boolean, toolbarPosition: ToolbarPosition, displayFooter: boolean,
|
|
91
|
+
protected constructor(INTERNAL_ONLY: symbol, defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, allowCopy: boolean, enableResize: boolean, allowColumnReordering: boolean, allowQuickFiltering: boolean, showQuickFilterByDefault: boolean, allowAdvancedFiltering: boolean, toolbarPosition: ToolbarPosition, displayFooter: boolean,
|
|
92
|
+
/** Declarative persistent row-highlight predicate (see CreateTableOptions). */
|
|
93
|
+
highlightRow: TableInitOptions<T, RowIdType>['highlightRow'], selectionExtractor: TableInitOptions<T, RowIdType>['selectionExtractor'], getUserId: () => string | undefined, _onEditCell: TableInitOptions<T, RowIdType>['onEditCell'],
|
|
90
94
|
/**
|
|
91
95
|
* Stable per-table identifier supplied by the host app, or
|
|
92
96
|
* `undefined` when remote saved views are disabled. Stored only;
|
|
@@ -107,6 +107,7 @@ export class TableContext {
|
|
|
107
107
|
allowAdvancedFiltering;
|
|
108
108
|
toolbarPosition;
|
|
109
109
|
displayFooter;
|
|
110
|
+
highlightRow;
|
|
110
111
|
selectionExtractor;
|
|
111
112
|
getUserId;
|
|
112
113
|
_onEditCell;
|
|
@@ -123,7 +124,7 @@ export class TableContext {
|
|
|
123
124
|
* `init`.
|
|
124
125
|
*/
|
|
125
126
|
static init(defaultColumnDefs, tableName, dataRepo, options) {
|
|
126
|
-
const context = new this(InternalSymbol, defaultColumnDefs, tableName, dataRepo, options.allowCopy ?? DEFAULT_TABLE_INIT_OPTIONS.allowCopy, options.enableResize ?? DEFAULT_TABLE_INIT_OPTIONS.enableResize, options.allowColumnReordering ?? DEFAULT_TABLE_INIT_OPTIONS.allowColumnReordering, options.allowQuickFiltering ?? DEFAULT_TABLE_INIT_OPTIONS.allowQuickFiltering, options.showQuickFilterByDefault ?? DEFAULT_TABLE_INIT_OPTIONS.showQuickFilterByDefault, options.allowAdvancedFiltering ?? DEFAULT_TABLE_INIT_OPTIONS.allowAdvancedFiltering, options.toolbar ?? DEFAULT_TABLE_INIT_OPTIONS.toolbar, options.displayFooter ?? DEFAULT_TABLE_INIT_OPTIONS.displayFooter,
|
|
127
|
+
const context = new this(InternalSymbol, defaultColumnDefs, tableName, dataRepo, options.allowCopy ?? DEFAULT_TABLE_INIT_OPTIONS.allowCopy, options.enableResize ?? DEFAULT_TABLE_INIT_OPTIONS.enableResize, options.allowColumnReordering ?? DEFAULT_TABLE_INIT_OPTIONS.allowColumnReordering, options.allowQuickFiltering ?? DEFAULT_TABLE_INIT_OPTIONS.allowQuickFiltering, options.showQuickFilterByDefault ?? DEFAULT_TABLE_INIT_OPTIONS.showQuickFilterByDefault, options.allowAdvancedFiltering ?? DEFAULT_TABLE_INIT_OPTIONS.allowAdvancedFiltering, options.toolbar ?? DEFAULT_TABLE_INIT_OPTIONS.toolbar, options.displayFooter ?? DEFAULT_TABLE_INIT_OPTIONS.displayFooter, options.highlightRow,
|
|
127
128
|
// Fallback identity extractor when no `selectionExtractor` is
|
|
128
129
|
// supplied (some consumers build an options object directly
|
|
129
130
|
// without one). Returning the row object preserves identity
|
|
@@ -134,7 +135,9 @@ export class TableContext {
|
|
|
134
135
|
return context;
|
|
135
136
|
}
|
|
136
137
|
// #region constructor
|
|
137
|
-
constructor(INTERNAL_ONLY, defaultColumnDefs, tableName, dataRepo, allowCopy, enableResize, allowColumnReordering, allowQuickFiltering, showQuickFilterByDefault, allowAdvancedFiltering, toolbarPosition, displayFooter,
|
|
138
|
+
constructor(INTERNAL_ONLY, defaultColumnDefs, tableName, dataRepo, allowCopy, enableResize, allowColumnReordering, allowQuickFiltering, showQuickFilterByDefault, allowAdvancedFiltering, toolbarPosition, displayFooter,
|
|
139
|
+
/** Declarative persistent row-highlight predicate (see CreateTableOptions). */
|
|
140
|
+
highlightRow, selectionExtractor, getUserId, _onEditCell = () => {
|
|
138
141
|
console.warn('Cannot edit immutable table');
|
|
139
142
|
},
|
|
140
143
|
/**
|
|
@@ -159,6 +162,7 @@ export class TableContext {
|
|
|
159
162
|
this.allowAdvancedFiltering = allowAdvancedFiltering;
|
|
160
163
|
this.toolbarPosition = toolbarPosition;
|
|
161
164
|
this.displayFooter = displayFooter;
|
|
165
|
+
this.highlightRow = highlightRow;
|
|
162
166
|
this.selectionExtractor = selectionExtractor;
|
|
163
167
|
this.getUserId = getUserId;
|
|
164
168
|
this._onEditCell = _onEditCell;
|
|
@@ -28,6 +28,8 @@ export interface TableInitOptions<T extends object, Identifier extends Primitive
|
|
|
28
28
|
allowAdvancedFiltering?: boolean;
|
|
29
29
|
toolbar?: ToolbarPosition;
|
|
30
30
|
displayFooter?: boolean;
|
|
31
|
+
/** Declarative persistent row-highlight predicate. See CreateTableOptions. */
|
|
32
|
+
highlightRow?: (item: T, index: number) => boolean;
|
|
31
33
|
onEditCell?: (item: T, coords: CellCoordinates, value: unknown) => void | Promise<void>;
|
|
32
34
|
getUserId: () => string | undefined;
|
|
33
35
|
/** Stable per-table identifier supplied by the host app. Identifies
|
|
@@ -377,6 +377,15 @@ export interface ExpandColumnOptions<TRow extends object, TInner extends object,
|
|
|
377
377
|
* inner content. Async supported. Defaults to `() => true`.
|
|
378
378
|
*/
|
|
379
379
|
isEnabled?: (row: TRow, index: number) => boolean | Promise<boolean>;
|
|
380
|
+
/**
|
|
381
|
+
* Per-row predicate for whether the expand affordance renders at all.
|
|
382
|
+
* When it resolves to `false` the toggle is omitted entirely (not just
|
|
383
|
+
* disabled), so rows that can never expand show no icon. Use to surface
|
|
384
|
+
* only the rows that are actually expandable (vs `isEnabled`, which keeps
|
|
385
|
+
* the toggle visible but greyed). Async supported. Defaults to always
|
|
386
|
+
* visible.
|
|
387
|
+
*/
|
|
388
|
+
isVisible?: (row: TRow, index: number) => boolean | Promise<boolean>;
|
|
380
389
|
/**
|
|
381
390
|
* Inner-table configuration. Each field maps 1:1 onto the equivalent
|
|
382
391
|
* `CreateTableOptions` field that configures an outer Table; supply
|
|
@@ -59,6 +59,15 @@ export interface CreateTableOptions<TRow extends object, TRowId extends Primitiv
|
|
|
59
59
|
toolbar?: 'top' | 'right' | 'left' | 'none';
|
|
60
60
|
/** Whether to render the footer. Defaults to true. */
|
|
61
61
|
showFooter?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Declarative, persistent row highlight. When provided, every row for
|
|
64
|
+
* which this returns true is rendered highlighted — reactively and
|
|
65
|
+
* independently of the transient click/copy highlight, so it survives
|
|
66
|
+
* data/pagination changes (the latter clears the interaction highlight).
|
|
67
|
+
* Read reactive state inside the predicate (e.g. a search term) to drive
|
|
68
|
+
* the highlight from outside the table. Synchronous. Defaults to none.
|
|
69
|
+
*/
|
|
70
|
+
highlightRow?: (row: TRow, index: number) => boolean;
|
|
62
71
|
/** Whether copy operations are enabled. Defaults to true. */
|
|
63
72
|
allowCopy?: boolean;
|
|
64
73
|
/** Whether columns may be user-resized. Defaults to true. */
|
|
@@ -76,6 +76,7 @@ export function createTable(options) {
|
|
|
76
76
|
allowAdvancedFiltering: options.allowAdvancedFilter,
|
|
77
77
|
toolbar: translateToolbar(options.toolbar),
|
|
78
78
|
displayFooter: options.showFooter,
|
|
79
|
+
highlightRow: options.highlightRow,
|
|
79
80
|
onEditCell,
|
|
80
81
|
datatableUuid: options.datatableUuid,
|
|
81
82
|
remoteLayouts: options.remoteLayouts,
|