flowbite-svelte 1.8.4 → 1.8.6
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.
|
@@ -6,14 +6,53 @@
|
|
|
6
6
|
import { Button, ToolbarButton, type DatepickerProps, cn } from "..";
|
|
7
7
|
import { datepicker } from "./theme";
|
|
8
8
|
|
|
9
|
-
let {
|
|
9
|
+
let {
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
defaultDate = null,
|
|
12
|
+
range = false,
|
|
13
|
+
rangeFrom = $bindable(),
|
|
14
|
+
rangeTo = $bindable(),
|
|
15
|
+
availableFrom = null,
|
|
16
|
+
availableTo = null,
|
|
17
|
+
locale = "default",
|
|
18
|
+
translationLocale = locale, // NEW: Separate locale for translations, defaults to locale for backward compatibility
|
|
19
|
+
firstDayOfWeek = 0,
|
|
20
|
+
dateFormat,
|
|
21
|
+
placeholder = "Select date",
|
|
22
|
+
disabled = false,
|
|
23
|
+
required = false,
|
|
24
|
+
inputClass = "",
|
|
25
|
+
color = "primary",
|
|
26
|
+
inline = false,
|
|
27
|
+
autohide = true,
|
|
28
|
+
showActionButtons = false,
|
|
29
|
+
title = "",
|
|
30
|
+
onselect,
|
|
31
|
+
onclear,
|
|
32
|
+
onapply,
|
|
33
|
+
btnClass,
|
|
34
|
+
inputmode = "none",
|
|
35
|
+
classes,
|
|
36
|
+
monthColor = "alternative",
|
|
37
|
+
monthBtnSelected = "bg-primary-500 text-white",
|
|
38
|
+
monthBtn = "text-gray-700 dark:text-gray-300",
|
|
39
|
+
class: className,
|
|
40
|
+
elementRef = $bindable() // NEW: Add elementRef prop
|
|
41
|
+
}: DatepickerProps & { translationLocale?: string; elementRef?: HTMLInputElement } = $props();
|
|
10
42
|
|
|
11
43
|
const dateFormatDefault = { year: "numeric", month: "long", day: "numeric" };
|
|
12
|
-
|
|
44
|
+
|
|
13
45
|
// Internal state
|
|
14
46
|
let isOpen: boolean = $state(inline);
|
|
15
47
|
let showMonthSelector: boolean = $state(false);
|
|
16
48
|
let inputElement: HTMLInputElement | null = $state(null);
|
|
49
|
+
|
|
50
|
+
// Update elementRef when inputElement changes
|
|
51
|
+
$effect(() => {
|
|
52
|
+
if (inputElement) {
|
|
53
|
+
elementRef = inputElement;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
17
56
|
let datepickerContainerElement: HTMLDivElement;
|
|
18
57
|
let currentMonth: Date = $state(value || defaultDate || new Date());
|
|
19
58
|
let focusedDate: Date | null = null;
|
|
@@ -60,17 +99,18 @@
|
|
|
60
99
|
return daysArray;
|
|
61
100
|
}
|
|
62
101
|
|
|
102
|
+
// MODIFIED: Use translationLocale for weekday names
|
|
63
103
|
const getWeekdayNames = (): string[] => {
|
|
64
|
-
return Array.from({ length: 7 }, (_, i) => new Date(1970, 0, 5 + i + firstDayOfWeek).toLocaleDateString(
|
|
104
|
+
return Array.from({ length: 7 }, (_, i) => new Date(1970, 0, 5 + i + firstDayOfWeek).toLocaleDateString(translationLocale, { weekday: "short" }));
|
|
65
105
|
};
|
|
66
|
-
let weekdays = getWeekdayNames();
|
|
106
|
+
let weekdays = $derived(getWeekdayNames());
|
|
67
107
|
|
|
108
|
+
// MODIFIED: Use translationLocale for month names
|
|
68
109
|
const getMonthNames = (): string[] => {
|
|
69
|
-
return Array.from({ length: 12 }, (_, i) => new Date(2000, i, 1).toLocaleDateString(
|
|
110
|
+
return Array.from({ length: 12 }, (_, i) => new Date(2000, i, 1).toLocaleDateString(translationLocale, { month: "short" }));
|
|
70
111
|
};
|
|
71
|
-
let monthNames = getMonthNames();
|
|
112
|
+
let monthNames = $derived(getMonthNames());
|
|
72
113
|
|
|
73
|
-
// const addMonth = (date: Date, increment: number): Date => new Date(date.getFullYear(), date.getMonth() + increment, 1);
|
|
74
114
|
const addDay = (date: Date, increment: number): Date => new Date(date.getFullYear(), date.getMonth(), date.getDate() + increment);
|
|
75
115
|
|
|
76
116
|
function changeMonth(increment: number) {
|
|
@@ -92,7 +132,6 @@
|
|
|
92
132
|
showMonthSelector = !showMonthSelector;
|
|
93
133
|
}
|
|
94
134
|
|
|
95
|
-
// Helper function to check if a date is available for selection
|
|
96
135
|
function isDateAvailable(date: Date): boolean {
|
|
97
136
|
const dateOnly = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
98
137
|
|
|
@@ -110,7 +149,6 @@
|
|
|
110
149
|
}
|
|
111
150
|
|
|
112
151
|
function handleDaySelect(day: Date) {
|
|
113
|
-
// Don't allow selection of unavailable dates
|
|
114
152
|
if (!isDateAvailable(day)) return;
|
|
115
153
|
|
|
116
154
|
if (range) {
|
|
@@ -145,6 +183,7 @@
|
|
|
145
183
|
}
|
|
146
184
|
}
|
|
147
185
|
|
|
186
|
+
// MODIFIED: Use locale for formatting (not translationLocale)
|
|
148
187
|
const formatDate = (date?: Date): string => date?.toLocaleDateString(locale, dateFormat) ?? "";
|
|
149
188
|
const isSameDate = (date1?: Date, date2?: Date): boolean => date1?.toDateString() === date2?.toDateString();
|
|
150
189
|
const isToday = (day: Date): boolean => isSameDate(day, new Date());
|
|
@@ -189,9 +228,9 @@
|
|
|
189
228
|
currentMonth = new Date(focusedDate.getFullYear(), focusedDate.getMonth(), 1);
|
|
190
229
|
}
|
|
191
230
|
|
|
192
|
-
//
|
|
231
|
+
// MODIFIED: Use translationLocale for aria-label
|
|
193
232
|
setTimeout(() => {
|
|
194
|
-
const focusedButton = calendarRef?.querySelector(`button[aria-label="${focusedDate!.toLocaleDateString(
|
|
233
|
+
const focusedButton = calendarRef?.querySelector(`button[aria-label="${focusedDate!.toLocaleDateString(translationLocale, { weekday: "long", year: "numeric", month: "long", day: "numeric" })}"]`) as HTMLButtonElement | null;
|
|
195
234
|
focusedButton?.focus();
|
|
196
235
|
}, 0);
|
|
197
236
|
}
|
|
@@ -271,8 +310,9 @@
|
|
|
271
310
|
<!-- Regular Calendar View -->
|
|
272
311
|
<div class={nav({ class: clsx(classes?.nav) })}>
|
|
273
312
|
{@render navButton(false)}
|
|
313
|
+
<!-- MODIFIED: Use translationLocale for month/year display -->
|
|
274
314
|
<Button type="button" class={cn(polite({ class: clsx(classes?.polite) }), "cursor-pointer rounded px-2 py-1 hover:bg-gray-100 dark:hover:bg-gray-700")} aria-live="polite" onclick={(event: MouseEvent) => toggleMonthSelector(event)}>
|
|
275
|
-
{currentMonth.toLocaleString(
|
|
315
|
+
{currentMonth.toLocaleString(translationLocale, { month: "long", year: "numeric" })}
|
|
276
316
|
</Button>
|
|
277
317
|
{@render navButton(true)}
|
|
278
318
|
</div>
|
|
@@ -295,7 +335,7 @@
|
|
|
295
335
|
})}
|
|
296
336
|
onclick={() => handleDaySelect(day)}
|
|
297
337
|
onkeydown={handleCalendarKeydown}
|
|
298
|
-
aria-label={day.toLocaleDateString(
|
|
338
|
+
aria-label={day.toLocaleDateString(translationLocale, { weekday: "long", year: "numeric", month: "long", day: "numeric" })}
|
|
299
339
|
aria-selected={isSelected(day)}
|
|
300
340
|
aria-disabled={!available}
|
|
301
341
|
disabled={!available}
|
|
@@ -317,40 +357,3 @@
|
|
|
317
357
|
</div>
|
|
318
358
|
{/if}
|
|
319
359
|
</div>
|
|
320
|
-
|
|
321
|
-
<!--
|
|
322
|
-
@component
|
|
323
|
-
[Go to docs](https://flowbite-svelte.com/)
|
|
324
|
-
## Type
|
|
325
|
-
[DatepickerProps](https://github.com/themesberg/flowbite-svelte/blob/main/src/lib/types.ts#L487)
|
|
326
|
-
## Props
|
|
327
|
-
@prop value = $bindable()
|
|
328
|
-
@prop defaultDate = null
|
|
329
|
-
@prop range = false
|
|
330
|
-
@prop rangeFrom = $bindable()
|
|
331
|
-
@prop rangeTo = $bindable()
|
|
332
|
-
@prop availableFrom = null
|
|
333
|
-
@prop availableTo = null
|
|
334
|
-
@prop locale = "default"
|
|
335
|
-
@prop firstDayOfWeek = 0
|
|
336
|
-
@prop dateFormat
|
|
337
|
-
@prop placeholder = "Select date"
|
|
338
|
-
@prop disabled = false
|
|
339
|
-
@prop required = false
|
|
340
|
-
@prop inputClass = ""
|
|
341
|
-
@prop color = "primary"
|
|
342
|
-
@prop inline = false
|
|
343
|
-
@prop autohide = true
|
|
344
|
-
@prop showActionButtons = false
|
|
345
|
-
@prop title = ""
|
|
346
|
-
@prop onselect
|
|
347
|
-
@prop onclear
|
|
348
|
-
@prop onapply
|
|
349
|
-
@prop btnClass
|
|
350
|
-
@prop inputmode = "none"
|
|
351
|
-
@prop classes
|
|
352
|
-
@prop monthColor = "alternative"
|
|
353
|
-
@prop monthBtnSelected = "bg-primary-500 text-white"
|
|
354
|
-
@prop monthBtn = "text-gray-700 dark:text-gray-300"
|
|
355
|
-
@prop class: className
|
|
356
|
-
-->
|
|
@@ -1,39 +1,8 @@
|
|
|
1
1
|
import { type DatepickerProps } from "..";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @prop value = $bindable()
|
|
8
|
-
* @prop defaultDate = null
|
|
9
|
-
* @prop range = false
|
|
10
|
-
* @prop rangeFrom = $bindable()
|
|
11
|
-
* @prop rangeTo = $bindable()
|
|
12
|
-
* @prop availableFrom = null
|
|
13
|
-
* @prop availableTo = null
|
|
14
|
-
* @prop locale = "default"
|
|
15
|
-
* @prop firstDayOfWeek = 0
|
|
16
|
-
* @prop dateFormat
|
|
17
|
-
* @prop placeholder = "Select date"
|
|
18
|
-
* @prop disabled = false
|
|
19
|
-
* @prop required = false
|
|
20
|
-
* @prop inputClass = ""
|
|
21
|
-
* @prop color = "primary"
|
|
22
|
-
* @prop inline = false
|
|
23
|
-
* @prop autohide = true
|
|
24
|
-
* @prop showActionButtons = false
|
|
25
|
-
* @prop title = ""
|
|
26
|
-
* @prop onselect
|
|
27
|
-
* @prop onclear
|
|
28
|
-
* @prop onapply
|
|
29
|
-
* @prop btnClass
|
|
30
|
-
* @prop inputmode = "none"
|
|
31
|
-
* @prop classes
|
|
32
|
-
* @prop monthColor = "alternative"
|
|
33
|
-
* @prop monthBtnSelected = "bg-primary-500 text-white"
|
|
34
|
-
* @prop monthBtn = "text-gray-700 dark:text-gray-300"
|
|
35
|
-
* @prop class: className
|
|
36
|
-
*/
|
|
37
|
-
declare const Datepicker: import("svelte").Component<DatepickerProps, {}, "value" | "rangeFrom" | "rangeTo">;
|
|
2
|
+
type $$ComponentProps = DatepickerProps & {
|
|
3
|
+
translationLocale?: string;
|
|
4
|
+
elementRef?: HTMLInputElement;
|
|
5
|
+
};
|
|
6
|
+
declare const Datepicker: import("svelte").Component<$$ComponentProps, {}, "value" | "elementRef" | "rangeFrom" | "rangeTo">;
|
|
38
7
|
type Datepicker = ReturnType<typeof Datepicker>;
|
|
39
8
|
export default Datepicker;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowbite-svelte",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"description": "Flowbite components for Svelte",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": {
|
|
@@ -12,26 +12,26 @@
|
|
|
12
12
|
"homepage": "https://flowbite-svelte.com/",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@changesets/cli": "2.29.
|
|
15
|
+
"@changesets/cli": "2.29.5",
|
|
16
16
|
"@docsearch/css": "^3.9.0",
|
|
17
17
|
"@docsearch/js": "^3.9.0",
|
|
18
18
|
"@eslint/compat": "^1.3.1",
|
|
19
19
|
"@eslint/js": "^9.30.1",
|
|
20
20
|
"@flowbite-svelte-plugins/chart": "^0.2.4",
|
|
21
21
|
"@flowbite-svelte-plugins/datatable": "^0.4.0",
|
|
22
|
-
"@flowbite-svelte-plugins/texteditor": "^0.
|
|
22
|
+
"@flowbite-svelte-plugins/texteditor": "^0.24.0",
|
|
23
23
|
"@playwright/test": "^1.53.2",
|
|
24
24
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
25
25
|
"@sveltejs/adapter-vercel": "^5.7.2",
|
|
26
26
|
"@sveltejs/kit": "^2.22.2",
|
|
27
|
-
"@sveltejs/package": "2.3.
|
|
27
|
+
"@sveltejs/package": "2.3.12",
|
|
28
28
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
29
29
|
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
|
30
30
|
"@tailwindcss/vite": "^4.1.11",
|
|
31
31
|
"@testing-library/jest-dom": "^6.6.3",
|
|
32
32
|
"@testing-library/svelte": "^5.2.8",
|
|
33
33
|
"@testing-library/user-event": "^14.6.1",
|
|
34
|
-
"@tiptap/core": "
|
|
34
|
+
"@tiptap/core": "3.0.0-beta.24",
|
|
35
35
|
"dayjs": "^1.11.13",
|
|
36
36
|
"deepmerge": "^4.3.1",
|
|
37
37
|
"eslint": "^9.30.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"prism-themes": "^1.9.0",
|
|
52
52
|
"publint": "^0.3.12",
|
|
53
53
|
"simple-datatables": "^10.0.0",
|
|
54
|
-
"svelte": "^5.35.
|
|
54
|
+
"svelte": "^5.35.4",
|
|
55
55
|
"svelte-check": "^4.2.2",
|
|
56
56
|
"svelte-doc-llm": "^0.2.2",
|
|
57
57
|
"svelte-lib-helpers": "^0.4.30",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"tailwindcss": "^4.1.11",
|
|
61
61
|
"tsx": "^4.20.3",
|
|
62
62
|
"typescript": "^5.8.3",
|
|
63
|
-
"typescript-eslint": "8.
|
|
63
|
+
"typescript-eslint": "8.36.0",
|
|
64
64
|
"vite": "^6.3.5",
|
|
65
65
|
"vite-plugin-devtools-json": "^0.2.1",
|
|
66
66
|
"vitest": "^3.2.4"
|