@immich/ui 0.60.2 → 0.60.3
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/common/context.svelte.d.ts +8 -1
- package/dist/common/context.svelte.js +28 -0
- package/dist/components/AppShell/AppShell.svelte +8 -10
- package/dist/components/AppShell/AppShellBar.svelte +3 -10
- package/dist/components/AppShell/AppShellBar.svelte.d.ts +2 -6
- package/dist/components/AppShell/AppShellHeader.svelte +19 -5
- package/dist/components/AppShell/AppShellHeader.svelte.d.ts +3 -3
- package/dist/components/Avatar/Avatar.svelte +14 -16
- package/dist/components/Avatar/Avatar.svelte.d.ts +1 -0
- package/dist/components/Card/Card.svelte +11 -11
- package/dist/components/Card/CardBody.svelte +3 -10
- package/dist/components/Card/CardBody.svelte.d.ts +2 -6
- package/dist/components/Card/CardFooter.svelte +3 -10
- package/dist/components/Card/CardFooter.svelte.d.ts +2 -6
- package/dist/components/Card/CardHeader.svelte +3 -10
- package/dist/components/Card/CardHeader.svelte.d.ts +2 -6
- package/dist/components/ControlBar/ControlBar.svelte +12 -10
- package/dist/components/ControlBar/ControlBarContent.svelte +3 -10
- package/dist/components/ControlBar/ControlBarContent.svelte.d.ts +2 -6
- package/dist/components/ControlBar/ControlBarHeader.svelte +3 -10
- package/dist/components/ControlBar/ControlBarHeader.svelte.d.ts +2 -6
- package/dist/components/ControlBar/ControlBarOverflow.svelte +3 -10
- package/dist/components/ControlBar/ControlBarOverflow.svelte.d.ts +2 -6
- package/dist/components/Field/Field.svelte +4 -9
- package/dist/components/HelperText/HelperText.svelte +3 -10
- package/dist/components/HelperText/HelperText.svelte.d.ts +2 -5
- package/dist/components/Modal/Modal.svelte +10 -10
- package/dist/components/Modal/ModalBody.svelte +3 -9
- package/dist/components/Modal/ModalBody.svelte.d.ts +2 -5
- package/dist/components/Modal/ModalFooter.svelte +3 -9
- package/dist/components/Modal/ModalFooter.svelte.d.ts +2 -5
- package/dist/components/Modal/ModalHeader.svelte +3 -9
- package/dist/components/Modal/ModalHeader.svelte.d.ts +2 -5
- package/dist/components/Table/Table.svelte +11 -11
- package/dist/components/Table/TableBody.svelte +3 -10
- package/dist/components/Table/TableBody.svelte.d.ts +2 -6
- package/dist/components/Table/TableFooter.svelte +3 -10
- package/dist/components/Table/TableFooter.svelte.d.ts +2 -6
- package/dist/components/Table/TableHeader.svelte +3 -10
- package/dist/components/Table/TableHeader.svelte.d.ts +2 -6
- package/dist/components/Text/Text.svelte +2 -2
- package/dist/components/Text/Text.svelte.d.ts +1 -1
- package/dist/internal/Child.svelte +9 -20
- package/dist/internal/Child.svelte.d.ts +2 -5
- package/dist/types.d.ts +3 -5
- package/package.json +1 -1
- package/dist/common/use-child.svelte.d.ts +0 -5
- package/dist/common/use-child.svelte.js +0 -15
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChildKey } from '../constants.js';
|
|
2
|
+
import type { ChildData, FieldContext, TableContext } from '../types.js';
|
|
2
3
|
export declare const setFieldContext: (context: () => FieldContext) => () => FieldContext;
|
|
3
4
|
export declare const getFieldContext: () => () => {
|
|
4
5
|
class?: (string & (import("svelte/elements").ClassValue | null)) | undefined;
|
|
@@ -455,3 +456,9 @@ export declare const getTableContext: () => () => {
|
|
|
455
456
|
size: import("../types.js").Size;
|
|
456
457
|
striped: boolean;
|
|
457
458
|
};
|
|
459
|
+
export declare const setChildContext: (key: ChildKey) => {
|
|
460
|
+
getByKey: (key: ChildKey) => ChildData | undefined;
|
|
461
|
+
};
|
|
462
|
+
export declare const getChildContext: (key: ChildKey) => () => {
|
|
463
|
+
register: (key: ChildKey, data: () => ChildData) => void;
|
|
464
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withPrefix } from '../utilities/internal.js';
|
|
2
2
|
import { getContext, setContext } from 'svelte';
|
|
3
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
3
4
|
const fieldKey = Symbol(withPrefix('field'));
|
|
4
5
|
export const setFieldContext = (context) => setContext(fieldKey, context);
|
|
5
6
|
export const getFieldContext = () => {
|
|
@@ -18,3 +19,30 @@ export const getTableContext = () => {
|
|
|
18
19
|
return { spacing, size, striped };
|
|
19
20
|
};
|
|
20
21
|
};
|
|
22
|
+
const asChildKey = (key) => withPrefix(key);
|
|
23
|
+
export const setChildContext = (key) => {
|
|
24
|
+
const map = new SvelteMap();
|
|
25
|
+
const context = {
|
|
26
|
+
register: (child, data) => {
|
|
27
|
+
map.set(child, data);
|
|
28
|
+
return () => {
|
|
29
|
+
map.delete(child);
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
setContext(asChildKey(key), () => context);
|
|
34
|
+
return {
|
|
35
|
+
getByKey: (key) => map.get(key)?.(),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const noop = () => { };
|
|
39
|
+
export const getChildContext = (key) => {
|
|
40
|
+
return () => {
|
|
41
|
+
const context = getContext(asChildKey(key));
|
|
42
|
+
if (!context) {
|
|
43
|
+
console.log(`Unable to find child context for key: ${key}`);
|
|
44
|
+
}
|
|
45
|
+
const { register } = context?.() ?? { register: () => noop };
|
|
46
|
+
return { register };
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { setChildContext } from '../../common/context.svelte.js';
|
|
3
3
|
import Scrollable from '../Scrollable/Scrollable.svelte';
|
|
4
4
|
import { ChildKey, zIndex } from '../../constants.js';
|
|
5
5
|
import { cleanClass } from '../../utilities/internal.js';
|
|
@@ -12,25 +12,23 @@
|
|
|
12
12
|
|
|
13
13
|
const { class: className, children }: Props = $props();
|
|
14
14
|
|
|
15
|
-
const {
|
|
16
|
-
const bar = $derived(
|
|
17
|
-
const header = $derived(
|
|
18
|
-
const sidebar = $derived(
|
|
15
|
+
const { getByKey } = setChildContext(ChildKey.AppShell);
|
|
16
|
+
const bar = $derived(getByKey(ChildKey.AppShellBar));
|
|
17
|
+
const header = $derived(getByKey(ChildKey.AppShellHeader));
|
|
18
|
+
const sidebar = $derived(getByKey(ChildKey.AppShellSidebar));
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<div class={cleanClass('flex h-dvh flex-col overflow-hidden', className)}>
|
|
22
22
|
{#if bar}
|
|
23
23
|
<div class={cleanClass('h-control-bar-container px-2 pt-2', zIndex.AppShellBar, bar.class)}>
|
|
24
|
-
{@render bar.
|
|
24
|
+
{@render bar.children?.()}
|
|
25
25
|
</div>
|
|
26
26
|
{:else if header}
|
|
27
|
-
|
|
28
|
-
{@render header.snippet()}
|
|
29
|
-
</header>
|
|
27
|
+
{@render header.children?.()}
|
|
30
28
|
{/if}
|
|
31
29
|
<div class="relative flex w-full grow overflow-y-auto">
|
|
32
30
|
{#if sidebar}
|
|
33
|
-
{@render sidebar.
|
|
31
|
+
{@render sidebar.children?.()}
|
|
34
32
|
{/if}
|
|
35
33
|
<Scrollable class="grow" resetOnNavigate>
|
|
36
34
|
{@render children?.()}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
children: Snippet;
|
|
8
|
-
class?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { children, class: className }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.AppShell} as={ChildKey.AppShellBar}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.AppShell} as={ChildKey.AppShellBar} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
children: Snippet;
|
|
4
|
-
class?: string;
|
|
5
|
-
};
|
|
6
|
-
declare const AppShellBar: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const AppShellBar: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type AppShellBar = ReturnType<typeof AppShellBar>;
|
|
8
4
|
export default AppShellBar;
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
|
+
import { cleanClass } from '../../utilities/internal.js';
|
|
6
|
+
import { tv } from 'tailwind-variants';
|
|
5
7
|
|
|
6
8
|
type Props = {
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
+
border?: boolean;
|
|
10
|
+
} & ChildData;
|
|
9
11
|
|
|
10
|
-
let { children }: Props = $props();
|
|
12
|
+
let { border = true, class: className, children }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const styles = tv({
|
|
15
|
+
base: 'h-control-bar-container flex items-center gap-2',
|
|
16
|
+
variants: {
|
|
17
|
+
border: {
|
|
18
|
+
true: 'border-b',
|
|
19
|
+
false: '',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
11
23
|
</script>
|
|
12
24
|
|
|
13
25
|
<Child for={ChildKey.AppShell} as={ChildKey.AppShellHeader}>
|
|
14
|
-
{
|
|
26
|
+
<header class={cleanClass(styles({ border }), className)}>
|
|
27
|
+
{@render children?.()}
|
|
28
|
+
</header>
|
|
15
29
|
</Child>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
2
|
type Props = {
|
|
3
|
-
|
|
4
|
-
};
|
|
3
|
+
border?: boolean;
|
|
4
|
+
} & ChildData;
|
|
5
5
|
declare const AppShellHeader: import("svelte").Component<Props, {}, "">;
|
|
6
6
|
type AppShellHeader = ReturnType<typeof AppShellHeader>;
|
|
7
7
|
export default AppShellHeader;
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Size } from '../../types.js';
|
|
3
|
+
import { cleanClass } from '../../utilities/internal.js';
|
|
3
4
|
import { tv } from 'tailwind-variants';
|
|
4
5
|
|
|
5
6
|
type Props = {
|
|
6
7
|
size?: Size;
|
|
7
8
|
color?: 'primary' | 'pink' | 'red' | 'yellow' | 'blue' | 'green' | 'purple' | 'orange' | 'gray' | 'amber';
|
|
8
9
|
name: string;
|
|
10
|
+
class?: string;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
const { color = 'primary', size = 'medium', name }: Props = $props();
|
|
13
|
+
const { color = 'primary', size = 'medium', name, class: className }: Props = $props();
|
|
12
14
|
|
|
13
15
|
const styles = tv({
|
|
14
|
-
base: 'flex items-center
|
|
16
|
+
base: 'flex items-center overflow-hidden rounded-full align-middle text-white shadow-md',
|
|
15
17
|
variants: {
|
|
16
|
-
size: {
|
|
17
|
-
tiny: 'h-5 w-5 text-xs',
|
|
18
|
-
small: 'h-7 w-7 text-sm',
|
|
19
|
-
medium: 'h-10 w-10 text-base',
|
|
20
|
-
large: 'h-12 w-12 text-lg',
|
|
21
|
-
giant: 'h-16 w-16 text-xl',
|
|
22
|
-
},
|
|
23
18
|
color: {
|
|
24
19
|
primary: 'bg-primary text-light',
|
|
25
20
|
pink: 'bg-pink-400',
|
|
@@ -32,25 +27,28 @@
|
|
|
32
27
|
blue: 'bg-blue-500',
|
|
33
28
|
green: 'bg-green-600',
|
|
34
29
|
},
|
|
30
|
+
size: {
|
|
31
|
+
tiny: 'h-5 w-5 text-xs',
|
|
32
|
+
small: 'h-7 w-7 text-sm',
|
|
33
|
+
medium: 'h-10 w-10 text-base',
|
|
34
|
+
large: 'h-12 w-12 text-lg',
|
|
35
|
+
giant: 'h-16 w-16 text-xl',
|
|
36
|
+
},
|
|
35
37
|
},
|
|
36
38
|
});
|
|
37
39
|
|
|
38
|
-
const wrapper = tv({
|
|
39
|
-
base: 'block w-full overflow-hidden rounded-full shadow-md',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
40
|
const getInitials = (name: string) => {
|
|
43
41
|
return name
|
|
44
42
|
.split(' ')
|
|
45
43
|
.map((part) => part.at(0))
|
|
46
44
|
.join('')
|
|
47
|
-
.
|
|
45
|
+
.substring(0, 2)
|
|
48
46
|
.toUpperCase();
|
|
49
47
|
};
|
|
50
48
|
|
|
51
49
|
const initials = $derived(getInitials(name));
|
|
52
50
|
</script>
|
|
53
51
|
|
|
54
|
-
<figure class={
|
|
55
|
-
<span class=
|
|
52
|
+
<figure class={cleanClass(styles({ size, color }), className)}>
|
|
53
|
+
<span class="w-full text-center font-medium select-none">{initials}</span>
|
|
56
54
|
</figure>
|
|
@@ -3,6 +3,7 @@ type Props = {
|
|
|
3
3
|
size?: Size;
|
|
4
4
|
color?: 'primary' | 'pink' | 'red' | 'yellow' | 'blue' | 'green' | 'purple' | 'orange' | 'gray' | 'amber';
|
|
5
5
|
name: string;
|
|
6
|
+
class?: string;
|
|
6
7
|
};
|
|
7
8
|
declare const Avatar: import("svelte").Component<Props, {}, "">;
|
|
8
9
|
type Avatar = ReturnType<typeof Avatar>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { setChildContext } from '../../common/context.svelte.js';
|
|
3
3
|
import IconButton from '../IconButton/IconButton.svelte';
|
|
4
4
|
import { ChildKey } from '../../constants.js';
|
|
5
5
|
import type { Color } from '../../types.js';
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
expanded = !expanded;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const {
|
|
81
|
-
const headerChild = $derived(
|
|
82
|
-
const bodyChild = $derived(
|
|
83
|
-
const footerChild = $derived(
|
|
80
|
+
const { getByKey } = setChildContext(ChildKey.Card);
|
|
81
|
+
const headerChild = $derived(getByKey(ChildKey.CardHeader));
|
|
82
|
+
const bodyChild = $derived(getByKey(ChildKey.CardBody));
|
|
83
|
+
const footerChild = $derived(getByKey(ChildKey.CardFooter));
|
|
84
84
|
|
|
85
85
|
const headerBorder = $derived(!color);
|
|
86
86
|
const headerPadding = $derived(headerBorder || !expanded);
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
onclick={onToggle}
|
|
104
104
|
class={cleanClass('flex w-full items-center justify-between px-4', headerContainerClasses)}
|
|
105
105
|
>
|
|
106
|
-
<div class=
|
|
107
|
-
{@render headerChild?.
|
|
106
|
+
<div class={cleanClass('flex flex-col', headerChild?.class)}>
|
|
107
|
+
{@render headerChild?.children?.()}
|
|
108
108
|
</div>
|
|
109
109
|
<div>
|
|
110
110
|
<IconButton
|
|
@@ -119,8 +119,8 @@
|
|
|
119
119
|
</div>
|
|
120
120
|
</button>
|
|
121
121
|
{:else}
|
|
122
|
-
<div class={cleanClass('flex flex-col', headerContainerClasses)}>
|
|
123
|
-
{@render headerChild?.
|
|
122
|
+
<div class={cleanClass('flex flex-col', headerContainerClasses, headerChild?.class)}>
|
|
123
|
+
{@render headerChild?.children?.()}
|
|
124
124
|
</div>
|
|
125
125
|
{/if}
|
|
126
126
|
{/snippet}
|
|
@@ -136,13 +136,13 @@
|
|
|
136
136
|
transition:slide={{ duration: expandable ? 200 : 0, easing: cubicOut }}
|
|
137
137
|
class={cleanClass('immich-scrollbar h-full w-full overflow-auto p-4', bodyChild?.class)}
|
|
138
138
|
>
|
|
139
|
-
{@render bodyChild?.
|
|
139
|
+
{@render bodyChild?.children?.()}
|
|
140
140
|
</div>
|
|
141
141
|
{/if}
|
|
142
142
|
|
|
143
143
|
{#if footerChild}
|
|
144
144
|
<div class={cleanClass('flex items-center border-t p-4', footerChild.class)}>
|
|
145
|
-
{@render footerChild.
|
|
145
|
+
{@render footerChild.children?.()}
|
|
146
146
|
</div>
|
|
147
147
|
{/if}
|
|
148
148
|
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Card} as={ChildKey.CardBody}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Card} as={ChildKey.CardBody} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const CardBody: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const CardBody: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type CardBody = ReturnType<typeof CardBody>;
|
|
8
4
|
export default CardBody;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Card} as={ChildKey.CardFooter}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Card} as={ChildKey.CardFooter} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const CardFooter: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const CardFooter: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type CardFooter = ReturnType<typeof CardFooter>;
|
|
8
4
|
export default CardFooter;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Card} as={ChildKey.CardHeader}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Card} as={ChildKey.CardHeader} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const CardHeader: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const CardHeader: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type CardHeader = ReturnType<typeof CardHeader>;
|
|
8
4
|
export default CardHeader;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { shortcuts } from '../../actions/shortcut.js';
|
|
3
|
-
import {
|
|
3
|
+
import { setChildContext } from '../../common/context.svelte.js';
|
|
4
4
|
import IconButton from '../IconButton/IconButton.svelte';
|
|
5
5
|
import { ChildKey } from '../../constants.js';
|
|
6
6
|
import { t } from '../../services/translation.svelte.js';
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const {
|
|
49
|
-
const headerChild = $derived(
|
|
50
|
-
const contentChild = $derived(
|
|
51
|
-
const overflowChild = $derived(
|
|
48
|
+
const { getByKey } = setChildContext(ChildKey.ControlBar);
|
|
49
|
+
const headerChild = $derived(getByKey(ChildKey.ControlBarHeader));
|
|
50
|
+
const contentChild = $derived(getByKey(ChildKey.ControlBarContent));
|
|
51
|
+
const overflowChild = $derived(getByKey(ChildKey.ControlBarOverflow));
|
|
52
52
|
</script>
|
|
53
53
|
|
|
54
54
|
<svelte:window use:shortcuts={[{ shortcut: { key: 'Escape' }, onShortcut: onEscape }]} />
|
|
@@ -73,18 +73,20 @@
|
|
|
73
73
|
/>
|
|
74
74
|
{/if}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
|
|
76
|
+
{#if headerChild}
|
|
77
|
+
<div class={cleanClass('flex shrink-0 flex-col', headerChild.class)}>
|
|
78
|
+
{@render headerChild.children?.()}
|
|
79
|
+
</div>
|
|
80
|
+
{/if}
|
|
79
81
|
</div>
|
|
80
82
|
|
|
81
83
|
<div class={cleanClass('flex grow items-center gap-2', contentChild?.class)}>
|
|
82
|
-
{@render contentChild?.
|
|
84
|
+
{@render contentChild?.children?.()}
|
|
83
85
|
</div>
|
|
84
86
|
|
|
85
87
|
{#if overflowChild}
|
|
86
88
|
<div class={cleanClass('flex shrink-0 items-center gap-2', overflowChild.class)}>
|
|
87
|
-
{@render overflowChild.
|
|
89
|
+
{@render overflowChild.children?.()}
|
|
88
90
|
</div>
|
|
89
91
|
{/if}
|
|
90
92
|
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarContent}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarContent} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const ControlBarContent: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ControlBarContent: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type ControlBarContent = ReturnType<typeof ControlBarContent>;
|
|
8
4
|
export default ControlBarContent;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarHeader}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarHeader} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const ControlBarHeader: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ControlBarHeader: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type ControlBarHeader = ReturnType<typeof ControlBarHeader>;
|
|
8
4
|
export default ControlBarHeader;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarOverflow}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.ControlBar} as={ChildKey.ControlBarOverflow} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const ControlBarOverflow: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ControlBarOverflow: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type ControlBarOverflow = ReturnType<typeof ControlBarOverflow>;
|
|
8
4
|
export default ControlBarOverflow;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { setFieldContext } from '../../common/context.svelte.js';
|
|
3
|
-
import { withChildrenSnippets } from '../../common/use-child.svelte.js';
|
|
2
|
+
import { setChildContext, setFieldContext } from '../../common/context.svelte.js';
|
|
4
3
|
import { ChildKey } from '../../constants.js';
|
|
5
4
|
import type { FieldContext } from '../../types.js';
|
|
6
5
|
import { cleanClass } from '../../utilities/internal.js';
|
|
@@ -17,15 +16,11 @@
|
|
|
17
16
|
|
|
18
17
|
setFieldContext(() => state);
|
|
19
18
|
|
|
20
|
-
const {
|
|
21
|
-
const
|
|
19
|
+
const { getByKey } = setChildContext(ChildKey.Field);
|
|
20
|
+
const helperTextChild = $derived(getByKey(ChildKey.HelperText));
|
|
22
21
|
</script>
|
|
23
22
|
|
|
24
23
|
<div class={cleanClass('w-full', className)}>
|
|
25
24
|
{@render children()}
|
|
26
|
-
{
|
|
27
|
-
<div class={cleanClass('pt-1', helperTextChildren.class)}>
|
|
28
|
-
{@render helperTextChildren.snippet()}
|
|
29
|
-
</div>
|
|
30
|
-
{/if}
|
|
25
|
+
{@render helperTextChild?.children?.()}
|
|
31
26
|
</div>
|
|
@@ -2,23 +2,16 @@
|
|
|
2
2
|
import Text from '../Text/Text.svelte';
|
|
3
3
|
import { ChildKey } from '../../constants.js';
|
|
4
4
|
import Child from '../../internal/Child.svelte';
|
|
5
|
-
import type { TextColor } from '../../types.js';
|
|
5
|
+
import type { ChildData, TextColor } from '../../types.js';
|
|
6
6
|
import { cleanClass } from '../../utilities/internal.js';
|
|
7
|
-
import type { Snippet } from 'svelte';
|
|
8
7
|
|
|
9
8
|
type Props = {
|
|
10
9
|
color?: TextColor;
|
|
11
|
-
|
|
12
|
-
children?: Snippet;
|
|
13
|
-
};
|
|
10
|
+
} & ChildData;
|
|
14
11
|
|
|
15
12
|
let { class: className, children, color = 'muted' }: Props = $props();
|
|
16
13
|
</script>
|
|
17
14
|
|
|
18
15
|
<Child for={ChildKey.Field} as={ChildKey.HelperText}>
|
|
19
|
-
<
|
|
20
|
-
<Text {color} size="small">
|
|
21
|
-
{@render children?.()}
|
|
22
|
-
</Text>
|
|
23
|
-
</div>
|
|
16
|
+
<Text {color} size="small" {children} class={cleanClass('pt-1', className)} />
|
|
24
17
|
</Child>
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { TextColor } from '../../types.js';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
1
|
+
import type { ChildData, TextColor } from '../../types.js';
|
|
3
2
|
type Props = {
|
|
4
3
|
color?: TextColor;
|
|
5
|
-
|
|
6
|
-
children?: Snippet;
|
|
7
|
-
};
|
|
4
|
+
} & ChildData;
|
|
8
5
|
declare const HelperText: import("svelte").Component<Props, {}, "">;
|
|
9
6
|
type HelperText = ReturnType<typeof HelperText>;
|
|
10
7
|
export default HelperText;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { setChildContext } from '../../common/context.svelte.js';
|
|
3
3
|
import Card from '../Card/Card.svelte';
|
|
4
4
|
import CardBody from '../Card/CardBody.svelte';
|
|
5
5
|
import CardFooter from '../Card/CardFooter.svelte';
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
},
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
const {
|
|
74
|
-
const headerChildren = $derived(
|
|
75
|
-
const bodyChildren = $derived(
|
|
76
|
-
const footerChildren = $derived(
|
|
73
|
+
const { getByKey } = setChildContext(ChildKey.Modal);
|
|
74
|
+
const headerChildren = $derived(getByKey(ChildKey.ModalHeader));
|
|
75
|
+
const bodyChildren = $derived(getByKey(ChildKey.ModalBody));
|
|
76
|
+
const footerChildren = $derived(getByKey(ChildKey.ModalFooter));
|
|
77
77
|
|
|
78
78
|
let cardRef = $state<HTMLElement | null>(null);
|
|
79
79
|
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
<Card bind:ref={cardRef} class={cleanClass(modalStyles({ size }), className)}>
|
|
111
111
|
<CardHeader class="border-b border-gray-200 px-5 py-3 dark:border-white/10">
|
|
112
112
|
{#if headerChildren}
|
|
113
|
-
{@render headerChildren.
|
|
113
|
+
{@render headerChildren.children?.()}
|
|
114
114
|
{:else if title}
|
|
115
115
|
<div class="flex items-center justify-between gap-2">
|
|
116
116
|
{#if typeof icon === 'string'}
|
|
@@ -124,13 +124,13 @@
|
|
|
124
124
|
{/if}
|
|
125
125
|
</CardHeader>
|
|
126
126
|
|
|
127
|
-
<CardBody class=
|
|
128
|
-
{@render bodyChildren?.
|
|
127
|
+
<CardBody class={cleanClass('grow px-5', bodyChildren?.class)}>
|
|
128
|
+
{@render bodyChildren?.children?.()}
|
|
129
129
|
</CardBody>
|
|
130
130
|
|
|
131
131
|
{#if footerChildren}
|
|
132
|
-
<CardFooter class=
|
|
133
|
-
{@render footerChildren.
|
|
132
|
+
<CardFooter class={cleanClass('border-t border-gray-200 dark:border-white/10', footerChildren.class)}>
|
|
133
|
+
{@render footerChildren.children?.()}
|
|
134
134
|
</CardFooter>
|
|
135
135
|
{/if}
|
|
136
136
|
</Card>
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
children: Snippet;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
11
7
|
</script>
|
|
12
8
|
|
|
13
|
-
<Child for={ChildKey.Modal} as={ChildKey.ModalBody}
|
|
14
|
-
{@render children?.()}
|
|
15
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Modal} as={ChildKey.ModalBody} {...props} />
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
children: Snippet;
|
|
4
|
-
};
|
|
5
|
-
declare const ModalBody: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ModalBody: import("svelte").Component<ChildData, {}, "">;
|
|
6
3
|
type ModalBody = ReturnType<typeof ModalBody>;
|
|
7
4
|
export default ModalBody;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
children: Snippet;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
11
7
|
</script>
|
|
12
8
|
|
|
13
|
-
<Child for={ChildKey.Modal} as={ChildKey.ModalFooter}
|
|
14
|
-
{@render children?.()}
|
|
15
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Modal} as={ChildKey.ModalFooter} {...props} />
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
children: Snippet;
|
|
4
|
-
};
|
|
5
|
-
declare const ModalFooter: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ModalFooter: import("svelte").Component<ChildData, {}, "">;
|
|
6
3
|
type ModalFooter = ReturnType<typeof ModalFooter>;
|
|
7
4
|
export default ModalFooter;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
children: Snippet;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
11
7
|
</script>
|
|
12
8
|
|
|
13
|
-
<Child for={ChildKey.Modal} as={ChildKey.ModalHeader}
|
|
14
|
-
{@render children?.()}
|
|
15
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Modal} as={ChildKey.ModalHeader} {...props} />
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
children: Snippet;
|
|
4
|
-
};
|
|
5
|
-
declare const ModalHeader: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const ModalHeader: import("svelte").Component<ChildData, {}, "">;
|
|
6
3
|
type ModalHeader = ReturnType<typeof ModalHeader>;
|
|
7
4
|
export default ModalHeader;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { setTableContext } from '../../common/context.svelte.js';
|
|
3
|
-
import { withChildrenSnippets } from '../../common/use-child.svelte.js';
|
|
2
|
+
import { setChildContext, setTableContext } from '../../common/context.svelte.js';
|
|
4
3
|
import { ChildKey } from '../../constants.js';
|
|
5
4
|
import { styleVariants } from '../../styles.js';
|
|
6
5
|
import type { TableContext } from '../../types.js';
|
|
@@ -32,10 +31,10 @@
|
|
|
32
31
|
|
|
33
32
|
setTableContext(() => ({ spacing, striped, size }));
|
|
34
33
|
|
|
35
|
-
const {
|
|
36
|
-
const headerChild = $derived(
|
|
37
|
-
const bodyChild = $derived(
|
|
38
|
-
const footerChild = $derived(
|
|
34
|
+
const { getByKey } = setChildContext(ChildKey.Table);
|
|
35
|
+
const headerChild = $derived(getByKey(ChildKey.TableHeader));
|
|
36
|
+
const bodyChild = $derived(getByKey(ChildKey.TableBody));
|
|
37
|
+
const footerChild = $derived(getByKey(ChildKey.TableFooter));
|
|
39
38
|
|
|
40
39
|
const headerRowStyles = tv({
|
|
41
40
|
base: 'bg-dark-900 flex w-full place-items-center',
|
|
@@ -66,15 +65,15 @@
|
|
|
66
65
|
<table bind:this={ref} class={cleanClass('w-full text-center', className)} {...restProps}>
|
|
67
66
|
{#if headerChild}
|
|
68
67
|
<thead class={cleanClass('text-primary mb-4 flex w-full overflow-hidden', commonStyles({ shape, border }))}>
|
|
69
|
-
<tr class={headerRowStyles({ spacing })}>
|
|
70
|
-
{@render headerChild?.
|
|
68
|
+
<tr class={cleanClass(headerRowStyles({ spacing }), headerChild.class)}>
|
|
69
|
+
{@render headerChild?.children?.()}
|
|
71
70
|
</tr>
|
|
72
71
|
</thead>
|
|
73
72
|
{/if}
|
|
74
73
|
|
|
75
74
|
{#if bodyChild}
|
|
76
|
-
<tbody class={cleanClass('block w-full overflow-y-auto',
|
|
77
|
-
{@render bodyChild?.
|
|
75
|
+
<tbody class={cleanClass('block w-full overflow-y-auto', commonStyles({ shape, border }), bodyChild.class)}>
|
|
76
|
+
{@render bodyChild?.children?.()}
|
|
78
77
|
</tbody>
|
|
79
78
|
{/if}
|
|
80
79
|
|
|
@@ -86,8 +85,9 @@
|
|
|
86
85
|
class={cleanClass(
|
|
87
86
|
'text-primary bg-subtle mt-4 flex h-12 w-full place-items-center p-4',
|
|
88
87
|
commonStyles({ shape, border }),
|
|
88
|
+
footerChild.class,
|
|
89
89
|
)}
|
|
90
90
|
>
|
|
91
|
-
{@render footerChild?.
|
|
91
|
+
{@render footerChild?.children?.()}
|
|
92
92
|
</div>
|
|
93
93
|
{/if}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Table} as={ChildKey.TableBody}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Table} as={ChildKey.TableBody} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const TableBody: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const TableBody: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type TableBody = ReturnType<typeof TableBody>;
|
|
8
4
|
export default TableBody;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Table} as={ChildKey.TableFooter}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Table} as={ChildKey.TableFooter} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const TableFooter: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const TableFooter: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type TableFooter = ReturnType<typeof TableFooter>;
|
|
8
4
|
export default TableFooter;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { ChildKey } from '../../constants.js';
|
|
3
3
|
import Child from '../../internal/Child.svelte';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChildData } from '../../types.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
class?: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let { class: className, children }: Props = $props();
|
|
6
|
+
let props: ChildData = $props();
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
|
-
<Child for={ChildKey.Table} as={ChildKey.TableHeader}
|
|
15
|
-
{@render children?.()}
|
|
16
|
-
</Child>
|
|
9
|
+
<Child for={ChildKey.Table} as={ChildKey.TableHeader} {...props} />
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
class?: string;
|
|
4
|
-
children: Snippet;
|
|
5
|
-
};
|
|
6
|
-
declare const TableHeader: import("svelte").Component<Props, {}, "">;
|
|
1
|
+
import type { ChildData } from '../../types.js';
|
|
2
|
+
declare const TableHeader: import("svelte").Component<ChildData, {}, "">;
|
|
7
3
|
type TableHeader = ReturnType<typeof TableHeader>;
|
|
8
4
|
export default TableHeader;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
variant?: TextVariant;
|
|
15
15
|
inline?: boolean;
|
|
16
16
|
class?: string;
|
|
17
|
-
children
|
|
17
|
+
children?: Snippet;
|
|
18
18
|
} & HTMLAttributes<HTMLElement>;
|
|
19
19
|
|
|
20
20
|
const { color, inline, size, fontWeight = 'normal', children, class: className, ...restProps }: Props = $props();
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
29
|
<Text tag={inline ? 'span' : 'p'} {color} {fontWeight} class={cleanClass(styles({ size }), className)} {...restProps}>
|
|
30
|
-
{@render children()}
|
|
30
|
+
{@render children?.()}
|
|
31
31
|
</Text>
|
|
@@ -9,7 +9,7 @@ type Props = {
|
|
|
9
9
|
variant?: TextVariant;
|
|
10
10
|
inline?: boolean;
|
|
11
11
|
class?: string;
|
|
12
|
-
children
|
|
12
|
+
children?: Snippet;
|
|
13
13
|
} & HTMLAttributes<HTMLElement>;
|
|
14
14
|
declare const Text: import("svelte").Component<Props, {}, "">;
|
|
15
15
|
type Text = ReturnType<typeof Text>;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { getChildContext } from '../common/context.svelte.js';
|
|
2
3
|
import { ChildKey } from '../constants.js';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import { getContext, onDestroy, type Snippet } from 'svelte';
|
|
4
|
+
import type { ChildData } from '../types.js';
|
|
5
|
+
import { onMount } from 'svelte';
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
8
|
for: ChildKey;
|
|
9
9
|
as: ChildKey;
|
|
10
|
-
|
|
11
|
-
children: Snippet;
|
|
12
|
-
props?: unknown;
|
|
13
|
-
};
|
|
10
|
+
} & ChildData;
|
|
14
11
|
|
|
15
|
-
const { for: key, as,
|
|
12
|
+
const { for: key, as, ...rest }: Props = $props();
|
|
16
13
|
|
|
17
|
-
const context =
|
|
14
|
+
const context = getChildContext(key);
|
|
15
|
+
const { register } = $derived(context());
|
|
16
|
+
const data = $derived(rest);
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (context) {
|
|
22
|
-
context.register(as, () => data);
|
|
23
|
-
} else {
|
|
24
|
-
console.log('Unable to find context for key:', key);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
onDestroy(() => {
|
|
28
|
-
context?.unregister(as);
|
|
29
|
-
});
|
|
18
|
+
onMount(() => register(as, () => data));
|
|
30
19
|
</script>
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ChildKey } from '../constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { ChildData } from '../types.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
for: ChildKey;
|
|
5
5
|
as: ChildKey;
|
|
6
|
-
|
|
7
|
-
children: Snippet;
|
|
8
|
-
props?: unknown;
|
|
9
|
-
};
|
|
6
|
+
} & ChildData;
|
|
10
7
|
declare const Child: import("svelte").Component<Props, {}, "">;
|
|
11
8
|
type Child = ReturnType<typeof Child>;
|
|
12
9
|
export default Child;
|
package/dist/types.d.ts
CHANGED
|
@@ -104,10 +104,9 @@ type StackBaseProps = {
|
|
|
104
104
|
fullWidth?: boolean;
|
|
105
105
|
fullHeight?: boolean;
|
|
106
106
|
};
|
|
107
|
-
export type ChildData
|
|
108
|
-
|
|
107
|
+
export type ChildData = {
|
|
108
|
+
children?: Snippet;
|
|
109
109
|
class?: string;
|
|
110
|
-
props?: T;
|
|
111
110
|
};
|
|
112
111
|
export type StackProps = StackBaseProps & {
|
|
113
112
|
align?: 'start' | 'center' | 'end';
|
|
@@ -320,8 +319,7 @@ export type ActionBarProps = ControlBarProps & {
|
|
|
320
319
|
actions?: ActionItem[];
|
|
321
320
|
overflowActions?: ActionItem[];
|
|
322
321
|
};
|
|
323
|
-
export type
|
|
322
|
+
export type ChildContext = {
|
|
324
323
|
register: (key: ChildKey, data: () => ChildData) => void;
|
|
325
|
-
unregister: (key: ChildKey) => void;
|
|
326
324
|
};
|
|
327
325
|
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ChildKey } from '../constants.js';
|
|
2
|
-
import {} from '../types.js';
|
|
3
|
-
import { withPrefix } from '../utilities/internal.js';
|
|
4
|
-
import { setContext } from 'svelte';
|
|
5
|
-
import { SvelteMap } from 'svelte/reactivity';
|
|
6
|
-
export const withChildrenSnippets = (key) => {
|
|
7
|
-
const map = new SvelteMap();
|
|
8
|
-
setContext(withPrefix(key), {
|
|
9
|
-
register: (child, data) => map.set(child, data),
|
|
10
|
-
unregister: (child) => map.delete(child),
|
|
11
|
-
});
|
|
12
|
-
return {
|
|
13
|
-
getChildren: (key) => map.get(key)?.(),
|
|
14
|
-
};
|
|
15
|
-
};
|