@rkosafo/cai.components 0.0.1 → 0.0.3
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/baseEditor/index.svelte +32 -0
- package/dist/baseEditor/index.svelte.d.ts +18 -0
- package/dist/builders/filters/FilterBuilder.svelte +638 -0
- package/dist/builders/filters/FilterBuilder.svelte.d.ts +4 -0
- package/dist/builders/filters/index.d.ts +1 -0
- package/dist/builders/filters/index.js +1 -0
- package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -0
- package/dist/forms/FormCheckbox/FormCheckbox.svelte.d.ts +4 -0
- package/dist/forms/FormCheckbox/index.d.ts +1 -0
- package/dist/forms/FormCheckbox/index.js +1 -0
- package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -0
- package/dist/forms/FormDatepicker/FormDatepicker.svelte.d.ts +13 -0
- package/dist/forms/FormDatepicker/index.d.ts +1 -0
- package/dist/forms/FormDatepicker/index.js +1 -0
- package/dist/forms/FormInput/FormInput.svelte +87 -0
- package/dist/forms/FormInput/FormInput.svelte.d.ts +4 -0
- package/dist/forms/FormInput/index.d.ts +1 -0
- package/dist/forms/FormInput/index.js +1 -0
- package/dist/forms/FormRadio/FormRadio.svelte +53 -0
- package/dist/forms/FormRadio/FormRadio.svelte.d.ts +4 -0
- package/dist/forms/FormRadio/index.d.ts +1 -0
- package/dist/forms/FormRadio/index.js +1 -0
- package/dist/forms/FormSelect/FormSelect.svelte +86 -0
- package/dist/forms/FormSelect/FormSelect.svelte.d.ts +4 -0
- package/dist/forms/FormSelect/index.d.ts +1 -0
- package/dist/forms/FormSelect/index.js +1 -0
- package/dist/forms/FormTextarea/FormTextarea.svelte +77 -0
- package/dist/forms/FormTextarea/FormTextarea.svelte.d.ts +4 -0
- package/dist/forms/FormTextarea/index.d.ts +1 -0
- package/dist/forms/FormTextarea/index.js +1 -0
- package/dist/forms/checkbox/Checkbox.svelte +82 -0
- package/dist/forms/checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/forms/checkbox/CheckboxButton.svelte +92 -0
- package/dist/forms/checkbox/CheckboxButton.svelte.d.ts +18 -0
- package/dist/forms/checkbox/index.d.ts +3 -0
- package/dist/forms/checkbox/index.js +3 -0
- package/dist/forms/checkbox/theme.d.ts +317 -0
- package/dist/forms/checkbox/theme.js +113 -0
- package/dist/forms/datepicker/Datepicker.svelte +706 -0
- package/dist/forms/datepicker/Datepicker.svelte.d.ts +41 -0
- package/dist/forms/datepicker/index.d.ts +2 -0
- package/dist/forms/datepicker/index.js +2 -0
- package/dist/forms/datepicker/theme.d.ts +385 -0
- package/dist/forms/datepicker/theme.js +56 -0
- package/dist/forms/form/Form.svelte +69 -0
- package/dist/forms/form/Form.svelte.d.ts +6 -0
- package/dist/forms/form/index.d.ts +2 -0
- package/dist/forms/form/index.js +2 -0
- package/dist/forms/input/Input.svelte +363 -0
- package/dist/forms/input/Input.svelte.d.ts +4 -0
- package/dist/forms/input/index.d.ts +4 -0
- package/dist/forms/input/index.js +5 -0
- package/dist/forms/input/theme.d.ts +301 -0
- package/dist/forms/input/theme.js +100 -0
- package/dist/forms/label/Label.svelte +38 -0
- package/dist/forms/label/Label.svelte.d.ts +15 -0
- package/dist/forms/label/index.d.ts +2 -0
- package/dist/forms/label/index.js +2 -0
- package/dist/forms/label/theme.d.ts +75 -0
- package/dist/forms/label/theme.js +29 -0
- package/dist/forms/radio/Radio.svelte +48 -0
- package/dist/forms/radio/Radio.svelte.d.ts +25 -0
- package/dist/forms/radio/RadioButton.svelte +22 -0
- package/dist/forms/radio/RadioButton.svelte.d.ts +25 -0
- package/dist/forms/radio/index.d.ts +3 -0
- package/dist/forms/radio/index.js +3 -0
- package/dist/forms/radio/theme.d.ts +290 -0
- package/dist/forms/radio/theme.js +95 -0
- package/dist/forms/select/Select.svelte +50 -0
- package/dist/forms/select/Select.svelte.d.ts +4 -0
- package/dist/forms/select/index.d.ts +1 -0
- package/dist/forms/select/index.js +1 -0
- package/dist/forms/textarea/Textarea.svelte +165 -0
- package/dist/forms/textarea/Textarea.svelte.d.ts +4 -0
- package/dist/forms/textarea/index.d.ts +2 -0
- package/dist/forms/textarea/index.js +2 -0
- package/dist/forms/textarea/theme.d.ts +100 -0
- package/dist/forms/textarea/theme.js +35 -0
- package/dist/index.d.ts +42 -2
- package/dist/index.js +42 -2
- package/dist/layout/TF/Content/Content.svelte +28 -0
- package/dist/layout/TF/Content/Content.svelte.d.ts +8 -0
- package/dist/layout/TF/Content/index.d.ts +1 -0
- package/dist/layout/TF/Content/index.js +1 -0
- package/dist/layout/TF/Header/Header.svelte +159 -0
- package/dist/layout/TF/Header/Header.svelte.d.ts +21 -0
- package/dist/layout/TF/Header/index.d.ts +1 -0
- package/dist/layout/TF/Header/index.js +1 -0
- package/dist/layout/TF/Sidebar/Sidebar.svelte +74 -0
- package/dist/layout/TF/Sidebar/Sidebar.svelte.d.ts +23 -0
- package/dist/layout/TF/Sidebar/index.d.ts +1 -0
- package/dist/layout/TF/Sidebar/index.js +1 -0
- package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -0
- package/dist/layout/TF/Wrapper/Wrapper.svelte.d.ts +8 -0
- package/dist/layout/TF/Wrapper/index.d.ts +1 -0
- package/dist/layout/TF/Wrapper/index.js +1 -0
- package/dist/layout/TF/index.d.ts +5 -0
- package/dist/layout/TF/index.js +5 -0
- package/dist/themes/ThemeProvider.svelte +20 -0
- package/dist/themes/ThemeProvider.svelte.d.ts +9 -0
- package/dist/themes/index.d.ts +7 -0
- package/dist/themes/index.js +1 -0
- package/dist/themes/themeUtils.d.ts +24 -0
- package/dist/themes/themeUtils.js +74 -0
- package/dist/themes/themes.d.ts +18 -0
- package/dist/themes/themes.js +18 -0
- package/dist/types/index.d.ts +755 -0
- package/dist/types/index.js +1 -0
- package/dist/typography/heading/Heading.svelte +35 -0
- package/dist/typography/heading/Heading.svelte.d.ts +10 -0
- package/dist/typography/heading/index.d.ts +2 -0
- package/dist/typography/heading/index.js +2 -0
- package/dist/typography/heading/theme.d.ts +30 -0
- package/dist/typography/heading/theme.js +17 -0
- package/dist/ui/accordion/Accordion.svelte +49 -0
- package/dist/ui/accordion/Accordion.svelte.d.ts +4 -0
- package/dist/ui/accordion/AccordionItem.svelte +173 -0
- package/dist/ui/accordion/AccordionItem.svelte.d.ts +4 -0
- package/dist/ui/accordion/index.d.ts +3 -0
- package/dist/ui/accordion/index.js +3 -0
- package/dist/ui/accordion/theme.d.ts +96 -0
- package/dist/ui/accordion/theme.js +59 -0
- package/dist/ui/alert/Alert.svelte +83 -0
- package/dist/ui/alert/Alert.svelte.d.ts +5 -0
- package/dist/ui/alert/index.d.ts +2 -0
- package/dist/ui/alert/index.js +2 -0
- package/dist/ui/alert/theme.d.ts +108 -0
- package/dist/ui/alert/theme.js +149 -0
- package/dist/ui/alertDialog/AlertDialog.svelte +40 -0
- package/dist/ui/alertDialog/AlertDialog.svelte.d.ts +4 -0
- package/dist/ui/alertDialog/index.d.ts +1 -0
- package/dist/ui/alertDialog/index.js +1 -0
- package/dist/ui/avatar/Avatar.svelte +77 -0
- package/dist/ui/avatar/Avatar.svelte.d.ts +4 -0
- package/dist/ui/avatar/index.d.ts +2 -0
- package/dist/ui/avatar/index.js +2 -0
- package/dist/ui/avatar/theme.d.ts +63 -0
- package/dist/ui/avatar/theme.js +31 -0
- package/dist/ui/buttons/Button.svelte +102 -0
- package/dist/ui/buttons/Button.svelte.d.ts +4 -0
- package/dist/ui/buttons/GradientButton.svelte +59 -0
- package/dist/ui/buttons/GradientButton.svelte.d.ts +4 -0
- package/dist/ui/buttons/index.d.ts +3 -0
- package/dist/ui/buttons/index.js +3 -0
- package/dist/ui/buttons/theme.d.ts +704 -0
- package/dist/ui/buttons/theme.js +332 -0
- package/dist/ui/datatable/Datatable.svelte +516 -0
- package/dist/ui/datatable/Datatable.svelte.d.ts +5 -0
- package/dist/ui/datatable/index.d.ts +2 -0
- package/dist/ui/datatable/index.js +2 -0
- package/dist/ui/drawer/Drawer.svelte +280 -0
- package/dist/ui/drawer/Drawer.svelte.d.ts +37 -0
- package/dist/ui/drawer/index.d.ts +2 -0
- package/dist/ui/drawer/index.js +2 -0
- package/dist/ui/drawer/theme.d.ts +211 -0
- package/dist/ui/drawer/theme.js +46 -0
- package/dist/ui/dropdown/Dropdown.svelte +36 -0
- package/dist/ui/dropdown/Dropdown.svelte.d.ts +4 -0
- package/dist/ui/dropdown/DropdownDivider.svelte +11 -0
- package/dist/ui/dropdown/DropdownDivider.svelte.d.ts +4 -0
- package/dist/ui/dropdown/DropdownGroup.svelte +14 -0
- package/dist/ui/dropdown/DropdownGroup.svelte.d.ts +4 -0
- package/dist/ui/dropdown/DropdownHeader.svelte +14 -0
- package/dist/ui/dropdown/DropdownHeader.svelte.d.ts +4 -0
- package/dist/ui/dropdown/DropdownItem.svelte +52 -0
- package/dist/ui/dropdown/DropdownItem.svelte.d.ts +4 -0
- package/dist/ui/dropdown/index.d.ts +6 -0
- package/dist/ui/dropdown/index.js +6 -0
- package/dist/ui/dropdown/theme.d.ts +55 -0
- package/dist/ui/dropdown/theme.js +20 -0
- package/dist/ui/footer/Footer.svelte +15 -0
- package/dist/ui/footer/Footer.svelte.d.ts +4 -0
- package/dist/ui/footer/FooterBrand.svelte +37 -0
- package/dist/ui/footer/FooterBrand.svelte.d.ts +4 -0
- package/dist/ui/footer/FooterCopyright.svelte +45 -0
- package/dist/ui/footer/FooterCopyright.svelte.d.ts +4 -0
- package/dist/ui/footer/FooterIcon.svelte +22 -0
- package/dist/ui/footer/FooterIcon.svelte.d.ts +4 -0
- package/dist/ui/footer/FooterLink.svelte +33 -0
- package/dist/ui/footer/FooterLink.svelte.d.ts +4 -0
- package/dist/ui/footer/FooterLinkGroup.svelte +13 -0
- package/dist/ui/footer/FooterLinkGroup.svelte.d.ts +4 -0
- package/dist/ui/footer/index.d.ts +7 -0
- package/dist/ui/footer/index.js +7 -0
- package/dist/ui/footer/theme.d.ts +137 -0
- package/dist/ui/footer/theme.js +39 -0
- package/dist/ui/indicator/Indicator.svelte +42 -0
- package/dist/ui/indicator/Indicator.svelte.d.ts +4 -0
- package/dist/ui/indicator/index.d.ts +2 -0
- package/dist/ui/indicator/index.js +2 -0
- package/dist/ui/indicator/theme.d.ts +177 -0
- package/dist/ui/indicator/theme.js +114 -0
- package/dist/ui/modal/Modal.svelte +265 -0
- package/dist/ui/modal/Modal.svelte.d.ts +38 -0
- package/dist/ui/modal/index.d.ts +2 -0
- package/dist/ui/modal/index.js +2 -0
- package/dist/ui/modal/theme.d.ts +190 -0
- package/dist/ui/modal/theme.js +41 -0
- package/dist/ui/notificationList/NotificationList.svelte +123 -0
- package/dist/ui/notificationList/NotificationList.svelte.d.ts +25 -0
- package/dist/ui/notificationList/index.d.ts +1 -0
- package/dist/ui/notificationList/index.js +1 -0
- package/dist/ui/pageLoader/PageLoader.svelte +10 -0
- package/dist/ui/pageLoader/PageLoader.svelte.d.ts +4 -0
- package/dist/ui/pageLoader/index.d.ts +1 -0
- package/dist/ui/pageLoader/index.js +1 -0
- package/dist/ui/paginate/Paginate.svelte +96 -0
- package/dist/ui/paginate/Paginate.svelte.d.ts +4 -0
- package/dist/ui/paginate/index.d.ts +1 -0
- package/dist/ui/paginate/index.js +1 -0
- package/dist/ui/tab/Tab.svelte +65 -0
- package/dist/ui/tab/Tab.svelte.d.ts +4 -0
- package/dist/ui/tab/index.d.ts +2 -0
- package/dist/ui/tab/index.js +2 -0
- package/dist/ui/tab/theme.d.ts +135 -0
- package/dist/ui/tab/theme.js +83 -0
- package/dist/ui/table/Table.svelte +385 -0
- package/dist/ui/table/Table.svelte.d.ts +4 -0
- package/dist/ui/table/index.d.ts +1 -0
- package/dist/ui/table/index.js +1 -0
- package/dist/ui/tableLoader/TableLoader.svelte +24 -0
- package/dist/ui/tableLoader/TableLoader.svelte.d.ts +13 -0
- package/dist/ui/tableLoader/index.d.ts +1 -0
- package/dist/ui/tableLoader/index.js +1 -0
- package/dist/ui/toolbar/Toolbar.svelte +59 -0
- package/dist/ui/toolbar/Toolbar.svelte.d.ts +17 -0
- package/dist/ui/toolbar/ToolbarButton.svelte +56 -0
- package/dist/ui/toolbar/ToolbarButton.svelte.d.ts +17 -0
- package/dist/ui/toolbar/ToolbarGroup.svelte +43 -0
- package/dist/ui/toolbar/ToolbarGroup.svelte.d.ts +16 -0
- package/dist/ui/toolbar/index.d.ts +4 -0
- package/dist/ui/toolbar/index.js +4 -0
- package/dist/ui/toolbar/theme.d.ts +320 -0
- package/dist/ui/toolbar/theme.js +155 -0
- package/dist/utils/Popper.svelte +257 -0
- package/dist/utils/Popper.svelte.d.ts +4 -0
- package/dist/utils/action.d.ts +16 -0
- package/dist/utils/action.js +107 -0
- package/dist/utils/closeButton/CloseButton.svelte +88 -0
- package/dist/utils/closeButton/CloseButton.svelte.d.ts +12 -0
- package/dist/utils/closeButton/index.d.ts +2 -0
- package/dist/utils/closeButton/index.js +2 -0
- package/dist/utils/closeButton/theme.d.ts +100 -0
- package/dist/utils/closeButton/theme.js +69 -0
- package/dist/utils/dismissable.d.ts +9 -0
- package/dist/utils/dismissable.js +16 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/paginate.svelte.d.ts +22 -0
- package/dist/utils/paginate.svelte.js +167 -0
- package/dist/utils/singleSelection.svelte.d.ts +15 -0
- package/dist/utils/singleSelection.svelte.js +49 -0
- package/dist/utils/svelte-legos.d.ts +7 -0
- package/dist/utils/svelte-legos.js +14 -0
- package/package.json +24 -2
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import clsx, { type ClassValue } from 'clsx';
|
|
3
|
+
import { fly } from 'svelte/transition';
|
|
4
|
+
import { sineIn } from 'svelte/easing';
|
|
5
|
+
import { drawer } from './index.js';
|
|
6
|
+
import { CloseButton } from '../../utils/closeButton/index.js';
|
|
7
|
+
import { createDismissableContext } from '../../utils/dismissable.js';
|
|
8
|
+
import { trapFocus } from '../../utils/index.js';
|
|
9
|
+
import { type ParamsType, type DrawerProps } from '../../index.js';
|
|
10
|
+
import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
onaction = () => true,
|
|
15
|
+
oncancel,
|
|
16
|
+
onsubmit,
|
|
17
|
+
ontoggle,
|
|
18
|
+
onclose,
|
|
19
|
+
form = false,
|
|
20
|
+
hidden = $bindable(),
|
|
21
|
+
activateClickOutside = true,
|
|
22
|
+
position,
|
|
23
|
+
width,
|
|
24
|
+
size, // NEW: Added size prop
|
|
25
|
+
backdrop = true,
|
|
26
|
+
backdropClass,
|
|
27
|
+
placement = 'left',
|
|
28
|
+
class: className,
|
|
29
|
+
classes,
|
|
30
|
+
transitionParams,
|
|
31
|
+
transitionType = fly,
|
|
32
|
+
bodyScrolling = false,
|
|
33
|
+
dismissable = true,
|
|
34
|
+
closeBtnClass,
|
|
35
|
+
headerClass,
|
|
36
|
+
bodyClass,
|
|
37
|
+
footerClass,
|
|
38
|
+
header,
|
|
39
|
+
footer,
|
|
40
|
+
title,
|
|
41
|
+
permanent = false,
|
|
42
|
+
autoclose = false,
|
|
43
|
+
...restProps
|
|
44
|
+
}: DrawerProps = $props();
|
|
45
|
+
|
|
46
|
+
warnThemeDeprecation(
|
|
47
|
+
'Drawer',
|
|
48
|
+
{ backdropClass, headerClass, bodyClass, footerClass, closeBtnClass },
|
|
49
|
+
{
|
|
50
|
+
backdropClass: 'backdrop',
|
|
51
|
+
bodyClass: 'body',
|
|
52
|
+
headerClass: 'header',
|
|
53
|
+
footerClass: 'footer',
|
|
54
|
+
closeBtnClass: 'close'
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
const styling = $derived(
|
|
58
|
+
classes ?? {
|
|
59
|
+
backdrop: backdropClass,
|
|
60
|
+
header: headerClass,
|
|
61
|
+
body: bodyClass,
|
|
62
|
+
footer: footerClass,
|
|
63
|
+
close: closeBtnClass
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const theme = getTheme('drawer');
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
base,
|
|
71
|
+
backdrop: backdropCls,
|
|
72
|
+
header: headerCls,
|
|
73
|
+
body,
|
|
74
|
+
footer: footerCls,
|
|
75
|
+
close: closeCls,
|
|
76
|
+
form: formCls
|
|
77
|
+
} = $derived(
|
|
78
|
+
drawer({
|
|
79
|
+
position,
|
|
80
|
+
placement,
|
|
81
|
+
width,
|
|
82
|
+
size, // NEW: Pass size to drawer function
|
|
83
|
+
backdrop
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
let innerWidth: number = $state(-1);
|
|
88
|
+
let innerHeight: number = $state(-1);
|
|
89
|
+
|
|
90
|
+
// Updated x and y calculations to consider different sizes
|
|
91
|
+
let x = $derived(() => {
|
|
92
|
+
if (placement === 'left') return -320;
|
|
93
|
+
if (placement === 'right') return innerWidth + 320;
|
|
94
|
+
return undefined;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
let y = $derived(() => {
|
|
98
|
+
if (placement === 'top') return -100;
|
|
99
|
+
if (placement === 'bottom') return innerHeight + 100;
|
|
100
|
+
return undefined;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
let transition_params = $derived(Object.assign({}, { x, y, duration: 200, easing: sineIn }));
|
|
104
|
+
|
|
105
|
+
let ref: HTMLDivElement | undefined = $state(undefined);
|
|
106
|
+
|
|
107
|
+
function close(ev: MouseEvent) {
|
|
108
|
+
if (ref?.dispatchEvent(new Event('close', { bubbles: true, cancelable: true }))) {
|
|
109
|
+
hidden = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function _oncancel(ev: Event & { currentTarget: HTMLDivElement }) {
|
|
114
|
+
if (ev.target !== ev.currentTarget) {
|
|
115
|
+
return; // ignore if not on drawer
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
oncancel?.(ev);
|
|
119
|
+
if (ev.defaultPrevented) return;
|
|
120
|
+
|
|
121
|
+
ev.preventDefault();
|
|
122
|
+
if (!permanent) hidden = true;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function _onclick(ev: Event & { currentTarget: HTMLDivElement }) {
|
|
126
|
+
const drawer: HTMLDivElement = ev.currentTarget;
|
|
127
|
+
if (activateClickOutside && ev.target === drawer) {
|
|
128
|
+
return close(ev as unknown as MouseEvent);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (autoclose && ev.target instanceof HTMLButtonElement && !permanent) {
|
|
132
|
+
return (hidden = true);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _onsubmit(ev: SubmitEvent & { currentTarget: HTMLFormElement }) {
|
|
137
|
+
onsubmit?.(ev as any);
|
|
138
|
+
if (ev.defaultPrevented) return;
|
|
139
|
+
|
|
140
|
+
ev.preventDefault();
|
|
141
|
+
|
|
142
|
+
const mainForm = ev.currentTarget;
|
|
143
|
+
let returnValue = '';
|
|
144
|
+
|
|
145
|
+
// Find all nested forms within the main form
|
|
146
|
+
const nestedForms = mainForm.querySelectorAll('form');
|
|
147
|
+
const combinedFormData = new FormData();
|
|
148
|
+
|
|
149
|
+
// Add data from main form (excluding nested forms)
|
|
150
|
+
new FormData(mainForm).forEach((value, key) => {
|
|
151
|
+
combinedFormData.append(key, value);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Add data from all nested forms
|
|
155
|
+
nestedForms.forEach((nestedForm) => {
|
|
156
|
+
new FormData(nestedForm).forEach((value, key) => {
|
|
157
|
+
combinedFormData.append(key, value);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (ev.submitter instanceof HTMLButtonElement || ev.submitter instanceof HTMLInputElement) {
|
|
162
|
+
returnValue = ev.submitter.value;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!returnValue) {
|
|
166
|
+
return (hidden = true);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
typeof onaction === 'function' &&
|
|
171
|
+
onaction({ action: returnValue, data: combinedFormData }) === false
|
|
172
|
+
) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// hidden = true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
createDismissableContext(close);
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<svelte:window bind:innerWidth bind:innerHeight />
|
|
183
|
+
|
|
184
|
+
{#snippet content()}
|
|
185
|
+
<div class="flex h-screen flex-col">
|
|
186
|
+
{#if title || header}
|
|
187
|
+
<div class={headerCls({ class: clsx(theme?.header, styling.header) })}>
|
|
188
|
+
{#if title}
|
|
189
|
+
<h3 class="text-base">{title}</h3>
|
|
190
|
+
{#if dismissable && !permanent}
|
|
191
|
+
<CloseButton type="submit" formnovalidate class={clsx(styling.close)} />
|
|
192
|
+
{/if}
|
|
193
|
+
{:else if header}
|
|
194
|
+
{@render header()}
|
|
195
|
+
{/if}
|
|
196
|
+
</div>
|
|
197
|
+
{/if}
|
|
198
|
+
<div class="h-full flex-grow overflow-y-auto overscroll-contain">
|
|
199
|
+
<div class={body({ class: clsx(theme?.body, styling.body) })}>
|
|
200
|
+
{@render children?.()}
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
{#if footer}
|
|
205
|
+
<div class={footerCls({ class: clsx(theme?.footer, styling.footer) })}>
|
|
206
|
+
{@render footer()}
|
|
207
|
+
</div>
|
|
208
|
+
{/if}
|
|
209
|
+
{#if dismissable && !permanent && !title}
|
|
210
|
+
<CloseButton
|
|
211
|
+
type="submit"
|
|
212
|
+
formnovalidate
|
|
213
|
+
class={closeCls({ class: clsx(theme?.close, styling.close) })}
|
|
214
|
+
/>
|
|
215
|
+
{/if}
|
|
216
|
+
</div>
|
|
217
|
+
{/snippet}
|
|
218
|
+
|
|
219
|
+
{#if !hidden}
|
|
220
|
+
<div
|
|
221
|
+
role="presentation"
|
|
222
|
+
bind:this={ref}
|
|
223
|
+
class={backdropCls({ class: clsx(theme?.backdrop, styling.backdrop) })}
|
|
224
|
+
onclick={activateClickOutside ? close : undefined}
|
|
225
|
+
style={bodyScrolling ? 'pointer-events: none;' : ''}
|
|
226
|
+
></div>
|
|
227
|
+
<div
|
|
228
|
+
use:trapFocus={{ onEscape: close as () => void }}
|
|
229
|
+
{...restProps}
|
|
230
|
+
class={base({ class: clsx(theme?.base, className) })}
|
|
231
|
+
transition:transitionType={transitionParams
|
|
232
|
+
? transitionParams
|
|
233
|
+
: (transition_params as ParamsType)}
|
|
234
|
+
tabindex="-1"
|
|
235
|
+
onclick={_onclick}
|
|
236
|
+
>
|
|
237
|
+
{#if form}
|
|
238
|
+
<form method="dialog" onsubmit={_onsubmit} class={formCls({ class: clsx(theme?.form) })}>
|
|
239
|
+
{@render content()}
|
|
240
|
+
</form>
|
|
241
|
+
{:else}
|
|
242
|
+
{@render content()}
|
|
243
|
+
{/if}
|
|
244
|
+
</div>
|
|
245
|
+
{/if}
|
|
246
|
+
|
|
247
|
+
<!--
|
|
248
|
+
@component
|
|
249
|
+
## Props
|
|
250
|
+
@prop children
|
|
251
|
+
@prop onaction = () => true
|
|
252
|
+
@prop oncancel
|
|
253
|
+
@prop onsubmit
|
|
254
|
+
@prop ontoggle
|
|
255
|
+
@prop form = false
|
|
256
|
+
@prop hidden = $bindable()
|
|
257
|
+
@prop activateClickOutside = true
|
|
258
|
+
@prop position
|
|
259
|
+
@prop width
|
|
260
|
+
@prop size // NEW: Added size prop documentation
|
|
261
|
+
@prop backdrop = true
|
|
262
|
+
@prop backdropClass
|
|
263
|
+
@prop placement = "left"
|
|
264
|
+
@prop class: className
|
|
265
|
+
@prop classes
|
|
266
|
+
@prop transitionParams
|
|
267
|
+
@prop transitionType = fly
|
|
268
|
+
@prop bodyScrolling = false
|
|
269
|
+
@prop dismissable = true
|
|
270
|
+
@prop closeBtnClass
|
|
271
|
+
@prop headerClass
|
|
272
|
+
@prop bodyClass
|
|
273
|
+
@prop footerClass
|
|
274
|
+
@prop header
|
|
275
|
+
@prop footer
|
|
276
|
+
@prop title
|
|
277
|
+
@prop permanent = false
|
|
278
|
+
@prop autoclose = false
|
|
279
|
+
@prop ...restProps
|
|
280
|
+
-->
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type DrawerProps } from '../../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* ## Props
|
|
4
|
+
* @prop children
|
|
5
|
+
* @prop onaction = () => true
|
|
6
|
+
* @prop oncancel
|
|
7
|
+
* @prop onsubmit
|
|
8
|
+
* @prop ontoggle
|
|
9
|
+
* @prop form = false
|
|
10
|
+
* @prop hidden = $bindable()
|
|
11
|
+
* @prop activateClickOutside = true
|
|
12
|
+
* @prop position
|
|
13
|
+
* @prop width
|
|
14
|
+
* @prop size // NEW: Added size prop documentation
|
|
15
|
+
* @prop backdrop = true
|
|
16
|
+
* @prop backdropClass
|
|
17
|
+
* @prop placement = "left"
|
|
18
|
+
* @prop class: className
|
|
19
|
+
* @prop classes
|
|
20
|
+
* @prop transitionParams
|
|
21
|
+
* @prop transitionType = fly
|
|
22
|
+
* @prop bodyScrolling = false
|
|
23
|
+
* @prop dismissable = true
|
|
24
|
+
* @prop closeBtnClass
|
|
25
|
+
* @prop headerClass
|
|
26
|
+
* @prop bodyClass
|
|
27
|
+
* @prop footerClass
|
|
28
|
+
* @prop header
|
|
29
|
+
* @prop footer
|
|
30
|
+
* @prop title
|
|
31
|
+
* @prop permanent = false
|
|
32
|
+
* @prop autoclose = false
|
|
33
|
+
* @prop ...restProps
|
|
34
|
+
*/
|
|
35
|
+
declare const Drawer: import("svelte").Component<DrawerProps, {}, "hidden">;
|
|
36
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
37
|
+
export default Drawer;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { Classes } from '../../themes/themeUtils.js';
|
|
2
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
3
|
+
export type DrawerVariants = VariantProps<typeof drawer> & Classes<typeof drawer>;
|
|
4
|
+
export declare const drawer: import("tailwind-variants").TVReturnType<{
|
|
5
|
+
position: {
|
|
6
|
+
fixed: {
|
|
7
|
+
base: string;
|
|
8
|
+
backdrop: string;
|
|
9
|
+
};
|
|
10
|
+
absolute: {
|
|
11
|
+
base: string;
|
|
12
|
+
backdrop: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
placement: {
|
|
16
|
+
left: {
|
|
17
|
+
base: string;
|
|
18
|
+
};
|
|
19
|
+
right: {
|
|
20
|
+
base: string;
|
|
21
|
+
};
|
|
22
|
+
top: {
|
|
23
|
+
base: string;
|
|
24
|
+
};
|
|
25
|
+
bottom: {
|
|
26
|
+
base: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
width: {
|
|
30
|
+
default: {
|
|
31
|
+
base: string;
|
|
32
|
+
};
|
|
33
|
+
full: {
|
|
34
|
+
base: string;
|
|
35
|
+
};
|
|
36
|
+
half: {
|
|
37
|
+
base: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
size: {
|
|
41
|
+
sm: {
|
|
42
|
+
base: string;
|
|
43
|
+
};
|
|
44
|
+
md: {
|
|
45
|
+
base: string;
|
|
46
|
+
};
|
|
47
|
+
lg: {
|
|
48
|
+
base: string;
|
|
49
|
+
};
|
|
50
|
+
xl: {
|
|
51
|
+
base: string;
|
|
52
|
+
};
|
|
53
|
+
'2xl': {
|
|
54
|
+
base: string;
|
|
55
|
+
};
|
|
56
|
+
'3xl': {
|
|
57
|
+
base: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
backdrop: {
|
|
61
|
+
true: {
|
|
62
|
+
backdrop: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}, {
|
|
66
|
+
base: string;
|
|
67
|
+
backdrop: string;
|
|
68
|
+
header: string;
|
|
69
|
+
close: string;
|
|
70
|
+
body: string;
|
|
71
|
+
footer: string;
|
|
72
|
+
form: string;
|
|
73
|
+
}, undefined, {
|
|
74
|
+
position: {
|
|
75
|
+
fixed: {
|
|
76
|
+
base: string;
|
|
77
|
+
backdrop: string;
|
|
78
|
+
};
|
|
79
|
+
absolute: {
|
|
80
|
+
base: string;
|
|
81
|
+
backdrop: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
placement: {
|
|
85
|
+
left: {
|
|
86
|
+
base: string;
|
|
87
|
+
};
|
|
88
|
+
right: {
|
|
89
|
+
base: string;
|
|
90
|
+
};
|
|
91
|
+
top: {
|
|
92
|
+
base: string;
|
|
93
|
+
};
|
|
94
|
+
bottom: {
|
|
95
|
+
base: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
width: {
|
|
99
|
+
default: {
|
|
100
|
+
base: string;
|
|
101
|
+
};
|
|
102
|
+
full: {
|
|
103
|
+
base: string;
|
|
104
|
+
};
|
|
105
|
+
half: {
|
|
106
|
+
base: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
size: {
|
|
110
|
+
sm: {
|
|
111
|
+
base: string;
|
|
112
|
+
};
|
|
113
|
+
md: {
|
|
114
|
+
base: string;
|
|
115
|
+
};
|
|
116
|
+
lg: {
|
|
117
|
+
base: string;
|
|
118
|
+
};
|
|
119
|
+
xl: {
|
|
120
|
+
base: string;
|
|
121
|
+
};
|
|
122
|
+
'2xl': {
|
|
123
|
+
base: string;
|
|
124
|
+
};
|
|
125
|
+
'3xl': {
|
|
126
|
+
base: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
backdrop: {
|
|
130
|
+
true: {
|
|
131
|
+
backdrop: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
}, {
|
|
135
|
+
base: string;
|
|
136
|
+
backdrop: string;
|
|
137
|
+
header: string;
|
|
138
|
+
close: string;
|
|
139
|
+
body: string;
|
|
140
|
+
footer: string;
|
|
141
|
+
form: string;
|
|
142
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
143
|
+
position: {
|
|
144
|
+
fixed: {
|
|
145
|
+
base: string;
|
|
146
|
+
backdrop: string;
|
|
147
|
+
};
|
|
148
|
+
absolute: {
|
|
149
|
+
base: string;
|
|
150
|
+
backdrop: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
placement: {
|
|
154
|
+
left: {
|
|
155
|
+
base: string;
|
|
156
|
+
};
|
|
157
|
+
right: {
|
|
158
|
+
base: string;
|
|
159
|
+
};
|
|
160
|
+
top: {
|
|
161
|
+
base: string;
|
|
162
|
+
};
|
|
163
|
+
bottom: {
|
|
164
|
+
base: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
width: {
|
|
168
|
+
default: {
|
|
169
|
+
base: string;
|
|
170
|
+
};
|
|
171
|
+
full: {
|
|
172
|
+
base: string;
|
|
173
|
+
};
|
|
174
|
+
half: {
|
|
175
|
+
base: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
size: {
|
|
179
|
+
sm: {
|
|
180
|
+
base: string;
|
|
181
|
+
};
|
|
182
|
+
md: {
|
|
183
|
+
base: string;
|
|
184
|
+
};
|
|
185
|
+
lg: {
|
|
186
|
+
base: string;
|
|
187
|
+
};
|
|
188
|
+
xl: {
|
|
189
|
+
base: string;
|
|
190
|
+
};
|
|
191
|
+
'2xl': {
|
|
192
|
+
base: string;
|
|
193
|
+
};
|
|
194
|
+
'3xl': {
|
|
195
|
+
base: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
backdrop: {
|
|
199
|
+
true: {
|
|
200
|
+
backdrop: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
}, {
|
|
204
|
+
base: string;
|
|
205
|
+
backdrop: string;
|
|
206
|
+
header: string;
|
|
207
|
+
close: string;
|
|
208
|
+
body: string;
|
|
209
|
+
footer: string;
|
|
210
|
+
form: string;
|
|
211
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const drawer = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'z-50 bg-white dark:bg-gray-800',
|
|
5
|
+
backdrop: 'fixed top-0 start-0 z-50 w-full h-full',
|
|
6
|
+
header: 'flex items-center justify-between rounded-t-lg shrink-0 text-xl font-semibold text-gray-900 dark:text-white px-4 py-2 border-b',
|
|
7
|
+
close: 'absolute top-3 end-2.5',
|
|
8
|
+
body: 'p-4 md:p-5 space-y-4',
|
|
9
|
+
footer: 'flex items-center p-3 md:p-5 space-x-3 rtl:space-x-reverse rounded-b-lg shrink-0 bg-gray-100',
|
|
10
|
+
form: 'flex flex-col divide-y'
|
|
11
|
+
},
|
|
12
|
+
variants: {
|
|
13
|
+
position: {
|
|
14
|
+
fixed: { base: 'fixed', backdrop: 'fixed' },
|
|
15
|
+
absolute: { base: 'absolute', backdrop: 'absolute' }
|
|
16
|
+
},
|
|
17
|
+
placement: {
|
|
18
|
+
left: { base: 'inset-y-0 start-0' },
|
|
19
|
+
right: { base: 'inset-y-0 end-0' },
|
|
20
|
+
top: { base: 'inset-x-0 top-0' },
|
|
21
|
+
bottom: { base: 'inset-x-0 bottom-0' }
|
|
22
|
+
},
|
|
23
|
+
width: {
|
|
24
|
+
default: { base: 'w-80' },
|
|
25
|
+
full: { base: 'w-full' },
|
|
26
|
+
half: { base: 'w-1/2' }
|
|
27
|
+
},
|
|
28
|
+
size: {
|
|
29
|
+
sm: { base: 'w-64' },
|
|
30
|
+
md: { base: 'w-80' },
|
|
31
|
+
lg: { base: 'w-96' },
|
|
32
|
+
xl: { base: 'w-[32rem]' },
|
|
33
|
+
'2xl': { base: 'w-[40rem]' },
|
|
34
|
+
'3xl': { base: 'w-[48rem]' }
|
|
35
|
+
},
|
|
36
|
+
backdrop: {
|
|
37
|
+
true: { backdrop: 'bg-gray-900 opacity-75' }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
position: 'fixed',
|
|
42
|
+
placement: 'left',
|
|
43
|
+
width: 'default',
|
|
44
|
+
size: 'md'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { setContext } from 'svelte';
|
|
4
|
+
import { dropdown, DropdownGroup } from './index.js';
|
|
5
|
+
import Popper from '../../utils/Popper.svelte';
|
|
6
|
+
import { type DropdownProps } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
simple = false,
|
|
11
|
+
placement = 'bottom',
|
|
12
|
+
offset = 2,
|
|
13
|
+
class: className,
|
|
14
|
+
activeUrl = '',
|
|
15
|
+
isOpen = $bindable(false),
|
|
16
|
+
...restProps
|
|
17
|
+
}: DropdownProps = $props();
|
|
18
|
+
|
|
19
|
+
const base = $derived(dropdown({ class: clsx(dropdown, className) }));
|
|
20
|
+
const activeUrlStore = $state({ value: '' });
|
|
21
|
+
setContext('activeUrl', activeUrlStore);
|
|
22
|
+
|
|
23
|
+
$effect(() => {
|
|
24
|
+
activeUrlStore.value = activeUrl ?? '';
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Popper {...restProps} {placement} {offset} bind:isOpen class={base}>
|
|
29
|
+
{#if simple}
|
|
30
|
+
<DropdownGroup>
|
|
31
|
+
{@render children()}
|
|
32
|
+
</DropdownGroup>
|
|
33
|
+
{:else}
|
|
34
|
+
{@render children()}
|
|
35
|
+
{/if}
|
|
36
|
+
</Popper>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { dropdownDivider } from './index.js';
|
|
4
|
+
import { getTheme } from '../../themes/themeUtils.js';
|
|
5
|
+
import type { DropdownDividerProps } from '../../index.js';
|
|
6
|
+
|
|
7
|
+
let { class: className, ...restProps }: DropdownDividerProps = $props();
|
|
8
|
+
const theme = getTheme('dropdownDivider');
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div {...restProps} class={dropdownDivider({ class: clsx(theme, className) })}></div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { dropdownGroup } from './index.js';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { getTheme } from '../../themes/themeUtils.js';
|
|
5
|
+
import type { DropdownGroupProps } from '../../index.js';
|
|
6
|
+
|
|
7
|
+
let { children, class: className, ...restProps }: DropdownGroupProps = $props();
|
|
8
|
+
|
|
9
|
+
const theme = getTheme('dropdownGroup');
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ul {...restProps} class={dropdownGroup({ class: clsx(theme, className) })}>
|
|
13
|
+
{@render children()}
|
|
14
|
+
</ul>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { dropdownHeader } from './index.js';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { getTheme } from '../../themes/themeUtils.js';
|
|
5
|
+
import type { DropdownHeaderProps } from '../../index.js';
|
|
6
|
+
|
|
7
|
+
let { children, class: className, ...restProps }: DropdownHeaderProps = $props();
|
|
8
|
+
|
|
9
|
+
const theme = getTheme('dropdownHeader');
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<div {...restProps} class={dropdownHeader({ class: clsx(theme, className) })}>
|
|
13
|
+
{@render children()}
|
|
14
|
+
</div>
|