cclkit4svelte 2.0.6 → 2.0.7
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/Accordion.svelte +40 -29
- package/dist/Accordion.svelte.d.ts +31 -22
- package/dist/AccordionItem.svelte +120 -87
- package/dist/AccordionItem.svelte.d.ts +43 -34
- package/dist/Alert.svelte +111 -82
- package/dist/Alert.svelte.d.ts +38 -36
- package/dist/Badge.svelte +84 -0
- package/dist/Badge.svelte.d.ts +34 -0
- package/dist/BookCard.svelte +127 -88
- package/dist/BookCard.svelte.d.ts +47 -45
- package/dist/Breadcrumb.svelte +91 -0
- package/dist/Breadcrumb.svelte.d.ts +37 -0
- package/dist/Button.svelte +72 -35
- package/dist/Button.svelte.d.ts +33 -31
- package/dist/Card.svelte +110 -75
- package/dist/Card.svelte.d.ts +38 -36
- package/dist/Carousel.svelte +91 -66
- package/dist/Carousel.svelte.d.ts +26 -24
- package/dist/ChangeHistory.svelte +188 -150
- package/dist/ChangeHistory.svelte.d.ts +29 -27
- package/dist/Checkbox.svelte +120 -89
- package/dist/Checkbox.svelte.d.ts +41 -39
- package/dist/CommonHeader.svelte +51 -24
- package/dist/CommonHeader.svelte.d.ts +38 -36
- package/dist/DatePicker.svelte +239 -188
- package/dist/DatePicker.svelte.d.ts +40 -38
- package/dist/Dialog.svelte +224 -0
- package/dist/Dialog.svelte.d.ts +50 -0
- package/dist/Drawer.svelte +158 -0
- package/dist/Drawer.svelte.d.ts +40 -0
- package/dist/Footer.svelte +32 -16
- package/dist/Footer.svelte.d.ts +21 -19
- package/dist/FormGroup.svelte +67 -43
- package/dist/FormGroup.svelte.d.ts +46 -37
- package/dist/Header.svelte +108 -98
- package/dist/Header.svelte.d.ts +25 -23
- package/dist/Input.svelte +154 -99
- package/dist/Input.svelte.d.ts +62 -60
- package/dist/Pagination.svelte +257 -0
- package/dist/Pagination.svelte.d.ts +35 -0
- package/dist/ProgressBar.svelte +49 -44
- package/dist/ProgressBar.svelte.d.ts +25 -23
- package/dist/RadioButton.svelte +92 -62
- package/dist/RadioButton.svelte.d.ts +40 -38
- package/dist/Select.svelte +94 -53
- package/dist/Select.svelte.d.ts +49 -47
- package/dist/ServiceCard.svelte +71 -64
- package/dist/ServiceCard.svelte.d.ts +27 -25
- package/dist/Skeleton.svelte +96 -0
- package/dist/Skeleton.svelte.d.ts +24 -0
- package/dist/SlideMenu.svelte +157 -0
- package/dist/SlideMenu.svelte.d.ts +42 -0
- package/dist/Spinner.svelte +25 -23
- package/dist/Spinner.svelte.d.ts +20 -18
- package/dist/TabPanel.svelte +42 -21
- package/dist/TabPanel.svelte.d.ts +40 -31
- package/dist/Table.svelte +114 -73
- package/dist/Table.svelte.d.ts +33 -31
- package/dist/Tabs.svelte +78 -72
- package/dist/Tabs.svelte.d.ts +18 -16
- package/dist/Textarea.svelte +101 -52
- package/dist/Textarea.svelte.d.ts +57 -55
- package/dist/Thumbnail.svelte +33 -15
- package/dist/Thumbnail.svelte.d.ts +34 -32
- package/dist/Toaster.svelte +144 -0
- package/dist/Toaster.svelte.d.ts +26 -0
- package/dist/Toggle.svelte +85 -61
- package/dist/Toggle.svelte.d.ts +36 -34
- package/dist/Tooltip.svelte +126 -122
- package/dist/Tooltip.svelte.d.ts +30 -21
- package/dist/const/colorMap.d.ts +5 -0
- package/dist/const/colorMap.js +21 -0
- package/dist/const/variables.css +21 -21
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/toast.d.ts +29 -0
- package/dist/toast.js +66 -0
- package/dist/types/breadcrumb.d.ts +4 -0
- package/dist/types/breadcrumb.js +1 -0
- package/dist/types/slide-menu.d.ts +5 -0
- package/dist/types/slide-menu.js +1 -0
- package/package.json +87 -87
package/dist/Tooltip.svelte
CHANGED
|
@@ -1,139 +1,143 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export let
|
|
5
|
-
export let
|
|
6
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CCLVividColor } from './const/config';
|
|
3
|
+
|
|
4
|
+
export let text: string;
|
|
5
|
+
export let position: 'top' | 'bottom' | 'left' | 'right' = 'top';
|
|
6
|
+
export let disabled = false;
|
|
7
|
+
export let backgroundColor: string = CCLVividColor.WRAP_GREY;
|
|
8
|
+
|
|
9
|
+
// ユニークなIDを生成してaria-describedbyで使用
|
|
10
|
+
const tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;
|
|
7
11
|
</script>
|
|
8
12
|
|
|
9
13
|
<div
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
class="tooltip-trigger"
|
|
15
|
+
data-testid="tooltip-trigger"
|
|
16
|
+
tabindex="0"
|
|
17
|
+
aria-describedby={!disabled ? tooltipId : undefined}
|
|
14
18
|
>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
<slot />
|
|
20
|
+
<span
|
|
21
|
+
{...{ id: tooltipId }}
|
|
22
|
+
style:--tooltip-background-color={backgroundColor.startsWith('--')
|
|
23
|
+
? `var(${backgroundColor})`
|
|
24
|
+
: backgroundColor}
|
|
25
|
+
class="tooltip-content"
|
|
26
|
+
data-testid="tooltip-content"
|
|
27
|
+
class:disabled
|
|
28
|
+
class:top={position === 'top'}
|
|
29
|
+
class:bottom={position === 'bottom'}
|
|
30
|
+
class:left={position === 'left'}
|
|
31
|
+
class:right={position === 'right'}
|
|
32
|
+
role="tooltip"
|
|
33
|
+
>
|
|
34
|
+
{text}
|
|
35
|
+
</span>
|
|
32
36
|
</div>
|
|
33
37
|
|
|
34
38
|
<style>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
.tooltip-trigger {
|
|
40
|
+
position: relative;
|
|
41
|
+
display: inline-block;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
}
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
.tooltip-content {
|
|
46
|
+
position: absolute;
|
|
47
|
+
z-index: 10;
|
|
48
|
+
background-color: var(--tooltip-background-color);
|
|
49
|
+
color: white;
|
|
50
|
+
padding: 0.5em 1em;
|
|
51
|
+
border-radius: 4px;
|
|
52
|
+
font-size: 0.875rem;
|
|
53
|
+
line-height: 1.4;
|
|
54
|
+
white-space: nowrap;
|
|
55
|
+
/* デフォルトは非表示 */
|
|
56
|
+
visibility: hidden;
|
|
57
|
+
opacity: 0;
|
|
58
|
+
transition:
|
|
59
|
+
opacity 0.2s,
|
|
60
|
+
visibility 0.2s;
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
/* disabledの場合は完全に非表示 */
|
|
64
|
+
.tooltip-content.disabled {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
/* ホバーまたはフォーカスで表示 */
|
|
69
|
+
.tooltip-trigger:hover .tooltip-content,
|
|
70
|
+
.tooltip-trigger:focus .tooltip-content {
|
|
71
|
+
visibility: visible;
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
/* 吹き出しの矢印 */
|
|
76
|
+
.tooltip-content::after {
|
|
77
|
+
content: '';
|
|
78
|
+
position: absolute;
|
|
79
|
+
border-style: solid;
|
|
80
|
+
}
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
/* --- ポジションごとのスタイル --- */
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
/* 上に表示 */
|
|
85
|
+
.tooltip-content.top {
|
|
86
|
+
bottom: 100%;
|
|
87
|
+
left: 50%;
|
|
88
|
+
transform: translateX(-50%);
|
|
89
|
+
margin-bottom: 8px;
|
|
90
|
+
}
|
|
91
|
+
.tooltip-content.top::after {
|
|
92
|
+
top: 100%;
|
|
93
|
+
left: 50%;
|
|
94
|
+
transform: translateX(-50%);
|
|
95
|
+
border-width: 5px;
|
|
96
|
+
border-color: var(--tooltip-background-color) transparent transparent transparent;
|
|
97
|
+
}
|
|
94
98
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
/* 下に表示 */
|
|
100
|
+
.tooltip-content.bottom {
|
|
101
|
+
top: 100%;
|
|
102
|
+
left: 50%;
|
|
103
|
+
transform: translateX(-50%);
|
|
104
|
+
margin-top: 8px;
|
|
105
|
+
}
|
|
106
|
+
.tooltip-content.bottom::after {
|
|
107
|
+
bottom: 100%;
|
|
108
|
+
left: 50%;
|
|
109
|
+
transform: translateX(-50%);
|
|
110
|
+
border-width: 5px;
|
|
111
|
+
border-color: transparent transparent var(--tooltip-background-color) transparent;
|
|
112
|
+
}
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
/* 左に表示 */
|
|
115
|
+
.tooltip-content.left {
|
|
116
|
+
right: 100%;
|
|
117
|
+
top: 50%;
|
|
118
|
+
transform: translateY(-50%);
|
|
119
|
+
margin-right: 8px;
|
|
120
|
+
}
|
|
121
|
+
.tooltip-content.left::after {
|
|
122
|
+
left: 100%;
|
|
123
|
+
top: 50%;
|
|
124
|
+
transform: translateY(-50%);
|
|
125
|
+
border-width: 5px;
|
|
126
|
+
border-color: transparent transparent transparent var(--tooltip-background-color);
|
|
127
|
+
}
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
129
|
+
/* 右に表示 */
|
|
130
|
+
.tooltip-content.right {
|
|
131
|
+
left: 100%;
|
|
132
|
+
top: 50%;
|
|
133
|
+
transform: translateY(-50%);
|
|
134
|
+
margin-left: 8px;
|
|
135
|
+
}
|
|
136
|
+
.tooltip-content.right::after {
|
|
137
|
+
right: 100%;
|
|
138
|
+
top: 50%;
|
|
139
|
+
transform: translateY(-50%);
|
|
140
|
+
border-width: 5px;
|
|
141
|
+
border-color: transparent var(--tooltip-background-color) transparent transparent;
|
|
142
|
+
}
|
|
139
143
|
</style>
|
package/dist/Tooltip.svelte.d.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {
|
|
13
|
-
default: {};
|
|
14
|
-
};
|
|
15
|
-
exports?: {} | undefined;
|
|
16
|
-
bindings?: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export type TooltipProps = typeof __propDef.props;
|
|
19
|
-
export type TooltipEvents = typeof __propDef.events;
|
|
20
|
-
export type TooltipSlots = typeof __propDef.slots;
|
|
21
|
-
export default class Tooltip extends SvelteComponent<TooltipProps, TooltipEvents, TooltipSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
22
13
|
}
|
|
23
|
-
|
|
14
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
+
default: any;
|
|
16
|
+
} ? Props extends Record<string, never> ? any : {
|
|
17
|
+
children?: any;
|
|
18
|
+
} : {});
|
|
19
|
+
declare const Tooltip: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
text: string;
|
|
21
|
+
position?: "top" | "bottom" | "left" | "right";
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
backgroundColor?: string;
|
|
24
|
+
}, {
|
|
25
|
+
default: {};
|
|
26
|
+
}>, {
|
|
27
|
+
[evt: string]: CustomEvent<any>;
|
|
28
|
+
}, {
|
|
29
|
+
default: {};
|
|
30
|
+
}, {}, string>;
|
|
31
|
+
type Tooltip = InstanceType<typeof Tooltip>;
|
|
32
|
+
export default Tooltip;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const pastelToVividMap: Record<string, string>;
|
|
2
|
+
/** Returns the vivid counterpart for a given color var if it's pastel; otherwise undefined. */
|
|
3
|
+
export declare function vividFor(colorVar: string | undefined): string | undefined;
|
|
4
|
+
/** Whether the provided CSS var corresponds to a known pastel color. */
|
|
5
|
+
export declare function isPastel(colorVar: string | undefined): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { CCLPastelColor, CCLVividColor } from './config';
|
|
3
|
+
// Pastel -> Vivid CSS variable mapping
|
|
4
|
+
export var pastelToVividMap = (_a = {},
|
|
5
|
+
_a[CCLPastelColor.PEACH_PINK] = CCLVividColor.STRAWBERRY_PINK,
|
|
6
|
+
_a[CCLPastelColor.LEMON_YELLOW] = CCLVividColor.PINEAPPLE_YELLOW,
|
|
7
|
+
_a[CCLPastelColor.SUGAR_BLUE] = CCLVividColor.SODA_BLUE,
|
|
8
|
+
_a[CCLPastelColor.MATCHA_GREEN] = CCLVividColor.MELON_GREEN,
|
|
9
|
+
_a[CCLPastelColor.AKEBI_PURPLE] = CCLVividColor.GRAPE_PURPLE,
|
|
10
|
+
_a[CCLPastelColor.CLOUD_GREY] = CCLVividColor.WRAP_GREY,
|
|
11
|
+
_a);
|
|
12
|
+
/** Returns the vivid counterpart for a given color var if it's pastel; otherwise undefined. */
|
|
13
|
+
export function vividFor(colorVar) {
|
|
14
|
+
if (!colorVar)
|
|
15
|
+
return undefined;
|
|
16
|
+
return pastelToVividMap[colorVar];
|
|
17
|
+
}
|
|
18
|
+
/** Whether the provided CSS var corresponds to a known pastel color. */
|
|
19
|
+
export function isPastel(colorVar) {
|
|
20
|
+
return !!colorVar && Object.prototype.hasOwnProperty.call(pastelToVividMap, colorVar);
|
|
21
|
+
}
|
package/dist/const/variables.css
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
:root {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
--hd-color: var(--strawberry-pink);
|
|
3
|
+
/*Vivid*/
|
|
4
|
+
--strawberry-pink: #ed3b7d;
|
|
5
|
+
--pineapple-yellow: #ed9126;
|
|
6
|
+
--soda-blue: #2089ea;
|
|
7
|
+
--melon-green: #70af0a;
|
|
8
|
+
--grape-purple: #9707db;
|
|
9
|
+
--wrap-grey: #5f5f60;
|
|
10
|
+
/*Pastel*/
|
|
11
|
+
--peach-pink: #ffb4c3;
|
|
12
|
+
--lemon-yellow: #fff27a;
|
|
13
|
+
--sugar-blue: #aee4ff;
|
|
14
|
+
--matcha-green: #d8ff85;
|
|
15
|
+
--akebi-purple: #ddb2ff;
|
|
16
|
+
--cloud-grey: #a3a3a3;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
/* default header height */
|
|
19
|
+
--hd-height: var(--hd-normal);
|
|
20
|
+
/*header height*/
|
|
21
|
+
--hd-wide: 130px;
|
|
22
|
+
--hd-normal: 80px;
|
|
23
|
+
--hd-nallow: 60px;
|
|
24
24
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,3 +29,12 @@ export { default as Tabs } from './Tabs.svelte';
|
|
|
29
29
|
export { default as TabPanel } from './TabPanel.svelte';
|
|
30
30
|
export { default as Accordion } from './Accordion.svelte';
|
|
31
31
|
export { default as AccordionItem } from './AccordionItem.svelte';
|
|
32
|
+
export { default as Dialog } from './Dialog.svelte';
|
|
33
|
+
export { default as Badge } from './Badge.svelte';
|
|
34
|
+
export { default as SlideMenu } from './SlideMenu.svelte';
|
|
35
|
+
export type { MenuItem } from './types/slide-menu';
|
|
36
|
+
export { default as Toaster } from './Toaster.svelte';
|
|
37
|
+
export { toast, toasts, type ToastItem, type ToastVariant } from './toast';
|
|
38
|
+
export { default as Skeleton } from './Skeleton.svelte';
|
|
39
|
+
export { default as Breadcrumb } from './Breadcrumb.svelte';
|
|
40
|
+
export type { BreadcrumbItem } from './types/breadcrumb';
|
package/dist/index.js
CHANGED
|
@@ -30,3 +30,11 @@ export { default as Tabs } from './Tabs.svelte';
|
|
|
30
30
|
export { default as TabPanel } from './TabPanel.svelte';
|
|
31
31
|
export { default as Accordion } from './Accordion.svelte';
|
|
32
32
|
export { default as AccordionItem } from './AccordionItem.svelte';
|
|
33
|
+
export { default as Dialog } from './Dialog.svelte';
|
|
34
|
+
export { default as Badge } from './Badge.svelte';
|
|
35
|
+
// Drawer is now an internal primitive; use SlideMenu for public API
|
|
36
|
+
export { default as SlideMenu } from './SlideMenu.svelte';
|
|
37
|
+
export { default as Toaster } from './Toaster.svelte';
|
|
38
|
+
export { toast, toasts } from './toast';
|
|
39
|
+
export { default as Skeleton } from './Skeleton.svelte';
|
|
40
|
+
export { default as Breadcrumb } from './Breadcrumb.svelte';
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
export type ToastVariant = 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
export type ToastItem = {
|
|
4
|
+
id: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
variant: ToastVariant;
|
|
8
|
+
duration: number;
|
|
9
|
+
};
|
|
10
|
+
export type ShowOptions = {
|
|
11
|
+
title?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
variant?: ToastVariant;
|
|
14
|
+
duration?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const toasts: Writable<ToastItem[]>;
|
|
17
|
+
export declare function show(opts: ShowOptions): string;
|
|
18
|
+
export declare function dismiss(id: string): void;
|
|
19
|
+
export declare function clear(): void;
|
|
20
|
+
export declare const toast: {
|
|
21
|
+
show: typeof show;
|
|
22
|
+
success(message: string, title?: string, duration?: number): string;
|
|
23
|
+
error(message: string, title?: string, duration?: number): string;
|
|
24
|
+
warning(message: string, title?: string, duration?: number): string;
|
|
25
|
+
info(message: string, title?: string, duration?: number): string;
|
|
26
|
+
dismiss: typeof dismiss;
|
|
27
|
+
clear: typeof clear;
|
|
28
|
+
};
|
|
29
|
+
export declare const variantColor: Record<ToastVariant, string>;
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { writable } from 'svelte/store';
|
|
11
|
+
import { CCLVividColor } from './const/config';
|
|
12
|
+
export var toasts = writable([]);
|
|
13
|
+
function genId() {
|
|
14
|
+
return Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
15
|
+
}
|
|
16
|
+
// Default auto-dismiss duration held internally
|
|
17
|
+
var DEFAULT_DURATION = 3000;
|
|
18
|
+
export function show(opts) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var id = genId();
|
|
21
|
+
var item = {
|
|
22
|
+
id: id,
|
|
23
|
+
title: opts.title,
|
|
24
|
+
message: opts.message,
|
|
25
|
+
variant: (_a = opts.variant) !== null && _a !== void 0 ? _a : 'info',
|
|
26
|
+
duration: (_b = opts.duration) !== null && _b !== void 0 ? _b : DEFAULT_DURATION
|
|
27
|
+
};
|
|
28
|
+
toasts.update(function (list) { return __spreadArray([item], list, true).slice(0, 50); });
|
|
29
|
+
if (typeof window !== 'undefined' && item.duration > 0) {
|
|
30
|
+
window.setTimeout(function () { return dismiss(id); }, item.duration);
|
|
31
|
+
}
|
|
32
|
+
return id;
|
|
33
|
+
}
|
|
34
|
+
export function dismiss(id) {
|
|
35
|
+
toasts.update(function (list) { return list.filter(function (t) { return t.id !== id; }); });
|
|
36
|
+
}
|
|
37
|
+
export function clear() {
|
|
38
|
+
toasts.set([]);
|
|
39
|
+
}
|
|
40
|
+
export var toast = {
|
|
41
|
+
show: show,
|
|
42
|
+
success: function (message, title, duration) {
|
|
43
|
+
if (title === void 0) { title = 'Success'; }
|
|
44
|
+
return show({ message: message, title: title, variant: 'success', duration: duration });
|
|
45
|
+
},
|
|
46
|
+
error: function (message, title, duration) {
|
|
47
|
+
if (title === void 0) { title = 'Error'; }
|
|
48
|
+
return show({ message: message, title: title, variant: 'error', duration: duration });
|
|
49
|
+
},
|
|
50
|
+
warning: function (message, title, duration) {
|
|
51
|
+
if (title === void 0) { title = 'Warning'; }
|
|
52
|
+
return show({ message: message, title: title, variant: 'warning', duration: duration });
|
|
53
|
+
},
|
|
54
|
+
info: function (message, title, duration) {
|
|
55
|
+
if (title === void 0) { title = 'Info'; }
|
|
56
|
+
return show({ message: message, title: title, variant: 'info', duration: duration });
|
|
57
|
+
},
|
|
58
|
+
dismiss: dismiss,
|
|
59
|
+
clear: clear
|
|
60
|
+
};
|
|
61
|
+
export var variantColor = {
|
|
62
|
+
success: CCLVividColor.MELON_GREEN,
|
|
63
|
+
error: CCLVividColor.STRAWBERRY_PINK,
|
|
64
|
+
warning: CCLVividColor.PINEAPPLE_YELLOW,
|
|
65
|
+
info: CCLVividColor.SODA_BLUE
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|