@ims360/svelte-ivory 0.0.22 → 0.0.24
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/basic/checkbox/Checkbox.svelte +20 -18
- package/dist/components/basic/checkbox/Checkbox.svelte.d.ts +5 -4
- package/dist/components/basic/checkbox/Checkbox.svelte.d.ts.map +1 -1
- package/dist/components/basic/index.d.ts +2 -0
- package/dist/components/basic/index.d.ts.map +1 -1
- package/dist/components/basic/index.js +2 -0
- package/dist/components/basic/toggle/Toggle.svelte +8 -8
- package/dist/components/basic/toggle/Toggle.svelte.d.ts +4 -5
- package/dist/components/basic/toggle/Toggle.svelte.d.ts.map +1 -1
- package/dist/components/buttons/CopyToClipboardButton.svelte +6 -5
- package/dist/components/buttons/CopyToClipboardButton.svelte.d.ts +3 -2
- package/dist/components/buttons/CopyToClipboardButton.svelte.d.ts.map +1 -1
- package/dist/components/layout/drawer/Drawer.svelte +13 -8
- package/dist/components/layout/drawer/Drawer.svelte.d.ts +4 -3
- package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
- package/dist/components/layout/heading/Heading.svelte +8 -6
- package/dist/components/layout/heading/Heading.svelte.d.ts +3 -4
- package/dist/components/layout/heading/Heading.svelte.d.ts.map +1 -1
- package/dist/components/layout/heading/index.d.ts +1 -1
- package/dist/components/layout/hiddenBackground/HiddenBackground.svelte +13 -7
- package/dist/components/layout/hiddenBackground/HiddenBackground.svelte.d.ts +4 -5
- package/dist/components/layout/hiddenBackground/HiddenBackground.svelte.d.ts.map +1 -1
- package/dist/components/layout/hiddenBackground/index.d.ts +1 -1
- package/dist/components/layout/index.d.ts +11 -6
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +9 -4
- package/dist/components/layout/modal/Modal.svelte +13 -17
- package/dist/components/layout/modal/Modal.svelte.d.ts +2 -4
- package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
- package/dist/components/layout/modal/ModalTest.svelte +3 -10
- package/dist/components/layout/modal/ModalTest.svelte.d.ts +4 -6
- package/dist/components/layout/modal/ModalTest.svelte.d.ts.map +1 -1
- package/dist/components/layout/popover/Popover.svelte +10 -12
- package/dist/components/layout/popover/Popover.svelte.d.ts +4 -8
- package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
- package/dist/components/layout/portal/Portal.svelte +10 -9
- package/dist/components/layout/portal/Portal.svelte.d.ts +7 -6
- package/dist/components/layout/portal/Portal.svelte.d.ts.map +1 -1
- package/dist/components/layout/tabs/Tab.svelte +7 -7
- package/dist/components/layout/tabs/Tab.svelte.d.ts +4 -4
- package/dist/components/layout/tabs/Tab.svelte.d.ts.map +1 -1
- package/dist/components/layout/tabs/TabPanel.svelte +6 -4
- package/dist/components/layout/tabs/TabPanel.svelte.d.ts +3 -3
- package/dist/components/layout/tabs/TabPanel.svelte.d.ts.map +1 -1
- package/dist/components/layout/tabs/Tabs.svelte +13 -16
- package/dist/components/layout/tabs/Tabs.svelte.d.ts +6 -9
- package/dist/components/layout/tabs/Tabs.svelte.d.ts.map +1 -1
- package/dist/components/layout/tabs/index.d.ts +6 -21
- package/dist/components/layout/tabs/index.d.ts.map +1 -1
- package/dist/components/layout/tabs/index.js +3 -0
- package/dist/components/layout/tooltip/Tooltip.svelte +0 -1
- package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
- package/dist/components/toast/Toast.svelte +22 -15
- package/dist/components/toast/Toast.svelte.d.ts +6 -5
- package/dist/components/toast/Toast.svelte.d.ts.map +1 -1
- package/dist/components/toast/index.d.ts +2 -2
- package/dist/components/toast/index.d.ts.map +1 -1
- package/dist/components/toast/toasts.svelte.d.ts +4 -4
- package/dist/components/toast/toasts.svelte.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/basic/checkbox/Checkbox.svelte +20 -18
- package/src/lib/components/basic/index.ts +2 -0
- package/src/lib/components/basic/toggle/Toggle.svelte +8 -8
- package/src/lib/components/buttons/CopyToClipboardButton.svelte +6 -5
- package/src/lib/components/layout/drawer/Drawer.svelte +13 -8
- package/src/lib/components/layout/heading/Heading.svelte +8 -6
- package/src/lib/components/layout/hiddenBackground/HiddenBackground.svelte +13 -7
- package/src/lib/components/layout/index.ts +17 -6
- package/src/lib/components/layout/modal/Modal.svelte +13 -17
- package/src/lib/components/layout/modal/ModalTest.svelte +3 -10
- package/src/lib/components/layout/popover/Popover.svelte +10 -12
- package/src/lib/components/layout/portal/Portal.svelte +10 -9
- package/src/lib/components/layout/tabs/Tab.svelte +7 -7
- package/src/lib/components/layout/tabs/TabPanel.svelte +6 -4
- package/src/lib/components/layout/tabs/Tabs.svelte +13 -16
- package/src/lib/components/layout/tabs/index.ts +3 -0
- package/src/lib/components/layout/tooltip/Tooltip.svelte +0 -1
- package/src/lib/components/toast/Toast.svelte +22 -15
- package/src/lib/components/toast/index.ts +2 -2
- package/src/lib/components/toast/toasts.svelte.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toasts.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/toast/toasts.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,
|
|
1
|
+
{"version":3,"file":"toasts.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/toast/toasts.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;CACrD;AAED,UAAU,KAAM,SAAQ,aAAa;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CAC7C;AASD,cAAM,UAAU;IACZ,MAAM,UAAuB;IAE7B,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,GAA0B,MAAM;IAWhE,KAAK,CAAC,EAAE,EAAE,MAAM;IAOhB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IAiBvC,MAAM,CAAC,EAAE,EAAE,MAAM;IAMjB,QAAQ,CAAC,EAAE,EAAE,MAAM;IAMnB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;CAKvB;AAED,2EAA2E;AAC3E,eAAO,MAAM,MAAM,YAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
It's a checkbox
|
|
4
|
-
-->
|
|
5
|
-
|
|
6
|
-
<script lang="ts">
|
|
7
|
-
import { type Icon as LucideIcon, Minus, icons } from '@lucide/svelte';
|
|
8
|
-
import clsx from 'clsx';
|
|
9
|
-
import type { ClassValue } from 'svelte/elements';
|
|
10
|
-
import { twMerge } from 'tailwind-merge';
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
11
3
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
4
|
+
export interface CheckboxProps extends IvoryComponent<HTMLElement> {
|
|
15
5
|
class?: ClassValue;
|
|
16
6
|
/** `checked` has prioriy over `partial` */
|
|
17
7
|
checked?: boolean | null;
|
|
@@ -23,7 +13,19 @@
|
|
|
23
13
|
onclick?: () => void;
|
|
24
14
|
/** data-testid */
|
|
25
15
|
testId?: string;
|
|
26
|
-
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<!--
|
|
20
|
+
@component
|
|
21
|
+
It's a checkbox
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { Check, type Icon as LucideIcon, Minus } from '@lucide/svelte';
|
|
26
|
+
import clsx from 'clsx';
|
|
27
|
+
import type { ClassValue } from 'svelte/elements';
|
|
28
|
+
import { twMerge } from 'tailwind-merge';
|
|
27
29
|
|
|
28
30
|
let {
|
|
29
31
|
class: clazz,
|
|
@@ -32,8 +34,8 @@
|
|
|
32
34
|
id,
|
|
33
35
|
disabled = false,
|
|
34
36
|
onclick,
|
|
35
|
-
|
|
36
|
-
}:
|
|
37
|
+
...rest
|
|
38
|
+
}: CheckboxProps = $props();
|
|
37
39
|
|
|
38
40
|
const {
|
|
39
41
|
icon: Icon,
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
{id}
|
|
63
65
|
{disabled}
|
|
64
66
|
{style}
|
|
67
|
+
{onclick}
|
|
65
68
|
class={twMerge(
|
|
66
69
|
clsx(
|
|
67
70
|
'box-border flex h-5 w-5 items-center justify-center overflow-hidden rounded border-2 transition-colors',
|
|
@@ -70,8 +73,7 @@
|
|
|
70
73
|
clazz
|
|
71
74
|
)
|
|
72
75
|
)}
|
|
73
|
-
{
|
|
74
|
-
data-testid={testId}
|
|
76
|
+
{...rest}
|
|
75
77
|
>
|
|
76
78
|
{#if Icon}
|
|
77
79
|
<Icon class="h-full w-full" size={16} strokeWidth={3} />
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
4
|
import type { Snippet } from 'svelte';
|
|
4
5
|
import type { ClassValue } from 'svelte/elements';
|
|
5
6
|
import { twMerge } from 'tailwind-merge';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
export interface ToggleProps extends IvoryComponent<HTMLElement> {
|
|
8
9
|
value?: boolean;
|
|
9
10
|
class?: ClassValue;
|
|
10
|
-
onclick?: () => void;
|
|
11
11
|
children?: Snippet;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
let { value, class: clazz, children, ...rest }: ToggleProps = $props();
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
19
|
<svelte:element
|
|
@@ -26,8 +27,7 @@
|
|
|
26
27
|
)}
|
|
27
28
|
type={onclick ? 'button' : undefined}
|
|
28
29
|
role={onclick ? 'button' : undefined}
|
|
29
|
-
{
|
|
30
|
-
data-testid={testId}
|
|
30
|
+
{...rest}
|
|
31
31
|
>
|
|
32
32
|
<div
|
|
33
33
|
class={[
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import { Copy } from '@lucide/svelte';
|
|
3
4
|
import type { ClassValue } from 'svelte/elements';
|
|
4
5
|
import { Toasts } from '../toast';
|
|
5
6
|
|
|
6
7
|
let lastCopied = $state<string>();
|
|
7
|
-
</script>
|
|
8
8
|
|
|
9
|
-
<
|
|
10
|
-
interface Props {
|
|
9
|
+
export interface CopyToClipboardButtonProps extends IvoryComponent<HTMLButtonElement> {
|
|
11
10
|
text: string;
|
|
12
11
|
class?: ClassValue;
|
|
13
12
|
toastMessage?: string;
|
|
14
13
|
}
|
|
14
|
+
</script>
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
let { text, toastMessage, ...rest }: CopyToClipboardButtonProps = $props();
|
|
17
18
|
|
|
18
19
|
async function copyText() {
|
|
19
20
|
await navigator.clipboard.writeText(text);
|
|
@@ -28,6 +29,6 @@
|
|
|
28
29
|
}
|
|
29
30
|
</script>
|
|
30
31
|
|
|
31
|
-
<button type="button" class={['text-surface-500 btn',
|
|
32
|
+
<button type="button" class={['text-surface-500 btn', rest.class]} onclick={copyText} {...rest}>
|
|
32
33
|
<Copy class={['h-5 w-5']} />
|
|
33
34
|
</button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import { X } from '@lucide/svelte';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import type { Snippet } from 'svelte';
|
|
@@ -7,31 +8,34 @@
|
|
|
7
8
|
import Heading from '../heading';
|
|
8
9
|
import HiddenBackground from '../hiddenBackground';
|
|
9
10
|
|
|
10
|
-
type DrawerPlacement = 'left' | 'right';
|
|
11
|
+
export type DrawerPlacement = 'left' | 'right';
|
|
11
12
|
|
|
12
|
-
interface
|
|
13
|
+
export interface DrawerProps extends IvoryComponent<HTMLDivElement> {
|
|
13
14
|
class?: string;
|
|
14
15
|
b_open: boolean;
|
|
15
16
|
title?: string;
|
|
16
17
|
children: Snippet;
|
|
17
18
|
placement?: DrawerPlacement;
|
|
18
19
|
}
|
|
20
|
+
</script>
|
|
19
21
|
|
|
22
|
+
<script lang="ts">
|
|
20
23
|
let {
|
|
21
24
|
class: clazz,
|
|
22
25
|
b_open = $bindable(false),
|
|
23
26
|
children,
|
|
24
27
|
title,
|
|
25
|
-
placement = 'right'
|
|
26
|
-
|
|
28
|
+
placement = 'right',
|
|
29
|
+
...rest
|
|
30
|
+
}: DrawerProps = $props();
|
|
27
31
|
|
|
28
|
-
const
|
|
32
|
+
const onclose = () => {
|
|
29
33
|
b_open = false;
|
|
30
34
|
};
|
|
31
35
|
</script>
|
|
32
36
|
|
|
33
37
|
{#if b_open}
|
|
34
|
-
<HiddenBackground onclose
|
|
38
|
+
<HiddenBackground {onclose}>
|
|
35
39
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
36
40
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
37
41
|
<div
|
|
@@ -45,12 +49,13 @@
|
|
|
45
49
|
)}
|
|
46
50
|
transition:fly={{ x: placement === 'right' ? '100%' : '-100%', duration: 200 }}
|
|
47
51
|
onclick={(e) => e.stopPropagation()}
|
|
52
|
+
{...rest}
|
|
48
53
|
>
|
|
49
54
|
<div class="flex flex-row items-center justify-between gap-8">
|
|
50
55
|
{#if title}
|
|
51
56
|
<Heading>{title}</Heading>
|
|
52
57
|
{/if}
|
|
53
|
-
<button class="group ml-auto flex justify-end" type="button" onclick={
|
|
58
|
+
<button class="group ml-auto flex justify-end" type="button" onclick={onclose}>
|
|
54
59
|
<X class="h-full w-auto transition-[stroke-width] group-hover:stroke-3" />
|
|
55
60
|
</button>
|
|
56
61
|
</div>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { ClassValue } from 'svelte/elements';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
|
|
7
|
-
export interface
|
|
8
|
-
children: Snippet;
|
|
7
|
+
export interface HeadingProps extends IvoryComponent<HTMLHeadingElement> {
|
|
9
8
|
class?: ClassValue;
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
</script>
|
|
18
17
|
|
|
19
18
|
<script lang="ts">
|
|
20
|
-
let { children, class: clazz }:
|
|
19
|
+
let { children, class: clazz, ...rest }: HeadingProps = $props();
|
|
21
20
|
</script>
|
|
22
21
|
|
|
23
22
|
<!--
|
|
@@ -28,6 +27,9 @@
|
|
|
28
27
|
If you set the `defaultClasses`, make sure to call it before using a component that uses the heading component (e.g. your root `+layout.svelte`).
|
|
29
28
|
-->
|
|
30
29
|
|
|
31
|
-
<h2
|
|
32
|
-
{
|
|
30
|
+
<h2
|
|
31
|
+
class={twMerge(clsx('shrink-0 truncate text-lg font-bold select-none', defaultClasses, clazz))}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{@render children?.()}
|
|
33
35
|
</h2>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { ClassValue } from 'svelte/elements';
|
|
5
5
|
import { fade } from 'svelte/transition';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -14,16 +14,21 @@
|
|
|
14
14
|
|
|
15
15
|
export const TEST_ID = 'background';
|
|
16
16
|
|
|
17
|
-
export interface
|
|
18
|
-
class?: ClassValue;
|
|
17
|
+
export interface HiddenBackgroundProps extends IvoryComponent<HTMLDialogElement> {
|
|
19
18
|
/** Gets called when the dialog is clicked */
|
|
20
19
|
onclose?: () => void;
|
|
21
|
-
|
|
20
|
+
duration?: number;
|
|
22
21
|
}
|
|
23
22
|
</script>
|
|
24
23
|
|
|
25
24
|
<script lang="ts">
|
|
26
|
-
let {
|
|
25
|
+
let {
|
|
26
|
+
class: clazz,
|
|
27
|
+
onclose,
|
|
28
|
+
children,
|
|
29
|
+
duration = 300,
|
|
30
|
+
...rest
|
|
31
|
+
}: HiddenBackgroundProps = $props();
|
|
27
32
|
</script>
|
|
28
33
|
|
|
29
34
|
<dialog
|
|
@@ -41,8 +46,9 @@
|
|
|
41
46
|
callback: onclose ?? (() => {})
|
|
42
47
|
}}
|
|
43
48
|
onclick={onclose}
|
|
44
|
-
transition:fade={{ duration
|
|
49
|
+
transition:fade={{ duration }}
|
|
45
50
|
data-testid={TEST_ID}
|
|
51
|
+
{...rest}
|
|
46
52
|
>
|
|
47
|
-
{@render children()}
|
|
53
|
+
{@render children?.()}
|
|
48
54
|
</dialog>
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
export { default as Drawer } from './drawer/Drawer.svelte';
|
|
2
|
-
export { default as Heading } from './heading
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
export { default as Heading } from './heading';
|
|
3
|
+
|
|
4
|
+
export * from './hiddenBackground';
|
|
5
|
+
export { default as HiddenBackground } from './hiddenBackground';
|
|
6
|
+
|
|
7
|
+
export * from './modal/Modal.svelte';
|
|
8
|
+
export { default as Modal } from './modal/Modal.svelte';
|
|
9
|
+
|
|
5
10
|
export { default as Popover } from './popover/Popover.svelte';
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { default as
|
|
11
|
+
|
|
12
|
+
export * from './portal/Portal.svelte';
|
|
13
|
+
export { default as Portal } from './portal/Portal.svelte';
|
|
14
|
+
|
|
15
|
+
export * from './tabs';
|
|
16
|
+
export { default as Tabs } from './tabs';
|
|
17
|
+
|
|
18
|
+
export * from './tooltip/Tooltip.svelte';
|
|
19
|
+
export { default as Tooltip } from './tooltip/Tooltip.svelte';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
2
3
|
import { X } from '@lucide/svelte';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import type { Snippet } from 'svelte';
|
|
5
|
-
import type { ClassValue } from 'svelte/elements';
|
|
6
|
+
import type { ClassValue, MouseEventHandler } from 'svelte/elements';
|
|
6
7
|
import { twMerge } from 'tailwind-merge';
|
|
7
8
|
import { Heading, HiddenBackground, Portal } from '..';
|
|
8
9
|
|
|
9
10
|
/** Props for the modal, expose if you overwrite the defaults in a custom component */
|
|
10
|
-
export interface ModalProps {
|
|
11
|
+
export interface ModalProps extends IvoryComponent<HTMLDivElement> {
|
|
11
12
|
/** Class of the modal itself, does not apply to the inner div */
|
|
12
13
|
class?: ClassValue;
|
|
13
14
|
/** Class of the div wrapping the children */
|
|
@@ -16,8 +17,6 @@
|
|
|
16
17
|
b_open: boolean;
|
|
17
18
|
/** Content of the modal */
|
|
18
19
|
children?: Snippet;
|
|
19
|
-
/** Style applied to the */
|
|
20
|
-
style?: string;
|
|
21
20
|
/** If `true` the modal will not close when clicking outside of it */
|
|
22
21
|
preventClosing?: boolean;
|
|
23
22
|
/** Variant of the modal, applies styling to the header */
|
|
@@ -32,12 +31,10 @@
|
|
|
32
31
|
interface Props extends ModalProps {
|
|
33
32
|
/** If you don't want the title and close button to be included you can overwrite the default modal */
|
|
34
33
|
modal?: Snippet;
|
|
35
|
-
testId?: string;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
let {
|
|
39
|
-
class: clazz = 'flex ',
|
|
40
|
-
style,
|
|
37
|
+
class: clazz = 'flex flex-col',
|
|
41
38
|
title,
|
|
42
39
|
b_open = $bindable(),
|
|
43
40
|
children,
|
|
@@ -45,13 +42,18 @@
|
|
|
45
42
|
preventClosing = false,
|
|
46
43
|
variant,
|
|
47
44
|
innerClass,
|
|
48
|
-
|
|
45
|
+
...rest
|
|
49
46
|
}: Props = $props();
|
|
50
47
|
|
|
51
48
|
function close() {
|
|
52
49
|
if (preventClosing) return;
|
|
53
50
|
b_open = false;
|
|
54
51
|
}
|
|
52
|
+
|
|
53
|
+
const onclick: MouseEventHandler<HTMLDivElement> = (e) => {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
rest.onclick?.(e);
|
|
56
|
+
};
|
|
55
57
|
</script>
|
|
56
58
|
|
|
57
59
|
<!--
|
|
@@ -67,12 +69,7 @@
|
|
|
67
69
|
{#if modal}
|
|
68
70
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
69
71
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
70
|
-
<div
|
|
71
|
-
class={clazz}
|
|
72
|
-
onclick={(e) => e.stopPropagation()}
|
|
73
|
-
data-testid={testId}
|
|
74
|
-
{style}
|
|
75
|
-
>
|
|
72
|
+
<div {...rest} {onclick}>
|
|
76
73
|
{@render modal()}
|
|
77
74
|
</div>
|
|
78
75
|
{:else}
|
|
@@ -85,9 +82,8 @@
|
|
|
85
82
|
clazz
|
|
86
83
|
])
|
|
87
84
|
)}
|
|
88
|
-
{
|
|
89
|
-
onclick
|
|
90
|
-
data-testid={testId}
|
|
85
|
+
{...rest}
|
|
86
|
+
{onclick}
|
|
91
87
|
>
|
|
92
88
|
<div
|
|
93
89
|
class={[
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import Modal from './Modal.svelte';
|
|
2
|
+
import Modal, { type ModalProps } from './Modal.svelte';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
open: boolean;
|
|
7
|
-
testId: string;
|
|
8
|
-
children: Snippet;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let { open, ...props }: Props = $props();
|
|
4
|
+
let { open, ...props }: ModalProps & { open: boolean } = $props();
|
|
12
5
|
|
|
13
6
|
let b_open = $state(open);
|
|
14
7
|
</script>
|
|
15
8
|
|
|
16
|
-
<Modal
|
|
9
|
+
<Modal {...props} bind:b_open />
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { browser } from '$app/environment';
|
|
3
|
+
import type { IvoryComponent } from '$lib/types';
|
|
3
4
|
import {
|
|
4
5
|
autoPlacement,
|
|
5
6
|
autoUpdate,
|
|
@@ -9,21 +10,15 @@
|
|
|
9
10
|
type ComputePositionConfig
|
|
10
11
|
} from '@floating-ui/dom';
|
|
11
12
|
import clsx from 'clsx';
|
|
12
|
-
import type { Snippet } from 'svelte';
|
|
13
|
-
import type { ClassValue } from 'svelte/elements';
|
|
14
13
|
import { twMerge } from 'tailwind-merge';
|
|
15
14
|
import { clickOutside } from '../../../utils/actions/clickOutside';
|
|
16
15
|
|
|
17
16
|
/** Possible placements for the popover */
|
|
18
17
|
export type PopoverPlacement = ComputePositionConfig['placement'];
|
|
19
|
-
</script>
|
|
20
18
|
|
|
21
|
-
<
|
|
22
|
-
type Props = {
|
|
23
|
-
class?: ClassValue;
|
|
19
|
+
export interface PopoverProps extends IvoryComponent<HTMLDivElement> {
|
|
24
20
|
/** Whether the popover is open or not */
|
|
25
21
|
b_open: boolean;
|
|
26
|
-
style?: string;
|
|
27
22
|
/** The element the popover will be positioned relative to */
|
|
28
23
|
target: Element | undefined;
|
|
29
24
|
/**
|
|
@@ -38,15 +33,16 @@
|
|
|
38
33
|
onClickOutside?: (e: MouseEvent) => void;
|
|
39
34
|
/** If set to `true`, the nested component will not be unmounted when the popover is closed */
|
|
40
35
|
keepMounted?: boolean;
|
|
41
|
-
children: Snippet;
|
|
42
36
|
/**
|
|
43
37
|
* Whether to place the popover automatically
|
|
44
38
|
*
|
|
45
39
|
* [Further reading](https://floating-ui.com/docs/autoPlacement)
|
|
46
40
|
*/
|
|
47
41
|
autoplacement?: boolean;
|
|
48
|
-
}
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
49
44
|
|
|
45
|
+
<script lang="ts">
|
|
50
46
|
let {
|
|
51
47
|
class: clazz,
|
|
52
48
|
b_open = $bindable(false),
|
|
@@ -58,8 +54,9 @@
|
|
|
58
54
|
},
|
|
59
55
|
keepMounted = false,
|
|
60
56
|
children,
|
|
61
|
-
autoplacement
|
|
62
|
-
|
|
57
|
+
autoplacement,
|
|
58
|
+
...rest
|
|
59
|
+
}: PopoverProps = $props();
|
|
63
60
|
|
|
64
61
|
let style: string = $state('');
|
|
65
62
|
let popover: HTMLDivElement | undefined = $state();
|
|
@@ -102,7 +99,8 @@
|
|
|
102
99
|
style={style + ' ' + externalStyle}
|
|
103
100
|
bind:this={popover}
|
|
104
101
|
use:clickOutside={{ callback: onClickOutside, target }}
|
|
102
|
+
{...rest}
|
|
105
103
|
>
|
|
106
|
-
{@render children()}
|
|
104
|
+
{@render children?.()}
|
|
107
105
|
</div>
|
|
108
106
|
{/if}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { portal } from '../../../utils/actions/index';
|
|
5
|
+
|
|
6
|
+
export interface PortalProps extends IvoryComponent<HTMLDivElement> {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
target?: string | HTMLElement;
|
|
9
|
+
}
|
|
10
|
+
|
|
2
11
|
export interface PortalConfig {
|
|
3
12
|
defaultTarget: string;
|
|
4
13
|
}
|
|
@@ -14,15 +23,7 @@
|
|
|
14
23
|
</script>
|
|
15
24
|
|
|
16
25
|
<script lang="ts">
|
|
17
|
-
|
|
18
|
-
import { portal } from '../../../utils/actions/index';
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
children: Snippet;
|
|
22
|
-
target?: string | HTMLElement;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let { children, target }: Props = $props();
|
|
26
|
+
let { children, target }: PortalProps = $props();
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
29
|
<!--
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
2
|
import { page } from '$app/state';
|
|
3
|
+
import type { IvoryComponent } from '$lib/types';
|
|
3
4
|
import { pseudoRandomId } from '$lib/utils/functions/index';
|
|
4
5
|
import clsx from 'clsx';
|
|
5
6
|
import { onMount, type Snippet } from 'svelte';
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
import { twMerge } from 'tailwind-merge';
|
|
8
9
|
import { getTabContext } from './Tabs.svelte';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
export interface TabProps extends Omit<IvoryComponent<HTMLElement>, 'children'> {
|
|
11
12
|
class?: ClassValue | ((selected: boolean) => ClassValue);
|
|
12
13
|
id?: string | undefined;
|
|
13
14
|
/**
|
|
@@ -17,19 +18,19 @@
|
|
|
17
18
|
*/
|
|
18
19
|
href?: string | undefined;
|
|
19
20
|
children: Snippet<[{ selected: boolean }]>;
|
|
20
|
-
testId?: string;
|
|
21
21
|
/** If `href` is set, this can be used to highlight an active tab */
|
|
22
22
|
active?: boolean;
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
24
25
|
|
|
26
|
+
<script lang="ts">
|
|
25
27
|
let {
|
|
26
28
|
class: clazz = (selected: boolean) => [selected && 'text-primary-500 underline'],
|
|
27
29
|
id,
|
|
28
30
|
href,
|
|
29
31
|
children,
|
|
30
|
-
testId,
|
|
31
32
|
active
|
|
32
|
-
}:
|
|
33
|
+
}: TabProps = $props();
|
|
33
34
|
|
|
34
35
|
const tab = pseudoRandomId('tab-');
|
|
35
36
|
const tabs = getTabContext();
|
|
@@ -69,7 +70,6 @@
|
|
|
69
70
|
}}
|
|
70
71
|
type={href ? undefined : 'button'}
|
|
71
72
|
{href}
|
|
72
|
-
data-testid={testId}
|
|
73
73
|
role="tab"
|
|
74
74
|
tabindex="0"
|
|
75
75
|
aria-selected={selected}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
2
|
import { pseudoRandomId } from '$lib/utils/functions/index';
|
|
3
3
|
import { type Snippet } from 'svelte';
|
|
4
4
|
import { getTabContext } from './Tabs.svelte';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export interface TabPanelProps {
|
|
7
7
|
keepMounted?: boolean;
|
|
8
8
|
children: Snippet<[{ visible: boolean }]>;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
let { keepMounted = false, children }: TabPanelProps = $props();
|
|
12
14
|
|
|
13
15
|
const panel = pseudoRandomId('tab-panel-');
|
|
14
16
|
const tabs = getTabContext();
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { IvoryComponent } from '$lib/types';
|
|
3
|
+
import { getContext, onDestroy, setContext } from 'svelte';
|
|
4
4
|
|
|
5
|
-
interface
|
|
5
|
+
export interface TabsProps extends IvoryComponent<HTMLDivElement> {
|
|
6
|
+
b_index?: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TabContext {
|
|
6
10
|
registerTab: (tab: string) => void;
|
|
7
11
|
registerPanel: (panel: string) => void;
|
|
8
12
|
selectedTab: string | undefined;
|
|
9
13
|
tabs: string[];
|
|
10
14
|
selectedPanel: string | undefined;
|
|
11
15
|
}
|
|
12
|
-
const TABS = {};
|
|
13
16
|
|
|
17
|
+
const CONTEXT = {};
|
|
14
18
|
function setTabContext(context: TabContext) {
|
|
15
|
-
setContext<TabContext>(
|
|
19
|
+
setContext<TabContext>(CONTEXT, context);
|
|
16
20
|
}
|
|
17
|
-
|
|
18
21
|
export function getTabContext() {
|
|
19
|
-
return getContext<TabContext>(
|
|
22
|
+
return getContext<TabContext>(CONTEXT);
|
|
20
23
|
}
|
|
21
24
|
</script>
|
|
22
25
|
|
|
23
26
|
<script lang="ts">
|
|
24
|
-
|
|
25
|
-
class?: ClassValue;
|
|
26
|
-
children: Snippet;
|
|
27
|
-
b_index?: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
let { class: clazz = '', children, b_index = $bindable(0) }: Props = $props();
|
|
27
|
+
let { children, b_index = $bindable(0), ...rest }: TabsProps = $props();
|
|
31
28
|
|
|
32
29
|
let allTabs: string[] = $state([]);
|
|
33
30
|
let panels: string[] = $state([]);
|
|
@@ -81,6 +78,6 @@
|
|
|
81
78
|
});
|
|
82
79
|
</script>
|
|
83
80
|
|
|
84
|
-
<div
|
|
85
|
-
{@render children()}
|
|
81
|
+
<div {...rest}>
|
|
82
|
+
{@render children?.()}
|
|
86
83
|
</div>
|