@isoftdata/svelte-table 2.6.6 → 2.7.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/README.md +1 -1
- package/dist/Table.svelte +31 -15
- package/dist/Td.svelte +5 -2
- package/dist/Td.svelte.d.ts +1 -0
- package/dist/column-info-store.svelte.d.ts +4 -1
- package/dist/column-info-store.svelte.js +18 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ This component uses a generic type `R` to represent the type of a single row pas
|
|
|
69
69
|
| rowSelectionIdProp | `K \| "uuid"` | The property to use as the unique identifier for each row in the row selection feature. | `"uuid"` |
|
|
70
70
|
| rowSelectionRequiresModKey | `boolean` | Whether the row selection feature requires a modifier key or not. | `false` |
|
|
71
71
|
| selectionEnabled | `boolean` | Whether the row selection feature is enabled or not. | `false` |
|
|
72
|
-
| selectionMode | `"SINGLE" \| "RANGE" \| null` | The selection mode for the row selection feature. When `
|
|
72
|
+
| selectionMode | `"SINGLE" \| "RANGE" \| null` | The selection mode for the row selection feature. When `multiSelectEnabled` is true, both selection modes will allow you to select multiple rows. | `null` |
|
|
73
73
|
| showFilterLabel | `boolean` | Whether the filter label is shown or not. | `false` |
|
|
74
74
|
| showFooter | `boolean` | Defines if a `<tfoot>` should be shown. See `footers` slot below. | `false` |
|
|
75
75
|
| size | `"sm" \| ""` | The size of the table. | `"sm"` |
|
package/dist/Table.svelte
CHANGED
|
@@ -547,9 +547,12 @@
|
|
|
547
547
|
|
|
548
548
|
try {
|
|
549
549
|
untrack(() => {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
550
|
+
columnInfo.updateColumns(
|
|
551
|
+
columnProperties.map((property): { property: RowProperties<R>; visible: boolean } => ({
|
|
552
|
+
property,
|
|
553
|
+
visible,
|
|
554
|
+
})),
|
|
555
|
+
)
|
|
553
556
|
})
|
|
554
557
|
} catch (err) {
|
|
555
558
|
console.error(`Error setting column visibility for columns ${JSON.stringify(columnProperties)}`, err)
|
|
@@ -639,20 +642,28 @@
|
|
|
639
642
|
useFixedLayout = false
|
|
640
643
|
await tick()
|
|
641
644
|
if (columnResizingEnabled) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
if (th) {
|
|
645
|
+
columnInfo.updateColumns(
|
|
646
|
+
columns.map((column): { property: RowProperties<R>; userWidth: string } => {
|
|
645
647
|
const thisColumnInfo = columnInfo.current[column.property]
|
|
646
648
|
const prevUserWidth = thisColumnInfo?.userWidth
|
|
647
649
|
// Minimum width will be inherited from the layout on reset, but this won't, so re-set it here if needed
|
|
648
650
|
const explicitWidth = thisColumnInfo?.width
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
651
|
+
|
|
652
|
+
return {
|
|
653
|
+
property: column.property,
|
|
654
|
+
userWidth: prevUserWidth ?? explicitWidth ?? getColumnThWidth(column.property),
|
|
655
|
+
}
|
|
656
|
+
}),
|
|
657
|
+
)
|
|
653
658
|
useFixedLayout = true
|
|
654
659
|
}
|
|
655
660
|
}
|
|
661
|
+
|
|
662
|
+
function getColumnThWidth(property: string) {
|
|
663
|
+
const thWidth =
|
|
664
|
+
tableParent?.querySelector<HTMLTableCellElement>(`#col-${tableId}-${CSS.escape(property)}`)?.offsetWidth ?? 25
|
|
665
|
+
return `${thWidth}px`
|
|
666
|
+
}
|
|
656
667
|
// #region Computed
|
|
657
668
|
$effect(() => {
|
|
658
669
|
selectedRowIdsStore.set(selectedRowIds)
|
|
@@ -897,7 +908,10 @@
|
|
|
897
908
|
{@render footerRow({ footers })}
|
|
898
909
|
{:else}
|
|
899
910
|
{#each footers as { property, value } (property)}
|
|
900
|
-
<Td
|
|
911
|
+
<Td
|
|
912
|
+
{property}
|
|
913
|
+
tagName="TH">{value ?? ''}</Td
|
|
914
|
+
>
|
|
901
915
|
{/each}
|
|
902
916
|
{/if}
|
|
903
917
|
</tr>
|
|
@@ -956,10 +970,12 @@
|
|
|
956
970
|
<DropdownItem
|
|
957
971
|
icon="broom"
|
|
958
972
|
onclick={() => {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
973
|
+
columnInfo.updateColumns(
|
|
974
|
+
computedColumns.map(col => ({
|
|
975
|
+
property: col.property,
|
|
976
|
+
userWidth: undefined,
|
|
977
|
+
})),
|
|
978
|
+
)
|
|
963
979
|
setDefaultColumnWidths()
|
|
964
980
|
}}>{translate('common:tableResetColumnSizes', 'Reset Column Sizes')}</DropdownItem
|
|
965
981
|
>
|
package/dist/Td.svelte
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
enterGoesDown?: boolean | ((ctx: { event: KeyboardEvent; tr: HTMLTableRowElement }) => void)
|
|
28
28
|
/** If enabled, keypress (enter only) and click events on the Td's contents will have `stopPropagation`/`preventDefault` called on them. */
|
|
29
29
|
stopPropagation?: boolean
|
|
30
|
+
tagName?: 'TD' | 'TH'
|
|
30
31
|
children?: Snippet
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
align = $bindable(columnInfo.current[property]?.align),
|
|
38
39
|
enterGoesDown = false,
|
|
39
40
|
stopPropagation = false,
|
|
41
|
+
tagName = 'TD',
|
|
40
42
|
children,
|
|
41
43
|
...rest
|
|
42
44
|
}: Props = $props()
|
|
@@ -104,7 +106,8 @@
|
|
|
104
106
|
</script>
|
|
105
107
|
|
|
106
108
|
{#if visible}
|
|
107
|
-
<
|
|
109
|
+
<svelte:element
|
|
110
|
+
this={tagName}
|
|
108
111
|
class={[classNames, alignClass]}
|
|
109
112
|
{...rest}
|
|
110
113
|
style:font-variant-numeric={thisColumnInfo?.numeric ? 'tabular-nums' : undefined}
|
|
@@ -126,7 +129,7 @@
|
|
|
126
129
|
{:else}
|
|
127
130
|
{@render children?.()}
|
|
128
131
|
{/if}
|
|
129
|
-
</
|
|
132
|
+
</svelte:element>
|
|
130
133
|
{/if}
|
|
131
134
|
|
|
132
135
|
<style>
|
package/dist/Td.svelte.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface Props extends Omit<HTMLTdAttributes, 'align'> {
|
|
|
20
20
|
}) => void);
|
|
21
21
|
/** If enabled, keypress (enter only) and click events on the Td's contents will have `stopPropagation`/`preventDefault` called on them. */
|
|
22
22
|
stopPropagation?: boolean;
|
|
23
|
+
tagName?: 'TD' | 'TH';
|
|
23
24
|
children?: Snippet;
|
|
24
25
|
}
|
|
25
26
|
declare const Td: import("svelte").Component<Props, {}, "align">;
|
|
@@ -56,7 +56,10 @@ export declare class ColumnInfoRunicStore<R extends UuidRowProps> {
|
|
|
56
56
|
visible: boolean;
|
|
57
57
|
}[];
|
|
58
58
|
get current(): ColumnInfoObject<R>;
|
|
59
|
-
updateColumn
|
|
59
|
+
updateColumn(property: RowProperties<R>, value: Partial<GenericColumnInfo<R>>): void;
|
|
60
|
+
updateColumns(newColumnInfos: Array<Partial<GenericColumnInfo<R>> & {
|
|
61
|
+
property: RowProperties<R>;
|
|
62
|
+
}>): void;
|
|
60
63
|
private getStoreValFromColumns;
|
|
61
64
|
/** Takes values from the given column, removes non-serializable values, and fills in with default serializable values */
|
|
62
65
|
private getSerializableValuesWithDefaults;
|
|
@@ -47,18 +47,28 @@ export class ColumnInfoRunicStore {
|
|
|
47
47
|
get current() {
|
|
48
48
|
return this.#value;
|
|
49
49
|
}
|
|
50
|
-
updateColumn
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
updateColumn(property, value) {
|
|
51
|
+
this.updateColumns([
|
|
52
|
+
{
|
|
53
|
+
...value,
|
|
54
|
+
property,
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
updateColumns(newColumnInfos) {
|
|
59
|
+
newColumnInfos.forEach(col => {
|
|
60
|
+
if (!(col.property in this.#value)) {
|
|
61
|
+
console.error(`Column ${col.property} not found in column info store`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// This gets run for every column in the table on render, so use Object.assign as it's faster than spreading
|
|
65
|
+
Object.assign(this.#value[col.property], col);
|
|
66
|
+
});
|
|
57
67
|
this.#lastValue = this.#value;
|
|
58
68
|
if (this.#persistedState) {
|
|
59
69
|
this.#persistedState.current = this.makeDerived(this.#value);
|
|
60
70
|
}
|
|
61
|
-
}
|
|
71
|
+
}
|
|
62
72
|
getStoreValFromColumns(columns, storeValue) {
|
|
63
73
|
const columnInfo = columns.reduce((acc, column) => {
|
|
64
74
|
const storedColumn = storeValue
|