@rkosafo/cai.components 0.0.78 → 0.0.80
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/README.md +8 -8
- package/dist/baseEditor/index.svelte +32 -32
- package/dist/builders/filters/FilterBuilder.svelte +641 -641
- package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
- package/dist/forms/FormClEditor/ClEdito.svelte +68 -68
- package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
- package/dist/forms/FormFileUpload/FormFileUplad.svelte +134 -134
- package/dist/forms/FormInput/FormInput.svelte +87 -87
- package/dist/forms/FormRadio/FormRadio.svelte +53 -53
- package/dist/forms/FormSelect/FormSelect.svelte +88 -88
- package/dist/forms/FormTextarea/FormTextarea.svelte +78 -78
- package/dist/forms/button-toggle/ButtonToggle.svelte +119 -119
- package/dist/forms/button-toggle/CheckIcon.svelte +28 -28
- package/dist/forms/checkbox/Checkbox.svelte +82 -82
- package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
- package/dist/forms/datepicker/Datepicker.svelte +707 -707
- package/dist/forms/form/Form.svelte +69 -69
- package/dist/forms/input/Input.svelte +363 -363
- package/dist/forms/label/Label.svelte +38 -38
- package/dist/forms/radio/Radio.svelte +48 -48
- package/dist/forms/radio/RadioButton.svelte +22 -22
- package/dist/forms/select/Select.svelte +56 -56
- package/dist/forms/textarea/Textarea.svelte +165 -165
- package/dist/forms/toggle/Toggle.svelte +70 -70
- package/dist/layout/Chat/CategorySelector.svelte +52 -52
- package/dist/layout/Chat/ChatEntry.svelte +246 -246
- package/dist/layout/Chat/ChatEntrySkeleton.svelte +81 -81
- package/dist/layout/Chat/ChatHeader.svelte +172 -172
- package/dist/layout/Chat/ChatInput.svelte +207 -207
- package/dist/layout/Chat/DraggableWindow.svelte +230 -230
- package/dist/layout/Chat/PreviewPage.svelte +182 -182
- package/dist/layout/Chat/RichText.svelte +216 -216
- package/dist/layout/ComponentCanvas/Canvas.svelte +40 -40
- package/dist/layout/ComponentCanvas/ComponentRenderer.svelte +85 -85
- package/dist/layout/TF/Content/Content.svelte +21 -21
- package/dist/layout/TF/Header/Header.svelte +166 -166
- package/dist/layout/TF/Sidebar/Sidebar.svelte +148 -148
- package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
- package/dist/layout/mailing/MailPaginator.svelte +36 -36
- package/dist/layout/mailing/MailSidebar.svelte +39 -39
- package/dist/layout/mailing/MailToolBar.svelte +174 -174
- package/dist/layout/mailing/MailingContent.svelte +10 -10
- package/dist/layout/mailing/MailingHeader.svelte +55 -55
- package/dist/layout/mailing/MailingMessageCard.svelte +112 -112
- package/dist/layout/mailing/MailingMessageViewer.svelte +87 -87
- package/dist/layout/mailing/MailingModule.svelte +448 -448
- package/dist/styles/docs.css +615 -615
- package/dist/styles/tf-layout.css +185 -185
- package/dist/themes/ThemeProvider.svelte +20 -20
- package/dist/types/index.d.ts +2 -0
- package/dist/typography/heading/Heading.svelte +35 -35
- package/dist/ui/accordion/Accordion.svelte +49 -49
- package/dist/ui/accordion/AccordionItem.svelte +173 -173
- package/dist/ui/alert/Alert.svelte +83 -83
- package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
- package/dist/ui/avatar/Avatar.svelte +77 -77
- package/dist/ui/box/Box.svelte +28 -28
- package/dist/ui/breadcrumb/Breadcrumb.svelte +39 -39
- package/dist/ui/buttons/ActionButton.svelte +234 -234
- package/dist/ui/buttons/Button.svelte +102 -102
- package/dist/ui/buttons/GradientButton.svelte +59 -59
- package/dist/ui/datatable/Datatable.svelte +525 -525
- package/dist/ui/drawer/Drawer.svelte +300 -300
- package/dist/ui/dropdown/Dropdown.svelte +36 -36
- package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
- package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
- package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
- package/dist/ui/dropdown/DropdownItem.svelte +52 -52
- package/dist/ui/footer/Footer.svelte +15 -15
- package/dist/ui/footer/FooterBrand.svelte +37 -37
- package/dist/ui/footer/FooterCopyright.svelte +45 -45
- package/dist/ui/footer/FooterIcon.svelte +22 -22
- package/dist/ui/footer/FooterLink.svelte +33 -33
- package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
- package/dist/ui/icons/IconifyIcon.svelte +7 -7
- package/dist/ui/indicator/Indicator.svelte +42 -42
- package/dist/ui/modal/Modal.svelte +265 -265
- package/dist/ui/notificationList/NotificationList.svelte +123 -123
- package/dist/ui/pageLoader/PageLoader.svelte +14 -14
- package/dist/ui/pageLoader/PageLoader2.svelte +99 -0
- package/dist/ui/pageLoader/PageLoader2.svelte.d.ts +24 -0
- package/dist/ui/pageLoader/index.d.ts +2 -1
- package/dist/ui/pageLoader/index.js +2 -1
- package/dist/ui/paginate/Paginate.svelte +96 -96
- package/dist/ui/speedDial/SpeedDial.svelte +77 -77
- package/dist/ui/speedDial/SpeedDialButton.svelte +75 -75
- package/dist/ui/speedDial/SpeedDialTrigger.svelte +79 -79
- package/dist/ui/tab/Tab.svelte +93 -67
- package/dist/ui/table/Table.svelte +396 -396
- package/dist/ui/tableLoader/TableLoader.svelte +24 -24
- package/dist/ui/toast/Toast.svelte +337 -337
- package/dist/ui/toast/Toast.svelte.d.ts +10 -10
- package/dist/ui/toolbar/Toolbar.svelte +59 -59
- package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
- package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
- package/dist/ui/tooltip/Tooltip.svelte +51 -51
- package/dist/utils/Popper.svelte +257 -257
- package/dist/utils/closeButton/CloseButton.svelte +88 -88
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -3
- package/dist/utils/singleSelection.svelte.js +48 -48
- package/dist/youtube/index.svelte +12 -12
- package/package.json +1 -1
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
accordionItem,
|
|
4
|
-
type AccordionCtxType,
|
|
5
|
-
type AccordionItemProps,
|
|
6
|
-
type ParamsType
|
|
7
|
-
} from '../../index.js';
|
|
8
|
-
import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
|
|
9
|
-
import { useSingleSelection } from '../../utils/singleSelection.svelte.js';
|
|
10
|
-
import clsx from 'clsx';
|
|
11
|
-
import { getContext } from 'svelte';
|
|
12
|
-
import { slide } from 'svelte/transition';
|
|
13
|
-
|
|
14
|
-
let {
|
|
15
|
-
children,
|
|
16
|
-
header,
|
|
17
|
-
arrowup,
|
|
18
|
-
arrowdown,
|
|
19
|
-
open = $bindable(false),
|
|
20
|
-
activeClass,
|
|
21
|
-
inactiveClass,
|
|
22
|
-
transitionType = slide,
|
|
23
|
-
transitionParams,
|
|
24
|
-
class: className,
|
|
25
|
-
classes,
|
|
26
|
-
headerClass,
|
|
27
|
-
contentClass
|
|
28
|
-
}: AccordionItemProps = $props();
|
|
29
|
-
|
|
30
|
-
warnThemeDeprecation(
|
|
31
|
-
'AccordionItem',
|
|
32
|
-
{
|
|
33
|
-
headerClass,
|
|
34
|
-
contentClass,
|
|
35
|
-
activeClass,
|
|
36
|
-
inactiveClass
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
headerClass: 'button',
|
|
40
|
-
contentClass: 'content',
|
|
41
|
-
activeClass: 'active',
|
|
42
|
-
inactiveClass: 'inactive'
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
let styling: typeof classes = $derived(
|
|
47
|
-
classes ?? {
|
|
48
|
-
button: headerClass,
|
|
49
|
-
content: contentClass,
|
|
50
|
-
active: activeClass,
|
|
51
|
-
inactive: inactiveClass
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const ctx: AccordionCtxType = getContext('ctx') ?? {};
|
|
56
|
-
|
|
57
|
-
const ctxTransitionType = ctx.transitionType ?? transitionType;
|
|
58
|
-
// Check if transitionType is explicitly set to undefined in props
|
|
59
|
-
const useTransition =
|
|
60
|
-
transitionType === 'none' ? false : ctxTransitionType === 'none' ? false : true;
|
|
61
|
-
|
|
62
|
-
// Theme context
|
|
63
|
-
const theme = getTheme('accordionItem');
|
|
64
|
-
|
|
65
|
-
// single selection
|
|
66
|
-
const self = Symbol('accordion-item');
|
|
67
|
-
|
|
68
|
-
const updateSingleSelection = useSingleSelection<symbol>((value) => (open = value === self));
|
|
69
|
-
|
|
70
|
-
$effect(() => {
|
|
71
|
-
updateSingleSelection(open, self);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const handleToggle = () => {
|
|
75
|
-
open = !open;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const { base, button, content, active, inactive } = $derived(
|
|
79
|
-
accordionItem({ flush: ctx.flush, open })
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
let buttonClass = $derived(
|
|
83
|
-
clsx(
|
|
84
|
-
open && !ctx.flush && (styling.active || ctx.activeClass || active()),
|
|
85
|
-
!open && !ctx.flush && (styling.inactive || ctx.inactiveClass || inactive())
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
<h2 class={base({ class: clsx(theme?.base, className) })}>
|
|
91
|
-
<button
|
|
92
|
-
type="button"
|
|
93
|
-
onclick={handleToggle}
|
|
94
|
-
class={button({ class: clsx(buttonClass, theme?.button, styling.button) })}
|
|
95
|
-
aria-expanded={open}
|
|
96
|
-
>
|
|
97
|
-
{#if header}
|
|
98
|
-
{@render header()}
|
|
99
|
-
{#if open}
|
|
100
|
-
{#if !arrowup}
|
|
101
|
-
<svg
|
|
102
|
-
class="h-3 w-3 text-gray-800 dark:text-white"
|
|
103
|
-
aria-hidden="true"
|
|
104
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
105
|
-
fill="none"
|
|
106
|
-
viewBox="0 0 10 6"
|
|
107
|
-
>
|
|
108
|
-
<path
|
|
109
|
-
stroke="currentColor"
|
|
110
|
-
stroke-linecap="round"
|
|
111
|
-
stroke-linejoin="round"
|
|
112
|
-
stroke-width="2"
|
|
113
|
-
d="M9 5 5 1 1 5"
|
|
114
|
-
/>
|
|
115
|
-
</svg>
|
|
116
|
-
{:else}
|
|
117
|
-
{@render arrowup()}
|
|
118
|
-
{/if}
|
|
119
|
-
{:else if !arrowdown}
|
|
120
|
-
<svg
|
|
121
|
-
class="h-3 w-3 text-gray-800 dark:text-white"
|
|
122
|
-
aria-hidden="true"
|
|
123
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
124
|
-
fill="none"
|
|
125
|
-
viewBox="0 0 10 6"
|
|
126
|
-
>
|
|
127
|
-
<path
|
|
128
|
-
stroke="currentColor"
|
|
129
|
-
stroke-linecap="round"
|
|
130
|
-
stroke-linejoin="round"
|
|
131
|
-
stroke-width="2"
|
|
132
|
-
d="m1 1 4 4 4-4"
|
|
133
|
-
/>
|
|
134
|
-
</svg>
|
|
135
|
-
{:else}
|
|
136
|
-
{@render arrowdown()}
|
|
137
|
-
{/if}
|
|
138
|
-
{/if}
|
|
139
|
-
</button>
|
|
140
|
-
</h2>
|
|
141
|
-
|
|
142
|
-
{#if useTransition}
|
|
143
|
-
{#if open && transitionType !== 'none'}
|
|
144
|
-
<div transition:transitionType={transitionParams as ParamsType}>
|
|
145
|
-
<div class={content({ class: clsx(theme?.content, styling.content) })}>
|
|
146
|
-
{@render children()}
|
|
147
|
-
</div>
|
|
148
|
-
</div>
|
|
149
|
-
{/if}
|
|
150
|
-
{:else}
|
|
151
|
-
<div class={open ? 'block' : 'hidden'}>
|
|
152
|
-
<div class={content({ class: clsx(theme?.content, styling.content) })}>
|
|
153
|
-
{@render children()}
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
{/if}
|
|
157
|
-
|
|
158
|
-
<!--
|
|
159
|
-
## Props
|
|
160
|
-
@prop children
|
|
161
|
-
@prop header
|
|
162
|
-
@prop arrowup
|
|
163
|
-
@prop arrowdown
|
|
164
|
-
@prop open = $bindable(false)
|
|
165
|
-
@prop activeClass
|
|
166
|
-
@prop inactiveClass
|
|
167
|
-
@prop transitionType = slide
|
|
168
|
-
@prop transitionParams
|
|
169
|
-
@prop class: className
|
|
170
|
-
@prop classes
|
|
171
|
-
@prop headerClass
|
|
172
|
-
@prop contentClass
|
|
173
|
-
-->
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
accordionItem,
|
|
4
|
+
type AccordionCtxType,
|
|
5
|
+
type AccordionItemProps,
|
|
6
|
+
type ParamsType
|
|
7
|
+
} from '../../index.js';
|
|
8
|
+
import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
|
|
9
|
+
import { useSingleSelection } from '../../utils/singleSelection.svelte.js';
|
|
10
|
+
import clsx from 'clsx';
|
|
11
|
+
import { getContext } from 'svelte';
|
|
12
|
+
import { slide } from 'svelte/transition';
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
header,
|
|
17
|
+
arrowup,
|
|
18
|
+
arrowdown,
|
|
19
|
+
open = $bindable(false),
|
|
20
|
+
activeClass,
|
|
21
|
+
inactiveClass,
|
|
22
|
+
transitionType = slide,
|
|
23
|
+
transitionParams,
|
|
24
|
+
class: className,
|
|
25
|
+
classes,
|
|
26
|
+
headerClass,
|
|
27
|
+
contentClass
|
|
28
|
+
}: AccordionItemProps = $props();
|
|
29
|
+
|
|
30
|
+
warnThemeDeprecation(
|
|
31
|
+
'AccordionItem',
|
|
32
|
+
{
|
|
33
|
+
headerClass,
|
|
34
|
+
contentClass,
|
|
35
|
+
activeClass,
|
|
36
|
+
inactiveClass
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
headerClass: 'button',
|
|
40
|
+
contentClass: 'content',
|
|
41
|
+
activeClass: 'active',
|
|
42
|
+
inactiveClass: 'inactive'
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
let styling: typeof classes = $derived(
|
|
47
|
+
classes ?? {
|
|
48
|
+
button: headerClass,
|
|
49
|
+
content: contentClass,
|
|
50
|
+
active: activeClass,
|
|
51
|
+
inactive: inactiveClass
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const ctx: AccordionCtxType = getContext('ctx') ?? {};
|
|
56
|
+
|
|
57
|
+
const ctxTransitionType = ctx.transitionType ?? transitionType;
|
|
58
|
+
// Check if transitionType is explicitly set to undefined in props
|
|
59
|
+
const useTransition =
|
|
60
|
+
transitionType === 'none' ? false : ctxTransitionType === 'none' ? false : true;
|
|
61
|
+
|
|
62
|
+
// Theme context
|
|
63
|
+
const theme = getTheme('accordionItem');
|
|
64
|
+
|
|
65
|
+
// single selection
|
|
66
|
+
const self = Symbol('accordion-item');
|
|
67
|
+
|
|
68
|
+
const updateSingleSelection = useSingleSelection<symbol>((value) => (open = value === self));
|
|
69
|
+
|
|
70
|
+
$effect(() => {
|
|
71
|
+
updateSingleSelection(open, self);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const handleToggle = () => {
|
|
75
|
+
open = !open;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { base, button, content, active, inactive } = $derived(
|
|
79
|
+
accordionItem({ flush: ctx.flush, open })
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
let buttonClass = $derived(
|
|
83
|
+
clsx(
|
|
84
|
+
open && !ctx.flush && (styling.active || ctx.activeClass || active()),
|
|
85
|
+
!open && !ctx.flush && (styling.inactive || ctx.inactiveClass || inactive())
|
|
86
|
+
)
|
|
87
|
+
);
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<h2 class={base({ class: clsx(theme?.base, className) })}>
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
onclick={handleToggle}
|
|
94
|
+
class={button({ class: clsx(buttonClass, theme?.button, styling.button) })}
|
|
95
|
+
aria-expanded={open}
|
|
96
|
+
>
|
|
97
|
+
{#if header}
|
|
98
|
+
{@render header()}
|
|
99
|
+
{#if open}
|
|
100
|
+
{#if !arrowup}
|
|
101
|
+
<svg
|
|
102
|
+
class="h-3 w-3 text-gray-800 dark:text-white"
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
105
|
+
fill="none"
|
|
106
|
+
viewBox="0 0 10 6"
|
|
107
|
+
>
|
|
108
|
+
<path
|
|
109
|
+
stroke="currentColor"
|
|
110
|
+
stroke-linecap="round"
|
|
111
|
+
stroke-linejoin="round"
|
|
112
|
+
stroke-width="2"
|
|
113
|
+
d="M9 5 5 1 1 5"
|
|
114
|
+
/>
|
|
115
|
+
</svg>
|
|
116
|
+
{:else}
|
|
117
|
+
{@render arrowup()}
|
|
118
|
+
{/if}
|
|
119
|
+
{:else if !arrowdown}
|
|
120
|
+
<svg
|
|
121
|
+
class="h-3 w-3 text-gray-800 dark:text-white"
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
124
|
+
fill="none"
|
|
125
|
+
viewBox="0 0 10 6"
|
|
126
|
+
>
|
|
127
|
+
<path
|
|
128
|
+
stroke="currentColor"
|
|
129
|
+
stroke-linecap="round"
|
|
130
|
+
stroke-linejoin="round"
|
|
131
|
+
stroke-width="2"
|
|
132
|
+
d="m1 1 4 4 4-4"
|
|
133
|
+
/>
|
|
134
|
+
</svg>
|
|
135
|
+
{:else}
|
|
136
|
+
{@render arrowdown()}
|
|
137
|
+
{/if}
|
|
138
|
+
{/if}
|
|
139
|
+
</button>
|
|
140
|
+
</h2>
|
|
141
|
+
|
|
142
|
+
{#if useTransition}
|
|
143
|
+
{#if open && transitionType !== 'none'}
|
|
144
|
+
<div transition:transitionType={transitionParams as ParamsType}>
|
|
145
|
+
<div class={content({ class: clsx(theme?.content, styling.content) })}>
|
|
146
|
+
{@render children()}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
{/if}
|
|
150
|
+
{:else}
|
|
151
|
+
<div class={open ? 'block' : 'hidden'}>
|
|
152
|
+
<div class={content({ class: clsx(theme?.content, styling.content) })}>
|
|
153
|
+
{@render children()}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
{/if}
|
|
157
|
+
|
|
158
|
+
<!--
|
|
159
|
+
## Props
|
|
160
|
+
@prop children
|
|
161
|
+
@prop header
|
|
162
|
+
@prop arrowup
|
|
163
|
+
@prop arrowdown
|
|
164
|
+
@prop open = $bindable(false)
|
|
165
|
+
@prop activeClass
|
|
166
|
+
@prop inactiveClass
|
|
167
|
+
@prop transitionType = slide
|
|
168
|
+
@prop transitionParams
|
|
169
|
+
@prop class: className
|
|
170
|
+
@prop classes
|
|
171
|
+
@prop headerClass
|
|
172
|
+
@prop contentClass
|
|
173
|
+
-->
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { fade } from 'svelte/transition';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { getTheme } from '../../index.js';
|
|
5
|
-
import type { AlertVariants } from './theme.js';
|
|
6
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
|
-
import type { Component, Snippet } from 'svelte';
|
|
8
|
-
import type { AlertProps, ParamsType, TransitionFunc } from '../../types/index.js';
|
|
9
|
-
import { createDismissableContext } from '../../utils/dismissable.js';
|
|
10
|
-
import { CloseButton } from '../../utils/closeButton/index.js';
|
|
11
|
-
import { alert } from './theme.js';
|
|
12
|
-
|
|
13
|
-
let {
|
|
14
|
-
children,
|
|
15
|
-
icon,
|
|
16
|
-
alertStatus = $bindable(true),
|
|
17
|
-
closeIcon: CloseIcon,
|
|
18
|
-
color = 'primary',
|
|
19
|
-
rounded = true,
|
|
20
|
-
border,
|
|
21
|
-
class: className,
|
|
22
|
-
dismissable,
|
|
23
|
-
transition = fade,
|
|
24
|
-
params,
|
|
25
|
-
...restProps
|
|
26
|
-
}: AlertProps = $props();
|
|
27
|
-
|
|
28
|
-
// Theme context
|
|
29
|
-
const theme = getTheme('alert');
|
|
30
|
-
|
|
31
|
-
let divCls = $derived(
|
|
32
|
-
alert({
|
|
33
|
-
color,
|
|
34
|
-
rounded,
|
|
35
|
-
border,
|
|
36
|
-
icon: !!icon,
|
|
37
|
-
dismissable,
|
|
38
|
-
class: clsx(theme, className)
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
let ref: HTMLDivElement | undefined = $state(undefined);
|
|
43
|
-
|
|
44
|
-
function close(event: MouseEvent) {
|
|
45
|
-
if (ref?.dispatchEvent(new Event('close', { bubbles: true, cancelable: true }))) {
|
|
46
|
-
alertStatus = false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
createDismissableContext(close);
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
{#if alertStatus}
|
|
54
|
-
<div
|
|
55
|
-
role="alert"
|
|
56
|
-
bind:this={ref}
|
|
57
|
-
{...restProps}
|
|
58
|
-
transition:transition={params as ParamsType}
|
|
59
|
-
class={divCls}
|
|
60
|
-
>
|
|
61
|
-
{#if icon}
|
|
62
|
-
{@render icon()}
|
|
63
|
-
{/if}
|
|
64
|
-
|
|
65
|
-
{#if icon || dismissable}
|
|
66
|
-
<div>
|
|
67
|
-
{@render children()}
|
|
68
|
-
</div>
|
|
69
|
-
{:else}
|
|
70
|
-
{@render children()}
|
|
71
|
-
{/if}
|
|
72
|
-
|
|
73
|
-
{#if dismissable}
|
|
74
|
-
{#if CloseIcon}
|
|
75
|
-
<CloseButton class="-my-1.5 ms-auto -me-1.5" {color} ariaLabel="Remove alert">
|
|
76
|
-
<CloseIcon />
|
|
77
|
-
</CloseButton>
|
|
78
|
-
{:else}
|
|
79
|
-
<CloseButton class="-my-1.5 ms-auto -me-1.5" {color} ariaLabel="Remove alert" />
|
|
80
|
-
{/if}
|
|
81
|
-
{/if}
|
|
82
|
-
</div>
|
|
83
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { getTheme } from '../../index.js';
|
|
5
|
+
import type { AlertVariants } from './theme.js';
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
|
+
import type { Component, Snippet } from 'svelte';
|
|
8
|
+
import type { AlertProps, ParamsType, TransitionFunc } from '../../types/index.js';
|
|
9
|
+
import { createDismissableContext } from '../../utils/dismissable.js';
|
|
10
|
+
import { CloseButton } from '../../utils/closeButton/index.js';
|
|
11
|
+
import { alert } from './theme.js';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
icon,
|
|
16
|
+
alertStatus = $bindable(true),
|
|
17
|
+
closeIcon: CloseIcon,
|
|
18
|
+
color = 'primary',
|
|
19
|
+
rounded = true,
|
|
20
|
+
border,
|
|
21
|
+
class: className,
|
|
22
|
+
dismissable,
|
|
23
|
+
transition = fade,
|
|
24
|
+
params,
|
|
25
|
+
...restProps
|
|
26
|
+
}: AlertProps = $props();
|
|
27
|
+
|
|
28
|
+
// Theme context
|
|
29
|
+
const theme = getTheme('alert');
|
|
30
|
+
|
|
31
|
+
let divCls = $derived(
|
|
32
|
+
alert({
|
|
33
|
+
color,
|
|
34
|
+
rounded,
|
|
35
|
+
border,
|
|
36
|
+
icon: !!icon,
|
|
37
|
+
dismissable,
|
|
38
|
+
class: clsx(theme, className)
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let ref: HTMLDivElement | undefined = $state(undefined);
|
|
43
|
+
|
|
44
|
+
function close(event: MouseEvent) {
|
|
45
|
+
if (ref?.dispatchEvent(new Event('close', { bubbles: true, cancelable: true }))) {
|
|
46
|
+
alertStatus = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
createDismissableContext(close);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
{#if alertStatus}
|
|
54
|
+
<div
|
|
55
|
+
role="alert"
|
|
56
|
+
bind:this={ref}
|
|
57
|
+
{...restProps}
|
|
58
|
+
transition:transition={params as ParamsType}
|
|
59
|
+
class={divCls}
|
|
60
|
+
>
|
|
61
|
+
{#if icon}
|
|
62
|
+
{@render icon()}
|
|
63
|
+
{/if}
|
|
64
|
+
|
|
65
|
+
{#if icon || dismissable}
|
|
66
|
+
<div>
|
|
67
|
+
{@render children()}
|
|
68
|
+
</div>
|
|
69
|
+
{:else}
|
|
70
|
+
{@render children()}
|
|
71
|
+
{/if}
|
|
72
|
+
|
|
73
|
+
{#if dismissable}
|
|
74
|
+
{#if CloseIcon}
|
|
75
|
+
<CloseButton class="-my-1.5 ms-auto -me-1.5" {color} ariaLabel="Remove alert">
|
|
76
|
+
<CloseIcon />
|
|
77
|
+
</CloseButton>
|
|
78
|
+
{:else}
|
|
79
|
+
<CloseButton class="-my-1.5 ms-auto -me-1.5" {color} ariaLabel="Remove alert" />
|
|
80
|
+
{/if}
|
|
81
|
+
{/if}
|
|
82
|
+
</div>
|
|
83
|
+
{/if}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modal, Button, type AlertDialogProps } from '../../index.js';
|
|
3
|
-
|
|
4
|
-
let {
|
|
5
|
-
open = $bindable(false),
|
|
6
|
-
message = '',
|
|
7
|
-
icon = 'line-md:alert-circle',
|
|
8
|
-
disableYes = false,
|
|
9
|
-
busy = false,
|
|
10
|
-
iconColor = '',
|
|
11
|
-
confirmText = "Yes, I'm sure",
|
|
12
|
-
buttonType = 'button',
|
|
13
|
-
dismissable = true,
|
|
14
|
-
onCancel,
|
|
15
|
-
onYes
|
|
16
|
-
}: AlertDialogProps = $props();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<div class="fixed z-[2000]">
|
|
20
|
-
<Modal bind:open size="xs" {dismissable}>
|
|
21
|
-
<div class="text-center">
|
|
22
|
-
<iconify-icon {icon} style="font-size: 100px;" class={iconColor}></iconify-icon>
|
|
23
|
-
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{message}</h3>
|
|
24
|
-
<Button
|
|
25
|
-
type={buttonType}
|
|
26
|
-
disabled={disableYes || busy}
|
|
27
|
-
color="red"
|
|
28
|
-
class="mr-2"
|
|
29
|
-
onclick={onYes}
|
|
30
|
-
><div class="flex items-center gap-1">
|
|
31
|
-
{confirmText}
|
|
32
|
-
{#if busy}
|
|
33
|
-
<iconify-icon icon="svg-spinners:180-ring-with-bg" class="text-pink-600"></iconify-icon>
|
|
34
|
-
{/if}
|
|
35
|
-
</div></Button
|
|
36
|
-
>
|
|
37
|
-
<Button color="alternative" onclick={onCancel} disabled={busy}>No, cancel</Button>
|
|
38
|
-
</div>
|
|
39
|
-
</Modal>
|
|
40
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modal, Button, type AlertDialogProps } from '../../index.js';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
open = $bindable(false),
|
|
6
|
+
message = '',
|
|
7
|
+
icon = 'line-md:alert-circle',
|
|
8
|
+
disableYes = false,
|
|
9
|
+
busy = false,
|
|
10
|
+
iconColor = '',
|
|
11
|
+
confirmText = "Yes, I'm sure",
|
|
12
|
+
buttonType = 'button',
|
|
13
|
+
dismissable = true,
|
|
14
|
+
onCancel,
|
|
15
|
+
onYes
|
|
16
|
+
}: AlertDialogProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="fixed z-[2000]">
|
|
20
|
+
<Modal bind:open size="xs" {dismissable}>
|
|
21
|
+
<div class="text-center">
|
|
22
|
+
<iconify-icon {icon} style="font-size: 100px;" class={iconColor}></iconify-icon>
|
|
23
|
+
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{message}</h3>
|
|
24
|
+
<Button
|
|
25
|
+
type={buttonType}
|
|
26
|
+
disabled={disableYes || busy}
|
|
27
|
+
color="red"
|
|
28
|
+
class="mr-2"
|
|
29
|
+
onclick={onYes}
|
|
30
|
+
><div class="flex items-center gap-1">
|
|
31
|
+
{confirmText}
|
|
32
|
+
{#if busy}
|
|
33
|
+
<iconify-icon icon="svg-spinners:180-ring-with-bg" class="text-pink-600"></iconify-icon>
|
|
34
|
+
{/if}
|
|
35
|
+
</div></Button
|
|
36
|
+
>
|
|
37
|
+
<Button color="alternative" onclick={onCancel} disabled={busy}>No, cancel</Button>
|
|
38
|
+
</div>
|
|
39
|
+
</Modal>
|
|
40
|
+
</div>
|