@ims360/svelte-ivory 0.0.46 → 0.0.48

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 (34) hide show
  1. package/dist/components/table/Column.svelte +29 -26
  2. package/dist/components/table/Column.svelte.d.ts.map +1 -1
  3. package/dist/components/table/ColumnHead.svelte +3 -5
  4. package/dist/components/table/ColumnHead.svelte.d.ts.map +1 -1
  5. package/dist/components/table/Row.svelte +25 -52
  6. package/dist/components/table/Row.svelte.d.ts +6 -4
  7. package/dist/components/table/Row.svelte.d.ts.map +1 -1
  8. package/dist/components/table/Table.svelte +74 -32
  9. package/dist/components/table/Table.svelte.d.ts +18 -8
  10. package/dist/components/table/Table.svelte.d.ts.map +1 -1
  11. package/dist/components/table/VirtualList.svelte +8 -5
  12. package/dist/components/table/VirtualList.svelte.d.ts +13 -3
  13. package/dist/components/table/VirtualList.svelte.d.ts.map +1 -1
  14. package/dist/components/table/controller.d.ts +3 -2
  15. package/dist/components/table/controller.d.ts.map +1 -1
  16. package/dist/components/table/index.d.ts +1 -2
  17. package/dist/components/table/index.d.ts.map +1 -1
  18. package/dist/components/table/index.js +0 -1
  19. package/dist/components/table/search.svelte.d.ts +8 -0
  20. package/dist/components/table/search.svelte.d.ts.map +1 -0
  21. package/dist/components/table/search.svelte.js +28 -0
  22. package/package.json +33 -32
  23. package/src/lib/components/table/Column.svelte +29 -26
  24. package/src/lib/components/table/ColumnHead.svelte +3 -5
  25. package/src/lib/components/table/Row.svelte +25 -52
  26. package/src/lib/components/table/Table.svelte +74 -32
  27. package/src/lib/components/table/VirtualList.svelte +8 -5
  28. package/src/lib/components/table/controller.ts +4 -2
  29. package/src/lib/components/table/index.ts +1 -2
  30. package/src/lib/components/table/search.svelte.ts +34 -0
  31. package/dist/components/table/plugins/search.svelte.d.ts +0 -14
  32. package/dist/components/table/plugins/search.svelte.d.ts.map +0 -1
  33. package/dist/components/table/plugins/search.svelte.js +0 -55
  34. package/src/lib/components/table/plugins/search.svelte.ts +0 -66
@@ -4,6 +4,7 @@
4
4
  import type { ClassValue } from 'svelte/elements';
5
5
  import { twMerge } from 'tailwind-merge';
6
6
  import type { ColumnConfig } from './columnController.svelte';
7
+ import { getRowContext } from './Row.svelte';
7
8
  import { getTableContext } from './Table.svelte';
8
9
 
9
10
  let defaultClasses = $state<ClassValue>();
@@ -25,7 +26,7 @@
25
26
 
26
27
  <script lang="ts">
27
28
  let {
28
- class: clazz = 'py-2 flex flex-row items-center',
29
+ class: clazz = 'py-2 flex flex-row items-center truncate',
29
30
  children,
30
31
  onclick,
31
32
  ignoreWidth = false,
@@ -36,10 +37,19 @@
36
37
  }: ColumnProps = $props();
37
38
 
38
39
  // Register the new column if this is the first table row that was rendered
39
- const { registerColumn, nestingInset } = getTableContext();
40
- const column = registerColumn({ resizable, ...props });
40
+ const tableContext = getTableContext();
41
+ const rowContext = getRowContext();
42
+ const column = tableContext.registerColumn({ resizable, ...props });
43
+
44
+ const finalOnClick = $derived(onclick || rowContext.onclick);
41
45
  const allowClicking = $derived(!!onclick);
42
46
 
47
+ const element = $derived.by(() => {
48
+ if (finalOnClick) return 'button';
49
+ if (rowContext.href) return 'a';
50
+ return 'div';
51
+ });
52
+
43
53
  // passes updated props to the column
44
54
  $effect(() => {
45
55
  column.updateConfig({ resizable, ...props });
@@ -49,34 +59,27 @@
49
59
  $effect(() => {
50
60
  if (!column.resizable && props.width !== undefined) column.resize(props.width);
51
61
  });
52
-
53
- function onClick(e: MouseEvent) {
54
- e.stopPropagation();
55
- e.preventDefault();
56
- onclick?.(e);
57
- }
58
62
  </script>
59
63
 
60
64
  <!-- svelte-ignore a11y_no_static_element_interactions -->
61
65
  <svelte:element
62
- this={allowClicking ? 'button' : 'div'}
63
- onclick={allowClicking ? onClick : undefined}
64
- type={onclick ? 'button' : undefined}
66
+ this={element}
67
+ onclick={allowClicking ? finalOnClick : undefined}
68
+ href={rowContext.href}
69
+ type={allowClicking ? 'button' : undefined}
65
70
  style={ignoreWidth
66
71
  ? ''
67
- : `width: calc(${column.width ?? 0}px - var(--spacing) * ${offsetNestingLevel * nestingInset}) !important;`}
68
- class={twMerge(
69
- clsx(
70
- 'flex shrink-0 flex-row items-stretch justify-start truncate',
71
- !ignoreWidth && [
72
- 'border-r border-transparent',
73
- column.dragging && 'border-primary-400-600',
74
- !column.dragging && column.hovering && 'border-surface-300-700'
75
- ],
76
- defaultClasses,
77
- clazz
78
- )
79
- )}
72
+ : `width: calc(${column.width ?? 0}px - var(--spacing) * ${offsetNestingLevel * tableContext.nestingInset}) !important;`}
73
+ class={[
74
+ 'flex h-full shrink-0 flex-row items-stretch justify-start truncate',
75
+ !ignoreWidth && [
76
+ 'after:mr-2 after:ml-auto after:h-full after:w-px',
77
+ column.dragging && 'after:bg-primary-400-600',
78
+ !column.dragging && column.hovering && 'after:bg-surface-300-700'
79
+ ]
80
+ ]}
80
81
  >
81
- {@render children()}
82
+ <div class={twMerge(clsx(['flex flex-row items-center gap-1', defaultClasses, clazz]))}>
83
+ {@render children()}
84
+ </div>
82
85
  </svelte:element>
@@ -1 +1 @@
1
- {"version":3,"file":"Column.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Column.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,QAEvC;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC7C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AA0DL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Column.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Column.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAM9D,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,QAEvC;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC7C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AA2DL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -36,7 +36,7 @@
36
36
  const onResize = (mouseX: number) => {
37
37
  if (!target) return;
38
38
  let newWidth = mouseX - target.getBoundingClientRect().left;
39
- column.resize(newWidth + 2);
39
+ column.resize(newWidth + 8);
40
40
  };
41
41
 
42
42
  const onDragging = (d: boolean) => {
@@ -55,10 +55,8 @@
55
55
  <button
56
56
  type="button"
57
57
  class={[
58
- 'ml-auto flex h-full w-4 shrink-0 translate-x-px cursor-col-resize justify-center border-r bg-inherit',
59
- dragging
60
- ? '!border-primary-400-600'
61
- : 'group-hover:!border-surface-300-700 border-transparent'
58
+ 'relative ml-auto h-full w-4 shrink-0 cursor-col-resize bg-inherit after:absolute after:top-0 after:right-2 after:h-full after:w-px',
59
+ dragging ? 'after:bg-primary-400-600' : 'group-hover:after:bg-surface-300-700'
62
60
  ]}
63
61
  use:resize={{ resized: onResize, dragging: onDragging }}
64
62
  onmouseenter={onHoverStart}
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnHead.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/ColumnHead.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAOlE,wBAAgB,oBAAoB,IAAI,gBAAgB,CAEvD;AAED,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA+CN,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"ColumnHead.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/ColumnHead.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAOlE,wBAAgB,oBAAoB,IAAI,gBAAgB,CAEvD;AAED,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA6CN,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -1,66 +1,39 @@
1
1
  <script lang="ts" module>
2
- import clsx from 'clsx';
3
- import { type Snippet } from 'svelte';
4
- import type { ClassValue } from 'svelte/elements';
5
- import { twMerge } from 'tailwind-merge';
2
+ import { getContext, setContext, type Snippet } from 'svelte';
6
3
 
7
- let defaultClasses = $state<ClassValue>();
8
-
9
- export function setClasses(c: ClassValue) {
10
- defaultClasses = c;
11
- }
12
-
13
- export interface Props {
14
- class?: ClassValue;
4
+ interface Props {
15
5
  onclick?: () => void;
16
6
  href?: string;
17
7
  children: Snippet;
18
8
  }
9
+
10
+ interface RowContext {
11
+ readonly onclick?: () => void;
12
+ readonly href?: string;
13
+ }
14
+
15
+ const CONTEXT = {};
16
+
17
+ function setRowContext(context: RowContext) {
18
+ setContext(CONTEXT, context);
19
+ }
20
+
21
+ export function getRowContext(): RowContext {
22
+ return getContext(CONTEXT);
23
+ }
19
24
  </script>
20
25
 
21
26
  <script lang="ts">
22
- let {
23
- class: clazz = 'hover:bg-surface-950-50/10 transition-colors',
24
- onclick,
25
- href,
26
- children
27
- }: Props = $props();
27
+ let { onclick, href, children }: Props = $props();
28
28
 
29
- const elementProps: {
30
- this: 'button' | 'a' | 'div';
31
- type?: 'button';
32
- onclick?: () => void;
33
- href?: string;
34
- } = $derived.by(() => {
35
- if (onclick) {
36
- return {
37
- this: 'button',
38
- type: 'button',
39
- onclick
40
- };
41
- } else if (href) {
42
- return {
43
- this: 'a',
44
- href: href
45
- };
46
- } else {
47
- return {
48
- this: 'div'
49
- };
29
+ setRowContext({
30
+ get onclick() {
31
+ return onclick;
32
+ },
33
+ get href() {
34
+ return href;
50
35
  }
51
36
  });
52
37
  </script>
53
38
 
54
- <svelte:element
55
- this={elementProps.this}
56
- {...elementProps}
57
- class={twMerge(
58
- clsx(
59
- 'flex h-full min-w-full grow flex-row items-stretch gap-2 overflow-hidden pr-4 pl-2',
60
- defaultClasses,
61
- clazz
62
- )
63
- )}
64
- >
65
- {@render children()}
66
- </svelte:element>
39
+ {@render children()}
@@ -1,12 +1,14 @@
1
1
  import { type Snippet } from 'svelte';
2
- import type { ClassValue } from 'svelte/elements';
3
- export declare function setClasses(c: ClassValue): void;
4
- export interface Props {
5
- class?: ClassValue;
2
+ interface Props {
6
3
  onclick?: () => void;
7
4
  href?: string;
8
5
  children: Snippet;
9
6
  }
7
+ interface RowContext {
8
+ readonly onclick?: () => void;
9
+ readonly href?: string;
10
+ }
11
+ export declare function getRowContext(): RowContext;
10
12
  declare const Row: import("svelte").Component<Props, {}, "">;
11
13
  type Row = ReturnType<typeof Row>;
12
14
  export default Row;
@@ -1 +1 @@
1
- {"version":3,"file":"Row.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Row.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,QAEvC;AAED,MAAM,WAAW,KAAK;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB;AAiDL,QAAA,MAAM,GAAG,2CAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"Row.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Row.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9D,UAAU,KAAK;IACX,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,UAAU;IAChB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CAC1B;AAQD,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAqBL,QAAA,MAAM,GAAG,2CAAwC,CAAC;AAClD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC;AAClC,eAAe,GAAG,CAAC"}
@@ -1,16 +1,17 @@
1
1
  <script lang="ts" module>
2
2
  import { ChevronRight } from '@lucide/svelte';
3
3
  import clsx from 'clsx';
4
- import { getContext, setContext, type Snippet } from 'svelte';
4
+ import { getContext, setContext, untrack, type Snippet } from 'svelte';
5
5
  import type { ClassValue } from 'svelte/elements';
6
6
  import { SvelteSet } from 'svelte/reactivity';
7
7
  import { twMerge } from 'tailwind-merge';
8
- import { Column as ColumnComponent, type TablePlugin, type TableRow } from '.';
8
+ import { Column as ColumnComponent, type TableRow } from '.';
9
+ import { ColumnController, type ColumnConfig } from './columnController.svelte';
9
10
  import ColumnHead from './ColumnHead.svelte';
11
+ import { treeWalker } from './controller';
10
12
  import Row from './Row.svelte';
13
+ import { searchData } from './search.svelte';
11
14
  import VirtualList from './VirtualList.svelte';
12
- import { ColumnController, type ColumnConfig } from './columnController.svelte';
13
- import { treeWalker, type TableState } from './controller';
14
15
 
15
16
  export interface TableProps<T extends TableRow<T>> {
16
17
  class?: ClassValue;
@@ -24,7 +25,10 @@
24
25
  firstColumn?: Snippet<[{ row: T }]>;
25
26
  rowClass?: ClassValue;
26
27
  headerClass?: ClassValue;
27
- plugins?: TablePlugin<T>[];
28
+ search?: {
29
+ term: string;
30
+ matches: (row: T) => boolean;
31
+ };
28
32
  /**
29
33
  * **Bindable**
30
34
  */
@@ -40,9 +44,9 @@
40
44
 
41
45
  const TABLE_CONTEXT = {};
42
46
  export type TableContext<T extends TableRow<T>> = {
43
- registerColumn: (config: ColumnConfig) => ColumnController;
44
- toggleExpansion: (id: string) => void;
45
- nestingInset: number;
47
+ readonly registerColumn: (config: ColumnConfig) => ColumnController;
48
+ readonly toggleExpansion: (id: string) => void;
49
+ readonly nestingInset: number;
46
50
  };
47
51
 
48
52
  function setTableContext<T extends TableRow<T>>(context: TableContext<T>) {
@@ -54,6 +58,7 @@
54
58
  }
55
59
 
56
60
  const treeIndicatorId = 'tree-chevron';
61
+ const treeIndicatorInset = 32;
57
62
  </script>
58
63
 
59
64
  <script lang="ts" generics="T extends TableRow<T>">
@@ -62,20 +67,19 @@
62
67
  data,
63
68
  children: passedChildren,
64
69
  firstColumn,
65
- rowClass,
70
+ rowClass = 'hover:bg-surface-950-50/10 transition-colors',
66
71
  headerClass,
67
72
  rowHeight = 64,
68
73
  onclick,
69
74
  href,
70
- plugins = [],
71
75
  expanded: expanded = new SvelteSet<string>(),
72
76
  nestingInset = 4,
73
77
  b_columns: externalColumns = $bindable(),
74
- b_scrollTop = $bindable()
78
+ b_scrollTop = $bindable(),
79
+ search
75
80
  }: TableProps<T> = $props();
76
81
 
77
82
  let columns = $state<ColumnController[]>(externalColumns ?? []);
78
- const results = $derived(computeResults(data, expanded, plugins));
79
83
  let treeIndicatorColumn = $state<ColumnController>();
80
84
 
81
85
  function toggleExpansion(id: string) {
@@ -83,6 +87,57 @@
83
87
  else expanded.add(id);
84
88
  }
85
89
 
90
+ let expandedBeforeSearch = $state<SvelteSet<string> | null>(null);
91
+ let prevSearch = $state('');
92
+
93
+ const searchResult = $derived.by(() => {
94
+ if (!search)
95
+ return {
96
+ filteredData: data,
97
+ isSearching: false
98
+ };
99
+ const query = search.term.trim();
100
+ // Note: We only use the 'filteredData' part of the search result here.
101
+ const { hidden } = searchData(data, query, search.matches);
102
+ return {
103
+ filteredData: data.filter((d) => !hidden.has(d.id)),
104
+ isSearching: true
105
+ };
106
+ });
107
+ const results = $derived(treeWalker({ data: searchResult.filteredData, expanded }));
108
+
109
+ $effect(() => {
110
+ if (!search) return;
111
+ const currentSearch = search.term.trim();
112
+ const wasSearching = prevSearch !== '';
113
+ const isSearching = currentSearch !== '';
114
+
115
+ // Transition: Not Searching -> Searching
116
+ if (!wasSearching && isSearching) {
117
+ // Save the current expansion state before overwriting it.
118
+ expandedBeforeSearch = untrack(() => new SvelteSet(expanded));
119
+ const { expanded: searchExpanded } = searchData(data, currentSearch, search.matches);
120
+ expanded = searchExpanded; // Set the initial expansion for the search.
121
+ }
122
+
123
+ // Transition: Searching -> Not Searching
124
+ if (wasSearching && !isSearching) {
125
+ // Restore the saved expansion state.
126
+ if (expandedBeforeSearch) {
127
+ expanded = expandedBeforeSearch;
128
+ expandedBeforeSearch = null;
129
+ }
130
+ }
131
+
132
+ // Transition: Searching -> Searching (different query)
133
+ if (wasSearching && isSearching && currentSearch !== prevSearch) {
134
+ const { expanded: searchExpanded } = searchData(data, currentSearch, search.matches);
135
+ expanded = searchExpanded; // Update the expansion for the new search.
136
+ }
137
+
138
+ prevSearch = currentSearch;
139
+ });
140
+
86
141
  setTableContext({
87
142
  toggleExpansion,
88
143
  registerColumn(config: ColumnConfig) {
@@ -107,17 +162,6 @@
107
162
  return nestingInset;
108
163
  }
109
164
  });
110
-
111
- function computeResults(data: T[], expanded: Set<string>, plugins: TablePlugin<T>[]) {
112
- let state: TableState<T> = {
113
- data,
114
- expanded
115
- };
116
- for (const plugin of plugins) {
117
- state = plugin(state);
118
- }
119
- return treeWalker(state);
120
- }
121
165
  </script>
122
166
 
123
167
  <VirtualList
@@ -125,12 +169,13 @@
125
169
  class={twMerge(clsx(['flex flex-col overflow-hidden border-transparent', clazz]))}
126
170
  bind:b_scrollTop
127
171
  {rowHeight}
172
+ rowClass={['pl-2 pr-4', rowClass]}
128
173
  >
129
174
  {#snippet header()}
130
175
  <div
131
176
  class={twMerge(
132
177
  clsx(
133
- 'flex w-fit min-w-full flex-row gap-2 border-b border-inherit pr-4 pl-2',
178
+ 'flex w-fit min-w-full flex-row border-b border-inherit pr-4 pl-2',
134
179
  headerClass
135
180
  )
136
181
  )}
@@ -154,11 +199,7 @@
154
199
  </div>
155
200
  {/snippet}
156
201
  {#snippet children({ row: { node, id, nestingLevel }, index })}
157
- <Row
158
- onclick={onclick ? () => onclick(node) : undefined}
159
- href={href?.(node)}
160
- class={rowClass}
161
- >
202
+ <Row href={href?.(node)} onclick={onclick ? () => onclick(node) : undefined}>
162
203
  {@render firstColumn?.({ row: node })}
163
204
  <ColumnComponent
164
205
  id={treeIndicatorId}
@@ -168,12 +209,13 @@
168
209
  toggleExpansion(node.id);
169
210
  }}
170
211
  ignoreWidth={results.someHaveChildren}
171
- width={results.someHaveChildren ? 24 : 0}
212
+ width={results.someHaveChildren ? treeIndicatorInset : 0}
172
213
  minWidth={0}
173
214
  >
174
215
  <div
175
- class="flex h-full items-center justify-end"
176
- style="width: calc(var(--spacing) * {nestingLevel * nestingInset} + 24px);"
216
+ class="flex h-full items-center justify-end pr-2"
217
+ style="width: calc(var(--spacing) * {nestingLevel *
218
+ nestingInset} + {treeIndicatorInset}px);"
177
219
  >
178
220
  {#if node.children}
179
221
  <ChevronRight
@@ -1,7 +1,7 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  import type { ClassValue } from 'svelte/elements';
3
3
  import { SvelteSet } from 'svelte/reactivity';
4
- import { type TablePlugin, type TableRow } from '.';
4
+ import { type TableRow } from '.';
5
5
  import { ColumnController, type ColumnConfig } from './columnController.svelte';
6
6
  export interface TableProps<T extends TableRow<T>> {
7
7
  class?: ClassValue;
@@ -21,7 +21,10 @@ export interface TableProps<T extends TableRow<T>> {
21
21
  }]>;
22
22
  rowClass?: ClassValue;
23
23
  headerClass?: ClassValue;
24
- plugins?: TablePlugin<T>[];
24
+ search?: {
25
+ term: string;
26
+ matches: (row: T) => boolean;
27
+ };
25
28
  /**
26
29
  * **Bindable**
27
30
  */
@@ -35,15 +38,22 @@ export interface TableProps<T extends TableRow<T>> {
35
38
  nestingInset?: number;
36
39
  }
37
40
  export type TableContext<T extends TableRow<T>> = {
38
- registerColumn: (config: ColumnConfig) => ColumnController;
39
- toggleExpansion: (id: string) => void;
40
- nestingInset: number;
41
+ readonly registerColumn: (config: ColumnConfig) => ColumnController;
42
+ readonly toggleExpansion: (id: string) => void;
43
+ readonly nestingInset: number;
41
44
  };
42
45
  export declare function getTableContext<T extends TableRow<T>>(): TableContext<T>;
46
+ declare function $$render<T extends TableRow<T>>(): {
47
+ props: TableProps<T>;
48
+ exports: {};
49
+ bindings: "b_scrollTop" | "b_columns";
50
+ slots: {};
51
+ events: {};
52
+ };
43
53
  declare class __sveltets_Render<T extends TableRow<T>> {
44
- props(): TableProps<T>;
45
- events(): {};
46
- slots(): {};
54
+ props(): ReturnType<typeof $$render<T>>['props'];
55
+ events(): ReturnType<typeof $$render<T>>['events'];
56
+ slots(): ReturnType<typeof $$render<T>>['slots'];
47
57
  bindings(): "b_scrollTop" | "b_columns";
48
58
  exports(): {};
49
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Table.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Table.svelte.ts"],"names":[],"mappings":"AAKI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAA6B,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,GAAG,CAAC;AAI/E,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGhF,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3B,IAAI,CAAC,EAAE,CAAC,GAAG,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QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAChZ,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/I,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,KAAK,EAAE,qBAAmC,CAAC;AAC/B,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,eAAe,KAAK,CAAC"}
@@ -12,6 +12,7 @@
12
12
  b_scrollTop?: number;
13
13
  rowHeight: number;
14
14
  overscan?: number;
15
+ rowClass?: ClassValue;
15
16
  };
16
17
 
17
18
  let {
@@ -21,9 +22,14 @@
21
22
  header,
22
23
  b_scrollTop = $bindable(),
23
24
  rowHeight,
24
- overscan = 2
25
+ overscan = 2,
26
+ rowClass
25
27
  }: Props<T> = $props();
26
28
 
29
+ const finalRowClass = $derived(
30
+ twMerge(clsx(['flex w-full shrink-0 grow flex-row items-center overflow-hidden', rowClass]))
31
+ );
32
+
27
33
  let scroll_top = $state(b_scrollTop ?? 0);
28
34
  let scroll_left = $state(0);
29
35
  let header_width = $state(0);
@@ -85,10 +91,7 @@
85
91
  style="padding-top: {top}px; padding-bottom: {bottom}px; min-width: max(100%, {header_width}px) !important;"
86
92
  >
87
93
  {#each visible as row, i (row.data.id)}
88
- <virtual-list-row
89
- class="flex w-full shrink-0 grow flex-row items-center overflow-hidden"
90
- style="height: {rowHeight}px !important;"
91
- >
94
+ <virtual-list-row class={finalRowClass} style="height: {rowHeight}px !important;">
92
95
  {@render children({
93
96
  row: row.data,
94
97
  domIndex: i,
@@ -12,13 +12,23 @@ type Props<T> = {
12
12
  b_scrollTop?: number;
13
13
  rowHeight: number;
14
14
  overscan?: number;
15
+ rowClass?: ClassValue;
16
+ };
17
+ declare function $$render<T extends {
18
+ id: string;
19
+ }>(): {
20
+ props: Props<T>;
21
+ exports: {};
22
+ bindings: "b_scrollTop";
23
+ slots: {};
24
+ events: {};
15
25
  };
16
26
  declare class __sveltets_Render<T extends {
17
27
  id: string;
18
28
  }> {
19
- props(): Props<T>;
20
- events(): {};
21
- slots(): {};
29
+ props(): ReturnType<typeof $$render<T>>['props'];
30
+ events(): ReturnType<typeof $$render<T>>['events'];
31
+ slots(): ReturnType<typeof $$render<T>>['slots'];
22
32
  bindings(): "b_scrollTop";
23
33
  exports(): {};
24
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualList.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/VirtualList.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI9C,KAAK,KAAK,CAAC,CAAC,IAAI;IACZ,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAA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E,MAAM,CAAA;CAAE,IAAI,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,eAAe,WAAW,CAAC"}
@@ -1,11 +1,12 @@
1
+ import type { SvelteSet } from 'svelte/reactivity';
1
2
  export type TableRow<T> = {
2
3
  id: string;
3
4
  children?: T[];
4
5
  };
5
- export type TablePlugin<T extends TableRow<T>> = (state: TableState<T>) => TableState<T>;
6
+ export type TablePlugin<T extends TableRow<T>> = (state: TableState<T>) => void;
6
7
  export interface TableState<T extends TableRow<T>> {
7
8
  data: T[];
8
- expanded: Set<string>;
9
+ expanded: SvelteSet<string>;
9
10
  }
10
11
  interface TreeRow<T> {
11
12
  node: T;
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/controller.ts"],"names":[],"mappings":"AAAA,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,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;AAED,0HAA0H;AAC1H,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;;;;EAmDtE;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,CAMxE"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,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,IAAI,CAAC;AAEhF,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,UAAU,OAAO,CAAC,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACd;AAED,0HAA0H;AAC1H,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;;;;EAmDtE;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,CAMxE"}
@@ -1,7 +1,6 @@
1
1
  export { default as Column, type ColumnProps } from './Column.svelte';
2
2
  export { ColumnController, type ColumnConfig } from './columnController.svelte';
3
3
  export { getColumnHeadContext } from './ColumnHead.svelte';
4
- export { getAllIds, type TablePlugin, type TableRow, type TableState } from './controller';
5
- export { searchPlugin } from './plugins/search.svelte';
4
+ export { getAllIds, type TableRow, type TableState } from './controller';
6
5
  export { getTableContext, default as Table, type TableContext, type TableProps } from './Table.svelte';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,eAAe,EACf,OAAO,IAAI,KAAK,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EAClB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACH,eAAe,EACf,OAAO,IAAI,KAAK,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EAClB,MAAM,gBAAgB,CAAC"}
@@ -2,5 +2,4 @@ export { default as Column } from './Column.svelte';
2
2
  export { ColumnController } from './columnController.svelte';
3
3
  export { getColumnHeadContext } from './ColumnHead.svelte';
4
4
  export { getAllIds } from './controller';
5
- export { searchPlugin } from './plugins/search.svelte';
6
5
  export { getTableContext, default as Table } from './Table.svelte';
@@ -0,0 +1,8 @@
1
+ import { SvelteSet } from 'svelte/reactivity';
2
+ import type { TableRow } from '.';
3
+ /** collapses everything that doesnt match the searchString, expands direct search hit */
4
+ export declare const searchData: <T extends TableRow<T>>(nodes: T[], searchString: string, stringsMatch: (a: T, b: string) => boolean) => {
5
+ hidden: SvelteSet<string>;
6
+ expanded: SvelteSet<string>;
7
+ };
8
+ //# sourceMappingURL=search.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/search.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAElC,yFAAyF;AACzF,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,EACV,cAAc,MAAM,EACpB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO;;;CA0B7C,CAAC"}