flowbite-svelte 0.46.7 → 0.46.9

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,54 +1,39 @@
1
- <script>import { twMerge } from "tailwind-merge";
2
- import { getContext } from "svelte";
1
+ <script>import { getContext } from "svelte";
3
2
  import { labelClass, inputClass } from "./Radio.svelte";
4
3
  import Label from "./Label.svelte";
4
+ export let name;
5
5
  export let color = "primary";
6
6
  export let custom = false;
7
7
  export let inline = false;
8
- export let group = [];
8
+ export let group;
9
+ export let choices;
9
10
  export let value = "on";
10
11
  export let checked = void 0;
11
12
  export let spacing = $$slots.default ? "me-2" : "";
12
13
  let background = getContext("background");
13
- function init(_, _group) {
14
- if (checked === void 0) checked = _group.includes(value);
15
- onChange();
16
- return {
17
- update(_group2) {
18
- checked = _group2.includes(value);
19
- }
20
- };
21
- }
22
- function onChange() {
23
- const index = group.indexOf(value);
24
- if (checked === void 0) checked = index >= 0;
25
- if (checked) {
26
- if (index < 0) {
27
- group.push(value);
28
- group = group;
29
- }
30
- } else {
31
- if (index >= 0) {
32
- group.splice(index, 1);
33
- group = group;
34
- }
35
- }
36
- }
37
14
  </script>
38
-
15
+ {#if group}
16
+ {#each choices as checkbox}
17
+ <label for={`checkbox-${value}`}>{ checkbox.label }</label>
18
+ <input type="checkbox" value={ checkbox.value } bind:group>
19
+ {/each}
20
+ {:else}
39
21
  <Label class={labelClass(inline, $$props.class)} show={$$slots.default}>
40
- <input use:init={group} type="checkbox" bind:checked on:keyup on:keydown on:keypress on:focus on:blur on:click on:mouseover on:mouseenter on:mouseleave on:paste on:change={onChange} on:change {value} {...$$restProps} class={inputClass(custom, color, true, background, spacing, $$slots.default || $$props.class)} />
22
+ <input {name} type="checkbox" bind:checked on:keyup on:keydown on:keypress on:focus on:blur on:click on:mouseover on:mouseenter on:mouseleave on:paste on:change {value} {...$$restProps} class={inputClass(custom, color, true, background, spacing, $$slots.default || $$props.class)} />
41
23
  <slot />
42
24
  </Label>
25
+ {/if}
43
26
 
44
27
  <!--
45
28
  @component
46
29
  [Go to docs](https://flowbite-svelte.com/)
47
30
  ## Props
31
+ @prop export let name: string;
48
32
  @prop export let color: FormColorType = 'primary';
49
33
  @prop export let custom: boolean = false;
50
34
  @prop export let inline: boolean = false;
51
- @prop export let group: (string | number)[] = [];
35
+ @prop export let group: CheckboxItem[];
36
+ @prop export let choices: CheckboxItem[];
52
37
  @prop export let value: string | number = 'on';
53
38
  @prop export let checked: boolean | undefined = undefined;
54
39
  @prop export let spacing: string = $$slots.default ? 'me-2' : '';
@@ -3,10 +3,20 @@ import type { FormColorType } from '../types';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
+ name: string;
6
7
  color?: FormColorType;
7
8
  custom?: boolean;
8
9
  inline?: boolean;
9
- group?: (string | number)[];
10
+ group: {
11
+ value: string;
12
+ label: string;
13
+ isChecked?: boolean;
14
+ }[];
15
+ choices: {
16
+ value: string;
17
+ label: string;
18
+ isChecked?: boolean;
19
+ }[];
10
20
  value?: string | number;
11
21
  checked?: boolean | undefined;
12
22
  spacing?: string;
@@ -36,10 +46,12 @@ export type CheckboxSlots = typeof __propDef.slots;
36
46
  /**
37
47
  * [Go to docs](https://flowbite-svelte.com/)
38
48
  * ## Props
49
+ * @prop export let name: string;
39
50
  * @prop export let color: FormColorType = 'primary';
40
51
  * @prop export let custom: boolean = false;
41
52
  * @prop export let inline: boolean = false;
42
- * @prop export let group: (string | number)[] = [];
53
+ * @prop export let group: CheckboxItem[];
54
+ * @prop export let choices: CheckboxItem[];
43
55
  * @prop export let value: string | number = 'on';
44
56
  * @prop export let checked: boolean | undefined = undefined;
45
57
  * @prop export let spacing: string = $$slots.default ? 'me-2' : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.46.7",
3
+ "version": "0.46.9",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "dist/index.js",
6
6
  "author": {
@@ -28,7 +28,7 @@
28
28
  "eslint": "^9.5.0",
29
29
  "eslint-config-prettier": "^9.1.0",
30
30
  "eslint-plugin-svelte": "^2.41.0",
31
- "flowbite-svelte": "^0.46.7",
31
+ "flowbite-svelte": "^0.46.9",
32
32
  "flowbite-svelte-blocks": "^1.1.3",
33
33
  "flowbite-svelte-icons": "^1.6.1",
34
34
  "mdsvex": "^0.11.2",