@ims360/svelte-ivory 0.0.21 → 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 +10 -5
- 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 +6 -14
- package/dist/components/layout/tooltip/Tooltip.svelte.d.ts +2 -5
- 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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- 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 +16 -5
- 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 +6 -14
- 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
- package/src/lib/index.ts +1 -0
- package/src/lib/types.ts +5 -0
|
@@ -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>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
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';
|
|
@@ -6,16 +7,12 @@
|
|
|
6
7
|
import Popover, { type PopoverPlacement } from '../popover/Popover.svelte';
|
|
7
8
|
import Portal from '../portal/Portal.svelte';
|
|
8
9
|
|
|
9
|
-
export interface Props {
|
|
10
|
+
export interface Props extends IvoryComponent<HTMLElement> {
|
|
10
11
|
children?: Snippet;
|
|
11
12
|
/** The content of the tooltip */
|
|
12
13
|
tooltip: string | Snippet;
|
|
13
|
-
/** The class of the element that triggers the tooltip */
|
|
14
|
-
class?: ClassValue;
|
|
15
14
|
/** The class of the tooltip itself */
|
|
16
15
|
tooltipClass?: ClassValue;
|
|
17
|
-
style?: string;
|
|
18
|
-
onclick?: (e: Event) => void;
|
|
19
16
|
/** If the href is set, the resulting element will be a link to the href */
|
|
20
17
|
href?: string;
|
|
21
18
|
/**
|
|
@@ -37,13 +34,11 @@
|
|
|
37
34
|
let {
|
|
38
35
|
children,
|
|
39
36
|
tooltip,
|
|
40
|
-
class: clazz,
|
|
41
|
-
style,
|
|
42
|
-
onclick,
|
|
43
37
|
href,
|
|
44
38
|
timeout = 500,
|
|
45
39
|
tooltipClass,
|
|
46
|
-
placement = 'top'
|
|
40
|
+
placement = 'top',
|
|
41
|
+
...rest
|
|
47
42
|
}: Props = $props();
|
|
48
43
|
|
|
49
44
|
let target = $state<HTMLElement>();
|
|
@@ -72,19 +67,16 @@
|
|
|
72
67
|
@component
|
|
73
68
|
Shows additional information when hovering over an element.
|
|
74
69
|
-->
|
|
75
|
-
|
|
76
70
|
<!-- Ignoring this error is fine since it's a false positive -->
|
|
77
71
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
78
72
|
<svelte:element
|
|
79
73
|
this={href ? 'a' : onclick ? 'button' : 'div'}
|
|
80
|
-
{href}
|
|
81
74
|
type={onclick ? 'button' : undefined}
|
|
82
|
-
|
|
75
|
+
{...rest}
|
|
76
|
+
{href}
|
|
83
77
|
bind:this={target}
|
|
84
78
|
{onmouseenter}
|
|
85
79
|
{onmouseleave}
|
|
86
|
-
{style}
|
|
87
|
-
{onclick}
|
|
88
80
|
>
|
|
89
81
|
{@render children?.()}
|
|
90
82
|
</svelte:element>
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export interface Props {
|
|
3
|
+
class?: ClassValue;
|
|
4
|
+
children?: Snippet<[toast: ToastSettings & { close: () => void }]>;
|
|
5
|
+
duration?: number;
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<!--
|
|
2
10
|
@component
|
|
3
11
|
Renders the toasts that have been triggered by the `Toasts` store.
|
|
@@ -12,12 +20,7 @@
|
|
|
12
20
|
import { fly, scale } from 'svelte/transition';
|
|
13
21
|
import { Toasts, type ToastSettings } from './toasts.svelte';
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
class?: ClassValue;
|
|
17
|
-
children?: Snippet<[toast: ToastSettings & { close: () => void }]>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
let { class: clazz = 'px-2 pb-2', children }: Props = $props();
|
|
23
|
+
let { class: clazz = 'px-2 pb-2', children, duration = 200 }: Props = $props();
|
|
21
24
|
|
|
22
25
|
function getIcon(
|
|
23
26
|
variant: 'info' | 'success' | 'warning' | 'error',
|
|
@@ -51,9 +54,9 @@
|
|
|
51
54
|
|
|
52
55
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
53
56
|
<div
|
|
54
|
-
in:fly={{ y: '-100%', duration
|
|
55
|
-
out:scale={{ duration
|
|
56
|
-
animate:flip={{ duration
|
|
57
|
+
in:fly={{ y: '-100%', duration }}
|
|
58
|
+
out:scale={{ duration }}
|
|
59
|
+
animate:flip={{ duration }}
|
|
57
60
|
onpointerenter={() => {
|
|
58
61
|
Toasts.freeze(toast.id);
|
|
59
62
|
}}
|
|
@@ -71,10 +74,14 @@
|
|
|
71
74
|
<div
|
|
72
75
|
class={[
|
|
73
76
|
'bg-opacity-85 flex flex-row items-center gap-4 rounded px-4 py-2 shadow-lg group-last:rounded-t-none',
|
|
74
|
-
toast.variant === 'info' &&
|
|
75
|
-
|
|
76
|
-
toast.variant === '
|
|
77
|
-
|
|
77
|
+
toast.variant === 'info' &&
|
|
78
|
+
'bg-primary-200-800 text-primary-contrast-50-950',
|
|
79
|
+
toast.variant === 'success' &&
|
|
80
|
+
'bg-success-200-800 text-success-contrast-50-950',
|
|
81
|
+
toast.variant === 'warning' &&
|
|
82
|
+
'bg-warning-200-800 text-warning-contrast-50-950',
|
|
83
|
+
toast.variant === 'error' &&
|
|
84
|
+
'bg-error-200-800 text-error-contrast-50-950'
|
|
78
85
|
]}
|
|
79
86
|
>
|
|
80
87
|
<VariantIcon />
|
|
@@ -87,9 +94,9 @@
|
|
|
87
94
|
onclick={() => {
|
|
88
95
|
Toasts.close(toast.id);
|
|
89
96
|
}}
|
|
90
|
-
class="
|
|
97
|
+
class="group"
|
|
91
98
|
>
|
|
92
|
-
<X />
|
|
99
|
+
<X size={20} class="stroke-1 transition-all group-hover:stroke-2" />
|
|
93
100
|
</button>
|
|
94
101
|
{/if}
|
|
95
102
|
</div>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as ToastUI } from './Toast.svelte';
|
|
2
|
-
export { Toasts } from './toasts.svelte';
|
|
1
|
+
export { default as ToastUI, type Props as ToastUIProps } from './Toast.svelte';
|
|
2
|
+
export { Toasts, type ToastSettings } from './toasts.svelte';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { Icon } from '@lucide/svelte';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface ToastSettings {
|
|
4
4
|
message: string;
|
|
5
5
|
autohide?: boolean;
|
|
6
6
|
timeout?: number;
|
|
7
7
|
hideDismiss?: boolean;
|
|
8
8
|
icon?: typeof Icon;
|
|
9
9
|
variant: 'info' | 'success' | 'warning' | 'error';
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
interface Toast extends ToastSettings {
|
|
13
13
|
id: string;
|
|
14
14
|
timeoutId?: ReturnType<typeof setTimeout>;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
|
|
17
17
|
const TOAST_DEFAULTS: ToastSettings = {
|
|
18
18
|
message: 'Missing Toast Message',
|
package/src/lib/index.ts
CHANGED