@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.
Files changed (103) hide show
  1. package/README.md +8 -8
  2. package/dist/baseEditor/index.svelte +32 -32
  3. package/dist/builders/filters/FilterBuilder.svelte +641 -641
  4. package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
  5. package/dist/forms/FormClEditor/ClEdito.svelte +68 -68
  6. package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
  7. package/dist/forms/FormFileUpload/FormFileUplad.svelte +134 -134
  8. package/dist/forms/FormInput/FormInput.svelte +87 -87
  9. package/dist/forms/FormRadio/FormRadio.svelte +53 -53
  10. package/dist/forms/FormSelect/FormSelect.svelte +88 -88
  11. package/dist/forms/FormTextarea/FormTextarea.svelte +78 -78
  12. package/dist/forms/button-toggle/ButtonToggle.svelte +119 -119
  13. package/dist/forms/button-toggle/CheckIcon.svelte +28 -28
  14. package/dist/forms/checkbox/Checkbox.svelte +82 -82
  15. package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
  16. package/dist/forms/datepicker/Datepicker.svelte +707 -707
  17. package/dist/forms/form/Form.svelte +69 -69
  18. package/dist/forms/input/Input.svelte +363 -363
  19. package/dist/forms/label/Label.svelte +38 -38
  20. package/dist/forms/radio/Radio.svelte +48 -48
  21. package/dist/forms/radio/RadioButton.svelte +22 -22
  22. package/dist/forms/select/Select.svelte +56 -56
  23. package/dist/forms/textarea/Textarea.svelte +165 -165
  24. package/dist/forms/toggle/Toggle.svelte +70 -70
  25. package/dist/layout/Chat/CategorySelector.svelte +52 -52
  26. package/dist/layout/Chat/ChatEntry.svelte +246 -246
  27. package/dist/layout/Chat/ChatEntrySkeleton.svelte +81 -81
  28. package/dist/layout/Chat/ChatHeader.svelte +172 -172
  29. package/dist/layout/Chat/ChatInput.svelte +207 -207
  30. package/dist/layout/Chat/DraggableWindow.svelte +230 -230
  31. package/dist/layout/Chat/PreviewPage.svelte +182 -182
  32. package/dist/layout/Chat/RichText.svelte +216 -216
  33. package/dist/layout/ComponentCanvas/Canvas.svelte +40 -40
  34. package/dist/layout/ComponentCanvas/ComponentRenderer.svelte +85 -85
  35. package/dist/layout/TF/Content/Content.svelte +21 -21
  36. package/dist/layout/TF/Header/Header.svelte +166 -166
  37. package/dist/layout/TF/Sidebar/Sidebar.svelte +148 -148
  38. package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
  39. package/dist/layout/mailing/MailPaginator.svelte +36 -36
  40. package/dist/layout/mailing/MailSidebar.svelte +39 -39
  41. package/dist/layout/mailing/MailToolBar.svelte +174 -174
  42. package/dist/layout/mailing/MailingContent.svelte +10 -10
  43. package/dist/layout/mailing/MailingHeader.svelte +55 -55
  44. package/dist/layout/mailing/MailingMessageCard.svelte +112 -112
  45. package/dist/layout/mailing/MailingMessageViewer.svelte +87 -87
  46. package/dist/layout/mailing/MailingModule.svelte +448 -448
  47. package/dist/styles/docs.css +615 -615
  48. package/dist/styles/tf-layout.css +185 -185
  49. package/dist/themes/ThemeProvider.svelte +20 -20
  50. package/dist/types/index.d.ts +2 -0
  51. package/dist/typography/heading/Heading.svelte +35 -35
  52. package/dist/ui/accordion/Accordion.svelte +49 -49
  53. package/dist/ui/accordion/AccordionItem.svelte +173 -173
  54. package/dist/ui/alert/Alert.svelte +83 -83
  55. package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
  56. package/dist/ui/avatar/Avatar.svelte +77 -77
  57. package/dist/ui/box/Box.svelte +28 -28
  58. package/dist/ui/breadcrumb/Breadcrumb.svelte +39 -39
  59. package/dist/ui/buttons/ActionButton.svelte +234 -234
  60. package/dist/ui/buttons/Button.svelte +102 -102
  61. package/dist/ui/buttons/GradientButton.svelte +59 -59
  62. package/dist/ui/datatable/Datatable.svelte +525 -525
  63. package/dist/ui/drawer/Drawer.svelte +300 -300
  64. package/dist/ui/dropdown/Dropdown.svelte +36 -36
  65. package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
  66. package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
  67. package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
  68. package/dist/ui/dropdown/DropdownItem.svelte +52 -52
  69. package/dist/ui/footer/Footer.svelte +15 -15
  70. package/dist/ui/footer/FooterBrand.svelte +37 -37
  71. package/dist/ui/footer/FooterCopyright.svelte +45 -45
  72. package/dist/ui/footer/FooterIcon.svelte +22 -22
  73. package/dist/ui/footer/FooterLink.svelte +33 -33
  74. package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
  75. package/dist/ui/icons/IconifyIcon.svelte +7 -7
  76. package/dist/ui/indicator/Indicator.svelte +42 -42
  77. package/dist/ui/modal/Modal.svelte +265 -265
  78. package/dist/ui/notificationList/NotificationList.svelte +123 -123
  79. package/dist/ui/pageLoader/PageLoader.svelte +14 -14
  80. package/dist/ui/pageLoader/PageLoader2.svelte +99 -0
  81. package/dist/ui/pageLoader/PageLoader2.svelte.d.ts +24 -0
  82. package/dist/ui/pageLoader/index.d.ts +2 -1
  83. package/dist/ui/pageLoader/index.js +2 -1
  84. package/dist/ui/paginate/Paginate.svelte +96 -96
  85. package/dist/ui/speedDial/SpeedDial.svelte +77 -77
  86. package/dist/ui/speedDial/SpeedDialButton.svelte +75 -75
  87. package/dist/ui/speedDial/SpeedDialTrigger.svelte +79 -79
  88. package/dist/ui/tab/Tab.svelte +93 -67
  89. package/dist/ui/table/Table.svelte +396 -396
  90. package/dist/ui/tableLoader/TableLoader.svelte +24 -24
  91. package/dist/ui/toast/Toast.svelte +337 -337
  92. package/dist/ui/toast/Toast.svelte.d.ts +10 -10
  93. package/dist/ui/toolbar/Toolbar.svelte +59 -59
  94. package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
  95. package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
  96. package/dist/ui/tooltip/Tooltip.svelte +51 -51
  97. package/dist/utils/Popper.svelte +257 -257
  98. package/dist/utils/closeButton/CloseButton.svelte +88 -88
  99. package/dist/utils/index.d.ts +2 -2
  100. package/dist/utils/index.js +3 -3
  101. package/dist/utils/singleSelection.svelte.js +48 -48
  102. package/dist/youtube/index.svelte +12 -12
  103. package/package.json +1 -1
@@ -1,88 +1,88 @@
1
- <script lang="ts">
2
- import { key, Label } from '../../index.js';
3
- import type { FormSelectProps } from '../../types/index.js';
4
- import { getContext } from 'svelte';
5
- import Select from '../select/Select.svelte';
6
-
7
- let {
8
- label = '',
9
- required,
10
- name = '',
11
- disabled,
12
- contextKey = null,
13
- placeholder,
14
- multiple = false,
15
- onChange,
16
- ...otherProps
17
- // onchange,
18
- }: FormSelectProps = $props();
19
- const { touched, errors, data, setData }: any = getContext(contextKey || key);
20
-
21
- const hasError = $derived($touched[name] && $errors[name]?.length);
22
- const error = $derived($errors[name]?.join(', '));
23
- const value = $derived($data[name]);
24
- const isSuccess = $derived(!disabled && !hasError && $touched[name]);
25
-
26
- let renderId = $state(0);
27
-
28
- function handleChange(e: any) {
29
- if (!e) return;
30
- if (!multiple) {
31
- setData({ ...$data, [name]: e.value || e.id });
32
- } else {
33
- const d = e.map((a: any) => a.value || a.id);
34
- // console.log({ d });
35
- setData({ ...$data, [name]: d });
36
- }
37
- if (onChange) onChange(e);
38
- }
39
-
40
- // $effect(() => {
41
- // if (hasError) renderId++;
42
- // if (isSuccess) {
43
- // alert(isSuccess);
44
- // renderId++;
45
- // alert('herr');
46
- // }
47
- // });
48
- </script>
49
-
50
- <div class="relative space-y-1">
51
- <Label
52
- >{label}
53
- {#if required}
54
- <span class="pl-1 text-red-500">*</span>
55
- {/if}
56
- </Label>
57
-
58
- <!-- {#key renderId} -->
59
- <Select
60
- {name}
61
- {multiple}
62
- {value}
63
- {disabled}
64
- onChange={handleChange}
65
- {hasError}
66
- minHeight={40}
67
- hasSuccess={isSuccess}
68
- {placeholder}
69
- {...otherProps}
70
- />
71
- <!-- {/key} -->
72
-
73
- {#if hasError}
74
- <Label
75
- class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
76
- 'text-red-600'}"
77
- >
78
- <span class="v-error-message hidden backdrop-blur-sm">
79
- {error}
80
- </span>
81
- <iconify-icon
82
- icon="solar:danger-circle-bold-duotone"
83
- class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
84
- style="font-size: 18px;"
85
- ></iconify-icon>
86
- </Label>
87
- {/if}
88
- </div>
1
+ <script lang="ts">
2
+ import { key, Label } from '../../index.js';
3
+ import type { FormSelectProps } from '../../types/index.js';
4
+ import { getContext } from 'svelte';
5
+ import Select from '../select/Select.svelte';
6
+
7
+ let {
8
+ label = '',
9
+ required,
10
+ name = '',
11
+ disabled,
12
+ contextKey = null,
13
+ placeholder,
14
+ multiple = false,
15
+ onChange,
16
+ ...otherProps
17
+ // onchange,
18
+ }: FormSelectProps = $props();
19
+ const { touched, errors, data, setData }: any = getContext(contextKey || key);
20
+
21
+ const hasError = $derived($touched[name] && $errors[name]?.length);
22
+ const error = $derived($errors[name]?.join(', '));
23
+ const value = $derived($data[name]);
24
+ const isSuccess = $derived(!disabled && !hasError && $touched[name]);
25
+
26
+ let renderId = $state(0);
27
+
28
+ function handleChange(e: any) {
29
+ if (!e) return;
30
+ if (!multiple) {
31
+ setData({ ...$data, [name]: e.value || e.id });
32
+ } else {
33
+ const d = e.map((a: any) => a.value || a.id);
34
+ // console.log({ d });
35
+ setData({ ...$data, [name]: d });
36
+ }
37
+ if (onChange) onChange(e);
38
+ }
39
+
40
+ // $effect(() => {
41
+ // if (hasError) renderId++;
42
+ // if (isSuccess) {
43
+ // alert(isSuccess);
44
+ // renderId++;
45
+ // alert('herr');
46
+ // }
47
+ // });
48
+ </script>
49
+
50
+ <div class="relative space-y-1">
51
+ <Label
52
+ >{label}
53
+ {#if required}
54
+ <span class="pl-1 text-red-500">*</span>
55
+ {/if}
56
+ </Label>
57
+
58
+ <!-- {#key renderId} -->
59
+ <Select
60
+ {name}
61
+ {multiple}
62
+ {value}
63
+ {disabled}
64
+ onChange={handleChange}
65
+ {hasError}
66
+ minHeight={40}
67
+ hasSuccess={isSuccess}
68
+ {placeholder}
69
+ {...otherProps}
70
+ />
71
+ <!-- {/key} -->
72
+
73
+ {#if hasError}
74
+ <Label
75
+ class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
76
+ 'text-red-600'}"
77
+ >
78
+ <span class="v-error-message hidden backdrop-blur-sm">
79
+ {error}
80
+ </span>
81
+ <iconify-icon
82
+ icon="solar:danger-circle-bold-duotone"
83
+ class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
84
+ style="font-size: 18px;"
85
+ ></iconify-icon>
86
+ </Label>
87
+ {/if}
88
+ </div>
@@ -1,78 +1,78 @@
1
- <script lang="ts">
2
- import { key, type FormTextareaProps } from '../../index.js';
3
- import { getContext } from 'svelte';
4
- import Label from '../label/Label.svelte';
5
- import Textarea from '../textarea/Textarea.svelte';
6
-
7
- let {
8
- label = '',
9
- required,
10
- name,
11
- readonly,
12
- contextKey = null,
13
- placeholder,
14
- onchange,
15
- ...otherProps
16
- // onchange,
17
- }: FormTextareaProps = $props();
18
- const { touched, errors, data, setData }: any = getContext(contextKey || key);
19
-
20
- const hasError = $derived($touched[name] && $errors[name]?.length);
21
- const error = $derived($errors[name]?.join(', '));
22
- const isSuccess = $derived(!readonly && !hasError && $touched[name]);
23
- const isTouched = $derived(!readonly && $touched[name]);
24
-
25
- function handeleChange(e: Event) {
26
- const value = (e.target as HTMLTextAreaElement).value;
27
- // console.log({ value });
28
- setData({ ...$data, [name]: value });
29
- if (onchange) onchange(e as any);
30
- }
31
-
32
- function getNestedValue<T extends Record<string, any>>(obj: T, path: string): any {
33
- return path
34
- .split('.')
35
- .reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj);
36
- }
37
- </script>
38
-
39
- <div class="relative space-y-1">
40
- <Label
41
- >{label}
42
- {#if required}
43
- <span class="pl-1 text-red-500">*</span>
44
- {/if}
45
- </Label>
46
-
47
- <Textarea
48
- color={readonly ? 'gray' : hasError ? 'red' : isSuccess ? 'green' : 'default'}
49
- {readonly}
50
- value={getNestedValue($data, name) || ''}
51
- onchange={handeleChange}
52
- {placeholder}
53
- class="flex w-full"
54
- {...otherProps}
55
- />
56
-
57
- {#if hasError}
58
- <Label
59
- class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
60
- 'text-red-600'}"
61
- >
62
- <span class="v-error-message hidden backdrop-blur-sm">
63
- {error}
64
- </span>
65
- <iconify-icon
66
- icon="solar:danger-circle-bold-duotone"
67
- class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
68
- style="font-size: 18px;"
69
- ></iconify-icon>
70
- </Label>
71
- {/if}
72
- </div>
73
-
74
- <!-- <style>
75
- .v-error-container:hover .v-error-message {
76
- display: block !important;
77
- }
78
- </style> -->
1
+ <script lang="ts">
2
+ import { key, type FormTextareaProps } from '../../index.js';
3
+ import { getContext } from 'svelte';
4
+ import Label from '../label/Label.svelte';
5
+ import Textarea from '../textarea/Textarea.svelte';
6
+
7
+ let {
8
+ label = '',
9
+ required,
10
+ name,
11
+ readonly,
12
+ contextKey = null,
13
+ placeholder,
14
+ onchange,
15
+ ...otherProps
16
+ // onchange,
17
+ }: FormTextareaProps = $props();
18
+ const { touched, errors, data, setData }: any = getContext(contextKey || key);
19
+
20
+ const hasError = $derived($touched[name] && $errors[name]?.length);
21
+ const error = $derived($errors[name]?.join(', '));
22
+ const isSuccess = $derived(!readonly && !hasError && $touched[name]);
23
+ const isTouched = $derived(!readonly && $touched[name]);
24
+
25
+ function handeleChange(e: Event) {
26
+ const value = (e.target as HTMLTextAreaElement).value;
27
+ // console.log({ value });
28
+ setData({ ...$data, [name]: value });
29
+ if (onchange) onchange(e as any);
30
+ }
31
+
32
+ function getNestedValue<T extends Record<string, any>>(obj: T, path: string): any {
33
+ return path
34
+ .split('.')
35
+ .reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj);
36
+ }
37
+ </script>
38
+
39
+ <div class="relative space-y-1">
40
+ <Label
41
+ >{label}
42
+ {#if required}
43
+ <span class="pl-1 text-red-500">*</span>
44
+ {/if}
45
+ </Label>
46
+
47
+ <Textarea
48
+ color={readonly ? 'gray' : hasError ? 'red' : isSuccess ? 'green' : 'default'}
49
+ {readonly}
50
+ value={getNestedValue($data, name) || ''}
51
+ onchange={handeleChange}
52
+ {placeholder}
53
+ class="flex w-full"
54
+ {...otherProps}
55
+ />
56
+
57
+ {#if hasError}
58
+ <Label
59
+ class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
60
+ 'text-red-600'}"
61
+ >
62
+ <span class="v-error-message hidden backdrop-blur-sm">
63
+ {error}
64
+ </span>
65
+ <iconify-icon
66
+ icon="solar:danger-circle-bold-duotone"
67
+ class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
68
+ style="font-size: 18px;"
69
+ ></iconify-icon>
70
+ </Label>
71
+ {/if}
72
+ </div>
73
+
74
+ <!-- <style>
75
+ .v-error-container:hover .v-error-message {
76
+ display: block !important;
77
+ }
78
+ </style> -->
@@ -1,119 +1,119 @@
1
- <!-- <script lang="ts">
2
- import CheckIcon from './CheckIcon.svelte';
3
- import { buttonToggle } from './theme.js';
4
- import type { VariantProps } from 'tailwind-variants';
5
- import clsx from 'clsx';
6
- import type { ButtonToggleProps } from '../../index.js';
7
- import { getButtonToggleContext } from '../../context';
8
- import { untrack } from 'svelte';
9
- import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
10
-
11
- let {
12
- value,
13
- selected = false,
14
- children,
15
- iconSlot,
16
- color,
17
- class: className,
18
- iconClass,
19
- txtClass,
20
- contentClass,
21
- classes,
22
- ...restProps
23
- }: ButtonToggleProps = $props();
24
-
25
- warnThemeDeprecation(
26
- 'ButtonToggle',
27
- untrack(() => ({ iconClass, txtClass, contentClass })),
28
- { iconClass: 'icon', txtClass: 'text', contentClass: 'content' }
29
- );
30
-
31
- // button(className), content, text, icon
32
- const styling = $derived(classes ?? { icon: iconClass, text: txtClass, content: contentClass });
33
-
34
- const theme = $derived(getTheme('buttonToggle'));
35
-
36
- // Get context - it will be undefined if used outside ButtonToggleGroup
37
- const ctx = getButtonToggleContext();
38
-
39
- // Extract context values with fallbacks
40
- const { toggleSelected, isSelected, multiSelect, size, roundedSize, ctxIconClass, ctxBtnClass } =
41
- {
42
- toggleSelected: ctx?.toggleSelected ?? (() => {}),
43
- isSelected: ctx?.isSelected ?? (() => false),
44
- multiSelect: ctx?.multiSelect ?? false,
45
- size: ctx?.size,
46
- roundedSize: ctx?.roundedSize,
47
- ctxIconClass: ctx?.ctxIconClass,
48
- ctxBtnClass: ctx?.ctxBtnClass
49
- };
50
-
51
- // Use context color if available, otherwise use prop color, otherwise default to "primary"
52
- const actualColor = $derived(
53
- (ctx?.color ?? color ?? 'primary') as VariantProps<typeof buttonToggle>['color']
54
- );
55
- const actualIconClass = ctxIconClass;
56
-
57
- // Filter size to only valid buttonToggle sizes (no 'xs')
58
- const actualSize = (size === 'xs' ? 'sm' : size) as VariantProps<typeof buttonToggle>['size'];
59
- // roundedSize is already validated by type system
60
- const actualRoundedSize = roundedSize as VariantProps<typeof buttonToggle>['roundedSize'];
61
-
62
- function handleClick() {
63
- toggleSelected(value);
64
- }
65
-
66
- const { button, content, text, icon } = $derived(
67
- buttonToggle({ selected, color: actualColor, size: actualSize })
68
- );
69
-
70
- $effect(() => {
71
- selected = isSelected(value);
72
- });
73
- </script>
74
-
75
- <button
76
- type="button"
77
- class={button({
78
- selected,
79
- color: actualColor,
80
- size: actualSize,
81
- roundedSize: actualRoundedSize,
82
- class: clsx(theme?.button, ctxBtnClass, className)
83
- })}
84
- data-selected={selected}
85
- onclick={handleClick}
86
- role={multiSelect ? 'checkbox' : 'radio'}
87
- aria-checked={selected}
88
- {...restProps}
89
- >
90
- <div class={content({ class: clsx(theme?.content, styling.content) })}>
91
- {#if selected}
92
- {#if iconSlot}
93
- {@render iconSlot()}
94
- {:else}
95
- <CheckIcon class={icon({ class: clsx(theme?.icon ?? actualIconClass, styling.icon) })} />
96
- {/if}
97
- {/if}
98
- <span class={text({ selected, class: clsx(theme?.text, styling.text) })}>
99
- {@render children()}
100
- </span>
101
- </div>
102
- </button>
103
-
104
- @component
105
- [Go to docs](https://flowbite-svelte.com/)
106
- ## Type
107
- [ButtonToggleProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L441)
108
- ## Props
109
- @prop value
110
- @prop selected = false
111
- @prop children
112
- @prop iconSlot
113
- @prop color
114
- @prop class: className
115
- @prop iconClass
116
- @prop txtClass
117
- @prop contentClass
118
- @prop classes
119
- @prop ...restProps -->
1
+ <!-- <script lang="ts">
2
+ import CheckIcon from './CheckIcon.svelte';
3
+ import { buttonToggle } from './theme.js';
4
+ import type { VariantProps } from 'tailwind-variants';
5
+ import clsx from 'clsx';
6
+ import type { ButtonToggleProps } from '../../index.js';
7
+ import { getButtonToggleContext } from '../../context';
8
+ import { untrack } from 'svelte';
9
+ import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
10
+
11
+ let {
12
+ value,
13
+ selected = false,
14
+ children,
15
+ iconSlot,
16
+ color,
17
+ class: className,
18
+ iconClass,
19
+ txtClass,
20
+ contentClass,
21
+ classes,
22
+ ...restProps
23
+ }: ButtonToggleProps = $props();
24
+
25
+ warnThemeDeprecation(
26
+ 'ButtonToggle',
27
+ untrack(() => ({ iconClass, txtClass, contentClass })),
28
+ { iconClass: 'icon', txtClass: 'text', contentClass: 'content' }
29
+ );
30
+
31
+ // button(className), content, text, icon
32
+ const styling = $derived(classes ?? { icon: iconClass, text: txtClass, content: contentClass });
33
+
34
+ const theme = $derived(getTheme('buttonToggle'));
35
+
36
+ // Get context - it will be undefined if used outside ButtonToggleGroup
37
+ const ctx = getButtonToggleContext();
38
+
39
+ // Extract context values with fallbacks
40
+ const { toggleSelected, isSelected, multiSelect, size, roundedSize, ctxIconClass, ctxBtnClass } =
41
+ {
42
+ toggleSelected: ctx?.toggleSelected ?? (() => {}),
43
+ isSelected: ctx?.isSelected ?? (() => false),
44
+ multiSelect: ctx?.multiSelect ?? false,
45
+ size: ctx?.size,
46
+ roundedSize: ctx?.roundedSize,
47
+ ctxIconClass: ctx?.ctxIconClass,
48
+ ctxBtnClass: ctx?.ctxBtnClass
49
+ };
50
+
51
+ // Use context color if available, otherwise use prop color, otherwise default to "primary"
52
+ const actualColor = $derived(
53
+ (ctx?.color ?? color ?? 'primary') as VariantProps<typeof buttonToggle>['color']
54
+ );
55
+ const actualIconClass = ctxIconClass;
56
+
57
+ // Filter size to only valid buttonToggle sizes (no 'xs')
58
+ const actualSize = (size === 'xs' ? 'sm' : size) as VariantProps<typeof buttonToggle>['size'];
59
+ // roundedSize is already validated by type system
60
+ const actualRoundedSize = roundedSize as VariantProps<typeof buttonToggle>['roundedSize'];
61
+
62
+ function handleClick() {
63
+ toggleSelected(value);
64
+ }
65
+
66
+ const { button, content, text, icon } = $derived(
67
+ buttonToggle({ selected, color: actualColor, size: actualSize })
68
+ );
69
+
70
+ $effect(() => {
71
+ selected = isSelected(value);
72
+ });
73
+ </script>
74
+
75
+ <button
76
+ type="button"
77
+ class={button({
78
+ selected,
79
+ color: actualColor,
80
+ size: actualSize,
81
+ roundedSize: actualRoundedSize,
82
+ class: clsx(theme?.button, ctxBtnClass, className)
83
+ })}
84
+ data-selected={selected}
85
+ onclick={handleClick}
86
+ role={multiSelect ? 'checkbox' : 'radio'}
87
+ aria-checked={selected}
88
+ {...restProps}
89
+ >
90
+ <div class={content({ class: clsx(theme?.content, styling.content) })}>
91
+ {#if selected}
92
+ {#if iconSlot}
93
+ {@render iconSlot()}
94
+ {:else}
95
+ <CheckIcon class={icon({ class: clsx(theme?.icon ?? actualIconClass, styling.icon) })} />
96
+ {/if}
97
+ {/if}
98
+ <span class={text({ selected, class: clsx(theme?.text, styling.text) })}>
99
+ {@render children()}
100
+ </span>
101
+ </div>
102
+ </button>
103
+
104
+ @component
105
+ [Go to docs](https://flowbite-svelte.com/)
106
+ ## Type
107
+ [ButtonToggleProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L441)
108
+ ## Props
109
+ @prop value
110
+ @prop selected = false
111
+ @prop children
112
+ @prop iconSlot
113
+ @prop color
114
+ @prop class: className
115
+ @prop iconClass
116
+ @prop txtClass
117
+ @prop contentClass
118
+ @prop classes
119
+ @prop ...restProps -->
@@ -1,28 +1,28 @@
1
- <script lang="ts">
2
- import type { CheckIconProps } from '../../types/index.js';
3
- import clsx from 'clsx';
4
- let { class: className, ...restProps }: CheckIconProps = $props();
5
- </script>
6
-
7
- <svg
8
- xmlns="http://www.w3.org/2000/svg"
9
- width="16"
10
- height="16"
11
- viewBox="0 0 24 24"
12
- fill="none"
13
- stroke="currentColor"
14
- stroke-width="2"
15
- stroke-linecap="round"
16
- stroke-linejoin="round"
17
- class={clsx(className)}
18
- {...restProps}
19
- >
20
- <polyline points="20 6 9 17 4 12"></polyline>
21
- </svg>
22
-
23
- <!--
24
-
25
- ## Props
26
- @prop class: className
27
- @prop ...restProps
28
- -->
1
+ <script lang="ts">
2
+ import type { CheckIconProps } from '../../types/index.js';
3
+ import clsx from 'clsx';
4
+ let { class: className, ...restProps }: CheckIconProps = $props();
5
+ </script>
6
+
7
+ <svg
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ width="16"
10
+ height="16"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ stroke="currentColor"
14
+ stroke-width="2"
15
+ stroke-linecap="round"
16
+ stroke-linejoin="round"
17
+ class={clsx(className)}
18
+ {...restProps}
19
+ >
20
+ <polyline points="20 6 9 17 4 12"></polyline>
21
+ </svg>
22
+
23
+ <!--
24
+
25
+ ## Props
26
+ @prop class: className
27
+ @prop ...restProps
28
+ -->