@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
// heading
|
|
3
|
+
export interface HeadingProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
tag?: HeadingVariants['tag'];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// // hr
|
|
9
|
+
// export interface HrProps extends HrVariants, HTMLAttributes<HTMLElement> {
|
|
10
|
+
// children?: Snippet;
|
|
11
|
+
// divClass?: string;
|
|
12
|
+
// iconDivClass?: string;
|
|
13
|
+
// textSpanClass?: string;
|
|
14
|
+
// innerDivClass?: string;
|
|
15
|
+
// }
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
import { getTheme } from '../../index.js';
|
|
20
|
+
import clsx from 'clsx';
|
|
21
|
+
import { heading } from './index.js';
|
|
22
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
23
|
+
import type { Snippet } from 'svelte';
|
|
24
|
+
import type { HeadingVariants } from './theme.js';
|
|
25
|
+
|
|
26
|
+
let { children, tag = 'h1', class: className, ...restProps }: HeadingProps = $props();
|
|
27
|
+
|
|
28
|
+
const theme = getTheme('heading');
|
|
29
|
+
|
|
30
|
+
let headingCls = $derived(heading({ tag, class: clsx(theme, className) }));
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<svelte:element this={tag} {...restProps} class={headingCls}>
|
|
34
|
+
{@render children()}
|
|
35
|
+
</svelte:element>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface HeadingProps extends HTMLAttributes<HTMLElement> {
|
|
2
|
+
children: Snippet;
|
|
3
|
+
tag?: HeadingVariants['tag'];
|
|
4
|
+
}
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { HeadingVariants } from './theme.js';
|
|
8
|
+
declare const Heading: import("svelte").Component<HeadingProps, {}, "">;
|
|
9
|
+
type Heading = ReturnType<typeof Heading>;
|
|
10
|
+
export default Heading;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type VariantProps } from "tailwind-variants";
|
|
2
|
+
export type HeadingVariants = VariantProps<typeof heading>;
|
|
3
|
+
export declare const heading: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
tag: {
|
|
5
|
+
h1: string;
|
|
6
|
+
h2: string;
|
|
7
|
+
h3: string;
|
|
8
|
+
h4: string;
|
|
9
|
+
h5: string;
|
|
10
|
+
h6: string;
|
|
11
|
+
};
|
|
12
|
+
}, undefined, "font-bold text-gray-900 dark:text-white", {
|
|
13
|
+
tag: {
|
|
14
|
+
h1: string;
|
|
15
|
+
h2: string;
|
|
16
|
+
h3: string;
|
|
17
|
+
h4: string;
|
|
18
|
+
h5: string;
|
|
19
|
+
h6: string;
|
|
20
|
+
};
|
|
21
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
22
|
+
tag: {
|
|
23
|
+
h1: string;
|
|
24
|
+
h2: string;
|
|
25
|
+
h3: string;
|
|
26
|
+
h4: string;
|
|
27
|
+
h5: string;
|
|
28
|
+
h6: string;
|
|
29
|
+
};
|
|
30
|
+
}, undefined, "font-bold text-gray-900 dark:text-white", unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
export const heading = tv({
|
|
3
|
+
base: "font-bold text-gray-900 dark:text-white",
|
|
4
|
+
variants: {
|
|
5
|
+
tag: {
|
|
6
|
+
h1: "text-5xl font-extrabold",
|
|
7
|
+
h2: "text-4xl",
|
|
8
|
+
h3: "text-3xl",
|
|
9
|
+
h4: "text-2xl",
|
|
10
|
+
h5: "text-xl",
|
|
11
|
+
h6: "text-lg"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
tag: "h1"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { accordion, getTheme, type AccordionCtxType, type AccordionProps } from '../../index.js';
|
|
3
|
+
import { createSingleSelectionContext } from '../../utils/singleSelection.svelte.js';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { setContext } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
flush,
|
|
10
|
+
activeClass,
|
|
11
|
+
inactiveClass,
|
|
12
|
+
multiple = false,
|
|
13
|
+
class: className,
|
|
14
|
+
transitionType,
|
|
15
|
+
...restProps
|
|
16
|
+
}: AccordionProps = $props();
|
|
17
|
+
|
|
18
|
+
const theme = getTheme('accordion');
|
|
19
|
+
|
|
20
|
+
const ctx: AccordionCtxType = $state({
|
|
21
|
+
flush,
|
|
22
|
+
activeClass,
|
|
23
|
+
inactiveClass,
|
|
24
|
+
transitionType
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
setContext<AccordionCtxType>('ctx', ctx);
|
|
28
|
+
|
|
29
|
+
createSingleSelectionContext(multiple);
|
|
30
|
+
|
|
31
|
+
const base = $derived(accordion({ flush, class: clsx(theme, className) }));
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div {...restProps} class={base}>
|
|
35
|
+
{@render children()}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<!--
|
|
39
|
+
|
|
40
|
+
## Props
|
|
41
|
+
@prop children
|
|
42
|
+
@prop flush
|
|
43
|
+
@prop activeClass
|
|
44
|
+
@prop inactiveClass
|
|
45
|
+
@prop multiple = false
|
|
46
|
+
@prop class: className
|
|
47
|
+
@prop transitionType
|
|
48
|
+
@prop ...restProps
|
|
49
|
+
-->
|
|
@@ -0,0 +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
|
+
-->
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Classes } from '../../themes/themeUtils.js';
|
|
2
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
3
|
+
export type AccordionVariants = VariantProps<typeof accordion>;
|
|
4
|
+
export type AccordionItemVariants = VariantProps<typeof accordionItem> & Classes<typeof accordionItem>;
|
|
5
|
+
export declare const accordion: import("tailwind-variants").TVReturnType<{
|
|
6
|
+
color: {
|
|
7
|
+
primary: string;
|
|
8
|
+
secondary: string;
|
|
9
|
+
};
|
|
10
|
+
flush: {
|
|
11
|
+
true: string;
|
|
12
|
+
false: string;
|
|
13
|
+
};
|
|
14
|
+
}, undefined, "w-full", {
|
|
15
|
+
color: {
|
|
16
|
+
primary: string;
|
|
17
|
+
secondary: string;
|
|
18
|
+
};
|
|
19
|
+
flush: {
|
|
20
|
+
true: string;
|
|
21
|
+
false: string;
|
|
22
|
+
};
|
|
23
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
24
|
+
color: {
|
|
25
|
+
primary: string;
|
|
26
|
+
secondary: string;
|
|
27
|
+
};
|
|
28
|
+
flush: {
|
|
29
|
+
true: string;
|
|
30
|
+
false: string;
|
|
31
|
+
};
|
|
32
|
+
}, undefined, "w-full", unknown, unknown, undefined>>;
|
|
33
|
+
export declare const accordionItem: import("tailwind-variants").TVReturnType<{
|
|
34
|
+
flush: {
|
|
35
|
+
true: {
|
|
36
|
+
button: string;
|
|
37
|
+
content: string;
|
|
38
|
+
};
|
|
39
|
+
false: {
|
|
40
|
+
button: string;
|
|
41
|
+
content: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
open: {
|
|
45
|
+
true: {};
|
|
46
|
+
false: {};
|
|
47
|
+
};
|
|
48
|
+
}, {
|
|
49
|
+
base: string;
|
|
50
|
+
button: string;
|
|
51
|
+
content: string;
|
|
52
|
+
active: string;
|
|
53
|
+
inactive: string;
|
|
54
|
+
}, undefined, {
|
|
55
|
+
flush: {
|
|
56
|
+
true: {
|
|
57
|
+
button: string;
|
|
58
|
+
content: string;
|
|
59
|
+
};
|
|
60
|
+
false: {
|
|
61
|
+
button: string;
|
|
62
|
+
content: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
open: {
|
|
66
|
+
true: {};
|
|
67
|
+
false: {};
|
|
68
|
+
};
|
|
69
|
+
}, {
|
|
70
|
+
base: string;
|
|
71
|
+
button: string;
|
|
72
|
+
content: string;
|
|
73
|
+
active: string;
|
|
74
|
+
inactive: string;
|
|
75
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
76
|
+
flush: {
|
|
77
|
+
true: {
|
|
78
|
+
button: string;
|
|
79
|
+
content: string;
|
|
80
|
+
};
|
|
81
|
+
false: {
|
|
82
|
+
button: string;
|
|
83
|
+
content: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
open: {
|
|
87
|
+
true: {};
|
|
88
|
+
false: {};
|
|
89
|
+
};
|
|
90
|
+
}, {
|
|
91
|
+
base: string;
|
|
92
|
+
button: string;
|
|
93
|
+
content: string;
|
|
94
|
+
active: string;
|
|
95
|
+
inactive: string;
|
|
96
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const accordion = tv({
|
|
3
|
+
base: 'w-full',
|
|
4
|
+
variants: {
|
|
5
|
+
color: {
|
|
6
|
+
primary: 'text-primary-500 dark:text-primary-400',
|
|
7
|
+
secondary: 'text-secondary-500 dark:text-secondary-400'
|
|
8
|
+
},
|
|
9
|
+
flush: {
|
|
10
|
+
true: '',
|
|
11
|
+
false: 'border border-gray-200 dark:border-gray-700 rounded-t-xl'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export const accordionItem = tv({
|
|
16
|
+
slots: {
|
|
17
|
+
base: 'group',
|
|
18
|
+
button: 'flex items-center justify-between w-full font-medium text-left group-first:rounded-t-xl border-gray-200 dark:border-gray-700 border-b',
|
|
19
|
+
content: 'border-b border-gray-200 dark:border-gray-700',
|
|
20
|
+
active: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800',
|
|
21
|
+
inactive: 'text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800'
|
|
22
|
+
},
|
|
23
|
+
variants: {
|
|
24
|
+
flush: {
|
|
25
|
+
true: {
|
|
26
|
+
button: 'py-5',
|
|
27
|
+
content: 'py-5'
|
|
28
|
+
},
|
|
29
|
+
false: {
|
|
30
|
+
button: 'p-5 border-s border-e group-first:border-t',
|
|
31
|
+
content: 'p-5 border-s border-e'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
open: {
|
|
35
|
+
true: {},
|
|
36
|
+
false: {}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
compoundVariants: [
|
|
40
|
+
{
|
|
41
|
+
flush: true,
|
|
42
|
+
open: true,
|
|
43
|
+
class: {
|
|
44
|
+
button: 'text-gray-900 dark:text-white'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
flush: true,
|
|
49
|
+
open: false,
|
|
50
|
+
class: {
|
|
51
|
+
button: 'text-gray-500 dark:text-gray-400'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
defaultVariants: {
|
|
56
|
+
flush: false,
|
|
57
|
+
open: false
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -0,0 +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}
|