@ims360/svelte-ivory 0.0.44 → 0.0.45

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.
Files changed (73) hide show
  1. package/dist/components/ai/Chat.svelte +11 -11
  2. package/dist/components/ai/UserMessage.svelte +1 -1
  3. package/dist/components/basic/checkbox/Checkbox.svelte +0 -1
  4. package/dist/components/basic/checkbox/Checkbox.svelte.d.ts.map +1 -1
  5. package/dist/components/layout/drawer/Drawer.svelte +0 -2
  6. package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
  7. package/dist/components/layout/modal/Modal.svelte +0 -4
  8. package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
  9. package/dist/components/layout/popover/Popover.svelte +1 -0
  10. package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
  11. package/dist/components/layout/tooltip/Tooltip.svelte +5 -5
  12. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts +5 -3
  13. package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
  14. package/dist/components/table/Column.svelte +2 -2
  15. package/dist/components/table/ColumnHead.svelte +4 -4
  16. package/dist/components/table/ColumnHead.svelte.d.ts +3 -3
  17. package/dist/components/table/ColumnHead.svelte.d.ts.map +1 -1
  18. package/dist/components/table/Row.svelte +0 -1
  19. package/dist/components/table/Row.svelte.d.ts.map +1 -1
  20. package/dist/components/table/Table.svelte +56 -24
  21. package/dist/components/table/Table.svelte.d.ts +12 -9
  22. package/dist/components/table/Table.svelte.d.ts.map +1 -1
  23. package/dist/components/table/VirtualList.svelte +3 -3
  24. package/dist/components/table/columnController.svelte.d.ts +1 -1
  25. package/dist/components/table/columnController.svelte.d.ts.map +1 -1
  26. package/dist/components/table/columnController.svelte.js +1 -1
  27. package/dist/components/table/controller.d.ts +23 -0
  28. package/dist/components/table/controller.d.ts.map +1 -0
  29. package/dist/components/table/controller.js +52 -0
  30. package/dist/components/table/index.d.ts +2 -2
  31. package/dist/components/table/index.d.ts.map +1 -1
  32. package/dist/components/table/index.js +2 -2
  33. package/dist/components/table/plugins/search.svelte.d.ts.map +1 -1
  34. package/dist/components/table/plugins/search.svelte.js +0 -1
  35. package/dist/components/toast/Toast.svelte +0 -2
  36. package/dist/components/toast/Toast.svelte.d.ts.map +1 -1
  37. package/dist/utils/functions/cookie.js +1 -1
  38. package/package.json +1 -1
  39. package/src/lib/components/ai/Chat.svelte +11 -11
  40. package/src/lib/components/ai/UserMessage.svelte +1 -1
  41. package/src/lib/components/basic/checkbox/Checkbox.svelte +0 -1
  42. package/src/lib/components/layout/drawer/Drawer.svelte +0 -2
  43. package/src/lib/components/layout/modal/Modal.svelte +0 -4
  44. package/src/lib/components/layout/popover/Popover.svelte +1 -0
  45. package/src/lib/components/layout/tabs/index.ts +0 -1
  46. package/src/lib/components/layout/tooltip/Tooltip.svelte +5 -5
  47. package/src/lib/components/table/Column.svelte +2 -2
  48. package/src/lib/components/table/ColumnHead.svelte +4 -4
  49. package/src/lib/components/table/Row.svelte +0 -1
  50. package/src/lib/components/table/Table.svelte +56 -24
  51. package/src/lib/components/table/VirtualList.svelte +3 -3
  52. package/src/lib/components/table/columnController.svelte.ts +1 -1
  53. package/src/lib/components/table/controller.ts +75 -0
  54. package/src/lib/components/table/index.ts +2 -9
  55. package/src/lib/components/table/plugins/search.svelte.ts +0 -9
  56. package/src/lib/components/toast/Toast.svelte +0 -2
  57. package/src/lib/utils/functions/cookie.ts +1 -1
  58. package/dist/components/layout/modal/ModalTest.svelte +0 -9
  59. package/dist/components/layout/modal/ModalTest.svelte.d.ts +0 -8
  60. package/dist/components/layout/modal/ModalTest.svelte.d.ts.map +0 -1
  61. package/dist/components/table/controller.svelte.d.ts +0 -37
  62. package/dist/components/table/controller.svelte.d.ts.map +0 -1
  63. package/dist/components/table/controller.svelte.js +0 -160
  64. package/dist/components/table/plugins/expandAll.svelte.d.ts +0 -7
  65. package/dist/components/table/plugins/expandAll.svelte.d.ts.map +0 -1
  66. package/dist/components/table/plugins/expandAll.svelte.js +0 -24
  67. package/dist/utils/functions/transitionProps.d.ts +0 -1
  68. package/dist/utils/functions/transitionProps.d.ts.map +0 -1
  69. package/dist/utils/functions/transitionProps.js +0 -1
  70. package/src/lib/components/layout/modal/ModalTest.svelte +0 -9
  71. package/src/lib/components/table/controller.svelte.ts +0 -203
  72. package/src/lib/components/table/plugins/expandAll.svelte.ts +0 -34
  73. package/src/lib/utils/functions/transitionProps.ts +0 -1
@@ -1,8 +0,0 @@
1
- import { type ModalProps } from './Modal.svelte';
2
- type $$ComponentProps = ModalProps & {
3
- open: boolean;
4
- };
5
- declare const ModalTest: import("svelte").Component<$$ComponentProps, {}, "">;
6
- type ModalTest = ReturnType<typeof ModalTest>;
7
- export default ModalTest;
8
- //# sourceMappingURL=ModalTest.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalTest.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/modal/ModalTest.svelte.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,KAAK,gBAAgB,GAAI,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAazD,QAAA,MAAM,SAAS,sDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -1,37 +0,0 @@
1
- import { SvelteSet } from 'svelte/reactivity';
2
- import { Column, type ColumnConfig } from './columnController.svelte';
3
- export type TableRow<T> = {
4
- id: string;
5
- children?: T[];
6
- };
7
- export type TablePlugin<T extends TableRow<T>> = (state: TableState<T>) => TableState<T>;
8
- export interface TableConfig<T extends TableRow<T>> {
9
- data: T[];
10
- plugins?: TablePlugin<T>[];
11
- id?: string;
12
- expanded: SvelteSet<string>;
13
- columns: Column[];
14
- scrollTop: number;
15
- readonly results: ReturnType<typeof treeWalker<T>>;
16
- readonly registerColumn: (config: ColumnConfig) => Column;
17
- readonly toggleExpansion: (id: string) => void;
18
- }
19
- export declare function createTableConfig<T extends TableRow<T>>(): TableConfig<T>;
20
- export interface TableState<T extends TableRow<T>> {
21
- data: T[];
22
- expanded: Set<string>;
23
- }
24
- interface TreeRow<T> {
25
- node: T;
26
- nestingLevel: number;
27
- id: string;
28
- }
29
- /** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
30
- declare function treeWalker<T extends TableRow<T>>(config: TableState<T>): {
31
- entries: TreeRow<T>[];
32
- someHaveChildren: boolean;
33
- maxNestingLevel: number;
34
- };
35
- export declare function getAllIds<T extends TableRow<T>>(...nodes: T[]): string[];
36
- export {};
37
- //# sourceMappingURL=controller.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/controller.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEtE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AAEzF,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC;IAC1D,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CA+DzE;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,UAAU,OAAO,CAAC,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACd;AAkDD,0HAA0H;AAC1H,iBAAS,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;;;;EAmD/D;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,CAMxE"}
@@ -1,160 +0,0 @@
1
- import { SvelteSet } from 'svelte/reactivity';
2
- import { Column } from './columnController.svelte';
3
- export function createTableConfig() {
4
- let data = $state([]);
5
- let plugins = $state([]);
6
- let scrollTop = $state(0);
7
- const expanded = new SvelteSet();
8
- const columns = $state([]);
9
- const results = $derived.by(() => {
10
- let state = {
11
- data,
12
- expanded
13
- };
14
- for (const plugin of plugins) {
15
- state = plugin(state);
16
- }
17
- return treeWalker(state);
18
- });
19
- return {
20
- get data() {
21
- return data;
22
- },
23
- set data(d) {
24
- data = d;
25
- },
26
- get plugins() {
27
- return plugins;
28
- },
29
- set plugins(p) {
30
- plugins = p;
31
- },
32
- get scrollTop() {
33
- return scrollTop;
34
- },
35
- set scrollTop(s) {
36
- scrollTop = s;
37
- },
38
- get expanded() {
39
- return expanded;
40
- },
41
- get columns() {
42
- return columns;
43
- },
44
- get results() {
45
- return results;
46
- },
47
- registerColumn(config) {
48
- let existingColumn = undefined;
49
- for (const column of columns) {
50
- if (column.id !== config.id)
51
- continue;
52
- existingColumn = column;
53
- break;
54
- }
55
- if (existingColumn)
56
- return existingColumn;
57
- const col = new Column(config);
58
- columns.push(col);
59
- return col;
60
- },
61
- toggleExpansion(id) {
62
- if (expanded.has(id))
63
- expanded.delete(id);
64
- else
65
- expanded.add(id);
66
- }
67
- };
68
- }
69
- // export class TableController<T extends TableRow<T>> {
70
- // id = $state();
71
- // columns = $state<Column[]>([]);
72
- // data = $state<T[]>([]);
73
- // expanded: Set<string> = new SvelteSet<string>();
74
- // scrollTop = $state(0);
75
- // constructor(id?: string) {
76
- // this.id = id;
77
- // }
78
- // readonly results = $derived(treeWalker(this.data, this.expanded));
79
- // refresh(conf: TableConfig<T>) {
80
- // let intitalState: TableState<T> = {
81
- // data: [...(conf.data ?? [])],
82
- // expanded: this.expanded
83
- // };
84
- // for (const plugin of conf.plugins ?? []) {
85
- // intitalState = plugin(intitalState);
86
- // }
87
- // this.data = intitalState.data;
88
- // this.expanded = new SvelteSet(intitalState.expanded);
89
- // this.id = conf.id ?? this.id ?? pseudoRandomId('table-');
90
- // }
91
- // registerColumn(config: ColumnConfig): Column {
92
- // // only register a column once
93
- // let existingColumn: Column | undefined = undefined;
94
- // for (const column of this.columns) {
95
- // if (column.id !== config.id) continue;
96
- // existingColumn = column;
97
- // break;
98
- // }
99
- // if (existingColumn) return existingColumn;
100
- // const col = new Column(config);
101
- // this.columns.push(col);
102
- // return col;
103
- // }
104
- // toggleExpansion(id: string) {
105
- // if (this.expanded.has(id)) this.expanded.delete(id);
106
- // else this.expanded.add(id);
107
- // }
108
- // }
109
- /** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
110
- function treeWalker(config) {
111
- const { data, expanded } = config;
112
- const stack = [];
113
- // push the root nodes of the trees onto the stack
114
- for (let i = 0; i < data.length; i++) {
115
- stack.push({
116
- node: data[data.length - i - 1],
117
- nestingLevel: 0
118
- });
119
- }
120
- const entries = []; // the final result
121
- let someHaveChildren = false; // used to determine whether to show the tree utility buttons
122
- let maxNestingLevel = 0;
123
- while (stack.length !== 0) {
124
- const stackEntry = stack.pop();
125
- if (!stackEntry)
126
- break;
127
- const { node, nestingLevel } = stackEntry;
128
- const children = node.children;
129
- if (children && children.length > 0) {
130
- someHaveChildren = true;
131
- // only show the children of expanded elements
132
- if (expanded.has(node.id)) {
133
- maxNestingLevel = Math.max(maxNestingLevel, nestingLevel + 1);
134
- stack.push(...children
135
- .map((c) => ({
136
- node: c,
137
- nestingLevel: nestingLevel + 1
138
- }))
139
- .reverse());
140
- }
141
- }
142
- entries.push({
143
- id: node.id,
144
- node,
145
- nestingLevel
146
- });
147
- }
148
- return {
149
- entries,
150
- someHaveChildren,
151
- maxNestingLevel
152
- };
153
- }
154
- export function getAllIds(...nodes) {
155
- const ids = nodes.map((n) => n.id);
156
- for (const node of nodes) {
157
- ids.push(...getAllIds(...(node.children ?? [])));
158
- }
159
- return ids;
160
- }
@@ -1,7 +0,0 @@
1
- import { type TablePlugin, type TableRow } from '../controller.svelte';
2
- interface ExpandAllConfig {
3
- enabled: boolean;
4
- }
5
- export declare function expandAllPlugin<T extends TableRow<T>>(conf: Partial<ExpandAllConfig>): TablePlugin<T>;
6
- export {};
7
- //# sourceMappingURL=expandAll.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expandAll.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/table/plugins/expandAll.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAElF,UAAU,eAAe;IACrB,OAAO,EAAE,OAAO,CAAC;CACpB;AAMD,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EACjD,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,GAC/B,WAAW,CAAC,CAAC,CAAC,CAoBhB"}
@@ -1,24 +0,0 @@
1
- import { SvelteSet } from 'svelte/reactivity';
2
- import { getAllIds } from '../controller.svelte';
3
- const DEFAULT_CONFIG = {
4
- enabled: true
5
- };
6
- export function expandAllPlugin(conf) {
7
- let initialized = false;
8
- const config = {
9
- ...DEFAULT_CONFIG,
10
- ...conf
11
- };
12
- const middleware = (state) => {
13
- if (initialized || !config.enabled)
14
- return state;
15
- initialized = true;
16
- const allIds = getAllIds(...state.data);
17
- const newExpanded = new SvelteSet(allIds);
18
- return {
19
- data: state.data,
20
- expanded: newExpanded
21
- };
22
- };
23
- return middleware;
24
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=transitionProps.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transitionProps.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/functions/transitionProps.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,9 +0,0 @@
1
- <script lang="ts">
2
- import Modal, { type ModalProps } from './Modal.svelte';
3
-
4
- let { open, ...props }: ModalProps & { open: boolean } = $props();
5
-
6
- let b_open = $state(open);
7
- </script>
8
-
9
- <Modal {...props} bind:b_open />
@@ -1,203 +0,0 @@
1
- import { SvelteSet } from 'svelte/reactivity';
2
- import { Column, type ColumnConfig } from './columnController.svelte';
3
-
4
- export type TableRow<T> = { id: string; children?: T[] };
5
- export type TablePlugin<T extends TableRow<T>> = (state: TableState<T>) => TableState<T>;
6
-
7
- export interface TableConfig<T extends TableRow<T>> {
8
- data: T[];
9
- plugins?: TablePlugin<T>[];
10
- id?: string;
11
- expanded: SvelteSet<string>;
12
- columns: Column[];
13
- scrollTop: number;
14
- readonly results: ReturnType<typeof treeWalker<T>>;
15
- readonly registerColumn: (config: ColumnConfig) => Column;
16
- readonly toggleExpansion: (id: string) => void;
17
- }
18
-
19
- export function createTableConfig<T extends TableRow<T>>(): TableConfig<T> {
20
- let data = $state<T[]>([]);
21
- let plugins = $state<TablePlugin<T>[]>([]);
22
- let scrollTop = $state(0);
23
- const expanded = new SvelteSet<string>();
24
- const columns = $state<Column[]>([]);
25
-
26
- const results = $derived.by(() => {
27
- let state: TableState<T> = {
28
- data,
29
- expanded
30
- };
31
- for (const plugin of plugins) {
32
- state = plugin(state);
33
- }
34
- return treeWalker(state);
35
- });
36
-
37
- return {
38
- get data() {
39
- return data;
40
- },
41
- set data(d) {
42
- data = d;
43
- },
44
- get plugins() {
45
- return plugins;
46
- },
47
- set plugins(p) {
48
- plugins = p;
49
- },
50
- get scrollTop() {
51
- return scrollTop;
52
- },
53
- set scrollTop(s) {
54
- scrollTop = s;
55
- },
56
- get expanded() {
57
- return expanded;
58
- },
59
- get columns() {
60
- return columns;
61
- },
62
- get results() {
63
- return results;
64
- },
65
- registerColumn(config: ColumnConfig) {
66
- let existingColumn: Column | undefined = undefined;
67
- for (const column of columns) {
68
- if (column.id !== config.id) continue;
69
- existingColumn = column;
70
- break;
71
- }
72
- if (existingColumn) return existingColumn;
73
- const col = new Column(config);
74
- columns.push(col);
75
- return col;
76
- },
77
- toggleExpansion(id: string) {
78
- if (expanded.has(id)) expanded.delete(id);
79
- else expanded.add(id);
80
- }
81
- };
82
- }
83
-
84
- export interface TableState<T extends TableRow<T>> {
85
- data: T[];
86
- expanded: Set<string>;
87
- }
88
-
89
- interface TreeRow<T> {
90
- node: T;
91
- nestingLevel: number;
92
- id: string;
93
- }
94
-
95
- // export class TableController<T extends TableRow<T>> {
96
- // id = $state();
97
- // columns = $state<Column[]>([]);
98
- // data = $state<T[]>([]);
99
- // expanded: Set<string> = new SvelteSet<string>();
100
- // scrollTop = $state(0);
101
-
102
- // constructor(id?: string) {
103
- // this.id = id;
104
- // }
105
-
106
- // readonly results = $derived(treeWalker(this.data, this.expanded));
107
-
108
- // refresh(conf: TableConfig<T>) {
109
- // let intitalState: TableState<T> = {
110
- // data: [...(conf.data ?? [])],
111
- // expanded: this.expanded
112
- // };
113
-
114
- // for (const plugin of conf.plugins ?? []) {
115
- // intitalState = plugin(intitalState);
116
- // }
117
-
118
- // this.data = intitalState.data;
119
- // this.expanded = new SvelteSet(intitalState.expanded);
120
- // this.id = conf.id ?? this.id ?? pseudoRandomId('table-');
121
- // }
122
-
123
- // registerColumn(config: ColumnConfig): Column {
124
- // // only register a column once
125
- // let existingColumn: Column | undefined = undefined;
126
- // for (const column of this.columns) {
127
- // if (column.id !== config.id) continue;
128
- // existingColumn = column;
129
- // break;
130
- // }
131
- // if (existingColumn) return existingColumn;
132
- // const col = new Column(config);
133
- // this.columns.push(col);
134
- // return col;
135
- // }
136
-
137
- // toggleExpansion(id: string) {
138
- // if (this.expanded.has(id)) this.expanded.delete(id);
139
- // else this.expanded.add(id);
140
- // }
141
- // }
142
-
143
- /** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
144
- function treeWalker<T extends TableRow<T>>(config: TableState<T>) {
145
- const { data, expanded } = config;
146
- const stack: { node: T; nestingLevel: number }[] = [];
147
-
148
- // push the root nodes of the trees onto the stack
149
- for (let i = 0; i < data.length; i++) {
150
- stack.push({
151
- node: data[data.length - i - 1],
152
- nestingLevel: 0
153
- });
154
- }
155
-
156
- const entries: TreeRow<T>[] = []; // the final result
157
-
158
- let someHaveChildren = false; // used to determine whether to show the tree utility buttons
159
- let maxNestingLevel = 0;
160
- while (stack.length !== 0) {
161
- const stackEntry = stack.pop();
162
- if (!stackEntry) break;
163
-
164
- const { node, nestingLevel } = stackEntry;
165
- const children = node.children;
166
-
167
- if (children && children.length > 0) {
168
- someHaveChildren = true;
169
- // only show the children of expanded elements
170
- if (expanded.has(node.id)) {
171
- maxNestingLevel = Math.max(maxNestingLevel, nestingLevel + 1);
172
- stack.push(
173
- ...children
174
- .map((c) => ({
175
- node: c,
176
- nestingLevel: nestingLevel + 1
177
- }))
178
- .reverse()
179
- );
180
- }
181
- }
182
-
183
- entries.push({
184
- id: node.id,
185
- node,
186
- nestingLevel
187
- });
188
- }
189
-
190
- return {
191
- entries,
192
- someHaveChildren,
193
- maxNestingLevel
194
- };
195
- }
196
-
197
- export function getAllIds<T extends TableRow<T>>(...nodes: T[]): string[] {
198
- const ids = nodes.map((n) => n.id);
199
- for (const node of nodes) {
200
- ids.push(...getAllIds(...(node.children ?? [])));
201
- }
202
- return ids;
203
- }
@@ -1,34 +0,0 @@
1
- import { SvelteSet } from 'svelte/reactivity';
2
- import { getAllIds, type TablePlugin, type TableRow } from '../controller.svelte';
3
-
4
- interface ExpandAllConfig {
5
- enabled: boolean;
6
- }
7
-
8
- const DEFAULT_CONFIG: ExpandAllConfig = {
9
- enabled: true
10
- };
11
-
12
- export function expandAllPlugin<T extends TableRow<T>>(
13
- conf: Partial<ExpandAllConfig>
14
- ): TablePlugin<T> {
15
- let initialized = false;
16
-
17
- const config: ExpandAllConfig = {
18
- ...DEFAULT_CONFIG,
19
- ...conf
20
- };
21
-
22
- const middleware: TablePlugin<T> = (state) => {
23
- if (initialized || !config.enabled) return state;
24
- initialized = true;
25
- const allIds = getAllIds(...state.data);
26
- const newExpanded = new SvelteSet(allIds);
27
- return {
28
- data: state.data,
29
- expanded: newExpanded
30
- };
31
- };
32
-
33
- return middleware;
34
- }