podo-ui 0.9.7 → 1.0.2
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/cdn/podo-datepicker.css +1 -1
- package/cdn/podo-datepicker.js +1 -1
- package/cdn/podo-datepicker.min.css +1 -1
- package/cdn/podo-datepicker.min.js +1 -1
- package/cdn/podo-ui.css +4 -1
- package/cdn/podo-ui.min.css +1 -1
- package/dist/react/atom/editor.d.ts.map +1 -1
- package/dist/react/atom/editor.js +94 -2
- package/dist/svelte/actions/portal.d.ts +18 -0
- package/dist/svelte/actions/portal.js +42 -0
- package/dist/svelte/atom/Avatar.svelte +97 -0
- package/dist/svelte/atom/Avatar.svelte.d.ts +31 -0
- package/dist/svelte/atom/Button.svelte +86 -0
- package/dist/svelte/atom/Button.svelte.d.ts +26 -0
- package/dist/svelte/atom/Checkbox.svelte +56 -0
- package/dist/svelte/atom/Checkbox.svelte.d.ts +16 -0
- package/dist/svelte/atom/Chip.svelte +60 -0
- package/dist/svelte/atom/Chip.svelte.d.ts +25 -0
- package/dist/svelte/atom/Editor.svelte +1314 -0
- package/dist/svelte/atom/Editor.svelte.d.ts +30 -0
- package/dist/svelte/atom/EditorView.svelte +16 -0
- package/dist/svelte/atom/EditorView.svelte.d.ts +9 -0
- package/dist/svelte/atom/File.svelte +33 -0
- package/dist/svelte/atom/File.svelte.d.ts +14 -0
- package/dist/svelte/atom/Input.svelte +80 -0
- package/dist/svelte/atom/Input.svelte.d.ts +19 -0
- package/dist/svelte/atom/Label.svelte +43 -0
- package/dist/svelte/atom/Label.svelte.d.ts +19 -0
- package/dist/svelte/atom/Radio.svelte +69 -0
- package/dist/svelte/atom/Radio.svelte.d.ts +26 -0
- package/dist/svelte/atom/RadioGroup.svelte +46 -0
- package/dist/svelte/atom/RadioGroup.svelte.d.ts +16 -0
- package/dist/svelte/atom/Select.svelte +65 -0
- package/dist/svelte/atom/Select.svelte.d.ts +26 -0
- package/dist/svelte/atom/Textarea.svelte +53 -0
- package/dist/svelte/atom/Textarea.svelte.d.ts +13 -0
- package/dist/svelte/atom/Toggle.svelte +48 -0
- package/dist/svelte/atom/Toggle.svelte.d.ts +14 -0
- package/dist/svelte/atom/Tooltip.svelte +78 -0
- package/dist/svelte/atom/Tooltip.svelte.d.ts +23 -0
- package/dist/svelte/atom/avatar.module.scss +82 -0
- package/dist/svelte/atom/editor-view.module.scss +251 -0
- package/dist/svelte/atom/input.module.scss +98 -0
- package/dist/svelte/atom/textarea.module.scss +17 -0
- package/dist/svelte/atom/tooltip.module.scss +227 -0
- package/dist/svelte/index.d.ts +26 -0
- package/dist/svelte/index.js +30 -0
- package/dist/svelte/molecule/DatePicker.svelte +986 -0
- package/dist/svelte/molecule/DatePicker.svelte.d.ts +71 -0
- package/dist/svelte/molecule/Field.svelte +81 -0
- package/dist/svelte/molecule/Field.svelte.d.ts +26 -0
- package/dist/svelte/molecule/Pagination.svelte +95 -0
- package/dist/svelte/molecule/Pagination.svelte.d.ts +14 -0
- package/dist/svelte/molecule/Tab.svelte +69 -0
- package/dist/svelte/molecule/Tab.svelte.d.ts +26 -0
- package/dist/svelte/molecule/TabPanel.svelte +24 -0
- package/dist/svelte/molecule/TabPanel.svelte.d.ts +14 -0
- package/dist/svelte/molecule/Table.svelte +109 -0
- package/dist/svelte/molecule/Table.svelte.d.ts +54 -0
- package/dist/svelte/molecule/Toast.svelte +111 -0
- package/dist/svelte/molecule/Toast.svelte.d.ts +25 -0
- package/dist/svelte/molecule/ToastProvider.svelte +74 -0
- package/dist/svelte/molecule/ToastProvider.svelte.d.ts +8 -0
- package/dist/svelte/molecule/field.module.scss +22 -0
- package/dist/svelte/molecule/pagination.module.scss +61 -0
- package/dist/svelte/molecule/toast-container.module.scss +70 -0
- package/dist/svelte/molecule/toast.module.scss +12 -0
- package/dist/svelte/stores/toast.d.ts +45 -0
- package/dist/svelte/stores/toast.js +55 -0
- package/dist/svelte/stores/validation.d.ts +15 -0
- package/dist/svelte/stores/validation.js +38 -0
- package/global.scss +1 -0
- package/package.json +32 -5
- package/vite-fonts.scss +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import styles from './toast.module.scss';
|
|
4
|
+
|
|
5
|
+
type ToastTheme = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
/** Toast ID */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Toast header */
|
|
11
|
+
header?: string;
|
|
12
|
+
/** Toast message */
|
|
13
|
+
message: string;
|
|
14
|
+
/** Toast theme */
|
|
15
|
+
theme?: ToastTheme;
|
|
16
|
+
/** Show border */
|
|
17
|
+
border?: boolean;
|
|
18
|
+
/** Long style (no header) */
|
|
19
|
+
long?: boolean;
|
|
20
|
+
/** Auto close duration in ms (0 = no auto close) */
|
|
21
|
+
duration?: number;
|
|
22
|
+
/** Toast width */
|
|
23
|
+
width?: string | number;
|
|
24
|
+
/** Close callback */
|
|
25
|
+
onclose: (id: string) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
header,
|
|
31
|
+
message,
|
|
32
|
+
theme = 'default',
|
|
33
|
+
border = false,
|
|
34
|
+
long = false,
|
|
35
|
+
duration = 3000,
|
|
36
|
+
width,
|
|
37
|
+
onclose,
|
|
38
|
+
...rest
|
|
39
|
+
}: Props & Record<string, unknown> = $props();
|
|
40
|
+
|
|
41
|
+
let isVisible = $state(false);
|
|
42
|
+
let isClosing = $state(false);
|
|
43
|
+
|
|
44
|
+
onMount(() => {
|
|
45
|
+
// Fade in
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
isVisible = true;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Auto close
|
|
51
|
+
if (duration > 0) {
|
|
52
|
+
const timer = setTimeout(() => {
|
|
53
|
+
handleClose();
|
|
54
|
+
}, duration);
|
|
55
|
+
|
|
56
|
+
return () => clearTimeout(timer);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
function handleClose() {
|
|
61
|
+
isClosing = true;
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
onclose(id);
|
|
64
|
+
}, 200); // 0.2s fade out
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let toastClasses = $derived(
|
|
68
|
+
[
|
|
69
|
+
'toast',
|
|
70
|
+
theme,
|
|
71
|
+
border ? 'border' : '',
|
|
72
|
+
long ? 'long' : '',
|
|
73
|
+
styles.toastAnimation,
|
|
74
|
+
isVisible && !isClosing ? styles.fadeIn : '',
|
|
75
|
+
isClosing ? styles.fadeOut : '',
|
|
76
|
+
]
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join(' ')
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
let toastStyle = $derived(
|
|
82
|
+
width ? `width: ${typeof width === 'number' ? `${width}px` : width};` : ''
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
function getIcon(): string {
|
|
86
|
+
switch (theme) {
|
|
87
|
+
case 'success':
|
|
88
|
+
return 'icon-check';
|
|
89
|
+
case 'warning':
|
|
90
|
+
return 'icon-warning';
|
|
91
|
+
case 'danger':
|
|
92
|
+
return 'icon-danger';
|
|
93
|
+
case 'primary':
|
|
94
|
+
case 'info':
|
|
95
|
+
case 'default':
|
|
96
|
+
default:
|
|
97
|
+
return 'icon-info';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<div class={toastClasses} style={toastStyle} {...rest}>
|
|
103
|
+
<i class={getIcon()}></i>
|
|
104
|
+
<div class="toast-content">
|
|
105
|
+
{#if header && !long}
|
|
106
|
+
<div class="toast-header">{header}</div>
|
|
107
|
+
{/if}
|
|
108
|
+
<div class="toast-body">{message}</div>
|
|
109
|
+
</div>
|
|
110
|
+
<button onclick={handleClose} aria-label="닫기"></button>
|
|
111
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type ToastTheme = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Toast ID */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Toast header */
|
|
6
|
+
header?: string;
|
|
7
|
+
/** Toast message */
|
|
8
|
+
message: string;
|
|
9
|
+
/** Toast theme */
|
|
10
|
+
theme?: ToastTheme;
|
|
11
|
+
/** Show border */
|
|
12
|
+
border?: boolean;
|
|
13
|
+
/** Long style (no header) */
|
|
14
|
+
long?: boolean;
|
|
15
|
+
/** Auto close duration in ms (0 = no auto close) */
|
|
16
|
+
duration?: number;
|
|
17
|
+
/** Toast width */
|
|
18
|
+
width?: string | number;
|
|
19
|
+
/** Close callback */
|
|
20
|
+
onclose: (id: string) => void;
|
|
21
|
+
}
|
|
22
|
+
type $$ComponentProps = Props & Record<string, unknown>;
|
|
23
|
+
declare const Toast: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
24
|
+
type Toast = ReturnType<typeof Toast>;
|
|
25
|
+
export default Toast;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import {
|
|
5
|
+
createToastContext,
|
|
6
|
+
type ToastPosition,
|
|
7
|
+
} from '../stores/toast';
|
|
8
|
+
import Toast from './Toast.svelte';
|
|
9
|
+
import { portal } from '../actions/portal';
|
|
10
|
+
import styles from './toast-container.module.scss';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
/** Children content */
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { children }: Props = $props();
|
|
18
|
+
|
|
19
|
+
const { toasts, hideToast } = createToastContext();
|
|
20
|
+
|
|
21
|
+
const positions: ToastPosition[] = [
|
|
22
|
+
'top-left',
|
|
23
|
+
'top-center',
|
|
24
|
+
'top-right',
|
|
25
|
+
'center-left',
|
|
26
|
+
'center',
|
|
27
|
+
'center-right',
|
|
28
|
+
'bottom-left',
|
|
29
|
+
'bottom-center',
|
|
30
|
+
'bottom-right',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
let isMounted = $state(false);
|
|
34
|
+
|
|
35
|
+
onMount(() => {
|
|
36
|
+
isMounted = true;
|
|
37
|
+
return () => {
|
|
38
|
+
isMounted = false;
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function getToastsByPosition(position: ToastPosition) {
|
|
43
|
+
return $toasts.filter((t) => t.position === position);
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
{#if children}
|
|
48
|
+
{@render children()}
|
|
49
|
+
{/if}
|
|
50
|
+
|
|
51
|
+
{#if isMounted}
|
|
52
|
+
<div class={styles.toastPortal} use:portal={'body'}>
|
|
53
|
+
{#each positions as position (position)}
|
|
54
|
+
{@const positionToasts = getToastsByPosition(position)}
|
|
55
|
+
{#if positionToasts.length > 0}
|
|
56
|
+
<div class="{styles.toastContainer} {styles[position]}">
|
|
57
|
+
{#each positionToasts as toast (toast.id)}
|
|
58
|
+
<Toast
|
|
59
|
+
id={toast.id}
|
|
60
|
+
header={toast.header}
|
|
61
|
+
message={toast.message}
|
|
62
|
+
theme={toast.theme}
|
|
63
|
+
border={toast.border}
|
|
64
|
+
long={toast.long}
|
|
65
|
+
duration={toast.duration}
|
|
66
|
+
width={toast.width}
|
|
67
|
+
onclose={() => hideToast(toast.id)}
|
|
68
|
+
/>
|
|
69
|
+
{/each}
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
72
|
+
{/each}
|
|
73
|
+
</div>
|
|
74
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Children content */
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
}
|
|
6
|
+
declare const ToastProvider: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type ToastProvider = ReturnType<typeof ToastProvider>;
|
|
8
|
+
export default ToastProvider;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use '../../../mixin.scss' as *;
|
|
2
|
+
.style {
|
|
3
|
+
width: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: s(3);
|
|
7
|
+
&:global {
|
|
8
|
+
> div.child {
|
|
9
|
+
width: 100%;
|
|
10
|
+
> :not(:last-child) {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
margin-right: s(5);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
> div.helper {
|
|
16
|
+
@include p4;
|
|
17
|
+
& {
|
|
18
|
+
color: color('text-sub');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@use '../../../mixin.scss' as *;
|
|
2
|
+
|
|
3
|
+
.pagination {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
gap: s(1);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.pageButton {
|
|
11
|
+
@include p3;
|
|
12
|
+
min-width: 32px;
|
|
13
|
+
height: 32px;
|
|
14
|
+
padding: s(1) s(2);
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
color: color(text-action);
|
|
20
|
+
border: 1px solid transparent;
|
|
21
|
+
border-radius: r(2);
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
transition: all 0.2s;
|
|
24
|
+
user-select: none;
|
|
25
|
+
|
|
26
|
+
&:hover:not(.active) {
|
|
27
|
+
background-color: color(default-fill);
|
|
28
|
+
color: color(text-action-hover);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:active:not(.active) {
|
|
32
|
+
background-color: color(default-hover);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.active {
|
|
36
|
+
background-color: color(primary);
|
|
37
|
+
color: color(primary-reverse);
|
|
38
|
+
border-color: color(primary);
|
|
39
|
+
font-weight: 600;
|
|
40
|
+
cursor: default;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:focus-visible {
|
|
44
|
+
outline: 4px solid color(primary-outline);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:disabled {
|
|
48
|
+
color: color(text-action-disabled);
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
i {
|
|
54
|
+
font-size: 16px;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.pageButtonPlaceholder {
|
|
59
|
+
min-width: 32px;
|
|
60
|
+
height: 32px;
|
|
61
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@use '../../../mixin' as *;
|
|
2
|
+
|
|
3
|
+
.toastPortal {
|
|
4
|
+
position: fixed;
|
|
5
|
+
inset: 0;
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
z-index: 9999;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.toastContainer {
|
|
11
|
+
position: fixed;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: s(3);
|
|
15
|
+
padding: s(5);
|
|
16
|
+
pointer-events: auto;
|
|
17
|
+
|
|
18
|
+
// Top positions
|
|
19
|
+
&.top-left {
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.top-center {
|
|
25
|
+
top: 0;
|
|
26
|
+
left: 50%;
|
|
27
|
+
transform: translateX(-50%);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.top-right {
|
|
31
|
+
top: 0;
|
|
32
|
+
right: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Center positions
|
|
36
|
+
&.center-left {
|
|
37
|
+
top: 50%;
|
|
38
|
+
left: 0;
|
|
39
|
+
transform: translateY(-50%);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.center {
|
|
43
|
+
top: 50%;
|
|
44
|
+
left: 50%;
|
|
45
|
+
transform: translate(-50%, -50%);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.center-right {
|
|
49
|
+
top: 50%;
|
|
50
|
+
right: 0;
|
|
51
|
+
transform: translateY(-50%);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Bottom positions
|
|
55
|
+
&.bottom-left {
|
|
56
|
+
bottom: 0;
|
|
57
|
+
left: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&.bottom-center {
|
|
61
|
+
bottom: 0;
|
|
62
|
+
left: 50%;
|
|
63
|
+
transform: translateX(-50%);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.bottom-right {
|
|
67
|
+
bottom: 0;
|
|
68
|
+
right: 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
3
|
+
export type ToastTheme = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
4
|
+
export interface ToastData {
|
|
5
|
+
id: string;
|
|
6
|
+
position: ToastPosition;
|
|
7
|
+
header?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
theme?: ToastTheme;
|
|
10
|
+
border?: boolean;
|
|
11
|
+
long?: boolean;
|
|
12
|
+
duration?: number;
|
|
13
|
+
width?: string | number;
|
|
14
|
+
}
|
|
15
|
+
export interface ToastOptions {
|
|
16
|
+
header?: string;
|
|
17
|
+
message: string;
|
|
18
|
+
theme?: ToastTheme;
|
|
19
|
+
border?: boolean;
|
|
20
|
+
long?: boolean;
|
|
21
|
+
duration?: number;
|
|
22
|
+
width?: string | number;
|
|
23
|
+
position?: ToastPosition;
|
|
24
|
+
}
|
|
25
|
+
export interface ToastContext {
|
|
26
|
+
toasts: Writable<ToastData[]>;
|
|
27
|
+
showToast: (options: ToastOptions) => string;
|
|
28
|
+
hideToast: (id: string) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create toast context for ToastProvider
|
|
32
|
+
* @returns Toast context with toasts store and methods
|
|
33
|
+
*/
|
|
34
|
+
export declare function createToastContext(): ToastContext;
|
|
35
|
+
/**
|
|
36
|
+
* Get toast context from parent ToastProvider
|
|
37
|
+
* @returns Toast context
|
|
38
|
+
* @throws Error if used outside ToastProvider
|
|
39
|
+
*/
|
|
40
|
+
export declare function useToast(): ToastContext;
|
|
41
|
+
declare const _default: {
|
|
42
|
+
createToastContext: typeof createToastContext;
|
|
43
|
+
useToast: typeof useToast;
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { getContext, setContext } from 'svelte';
|
|
22
|
+
import { writable } from 'svelte/store';
|
|
23
|
+
var TOAST_KEY = Symbol('toast');
|
|
24
|
+
/**
|
|
25
|
+
* Create toast context for ToastProvider
|
|
26
|
+
* @returns Toast context with toasts store and methods
|
|
27
|
+
*/
|
|
28
|
+
export function createToastContext() {
|
|
29
|
+
var toasts = writable([]);
|
|
30
|
+
var showToast = function (options) {
|
|
31
|
+
var id = "toast-".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 9));
|
|
32
|
+
var position = options.position || 'top-right';
|
|
33
|
+
toasts.update(function (items) { return __spreadArray(__spreadArray([], items, true), [__assign({ id: id, position: position }, options)], false); });
|
|
34
|
+
return id;
|
|
35
|
+
};
|
|
36
|
+
var hideToast = function (id) {
|
|
37
|
+
toasts.update(function (items) { return items.filter(function (t) { return t.id !== id; }); });
|
|
38
|
+
};
|
|
39
|
+
var context = { toasts: toasts, showToast: showToast, hideToast: hideToast };
|
|
40
|
+
setContext(TOAST_KEY, context);
|
|
41
|
+
return context;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get toast context from parent ToastProvider
|
|
45
|
+
* @returns Toast context
|
|
46
|
+
* @throws Error if used outside ToastProvider
|
|
47
|
+
*/
|
|
48
|
+
export function useToast() {
|
|
49
|
+
var context = getContext(TOAST_KEY);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error('useToast must be used within ToastProvider');
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
export default { createToastContext: createToastContext, useToast: useToast };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Readable } from 'svelte/store';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export interface ValidationStore {
|
|
4
|
+
message: Readable<string>;
|
|
5
|
+
statusClass: Readable<string>;
|
|
6
|
+
validate: (value: string | number | undefined) => void;
|
|
7
|
+
reset: () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a validation store for Zod schema validation
|
|
11
|
+
* @param validator - Zod schema for validation
|
|
12
|
+
* @returns Validation store with message, statusClass, validate, and reset
|
|
13
|
+
*/
|
|
14
|
+
export declare function createValidation(validator?: z.ZodType<unknown>): ValidationStore;
|
|
15
|
+
export default createValidation;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Create a validation store for Zod schema validation
|
|
5
|
+
* @param validator - Zod schema for validation
|
|
6
|
+
* @returns Validation store with message, statusClass, validate, and reset
|
|
7
|
+
*/
|
|
8
|
+
export function createValidation(validator) {
|
|
9
|
+
var message = writable('');
|
|
10
|
+
var statusClass = writable('');
|
|
11
|
+
var reset = function () {
|
|
12
|
+
message.set('');
|
|
13
|
+
statusClass.set('');
|
|
14
|
+
};
|
|
15
|
+
var validate = function (value) {
|
|
16
|
+
reset();
|
|
17
|
+
if (!validator || !value) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
validator.parse(value);
|
|
22
|
+
statusClass.set('success');
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e instanceof z.ZodError) {
|
|
26
|
+
message.set(e.errors[0].message);
|
|
27
|
+
statusClass.set('danger');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
message: { subscribe: message.subscribe },
|
|
33
|
+
statusClass: { subscribe: statusClass.subscribe },
|
|
34
|
+
validate: validate,
|
|
35
|
+
reset: reset,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export default createValidation;
|
package/global.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podo-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "hada0127 <work@tarucy.net>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,6 +44,24 @@
|
|
|
44
44
|
"import": "./dist/react/molecule/*.js",
|
|
45
45
|
"default": "./dist/react/molecule/*.js"
|
|
46
46
|
},
|
|
47
|
+
"./svelte": {
|
|
48
|
+
"types": "./dist/svelte/index.d.ts",
|
|
49
|
+
"svelte": "./dist/svelte/index.js",
|
|
50
|
+
"import": "./dist/svelte/index.js",
|
|
51
|
+
"default": "./dist/svelte/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./svelte/atom/*": {
|
|
54
|
+
"types": "./dist/svelte/atom/*.d.ts",
|
|
55
|
+
"svelte": "./dist/svelte/atom/*.svelte",
|
|
56
|
+
"import": "./dist/svelte/atom/*.js",
|
|
57
|
+
"default": "./dist/svelte/atom/*.js"
|
|
58
|
+
},
|
|
59
|
+
"./svelte/molecule/*": {
|
|
60
|
+
"types": "./dist/svelte/molecule/*.d.ts",
|
|
61
|
+
"svelte": "./dist/svelte/molecule/*.svelte",
|
|
62
|
+
"import": "./dist/svelte/molecule/*.js",
|
|
63
|
+
"default": "./dist/svelte/molecule/*.js"
|
|
64
|
+
},
|
|
47
65
|
"./global.scss": {
|
|
48
66
|
"types": "./global.d.ts",
|
|
49
67
|
"default": "./global.scss"
|
|
@@ -78,7 +96,8 @@
|
|
|
78
96
|
"build:lib": "node ./cli/build-lib.js",
|
|
79
97
|
"build:cdn": "node ./cli/build-cdn.js",
|
|
80
98
|
"build:cdn-js": "node ./cli/build-cdn-js.js",
|
|
81
|
-
"build:
|
|
99
|
+
"build:svelte": "node ./cli/build-svelte.js",
|
|
100
|
+
"build:all": "npm run build:lib && npm run build:svelte && npm run build:cdn && npm run build:cdn-js",
|
|
82
101
|
"prepublishOnly": "npm run build:all",
|
|
83
102
|
"lint": "eslint .",
|
|
84
103
|
"icon": "node ./cli/icon-scss.js",
|
|
@@ -90,17 +109,21 @@
|
|
|
90
109
|
"peerDependencies": {
|
|
91
110
|
"react": "^18.0.0 || ^19.0.0",
|
|
92
111
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
93
|
-
"sass": "^1.0.0"
|
|
112
|
+
"sass": "^1.0.0",
|
|
113
|
+
"svelte": "^5.0.0"
|
|
94
114
|
},
|
|
95
115
|
"peerDependenciesMeta": {
|
|
96
116
|
"react": {
|
|
97
|
-
"optional":
|
|
117
|
+
"optional": true
|
|
98
118
|
},
|
|
99
119
|
"react-dom": {
|
|
100
|
-
"optional":
|
|
120
|
+
"optional": true
|
|
101
121
|
},
|
|
102
122
|
"sass": {
|
|
103
123
|
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"svelte": {
|
|
126
|
+
"optional": true
|
|
104
127
|
}
|
|
105
128
|
},
|
|
106
129
|
"dependencies": {
|
|
@@ -109,6 +132,10 @@
|
|
|
109
132
|
"zod": "^3.23.8"
|
|
110
133
|
},
|
|
111
134
|
"devDependencies": {
|
|
135
|
+
"@sveltejs/package": "^2.3.0",
|
|
136
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
137
|
+
"svelte": "^5.0.0",
|
|
138
|
+
"svelte-check": "^4.0.0",
|
|
112
139
|
"@eslint/js": "^9.8.0",
|
|
113
140
|
"@playwright/test": "^1.56.1",
|
|
114
141
|
"@testing-library/jest-dom": "^6.6.3",
|