jaci-ui 0.3.0 → 0.5.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/CHANGELOG.md +14 -0
- package/README.md +85 -0
- package/dist/components/calendar/calendar.cjs +377 -0
- package/dist/components/calendar/calendar.cjs.map +1 -0
- package/dist/components/calendar/calendar.d.cts +56 -0
- package/dist/components/calendar/calendar.d.ts +56 -0
- package/dist/components/calendar/calendar.js +368 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.cts +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/combobox/combobox.cjs +13 -1
- package/dist/components/combobox/combobox.cjs.map +1 -1
- package/dist/components/combobox/combobox.d.cts +7 -2
- package/dist/components/combobox/combobox.d.ts +7 -2
- package/dist/components/combobox/combobox.js +13 -2
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/combobox/index.d.cts +2 -2
- package/dist/components/combobox/index.d.ts +2 -2
- package/dist/components/command/command.cjs +55 -34
- package/dist/components/command/command.cjs.map +1 -1
- package/dist/components/command/command.d.cts +1 -0
- package/dist/components/command/command.d.ts +1 -0
- package/dist/components/command/command.js +55 -34
- package/dist/components/command/command.js.map +1 -1
- package/dist/components/controls/input.cjs +26 -5
- package/dist/components/controls/input.cjs.map +1 -1
- package/dist/components/controls/input.d.cts +5 -2
- package/dist/components/controls/input.d.ts +5 -2
- package/dist/components/controls/input.js +28 -7
- package/dist/components/controls/input.js.map +1 -1
- package/dist/components/controls/textarea.cjs +26 -5
- package/dist/components/controls/textarea.cjs.map +1 -1
- package/dist/components/controls/textarea.d.cts +5 -2
- package/dist/components/controls/textarea.d.ts +5 -2
- package/dist/components/controls/textarea.js +28 -7
- package/dist/components/controls/textarea.js.map +1 -1
- package/dist/components/data-toolbar/data-toolbar.cjs +141 -0
- package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -0
- package/dist/components/data-toolbar/data-toolbar.d.cts +50 -0
- package/dist/components/data-toolbar/data-toolbar.d.ts +50 -0
- package/dist/components/data-toolbar/data-toolbar.js +132 -0
- package/dist/components/data-toolbar/data-toolbar.js.map +1 -0
- package/dist/components/data-toolbar/index.d.cts +2 -0
- package/dist/components/data-toolbar/index.d.ts +2 -0
- package/dist/components/data-view/data-view.cjs +33 -1
- package/dist/components/data-view/data-view.cjs.map +1 -1
- package/dist/components/data-view/data-view.d.cts +12 -1
- package/dist/components/data-view/data-view.d.ts +12 -1
- package/dist/components/data-view/data-view.js +31 -2
- package/dist/components/data-view/data-view.js.map +1 -1
- package/dist/components/data-view/index.d.cts +2 -2
- package/dist/components/data-view/index.d.ts +2 -2
- package/dist/components/date-picker/date-picker.cjs +9 -9
- package/dist/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/components/date-picker/date-picker.d.cts +3 -1
- package/dist/components/date-picker/date-picker.d.ts +3 -1
- package/dist/components/date-picker/date-picker.js +9 -9
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/date-range-picker/date-range-picker.cjs +589 -0
- package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -0
- package/dist/components/date-range-picker/date-range-picker.d.cts +134 -0
- package/dist/components/date-range-picker/date-range-picker.d.ts +134 -0
- package/dist/components/date-range-picker/date-range-picker.js +568 -0
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -0
- package/dist/components/date-range-picker/index.d.cts +2 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/field/field.cjs +106 -11
- package/dist/components/field/field.cjs.map +1 -1
- package/dist/components/field/field.d.cts +22 -4
- package/dist/components/field/field.d.ts +22 -4
- package/dist/components/field/field.js +107 -13
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/index.d.cts +2 -2
- package/dist/components/field/index.d.ts +2 -2
- package/dist/components/list/list.cjs +3 -1
- package/dist/components/list/list.cjs.map +1 -1
- package/dist/components/list/list.d.cts +3 -1
- package/dist/components/list/list.d.ts +3 -1
- package/dist/components/list/list.js +3 -1
- package/dist/components/list/list.js.map +1 -1
- package/dist/components/pagination/index.d.cts +2 -2
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/pagination.cjs +122 -21
- package/dist/components/pagination/pagination.cjs.map +1 -1
- package/dist/components/pagination/pagination.d.cts +25 -13
- package/dist/components/pagination/pagination.d.ts +25 -13
- package/dist/components/pagination/pagination.js +122 -23
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/pin-input/index.d.cts +2 -0
- package/dist/components/pin-input/index.d.ts +2 -0
- package/dist/components/pin-input/pin-input.cjs +266 -0
- package/dist/components/pin-input/pin-input.cjs.map +1 -0
- package/dist/components/pin-input/pin-input.d.cts +46 -0
- package/dist/components/pin-input/pin-input.d.ts +46 -0
- package/dist/components/pin-input/pin-input.js +258 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/select/index.d.cts +2 -2
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/select.cjs +80 -3
- package/dist/components/select/select.cjs.map +1 -1
- package/dist/components/select/select.d.cts +18 -3
- package/dist/components/select/select.d.ts +18 -3
- package/dist/components/select/select.js +78 -5
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/table/index.d.cts +2 -2
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/table.cjs +265 -46
- package/dist/components/table/table.cjs.map +1 -1
- package/dist/components/table/table.d.cts +41 -8
- package/dist/components/table/table.d.ts +41 -8
- package/dist/components/table/table.js +264 -48
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tags-input/tags-input.cjs +83 -5
- package/dist/components/tags-input/tags-input.cjs.map +1 -1
- package/dist/components/tags-input/tags-input.d.cts +3 -0
- package/dist/components/tags-input/tags-input.d.ts +3 -0
- package/dist/components/tags-input/tags-input.js +83 -5
- package/dist/components/tags-input/tags-input.js.map +1 -1
- package/dist/components/tree-view/index.d.cts +2 -2
- package/dist/components/tree-view/index.d.ts +2 -2
- package/dist/components/tree-view/tree-view.cjs +60 -3
- package/dist/components/tree-view/tree-view.cjs.map +1 -1
- package/dist/components/tree-view/tree-view.d.cts +12 -1
- package/dist/components/tree-view/tree-view.d.ts +12 -1
- package/dist/components/tree-view/tree-view.js +58 -4
- package/dist/components/tree-view/tree-view.js.map +1 -1
- package/dist/components/upload/index.d.cts +2 -2
- package/dist/components/upload/index.d.ts +2 -2
- package/dist/components/upload/upload.cjs +90 -10
- package/dist/components/upload/upload.cjs.map +1 -1
- package/dist/components/upload/upload.d.cts +25 -2
- package/dist/components/upload/upload.d.ts +25 -2
- package/dist/components/upload/upload.js +89 -11
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/index.cjs +74 -1
- package/dist/index.d.cts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +14 -10
- package/dist/styled-system/recipes/calendar.cjs +43 -0
- package/dist/styled-system/recipes/calendar.cjs.map +1 -0
- package/dist/styled-system/recipes/calendar.js +43 -0
- package/dist/styled-system/recipes/calendar.js.map +1 -0
- package/dist/styled-system/recipes/combobox.cjs +1 -0
- package/dist/styled-system/recipes/combobox.cjs.map +1 -1
- package/dist/styled-system/recipes/combobox.js +1 -0
- package/dist/styled-system/recipes/combobox.js.map +1 -1
- package/dist/styled-system/recipes/data-toolbar.cjs +40 -0
- package/dist/styled-system/recipes/data-toolbar.cjs.map +1 -0
- package/dist/styled-system/recipes/data-toolbar.js +40 -0
- package/dist/styled-system/recipes/data-toolbar.js.map +1 -0
- package/dist/styled-system/recipes/data-view.cjs +3 -0
- package/dist/styled-system/recipes/data-view.cjs.map +1 -1
- package/dist/styled-system/recipes/data-view.js +3 -0
- package/dist/styled-system/recipes/data-view.js.map +1 -1
- package/dist/styled-system/recipes/date-range-picker.cjs +52 -0
- package/dist/styled-system/recipes/date-range-picker.cjs.map +1 -0
- package/dist/styled-system/recipes/date-range-picker.js +52 -0
- package/dist/styled-system/recipes/date-range-picker.js.map +1 -0
- package/dist/styled-system/recipes/list.cjs +7 -1
- package/dist/styled-system/recipes/list.cjs.map +1 -1
- package/dist/styled-system/recipes/list.js +7 -1
- package/dist/styled-system/recipes/list.js.map +1 -1
- package/dist/styled-system/recipes/pagination.cjs +9 -1
- package/dist/styled-system/recipes/pagination.cjs.map +1 -1
- package/dist/styled-system/recipes/pagination.js +9 -1
- package/dist/styled-system/recipes/pagination.js.map +1 -1
- package/dist/styled-system/recipes/pin-input.cjs +39 -0
- package/dist/styled-system/recipes/pin-input.cjs.map +1 -0
- package/dist/styled-system/recipes/pin-input.js +39 -0
- package/dist/styled-system/recipes/pin-input.js.map +1 -0
- package/dist/styled-system/recipes/select.cjs +5 -1
- package/dist/styled-system/recipes/select.cjs.map +1 -1
- package/dist/styled-system/recipes/select.js +5 -1
- package/dist/styled-system/recipes/select.js.map +1 -1
- package/dist/styled-system/recipes/table.cjs +15 -2
- package/dist/styled-system/recipes/table.cjs.map +1 -1
- package/dist/styled-system/recipes/table.js +15 -2
- package/dist/styled-system/recipes/table.js.map +1 -1
- package/dist/styled-system/recipes/tree-view.cjs +4 -1
- package/dist/styled-system/recipes/tree-view.cjs.map +1 -1
- package/dist/styled-system/recipes/tree-view.js +4 -1
- package/dist/styled-system/recipes/tree-view.js.map +1 -1
- package/dist/styled-system/recipes/upload.cjs +2 -0
- package/dist/styled-system/recipes/upload.cjs.map +1 -1
- package/dist/styled-system/recipes/upload.js +2 -0
- package/dist/styled-system/recipes/upload.js.map +1 -1
- package/dist/styles.css +995 -95
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 343c729: Add controlled data-display primitives for tables, views, lists and pagination, plus the new
|
|
8
|
+
DataToolbar composition. Command and TreeView gain more robust filtering, selection, keyboard
|
|
9
|
+
navigation and declarative loading states.
|
|
10
|
+
|
|
11
|
+
## 0.4.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- bd92571: Add Calendar, DateRangePicker, and PinInput components, plus richer form field, input, tags, upload, and selection APIs.
|
|
16
|
+
|
|
3
17
|
## 0.3.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -87,6 +87,91 @@ DatePicker supports day, month and date-time values while keeping the public val
|
|
|
87
87
|
Use `granularity="month"` to select a month normalized to its first day. Date-time popups stay
|
|
88
88
|
open until `DatePicker.Close` is activated; day and month modes close after selection by default.
|
|
89
89
|
|
|
90
|
+
`Calendar` is the standalone, server-renderable calendar engine. Pass `referenceDate` when the
|
|
91
|
+
initial view must be deterministic during SSR or tests:
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<Calendar.Root
|
|
95
|
+
defaultValue={new Date(2025, 3, 15, 12)}
|
|
96
|
+
referenceDate={new Date(2025, 3, 1, 12)}
|
|
97
|
+
locale="en-US"
|
|
98
|
+
>
|
|
99
|
+
<Calendar.Header>
|
|
100
|
+
<Calendar.Previous />
|
|
101
|
+
<Calendar.MonthSelect />
|
|
102
|
+
<Calendar.YearSelect />
|
|
103
|
+
<Calendar.Next />
|
|
104
|
+
</Calendar.Header>
|
|
105
|
+
<Calendar.Grid />
|
|
106
|
+
</Calendar.Root>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`DateRangePicker` keeps its value as local `Date` objects and supports native form fields,
|
|
110
|
+
previewing and optional closing after the second date:
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<DateRangePicker.Root name="period" closeOnSelect={false} referenceDate={new Date(2025, 3, 1, 12)}>
|
|
114
|
+
<DateRangePicker.Label>Period</DateRangePicker.Label>
|
|
115
|
+
<DateRangePicker.Trigger><DateRangePicker.Value /></DateRangePicker.Trigger>
|
|
116
|
+
<DateRangePicker.Portal>
|
|
117
|
+
<DateRangePicker.Positioner>
|
|
118
|
+
<DateRangePicker.Popup>
|
|
119
|
+
<DateRangePicker.Calendar />
|
|
120
|
+
<DateRangePicker.Preview />
|
|
121
|
+
<DateRangePicker.Close>Done</DateRangePicker.Close>
|
|
122
|
+
</DateRangePicker.Popup>
|
|
123
|
+
</DateRangePicker.Positioner>
|
|
124
|
+
</DateRangePicker.Portal>
|
|
125
|
+
</DateRangePicker.Root>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For one-time codes, `PinInput` generates one accessible input per character and supports paste,
|
|
129
|
+
auto-advance, password masking and native form submission:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
<PinInput.Root length={6} name="verification-code" otp onComplete={verifyCode}>
|
|
133
|
+
<PinInput.Label>Verification code</PinInput.Label>
|
|
134
|
+
<PinInput.Control><PinInput.Inputs /></PinInput.Control>
|
|
135
|
+
</PinInput.Root>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
For data-heavy screens, compose `DataToolbar`, `DataView`, `Table` and `Pagination` explicitly.
|
|
139
|
+
The library does not fetch, filter or virtualize data for you, so the application remains the
|
|
140
|
+
source of truth for query, sort, selection and page state:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<DataToolbar.Root aria-label="Project tools">
|
|
144
|
+
<DataToolbar.Search value={search} onValueChange={setSearch} />
|
|
145
|
+
<DataToolbar.Sort value={sort} onValueChange={setSort}>
|
|
146
|
+
<option value="name">Name</option>
|
|
147
|
+
</DataToolbar.Sort>
|
|
148
|
+
<DataToolbar.Selection count={selected.length} onClear={() => setSelected([])}>
|
|
149
|
+
<DataToolbar.ClearSelection />
|
|
150
|
+
</DataToolbar.Selection>
|
|
151
|
+
</DataToolbar.Root>
|
|
152
|
+
|
|
153
|
+
<DataView.Root layout="table" status={loading ? "loading" : "ready"}>
|
|
154
|
+
<DataView.Content>
|
|
155
|
+
<Table.Root
|
|
156
|
+
selectionMode="multiple"
|
|
157
|
+
selectedRowIds={selected}
|
|
158
|
+
onSelectionChange={setSelected}
|
|
159
|
+
>
|
|
160
|
+
<Table.Header>{/* Table.Row, Table.SelectionHeader and Table.Head */}</Table.Header>
|
|
161
|
+
<Table.Body>{/* Table.Row and Table.Cell */}</Table.Body>
|
|
162
|
+
</Table.Root>
|
|
163
|
+
</DataView.Content>
|
|
164
|
+
<DataView.Footer>
|
|
165
|
+
<Pagination.Root page={page} pageCount={pageCount} onPageChange={setPage} />
|
|
166
|
+
</DataView.Footer>
|
|
167
|
+
</DataView.Root>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`Table` supports controlled sorting (`sort`/`onSortChange`), single or multiple selection,
|
|
171
|
+
disabled rows, loading/empty/error states, compact density, alignment and responsive columns.
|
|
172
|
+
`List` remains a semantic `ul`/`ol`, and `Command` and `TreeView` expose their keyboard and
|
|
173
|
+
selection state without requiring a data engine.
|
|
174
|
+
|
|
90
175
|
Small composition helpers keep common layouts consistent:
|
|
91
176
|
|
|
92
177
|
```tsx
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_cx = require("../../styled-system/css/cx.cjs");
|
|
3
|
+
const require_calendar = require("../../styled-system/recipes/calendar.cjs");
|
|
4
|
+
const require_date_utils = require("../date-picker/date-utils.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/components/calendar/calendar.tsx
|
|
8
|
+
const CalendarContext = (0, react.createContext)(null);
|
|
9
|
+
function useCalendarContext() {
|
|
10
|
+
const context = (0, react.useContext)(CalendarContext);
|
|
11
|
+
if (!context) throw new Error("Calendar parts must be rendered inside Calendar.Root.");
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
function sameMonth(left, right) {
|
|
15
|
+
return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
|
|
16
|
+
}
|
|
17
|
+
const CalendarRoot = (0, react.forwardRef)(function CalendarRoot({ children, className, defaultValue = null, disabled = false, isDateDisabled, locale = "pt-BR", maxDate, minDate, onValueChange, referenceDate, value: controlledValue, weekStartsOn = 0, yearRange: configuredYearRange, ...props }, ref) {
|
|
18
|
+
const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? /* @__PURE__ */ new Date();
|
|
19
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, react.useState)(defaultValue);
|
|
20
|
+
const selected = controlledValue === void 0 ? uncontrolledValue : controlledValue;
|
|
21
|
+
const [month, setMonthState] = (0, react.useState)(() => require_date_utils.startOfMonth(initialDate));
|
|
22
|
+
const [focusedDate, setFocusedDate] = (0, react.useState)(selected ?? initialDate);
|
|
23
|
+
const dayRefs = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
24
|
+
const calendarId = (0, react.useId)();
|
|
25
|
+
const styles = require_calendar.calendar();
|
|
26
|
+
const today = (0, react.useMemo)(() => require_date_utils.createCalendarDate((referenceDate ?? /* @__PURE__ */ new Date()).getFullYear(), (referenceDate ?? /* @__PURE__ */ new Date()).getMonth(), (referenceDate ?? /* @__PURE__ */ new Date()).getDate()), [referenceDate]);
|
|
27
|
+
const minMonth = minDate ? require_date_utils.startOfMonth(minDate) : void 0;
|
|
28
|
+
const maxMonth = maxDate ? require_date_utils.startOfMonth(maxDate) : void 0;
|
|
29
|
+
const yearRange = (0, react.useMemo)(() => {
|
|
30
|
+
const start = configuredYearRange?.start ?? today.getFullYear() - 100;
|
|
31
|
+
const end = configuredYearRange?.end ?? today.getFullYear() + 20;
|
|
32
|
+
const years = [
|
|
33
|
+
selected?.getFullYear(),
|
|
34
|
+
minDate?.getFullYear(),
|
|
35
|
+
maxDate?.getFullYear()
|
|
36
|
+
].filter((year) => year !== void 0);
|
|
37
|
+
return {
|
|
38
|
+
start: Math.min(start, end, ...years),
|
|
39
|
+
end: Math.max(start, end, ...years)
|
|
40
|
+
};
|
|
41
|
+
}, [
|
|
42
|
+
configuredYearRange?.end,
|
|
43
|
+
configuredYearRange?.start,
|
|
44
|
+
maxDate,
|
|
45
|
+
minDate,
|
|
46
|
+
selected,
|
|
47
|
+
today
|
|
48
|
+
]);
|
|
49
|
+
const dateDisabled = (0, react.useCallback)((date) => Boolean(minDate && require_date_utils.isBeforeDay(date, minDate) || maxDate && require_date_utils.isAfterDay(date, maxDate) || isDateDisabled?.(date)), [
|
|
50
|
+
isDateDisabled,
|
|
51
|
+
maxDate,
|
|
52
|
+
minDate
|
|
53
|
+
]);
|
|
54
|
+
const monthDisabled = (0, react.useCallback)((date) => {
|
|
55
|
+
const first = require_date_utils.startOfMonth(date);
|
|
56
|
+
const last = require_date_utils.createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);
|
|
57
|
+
return Boolean(minDate && require_date_utils.isBeforeDay(last, minDate) || maxDate && require_date_utils.isAfterDay(first, maxDate));
|
|
58
|
+
}, [maxDate, minDate]);
|
|
59
|
+
const clampMonth = (0, react.useCallback)((date) => {
|
|
60
|
+
const normalized = require_date_utils.startOfMonth(date);
|
|
61
|
+
if (minMonth && require_date_utils.isBeforeDay(normalized, minMonth)) return minMonth;
|
|
62
|
+
if (maxMonth && require_date_utils.isAfterDay(normalized, maxMonth)) return maxMonth;
|
|
63
|
+
return normalized;
|
|
64
|
+
}, [maxMonth, minMonth]);
|
|
65
|
+
const setMonth = (0, react.useCallback)((date) => setMonthState(clampMonth(date)), [clampMonth]);
|
|
66
|
+
const canNavigate = (0, react.useCallback)((amount) => {
|
|
67
|
+
const next = require_date_utils.addMonths(month, amount);
|
|
68
|
+
return !(minMonth && require_date_utils.isBeforeDay(next, minMonth)) && !(maxMonth && require_date_utils.isAfterDay(next, maxMonth));
|
|
69
|
+
}, [
|
|
70
|
+
maxMonth,
|
|
71
|
+
minMonth,
|
|
72
|
+
month
|
|
73
|
+
]);
|
|
74
|
+
const setValue = (0, react.useCallback)((nextValue) => {
|
|
75
|
+
if (controlledValue === void 0) setUncontrolledValue(nextValue);
|
|
76
|
+
onValueChange?.(nextValue);
|
|
77
|
+
}, [controlledValue, onValueChange]);
|
|
78
|
+
const onSelect = (0, react.useCallback)((date) => {
|
|
79
|
+
if (disabled || dateDisabled(date)) return;
|
|
80
|
+
const next = require_date_utils.createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());
|
|
81
|
+
setValue(next);
|
|
82
|
+
setFocusedDate(next);
|
|
83
|
+
setMonth(next);
|
|
84
|
+
}, [
|
|
85
|
+
dateDisabled,
|
|
86
|
+
disabled,
|
|
87
|
+
setMonth,
|
|
88
|
+
setValue
|
|
89
|
+
]);
|
|
90
|
+
const focusDate = (0, react.useCallback)((date, direction = 1) => {
|
|
91
|
+
let next = require_date_utils.createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());
|
|
92
|
+
const step = direction < 0 ? -1 : 1;
|
|
93
|
+
let attempts = 0;
|
|
94
|
+
while (dateDisabled(next) && attempts < 366) {
|
|
95
|
+
next = require_date_utils.addDays(next, step);
|
|
96
|
+
attempts += 1;
|
|
97
|
+
}
|
|
98
|
+
setFocusedDate(next);
|
|
99
|
+
setMonth(next);
|
|
100
|
+
const focusTarget = () => dayRefs.current.get(require_date_utils.dateKey(next))?.focus();
|
|
101
|
+
focusTarget();
|
|
102
|
+
queueMicrotask(focusTarget);
|
|
103
|
+
}, [dateDisabled, setMonth]);
|
|
104
|
+
const selectMonth = (0, react.useCallback)((monthIndex) => setMonth(require_date_utils.createCalendarDate(month.getFullYear(), monthIndex, 1)), [month, setMonth]);
|
|
105
|
+
const selectYear = (0, react.useCallback)((year) => setMonth(require_date_utils.createCalendarDate(year, month.getMonth(), 1)), [month, setMonth]);
|
|
106
|
+
const registerDay = (0, react.useCallback)((key, node) => {
|
|
107
|
+
if (node) dayRefs.current.set(key, node);
|
|
108
|
+
else dayRefs.current.delete(key);
|
|
109
|
+
}, []);
|
|
110
|
+
(0, react.useEffect)(() => {
|
|
111
|
+
if (!selected) return;
|
|
112
|
+
setFocusedDate(selected);
|
|
113
|
+
setMonthState((current) => sameMonth(current, selected) ? current : clampMonth(selected));
|
|
114
|
+
}, [clampMonth, selected]);
|
|
115
|
+
const context = {
|
|
116
|
+
calendarId,
|
|
117
|
+
canNavigate,
|
|
118
|
+
dateDisabled,
|
|
119
|
+
disabled,
|
|
120
|
+
focusedDate,
|
|
121
|
+
focusDate,
|
|
122
|
+
locale,
|
|
123
|
+
month,
|
|
124
|
+
monthDisabled,
|
|
125
|
+
onSelect,
|
|
126
|
+
registerDay,
|
|
127
|
+
selected,
|
|
128
|
+
selectMonth,
|
|
129
|
+
selectYear,
|
|
130
|
+
setMonth,
|
|
131
|
+
styles,
|
|
132
|
+
today,
|
|
133
|
+
weekStartsOn,
|
|
134
|
+
yearRange
|
|
135
|
+
};
|
|
136
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarContext.Provider, {
|
|
137
|
+
value: context,
|
|
138
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
139
|
+
...props,
|
|
140
|
+
"aria-label": props["aria-label"] ?? require_date_utils.formatMonthLabel(month, locale),
|
|
141
|
+
className: require_cx.cx(styles.root, className),
|
|
142
|
+
"data-jaci-component": "calendar",
|
|
143
|
+
"data-slot": "calendar",
|
|
144
|
+
ref,
|
|
145
|
+
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CalendarHeader, { children: [
|
|
146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarPrevious, {}),
|
|
147
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarCaption, {}),
|
|
148
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarNext, {})
|
|
149
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarGrid, {})] })
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
const CalendarHeader = (0, react.forwardRef)(function CalendarHeader({ className, ...props }, ref) {
|
|
154
|
+
const { styles } = useCalendarContext();
|
|
155
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
156
|
+
...props,
|
|
157
|
+
className: require_cx.cx(styles.header, className),
|
|
158
|
+
"data-slot": "calendar-header",
|
|
159
|
+
ref
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
const CalendarCaption = (0, react.forwardRef)(function CalendarCaption({ children, className, ...props }, ref) {
|
|
163
|
+
const { locale, month, styles } = useCalendarContext();
|
|
164
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
165
|
+
...props,
|
|
166
|
+
className: require_cx.cx(styles.caption, className),
|
|
167
|
+
"data-slot": "calendar-caption",
|
|
168
|
+
ref,
|
|
169
|
+
children: children ?? require_date_utils.formatMonthLabel(month, locale)
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
const CalendarNavigationButton = (0, react.forwardRef)(function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {
|
|
173
|
+
const { canNavigate, month, setMonth, styles } = useCalendarContext();
|
|
174
|
+
const isDisabled = props.disabled || !canNavigate(amount);
|
|
175
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
176
|
+
...props,
|
|
177
|
+
"aria-label": props["aria-label"] ?? (amount < 0 ? "Previous month" : "Next month"),
|
|
178
|
+
className: require_cx.cx(styles.navigation, className),
|
|
179
|
+
"data-slot": amount < 0 ? "calendar-previous" : "calendar-next",
|
|
180
|
+
disabled: isDisabled,
|
|
181
|
+
onClick: (event) => {
|
|
182
|
+
if (!isDisabled) setMonth(require_date_utils.addMonths(month, amount));
|
|
183
|
+
onClick?.(event);
|
|
184
|
+
},
|
|
185
|
+
ref,
|
|
186
|
+
type: "button",
|
|
187
|
+
children: children ?? (amount < 0 ? "‹" : "›")
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
const CalendarPrevious = (0, react.forwardRef)(function CalendarPrevious(props, ref) {
|
|
191
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarNavigationButton, {
|
|
192
|
+
...props,
|
|
193
|
+
amount: -1,
|
|
194
|
+
ref
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
const CalendarNext = (0, react.forwardRef)(function CalendarNext(props, ref) {
|
|
198
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarNavigationButton, {
|
|
199
|
+
...props,
|
|
200
|
+
amount: 1,
|
|
201
|
+
ref
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
const CalendarMonthSelect = (0, react.forwardRef)(function CalendarMonthSelect({ className, ...props }, ref) {
|
|
205
|
+
const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();
|
|
206
|
+
const labels = Array.from({ length: 12 }, (_, index) => new Intl.DateTimeFormat(locale, { month: "long" }).format(require_date_utils.createCalendarDate(2024, index, 1)));
|
|
207
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
208
|
+
...props,
|
|
209
|
+
"aria-label": props["aria-label"] ?? "Select month",
|
|
210
|
+
className: require_cx.cx(styles.monthSelect, className),
|
|
211
|
+
"data-slot": "calendar-month-select",
|
|
212
|
+
onChange: (event) => selectMonth(Number(event.currentTarget.value)),
|
|
213
|
+
ref,
|
|
214
|
+
value: month.getMonth(),
|
|
215
|
+
children: labels.map((label, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
216
|
+
disabled: monthDisabled(require_date_utils.createCalendarDate(month.getFullYear(), index, 1)),
|
|
217
|
+
value: index,
|
|
218
|
+
children: label
|
|
219
|
+
}, label))
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
const CalendarYearSelect = (0, react.forwardRef)(function CalendarYearSelect({ className, ...props }, ref) {
|
|
223
|
+
const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();
|
|
224
|
+
const years = Array.from({ length: yearRange.end - yearRange.start + 1 }, (_, index) => yearRange.start + index);
|
|
225
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
226
|
+
...props,
|
|
227
|
+
"aria-label": props["aria-label"] ?? "Select year",
|
|
228
|
+
className: require_cx.cx(styles.yearSelect, className),
|
|
229
|
+
"data-slot": "calendar-year-select",
|
|
230
|
+
onChange: (event) => selectYear(Number(event.currentTarget.value)),
|
|
231
|
+
ref,
|
|
232
|
+
value: month.getFullYear(),
|
|
233
|
+
children: years.map((year) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
234
|
+
disabled: monthDisabled(require_date_utils.createCalendarDate(year, month.getMonth(), 1)),
|
|
235
|
+
value: year,
|
|
236
|
+
children: year
|
|
237
|
+
}, year))
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
const CalendarDay = (0, react.forwardRef)(function CalendarDay({ children, className, date, disabled, onClick, onKeyDown, ...props }, ref) {
|
|
241
|
+
const { dateDisabled, disabled: calendarDisabled, focusDate, focusedDate, locale, month, onSelect, registerDay, selected, styles, today, weekStartsOn } = useCalendarContext();
|
|
242
|
+
const key = require_date_utils.dateKey(date);
|
|
243
|
+
const outsideMonth = !sameMonth(date, month);
|
|
244
|
+
const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));
|
|
245
|
+
const isSelected = require_date_utils.isSameDay(date, selected);
|
|
246
|
+
const isFocused = require_date_utils.isSameDay(date, focusedDate);
|
|
247
|
+
const isToday = require_date_utils.isSameDay(date, today);
|
|
248
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
249
|
+
...props,
|
|
250
|
+
"aria-label": props["aria-label"] ?? new Intl.DateTimeFormat(locale, { dateStyle: "full" }).format(date),
|
|
251
|
+
"aria-current": isToday ? "date" : void 0,
|
|
252
|
+
"aria-selected": isSelected,
|
|
253
|
+
className: require_cx.cx(styles.day, className),
|
|
254
|
+
"data-date": key,
|
|
255
|
+
"data-disabled": isDisabled || void 0,
|
|
256
|
+
"data-outside-month": outsideMonth || void 0,
|
|
257
|
+
"data-selected": isSelected || void 0,
|
|
258
|
+
"data-slot": "calendar-day",
|
|
259
|
+
"data-today": isToday || void 0,
|
|
260
|
+
disabled: isDisabled,
|
|
261
|
+
onClick: (event) => {
|
|
262
|
+
onSelect(date);
|
|
263
|
+
onClick?.(event);
|
|
264
|
+
},
|
|
265
|
+
onKeyDown: (event) => {
|
|
266
|
+
if (!event.defaultPrevented) {
|
|
267
|
+
let nextDate;
|
|
268
|
+
switch (event.key) {
|
|
269
|
+
case "ArrowLeft":
|
|
270
|
+
nextDate = require_date_utils.addDays(date, -1);
|
|
271
|
+
break;
|
|
272
|
+
case "ArrowRight":
|
|
273
|
+
nextDate = require_date_utils.addDays(date, 1);
|
|
274
|
+
break;
|
|
275
|
+
case "ArrowUp":
|
|
276
|
+
nextDate = require_date_utils.addDays(date, -7);
|
|
277
|
+
break;
|
|
278
|
+
case "ArrowDown":
|
|
279
|
+
nextDate = require_date_utils.addDays(date, 7);
|
|
280
|
+
break;
|
|
281
|
+
case "Home":
|
|
282
|
+
nextDate = require_date_utils.addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));
|
|
283
|
+
break;
|
|
284
|
+
case "End":
|
|
285
|
+
nextDate = require_date_utils.addDays(date, 6 - (date.getDay() - weekStartsOn + 7) % 7);
|
|
286
|
+
break;
|
|
287
|
+
case "PageUp":
|
|
288
|
+
nextDate = require_date_utils.addMonths(date, event.shiftKey ? -12 : -1);
|
|
289
|
+
break;
|
|
290
|
+
case "PageDown":
|
|
291
|
+
nextDate = require_date_utils.addMonths(date, event.shiftKey ? 12 : 1);
|
|
292
|
+
break;
|
|
293
|
+
case "Enter":
|
|
294
|
+
case " ":
|
|
295
|
+
if (!isDisabled) {
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
onSelect(date);
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
if (nextDate) {
|
|
302
|
+
event.preventDefault();
|
|
303
|
+
focusDate(nextDate, nextDate < date ? -1 : 1);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
onKeyDown?.(event);
|
|
307
|
+
},
|
|
308
|
+
ref: (node) => {
|
|
309
|
+
registerDay(key, node);
|
|
310
|
+
if (typeof ref === "function") ref(node);
|
|
311
|
+
else if (ref) ref.current = node;
|
|
312
|
+
},
|
|
313
|
+
role: "gridcell",
|
|
314
|
+
tabIndex: isFocused && !isDisabled ? 0 : -1,
|
|
315
|
+
type: "button",
|
|
316
|
+
children: children ?? date.getDate()
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
const CalendarGrid = (0, react.forwardRef)(function CalendarGrid({ "aria-label": ariaLabel, className, ...props }, ref) {
|
|
320
|
+
const { locale, month, styles, weekStartsOn } = useCalendarContext();
|
|
321
|
+
const days = (0, react.useMemo)(() => require_date_utils.getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);
|
|
322
|
+
const weeks = (0, react.useMemo)(() => Array.from({ length: Math.ceil(days.length / 7) }, (_, index) => days.slice(index * 7, index * 7 + 7)), [days]);
|
|
323
|
+
const weekdays = (0, react.useMemo)(() => require_date_utils.getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);
|
|
324
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
325
|
+
...props,
|
|
326
|
+
className: require_cx.cx(styles.calendar, className),
|
|
327
|
+
"data-slot": "calendar-grid",
|
|
328
|
+
ref,
|
|
329
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
330
|
+
"aria-hidden": "true",
|
|
331
|
+
className: styles.weekdays,
|
|
332
|
+
"data-slot": "calendar-weekdays",
|
|
333
|
+
children: weekdays.map((weekday) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
334
|
+
className: styles.weekday,
|
|
335
|
+
"data-slot": "calendar-weekday",
|
|
336
|
+
children: weekday
|
|
337
|
+
}, weekday))
|
|
338
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
339
|
+
"aria-label": ariaLabel ?? require_date_utils.formatMonthLabel(month, locale),
|
|
340
|
+
className: styles.grid,
|
|
341
|
+
"data-slot": "calendar-day-grid",
|
|
342
|
+
role: "grid",
|
|
343
|
+
children: weeks.map((week, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
344
|
+
"aria-rowindex": index + 1,
|
|
345
|
+
className: styles.row,
|
|
346
|
+
"data-slot": "calendar-week",
|
|
347
|
+
role: "row",
|
|
348
|
+
tabIndex: -1,
|
|
349
|
+
children: week.map((date) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarDay, { date }, require_date_utils.dateKey(date)))
|
|
350
|
+
}, week.map(require_date_utils.dateKey).join("-")))
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
const Calendar = {
|
|
355
|
+
Root: CalendarRoot,
|
|
356
|
+
Header: CalendarHeader,
|
|
357
|
+
Caption: CalendarCaption,
|
|
358
|
+
Previous: CalendarPrevious,
|
|
359
|
+
Next: CalendarNext,
|
|
360
|
+
MonthSelect: CalendarMonthSelect,
|
|
361
|
+
YearSelect: CalendarYearSelect,
|
|
362
|
+
Grid: CalendarGrid,
|
|
363
|
+
Day: CalendarDay
|
|
364
|
+
};
|
|
365
|
+
//#endregion
|
|
366
|
+
exports.Calendar = Calendar;
|
|
367
|
+
exports.CalendarCaption = CalendarCaption;
|
|
368
|
+
exports.CalendarDay = CalendarDay;
|
|
369
|
+
exports.CalendarGrid = CalendarGrid;
|
|
370
|
+
exports.CalendarHeader = CalendarHeader;
|
|
371
|
+
exports.CalendarMonthSelect = CalendarMonthSelect;
|
|
372
|
+
exports.CalendarNext = CalendarNext;
|
|
373
|
+
exports.CalendarPrevious = CalendarPrevious;
|
|
374
|
+
exports.CalendarRoot = CalendarRoot;
|
|
375
|
+
exports.CalendarYearSelect = CalendarYearSelect;
|
|
376
|
+
|
|
377
|
+
//# sourceMappingURL=calendar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.cjs","names":["startOfMonth","calendar","createCalendarDate","isBeforeDay","isAfterDay","addMonths","addDays","dateKey","formatMonthLabel","cx","isSameDay","getCalendarDays","getWeekdayLabels"],"sources":["../../../src/components/calendar/calendar.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { calendar } from \"../../styled-system/recipes\";\nimport {\n addDays,\n addMonths,\n createCalendarDate,\n dateKey,\n formatMonthLabel,\n getCalendarDays,\n getWeekdayLabels,\n isAfterDay,\n isBeforeDay,\n isSameDay,\n startOfMonth,\n} from \"../date-picker/date-utils\";\n\nexport interface CalendarYearRange {\n start: number;\n end: number;\n}\n\nexport interface CalendarRootProps\n extends Omit<ComponentPropsWithoutRef<\"section\">, \"children\" | \"defaultValue\" | \"value\"> {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n referenceDate?: Date;\n locale?: string;\n weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n minDate?: Date;\n maxDate?: Date;\n isDateDisabled?: (date: Date) => boolean;\n yearRange?: CalendarYearRange;\n disabled?: boolean;\n children?: ReactNode;\n}\n\ninterface CalendarContextValue {\n calendarId: string;\n dateDisabled: (date: Date) => boolean;\n disabled: boolean;\n focusedDate: Date;\n focusDate: (date: Date, direction?: number) => void;\n locale: string;\n month: Date;\n monthDisabled: (date: Date) => boolean;\n onSelect: (date: Date) => void;\n selected: Date | null;\n setMonth: (date: Date) => void;\n styles: ReturnType<typeof calendar>;\n today: Date;\n weekStartsOn: number;\n yearRange: CalendarYearRange;\n canNavigate: (amount: number) => boolean;\n selectMonth: (month: number) => void;\n selectYear: (year: number) => void;\n registerDay: (key: string, node: HTMLButtonElement | null) => void;\n}\n\nimport { createContext, useContext } from \"react\";\n\nconst CalendarContext = createContext<CalendarContextValue | null>(null);\n\nfunction useCalendarContext() {\n const context = useContext(CalendarContext);\n if (!context) throw new Error(\"Calendar parts must be rendered inside Calendar.Root.\");\n return context;\n}\n\nfunction sameMonth(left: Date, right: Date) {\n return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();\n}\n\nexport const CalendarRoot = forwardRef<HTMLElement, CalendarRootProps>(function CalendarRoot(\n {\n children,\n className,\n defaultValue = null,\n disabled = false,\n isDateDisabled,\n locale = \"pt-BR\",\n maxDate,\n minDate,\n onValueChange,\n referenceDate,\n value: controlledValue,\n weekStartsOn = 0,\n yearRange: configuredYearRange,\n ...props\n },\n ref,\n) {\n const initialDate = controlledValue ?? defaultValue ?? referenceDate ?? new Date();\n const [uncontrolledValue, setUncontrolledValue] = useState<Date | null>(defaultValue);\n const selected = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const [month, setMonthState] = useState(() => startOfMonth(initialDate));\n const [focusedDate, setFocusedDate] = useState(selected ?? initialDate);\n const dayRefs = useRef(new Map<string, HTMLButtonElement>());\n const calendarId = useId();\n const styles = calendar();\n const today = useMemo(\n () =>\n createCalendarDate(\n (referenceDate ?? new Date()).getFullYear(),\n (referenceDate ?? new Date()).getMonth(),\n (referenceDate ?? new Date()).getDate(),\n ),\n [referenceDate],\n );\n const minMonth = minDate ? startOfMonth(minDate) : undefined;\n const maxMonth = maxDate ? startOfMonth(maxDate) : undefined;\n const yearRange = useMemo(() => {\n const start = configuredYearRange?.start ?? today.getFullYear() - 100;\n const end = configuredYearRange?.end ?? today.getFullYear() + 20;\n const years = [selected?.getFullYear(), minDate?.getFullYear(), maxDate?.getFullYear()].filter(\n (year): year is number => year !== undefined,\n );\n return { start: Math.min(start, end, ...years), end: Math.max(start, end, ...years) };\n }, [configuredYearRange?.end, configuredYearRange?.start, maxDate, minDate, selected, today]);\n\n const dateDisabled = useCallback(\n (date: Date) =>\n Boolean(\n (minDate && isBeforeDay(date, minDate)) ||\n (maxDate && isAfterDay(date, maxDate)) ||\n isDateDisabled?.(date),\n ),\n [isDateDisabled, maxDate, minDate],\n );\n const monthDisabled = useCallback(\n (date: Date) => {\n const first = startOfMonth(date);\n const last = createCalendarDate(date.getFullYear(), date.getMonth() + 1, 0);\n return Boolean(\n (minDate && isBeforeDay(last, minDate)) || (maxDate && isAfterDay(first, maxDate)),\n );\n },\n [maxDate, minDate],\n );\n const clampMonth = useCallback(\n (date: Date) => {\n const normalized = startOfMonth(date);\n if (minMonth && isBeforeDay(normalized, minMonth)) return minMonth;\n if (maxMonth && isAfterDay(normalized, maxMonth)) return maxMonth;\n return normalized;\n },\n [maxMonth, minMonth],\n );\n const setMonth = useCallback((date: Date) => setMonthState(clampMonth(date)), [clampMonth]);\n const canNavigate = useCallback(\n (amount: number) => {\n const next = addMonths(month, amount);\n return (\n !(minMonth && isBeforeDay(next, minMonth)) && !(maxMonth && isAfterDay(next, maxMonth))\n );\n },\n [maxMonth, minMonth, month],\n );\n const setValue = useCallback(\n (nextValue: Date | null) => {\n if (controlledValue === undefined) setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n },\n [controlledValue, onValueChange],\n );\n const onSelect = useCallback(\n (date: Date) => {\n if (disabled || dateDisabled(date)) return;\n const next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n setValue(next);\n setFocusedDate(next);\n setMonth(next);\n },\n [dateDisabled, disabled, setMonth, setValue],\n );\n const focusDate = useCallback(\n (date: Date, direction = 1) => {\n let next = createCalendarDate(date.getFullYear(), date.getMonth(), date.getDate());\n const step = direction < 0 ? -1 : 1;\n let attempts = 0;\n while (dateDisabled(next) && attempts < 366) {\n next = addDays(next, step);\n attempts += 1;\n }\n setFocusedDate(next);\n setMonth(next);\n const focusTarget = () => dayRefs.current.get(dateKey(next))?.focus();\n focusTarget();\n queueMicrotask(focusTarget);\n },\n [dateDisabled, setMonth],\n );\n const selectMonth = useCallback(\n (monthIndex: number) => setMonth(createCalendarDate(month.getFullYear(), monthIndex, 1)),\n [month, setMonth],\n );\n const selectYear = useCallback(\n (year: number) => setMonth(createCalendarDate(year, month.getMonth(), 1)),\n [month, setMonth],\n );\n const registerDay = useCallback((key: string, node: HTMLButtonElement | null) => {\n if (node) dayRefs.current.set(key, node);\n else dayRefs.current.delete(key);\n }, []);\n\n useEffect(() => {\n if (!selected) return;\n setFocusedDate(selected);\n setMonthState((current) => (sameMonth(current, selected) ? current : clampMonth(selected)));\n }, [clampMonth, selected]);\n\n const context: CalendarContextValue = {\n calendarId,\n canNavigate,\n dateDisabled,\n disabled,\n focusedDate,\n focusDate,\n locale,\n month,\n monthDisabled,\n onSelect,\n registerDay,\n selected,\n selectMonth,\n selectYear,\n setMonth,\n styles,\n today,\n weekStartsOn,\n yearRange,\n };\n\n return (\n <CalendarContext.Provider value={context}>\n <section\n {...props}\n aria-label={props[\"aria-label\"] ?? formatMonthLabel(month, locale)}\n className={cx(styles.root, className)}\n data-jaci-component=\"calendar\"\n data-slot=\"calendar\"\n ref={ref}\n >\n {children ?? (\n <>\n <CalendarHeader>\n <CalendarPrevious />\n <CalendarCaption />\n <CalendarNext />\n </CalendarHeader>\n <CalendarGrid />\n </>\n )}\n </section>\n </CalendarContext.Provider>\n );\n});\n\nexport type CalendarHeaderProps = ComponentPropsWithoutRef<\"div\">;\nexport const CalendarHeader = forwardRef<HTMLDivElement, CalendarHeaderProps>(\n function CalendarHeader({ className, ...props }, ref) {\n const { styles } = useCalendarContext();\n return (\n <div\n {...props}\n className={cx(styles.header, className)}\n data-slot=\"calendar-header\"\n ref={ref}\n />\n );\n },\n);\n\nexport type CalendarCaptionProps = ComponentPropsWithoutRef<\"span\">;\nexport const CalendarCaption = forwardRef<HTMLSpanElement, CalendarCaptionProps>(\n function CalendarCaption({ children, className, ...props }, ref) {\n const { locale, month, styles } = useCalendarContext();\n return (\n <span\n {...props}\n className={cx(styles.caption, className)}\n data-slot=\"calendar-caption\"\n ref={ref}\n >\n {children ?? formatMonthLabel(month, locale)}\n </span>\n );\n },\n);\n\nexport interface CalendarNavigationProps extends ComponentPropsWithoutRef<\"button\"> {\n amount?: number;\n}\n\nconst CalendarNavigationButton = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNavigationButton({ amount = 1, children, className, onClick, ...props }, ref) {\n const { canNavigate, month, setMonth, styles } = useCalendarContext();\n const isDisabled = props.disabled || !canNavigate(amount);\n return (\n <button\n {...props}\n aria-label={props[\"aria-label\"] ?? (amount < 0 ? \"Previous month\" : \"Next month\")}\n className={cx(styles.navigation, className)}\n data-slot={amount < 0 ? \"calendar-previous\" : \"calendar-next\"}\n disabled={isDisabled}\n onClick={(event) => {\n if (!isDisabled) setMonth(addMonths(month, amount));\n onClick?.(event);\n }}\n ref={ref}\n type=\"button\"\n >\n {children ?? (amount < 0 ? \"‹\" : \"›\")}\n </button>\n );\n },\n);\n\nexport const CalendarPrevious = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarPrevious(props, ref) {\n return <CalendarNavigationButton {...props} amount={-1} ref={ref} />;\n },\n);\nexport const CalendarNext = forwardRef<HTMLButtonElement, CalendarNavigationProps>(\n function CalendarNext(props, ref) {\n return <CalendarNavigationButton {...props} amount={1} ref={ref} />;\n },\n);\n\nexport type CalendarMonthSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarMonthSelect = forwardRef<HTMLSelectElement, CalendarMonthSelectProps>(\n function CalendarMonthSelect({ className, ...props }, ref) {\n const { locale, month, monthDisabled, selectMonth, styles } = useCalendarContext();\n const labels = Array.from({ length: 12 }, (_, index) =>\n new Intl.DateTimeFormat(locale, { month: \"long\" }).format(createCalendarDate(2024, index, 1)),\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select month\"}\n className={cx(styles.monthSelect, className)}\n data-slot=\"calendar-month-select\"\n onChange={(event) => selectMonth(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getMonth()}\n >\n {labels.map((label, index) => (\n <option\n disabled={monthDisabled(createCalendarDate(month.getFullYear(), index, 1))}\n key={label}\n value={index}\n >\n {label}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport type CalendarYearSelectProps = Omit<\n ComponentPropsWithoutRef<\"select\">,\n \"children\" | \"onChange\" | \"value\"\n>;\nexport const CalendarYearSelect = forwardRef<HTMLSelectElement, CalendarYearSelectProps>(\n function CalendarYearSelect({ className, ...props }, ref) {\n const { month, monthDisabled, selectYear, styles, yearRange } = useCalendarContext();\n const years = Array.from(\n { length: yearRange.end - yearRange.start + 1 },\n (_, index) => yearRange.start + index,\n );\n return (\n <select\n {...props}\n aria-label={props[\"aria-label\"] ?? \"Select year\"}\n className={cx(styles.yearSelect, className)}\n data-slot=\"calendar-year-select\"\n onChange={(event) => selectYear(Number(event.currentTarget.value))}\n ref={ref}\n value={month.getFullYear()}\n >\n {years.map((year) => (\n <option\n disabled={monthDisabled(createCalendarDate(year, month.getMonth(), 1))}\n key={year}\n value={year}\n >\n {year}\n </option>\n ))}\n </select>\n );\n },\n);\n\nexport interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<\"button\">, \"value\"> {\n date: Date;\n}\n\nexport const CalendarDay = forwardRef<HTMLButtonElement, CalendarDayProps>(function CalendarDay(\n { children, className, date, disabled, onClick, onKeyDown, ...props },\n ref,\n) {\n const {\n dateDisabled,\n disabled: calendarDisabled,\n focusDate,\n focusedDate,\n locale,\n month,\n onSelect,\n registerDay,\n selected,\n styles,\n today,\n weekStartsOn,\n } = useCalendarContext();\n const key = dateKey(date);\n const outsideMonth = !sameMonth(date, month);\n const isDisabled = Boolean(disabled || calendarDisabled || dateDisabled(date));\n const isSelected = isSameDay(date, selected);\n const isFocused = isSameDay(date, focusedDate);\n const isToday = isSameDay(date, today);\n return (\n // biome-ignore lint/a11y/useSemanticElements: the roving button is the interactive grid cell.\n <button\n {...props}\n aria-label={\n props[\"aria-label\"] ?? new Intl.DateTimeFormat(locale, { dateStyle: \"full\" }).format(date)\n }\n aria-current={isToday ? \"date\" : undefined}\n aria-selected={isSelected}\n className={cx(styles.day, className)}\n data-date={key}\n data-disabled={isDisabled || undefined}\n data-outside-month={outsideMonth || undefined}\n data-selected={isSelected || undefined}\n data-slot=\"calendar-day\"\n data-today={isToday || undefined}\n disabled={isDisabled}\n onClick={(event) => {\n onSelect(date);\n onClick?.(event);\n }}\n onKeyDown={(event) => {\n if (!event.defaultPrevented) {\n let nextDate: Date | undefined;\n switch (event.key) {\n case \"ArrowLeft\":\n nextDate = addDays(date, -1);\n break;\n case \"ArrowRight\":\n nextDate = addDays(date, 1);\n break;\n case \"ArrowUp\":\n nextDate = addDays(date, -7);\n break;\n case \"ArrowDown\":\n nextDate = addDays(date, 7);\n break;\n case \"Home\":\n nextDate = addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"End\":\n nextDate = addDays(date, 6 - ((date.getDay() - weekStartsOn + 7) % 7));\n break;\n case \"PageUp\":\n nextDate = addMonths(date, event.shiftKey ? -12 : -1);\n break;\n case \"PageDown\":\n nextDate = addMonths(date, event.shiftKey ? 12 : 1);\n break;\n case \"Enter\":\n case \" \":\n if (!isDisabled) {\n event.preventDefault();\n onSelect(date);\n }\n break;\n }\n if (nextDate) {\n event.preventDefault();\n focusDate(nextDate, nextDate < date ? -1 : 1);\n }\n }\n onKeyDown?.(event);\n }}\n ref={(node) => {\n registerDay(key, node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n role=\"gridcell\"\n tabIndex={isFocused && !isDisabled ? 0 : -1}\n type=\"button\"\n >\n {children ?? date.getDate()}\n </button>\n );\n});\n\nexport interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n \"aria-label\"?: string;\n}\n\nexport const CalendarGrid = forwardRef<HTMLDivElement, CalendarGridProps>(function CalendarGrid(\n { \"aria-label\": ariaLabel, className, ...props },\n ref,\n) {\n const { locale, month, styles, weekStartsOn } = useCalendarContext();\n const days = useMemo(() => getCalendarDays(month, weekStartsOn), [month, weekStartsOn]);\n const weeks = useMemo(\n () =>\n Array.from({ length: Math.ceil(days.length / 7) }, (_, index) =>\n days.slice(index * 7, index * 7 + 7),\n ),\n [days],\n );\n const weekdays = useMemo(() => getWeekdayLabels(locale, weekStartsOn), [locale, weekStartsOn]);\n return (\n <div {...props} className={cx(styles.calendar, className)} data-slot=\"calendar-grid\" ref={ref}>\n <div aria-hidden=\"true\" className={styles.weekdays} data-slot=\"calendar-weekdays\">\n {weekdays.map((weekday) => (\n <span className={styles.weekday} data-slot=\"calendar-weekday\" key={weekday}>\n {weekday}\n </span>\n ))}\n </div>\n {/* biome-ignore lint/a11y/useSemanticElements: the calendar uses the ARIA grid pattern. */}\n <div\n aria-label={ariaLabel ?? formatMonthLabel(month, locale)}\n className={styles.grid}\n data-slot=\"calendar-day-grid\"\n role=\"grid\"\n >\n {weeks.map((week, index) => (\n // biome-ignore lint/a11y/useSemanticElements: Calendar rows use ARIA grid semantics while the day controls remain buttons.\n <div\n aria-rowindex={index + 1}\n className={styles.row}\n data-slot=\"calendar-week\"\n key={week.map(dateKey).join(\"-\")}\n role=\"row\"\n tabIndex={-1}\n >\n {week.map((date) => (\n <CalendarDay date={date} key={dateKey(date)} />\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n});\n\nexport const Calendar = {\n Root: CalendarRoot,\n Header: CalendarHeader,\n Caption: CalendarCaption,\n Previous: CalendarPrevious,\n Next: CalendarNext,\n MonthSelect: CalendarMonthSelect,\n YearSelect: CalendarYearSelect,\n Grid: CalendarGrid,\n Day: CalendarDay,\n};\n"],"mappings":";;;;;;;AAkEA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AAEvE,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAEA,SAAS,UAAU,MAAY,OAAa;CAC1C,OAAO,KAAK,YAAY,MAAM,MAAM,YAAY,KAAK,KAAK,SAAS,MAAM,MAAM,S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CAAC,aAAD,EAAmB,KAA2B,GAAhBD,mBAAAA,QAAQ,IAAI,CAAI,CAC/C;GACE,GAPE,KAAK,IAAIA,mBAAAA,OAAO,CAAC,CAAC,KAAK,GAAG,CAO5B,CACN;EACE,CAAA,CACF;;AAET,CAAC;AAED,MAAa,WAAW;CACtB,MAAM;CACN,QAAQ;CACR,SAAS;CACT,UAAU;CACV,MAAM;CACN,aAAa;CACb,YAAY;CACZ,MAAM;CACN,KAAK;AACP"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/calendar/calendar.d.ts
|
|
3
|
+
interface CalendarYearRange {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
interface CalendarRootProps extends Omit<ComponentPropsWithoutRef<"section">, "children" | "defaultValue" | "value"> {
|
|
8
|
+
value?: Date | null;
|
|
9
|
+
defaultValue?: Date | null;
|
|
10
|
+
onValueChange?: (value: Date | null) => void;
|
|
11
|
+
referenceDate?: Date;
|
|
12
|
+
locale?: string;
|
|
13
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
|
+
minDate?: Date;
|
|
15
|
+
maxDate?: Date;
|
|
16
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
17
|
+
yearRange?: CalendarYearRange;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
declare const CalendarRoot: import("react").ForwardRefExoticComponent<CalendarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
22
|
+
type CalendarHeaderProps = ComponentPropsWithoutRef<"div">;
|
|
23
|
+
declare const CalendarHeader: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
24
|
+
type CalendarCaptionProps = ComponentPropsWithoutRef<"span">;
|
|
25
|
+
declare const CalendarCaption: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
26
|
+
interface CalendarNavigationProps extends ComponentPropsWithoutRef<"button"> {
|
|
27
|
+
amount?: number;
|
|
28
|
+
}
|
|
29
|
+
declare const CalendarPrevious: import("react").ForwardRefExoticComponent<CalendarNavigationProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
declare const CalendarNext: import("react").ForwardRefExoticComponent<CalendarNavigationProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
31
|
+
type CalendarMonthSelectProps = Omit<ComponentPropsWithoutRef<"select">, "children" | "onChange" | "value">;
|
|
32
|
+
declare const CalendarMonthSelect: import("react").ForwardRefExoticComponent<CalendarMonthSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
33
|
+
type CalendarYearSelectProps = Omit<ComponentPropsWithoutRef<"select">, "children" | "onChange" | "value">;
|
|
34
|
+
declare const CalendarYearSelect: import("react").ForwardRefExoticComponent<CalendarYearSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
35
|
+
interface CalendarDayProps extends Omit<ComponentPropsWithoutRef<"button">, "value"> {
|
|
36
|
+
date: Date;
|
|
37
|
+
}
|
|
38
|
+
declare const CalendarDay: import("react").ForwardRefExoticComponent<CalendarDayProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
39
|
+
interface CalendarGridProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
40
|
+
"aria-label"?: string;
|
|
41
|
+
}
|
|
42
|
+
declare const CalendarGrid: import("react").ForwardRefExoticComponent<CalendarGridProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
43
|
+
declare const Calendar: {
|
|
44
|
+
Root: import("react").ForwardRefExoticComponent<CalendarRootProps & import("react").RefAttributes<HTMLElement>>;
|
|
45
|
+
Header: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
46
|
+
Caption: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
47
|
+
Previous: import("react").ForwardRefExoticComponent<CalendarNavigationProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
48
|
+
Next: import("react").ForwardRefExoticComponent<CalendarNavigationProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
49
|
+
MonthSelect: import("react").ForwardRefExoticComponent<CalendarMonthSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
50
|
+
YearSelect: import("react").ForwardRefExoticComponent<CalendarYearSelectProps & import("react").RefAttributes<HTMLSelectElement>>;
|
|
51
|
+
Grid: import("react").ForwardRefExoticComponent<CalendarGridProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
52
|
+
Day: import("react").ForwardRefExoticComponent<CalendarDayProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Calendar, CalendarCaption, CalendarCaptionProps, CalendarDay, CalendarDayProps, CalendarGrid, CalendarGridProps, CalendarHeader, CalendarHeaderProps, CalendarMonthSelect, CalendarMonthSelectProps, CalendarNavigationProps, CalendarNext, CalendarPrevious, CalendarRoot, CalendarRootProps, CalendarYearRange, CalendarYearSelect, CalendarYearSelectProps };
|
|
56
|
+
//# sourceMappingURL=calendar.d.cts.map
|