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/Accordion.svelte
CHANGED
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext } from 'svelte';
|
|
3
|
+
import { writable } from 'svelte/store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 複数の項目を同時に開けるようにするかどうか
|
|
7
|
+
* @default false
|
|
8
|
+
* @type boolean
|
|
9
|
+
*/
|
|
10
|
+
export let multiple: boolean = false;
|
|
11
|
+
|
|
12
|
+
import { ACCORDION_CONTEXT_KEY } from './scripts/accordionContext';
|
|
13
|
+
|
|
14
|
+
const openItems = writable<Set<string>>(new Set());
|
|
15
|
+
|
|
16
|
+
function toggleItem(label: string) {
|
|
17
|
+
openItems.update((currentOpenItems) => {
|
|
18
|
+
const newOpenItems = new Set(currentOpenItems);
|
|
19
|
+
if (newOpenItems.has(label)) {
|
|
20
|
+
newOpenItems.delete(label);
|
|
21
|
+
} else {
|
|
22
|
+
if (!multiple) {
|
|
23
|
+
newOpenItems.clear();
|
|
24
|
+
}
|
|
25
|
+
newOpenItems.add(label);
|
|
14
26
|
}
|
|
15
|
-
newOpenItems
|
|
27
|
+
return newOpenItems;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setContext(ACCORDION_CONTEXT_KEY, {
|
|
32
|
+
openItems,
|
|
33
|
+
toggleItem,
|
|
34
|
+
initiallyOpen: (label: string) => {
|
|
35
|
+
openItems.update((items) => items.add(label));
|
|
16
36
|
}
|
|
17
|
-
return newOpenItems;
|
|
18
37
|
});
|
|
19
|
-
}
|
|
20
|
-
setContext(ACCORDION_CONTEXT_KEY, {
|
|
21
|
-
openItems,
|
|
22
|
-
toggleItem,
|
|
23
|
-
initiallyOpen: (label) => {
|
|
24
|
-
openItems.update((items) => items.add(label));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
38
|
</script>
|
|
28
39
|
|
|
29
40
|
<div class="accordion-wrapper" role="presentation">
|
|
30
|
-
|
|
41
|
+
<slot />
|
|
31
42
|
</div>
|
|
32
43
|
|
|
33
44
|
<style>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
.accordion-wrapper {
|
|
46
|
+
border: 1px solid #e0e0e0;
|
|
47
|
+
border-radius: 8px;
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
}
|
|
39
50
|
</style>
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
9
11
|
};
|
|
10
|
-
|
|
11
|
-
[evt: string]: CustomEvent<any>;
|
|
12
|
-
};
|
|
13
|
-
slots: {
|
|
14
|
-
default: {};
|
|
15
|
-
};
|
|
16
|
-
exports?: {} | undefined;
|
|
17
|
-
bindings?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
export type AccordionProps = typeof __propDef.props;
|
|
20
|
-
export type AccordionEvents = typeof __propDef.events;
|
|
21
|
-
export type AccordionSlots = typeof __propDef.slots;
|
|
22
|
-
export default class Accordion extends SvelteComponent<AccordionProps, AccordionEvents, AccordionSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
23
13
|
}
|
|
24
|
-
|
|
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 Accordion: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
/**
|
|
21
|
+
* 複数の項目を同時に開けるようにするかどうか
|
|
22
|
+
* @default false
|
|
23
|
+
* @type boolean
|
|
24
|
+
*/ multiple?: boolean;
|
|
25
|
+
}, {
|
|
26
|
+
default: {};
|
|
27
|
+
}>, {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
}, {
|
|
30
|
+
default: {};
|
|
31
|
+
}, {}, string>;
|
|
32
|
+
type Accordion = InstanceType<typeof Accordion>;
|
|
33
|
+
export default Accordion;
|
|
@@ -1,96 +1,129 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onMount } from 'svelte';
|
|
3
|
+
import { writable, type Readable } from 'svelte/store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 項目のヘッダーとして常に表示されるテキスト
|
|
7
|
+
* @type string
|
|
8
|
+
*/
|
|
9
|
+
export let label: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 項目の初期状態を開いた状態にするかどうか
|
|
13
|
+
* @default false
|
|
14
|
+
* @type boolean
|
|
15
|
+
*/
|
|
16
|
+
export let isOpen: boolean = false;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ヘッダーの背景色
|
|
20
|
+
* @type {string | undefined}
|
|
21
|
+
*/
|
|
22
|
+
export let headerColor: string | undefined = undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* コンテンツエリアの背景色
|
|
26
|
+
* @type {string | undefined}
|
|
27
|
+
*/
|
|
28
|
+
export let contentColor: string | undefined = undefined;
|
|
29
|
+
|
|
30
|
+
import { ACCORDION_CONTEXT_KEY } from './scripts/accordionContext';
|
|
31
|
+
|
|
32
|
+
interface AccordionContext {
|
|
33
|
+
openItems: Readable<Set<string>>;
|
|
34
|
+
toggleItem: (label: string) => void;
|
|
35
|
+
initiallyOpen: (label: string) => void;
|
|
12
36
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
37
|
+
|
|
38
|
+
const { openItems, toggleItem, initiallyOpen } =
|
|
39
|
+
getContext<AccordionContext>(ACCORDION_CONTEXT_KEY);
|
|
40
|
+
|
|
41
|
+
onMount(() => {
|
|
42
|
+
if (isOpen) {
|
|
43
|
+
initiallyOpen(label);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let isContentOpen = false;
|
|
48
|
+
$: isContentOpen = $openItems.has(label);
|
|
16
49
|
</script>
|
|
17
50
|
|
|
18
51
|
<div
|
|
19
|
-
|
|
20
|
-
|
|
52
|
+
class="accordion-item"
|
|
53
|
+
style={`${headerColor ? `--header-bg-color: var(${headerColor});` : ''}${contentColor ? `--content-bg-color: var(${contentColor});` : ''}`}
|
|
21
54
|
>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
<h2 class="accordion-header">
|
|
56
|
+
<button
|
|
57
|
+
class="accordion-button"
|
|
58
|
+
aria-expanded={isContentOpen}
|
|
59
|
+
aria-controls={`accordion-panel-${label}`}
|
|
60
|
+
on:click={() => toggleItem(label)}
|
|
61
|
+
>
|
|
62
|
+
<span class="button-label">{label}</span>
|
|
63
|
+
<span class="accordion-icon" class:open={isContentOpen} aria-hidden="true">▼</span>
|
|
64
|
+
</button>
|
|
65
|
+
</h2>
|
|
66
|
+
{#if isContentOpen}
|
|
67
|
+
<div
|
|
68
|
+
class="accordion-content"
|
|
69
|
+
id={`accordion-panel-${label}`}
|
|
70
|
+
role="region"
|
|
71
|
+
aria-labelledby={`accordion-button-${label}`}
|
|
72
|
+
>
|
|
73
|
+
<div class="content-padding">
|
|
74
|
+
<slot />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
{/if}
|
|
45
78
|
</div>
|
|
46
79
|
|
|
47
80
|
<style>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
.accordion-item {
|
|
82
|
+
border-bottom: 1px solid #e0e0e0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.accordion-item:last-child {
|
|
86
|
+
border-bottom: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.accordion-header {
|
|
90
|
+
margin: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.accordion-button {
|
|
94
|
+
width: 100%;
|
|
95
|
+
display: flex;
|
|
96
|
+
justify-content: space-between;
|
|
97
|
+
align-items: center;
|
|
98
|
+
padding: 16px 20px;
|
|
99
|
+
font-size: 1rem;
|
|
100
|
+
font-weight: 600;
|
|
101
|
+
color: #333;
|
|
102
|
+
background-color: var(--header-bg-color, #f9f9f9);
|
|
103
|
+
border: none;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
text-align: left;
|
|
106
|
+
transition: filter 0.2s ease-in-out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.accordion-button:hover {
|
|
110
|
+
filter: brightness(95%);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.accordion-icon {
|
|
114
|
+
transition: transform 0.2s ease-in-out;
|
|
115
|
+
transform: rotate(0deg);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.accordion-icon.open {
|
|
119
|
+
transform: rotate(180deg);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.accordion-content {
|
|
123
|
+
background-color: var(--content-bg-color, white);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.content-padding {
|
|
127
|
+
padding: 16px 20px;
|
|
128
|
+
}
|
|
96
129
|
</style>
|
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @type boolean
|
|
12
|
-
*/ isOpen?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* ヘッダーの背景色
|
|
15
|
-
* @type {string | undefined}
|
|
16
|
-
*/ headerColor?: string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* コンテンツエリアの背景色
|
|
19
|
-
* @type {string | undefined}
|
|
20
|
-
*/ contentColor?: string | undefined;
|
|
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;
|
|
21
11
|
};
|
|
22
|
-
|
|
23
|
-
[evt: string]: CustomEvent<any>;
|
|
24
|
-
};
|
|
25
|
-
slots: {
|
|
26
|
-
default: {};
|
|
27
|
-
};
|
|
28
|
-
exports?: {} | undefined;
|
|
29
|
-
bindings?: string | undefined;
|
|
30
|
-
};
|
|
31
|
-
export type AccordionItemProps = typeof __propDef.props;
|
|
32
|
-
export type AccordionItemEvents = typeof __propDef.events;
|
|
33
|
-
export type AccordionItemSlots = typeof __propDef.slots;
|
|
34
|
-
export default class AccordionItem extends SvelteComponent<AccordionItemProps, AccordionItemEvents, AccordionItemSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
35
13
|
}
|
|
36
|
-
|
|
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 AccordionItem: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
/**
|
|
21
|
+
* 項目のヘッダーとして常に表示されるテキスト
|
|
22
|
+
* @type string
|
|
23
|
+
*/ label: string;
|
|
24
|
+
/**
|
|
25
|
+
* 項目の初期状態を開いた状態にするかどうか
|
|
26
|
+
* @default false
|
|
27
|
+
* @type boolean
|
|
28
|
+
*/ isOpen?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* ヘッダーの背景色
|
|
31
|
+
* @type {string | undefined}
|
|
32
|
+
*/ headerColor?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* コンテンツエリアの背景色
|
|
35
|
+
* @type {string | undefined}
|
|
36
|
+
*/ contentColor?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
default: {};
|
|
39
|
+
}>, {
|
|
40
|
+
[evt: string]: CustomEvent<any>;
|
|
41
|
+
}, {
|
|
42
|
+
default: {};
|
|
43
|
+
}, {}, string>;
|
|
44
|
+
type AccordionItem = InstanceType<typeof AccordionItem>;
|
|
45
|
+
export default AccordionItem;
|
package/dist/Alert.svelte
CHANGED
|
@@ -1,95 +1,124 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { CCLVividColor } from './const/config';
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
|
|
5
|
+
const dispatch = createEventDispatcher();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The message to display in the alert.
|
|
9
|
+
* @type {string}
|
|
10
|
+
*/
|
|
11
|
+
export let message: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The type of the alert, which determines its styling.
|
|
15
|
+
* @type {'success' | 'error' | 'warning' | 'info'}
|
|
16
|
+
* @default 'info'
|
|
17
|
+
*/
|
|
18
|
+
export let type: 'success' | 'error' | 'warning' | 'info' = 'info';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether the alert can be dismissed by the user.
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
export let dismissible: boolean = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the alert should have an outline style.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
export let outline: boolean = false;
|
|
33
|
+
|
|
34
|
+
let baseColor: string;
|
|
35
|
+
let computedBgColor: string;
|
|
36
|
+
let computedBorderColor: string;
|
|
37
|
+
let textColor: string;
|
|
38
|
+
|
|
39
|
+
$: {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'success':
|
|
42
|
+
baseColor = CCLVividColor.MELON_GREEN;
|
|
43
|
+
break;
|
|
44
|
+
case 'error':
|
|
45
|
+
baseColor = CCLVividColor.STRAWBERRY_PINK;
|
|
46
|
+
break;
|
|
47
|
+
case 'warning':
|
|
48
|
+
baseColor = CCLVividColor.PINEAPPLE_YELLOW;
|
|
49
|
+
break;
|
|
50
|
+
case 'info':
|
|
51
|
+
baseColor = CCLVividColor.SODA_BLUE;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
baseColor = CCLVividColor.SODA_BLUE; // Fallback
|
|
39
55
|
}
|
|
56
|
+
|
|
57
|
+
if (outline) {
|
|
58
|
+
computedBgColor = 'transparent';
|
|
59
|
+
computedBorderColor = baseColor;
|
|
60
|
+
textColor = 'var(--wrap-grey)'; // Outline alerts usually have dark text for contrast
|
|
61
|
+
} else {
|
|
62
|
+
computedBgColor = baseColor;
|
|
63
|
+
computedBorderColor = 'transparent'; // No border for filled alerts
|
|
64
|
+
textColor = 'white'; // Default text color for filled alerts
|
|
65
|
+
if (type === 'warning') {
|
|
66
|
+
textColor = 'white'; // Ensure warning text is white for filled style
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function dismissAlert() {
|
|
72
|
+
dispatch('dismiss');
|
|
40
73
|
}
|
|
41
|
-
}
|
|
42
|
-
function dismissAlert() {
|
|
43
|
-
dispatch("dismiss");
|
|
44
|
-
}
|
|
45
74
|
</script>
|
|
46
75
|
|
|
47
76
|
<div
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
class="alert-wrapper"
|
|
78
|
+
class:dismissible
|
|
79
|
+
class:outline
|
|
80
|
+
style="background-color: var({computedBgColor}); color: {textColor}; border-color: var({computedBorderColor});"
|
|
52
81
|
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
<span class="alert-message">{message}</span>
|
|
83
|
+
{#if dismissible}
|
|
84
|
+
<button class="dismiss-button" on:click={dismissAlert} aria-label="Dismiss alert">
|
|
85
|
+
×
|
|
86
|
+
</button>
|
|
87
|
+
{/if}
|
|
59
88
|
</div>
|
|
60
89
|
|
|
61
90
|
<style>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
.alert-wrapper {
|
|
92
|
+
padding: 12px 20px;
|
|
93
|
+
border-radius: 8px;
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: space-between;
|
|
96
|
+
align-items: center;
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
font-weight: 500;
|
|
99
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
100
|
+
margin-bottom: 10px; /* Add some spacing when multiple alerts are shown */
|
|
101
|
+
border: 2px solid; /* Use solid border, color set by style attribute */
|
|
102
|
+
}
|
|
74
103
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
104
|
+
.alert-message {
|
|
105
|
+
flex-grow: 1;
|
|
106
|
+
}
|
|
78
107
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
.dismiss-button {
|
|
109
|
+
background: none;
|
|
110
|
+
border: none;
|
|
111
|
+
color: inherit; /* Inherit text color from parent */
|
|
112
|
+
font-size: 20px;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
margin-left: 15px;
|
|
115
|
+
padding: 0;
|
|
116
|
+
line-height: 1;
|
|
117
|
+
opacity: 0.7;
|
|
118
|
+
transition: opacity 0.2s ease-in-out;
|
|
119
|
+
}
|
|
91
120
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
.dismiss-button:hover {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
}
|
|
95
124
|
</style>
|