@ims360/svelte-ivory 0.0.41 → 0.0.44
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/ai/Chat.svelte +1 -1
- package/dist/components/ai/Chat.svelte.d.ts +3 -1
- package/dist/components/ai/Chat.svelte.d.ts.map +1 -1
- package/dist/components/layout/drawer/Drawer.svelte +13 -7
- package/dist/components/layout/drawer/Drawer.svelte.d.ts +4 -4
- package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
- package/dist/components/layout/modal/Modal.svelte +12 -5
- package/dist/components/layout/modal/Modal.svelte.d.ts +6 -5
- package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
- package/dist/components/table/Table.svelte +4 -6
- package/dist/components/table/Table.svelte.d.ts.map +1 -1
- package/dist/components/table/controller.svelte.d.ts +4 -3
- package/dist/components/table/controller.svelte.d.ts.map +1 -1
- package/dist/components/table/controller.svelte.js +14 -1
- package/dist/components/table/plugins/search.svelte.d.ts +3 -2
- package/dist/components/table/plugins/search.svelte.d.ts.map +1 -1
- package/dist/components/table/plugins/search.svelte.js +5 -4
- package/package.json +1 -1
- package/src/lib/components/ai/Chat.svelte +1 -1
- package/src/lib/components/layout/drawer/Drawer.svelte +13 -7
- package/src/lib/components/layout/modal/Modal.svelte +12 -5
- package/src/lib/components/table/Table.svelte +4 -6
- package/src/lib/components/table/controller.svelte.ts +18 -3
- package/src/lib/components/table/plugins/search.svelte.ts +5 -4
|
@@ -35,7 +35,9 @@ interface Props {
|
|
|
35
35
|
* Comes with default styles for the chat messages, but can be customized with the `userMessage` and `systemMessage` props.
|
|
36
36
|
* The input component has to be provided as a child component, and the `submit` function has to be provided as a callback.
|
|
37
37
|
*/
|
|
38
|
-
declare const Chat: import("svelte").Component<Props, {
|
|
38
|
+
declare const Chat: import("svelte").Component<Props, {
|
|
39
|
+
scrollToBottom: () => Promise<void>;
|
|
40
|
+
}, "b_chat">;
|
|
39
41
|
type Chat = ReturnType<typeof Chat>;
|
|
40
42
|
export default Chat;
|
|
41
43
|
//# sourceMappingURL=Chat.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E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C,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI;;YAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransitionProps } from '../../../types';
|
|
3
3
|
import { X } from '@lucide/svelte';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
export type DrawerPlacement = 'left' | 'right';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type DrawerProps = TransitionProps & {
|
|
15
15
|
class?: string;
|
|
16
16
|
b_open: boolean;
|
|
17
|
-
title?: string;
|
|
17
|
+
title?: string | Snippet;
|
|
18
18
|
children: Snippet;
|
|
19
19
|
placement?: DrawerPlacement;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<script lang="ts">
|
|
@@ -54,13 +54,19 @@
|
|
|
54
54
|
])
|
|
55
55
|
)}
|
|
56
56
|
onclick={(e) => e.stopPropagation()}
|
|
57
|
-
in:inTransition
|
|
58
|
-
out:outTransition
|
|
57
|
+
in:inTransition|global
|
|
58
|
+
out:outTransition|global
|
|
59
59
|
{...rest}
|
|
60
60
|
>
|
|
61
61
|
<div class="flex flex-row items-center justify-between gap-8">
|
|
62
62
|
{#if title}
|
|
63
|
-
<Heading>
|
|
63
|
+
<Heading class="flex grow flex-row items-center gap-4">
|
|
64
|
+
{#if typeof title === 'function'}
|
|
65
|
+
{@render title()}
|
|
66
|
+
{:else}
|
|
67
|
+
{title}
|
|
68
|
+
{/if}
|
|
69
|
+
</Heading>
|
|
64
70
|
{/if}
|
|
65
71
|
<button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
|
|
66
72
|
<X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TransitionProps } from '../../../types';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export type DrawerPlacement = 'left' | 'right';
|
|
4
|
-
export
|
|
4
|
+
export type DrawerProps = TransitionProps & {
|
|
5
5
|
class?: string;
|
|
6
6
|
b_open: boolean;
|
|
7
|
-
title?: string;
|
|
7
|
+
title?: string | Snippet;
|
|
8
8
|
children: Snippet;
|
|
9
9
|
placement?: DrawerPlacement;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
declare const Drawer: import("svelte").Component<DrawerProps, {}, "b_open">;
|
|
12
12
|
type Drawer = ReturnType<typeof Drawer>;
|
|
13
13
|
export default Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/drawer/Drawer.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/drawer/Drawer.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAOtC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AA0DN,QAAA,MAAM,MAAM,uDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransitionProps } from '../../../types';
|
|
3
3
|
import { X } from '@lucide/svelte';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { type Snippet } from 'svelte';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Heading, HiddenBackground, Portal } from '..';
|
|
10
10
|
|
|
11
11
|
/** Props for the modal, expose if you overwrite the defaults in a custom component */
|
|
12
|
-
export
|
|
12
|
+
export type ModalProps = TransitionProps & {
|
|
13
13
|
/** Class of the modal itself, does not apply to the inner div */
|
|
14
14
|
class?: ClassValue;
|
|
15
15
|
/** Class of the div wrapping the children */
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
preventClosing?: boolean;
|
|
23
23
|
/** Variant of the modal, applies styling to the header */
|
|
24
24
|
variant?: ModalVariant;
|
|
25
|
-
title?: string;
|
|
26
|
-
|
|
25
|
+
title?: string | Snippet;
|
|
26
|
+
onclick?: MouseEventHandler<HTMLDivElement>;
|
|
27
|
+
};
|
|
27
28
|
|
|
28
29
|
export type ModalVariant = 'success' | 'warning' | 'error' | 'info';
|
|
29
30
|
</script>
|
|
@@ -104,7 +105,13 @@
|
|
|
104
105
|
]}
|
|
105
106
|
>
|
|
106
107
|
{#if title}
|
|
107
|
-
<Heading>
|
|
108
|
+
<Heading class="flex grow flex-row items-center gap-4">
|
|
109
|
+
{#if typeof title === 'function'}
|
|
110
|
+
{@render title()}
|
|
111
|
+
{:else}
|
|
112
|
+
{title}
|
|
113
|
+
{/if}
|
|
114
|
+
</Heading>
|
|
108
115
|
{/if}
|
|
109
116
|
<button
|
|
110
117
|
class="group ml-auto flex justify-end"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TransitionProps } from '../../../types';
|
|
2
2
|
import { type Snippet } from 'svelte';
|
|
3
|
-
import type { ClassValue } from 'svelte/elements';
|
|
3
|
+
import type { ClassValue, MouseEventHandler } from 'svelte/elements';
|
|
4
4
|
/** Props for the modal, expose if you overwrite the defaults in a custom component */
|
|
5
|
-
export
|
|
5
|
+
export type ModalProps = TransitionProps & {
|
|
6
6
|
/** Class of the modal itself, does not apply to the inner div */
|
|
7
7
|
class?: ClassValue;
|
|
8
8
|
/** Class of the div wrapping the children */
|
|
@@ -15,8 +15,9 @@ export interface ModalProps extends IvoryComponent<HTMLDivElement>, TransitionPr
|
|
|
15
15
|
preventClosing?: boolean;
|
|
16
16
|
/** Variant of the modal, applies styling to the header */
|
|
17
17
|
variant?: ModalVariant;
|
|
18
|
-
title?: string;
|
|
19
|
-
|
|
18
|
+
title?: string | Snippet;
|
|
19
|
+
onclick?: MouseEventHandler<HTMLDivElement>;
|
|
20
|
+
};
|
|
20
21
|
export type ModalVariant = 'success' | 'warning' | 'error' | 'info';
|
|
21
22
|
interface Props extends ModalProps {
|
|
22
23
|
/** If you don't want the title and close button to be included you can overwrite the default modal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/modal/Modal.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Modal.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/modal/Modal.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKrE,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACvC,iEAAiE;IACjE,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,wCAAwC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qEAAqE;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpE,UAAU,KAAM,SAAQ,UAAU;IAC9B,sGAAsG;IACtG,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AA0FL,oFAAoF;AACpF,QAAA,MAAM,KAAK,iDAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import ColumnHead from './ColumnHead.svelte';
|
|
10
10
|
import Row from './Row.svelte';
|
|
11
11
|
import VirtualList from './VirtualList.svelte';
|
|
12
|
-
import { createTableConfig
|
|
12
|
+
import { createTableConfig } from './controller.svelte';
|
|
13
13
|
|
|
14
14
|
export interface TableProps<T extends TableRow<T>> {
|
|
15
15
|
class?: ClassValue;
|
|
@@ -79,13 +79,11 @@
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
const results = $derived(treeWalker(table));
|
|
83
|
-
|
|
84
82
|
const treeIndicatorId = pseudoRandomId('tree-indicator-');
|
|
85
83
|
</script>
|
|
86
84
|
|
|
87
85
|
<VirtualList
|
|
88
|
-
data={results.entries}
|
|
86
|
+
data={table.results.entries}
|
|
89
87
|
class={twMerge(clsx(['flex flex-col overflow-hidden border-transparent', clazz]))}
|
|
90
88
|
bind:b_scrollTop={table.scrollTop}
|
|
91
89
|
{rowHeight}
|
|
@@ -128,8 +126,8 @@
|
|
|
128
126
|
onclick={() => {
|
|
129
127
|
table.toggleExpansion(node.id);
|
|
130
128
|
}}
|
|
131
|
-
ignoreWidth={results.someHaveChildren}
|
|
132
|
-
width={results.someHaveChildren ? 24 : 0}
|
|
129
|
+
ignoreWidth={table.results.someHaveChildren}
|
|
130
|
+
width={table.results.someHaveChildren ? 24 : 0}
|
|
133
131
|
minWidth={0}
|
|
134
132
|
>
|
|
135
133
|
<div
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/table/Table.svelte.ts"],"names":[],"mappings":"AAMI,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,GAAG,CAAC;AAM9E,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,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MA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 +12,9 @@ export interface TableConfig<T extends TableRow<T>> {
|
|
|
12
12
|
expanded: SvelteSet<string>;
|
|
13
13
|
columns: Column[];
|
|
14
14
|
scrollTop: number;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
readonly results: ReturnType<typeof treeWalker<T>>;
|
|
16
|
+
readonly registerColumn: (config: ColumnConfig) => Column;
|
|
17
|
+
readonly toggleExpansion: (id: string) => void;
|
|
17
18
|
}
|
|
18
19
|
export declare function createTableConfig<T extends TableRow<T>>(): TableConfig<T>;
|
|
19
20
|
export interface TableState<T extends TableRow<T>> {
|
|
@@ -26,7 +27,7 @@ interface TreeRow<T> {
|
|
|
26
27
|
id: string;
|
|
27
28
|
}
|
|
28
29
|
/** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
|
|
29
|
-
|
|
30
|
+
declare function treeWalker<T extends TableRow<T>>(config: TableState<T>): {
|
|
30
31
|
entries: TreeRow<T>[];
|
|
31
32
|
someHaveChildren: boolean;
|
|
32
33
|
maxNestingLevel: number;
|
|
@@ -1 +1 @@
|
|
|
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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,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"}
|
|
@@ -6,6 +6,16 @@ export function createTableConfig() {
|
|
|
6
6
|
let scrollTop = $state(0);
|
|
7
7
|
const expanded = new SvelteSet();
|
|
8
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
|
+
});
|
|
9
19
|
return {
|
|
10
20
|
get data() {
|
|
11
21
|
return data;
|
|
@@ -31,6 +41,9 @@ export function createTableConfig() {
|
|
|
31
41
|
get columns() {
|
|
32
42
|
return columns;
|
|
33
43
|
},
|
|
44
|
+
get results() {
|
|
45
|
+
return results;
|
|
46
|
+
},
|
|
34
47
|
registerColumn(config) {
|
|
35
48
|
let existingColumn = undefined;
|
|
36
49
|
for (const column of columns) {
|
|
@@ -94,7 +107,7 @@ export function createTableConfig() {
|
|
|
94
107
|
// }
|
|
95
108
|
// }
|
|
96
109
|
/** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
|
|
97
|
-
|
|
110
|
+
function treeWalker(config) {
|
|
98
111
|
const { data, expanded } = config;
|
|
99
112
|
const stack = [];
|
|
100
113
|
// push the root nodes of the trees onto the stack
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
1
2
|
import type { TablePlugin, TableRow } from '../';
|
|
2
3
|
interface SearchConfig<T extends TableRow<T>> {
|
|
3
4
|
search: string;
|
|
@@ -6,8 +7,8 @@ interface SearchConfig<T extends TableRow<T>> {
|
|
|
6
7
|
export declare function searchPlugin<T extends TableRow<T>>(conf: SearchConfig<T>): TablePlugin<T>;
|
|
7
8
|
/** collapses everything that doesnt match the searchString, expands direct search hit */
|
|
8
9
|
export declare const search: <T extends TableRow<T>>(nodes: T[], searchString: string, stringsMatch: (a: T, b: string) => boolean) => {
|
|
9
|
-
hidden:
|
|
10
|
-
expanded:
|
|
10
|
+
hidden: SvelteSet<string>;
|
|
11
|
+
expanded: SvelteSet<string>;
|
|
11
12
|
};
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=search.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/table/plugins/search.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/table/plugins/search.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEjD,UAAU,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAChC;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA8BzF;AAED,yFAAyF;AACzF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EACxC,OAAO,CAAC,EAAE,EACV,cAAc,MAAM,EACpB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO;;;CA8B7C,CAAC"}
|
|
@@ -19,6 +19,7 @@ export function searchPlugin(conf) {
|
|
|
19
19
|
// figure out which nodes to expand and hide
|
|
20
20
|
const { expanded, hidden } = search(state.data, conf.search, conf.matches);
|
|
21
21
|
prevSearch = conf.search;
|
|
22
|
+
console.log(hidden);
|
|
22
23
|
return {
|
|
23
24
|
data: state.data.filter((d) => !hidden.has(d.id)),
|
|
24
25
|
expanded: new SvelteSet(expanded)
|
|
@@ -29,20 +30,20 @@ export function searchPlugin(conf) {
|
|
|
29
30
|
/** collapses everything that doesnt match the searchString, expands direct search hit */
|
|
30
31
|
export const search = (nodes, searchString, stringsMatch) => {
|
|
31
32
|
const search = searchString.trim().toLowerCase();
|
|
32
|
-
const hidden = new
|
|
33
|
-
const expanded = new
|
|
33
|
+
const hidden = new SvelteSet();
|
|
34
|
+
const expanded = new SvelteSet();
|
|
34
35
|
function nodeMatches(node, childOfMatch = false) {
|
|
35
36
|
const matches = stringsMatch(node, search);
|
|
36
37
|
let intermediate = false;
|
|
37
38
|
for (const child of node.children || []) {
|
|
38
39
|
const childMatches = nodeMatches(child, matches || childOfMatch);
|
|
39
|
-
if (childMatches
|
|
40
|
+
if (childMatches)
|
|
40
41
|
intermediate = true;
|
|
41
42
|
}
|
|
42
43
|
if (intermediate) {
|
|
43
44
|
expanded.add(node.id);
|
|
44
45
|
}
|
|
45
|
-
else if (!childOfMatch) {
|
|
46
|
+
else if (!childOfMatch && !matches) {
|
|
46
47
|
hidden.add(node.id);
|
|
47
48
|
}
|
|
48
49
|
return matches || intermediate;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransitionProps } from '$lib/types';
|
|
3
3
|
import { X } from '@lucide/svelte';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
export type DrawerPlacement = 'left' | 'right';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export type DrawerProps = TransitionProps & {
|
|
15
15
|
class?: string;
|
|
16
16
|
b_open: boolean;
|
|
17
|
-
title?: string;
|
|
17
|
+
title?: string | Snippet;
|
|
18
18
|
children: Snippet;
|
|
19
19
|
placement?: DrawerPlacement;
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
23
|
<script lang="ts">
|
|
@@ -54,13 +54,19 @@
|
|
|
54
54
|
])
|
|
55
55
|
)}
|
|
56
56
|
onclick={(e) => e.stopPropagation()}
|
|
57
|
-
in:inTransition
|
|
58
|
-
out:outTransition
|
|
57
|
+
in:inTransition|global
|
|
58
|
+
out:outTransition|global
|
|
59
59
|
{...rest}
|
|
60
60
|
>
|
|
61
61
|
<div class="flex flex-row items-center justify-between gap-8">
|
|
62
62
|
{#if title}
|
|
63
|
-
<Heading>
|
|
63
|
+
<Heading class="flex grow flex-row items-center gap-4">
|
|
64
|
+
{#if typeof title === 'function'}
|
|
65
|
+
{@render title()}
|
|
66
|
+
{:else}
|
|
67
|
+
{title}
|
|
68
|
+
{/if}
|
|
69
|
+
</Heading>
|
|
64
70
|
{/if}
|
|
65
71
|
<button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
|
|
66
72
|
<X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransitionProps } from '$lib/types';
|
|
3
3
|
import { X } from '@lucide/svelte';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { type Snippet } from 'svelte';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Heading, HiddenBackground, Portal } from '..';
|
|
10
10
|
|
|
11
11
|
/** Props for the modal, expose if you overwrite the defaults in a custom component */
|
|
12
|
-
export
|
|
12
|
+
export type ModalProps = TransitionProps & {
|
|
13
13
|
/** Class of the modal itself, does not apply to the inner div */
|
|
14
14
|
class?: ClassValue;
|
|
15
15
|
/** Class of the div wrapping the children */
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
preventClosing?: boolean;
|
|
23
23
|
/** Variant of the modal, applies styling to the header */
|
|
24
24
|
variant?: ModalVariant;
|
|
25
|
-
title?: string;
|
|
26
|
-
|
|
25
|
+
title?: string | Snippet;
|
|
26
|
+
onclick?: MouseEventHandler<HTMLDivElement>;
|
|
27
|
+
};
|
|
27
28
|
|
|
28
29
|
export type ModalVariant = 'success' | 'warning' | 'error' | 'info';
|
|
29
30
|
</script>
|
|
@@ -104,7 +105,13 @@
|
|
|
104
105
|
]}
|
|
105
106
|
>
|
|
106
107
|
{#if title}
|
|
107
|
-
<Heading>
|
|
108
|
+
<Heading class="flex grow flex-row items-center gap-4">
|
|
109
|
+
{#if typeof title === 'function'}
|
|
110
|
+
{@render title()}
|
|
111
|
+
{:else}
|
|
112
|
+
{title}
|
|
113
|
+
{/if}
|
|
114
|
+
</Heading>
|
|
108
115
|
{/if}
|
|
109
116
|
<button
|
|
110
117
|
class="group ml-auto flex justify-end"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import ColumnHead from './ColumnHead.svelte';
|
|
10
10
|
import Row from './Row.svelte';
|
|
11
11
|
import VirtualList from './VirtualList.svelte';
|
|
12
|
-
import { createTableConfig
|
|
12
|
+
import { createTableConfig } from './controller.svelte';
|
|
13
13
|
|
|
14
14
|
export interface TableProps<T extends TableRow<T>> {
|
|
15
15
|
class?: ClassValue;
|
|
@@ -79,13 +79,11 @@
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
const results = $derived(treeWalker(table));
|
|
83
|
-
|
|
84
82
|
const treeIndicatorId = pseudoRandomId('tree-indicator-');
|
|
85
83
|
</script>
|
|
86
84
|
|
|
87
85
|
<VirtualList
|
|
88
|
-
data={results.entries}
|
|
86
|
+
data={table.results.entries}
|
|
89
87
|
class={twMerge(clsx(['flex flex-col overflow-hidden border-transparent', clazz]))}
|
|
90
88
|
bind:b_scrollTop={table.scrollTop}
|
|
91
89
|
{rowHeight}
|
|
@@ -128,8 +126,8 @@
|
|
|
128
126
|
onclick={() => {
|
|
129
127
|
table.toggleExpansion(node.id);
|
|
130
128
|
}}
|
|
131
|
-
ignoreWidth={results.someHaveChildren}
|
|
132
|
-
width={results.someHaveChildren ? 24 : 0}
|
|
129
|
+
ignoreWidth={table.results.someHaveChildren}
|
|
130
|
+
width={table.results.someHaveChildren ? 24 : 0}
|
|
133
131
|
minWidth={0}
|
|
134
132
|
>
|
|
135
133
|
<div
|
|
@@ -11,8 +11,9 @@ export interface TableConfig<T extends TableRow<T>> {
|
|
|
11
11
|
expanded: SvelteSet<string>;
|
|
12
12
|
columns: Column[];
|
|
13
13
|
scrollTop: number;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
readonly results: ReturnType<typeof treeWalker<T>>;
|
|
15
|
+
readonly registerColumn: (config: ColumnConfig) => Column;
|
|
16
|
+
readonly toggleExpansion: (id: string) => void;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function createTableConfig<T extends TableRow<T>>(): TableConfig<T> {
|
|
@@ -22,6 +23,17 @@ export function createTableConfig<T extends TableRow<T>>(): TableConfig<T> {
|
|
|
22
23
|
const expanded = new SvelteSet<string>();
|
|
23
24
|
const columns = $state<Column[]>([]);
|
|
24
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
|
+
|
|
25
37
|
return {
|
|
26
38
|
get data() {
|
|
27
39
|
return data;
|
|
@@ -47,6 +59,9 @@ export function createTableConfig<T extends TableRow<T>>(): TableConfig<T> {
|
|
|
47
59
|
get columns() {
|
|
48
60
|
return columns;
|
|
49
61
|
},
|
|
62
|
+
get results() {
|
|
63
|
+
return results;
|
|
64
|
+
},
|
|
50
65
|
registerColumn(config: ColumnConfig) {
|
|
51
66
|
let existingColumn: Column | undefined = undefined;
|
|
52
67
|
for (const column of columns) {
|
|
@@ -126,7 +141,7 @@ interface TreeRow<T> {
|
|
|
126
141
|
// }
|
|
127
142
|
|
|
128
143
|
/** Walks though a tree strucure and turns it into a flat list, needed since the `VirtualList` needs a list, not a tree */
|
|
129
|
-
|
|
144
|
+
function treeWalker<T extends TableRow<T>>(config: TableState<T>) {
|
|
130
145
|
const { data, expanded } = config;
|
|
131
146
|
const stack: { node: T; nestingLevel: number }[] = [];
|
|
132
147
|
|
|
@@ -28,6 +28,7 @@ export function searchPlugin<T extends TableRow<T>>(conf: SearchConfig<T>): Tabl
|
|
|
28
28
|
// figure out which nodes to expand and hide
|
|
29
29
|
const { expanded, hidden } = search(state.data, conf.search, conf.matches);
|
|
30
30
|
prevSearch = conf.search;
|
|
31
|
+
console.log(hidden);
|
|
31
32
|
|
|
32
33
|
return {
|
|
33
34
|
data: state.data.filter((d) => !hidden.has(d.id)),
|
|
@@ -44,8 +45,8 @@ export const search = <T extends TableRow<T>>(
|
|
|
44
45
|
stringsMatch: (a: T, b: string) => boolean
|
|
45
46
|
) => {
|
|
46
47
|
const search = searchString.trim().toLowerCase();
|
|
47
|
-
const hidden = new
|
|
48
|
-
const expanded = new
|
|
48
|
+
const hidden = new SvelteSet<string>();
|
|
49
|
+
const expanded = new SvelteSet<string>();
|
|
49
50
|
|
|
50
51
|
function nodeMatches(node: T, childOfMatch = false): boolean {
|
|
51
52
|
const matches = stringsMatch(node, search);
|
|
@@ -53,12 +54,12 @@ export const search = <T extends TableRow<T>>(
|
|
|
53
54
|
let intermediate = false;
|
|
54
55
|
for (const child of node.children || []) {
|
|
55
56
|
const childMatches = nodeMatches(child, matches || childOfMatch);
|
|
56
|
-
if (childMatches
|
|
57
|
+
if (childMatches) intermediate = true;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
if (intermediate) {
|
|
60
61
|
expanded.add(node.id);
|
|
61
|
-
} else if (!childOfMatch) {
|
|
62
|
+
} else if (!childOfMatch && !matches) {
|
|
62
63
|
hidden.add(node.id);
|
|
63
64
|
}
|
|
64
65
|
|