@maxio-com/react-ui-components 9.24.1 → 9.26.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/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/skills/maxio-react/SKILL.md +3 -0
- package/dist/skills/maxio-react/references/components-calendar.md +10 -10
- package/dist/skills/maxio-react/references/components-forms-datefield.md +192 -0
- package/dist/skills/maxio-react/references/components-forms-datepicker.md +221 -0
- package/dist/skills/maxio-react/references/components-forms-daterangepicker.md +246 -0
- package/dist/skills/maxio-react/references/components-listbox.md +53 -0
- package/dist/skills/maxio-react/references/components-rangecalendar.md +24 -24
- package/dist/temporary-typings/src/components/ListBox/ListBox.d.ts +1 -1
- package/dist/temporary-typings/src/components/ListBox/ListBox.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ListBox/types.d.ts +4 -1
- package/dist/temporary-typings/src/components/ListBox/types.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/forms/DateField/DateField.d.ts +6 -0
- package/dist/temporary-typings/src/components/forms/DateField/DateField.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateField/DateInput.d.ts +7 -0
- package/dist/temporary-typings/src/components/forms/DateField/DateInput.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateField/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/forms/DateField/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateField/types.d.ts +8 -0
- package/dist/temporary-typings/src/components/forms/DateField/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/DatePicker.d.ts +6 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/DatePicker.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/types.d.ts +12 -0
- package/dist/temporary-typings/src/components/forms/DatePicker/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/DatePresets.d.ts +5 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/DatePresets.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/types.d.ts +13 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/utils.d.ts +14 -0
- package/dist/temporary-typings/src/components/forms/DatePresets/utils.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/DateRangePicker.d.ts +6 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/DateRangePicker.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/index.d.ts +3 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/index.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/types.d.ts +15 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/types.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/utils.d.ts +8 -0
- package/dist/temporary-typings/src/components/forms/DateRangePicker/utils.d.ts.map +1 -0
- package/dist/temporary-typings/src/components/forms/index.d.ts +6 -0
- package/dist/temporary-typings/src/components/forms/index.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/index.d.ts +7 -1
- package/dist/temporary-typings/src/components/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/typings/index.d.ts +46 -4
|
@@ -39,6 +39,9 @@ Use this skill to build React components using `@maxio-com/react-ui-components`.
|
|
|
39
39
|
- [Components / Flex](references/components-flex.md)
|
|
40
40
|
- [Components / Forms / Checkbox](references/components-forms-checkbox.md)
|
|
41
41
|
- [Components / Forms / ComboBox](references/components-forms-combobox.md)
|
|
42
|
+
- [Components / Forms / DateField](references/components-forms-datefield.md)
|
|
43
|
+
- [Components / Forms / DatePicker](references/components-forms-datepicker.md)
|
|
44
|
+
- [Components / Forms / DateRangePicker](references/components-forms-daterangepicker.md)
|
|
42
45
|
- [Components / Forms / Radio Group](references/components-forms-radio-group.md)
|
|
43
46
|
- [Components / Forms / Select](references/components-forms-select.md)
|
|
44
47
|
- [Components / Forms / TextArea](references/components-forms-textarea.md)
|
|
@@ -124,7 +124,7 @@ import { Calendar, I18nProvider } from "@maxio-com/react-ui-components";
|
|
|
124
124
|
Use Default when users need to select one date from a visible month grid.
|
|
125
125
|
|
|
126
126
|
```tsx
|
|
127
|
-
const Default = () => <Calendar aria-label="Billing date" defaultValue={
|
|
127
|
+
const Default = () => <Calendar aria-label="Billing date" defaultValue={referenceDate} />;
|
|
128
128
|
```
|
|
129
129
|
|
|
130
130
|
### Controlled
|
|
@@ -133,7 +133,7 @@ Use Controlled when application state owns the selected date.
|
|
|
133
133
|
|
|
134
134
|
```tsx
|
|
135
135
|
const Controlled = function ControlledCalendar() {
|
|
136
|
-
const [value, setValue] = useState(
|
|
136
|
+
const [value, setValue] = useState(referenceDate);
|
|
137
137
|
return (
|
|
138
138
|
<Calendar aria-label="Billing date" value={value} onChange={setValue} />
|
|
139
139
|
);
|
|
@@ -147,11 +147,11 @@ Use Date Restrictions to limit selection to a billing period and exclude specifi
|
|
|
147
147
|
```tsx
|
|
148
148
|
const DateRestrictions = () => <Calendar
|
|
149
149
|
aria-label="Billing date"
|
|
150
|
-
defaultValue={
|
|
151
|
-
minValue={
|
|
152
|
-
maxValue={
|
|
150
|
+
defaultValue={referenceDate}
|
|
151
|
+
minValue={referenceDate.subtract({ days: 7 })}
|
|
152
|
+
maxValue={referenceDate.add({ days: 14 })}
|
|
153
153
|
isDateUnavailable={(date) =>
|
|
154
|
-
date.compare(
|
|
154
|
+
date.compare(referenceDate.add({ days: 5 })) === 0} />;
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
### Disabled
|
|
@@ -159,7 +159,7 @@ const DateRestrictions = () => <Calendar
|
|
|
159
159
|
Use Disabled when calendar interaction is unavailable.
|
|
160
160
|
|
|
161
161
|
```tsx
|
|
162
|
-
const Disabled = () => <Calendar aria-label="Billing date" defaultValue={
|
|
162
|
+
const Disabled = () => <Calendar aria-label="Billing date" defaultValue={referenceDate} isDisabled />;
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
### Read Only
|
|
@@ -167,7 +167,7 @@ const Disabled = () => <Calendar aria-label="Billing date" defaultValue={current
|
|
|
167
167
|
Use Read Only to allow browsing without changing the selected date.
|
|
168
168
|
|
|
169
169
|
```tsx
|
|
170
|
-
const ReadOnly = () => <Calendar aria-label="Billing date" defaultValue={
|
|
170
|
+
const ReadOnly = () => <Calendar aria-label="Billing date" defaultValue={referenceDate} isReadOnly />;
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
### Invalid
|
|
@@ -177,7 +177,7 @@ Use Invalid with an actionable error message when the selected date fails valida
|
|
|
177
177
|
```tsx
|
|
178
178
|
const Invalid = () => <Calendar
|
|
179
179
|
aria-label="Billing date"
|
|
180
|
-
defaultValue={
|
|
180
|
+
defaultValue={referenceDate}
|
|
181
181
|
isInvalid
|
|
182
182
|
errorMessage="Choose a date within the billing period." />;
|
|
183
183
|
```
|
|
@@ -188,6 +188,6 @@ Use I18nProvider to localize labels, weekday order, and navigation direction.
|
|
|
188
188
|
|
|
189
189
|
```tsx
|
|
190
190
|
const International = () => <I18nProvider locale="pl-PL">
|
|
191
|
-
<Calendar aria-label="Billing date" defaultValue={
|
|
191
|
+
<Calendar aria-label="Billing date" defaultValue={referenceDate} />
|
|
192
192
|
</I18nProvider>;
|
|
193
193
|
```
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# DateField
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
DateField provides localized, individually editable date and time segments for keyboard entry.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use for billing, scheduling, or reporting dates.
|
|
12
|
+
- Use when users know the date and can enter it directly.
|
|
13
|
+
|
|
14
|
+
#### When Not to Use
|
|
15
|
+
|
|
16
|
+
- Use DateRangePicker when a task requires two endpoints.
|
|
17
|
+
- Use DatePicker when users need a calendar to browse dates.
|
|
18
|
+
- Do not use for free-form dates or recurring schedule expressions.
|
|
19
|
+
|
|
20
|
+
### Variants
|
|
21
|
+
|
|
22
|
+
| Variant | Purpose | Usage notes |
|
|
23
|
+
| :---------------- | :--------------------------- | :----------------------------------------- |
|
|
24
|
+
| Default | Enter a date | Provide a specific label. |
|
|
25
|
+
| Empty | Start without a value | Date placeholders follow the locale. |
|
|
26
|
+
| Disabled | Prevent interaction | Use when the field is unavailable. |
|
|
27
|
+
| Read only | Prevent edits | Keep the existing value available to read. |
|
|
28
|
+
| Invalid | Explain a validation failure | Supply an actionable error message. |
|
|
29
|
+
| Date restrictions | Limit permitted dates | Explain the limits in the description. |
|
|
30
|
+
|
|
31
|
+
### Behavior
|
|
32
|
+
|
|
33
|
+
- **Mouse and touch**: select a date segment to edit it.
|
|
34
|
+
- **Keyboard**: Tab moves between editable segments; arrow keys adjust values and typing replaces segment contents.
|
|
35
|
+
- **Focus management**: preserve visible keyboard focus. Date segments are separate focus targets.
|
|
36
|
+
- **Controlled state**: use controlled values when application state owns the selection; otherwise supply an initial value.
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
|
|
40
|
+
- Provide a visible `label`, or `aria-label` / `aria-labelledby` when the layout supplies visual context.
|
|
41
|
+
- Use `description` for instructions and `errorMessage` for validation feedback; React Aria associates them with the field.
|
|
42
|
+
- Preserve segment keyboard behavior, accessible names, and visible focus indicators.
|
|
43
|
+
- Explain restrictions in text; do not rely on color alone to communicate errors or unavailable dates.
|
|
44
|
+
|
|
45
|
+
### Content
|
|
46
|
+
|
|
47
|
+
- Use a task-specific label such as "Billing date".
|
|
48
|
+
- Explain date limits before entry, for example "Choose dates within the billing period."
|
|
49
|
+
- Keep errors actionable, such as "Choose a date on or after the invoice date."
|
|
50
|
+
- Allow for locale-specific date order, time zones, and right-to-left layouts.
|
|
51
|
+
|
|
52
|
+
### Related
|
|
53
|
+
|
|
54
|
+
- **[DatePicker](components-forms-datepicker.md)**: Add calendar selection to a single date input.
|
|
55
|
+
- **[DateRangePicker](components-forms-daterangepicker.md)**: Collect a start and end date.
|
|
56
|
+
|
|
57
|
+
## React
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { DateField } from '@maxio-com/react-ui-components';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### State Management
|
|
64
|
+
|
|
65
|
+
#### Controlled
|
|
66
|
+
|
|
67
|
+
Use `value` and `onChange` as shown in the Controlled story. The parent must apply
|
|
68
|
+
changes to `value` before they appear in the input.
|
|
69
|
+
|
|
70
|
+
#### Uncontrolled
|
|
71
|
+
|
|
72
|
+
Use `defaultValue`, as shown in the Default story, to initialize internal state.
|
|
73
|
+
Omit it to start empty.
|
|
74
|
+
|
|
75
|
+
### Date Values and Forms
|
|
76
|
+
|
|
77
|
+
Install `@internationalized/date` in the consuming application to construct values
|
|
78
|
+
with `parseDate` or the appropriate date-time constructor. Values are date objects
|
|
79
|
+
from that package, not JavaScript `Date` instances or strings.
|
|
80
|
+
|
|
81
|
+
A cleared value is `null`. Use `name` for native form submission.
|
|
82
|
+
Use `isRequired`, `validate`, and `validationBehavior` for validation. Pair custom
|
|
83
|
+
invalid state with `isInvalid` and `errorMessage`.
|
|
84
|
+
|
|
85
|
+
### Localization
|
|
86
|
+
|
|
87
|
+
Use React Aria's `I18nProvider`, as shown in the International story, to set date
|
|
88
|
+
order and reading direction. Date-time values support `granularity` and time zones.
|
|
89
|
+
|
|
90
|
+
## Imports
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { DateField, I18nProvider } from "@maxio-com/react-ui-components";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Prop Types
|
|
97
|
+
|
|
98
|
+
### DateField
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
101
|
+
| --- | --- | --- | --- | --- | --- |
|
|
102
|
+
| `description` | `ReactNode` | no | - | Instructions associated with the field. | DateFieldProps |
|
|
103
|
+
| `errorMessage` | `ReactNode \| ((validation: ValidationResult) => ReactNode)` | no | - | Validation feedback, or a function formatting native validation errors. | DateFieldProps |
|
|
104
|
+
| `label` | `ReactNode` | no | - | Visible accessible label. Supply aria-label when omitted. | DateFieldProps |
|
|
105
|
+
|
|
106
|
+
## Stories
|
|
107
|
+
|
|
108
|
+
### Default
|
|
109
|
+
|
|
110
|
+
Use for an initial, uncontrolled date. Provide a visible label or an accessible name.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
const Default = () => <DateField label="Billing date" defaultValue={initialValue} />;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Empty
|
|
117
|
+
|
|
118
|
+
Use when users should make an explicit selection. Placeholders and segment order follow the locale.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
const Empty = () => <DateField label="Billing date" defaultValue={undefined} />;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Controlled
|
|
125
|
+
|
|
126
|
+
Use when application state owns the selection. Apply onChange values back to value to display edits.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
const Controlled = () => {
|
|
130
|
+
const [value, setValue] = useState<DateValue | null>(initialValue);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<DateField
|
|
134
|
+
label="Billing date"
|
|
135
|
+
defaultValue={initialValue}
|
|
136
|
+
value={value}
|
|
137
|
+
onChange={setValue} />
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Disabled
|
|
143
|
+
|
|
144
|
+
Use when the field is unavailable. Prevents editing and selection.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
const Disabled = () => <DateField label="Billing date" defaultValue={initialValue} isDisabled />;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Read Only
|
|
151
|
+
|
|
152
|
+
Use to display a value while preventing edits.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const ReadOnly = () => <DateField label="Billing date" defaultValue={initialValue} isReadOnly />;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Invalid
|
|
159
|
+
|
|
160
|
+
Pair isInvalid with an actionable errorMessage. Do not communicate errors using color alone.
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
const Invalid = () => <DateField
|
|
164
|
+
label="Billing date"
|
|
165
|
+
defaultValue={initialValue}
|
|
166
|
+
isInvalid
|
|
167
|
+
errorMessage="Choose a date within the billing period." />;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Date Restrictions
|
|
171
|
+
|
|
172
|
+
Use minValue, maxValue, and isDateUnavailable to limit dates. Explain restrictions with description.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
const DateRestrictions = () => <DateField
|
|
176
|
+
label="Billing date"
|
|
177
|
+
defaultValue={initialValue}
|
|
178
|
+
minValue={parseDate('2026-09-01')}
|
|
179
|
+
maxValue={parseDate('2026-09-30')}
|
|
180
|
+
description="Choose dates in September 2026."
|
|
181
|
+
isDateUnavailable={(date) => date.day === 20} />;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### International
|
|
185
|
+
|
|
186
|
+
Use I18nProvider to localize date order and reading direction. Localize visible labels in the consuming app.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
const International = () => <I18nProvider locale="pl-PL">
|
|
190
|
+
<DateField label="Billing date" defaultValue={initialValue} />
|
|
191
|
+
</I18nProvider>;
|
|
192
|
+
```
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# DatePicker
|
|
2
|
+
|
|
3
|
+
## Usage Guidelines
|
|
4
|
+
|
|
5
|
+
### Overview
|
|
6
|
+
|
|
7
|
+
DatePicker combines localized date entry with a calendar popover for selecting one date.
|
|
8
|
+
|
|
9
|
+
#### When to Use
|
|
10
|
+
|
|
11
|
+
- Use for billing, scheduling, or reporting dates.
|
|
12
|
+
- Use when users benefit from both typed entry and calendar selection.
|
|
13
|
+
|
|
14
|
+
#### When Not to Use
|
|
15
|
+
|
|
16
|
+
- Use DateRangePicker when a task requires two endpoints.
|
|
17
|
+
- Use Calendar for a month grid that stays visible.
|
|
18
|
+
- Do not use for free-form dates or recurring schedule expressions.
|
|
19
|
+
|
|
20
|
+
### Variants
|
|
21
|
+
|
|
22
|
+
| Variant | Purpose | Usage notes |
|
|
23
|
+
| :---------------- | :------------------------------- | :----------------------------------------- |
|
|
24
|
+
| Default | Enter a date | Provide a specific label. |
|
|
25
|
+
| Empty | Start without a value | Date placeholders follow the locale. |
|
|
26
|
+
| Disabled | Prevent interaction | Use when the field is unavailable. |
|
|
27
|
+
| Read only | Prevent edits | Keep the existing value available to read. |
|
|
28
|
+
| Invalid | Explain a validation failure | Supply an actionable error message. |
|
|
29
|
+
| Date restrictions | Limit permitted dates | Explain the limits in the description. |
|
|
30
|
+
| Presets | Offer frequently used selections | Give each shortcut a clear label. |
|
|
31
|
+
|
|
32
|
+
### Behavior
|
|
33
|
+
|
|
34
|
+
- **Mouse and touch**: select a date segment to edit it. Open the calendar button to browse and select dates.
|
|
35
|
+
- **Keyboard**: Tab moves between editable segments; arrow keys adjust values and typing replaces segment contents. In the calendar, arrow keys move focus and Enter or Space selects a date. Escape dismisses the popover.
|
|
36
|
+
- **Focus management**: preserve visible keyboard focus. Closing the popover returns focus to its trigger.
|
|
37
|
+
- **Controlled state**: use controlled values when application state owns the selection; otherwise supply an initial value.
|
|
38
|
+
- **Presets**: selecting a shortcut updates the selection and closes the popover. Disabled or restricted shortcuts cannot be selected.
|
|
39
|
+
- **Display text**: a null preset shows its label instead of empty date segments. That text is not editable or a keyboard tab stop; users can replace it through the calendar or presets.
|
|
40
|
+
|
|
41
|
+
### Accessibility
|
|
42
|
+
|
|
43
|
+
- Provide a visible `label`, or `aria-label` / `aria-labelledby` when the layout supplies visual context.
|
|
44
|
+
- Use `description` for instructions and `errorMessage` for validation feedback; React Aria associates them with the field.
|
|
45
|
+
- Preserve segment keyboard behavior, accessible names, and visible focus indicators.
|
|
46
|
+
- Explain restrictions in text; do not rely on color alone to communicate errors or unavailable dates.
|
|
47
|
+
- Localize preset labels and the preset group name alongside the surrounding interface.
|
|
48
|
+
|
|
49
|
+
### Content
|
|
50
|
+
|
|
51
|
+
- Use a task-specific label such as "Billing date".
|
|
52
|
+
- Explain date limits before entry, for example "Choose dates within the billing period."
|
|
53
|
+
- Keep errors actionable, such as "Choose a date on or after the invoice date."
|
|
54
|
+
- Allow for locale-specific date order, time zones, and right-to-left layouts.
|
|
55
|
+
|
|
56
|
+
### Related
|
|
57
|
+
|
|
58
|
+
- **[DateField](components-forms-datefield.md)**: Use segmented entry without a calendar popover.
|
|
59
|
+
- **[DateRangePicker](components-forms-daterangepicker.md)**: Collect a start and end date.
|
|
60
|
+
- **[Calendar](components-calendar.md)**: Keep a month grid visible on the page.
|
|
61
|
+
|
|
62
|
+
## React
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { DatePicker } from '@maxio-com/react-ui-components';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### State Management
|
|
69
|
+
|
|
70
|
+
#### Controlled
|
|
71
|
+
|
|
72
|
+
Use `value` and `onChange` as shown in the Controlled story. The parent must apply
|
|
73
|
+
changes to `value` before they appear in the input.
|
|
74
|
+
|
|
75
|
+
#### Uncontrolled
|
|
76
|
+
|
|
77
|
+
Use `defaultValue`, as shown in the Default story, to initialize internal state.
|
|
78
|
+
Omit it to start empty.
|
|
79
|
+
|
|
80
|
+
### Date Values and Forms
|
|
81
|
+
|
|
82
|
+
Install `@internationalized/date` in the consuming application to construct values
|
|
83
|
+
with `parseDate` or the appropriate date-time constructor. Values are date objects
|
|
84
|
+
from that package, not JavaScript `Date` instances or strings.
|
|
85
|
+
|
|
86
|
+
A cleared value is `null`. Use `name` for native form submission.
|
|
87
|
+
Use `isRequired`, `validate`, and `validationBehavior` for validation. Pair custom
|
|
88
|
+
invalid state with `isInvalid` and `errorMessage`.
|
|
89
|
+
|
|
90
|
+
### Localization
|
|
91
|
+
|
|
92
|
+
Use React Aria's `I18nProvider`, as shown in the International story, to set date
|
|
93
|
+
order and reading direction. Date-time values support `granularity` and time zones.
|
|
94
|
+
|
|
95
|
+
### Preset Values
|
|
96
|
+
|
|
97
|
+
Each `presets` entry has a `label`, `value`, and optional `isDisabled`. Set
|
|
98
|
+
`presetsLabel` to localize the group name, which defaults to "Presets".
|
|
99
|
+
A null value clears the selection. Its `label` replaces empty
|
|
100
|
+
segments with non-editable text; the first matching preset supplies that text.
|
|
101
|
+
Preset labels do not become submitted date values or satisfy required validation.
|
|
102
|
+
|
|
103
|
+
## Imports
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { DatePicker, I18nProvider } from "@maxio-com/react-ui-components";
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Prop Types
|
|
110
|
+
|
|
111
|
+
### DatePicker
|
|
112
|
+
|
|
113
|
+
| Prop | Type | Required | Default | Description | Source |
|
|
114
|
+
| --- | --- | --- | --- | --- | --- |
|
|
115
|
+
| `description` | `ReactNode` | no | - | Instructions associated with the field. | DatePickerProps |
|
|
116
|
+
| `errorMessage` | `ReactNode \| ((validation: ValidationResult) => ReactNode)` | no | - | Validation feedback, or a function formatting native validation errors. | DatePickerProps |
|
|
117
|
+
| `label` | `ReactNode` | no | - | Visible accessible label. Supply aria-label when omitted. | DatePickerProps |
|
|
118
|
+
| `presets` | `readonly DatePreset<T>[]` | no | - | Optional shortcuts. Values use the same date type as the picker. | DatePickerProps |
|
|
119
|
+
| `presetsLabel` | `string` | no | - | Accessible name for the preset group; localize alongside preset labels. | DatePickerProps |
|
|
120
|
+
|
|
121
|
+
## Stories
|
|
122
|
+
|
|
123
|
+
### Default
|
|
124
|
+
|
|
125
|
+
Use for an initial, uncontrolled date. Provide a visible label or an accessible name.
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
const Default = () => <DatePicker label="Billing date" defaultValue={initialValue} />;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Empty
|
|
132
|
+
|
|
133
|
+
Use when users should make an explicit selection. Placeholders and segment order follow the locale.
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
const Empty = () => <DatePicker label="Billing date" defaultValue={undefined} />;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Controlled
|
|
140
|
+
|
|
141
|
+
Use when application state owns the selection. Apply onChange values back to value to display edits.
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
const Controlled = () => {
|
|
145
|
+
const [value, setValue] = useState<DateValue | null>(initialValue);
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<DatePicker
|
|
149
|
+
label="Billing date"
|
|
150
|
+
defaultValue={initialValue}
|
|
151
|
+
value={value}
|
|
152
|
+
onChange={setValue} />
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Disabled
|
|
158
|
+
|
|
159
|
+
Use when the field is unavailable. Prevents editing and selection.
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
const Disabled = () => <DatePicker label="Billing date" defaultValue={initialValue} isDisabled />;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Read Only
|
|
166
|
+
|
|
167
|
+
Use to display a value while preventing edits.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const ReadOnly = () => <DatePicker label="Billing date" defaultValue={initialValue} isReadOnly />;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Invalid
|
|
174
|
+
|
|
175
|
+
Pair isInvalid with an actionable errorMessage. Do not communicate errors using color alone.
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
const Invalid = () => <DatePicker
|
|
179
|
+
label="Billing date"
|
|
180
|
+
defaultValue={initialValue}
|
|
181
|
+
isInvalid
|
|
182
|
+
errorMessage="Choose a date within the billing period." />;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Date Restrictions
|
|
186
|
+
|
|
187
|
+
Use minValue, maxValue, and isDateUnavailable to limit dates. Explain restrictions with description.
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
const DateRestrictions = () => <DatePicker
|
|
191
|
+
label="Billing date"
|
|
192
|
+
defaultValue={initialValue}
|
|
193
|
+
minValue={parseDate('2026-09-01')}
|
|
194
|
+
maxValue={parseDate('2026-09-30')}
|
|
195
|
+
description="Choose dates in September 2026."
|
|
196
|
+
isDateUnavailable={(date) => date.day === 20} />;
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### International
|
|
200
|
+
|
|
201
|
+
Use I18nProvider to localize date order and reading direction. Localize visible labels in the consuming app.
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
const International = () => <I18nProvider locale="pl-PL">
|
|
205
|
+
<DatePicker label="Billing date" defaultValue={initialValue} />
|
|
206
|
+
</I18nProvider>;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Presets
|
|
210
|
+
|
|
211
|
+
Use labeled shortcuts for common dates. A null preset clears the value and shows its label as non-editable text. Date restrictions and disabled/read-only state apply to shortcuts.
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
const Presets = () => <DatePicker
|
|
215
|
+
label="Billing date"
|
|
216
|
+
defaultValue={initialValue}
|
|
217
|
+
presets={[
|
|
218
|
+
{ label: 'Today', value: referenceDate },
|
|
219
|
+
{ label: 'Evergreen', value: null },
|
|
220
|
+
]} />;
|
|
221
|
+
```
|