flowbite-svelte 1.13.4 → 1.13.5

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.
@@ -1,46 +1,60 @@
1
1
  <script lang="ts">
2
2
  import { checkbox } from ".";
3
3
  import clsx from "clsx";
4
- import { type CheckboxProps, type CheckboxItem, Label } from "../..";
4
+ import { type CheckboxProps, Label } from "../..";
5
5
  import { getTheme, warnThemeDeprecation } from "../../theme/themeUtils";
6
6
 
7
- let { children, color = "primary", custom, inline, tinted, rounded, group = $bindable([]), choices = [], checked = $bindable(false), indeterminate, classes, class: className, divClass, disabled = false, value, labelProps = {}, ...restProps }: CheckboxProps = $props();
7
+ let { children, color = "primary", custom, inline, tinted, rounded, group = $bindable([]), choices = [], checked = $bindable(false), classes, class: className, divClass, disabled, value, labelProps = {}, ...restProps }: CheckboxProps = $props();
8
8
 
9
9
  warnThemeDeprecation("Checkbox", { divClass }, { divClass: "div" });
10
10
  const styling = $derived(classes ?? { div: divClass });
11
11
 
12
12
  const theme = getTheme("checkbox");
13
13
 
14
- const disabledValue = $derived(disabled === null ? undefined : disabled);
15
- const { base, div: divStyle } = $derived(checkbox({ color, tinted, custom, rounded, inline, disabled: disabledValue }));
14
+ const { base, div: divStyle } = $derived(checkbox({ color, tinted, custom, rounded, inline, disabled: disabled ?? false }));
16
15
 
17
- // Separate label rendering logic
18
- function renderLabel(choice?: CheckboxItem) {
19
- if (!choice) return "";
16
+ $effect(() => {
17
+ if (value !== undefined && Array.isArray(group)) {
18
+ checked = group.includes(value);
19
+ }
20
+ });
21
+
22
+ $effect(() => {
23
+ if (value === undefined || !Array.isArray(group)) return;
24
+ // There's a bug in Svelte and bind:group is not working with wrapped checkbox
25
+ // This workaround is taken from:
26
+ // https://svelte.dev/repl/de117399559f4e7e9e14e2fc9ab243cc?version=3.12.1
27
+ const index = group.indexOf(value);
28
+ if (checked === undefined) checked = index >= 0;
20
29
 
21
- if (children) {
22
- return children(choice);
30
+ if (checked) {
31
+ if (index < 0) {
32
+ group.push(value);
33
+ }
34
+ } else {
35
+ if (index >= 0) {
36
+ group.splice(index, 1);
37
+ }
23
38
  }
24
- return choice.label || "";
25
- }
39
+ });
26
40
  </script>
27
41
 
28
42
  {#if choices.length > 0}
29
- {#each choices as choice, i}
30
- <div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
31
- <Label show={true} {...labelProps}>
32
- <input type="checkbox" value={choice.value} checked={choice.checked ?? false} {disabled} bind:group {...restProps} class={base({ class: clsx(theme?.base, className) })} />
33
- {renderLabel(choice)}
34
- </Label>
35
- </div>
36
- {/each}
37
- {:else}
38
- <div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
39
- <Label show={true} {...labelProps}>
40
- <input type="checkbox" {value} bind:checked {indeterminate} {disabled} {...restProps} class={base({ class: clsx(theme?.base, className) })} />
43
+ {#each choices as choice, i (choice.value ?? i)}
44
+ <Label show={!!children || !!choice.label} {...labelProps} class={divStyle({ class: clsx(theme?.div, styling.div) })}>
45
+ <input type="checkbox" value={choice.value} checked={choice.checked ?? false} {disabled} bind:group {...restProps} class={base({ class: clsx(theme?.base, className) })} />
41
46
  {#if children}
42
- {@render children({ value, checked, disabled })}
47
+ {@render children({ value: choice.value, checked: choice.checked, disabled })}
48
+ {:else}
49
+ {choice.label}
43
50
  {/if}
44
51
  </Label>
45
- </div>
52
+ {/each}
53
+ {:else}
54
+ <Label show={!!children} {...labelProps} class={divStyle({ class: clsx(theme?.div, styling.div) })}>
55
+ <input type="checkbox" {value} bind:checked {disabled} {...restProps} class={base({ class: clsx(theme?.base, className) })} />
56
+ {#if children}
57
+ {@render children({ value, checked, disabled })}
58
+ {/if}
59
+ </Label>
46
60
  {/if}
@@ -1,56 +1,20 @@
1
1
  <script lang="ts">
2
+ import { type CheckboxButtonProps } from "../..";
2
3
  import Button from "../../buttons/Button.svelte";
4
+ import { getTheme } from "../../theme/themeUtils";
3
5
  import clsx from "clsx";
4
- import { type CheckboxButtonProps } from "../..";
6
+ import Checkbox from "./Checkbox.svelte";
5
7
  import { checkboxButton } from "./theme";
6
- import { getTheme } from "../../theme/themeUtils";
7
8
 
8
- let { children, class: className, group = $bindable([]), value, checked, inline, pill, outline, size, color, shadow, ...restProps }: CheckboxButtonProps = $props();
9
+ let { children, class: className, group = $bindable(), checked = $bindable(false), inline, pill, outline, size, color, shadow, ...restProps }: CheckboxButtonProps = $props();
9
10
 
10
11
  const theme = getTheme("checkboxButton");
11
12
 
12
- // react on external group changes
13
- function init(_: HTMLElement, _group: (string | number)[]) {
14
- group = _group ?? [];
15
-
16
- if (checked === undefined && value !== undefined) checked = group.includes(value);
17
- onChange();
18
-
19
- $effect(() => {
20
- if (value !== undefined) {
21
- checked = group.includes(value);
22
- }
23
- });
24
- }
25
-
26
- function onChange() {
27
- if (!value) return;
28
-
29
- // There's a bug in Svelte and bind:group is not working with wrapped checkbox
30
- // This workaround is taken from:
31
- // https://svelte.dev/repl/de117399559f4e7e9e14e2fc9ab243cc?version=3.12.1
32
- const index = group.indexOf(value);
33
-
34
- if (checked === undefined) checked = index >= 0;
35
-
36
- if (checked) {
37
- if (index < 0) {
38
- group.push(value);
39
- group = group;
40
- }
41
- } else {
42
- if (index >= 0) {
43
- group.splice(index, 1);
44
- group = group;
45
- }
46
- }
47
- }
48
-
49
13
  let buttonClass: string = $derived(checkboxButton({ inline, checked, class: clsx(theme, className) }));
50
14
  </script>
51
15
 
52
- <Button tag="label" {checked} {pill} {outline} {size} {color} {shadow} class={buttonClass}>
53
- <input use:init={group} type="checkbox" bind:checked {value} {...restProps} class="sr-only" onchange={onChange} />
16
+ <Button tag="label" {pill} {outline} {size} {color} {shadow} class={buttonClass}>
17
+ <Checkbox bind:group bind:checked {...restProps} class="sr-only"></Checkbox>
54
18
  {@render children?.()}
55
19
  </Button>
56
20
 
@@ -17,6 +17,6 @@ import { type CheckboxButtonProps } from "../..";
17
17
  * @prop shadow
18
18
  * @prop ...restProps
19
19
  */
20
- declare const CheckboxButton: import("svelte").Component<CheckboxButtonProps, {}, "group">;
20
+ declare const CheckboxButton: import("svelte").Component<CheckboxButtonProps, {}, "group" | "checked">;
21
21
  type CheckboxButton = ReturnType<typeof CheckboxButton>;
22
22
  export default CheckboxButton;
@@ -1,6 +1,5 @@
1
1
  import { type VariantProps } from "tailwind-variants";
2
2
  import type { Classes } from "../../theme/themeUtils";
3
- export type CheckboxVariants = VariantProps<typeof checkbox> & Classes<typeof checkbox>;
4
3
  export declare const checkbox: import("tailwind-variants").TVReturnType<{
5
4
  color: {
6
5
  primary: {
@@ -93,6 +92,7 @@ export declare const checkbox: import("tailwind-variants").TVReturnType<{
93
92
  base: string;
94
93
  div: string;
95
94
  };
95
+ false: {};
96
96
  };
97
97
  }, {
98
98
  base: string;
@@ -189,6 +189,7 @@ export declare const checkbox: import("tailwind-variants").TVReturnType<{
189
189
  base: string;
190
190
  div: string;
191
191
  };
192
+ false: {};
192
193
  };
193
194
  }, {
194
195
  base: string;
@@ -285,11 +286,13 @@ export declare const checkbox: import("tailwind-variants").TVReturnType<{
285
286
  base: string;
286
287
  div: string;
287
288
  };
289
+ false: {};
288
290
  };
289
291
  }, {
290
292
  base: string;
291
293
  div: string;
292
294
  }, undefined, unknown, unknown, undefined>>;
295
+ export type CheckboxVariants = Omit<VariantProps<typeof checkbox> & Classes<typeof checkbox>, "disabled">;
293
296
  export declare const checkboxButton: import("tailwind-variants").TVReturnType<{
294
297
  inline: {
295
298
  true: string;
@@ -315,3 +318,4 @@ export declare const checkboxButton: import("tailwind-variants").TVReturnType<{
315
318
  true: string;
316
319
  };
317
320
  }, undefined, "", unknown, unknown, undefined>>;
321
+ export type CheckboxButtonVariants = VariantProps<typeof checkboxButton>;
@@ -88,7 +88,8 @@ export const checkbox = tv({
88
88
  true: {
89
89
  base: "cursor-not-allowed opacity-50 bg-gray-200 border-gray-300",
90
90
  div: "cursor-not-allowed opacity-70"
91
- }
91
+ },
92
+ false: {},
92
93
  }
93
94
  },
94
95
  defaultVariants: {
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export * from "./sidebar";
35
35
  export * from "./skeleton";
36
36
  export * from "./speed-dial";
37
37
  export * from "./spinner";
38
- export * from "./stepindicator";
38
+ export * from "./step-indicator";
39
39
  export * from "./stepper";
40
40
  export * from "./tabs";
41
41
  export * from "./table";
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ export * from "./sidebar";
38
38
  export * from "./skeleton";
39
39
  export * from "./speed-dial";
40
40
  export * from "./spinner";
41
- export * from "./stepindicator";
41
+ export * from "./step-indicator";
42
42
  export * from "./stepper";
43
43
  export * from "./tabs";
44
44
  export * from "./table";
@@ -31,7 +31,7 @@ export { sidebar, sidebarBrand, sidebarButton, sidebarCta, sidebarDropdownWrappe
31
31
  export { cardPlaceholder, imagePlaceholder, listPlaceholder, skeleton, testimonialPlaceholder, textPlaceholder, videoPlaceholder, widgetPlaceholder } from "../skeleton";
32
32
  export { speedDial, speedDialButton } from "../speed-dial";
33
33
  export { spinner } from "../spinner";
34
- export { stepIndicator } from "../stepindicator";
34
+ export { stepIndicator } from "../step-indicator";
35
35
  export { stepper, progressStepper, verticalStepper, detailedStepper, breadcrumbStepper, timelineStepper } from "../stepper";
36
36
  export { table, tableBodyCell, tableBodyRow, tableHead, tableHeadCell, tableSearch } from "../table";
37
37
  export { tabs, tabItem } from "../tabs";
@@ -31,7 +31,7 @@ export { sidebar, sidebarBrand, sidebarButton, sidebarCta, sidebarDropdownWrappe
31
31
  export { cardPlaceholder, imagePlaceholder, listPlaceholder, skeleton, testimonialPlaceholder, textPlaceholder, videoPlaceholder, widgetPlaceholder } from "../skeleton";
32
32
  export { speedDial, speedDialButton } from "../speed-dial";
33
33
  export { spinner } from "../spinner";
34
- export { stepIndicator } from "../stepindicator";
34
+ export { stepIndicator } from "../step-indicator";
35
35
  export { stepper, progressStepper, verticalStepper, detailedStepper, breadcrumbStepper, timelineStepper } from "../stepper";
36
36
  export { table, tableBodyCell, tableBodyRow, tableHead, tableHeadCell, tableSearch } from "../table";
37
37
  export { tabs, tabItem } from "../tabs";
package/dist/types.d.ts CHANGED
@@ -29,7 +29,7 @@ import type { SidebarVariants, SidebarCtaVariants, SidebarBrandVariants, Sidebar
29
29
  import type { CardPlaceholderVariants, ImagePlaceholderVariants, ListPlaceholderVariants, SkeletonVariants, TestimonialPlaceholderVariants, TextPlaceholderVariants, VideoPlaceholderVariants, WidgetPlaceholderVariants } from "./skeleton/theme";
30
30
  import type { SpeedDialVariants, SpeedDialButtonVariants } from "./speed-dial/theme";
31
31
  import type { SpinnerVaraiants } from "./spinner/theme";
32
- import type { StepIndicatorVariants } from "./stepindicator/theme";
32
+ import type { StepIndicatorVariants } from "./step-indicator/theme";
33
33
  import type { StepperVariants, ProgressStepperVariants, DetailedStepperVariants, VerticalStepperVariants, BreadcrumbStepperVariants, TimelineStepperVariants } from "./stepper/theme";
34
34
  import type { PaginationItemVariants, PaginationVariants } from "./pagination/theme";
35
35
  import type { ProgressbarVariants, ProgressradialVariants } from "./progress/theme";
@@ -40,7 +40,7 @@ import type { TimelineVariants, ActivityItemVariants, GroupVariants, GroupItemVa
40
40
  import type { ToastVaraints } from "./toast/theme";
41
41
  import type { ToolbarButtonVariants, ToolbarGroupVariants, ToolbarVariants } from "./toolbar/theme";
42
42
  import type { TooltipVariants } from "./tooltip/theme";
43
- import type { CheckboxVariants } from "./forms/checkbox/theme";
43
+ import type { CheckboxButtonVariants, CheckboxVariants } from "./forms/checkbox/theme";
44
44
  import type { FileuploadViariants } from "./forms/fileupload/theme";
45
45
  import type { FloatingLabelInputVaratiants } from "./forms/floating-label/theme";
46
46
  import type { HelperVariants } from "./forms/helper/theme";
@@ -578,7 +578,7 @@ export interface CheckboxItem {
578
578
  checked?: boolean | null;
579
579
  [key: string]: any;
580
580
  }
581
- export interface CheckboxProps extends CheckboxVariants, Omit<HTMLInputAttributes, "children" | "color" | "disabled"> {
581
+ export interface CheckboxProps extends CheckboxVariants, Omit<HTMLInputAttributes, "children" | "color"> {
582
582
  children?: Snippet<[{
583
583
  value?: string | number;
584
584
  checked: boolean;
@@ -587,16 +587,11 @@ export interface CheckboxProps extends CheckboxVariants, Omit<HTMLInputAttribute
587
587
  inline?: boolean;
588
588
  tinted?: boolean;
589
589
  rounded?: boolean;
590
- group?: (string | number)[];
591
590
  choices?: CheckboxItem[];
592
- indeterminate?: boolean;
593
591
  divClass?: ClassValue;
594
- labelProps?: Record<string, any>;
592
+ labelProps?: Omit<LabelProps, "children">;
595
593
  }
596
- export interface CheckboxButtonProps extends Omit<HTMLInputAttributes, "size"> {
597
- group?: (string | number)[];
598
- value?: string | number;
599
- checked?: boolean;
594
+ export interface CheckboxButtonProps extends CheckboxButtonVariants, Omit<HTMLInputAttributes, "size" | "checked"> {
600
595
  inline?: boolean;
601
596
  pill?: boolean;
602
597
  outline?: boolean;
@@ -27,8 +27,10 @@ export function createSingleSelectionContext(nonReactive = false) {
27
27
  * @returns {SingleSelectionContext<T>}
28
28
  */
29
29
  function setSelected(context, open, value) {
30
- if (open) context.value = value;
31
- else if (context.value === value) context.value = undefined;
30
+ if (Object.hasOwn(context, 'value')) {
31
+ if (open) context.value = value;
32
+ else if (context.value === value) context.value = undefined;
33
+ }
32
34
  return context;
33
35
  }
34
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "1.13.4",
3
+ "version": "1.13.5",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "dist/index.js",
6
6
  "author": {
@@ -25,7 +25,7 @@
25
25
  "@sveltejs/adapter-auto": "^6.1.0",
26
26
  "@sveltejs/adapter-vercel": "^5.10.2",
27
27
  "@sveltejs/enhanced-img": "0.6.1",
28
- "@sveltejs/kit": "^2.36.3",
28
+ "@sveltejs/kit": "^2.37.0",
29
29
  "@sveltejs/package": "2.5.0",
30
30
  "@sveltejs/vite-plugin-svelte": "^6.1.3",
31
31
  "@svitejs/changesets-changelog-github-compact": "^1.2.0",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/svelte": "^5.2.8",
35
35
  "@testing-library/user-event": "^14.6.1",
36
36
  "@tiptap/core": "3.3.0",
37
- "dayjs": "^1.11.15",
37
+ "dayjs": "^1.11.18",
38
38
  "deepmerge": "^4.3.1",
39
39
  "eslint": "^9.34.0",
40
40
  "eslint-config-prettier": "^10.1.8",
@@ -58,12 +58,12 @@
58
58
  "publint": "^0.3.12",
59
59
  "runatics": "^0.1.4",
60
60
  "runes-meta-tags": "^0.4.5",
61
- "satori": "^0.16.2",
61
+ "satori": "^0.18.1",
62
62
  "satori-html": "^0.3.2",
63
63
  "simple-datatables": "^10.0.0",
64
64
  "svelte": "^5.38.6",
65
65
  "svelte-check": "^4.3.1",
66
- "svelte-doc-llm": "^0.2.2",
66
+ "svelte-doc-llm": "^0.4.0",
67
67
  "svelte-lib-helpers": "^0.4.30",
68
68
  "svelte-meta-tags": "^4.4.0",
69
69
  "svelte-rune-highlight": "^0.7.1",
@@ -634,8 +634,8 @@
634
634
  "svelte": "./dist/spinner/Spinner.svelte"
635
635
  },
636
636
  "./StepIndicator.svelte": {
637
- "types": "./dist/stepindicator/StepIndicator.svelte.d.ts",
638
- "svelte": "./dist/stepindicator/StepIndicator.svelte"
637
+ "types": "./dist/step-indicator/StepIndicator.svelte.d.ts",
638
+ "svelte": "./dist/step-indicator/StepIndicator.svelte"
639
639
  },
640
640
  "./BreadcrumbStepper.svelte": {
641
641
  "types": "./dist/stepper/BreadcrumbStepper.svelte.d.ts",
@@ -839,8 +839,8 @@
839
839
  "gen:docspropvalue": "svelte-lib-helpers docspropvalue themesberg/flowbite-svelte",
840
840
  "gen:component-data-prop-value": "svelte-lib-helpers component-data-prop-value themesberg/flowbite-svelte",
841
841
  "copy:packagejson": "svelte-lib-helpers package",
842
- "lib-helpers": "pnpm gen:component-data-prop-value && pnpm gen:docspropvalue && pnpm format && pnpm package && pnpm gen:exports && pnpm copy:packagejson && pnpm llm",
843
- "llm": "svelte-doc-llm",
842
+ "lib-helpers": "pnpm gen:component-data-prop-value && pnpm gen:docspropvalue && pnpm format && pnpm package && pnpm gen:exports && pnpm copy:packagejson && pnpm llm && pnpm update:icons-llm",
843
+ "llm": "svelte-doc-llm && ./scripts/update-llms.sh",
844
844
  "ch": "npx changeset",
845
845
  "cv": "npx changeset version",
846
846
  "cp": "npx changeset publish"
File without changes
File without changes