flowbite-svelte 0.46.22 → 0.46.23

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.
@@ -3,7 +3,7 @@ export let outerClass = "w-full";
3
3
  export let innerClass = "grid max-w-xs grid-cols-3 gap-1 p-1 mx-auto my-2 bg-gray-100 rounded-lg dark:bg-gray-600";
4
4
  </script>
5
5
 
6
- <div class={twMerge(outerClass, $$props.classOuter)} {...$$restProps}>
6
+ <div {...$$restProps} class={twMerge(outerClass, $$props.classOuter)} >
7
7
  <div class={twMerge(innerClass, $$props.classInner)} role="group">
8
8
  <slot />
9
9
  </div>
@@ -6,7 +6,7 @@ export let spanClass = "ms-1 text-sm font-medium text-gray-500 md:ms-2 dark:text
6
6
  export let homeClass = "inline-flex items-center text-sm font-medium text-gray-700 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white";
7
7
  </script>
8
8
 
9
- <li class={twMerge('inline-flex items-center', $$props.class)} {...$$restProps}>
9
+ <li {...$$restProps} class={twMerge('inline-flex items-center', $$props.class)}>
10
10
  {#if home}
11
11
  <a class={twMerge(homeClass, $$props.classHome)} {href}>
12
12
  {#if $$slots.icon}
@@ -0,0 +1,150 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { Button, Modal } from "..";
3
+ import { ChevronLeftOutline, ChevronRightOutline } from "flowbite-svelte-icons";
4
+ export let currentDate = /* @__PURE__ */ new Date();
5
+ export let open = false;
6
+ export let locale = "default";
7
+ export let firstDayOfWeek = 0;
8
+ export let showToday = true;
9
+ export let showClose = true;
10
+ export let dateFormat = { month: "long", year: "numeric" };
11
+ export let dayLabelFormat = "short";
12
+ export let customClass = "";
13
+ export let primaryColor = "blue";
14
+ export let secondaryColor = "gray";
15
+ const dispatch = createEventDispatcher();
16
+ let currentMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
17
+ let daysInMonth = getDaysInMonth(currentMonth);
18
+ function getDaysInMonth(date) {
19
+ const year = date.getFullYear();
20
+ const month = date.getMonth();
21
+ const firstDay = new Date(year, month, 1);
22
+ const lastDay = new Date(year, month + 1, 0);
23
+ const daysArray = [];
24
+ let start = firstDay.getDay() - firstDayOfWeek;
25
+ if (start < 0) start += 7;
26
+ for (let i = 0; i < start; i++) {
27
+ const prevMonthDay = new Date(year, month, -i);
28
+ daysArray.unshift(prevMonthDay);
29
+ }
30
+ for (let i = 1; i <= lastDay.getDate(); i++) {
31
+ daysArray.push(new Date(year, month, i));
32
+ }
33
+ const remainingDays = 7 - daysArray.length % 7;
34
+ if (remainingDays < 7) {
35
+ for (let i = 1; i <= remainingDays; i++) {
36
+ daysArray.push(new Date(year, month + 1, i));
37
+ }
38
+ }
39
+ return daysArray;
40
+ }
41
+ function changeMonth(increment) {
42
+ currentMonth = new Date(currentMonth.getFullYear(), currentMonth.getMonth() + increment, 1);
43
+ daysInMonth = getDaysInMonth(currentMonth);
44
+ }
45
+ function handleDaySelect(day) {
46
+ dispatch("selectDay", day);
47
+ open = false;
48
+ }
49
+ function isCurrentMonth(day) {
50
+ return day.getMonth() === currentMonth.getMonth();
51
+ }
52
+ function handleClose() {
53
+ open = false;
54
+ dispatch("close");
55
+ }
56
+ function goToToday() {
57
+ const today = /* @__PURE__ */ new Date();
58
+ currentMonth = new Date(today.getFullYear(), today.getMonth(), 1);
59
+ daysInMonth = getDaysInMonth(currentMonth);
60
+ currentDate = today;
61
+ handleDaySelect(today);
62
+ }
63
+ function isToday(day) {
64
+ const today = /* @__PURE__ */ new Date();
65
+ return day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear();
66
+ }
67
+ $: weekdays = [...Array(7)].map((_, i) => {
68
+ const day = new Date(2021, 5, i + firstDayOfWeek);
69
+ return day.toLocaleString(locale, { weekday: dayLabelFormat });
70
+ });
71
+ export function setDate(date) {
72
+ currentDate = date;
73
+ currentMonth = new Date(date.getFullYear(), date.getMonth(), 1);
74
+ daysInMonth = getDaysInMonth(currentMonth);
75
+ }
76
+ export function nextMonth() {
77
+ changeMonth(1);
78
+ }
79
+ export function previousMonth() {
80
+ changeMonth(-1);
81
+ }
82
+ export function setMonth(month) {
83
+ currentMonth = new Date(currentMonth.getFullYear(), month, 1);
84
+ daysInMonth = getDaysInMonth(currentMonth);
85
+ }
86
+ export function setYear(year) {
87
+ currentMonth = new Date(year, currentMonth.getMonth(), 1);
88
+ daysInMonth = getDaysInMonth(currentMonth);
89
+ }
90
+ </script>
91
+
92
+ <Modal bind:open size="xs" autoclose={false} class={`w-full ${customClass}`}>
93
+ <div class="w-full max-w-md rounded-lg p-6">
94
+ <div class="mb-4 flex items-center justify-between">
95
+ <Button size="sm" on:click={() => changeMonth(-1)} color={primaryColor}>
96
+ <ChevronLeftOutline size="md" />
97
+ </Button>
98
+ <span class="text-lg font-semibold">
99
+ {currentMonth.toLocaleString(locale, dateFormat)}
100
+ </span>
101
+ <Button size="sm" on:click={() => changeMonth(1)} color={primaryColor}>
102
+ <ChevronRightOutline size="md" />
103
+ </Button>
104
+ </div>
105
+ <div class="grid grid-cols-7 gap-2">
106
+ {#each weekdays as day}
107
+ <div class="text-center text-sm font-medium">{day}</div>
108
+ {/each}
109
+ {#each daysInMonth as day}
110
+ <Button
111
+ size="sm"
112
+ color={currentDate.toDateString() === day.toDateString()
113
+ ? primaryColor
114
+ : isToday(day)
115
+ ? secondaryColor
116
+ : 'alternative'}
117
+ class={!isCurrentMonth(day) ? 'opacity-50' : ''}
118
+ on:click={() => handleDaySelect(day)}
119
+ >
120
+ {day.getDate()}
121
+ </Button>
122
+ {/each}
123
+ </div>
124
+ <div class="mt-4 flex justify-between">
125
+ {#if showToday}
126
+ <Button size="sm" color={primaryColor} on:click={goToToday}>Today</Button>
127
+ {/if}
128
+ {#if showClose}
129
+ <Button size="sm" color={primaryColor} on:click={handleClose}>Close</Button>
130
+ {/if}
131
+ </div>
132
+ </div>
133
+ </Modal>
134
+
135
+ <!--
136
+ @component
137
+ [Go to docs](https://flowbite-svelte.com/)
138
+ ## Props
139
+ @prop export let currentDate: Date = new Date();
140
+ @prop export let open = false;
141
+ @prop export let locale: string = 'default';
142
+ @prop export let firstDayOfWeek: number = 0;
143
+ @prop export let showToday: boolean = true;
144
+ @prop export let showClose: boolean = true;
145
+ @prop export let dateFormat: Intl.DateTimeFormatOptions = { month: 'long', year: 'numeric' };
146
+ @prop export let dayLabelFormat: 'short' | 'narrow' | 'long' = 'short';
147
+ @prop export let customClass: string = '';
148
+ @prop export let primaryColor: Button['color'] = 'blue';
149
+ @prop export let secondaryColor: string = 'gray';
150
+ -->
@@ -0,0 +1,55 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import { Button } from '..';
3
+ declare const __propDef: {
4
+ props: {
5
+ currentDate?: Date;
6
+ open?: boolean;
7
+ locale?: string;
8
+ firstDayOfWeek?: number;
9
+ showToday?: boolean;
10
+ showClose?: boolean;
11
+ dateFormat?: Intl.DateTimeFormatOptions;
12
+ dayLabelFormat?: "short" | "narrow" | "long";
13
+ customClass?: string;
14
+ primaryColor?: Button["color"];
15
+ secondaryColor?: string;
16
+ setDate?: (date: Date) => void;
17
+ nextMonth?: () => void;
18
+ previousMonth?: () => void;
19
+ setMonth?: (month: number) => void;
20
+ setYear?: (year: number) => void;
21
+ };
22
+ events: {
23
+ selectDay: CustomEvent<any>;
24
+ close: CustomEvent<any>;
25
+ } & {
26
+ [evt: string]: CustomEvent<any>;
27
+ };
28
+ slots: {};
29
+ };
30
+ export type DateCalenderProps = typeof __propDef.props;
31
+ export type DateCalenderEvents = typeof __propDef.events;
32
+ export type DateCalenderSlots = typeof __propDef.slots;
33
+ /**
34
+ * [Go to docs](https://flowbite-svelte.com/)
35
+ * ## Props
36
+ * @prop export let currentDate: Date = new Date();
37
+ * @prop export let open = false;
38
+ * @prop export let locale: string = 'default';
39
+ * @prop export let firstDayOfWeek: number = 0;
40
+ * @prop export let showToday: boolean = true;
41
+ * @prop export let showClose: boolean = true;
42
+ * @prop export let dateFormat: Intl.DateTimeFormatOptions = { month: 'long', year: 'numeric' };
43
+ * @prop export let dayLabelFormat: 'short' | 'narrow' | 'long' = 'short';
44
+ * @prop export let customClass: string = '';
45
+ * @prop export let primaryColor: Button['color'] = 'blue';
46
+ * @prop export let secondaryColor: string = 'gray';
47
+ */
48
+ export default class DateCalender extends SvelteComponentTyped<DateCalenderProps, DateCalenderEvents, DateCalenderSlots> {
49
+ get setDate(): (date: Date) => void;
50
+ get nextMonth(): () => void;
51
+ get previousMonth(): () => void;
52
+ get setMonth(): (month: number) => void;
53
+ get setYear(): (year: number) => void;
54
+ }
55
+ export {};
@@ -2,7 +2,7 @@
2
2
  export let ulClass = "text-gray-600 dark:text-gray-400";
3
3
  </script>
4
4
 
5
- <ul class={twMerge(ulClass, $$props.class)} {...$$restProps}>
5
+ <ul {...$$restProps} class={twMerge(ulClass, $$props.class)} >
6
6
  <slot />
7
7
  </ul>
8
8
 
@@ -9,27 +9,29 @@ export let outline = false;
9
9
  export let size = void 0;
10
10
  export let color = void 0;
11
11
  export let shadow = false;
12
- function init(_, _group) {
13
- if (checked === void 0) checked = _group.includes(value);
14
- onChange();
15
- return {
16
- update(_group2) {
12
+ function init(node, _group) {
13
+ function update(_group2) {
14
+ if (_group2 && value !== void 0) {
17
15
  checked = _group2.includes(value);
18
16
  }
19
- };
17
+ }
18
+ update(_group);
19
+ return { update };
20
20
  }
21
21
  function onChange() {
22
- const index = group.indexOf(value);
23
- if (checked === void 0) checked = index >= 0;
24
- if (checked) {
25
- if (index < 0) {
26
- group.push(value);
27
- group = group;
28
- }
29
- } else {
30
- if (index >= 0) {
31
- group.splice(index, 1);
32
- group = group;
22
+ if (group && value !== void 0) {
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
+ }
33
35
  }
34
36
  }
35
37
  }
@@ -42,7 +44,7 @@ $: buttonClass = twMerge(inline ? "inline-flex" : "flex", $$props.class);
42
44
  use:init={group}
43
45
  type="checkbox"
44
46
  bind:checked
45
- {value}
47
+ value={value !== undefined ? value : 'on'}
46
48
  {...$$restProps}
47
49
  class="sr-only"
48
50
  on:keyup
@@ -23,14 +23,14 @@ declare const __propDef: {
23
23
  disabled?: import("svelte/elements").HTMLButtonAttributes["disabled"];
24
24
  type?: import("svelte/elements").HTMLButtonAttributes["type"];
25
25
  })) & {
26
- group: (string | number)[];
27
- value: string | number;
26
+ group?: (string | number)[];
27
+ value?: string | number;
28
28
  checked?: boolean;
29
29
  inline?: boolean;
30
30
  pill?: boolean;
31
31
  outline?: boolean;
32
- size?: SizeType | undefined;
33
- color?: ButtonColorType | undefined;
32
+ size?: SizeType;
33
+ color?: ButtonColorType;
34
34
  shadow?: boolean;
35
35
  };
36
36
  events: {
@@ -9,8 +9,8 @@ declare const __propDef: {
9
9
  color?: "base" | "green" | "red";
10
10
  floatClass?: string;
11
11
  } & {
12
- value: string;
13
- files: FileList | undefined;
12
+ value?: string;
13
+ files?: FileList | undefined;
14
14
  inputClass?: string;
15
15
  };
16
16
  events: {
@@ -51,7 +51,7 @@ const clearAll = (e) => {
51
51
  };
52
52
  </script>
53
53
 
54
- <Wrapper class="relative w-full" show>
54
+ <Wrapper class="relative w-full" show={$$slots.left || $$slots.right}>
55
55
  {#if $$slots.left}
56
56
  <div class="{twMerge(floatClass, $$props.classLeft)} start-0 ps-2.5 pointer-events-none">
57
57
  <slot name="left" />
@@ -60,14 +60,14 @@ const clearAll = (e) => {
60
60
  <slot props={{ ...$$restProps, class: inputClass }}>
61
61
  <input {...$$restProps} bind:value on:blur on:change on:click on:contextmenu on:focus on:keydown on:keypress on:keyup on:mouseover on:mouseenter on:mouseleave on:paste on:input {...{ type }} class={inputClass} />
62
62
  </slot>
63
+ {#if $$slots.right}
63
64
  <div class="{twMerge(floatClass, $$props.classRight)} end-0 pe-2.5">
64
- {#if $$slots.right}
65
- <slot name="right"></slot>
66
- {/if}
67
- {#if clearable && value && `${value}`.length > 0}
68
- <CloseButton {size} on:click={clearAll} color="none" class="p-0 focus:ring-gray-400 dark:text-white" />
69
- {/if}
65
+ <slot name="right"></slot>
70
66
  </div>
67
+ {/if}
68
+ {#if clearable && value && `${value}`.length > 0}
69
+ <CloseButton {size} on:click={clearAll} color="none" class=" {twMerge(floatClass, $$props.classRight)} focus:ring-0 end-6 focus:ring-gray-400 dark:text-white" />
70
+ {/if}
71
71
  </Wrapper>
72
72
 
73
73
  <!--
@@ -57,7 +57,7 @@ let dotClass;
57
57
  $: dotClass = twMerge("flex-shrink-0", rounded ? "rounded" : "rounded-full", border && "border-2 border-white dark:border-gray-800", sizes[size], colors[color], $$slots.default && "inline-flex items-center justify-center", placement && "absolute " + placements[placement], placement && offset && offsets[placement], $$props.class);
58
58
  </script>
59
59
 
60
- <div class={dotClass} {...$$restProps}><slot /></div>
60
+ <div {...$$restProps} class={dotClass} ><slot /></div>
61
61
 
62
62
  <!--
63
63
  @component
@@ -2,7 +2,7 @@
2
2
  export let fluid = false;
3
3
  </script>
4
4
 
5
- <div class={twMerge('mx-auto flex flex-wrap justify-between items-center ', fluid ? 'w-full' : 'container', $$props.class)} {...$$restProps}>
5
+ <div {...$$restProps} class={twMerge('mx-auto flex flex-wrap justify-between items-center ', fluid ? 'w-full' : 'container', $$props.class)} >
6
6
  <slot />
7
7
  </div>
8
8
 
@@ -8,7 +8,7 @@ let sorter = getContext("sorter");
8
8
  $: sorted = $sorter ? filtered.toSorted((a, b) => $sorter.sortDirection * $sorter.sort(a, b)) : filtered;
9
9
  </script>
10
10
 
11
- <tbody class={tableBodyClass} {...$$restProps}>
11
+ <tbody {...$$restProps} class={tableBodyClass}>
12
12
  <slot />
13
13
  {#each sorted as item}
14
14
  <slot name="row" {item} />
@@ -37,7 +37,7 @@ function init(node) {
37
37
  $: ulClass = twMerge(defaultClass, tabStyle === "underline" && "-mb-px", $$props.class);
38
38
  </script>
39
39
 
40
- <ul class={ulClass} {...$$restProps}>
40
+ <ul {...$$restProps} class={ulClass}>
41
41
  <slot {tabStyle}></slot>
42
42
  </ul>
43
43
  {#if divider}
@@ -10,7 +10,7 @@ let olCls = twMerge(olClass, $$props.classOl);
10
10
 
11
11
  <div class={divCls}>
12
12
  <time class={timeCls}>{date}</time>
13
- <ol class={olCls} {...$$restProps}>
13
+ <ol {...$$restProps} class={olCls}>
14
14
  <slot />
15
15
  </ol>
16
16
  </div>
@@ -11,7 +11,7 @@ let olClasses = {
11
11
  };
12
12
  </script>
13
13
 
14
- <ol class={twMerge(olClasses[order], $$props.class)} {...$$restProps}>
14
+ <ol {...$$restProps} class={twMerge(olClasses[order], $$props.class)} >
15
15
  <slot />
16
16
  </ol>
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowbite-svelte",
3
- "version": "0.46.22",
3
+ "version": "0.46.23",
4
4
  "description": "Flowbite components for Svelte",
5
5
  "main": "dist/index.js",
6
6
  "author": {
@@ -12,12 +12,12 @@
12
12
  "homepage": "https://flowbite-svelte.com/",
13
13
  "license": "MIT",
14
14
  "devDependencies": {
15
- "@changesets/cli": "^2.27.8",
15
+ "@changesets/cli": "^2.27.9",
16
16
  "@docsearch/css": "^3.6.2",
17
17
  "@docsearch/js": "^3.6.2",
18
- "@playwright/test": "^1.47.2",
19
- "@sveltejs/adapter-vercel": "^5.4.4",
20
- "@sveltejs/kit": "^2.6.1",
18
+ "@playwright/test": "^1.48.0",
19
+ "@sveltejs/adapter-vercel": "^5.4.5",
20
+ "@sveltejs/kit": "^2.6.3",
21
21
  "@sveltejs/package": "2.3.2",
22
22
  "@sveltejs/vite-plugin-svelte": "^3.1.2",
23
23
  "@svitejs/changesets-changelog-github-compact": "^1.1.0",
@@ -25,11 +25,9 @@
25
25
  "autoprefixer": "^10.4.20",
26
26
  "dayjs": "^1.11.13",
27
27
  "esbuild": "0.23.1",
28
- "eslint": "^9.11.1",
28
+ "eslint": "^9.12.0",
29
29
  "eslint-config-prettier": "^9.1.0",
30
30
  "eslint-plugin-svelte": "^2.44.1",
31
- "flowbite-svelte": "^0.46.22",
32
- "flowbite-svelte-blocks": "^1.1.3",
33
31
  "flowbite-svelte-icons": "^1.6.1",
34
32
  "mdsvex": "^0.12.3",
35
33
  "mdsvexamples": "^0.4.1",
@@ -40,14 +38,14 @@
40
38
  "publint": "^0.2.11",
41
39
  "svelte": "^4.2.19",
42
40
  "svelte-check": "^4.0.4",
43
- "svelte-lib-helpers": "^0.4.9",
41
+ "svelte-lib-helpers": "^0.4.16",
44
42
  "svelte-meta-tags": "^3.1.4",
45
43
  "svelte-preprocess": "^6.0.3",
46
44
  "svelte2tsx": "^0.7.21",
47
45
  "tailwind-merge": "^1.13.1",
48
46
  "tailwindcss": "^3.4.13",
49
47
  "tslib": "^2.7.0",
50
- "typescript": "^5.6.2",
48
+ "typescript": "^5.6.3",
51
49
  "typescript-eslint": "8.4.0",
52
50
  "vite": "^5.4.8",
53
51
  "vitest": "^1.6.0"
@@ -102,7 +100,7 @@
102
100
  "@floating-ui/dom": "^1.6.11",
103
101
  "apexcharts": "^3.54.0",
104
102
  "flowbite": "^2.5.2",
105
- "tailwind-merge": "^2.5.2"
103
+ "tailwind-merge": "^2.5.3"
106
104
  },
107
105
  "engines": {
108
106
  "pnpm": ">=8.0.0",
@@ -224,6 +222,10 @@
224
222
  "types": "./dist/datepicker/Calender.svelte.d.ts",
225
223
  "svelte": "./dist/datepicker/Calender.svelte"
226
224
  },
225
+ "./DateCalender.svelte": {
226
+ "types": "./dist/datepicker/DateCalender.svelte.d.ts",
227
+ "svelte": "./dist/datepicker/DateCalender.svelte"
228
+ },
227
229
  "./Datepicker.svelte": {
228
230
  "types": "./dist/datepicker/Datepicker.svelte.d.ts",
229
231
  "svelte": "./dist/datepicker/Datepicker.svelte"