@isoftdata/svelte-table 2.11.0 → 2.12.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/dist/DraggableRows.svelte +2 -2
- package/dist/Pagination.svelte +1 -0
- package/dist/Table.svelte +59 -38
- package/dist/Table.svelte.d.ts +14 -26
- package/dist/Td.svelte +2 -1
- package/dist/Td.svelte.d.ts +2 -2
- package/dist/TreeRow.svelte +4 -3
- package/dist/bracket-paths.d.ts +5 -3
- package/dist/tree-utility.d.ts +1 -1
- package/dist/tree-utility.js +1 -3
- package/dist/types.d.ts +1 -5
- package/package.json +11 -13
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { StringKeyOfType } from './tree-utility'
|
|
8
8
|
|
|
9
9
|
import type Table from './Table.svelte'
|
|
10
|
-
import type { Column, UuidRowProps } from './'
|
|
10
|
+
import type { Column, RowProperties, UuidRowProps } from './'
|
|
11
11
|
import Td from './Td.svelte'
|
|
12
12
|
import { flip } from 'svelte/animate'
|
|
13
13
|
import { getContext, tick } from 'svelte'
|
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
onclick={() => rowClick?.({ row })}
|
|
212
212
|
>
|
|
213
213
|
{@render prepend?.({ row })}
|
|
214
|
-
<Td property={rankProperty}>
|
|
214
|
+
<Td property={rankProperty as RowProperties<Row>}>
|
|
215
215
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
216
216
|
<div
|
|
217
217
|
draggable={reorderable ? 'true' : 'false'}
|
package/dist/Pagination.svelte
CHANGED
package/dist/Table.svelte
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script
|
|
2
|
+
module
|
|
3
|
+
lang="ts"
|
|
4
|
+
>
|
|
2
5
|
import { getBootstrapCdnVersion } from '@isoftdata/utility-bootstrap'
|
|
3
6
|
let bs5 = $state(false)
|
|
4
7
|
try {
|
|
5
8
|
bs5 = getBootstrapCdnVersion() === 5
|
|
6
|
-
} catch
|
|
9
|
+
} catch {
|
|
7
10
|
onMount(() => {
|
|
8
11
|
bs5 = getBootstrapCdnVersion() === 5
|
|
9
12
|
})
|
|
@@ -28,6 +31,7 @@
|
|
|
28
31
|
type FooterReducerValue,
|
|
29
32
|
ARBITRARY_PROPERTY_PREFIX,
|
|
30
33
|
type ArbitraryProperty,
|
|
34
|
+
type ColumnInfo,
|
|
31
35
|
} from './'
|
|
32
36
|
|
|
33
37
|
import { writable, type Writable } from 'svelte/store'
|
|
@@ -91,7 +95,7 @@
|
|
|
91
95
|
selectionEnabled?: boolean
|
|
92
96
|
// Array<number> | Array<string> | Array<R[K]> ???
|
|
93
97
|
selectedRowIds?: Array<GetIndexedRowProperty>
|
|
94
|
-
rowSelectionIdProp?:
|
|
98
|
+
rowSelectionIdProp?: RowProperties<IndexedRow>
|
|
95
99
|
rowSelectionRequiresModKey?: boolean
|
|
96
100
|
selectionMode?: 'SINGLE' | 'RANGE' | null
|
|
97
101
|
multiSelectEnabled?: boolean
|
|
@@ -99,7 +103,7 @@
|
|
|
99
103
|
totalItemsCount?: number
|
|
100
104
|
stickyHeader?: boolean
|
|
101
105
|
responsive?: boolean | 'sm' | 'md' | 'lg' | 'xl'
|
|
102
|
-
size?: 'sm' | ''
|
|
106
|
+
size?: 'xs' | 'sm' | ''
|
|
103
107
|
striped?: boolean
|
|
104
108
|
/** When true, enables tree-specific features. Required if you want to use `TreeRow`s. */
|
|
105
109
|
tree?: boolean
|
|
@@ -161,7 +165,7 @@
|
|
|
161
165
|
columnHidingEnabled = false,
|
|
162
166
|
selectionEnabled = false,
|
|
163
167
|
selectedRowIds = $bindable([]),
|
|
164
|
-
rowSelectionIdProp = 'uuid'
|
|
168
|
+
rowSelectionIdProp = 'uuid' as RowProperties<IndexedRow>,
|
|
165
169
|
rowSelectionRequiresModKey = false,
|
|
166
170
|
selectionMode = $bindable(null),
|
|
167
171
|
multiSelectEnabled = true,
|
|
@@ -235,6 +239,7 @@
|
|
|
235
239
|
const session = getContext<Writable<{ userAccountId?: number }> | undefined>('session')
|
|
236
240
|
// This will be accessible on the component instance, ie `const columnInfo = $derived(table?.columnInfo)` if you need it
|
|
237
241
|
export const columnInfo = new ColumnInfoRunicStore<R>(() => columns, {
|
|
242
|
+
// eslint-disable-next-line svelte/no-unused-svelte-ignore
|
|
238
243
|
// svelte-ignore state_referenced_locally
|
|
239
244
|
key: localStorageKey,
|
|
240
245
|
userAccountId: session && $session ? $session.userAccountId : undefined,
|
|
@@ -270,7 +275,7 @@
|
|
|
270
275
|
})
|
|
271
276
|
}
|
|
272
277
|
|
|
273
|
-
function defaultFilter(filter: string, rows: R
|
|
278
|
+
function defaultFilter(filter: string, rows: Array<R>, columns: Array<Column>): Array<IndexedRow> {
|
|
274
279
|
const columnProps = columns
|
|
275
280
|
?.map(({ property }) => property)
|
|
276
281
|
.filter((property): property is KeyPath => !isArbitraryProperty(property))
|
|
@@ -287,8 +292,8 @@
|
|
|
287
292
|
*
|
|
288
293
|
* In tree mode, shows all children if parent matches, or shows matching children and their children
|
|
289
294
|
*/
|
|
290
|
-
function getFilterMatches(filter: string, theRows: Array<R>, props: KeyPath
|
|
291
|
-
return theRows.reduce((rows, row, index): IndexedRow
|
|
295
|
+
function getFilterMatches(filter: string, theRows: Array<R>, props: Array<KeyPath>) {
|
|
296
|
+
return theRows.reduce((rows, row, index): Array<IndexedRow> => {
|
|
292
297
|
if (rowMatchesFilterMethod(filter, row, props)) {
|
|
293
298
|
rows.push({ ...row, originalIndex: index, uuid: 'uuid' in row ? (row.uuid as string) : uuid() })
|
|
294
299
|
} else if (tree && Array.isArray(row.children) && row.children.length) {
|
|
@@ -315,29 +320,24 @@
|
|
|
315
320
|
)
|
|
316
321
|
}
|
|
317
322
|
|
|
318
|
-
export function getNestedProperty(
|
|
319
|
-
row:
|
|
320
|
-
path:
|
|
323
|
+
export function getNestedProperty<Row extends R, K extends RowProperties<Row>>(
|
|
324
|
+
row: Row,
|
|
325
|
+
path: K,
|
|
321
326
|
defaultValue?: string | number,
|
|
322
|
-
):
|
|
323
|
-
export function getNestedProperty(row: R, path: KeyPath, defaultValue?: string | number): GetRowProperty
|
|
324
|
-
export function getNestedProperty(
|
|
325
|
-
row: R | (R & { uuid: string }),
|
|
326
|
-
path: KeyPath | 'uuid',
|
|
327
|
-
defaultValue?: string | number,
|
|
328
|
-
): GetRowProperty | GetIndexedRowProperty {
|
|
327
|
+
): Get<Row, K> {
|
|
329
328
|
if (!path) {
|
|
330
|
-
return defaultValue as
|
|
329
|
+
return defaultValue as Get<Row, K>
|
|
331
330
|
}
|
|
332
331
|
|
|
333
332
|
if (row[path]) {
|
|
334
|
-
return row[path] as
|
|
333
|
+
return row[path] as Get<Row, K>
|
|
335
334
|
}
|
|
336
335
|
|
|
337
336
|
const val =
|
|
338
337
|
path
|
|
339
338
|
.split('[')
|
|
340
339
|
// TODO figure out if we can do this less evilly
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
341
341
|
.reduce((obj, prop) => (obj as any)?.[prop.replace(/\]/g, '')], row as any) ?? defaultValue
|
|
342
342
|
return val
|
|
343
343
|
}
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
|
|
365
365
|
export function rowIsSelected(
|
|
366
366
|
row: IndexedRow,
|
|
367
|
-
rowSelectionIdProp:
|
|
367
|
+
rowSelectionIdProp: RowProperties<IndexedRow>,
|
|
368
368
|
selectedRowIds: Array<GetIndexedRowProperty>,
|
|
369
369
|
) {
|
|
370
370
|
const selectionId = getNestedProperty(row, rowSelectionIdProp, row.uuid)
|
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
if (!selectionEnabled || !rowSelectionIdProp) {
|
|
376
376
|
return
|
|
377
377
|
}
|
|
378
|
-
const clickedId = getNestedProperty(row, rowSelectionIdProp
|
|
378
|
+
const clickedId = getNestedProperty(row, rowSelectionIdProp)
|
|
379
379
|
|
|
380
380
|
const selectedIds = selectedRowIds
|
|
381
381
|
|
|
@@ -419,10 +419,11 @@
|
|
|
419
419
|
|
|
420
420
|
if (selectionDirection) {
|
|
421
421
|
sortedRows.forEach((item, index) => {
|
|
422
|
+
const id = getNestedProperty(item, rowSelectionIdProp)
|
|
422
423
|
if (selectionDirection === 'UP' && index <= lastSelectedIndex && index >= clickedItemIndex) {
|
|
423
|
-
newSelectedIds = newSelectedIds.concat(
|
|
424
|
+
newSelectedIds = newSelectedIds.concat(id)
|
|
424
425
|
} else if (selectionDirection === 'DOWN' && index >= lastSelectedIndex && index <= clickedItemIndex) {
|
|
425
|
-
newSelectedIds = newSelectedIds.concat(
|
|
426
|
+
newSelectedIds = newSelectedIds.concat(id)
|
|
426
427
|
}
|
|
427
428
|
})
|
|
428
429
|
}
|
|
@@ -532,7 +533,6 @@
|
|
|
532
533
|
previousSortDirection = sortDirection
|
|
533
534
|
previousSortColumn = sortColumn
|
|
534
535
|
sortedRows = theSortedRows
|
|
535
|
-
return
|
|
536
536
|
|
|
537
537
|
function standardSort(a: R, b: R) {
|
|
538
538
|
let aValue: Get<R, KeyPath> | string = getNestedProperty(a, sortProp, '')
|
|
@@ -716,20 +716,24 @@
|
|
|
716
716
|
untrack(() =>
|
|
717
717
|
doSort({
|
|
718
718
|
rows: filteredRows && Array.isArray(filteredRows) ? filteredRows : [],
|
|
719
|
-
sortColumn
|
|
720
|
-
sortDirection
|
|
719
|
+
sortColumn,
|
|
720
|
+
sortDirection,
|
|
721
721
|
sameSortOrder: true,
|
|
722
722
|
}),
|
|
723
723
|
)
|
|
724
724
|
})
|
|
725
725
|
|
|
726
726
|
const responsiveClass = $derived(
|
|
727
|
-
responsive === true ? 'table-responsive' :
|
|
727
|
+
responsive === true ? 'table-responsive' : responsive ? `table-responsive-${responsive}` : '',
|
|
728
728
|
)
|
|
729
729
|
/** Includes information computed by the columnInfo store, including what we serialize to localstorage */
|
|
730
|
-
const computedColumns = $derived(columnInfo.columns)
|
|
731
|
-
const visibleColumns = $derived(
|
|
732
|
-
|
|
730
|
+
const computedColumns: Array<ColumnInfo<R>> = $derived(columnInfo.columns)
|
|
731
|
+
const visibleColumns: Array<ColumnInfo<R>> = $derived(
|
|
732
|
+
computedColumns.filter(column => column.unhidable || column.visible),
|
|
733
|
+
)
|
|
734
|
+
const hiddenColumns: Array<ColumnInfo<R>> = $derived(
|
|
735
|
+
computedColumns.filter(column => !column.unhidable && !column.visible),
|
|
736
|
+
)
|
|
733
737
|
const showPagination = $derived((perPageCount && rows.length > perPageCount) || totalItemsCount > perPageCount)
|
|
734
738
|
|
|
735
739
|
const footers = $derived(
|
|
@@ -848,6 +852,7 @@
|
|
|
848
852
|
id={tableId}
|
|
849
853
|
class={['table mb-0', tableClass]}
|
|
850
854
|
class:table-sm={size === 'sm'}
|
|
855
|
+
class:table-xs={size === 'xs'}
|
|
851
856
|
class:table-layout-fixed={columnResizingEnabled && useFixedLayout}
|
|
852
857
|
class:sticky={stickyHeader}
|
|
853
858
|
class:table-striped={striped}
|
|
@@ -857,7 +862,7 @@
|
|
|
857
862
|
>
|
|
858
863
|
<thead>
|
|
859
864
|
<tr>
|
|
860
|
-
{#each visibleColumns as column, index}
|
|
865
|
+
{#each visibleColumns as column, index (column.property)}
|
|
861
866
|
{@const isSortColumn = sortColumn?.property === column.property}
|
|
862
867
|
{@const doEllipsis = column.ellipsis || columnResizingEnabled}
|
|
863
868
|
|
|
@@ -910,7 +915,6 @@
|
|
|
910
915
|
<!-- I think setting the role and aria-orientation attributes is the best we can do here -->
|
|
911
916
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
912
917
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
913
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
914
918
|
<div
|
|
915
919
|
id="col-resizer-{tableId}-{column.property}"
|
|
916
920
|
tabindex={0}
|
|
@@ -928,7 +932,7 @@
|
|
|
928
932
|
</tr>
|
|
929
933
|
</thead>
|
|
930
934
|
<tbody class:unselectable={selectionMode === 'RANGE'}>
|
|
931
|
-
{#snippet tableRow(row:
|
|
935
|
+
{#snippet tableRow(row: IndexedRow, index: number)}
|
|
932
936
|
{#if children}
|
|
933
937
|
{@render children({ row, index })}
|
|
934
938
|
{:else}
|
|
@@ -944,8 +948,8 @@
|
|
|
944
948
|
{isArbitraryProperty(column.property)
|
|
945
949
|
? ''
|
|
946
950
|
: column.formatter
|
|
947
|
-
? column.formatter(getNestedProperty(row, column.property, ''))
|
|
948
|
-
: getNestedProperty(row, column.property, '')}
|
|
951
|
+
? column.formatter(getNestedProperty<R, KeyPath>(row, column.property, ''))
|
|
952
|
+
: getNestedProperty<R, KeyPath>(row, column.property, '')}
|
|
949
953
|
</Td>
|
|
950
954
|
{/each}
|
|
951
955
|
</tr>
|
|
@@ -964,13 +968,14 @@
|
|
|
964
968
|
{@render tableRow(row, index)}
|
|
965
969
|
{/each}
|
|
966
970
|
{:else}
|
|
971
|
+
<!-- eslint-disable-next-line svelte/require-each-key -->
|
|
967
972
|
{#each currentPageRows as row, index}
|
|
968
973
|
{@render tableRow(row, index)}
|
|
969
974
|
{/each}
|
|
970
975
|
{/if}
|
|
971
976
|
</tbody>
|
|
972
977
|
{#if showFooter && footers}
|
|
973
|
-
<tfoot>
|
|
978
|
+
<tfoot class="font-weight-bold fw-bold">
|
|
974
979
|
<tr class="table-secondary">
|
|
975
980
|
{#if footerRow}
|
|
976
981
|
{@render footerRow({ footers })}
|
|
@@ -1090,7 +1095,7 @@
|
|
|
1090
1095
|
{/if}
|
|
1091
1096
|
</ContextMenu>
|
|
1092
1097
|
|
|
1093
|
-
{#snippet columnNameAndIcon(column: GenericColumn)}
|
|
1098
|
+
{#snippet columnNameAndIcon(column: Pick<GenericColumn, 'icon' | 'iconLeft' | 'iconPrefix' | 'name'>)}
|
|
1094
1099
|
<!-- Don't add any whitespace btwn these if blocks to keep the spaces correct -->
|
|
1095
1100
|
{#if column.icon && column.iconLeft}
|
|
1096
1101
|
<Icon
|
|
@@ -1162,4 +1167,20 @@
|
|
|
1162
1167
|
.cursor-pointer {
|
|
1163
1168
|
cursor: pointer;
|
|
1164
1169
|
}
|
|
1170
|
+
|
|
1171
|
+
table.table-xs {
|
|
1172
|
+
--xs-padding: 0.125rem;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/* Copied from table-sm - reduce td padding */
|
|
1176
|
+
* :global(.table-xs > :not(caption) > * > *) {
|
|
1177
|
+
padding: var(--xs-padding) var(--xs-padding) !important;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/* Reduce form control padding. */
|
|
1181
|
+
* :global(.table-xs :where(input, select, textarea)) {
|
|
1182
|
+
padding: var(--xs-padding) 0.25rem !important;
|
|
1183
|
+
/* Bootstrap sets a min width on form controls; Undo that so the lower padding works */
|
|
1184
|
+
min-height: 0px;
|
|
1185
|
+
}
|
|
1165
1186
|
</style>
|
package/dist/Table.svelte.d.ts
CHANGED
|
@@ -53,7 +53,10 @@ declare class __sveltets_Render<R extends UuidRowProps> {
|
|
|
53
53
|
}, []> : T : never : never, {
|
|
54
54
|
strict: true;
|
|
55
55
|
}>[] | undefined;
|
|
56
|
-
rowSelectionIdProp?:
|
|
56
|
+
rowSelectionIdProp?: RowProperties<R & {
|
|
57
|
+
originalIndex: number;
|
|
58
|
+
uuid: string;
|
|
59
|
+
}> | undefined;
|
|
57
60
|
rowSelectionRequiresModKey?: boolean;
|
|
58
61
|
selectionMode?: "SINGLE" | "RANGE" | null;
|
|
59
62
|
multiSelectEnabled?: boolean;
|
|
@@ -74,7 +77,7 @@ declare class __sveltets_Render<R extends UuidRowProps> {
|
|
|
74
77
|
totalItemsCount?: number;
|
|
75
78
|
stickyHeader?: boolean;
|
|
76
79
|
responsive?: boolean | "sm" | "md" | "lg" | "xl";
|
|
77
|
-
size?: "sm" | "";
|
|
80
|
+
size?: "xs" | "sm" | "";
|
|
78
81
|
striped?: boolean;
|
|
79
82
|
/** When true, enables tree-specific features. Required if you want to use `TreeRow`s. */
|
|
80
83
|
tree?: boolean;
|
|
@@ -145,34 +148,19 @@ declare class __sveltets_Render<R extends UuidRowProps> {
|
|
|
145
148
|
columnInfo: ColumnInfoRunicStore<R>;
|
|
146
149
|
defaultColumnClicked: (clickedColumn: GenericColumn<R & {}>, sortDirection: SortDirection) => Promise<void>;
|
|
147
150
|
defaultRowMatchesFilter: (filter: string, row: R, props: RowProperties<R>[]) => boolean;
|
|
148
|
-
getNestedProperty: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
uuid: string;
|
|
154
|
-
}, RowProperties<R & {
|
|
155
|
-
originalIndex: number;
|
|
156
|
-
uuid: string;
|
|
157
|
-
}> extends infer T ? T extends RowProperties<R & {
|
|
158
|
-
originalIndex: number;
|
|
159
|
-
uuid: string;
|
|
160
|
-
}> ? T extends string ? import("type-fest/source/split").SplitHelper<import("type-fest/source/get").FixPathSquareBrackets<T>, ".", {
|
|
161
|
-
strictLiteralChecks: false;
|
|
162
|
-
}, []> : T : never : never, {
|
|
163
|
-
strict: true;
|
|
164
|
-
}>;
|
|
165
|
-
(row: R, path: RowProperties<R>, defaultValue?: string | number): import("type-fest/source/get").GetWithPath<R, RowProperties<R> extends infer T ? T extends RowProperties<R> ? T extends string ? import("type-fest/source/split").SplitHelper<import("type-fest/source/get").FixPathSquareBrackets<T>, ".", {
|
|
166
|
-
strictLiteralChecks: false;
|
|
167
|
-
}, []> : T : never : never, {
|
|
168
|
-
strict: true;
|
|
169
|
-
}>;
|
|
170
|
-
};
|
|
151
|
+
getNestedProperty: <Row extends R, K extends RowProperties<Row>>(row: Row, path: K, defaultValue?: string | number) => import("type-fest/source/get").GetWithPath<Row, K extends string ? import("type-fest/source/split").SplitHelper<import("type-fest/source/get").FixPathSquareBrackets<K>, ".", {
|
|
152
|
+
strictLiteralChecks: false;
|
|
153
|
+
}, []> : K, {
|
|
154
|
+
strict: true;
|
|
155
|
+
}>;
|
|
171
156
|
expandRow: (rowId: string | number, expanded?: boolean) => void;
|
|
172
157
|
rowIsSelected: (row: R & {
|
|
173
158
|
originalIndex: number;
|
|
174
159
|
uuid: string;
|
|
175
|
-
}, rowSelectionIdProp:
|
|
160
|
+
}, rowSelectionIdProp: RowProperties<R & {
|
|
161
|
+
originalIndex: number;
|
|
162
|
+
uuid: string;
|
|
163
|
+
}>, selectedRowIds: import("type-fest/source/get").GetWithPath<R & {
|
|
176
164
|
originalIndex: number;
|
|
177
165
|
uuid: string;
|
|
178
166
|
}, RowProperties<R & {
|
package/dist/Td.svelte
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
|
1
2
|
<script
|
|
2
3
|
lang="ts"
|
|
3
4
|
generics="R extends UuidRowProps = any"
|
|
4
5
|
>
|
|
5
|
-
import type { ColumnInfo,
|
|
6
|
+
import type { ColumnInfo, UuidRowProps } from './'
|
|
6
7
|
import type { ColumnInfoRunicStore } from './column-info-store.svelte'
|
|
7
8
|
import type { HTMLTdAttributes, ClassValue } from 'svelte/elements'
|
|
8
9
|
import type { Writable } from 'svelte/store'
|
package/dist/Td.svelte.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UuidRowProps } from './';
|
|
2
2
|
import type { HTMLTdAttributes, ClassValue } from 'svelte/elements';
|
|
3
3
|
import { type Snippet } from 'svelte';
|
|
4
4
|
declare class __sveltets_Render<R extends UuidRowProps = any> {
|
|
5
5
|
props(): Omit<HTMLTdAttributes, "align"> & {
|
|
6
6
|
class?: ClassValue;
|
|
7
|
-
property: `_${string}` | RowProperties<R>;
|
|
7
|
+
property: `_${string}` | import("./").RowProperties<R>;
|
|
8
8
|
/** Direction to align the column's contents
|
|
9
9
|
*
|
|
10
10
|
* `start` and `end` are only available in Bootstrap 5+
|
package/dist/TreeRow.svelte
CHANGED
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
}: Props = $props()
|
|
56
56
|
|
|
57
57
|
function pad(depth: number) {
|
|
58
|
-
return depth * NEST_PADDING
|
|
58
|
+
return `${depth * NEST_PADDING}rem`
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const selectedRowIds = getContext<Writable<
|
|
61
|
+
const selectedRowIds = getContext<Writable<Array<number | string>>>('selectedRowIds')
|
|
62
62
|
if (!hasContext('expandedRows')) {
|
|
63
63
|
throw new Error('TreeRow requires that the `tree` prop is set to true on a parent Table component.')
|
|
64
64
|
}
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
size="xs"
|
|
117
117
|
color="link"
|
|
118
118
|
style="padding-left: {buttonPadding}; box-shadow: none!important; font-size: 1rem; text-wrap: nowrap;"
|
|
119
|
-
icon={{ icon
|
|
119
|
+
icon={{ icon, class: 'fa-xl', fixedWidth: true, prefix: 'fas' }}
|
|
120
120
|
disabled={!childRows.length}
|
|
121
121
|
colorGreyDisabled={false}
|
|
122
122
|
onclick={onFoldClick}
|
|
@@ -145,6 +145,7 @@
|
|
|
145
145
|
</tr>
|
|
146
146
|
|
|
147
147
|
{#if expanded}
|
|
148
|
+
<!-- eslint-disable-next-line svelte/require-each-key -->
|
|
148
149
|
{#each childRows as child}
|
|
149
150
|
<TreeRow
|
|
150
151
|
node={child}
|
package/dist/bracket-paths.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Paths } from 'type-fest';
|
|
2
2
|
/**
|
|
3
3
|
Generate a union of all possible paths to properties in the given object, denoting the object structure with brackets.
|
|
4
4
|
|
|
5
5
|
This is the `Paths` utility type from the `type-fest` package, but with brackets.
|
|
6
6
|
*/
|
|
7
|
-
export type BracketPaths<Row
|
|
8
|
-
|
|
7
|
+
export type BracketPaths<Row> = DotToBracket<Paths<Row, {
|
|
8
|
+
maxRecursionDepth: 3;
|
|
9
|
+
}>>;
|
|
10
|
+
export type DotToBracket<S> = S extends string ? S extends `${infer Head}.${infer Tail}` ? `${Head}${_DotToBracketTail<Tail>}` : S : never;
|
|
9
11
|
type _DotToBracketTail<S extends string> = S extends `${infer Part}.${infer Rest}` ? `[${Part}]${_DotToBracketTail<Rest>}` : `[${S}]`;
|
|
10
12
|
export {};
|
package/dist/tree-utility.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type TreeNode<T, IdKeypath extends IdKeyType<T>, ParentIdKeypath extends
|
|
|
16
16
|
* @param idKey The name of a unique id property on the objects in the array
|
|
17
17
|
* @param parentIdKey The name of a property on the objects in the array that references the id of the parent object
|
|
18
18
|
*/
|
|
19
|
-
export declare function treeify<T extends object, K extends IdKeyType<T>, P extends ParentIdKeyType<T>>(array: T
|
|
19
|
+
export declare function treeify<T extends object, K extends IdKeyType<T>, P extends ParentIdKeyType<T>>(array: Array<T>, idKey: K, parentIdKey: P): TreeNode<T, K, P>[];
|
|
20
20
|
/**
|
|
21
21
|
* Gets the path to a node in the tree with the given id
|
|
22
22
|
* @param tree The tree
|
package/dist/tree-utility.js
CHANGED
|
@@ -121,9 +121,7 @@ export function upsertIntoTree(tree, node, key, parentKey) {
|
|
|
121
121
|
* @param deleteChildren If true, the node's children will be deleted. If false, the node's children will be moved to the node's parent
|
|
122
122
|
* @returns The tree, with the node(s) removed
|
|
123
123
|
*/
|
|
124
|
-
export function removeFromTree(tree, node, key, parentKey,
|
|
125
|
-
// eslint-disable-next-line comma-dangle
|
|
126
|
-
deleteChildren = false) {
|
|
124
|
+
export function removeFromTree(tree, node, key, parentKey, deleteChildren = false) {
|
|
127
125
|
const foundNode = findNodeById(tree, key, node[key]);
|
|
128
126
|
if (foundNode) {
|
|
129
127
|
const parent = foundNode.parent;
|
package/dist/types.d.ts
CHANGED
|
@@ -8,11 +8,7 @@ export type SortDirection = 'ASC' | 'DESC';
|
|
|
8
8
|
*
|
|
9
9
|
* Can include bracket notation for nested properties, e.g. `foo[bar]` for `{ foo: { bar: 'baz' } }`. Max recursion depth is 3.
|
|
10
10
|
*/
|
|
11
|
-
export type RowProperties<R> = BracketPaths<R
|
|
12
|
-
maxRecursionDepth: 3;
|
|
13
|
-
}> extends never ? string : BracketPaths<R, {
|
|
14
|
-
maxRecursionDepth: 3;
|
|
15
|
-
}>;
|
|
11
|
+
export type RowProperties<R> = BracketPaths<R> extends never ? string : BracketPaths<R>;
|
|
16
12
|
/** A column in your table.
|
|
17
13
|
*
|
|
18
14
|
* If you specify a type for your row object, `property` must be a valid path to a property of that object.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoftdata/svelte-table",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,35 +13,32 @@
|
|
|
13
13
|
"!dist/**/*.spec.*"
|
|
14
14
|
],
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"svelte": "
|
|
16
|
+
"svelte": "5.55.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@faker-js/faker": "^8.4.1",
|
|
20
20
|
"@fortawesome/fontawesome-common-types": "^7.1.0",
|
|
21
|
+
"@isoftdata/eslint-config-svelte": "^1.1.0",
|
|
21
22
|
"@isoftdata/prettier-config": "^2.0.4",
|
|
22
23
|
"@isoftdata/svelte-bootstrap-version-switcher": "^1.1.2",
|
|
23
24
|
"@isoftdata/svelte-checkbox": "^2.2.1",
|
|
24
25
|
"@isoftdata/svelte-select": "^2.0.1",
|
|
25
26
|
"@isoftdata/svelte-textarea": "^2.0.0",
|
|
26
27
|
"@sveltejs/adapter-auto": "^3.3.1",
|
|
27
|
-
"@sveltejs/kit": "^2.
|
|
28
|
-
"@sveltejs/package": "^2.
|
|
28
|
+
"@sveltejs/kit": "^2.59.1",
|
|
29
|
+
"@sveltejs/package": "^2.5.7",
|
|
29
30
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
30
31
|
"@types/natural-compare-lite": "^1.4.2",
|
|
31
|
-
"
|
|
32
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
33
|
-
"eslint": "^8.57.1",
|
|
34
|
-
"eslint-config-prettier": "^8.10.0",
|
|
35
|
-
"eslint-plugin-svelte": "^2.46.1",
|
|
32
|
+
"eslint": "^10.3.0",
|
|
36
33
|
"i18next": "^24.2.2",
|
|
37
34
|
"prettier": "^3.5.3",
|
|
38
35
|
"prettier-plugin-svelte": "^3.3.3",
|
|
39
36
|
"publint": "^0.1.16",
|
|
40
|
-
"svelte": "5.
|
|
37
|
+
"svelte": "5.55.5",
|
|
41
38
|
"svelte-check": "^4.1.4",
|
|
42
39
|
"tslib": "^2.8.1",
|
|
43
40
|
"type-fest": "^4.41.0",
|
|
44
|
-
"typescript": "^
|
|
41
|
+
"typescript": "^6.0.3",
|
|
45
42
|
"vite": "^6.2.0"
|
|
46
43
|
},
|
|
47
44
|
"svelte": "./dist/index.js",
|
|
@@ -51,7 +48,7 @@
|
|
|
51
48
|
"dependencies": {
|
|
52
49
|
"@isoftdata/browser-event": "^2.3.2",
|
|
53
50
|
"@isoftdata/svelte-button": "^2.1.0",
|
|
54
|
-
"@isoftdata/svelte-context-menu": "^2.0
|
|
51
|
+
"@isoftdata/svelte-context-menu": "^2.1.0",
|
|
55
52
|
"@isoftdata/svelte-icon": "^2.1.0",
|
|
56
53
|
"@isoftdata/svelte-input": "^2.1.1",
|
|
57
54
|
"@isoftdata/svelte-store-user-local-writable": "^2.0.0",
|
|
@@ -59,12 +56,13 @@
|
|
|
59
56
|
"@isoftdata/utility-currency": "^3.0.0",
|
|
60
57
|
"@isoftdata/utility-string": "^2.1.0",
|
|
61
58
|
"@lukeed/uuid": "^2.0.1",
|
|
59
|
+
"@types/node": "^22.19.18",
|
|
62
60
|
"klona": "^2.0.6",
|
|
63
61
|
"natural-compare-lite": "^1.4.0",
|
|
64
62
|
"runed": "^0.23.4"
|
|
65
63
|
},
|
|
66
64
|
"engines": {
|
|
67
|
-
"pnpm": "
|
|
65
|
+
"pnpm": "11.x"
|
|
68
66
|
},
|
|
69
67
|
"scripts": {
|
|
70
68
|
"dev": "vite dev",
|