@glob-ui/calendar 0.0.0-stage → 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kevin Martínez E
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,17 @@
1
- # Temporary Holding Version
1
+ # @glob-ui/calendar
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A month grid for picking one day or a range of days. Values are ISO date strings ("YYYY-MM-DD"), so they serialize and compare without time zones.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @glob-ui/calendar
9
+ ```
10
+
11
+ ## Documentation
12
+
13
+ Full docs, examples and the accessibility table: [Calendar](https://github.com/kevin-martineze/GlobUI/tree/main/apps/docs/content/docs/components/calendar.mdx).
14
+
15
+ ## License
16
+
17
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,92 @@
1
+ import * as react from 'react';
2
+
3
+ interface DateRange {
4
+ from: string | null;
5
+ to: string | null;
6
+ }
7
+ interface CalendarBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
8
+ /** The first day of the week, 0 (Sunday) to 6. Default: from the locale. */
9
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
10
+ /**
11
+ * BCP 47 tag, for example "es-ES". Default: the browser's locale. Server-rendered pages show "en-US" until
12
+ * hydration, then switch; pass `locale` to avoid the switch.
13
+ */
14
+ locale?: string;
15
+ /** Earliest selectable day, "YYYY-MM-DD". Days before it are disabled and navigation stops before its month. */
16
+ min?: string;
17
+ /** Latest selectable day, "YYYY-MM-DD". Days after it are disabled and navigation stops after its month. */
18
+ max?: string;
19
+ /** Disables more days. Disabled days can still receive focus, but cannot be selected. */
20
+ isDateDisabled?: (iso: string) => boolean;
21
+ /** The visible month, "YYYY-MM" (controlled). */
22
+ month?: string;
23
+ defaultMonth?: string;
24
+ onMonthChange?: (month: string) => void;
25
+ /** Shows one month, or two side by side (stacked on small screens). */
26
+ numberOfMonths?: 1 | 2;
27
+ /** Muted days from the adjacent months. Not selectable; clicking one moves to its month. Default true. */
28
+ showOutsideDays?: boolean;
29
+ /** Called when the user picks an enabled day, even when it is already the selected one. Used by DatePicker to close. */
30
+ onSelectDay?: (iso: string) => void;
31
+ }
32
+ interface CalendarSingleProps extends CalendarBaseProps {
33
+ mode?: "single";
34
+ value?: string | null;
35
+ defaultValue?: string | null;
36
+ onChange?: (iso: string | null) => void;
37
+ /** Clicking the selected day again clears it. Default false. */
38
+ allowDeselect?: boolean;
39
+ }
40
+ interface CalendarRangeProps extends CalendarBaseProps {
41
+ mode: "range";
42
+ value?: DateRange;
43
+ defaultValue?: DateRange;
44
+ onChange?: (range: DateRange) => void;
45
+ }
46
+ type CalendarProps = CalendarSingleProps | CalendarRangeProps;
47
+ /**
48
+ * A month grid for picking one day, or a range of days. Values are "YYYY-MM-DD" strings.
49
+ * Follows the WAI-ARIA date picker grid: one tab stop, arrows move by day and week, PageUp and PageDown by month.
50
+ */
51
+ declare const Calendar: react.ForwardRefExoticComponent<CalendarProps & react.RefAttributes<HTMLDivElement>>;
52
+
53
+ /** The local calendar date of `date` as "YYYY-MM-DD". */
54
+ declare function toISODate(date: Date): string;
55
+ /** Local midnight of an ISO date. */
56
+ declare function parseISODate(iso: string): Date;
57
+ /** The date `n` days after `iso` (negative goes back). */
58
+ declare function addDays(iso: string, n: number): string;
59
+ /**
60
+ * The date `n` months after `iso`, on the same day of the month. When that day does not exist in the
61
+ * target month it is clamped to the last day: Jan 31 + 1 month is Feb 28 (or 29 in a leap year).
62
+ */
63
+ declare function addMonths(iso: string, n: number): string;
64
+ /** True when both ISO dates are the same day. */
65
+ declare function isSameDay(a: string, b: string): boolean;
66
+ /** -1, 0 or 1, for sorting ISO dates. */
67
+ declare function compareISODate(a: string, b: string): -1 | 0 | 1;
68
+ /** Today's local date as "YYYY-MM-DD". */
69
+ declare function todayISODate(): string;
70
+
71
+ /** The locale to format with: the one passed in, else the runtime default. */
72
+ declare function resolveLocale(locale?: string): string;
73
+ /**
74
+ * The first day of the week for a locale, 0 (Sunday) to 6 (Saturday). From `Intl.Locale` week data
75
+ * when the runtime has it (for example es-ES starts on Monday), otherwise Sunday.
76
+ */
77
+ declare function defaultWeekStart(locale?: string): number;
78
+ /**
79
+ * False on the server and during hydration, true after. Lets values that depend on the browser
80
+ * (its locale, today's date) render the same HTML on both sides, then update on the client.
81
+ */
82
+ declare function useHydrated(): boolean;
83
+ /** Locale used before hydration when none is passed, so server and client HTML match. */
84
+ declare const FALLBACK_LOCALE = "en-US";
85
+ /**
86
+ * The locale to render with. A passed locale is used as is. Without one, the server and the first
87
+ * client render use `FALLBACK_LOCALE`, then the browser's locale takes over. Pass `locale` in
88
+ * server-rendered apps to avoid that switch.
89
+ */
90
+ declare function useResolvedLocale(locale?: string): string;
91
+
92
+ export { Calendar, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type DateRange, FALLBACK_LOCALE, addDays, addMonths, compareISODate, defaultWeekStart, isSameDay, parseISODate, resolveLocale, toISODate, todayISODate, useHydrated, useResolvedLocale };
@@ -0,0 +1,92 @@
1
+ import * as react from 'react';
2
+
3
+ interface DateRange {
4
+ from: string | null;
5
+ to: string | null;
6
+ }
7
+ interface CalendarBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
8
+ /** The first day of the week, 0 (Sunday) to 6. Default: from the locale. */
9
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
10
+ /**
11
+ * BCP 47 tag, for example "es-ES". Default: the browser's locale. Server-rendered pages show "en-US" until
12
+ * hydration, then switch; pass `locale` to avoid the switch.
13
+ */
14
+ locale?: string;
15
+ /** Earliest selectable day, "YYYY-MM-DD". Days before it are disabled and navigation stops before its month. */
16
+ min?: string;
17
+ /** Latest selectable day, "YYYY-MM-DD". Days after it are disabled and navigation stops after its month. */
18
+ max?: string;
19
+ /** Disables more days. Disabled days can still receive focus, but cannot be selected. */
20
+ isDateDisabled?: (iso: string) => boolean;
21
+ /** The visible month, "YYYY-MM" (controlled). */
22
+ month?: string;
23
+ defaultMonth?: string;
24
+ onMonthChange?: (month: string) => void;
25
+ /** Shows one month, or two side by side (stacked on small screens). */
26
+ numberOfMonths?: 1 | 2;
27
+ /** Muted days from the adjacent months. Not selectable; clicking one moves to its month. Default true. */
28
+ showOutsideDays?: boolean;
29
+ /** Called when the user picks an enabled day, even when it is already the selected one. Used by DatePicker to close. */
30
+ onSelectDay?: (iso: string) => void;
31
+ }
32
+ interface CalendarSingleProps extends CalendarBaseProps {
33
+ mode?: "single";
34
+ value?: string | null;
35
+ defaultValue?: string | null;
36
+ onChange?: (iso: string | null) => void;
37
+ /** Clicking the selected day again clears it. Default false. */
38
+ allowDeselect?: boolean;
39
+ }
40
+ interface CalendarRangeProps extends CalendarBaseProps {
41
+ mode: "range";
42
+ value?: DateRange;
43
+ defaultValue?: DateRange;
44
+ onChange?: (range: DateRange) => void;
45
+ }
46
+ type CalendarProps = CalendarSingleProps | CalendarRangeProps;
47
+ /**
48
+ * A month grid for picking one day, or a range of days. Values are "YYYY-MM-DD" strings.
49
+ * Follows the WAI-ARIA date picker grid: one tab stop, arrows move by day and week, PageUp and PageDown by month.
50
+ */
51
+ declare const Calendar: react.ForwardRefExoticComponent<CalendarProps & react.RefAttributes<HTMLDivElement>>;
52
+
53
+ /** The local calendar date of `date` as "YYYY-MM-DD". */
54
+ declare function toISODate(date: Date): string;
55
+ /** Local midnight of an ISO date. */
56
+ declare function parseISODate(iso: string): Date;
57
+ /** The date `n` days after `iso` (negative goes back). */
58
+ declare function addDays(iso: string, n: number): string;
59
+ /**
60
+ * The date `n` months after `iso`, on the same day of the month. When that day does not exist in the
61
+ * target month it is clamped to the last day: Jan 31 + 1 month is Feb 28 (or 29 in a leap year).
62
+ */
63
+ declare function addMonths(iso: string, n: number): string;
64
+ /** True when both ISO dates are the same day. */
65
+ declare function isSameDay(a: string, b: string): boolean;
66
+ /** -1, 0 or 1, for sorting ISO dates. */
67
+ declare function compareISODate(a: string, b: string): -1 | 0 | 1;
68
+ /** Today's local date as "YYYY-MM-DD". */
69
+ declare function todayISODate(): string;
70
+
71
+ /** The locale to format with: the one passed in, else the runtime default. */
72
+ declare function resolveLocale(locale?: string): string;
73
+ /**
74
+ * The first day of the week for a locale, 0 (Sunday) to 6 (Saturday). From `Intl.Locale` week data
75
+ * when the runtime has it (for example es-ES starts on Monday), otherwise Sunday.
76
+ */
77
+ declare function defaultWeekStart(locale?: string): number;
78
+ /**
79
+ * False on the server and during hydration, true after. Lets values that depend on the browser
80
+ * (its locale, today's date) render the same HTML on both sides, then update on the client.
81
+ */
82
+ declare function useHydrated(): boolean;
83
+ /** Locale used before hydration when none is passed, so server and client HTML match. */
84
+ declare const FALLBACK_LOCALE = "en-US";
85
+ /**
86
+ * The locale to render with. A passed locale is used as is. Without one, the server and the first
87
+ * client render use `FALLBACK_LOCALE`, then the browser's locale takes over. Pass `locale` in
88
+ * server-rendered apps to avoid that switch.
89
+ */
90
+ declare function useResolvedLocale(locale?: string): string;
91
+
92
+ export { Calendar, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type DateRange, FALLBACK_LOCALE, addDays, addMonths, compareISODate, defaultWeekStart, isSameDay, parseISODate, resolveLocale, toISODate, todayISODate, useHydrated, useResolvedLocale };