@simplybusiness/mobius-datepicker 4.0.0-beta.7 → 4.0.0-beta.9
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/cjs/components/NewDatePicker/DatePickerIcon.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/DatePickerIcon.js +7 -0
- package/dist/cjs/components/NewDatePicker/DatePickerIcon.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/DatePickerModal.d.ts +7 -0
- package/dist/cjs/components/NewDatePicker/DatePickerModal.js +35 -0
- package/dist/cjs/components/NewDatePicker/DatePickerModal.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.d.ts +7 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.js +73 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.stories.d.ts +27 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.stories.js +32 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.stories.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.test.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.test.js +80 -0
- package/dist/cjs/components/NewDatePicker/NewDatePicker.test.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/constants.d.ts +2 -0
- package/dist/cjs/components/NewDatePicker/constants.js +7 -0
- package/dist/cjs/components/NewDatePicker/constants.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.js +7 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.test.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.test.js +15 -0
- package/dist/cjs/components/NewDatePicker/dateObjToString.test.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/index.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/index.js +18 -0
- package/dist/cjs/components/NewDatePicker/index.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.d.ts +2 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.js +14 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.js.map +1 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.test.d.ts +1 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.test.js +23 -0
- package/dist/cjs/components/NewDatePicker/weekdayAsOneLetter.test.js.map +1 -0
- package/dist/cjs/hooks/useFocusTrap.d.ts +5 -0
- package/dist/cjs/hooks/useFocusTrap.js +41 -0
- package/dist/cjs/hooks/useFocusTrap.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/excludeControls.d.ts +1 -0
- package/dist/cjs/utils/excludeControls.js +29 -0
- package/dist/cjs/utils/excludeControls.js.map +1 -0
- package/dist/cjs/utils/excludeControls.test.d.ts +1 -0
- package/dist/cjs/utils/excludeControls.test.js +25 -0
- package/dist/cjs/utils/excludeControls.test.js.map +1 -0
- package/dist/cjs/utils/isTouchDevice.d.ts +1 -0
- package/dist/cjs/utils/isTouchDevice.js +11 -0
- package/dist/cjs/utils/isTouchDevice.js.map +1 -0
- package/dist/esm/components/NewDatePicker/DatePickerIcon.js +3 -0
- package/dist/esm/components/NewDatePicker/DatePickerIcon.js.map +1 -0
- package/dist/esm/components/NewDatePicker/DatePickerModal.js +28 -0
- package/dist/esm/components/NewDatePicker/DatePickerModal.js.map +1 -0
- package/dist/esm/components/NewDatePicker/NewDatePicker.js +66 -0
- package/dist/esm/components/NewDatePicker/NewDatePicker.js.map +1 -0
- package/dist/esm/components/NewDatePicker/constants.js +4 -0
- package/dist/esm/components/NewDatePicker/constants.js.map +1 -0
- package/dist/esm/components/NewDatePicker/dateObjToString.js +3 -0
- package/dist/esm/components/NewDatePicker/dateObjToString.js.map +1 -0
- package/dist/esm/components/NewDatePicker/dateObjToString.test.js +13 -0
- package/dist/esm/components/NewDatePicker/dateObjToString.test.js.map +1 -0
- package/dist/esm/components/NewDatePicker/index.js +2 -0
- package/dist/esm/components/NewDatePicker/index.js.map +1 -0
- package/dist/esm/components/NewDatePicker/weekdayAsOneLetter.js +10 -0
- package/dist/esm/components/NewDatePicker/weekdayAsOneLetter.js.map +1 -0
- package/dist/esm/components/NewDatePicker/weekdayAsOneLetter.test.js +21 -0
- package/dist/esm/components/NewDatePicker/weekdayAsOneLetter.test.js.map +1 -0
- package/dist/esm/hooks/useFocusTrap.js +38 -0
- package/dist/esm/hooks/useFocusTrap.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/excludeControls.js +25 -0
- package/dist/esm/utils/excludeControls.js.map +1 -0
- package/dist/esm/utils/excludeControls.test.js +23 -0
- package/dist/esm/utils/excludeControls.test.js.map +1 -0
- package/dist/esm/utils/isTouchDevice.js +7 -0
- package/dist/esm/utils/isTouchDevice.js.map +1 -0
- package/package.json +6 -4
- package/src/components/NewDatePicker/DatePickerIcon.tsx +1 -0
- package/src/components/NewDatePicker/DatePickerModal.tsx +69 -0
- package/src/components/NewDatePicker/NewDatePicker.mdx +521 -0
- package/src/components/NewDatePicker/NewDatePicker.stories.tsx +46 -0
- package/src/components/NewDatePicker/NewDatePicker.test.tsx +121 -0
- package/src/components/NewDatePicker/NewDatePicker.tsx +119 -0
- package/src/components/NewDatePicker/constants.ts +3 -0
- package/src/components/NewDatePicker/dateObjToString.test.ts +17 -0
- package/src/components/NewDatePicker/dateObjToString.ts +3 -0
- package/src/components/NewDatePicker/index.tsx +1 -0
- package/src/components/NewDatePicker/weekdayAsOneLetter.test.ts +28 -0
- package/src/components/NewDatePicker/weekdayAsOneLetter.ts +11 -0
- package/src/hooks/useFocusTrap.tsx +55 -0
- package/src/utils/excludeControls.test.ts +26 -0
- package/src/utils/excludeControls.ts +28 -0
- package/src/utils/isTouchDevice.ts +7 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplybusiness/mobius-datepicker",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.9",
|
|
5
5
|
"description": "Mobius date picker component",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -91,10 +91,12 @@
|
|
|
91
91
|
"@react-aria/visually-hidden": "^3.8.6",
|
|
92
92
|
"@react-stately/calendar": "^3.4.1",
|
|
93
93
|
"@react-stately/datepicker": "^3.8.0",
|
|
94
|
-
"@simplybusiness/icons": "^4.0.0-beta.
|
|
95
|
-
"@simplybusiness/mobius": "^4.0.0-beta.
|
|
94
|
+
"@simplybusiness/icons": "^4.0.0-beta.9",
|
|
95
|
+
"@simplybusiness/mobius": "^4.0.0-beta.9",
|
|
96
96
|
"classnames": "^2.3.2",
|
|
97
|
-
"
|
|
97
|
+
"date-fns": "^2.30.0",
|
|
98
|
+
"lodash.debounce": "^4.0.8",
|
|
99
|
+
"react-day-picker": "^8.9.1"
|
|
98
100
|
},
|
|
99
101
|
"lint-staged": {
|
|
100
102
|
"*.{js,ts,jsx,tsx}": "eslint --ext .tsx,.ts,.js,.jsx,.mjs --fix"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DatePickerIcon = () => <> </>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { VisuallyHidden } from "@simplybusiness/mobius";
|
|
4
|
+
import classNames from "classnames/dedupe";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
import { DayPicker } from "react-day-picker";
|
|
7
|
+
import FocusTrap from "../../hooks/useFocusTrap";
|
|
8
|
+
import { DatePickerIcon } from "./DatePickerIcon";
|
|
9
|
+
import { MONDAY_AS_NUMBER } from "./constants";
|
|
10
|
+
import { dateObjToString } from "./dateObjToString";
|
|
11
|
+
import { weekdayAsOneLetter } from "./weekdayAsOneLetter";
|
|
12
|
+
|
|
13
|
+
export type DatePickerModalProps = {
|
|
14
|
+
date?: string; // yyyy-mm-dd
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
onSelected: (date: string) => void;
|
|
17
|
+
top: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const DatePickerModal = ({
|
|
21
|
+
date,
|
|
22
|
+
isOpen,
|
|
23
|
+
onSelected,
|
|
24
|
+
top,
|
|
25
|
+
}: DatePickerModalProps) => {
|
|
26
|
+
const modalRef = useRef<HTMLDivElement>(null);
|
|
27
|
+
const initialDate = date ? new Date(date) : new Date();
|
|
28
|
+
|
|
29
|
+
const handleDayPickerSelect = (selectedDate: Date | undefined) => {
|
|
30
|
+
if (!selectedDate) return;
|
|
31
|
+
|
|
32
|
+
onSelected(dateObjToString(selectedDate));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const modalClasses = classNames("mobius/DatePickerModal", {
|
|
36
|
+
"--is-open": isOpen,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FocusTrap>
|
|
41
|
+
<div
|
|
42
|
+
ref={modalRef}
|
|
43
|
+
className={modalClasses}
|
|
44
|
+
style={{ top }}
|
|
45
|
+
aria-describedby="screen-reader-title"
|
|
46
|
+
>
|
|
47
|
+
<VisuallyHidden>
|
|
48
|
+
<div id="screen-reader-title">
|
|
49
|
+
Please select a date from the calendar
|
|
50
|
+
</div>
|
|
51
|
+
</VisuallyHidden>
|
|
52
|
+
<DayPicker
|
|
53
|
+
mode="single"
|
|
54
|
+
selected={initialDate}
|
|
55
|
+
defaultMonth={initialDate}
|
|
56
|
+
onSelect={handleDayPickerSelect}
|
|
57
|
+
pagedNavigation
|
|
58
|
+
showOutsideDays
|
|
59
|
+
weekStartsOn={MONDAY_AS_NUMBER}
|
|
60
|
+
formatters={{ formatWeekdayName: weekdayAsOneLetter }}
|
|
61
|
+
components={{
|
|
62
|
+
IconLeft: DatePickerIcon,
|
|
63
|
+
IconRight: DatePickerIcon,
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</FocusTrap>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
import { Meta, ArgTypes, Canvas, Story } from "@storybook/blocks";
|
|
2
|
+
import { NewDatePicker } from "./NewDatePicker";
|
|
3
|
+
import * as DatePickerStories from "./NewDatePicker.stories";
|
|
4
|
+
|
|
5
|
+
<Meta of={DatePickerStories} />
|
|
6
|
+
|
|
7
|
+
# DatePicker
|
|
8
|
+
|
|
9
|
+
DatePicker allows you to display a date picker.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @simplybusiness/mobius-datepicker
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { DatePicker } from "@simplybusiness/mobius-datepicker";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Normal
|
|
24
|
+
|
|
25
|
+
<Story of={DatePickerStories.Normal} />
|
|
26
|
+
|
|
27
|
+
{/* prettier-ignore */}
|
|
28
|
+
```jsx
|
|
29
|
+
import { NewDatePicker } from "@simplybusiness/mobius-datepicker";
|
|
30
|
+
|
|
31
|
+
<DatePicker defaultValue="2023-11-13" label="Start date" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# Localising
|
|
35
|
+
|
|
36
|
+
## Props
|
|
37
|
+
|
|
38
|
+
<ArgTypes of={NewDatePicker} />
|
|
39
|
+
|
|
40
|
+
## Component HTML Structure and Class names
|
|
41
|
+
|
|
42
|
+
The following HTML is rendered for a DatePicker:
|
|
43
|
+
|
|
44
|
+
### DateField
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<div class="mobius/DateFieldGroup">
|
|
48
|
+
<div class="mobius/DateField">
|
|
49
|
+
<span></span>
|
|
50
|
+
<div role="presentation" class="mobius/DateSegments">
|
|
51
|
+
<div class="mobius/DateSegment --is-placeholder">mm</div>
|
|
52
|
+
<div aria-hidden="true" class="mobius/DateSegment --is-literal">/</div>
|
|
53
|
+
<div class="mobius/DateSegment --is-placeholder">dd</div>
|
|
54
|
+
<div aria-hidden="true" class="mobius/DateSegment --is-literal">/</div>
|
|
55
|
+
<div class="mobius/DateSegment --is-placeholder">yyyy</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
class="mobius mobius/Button --variant-secondary --size-medium mobius/DateFieldButton"
|
|
61
|
+
>
|
|
62
|
+
<span>
|
|
63
|
+
<div>Pick date</div>
|
|
64
|
+
</span>
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Calendar
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<div class="mobius/DatePickerContainer">
|
|
73
|
+
<div class="mobius mobius/Flex mobius/TextField mobius/DatePicker">
|
|
74
|
+
<label class="mobius mobius/Label">Start date</label>
|
|
75
|
+
<div class="mobius/TextFieldInputWrapper">
|
|
76
|
+
<input
|
|
77
|
+
aria-invalid="false"
|
|
78
|
+
type="date"
|
|
79
|
+
class="mobius mobius/TextInput mobius/DatePicker"
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<button
|
|
84
|
+
tabindex="0"
|
|
85
|
+
type="button"
|
|
86
|
+
class="mobius mobius/Button --variant-primary --size-medium mobius/DateFieldButton"
|
|
87
|
+
>
|
|
88
|
+
<div>Pick date</div>
|
|
89
|
+
</button>
|
|
90
|
+
<div class="mobius/DatePickerModal --is-open" style="top: 74px;">
|
|
91
|
+
<div class="rdp">
|
|
92
|
+
<div class="rdp-months">
|
|
93
|
+
<div class="rdp-month rdp-caption_start rdp-caption_end">
|
|
94
|
+
<div class="rdp-caption">
|
|
95
|
+
<div
|
|
96
|
+
class="rdp-caption_label"
|
|
97
|
+
aria-live="polite"
|
|
98
|
+
role="presentation"
|
|
99
|
+
id="react-day-picker-1"
|
|
100
|
+
>
|
|
101
|
+
November 2023
|
|
102
|
+
</div>
|
|
103
|
+
<div class="rdp-nav">
|
|
104
|
+
<button
|
|
105
|
+
name="previous-month"
|
|
106
|
+
aria-label="Go to previous month"
|
|
107
|
+
class="rdp-button_reset rdp-button rdp-nav_button rdp-nav_button_previous"
|
|
108
|
+
type="button"
|
|
109
|
+
></button
|
|
110
|
+
><button
|
|
111
|
+
name="next-month"
|
|
112
|
+
aria-label="Go to next month"
|
|
113
|
+
class="rdp-button_reset rdp-button rdp-nav_button rdp-nav_button_next"
|
|
114
|
+
type="button"
|
|
115
|
+
></button>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
<table
|
|
119
|
+
class="rdp-table"
|
|
120
|
+
role="grid"
|
|
121
|
+
aria-labelledby="react-day-picker-1"
|
|
122
|
+
>
|
|
123
|
+
<thead class="rdp-head">
|
|
124
|
+
<tr class="rdp-head_row">
|
|
125
|
+
<th scope="col" class="rdp-head_cell" aria-label="Monday">M</th>
|
|
126
|
+
<th scope="col" class="rdp-head_cell" aria-label="Tuesday">
|
|
127
|
+
T
|
|
128
|
+
</th>
|
|
129
|
+
<th scope="col" class="rdp-head_cell" aria-label="Wednesday">
|
|
130
|
+
W
|
|
131
|
+
</th>
|
|
132
|
+
<th scope="col" class="rdp-head_cell" aria-label="Thursday">
|
|
133
|
+
T
|
|
134
|
+
</th>
|
|
135
|
+
<th scope="col" class="rdp-head_cell" aria-label="Friday">F</th>
|
|
136
|
+
<th scope="col" class="rdp-head_cell" aria-label="Saturday">
|
|
137
|
+
S
|
|
138
|
+
</th>
|
|
139
|
+
<th scope="col" class="rdp-head_cell" aria-label="Sunday">S</th>
|
|
140
|
+
</tr>
|
|
141
|
+
</thead>
|
|
142
|
+
<tbody class="rdp-tbody">
|
|
143
|
+
<tr class="rdp-row">
|
|
144
|
+
<td class="rdp-cell" role="presentation">
|
|
145
|
+
<button
|
|
146
|
+
name="day"
|
|
147
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_outside"
|
|
148
|
+
role="gridcell"
|
|
149
|
+
tabindex="-1"
|
|
150
|
+
>
|
|
151
|
+
30
|
|
152
|
+
</button>
|
|
153
|
+
</td>
|
|
154
|
+
<td class="rdp-cell" role="presentation">
|
|
155
|
+
<button
|
|
156
|
+
name="day"
|
|
157
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_outside"
|
|
158
|
+
role="gridcell"
|
|
159
|
+
tabindex="-1"
|
|
160
|
+
>
|
|
161
|
+
31
|
|
162
|
+
</button>
|
|
163
|
+
</td>
|
|
164
|
+
<td class="rdp-cell" role="presentation">
|
|
165
|
+
<button
|
|
166
|
+
name="day"
|
|
167
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
168
|
+
role="gridcell"
|
|
169
|
+
tabindex="-1"
|
|
170
|
+
>
|
|
171
|
+
1
|
|
172
|
+
</button>
|
|
173
|
+
</td>
|
|
174
|
+
<td class="rdp-cell" role="presentation">
|
|
175
|
+
<button
|
|
176
|
+
name="day"
|
|
177
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
178
|
+
role="gridcell"
|
|
179
|
+
tabindex="-1"
|
|
180
|
+
>
|
|
181
|
+
2
|
|
182
|
+
</button>
|
|
183
|
+
</td>
|
|
184
|
+
<td class="rdp-cell" role="presentation">
|
|
185
|
+
<button
|
|
186
|
+
name="day"
|
|
187
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
188
|
+
role="gridcell"
|
|
189
|
+
tabindex="-1"
|
|
190
|
+
>
|
|
191
|
+
3
|
|
192
|
+
</button>
|
|
193
|
+
</td>
|
|
194
|
+
<td class="rdp-cell" role="presentation">
|
|
195
|
+
<button
|
|
196
|
+
name="day"
|
|
197
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
198
|
+
role="gridcell"
|
|
199
|
+
tabindex="-1"
|
|
200
|
+
>
|
|
201
|
+
4
|
|
202
|
+
</button>
|
|
203
|
+
</td>
|
|
204
|
+
<td class="rdp-cell" role="presentation">
|
|
205
|
+
<button
|
|
206
|
+
name="day"
|
|
207
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
208
|
+
role="gridcell"
|
|
209
|
+
tabindex="-1"
|
|
210
|
+
>
|
|
211
|
+
5
|
|
212
|
+
</button>
|
|
213
|
+
</td>
|
|
214
|
+
</tr>
|
|
215
|
+
<tr class="rdp-row">
|
|
216
|
+
<td class="rdp-cell" role="presentation">
|
|
217
|
+
<button
|
|
218
|
+
name="day"
|
|
219
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
220
|
+
role="gridcell"
|
|
221
|
+
tabindex="-1"
|
|
222
|
+
>
|
|
223
|
+
6
|
|
224
|
+
</button>
|
|
225
|
+
</td>
|
|
226
|
+
<td class="rdp-cell" role="presentation">
|
|
227
|
+
<button
|
|
228
|
+
name="day"
|
|
229
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
230
|
+
role="gridcell"
|
|
231
|
+
tabindex="-1"
|
|
232
|
+
>
|
|
233
|
+
7
|
|
234
|
+
</button>
|
|
235
|
+
</td>
|
|
236
|
+
<td class="rdp-cell" role="presentation">
|
|
237
|
+
<button
|
|
238
|
+
name="day"
|
|
239
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
240
|
+
role="gridcell"
|
|
241
|
+
tabindex="-1"
|
|
242
|
+
>
|
|
243
|
+
8
|
|
244
|
+
</button>
|
|
245
|
+
</td>
|
|
246
|
+
<td class="rdp-cell" role="presentation">
|
|
247
|
+
<button
|
|
248
|
+
name="day"
|
|
249
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
250
|
+
role="gridcell"
|
|
251
|
+
tabindex="-1"
|
|
252
|
+
>
|
|
253
|
+
9
|
|
254
|
+
</button>
|
|
255
|
+
</td>
|
|
256
|
+
<td class="rdp-cell" role="presentation">
|
|
257
|
+
<button
|
|
258
|
+
name="day"
|
|
259
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
260
|
+
role="gridcell"
|
|
261
|
+
tabindex="-1"
|
|
262
|
+
>
|
|
263
|
+
10
|
|
264
|
+
</button>
|
|
265
|
+
</td>
|
|
266
|
+
<td class="rdp-cell" role="presentation">
|
|
267
|
+
<button
|
|
268
|
+
name="day"
|
|
269
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
270
|
+
role="gridcell"
|
|
271
|
+
tabindex="-1"
|
|
272
|
+
>
|
|
273
|
+
11
|
|
274
|
+
</button>
|
|
275
|
+
</td>
|
|
276
|
+
<td class="rdp-cell" role="presentation">
|
|
277
|
+
<button
|
|
278
|
+
name="day"
|
|
279
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
280
|
+
role="gridcell"
|
|
281
|
+
tabindex="-1"
|
|
282
|
+
>
|
|
283
|
+
12
|
|
284
|
+
</button>
|
|
285
|
+
</td>
|
|
286
|
+
</tr>
|
|
287
|
+
<tr class="rdp-row">
|
|
288
|
+
<td class="rdp-cell" role="presentation">
|
|
289
|
+
<button
|
|
290
|
+
name="day"
|
|
291
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_today"
|
|
292
|
+
role="gridcell"
|
|
293
|
+
tabindex="0"
|
|
294
|
+
>
|
|
295
|
+
13
|
|
296
|
+
</button>
|
|
297
|
+
</td>
|
|
298
|
+
<td class="rdp-cell" role="presentation">
|
|
299
|
+
<button
|
|
300
|
+
name="day"
|
|
301
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
302
|
+
role="gridcell"
|
|
303
|
+
tabindex="-1"
|
|
304
|
+
>
|
|
305
|
+
14
|
|
306
|
+
</button>
|
|
307
|
+
</td>
|
|
308
|
+
<td class="rdp-cell" role="presentation">
|
|
309
|
+
<button
|
|
310
|
+
name="day"
|
|
311
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
312
|
+
role="gridcell"
|
|
313
|
+
tabindex="-1"
|
|
314
|
+
>
|
|
315
|
+
15
|
|
316
|
+
</button>
|
|
317
|
+
</td>
|
|
318
|
+
<td class="rdp-cell" role="presentation">
|
|
319
|
+
<button
|
|
320
|
+
name="day"
|
|
321
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
322
|
+
role="gridcell"
|
|
323
|
+
tabindex="-1"
|
|
324
|
+
>
|
|
325
|
+
16
|
|
326
|
+
</button>
|
|
327
|
+
</td>
|
|
328
|
+
<td class="rdp-cell" role="presentation">
|
|
329
|
+
<button
|
|
330
|
+
name="day"
|
|
331
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
332
|
+
role="gridcell"
|
|
333
|
+
tabindex="-1"
|
|
334
|
+
>
|
|
335
|
+
17
|
|
336
|
+
</button>
|
|
337
|
+
</td>
|
|
338
|
+
<td class="rdp-cell" role="presentation">
|
|
339
|
+
<button
|
|
340
|
+
name="day"
|
|
341
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
342
|
+
role="gridcell"
|
|
343
|
+
tabindex="-1"
|
|
344
|
+
>
|
|
345
|
+
18
|
|
346
|
+
</button>
|
|
347
|
+
</td>
|
|
348
|
+
<td class="rdp-cell" role="presentation">
|
|
349
|
+
<button
|
|
350
|
+
name="day"
|
|
351
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
352
|
+
role="gridcell"
|
|
353
|
+
tabindex="-1"
|
|
354
|
+
>
|
|
355
|
+
19
|
|
356
|
+
</button>
|
|
357
|
+
</td>
|
|
358
|
+
</tr>
|
|
359
|
+
<tr class="rdp-row">
|
|
360
|
+
<td class="rdp-cell" role="presentation">
|
|
361
|
+
<button
|
|
362
|
+
name="day"
|
|
363
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
364
|
+
role="gridcell"
|
|
365
|
+
tabindex="-1"
|
|
366
|
+
>
|
|
367
|
+
20
|
|
368
|
+
</button>
|
|
369
|
+
</td>
|
|
370
|
+
<td class="rdp-cell" role="presentation">
|
|
371
|
+
<button
|
|
372
|
+
name="day"
|
|
373
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
374
|
+
role="gridcell"
|
|
375
|
+
tabindex="-1"
|
|
376
|
+
>
|
|
377
|
+
21
|
|
378
|
+
</button>
|
|
379
|
+
</td>
|
|
380
|
+
<td class="rdp-cell" role="presentation">
|
|
381
|
+
<button
|
|
382
|
+
name="day"
|
|
383
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
384
|
+
role="gridcell"
|
|
385
|
+
tabindex="-1"
|
|
386
|
+
>
|
|
387
|
+
22
|
|
388
|
+
</button>
|
|
389
|
+
</td>
|
|
390
|
+
<td class="rdp-cell" role="presentation">
|
|
391
|
+
<button
|
|
392
|
+
name="day"
|
|
393
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
394
|
+
role="gridcell"
|
|
395
|
+
tabindex="-1"
|
|
396
|
+
>
|
|
397
|
+
23
|
|
398
|
+
</button>
|
|
399
|
+
</td>
|
|
400
|
+
<td class="rdp-cell" role="presentation">
|
|
401
|
+
<button
|
|
402
|
+
name="day"
|
|
403
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
404
|
+
role="gridcell"
|
|
405
|
+
tabindex="-1"
|
|
406
|
+
>
|
|
407
|
+
24
|
|
408
|
+
</button>
|
|
409
|
+
</td>
|
|
410
|
+
<td class="rdp-cell" role="presentation">
|
|
411
|
+
<button
|
|
412
|
+
name="day"
|
|
413
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
414
|
+
role="gridcell"
|
|
415
|
+
tabindex="-1"
|
|
416
|
+
>
|
|
417
|
+
25
|
|
418
|
+
</button>
|
|
419
|
+
</td>
|
|
420
|
+
<td class="rdp-cell" role="presentation">
|
|
421
|
+
<button
|
|
422
|
+
name="day"
|
|
423
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
424
|
+
role="gridcell"
|
|
425
|
+
tabindex="-1"
|
|
426
|
+
>
|
|
427
|
+
26
|
|
428
|
+
</button>
|
|
429
|
+
</td>
|
|
430
|
+
</tr>
|
|
431
|
+
<tr class="rdp-row">
|
|
432
|
+
<td class="rdp-cell" role="presentation">
|
|
433
|
+
<button
|
|
434
|
+
name="day"
|
|
435
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
436
|
+
role="gridcell"
|
|
437
|
+
tabindex="-1"
|
|
438
|
+
>
|
|
439
|
+
27
|
|
440
|
+
</button>
|
|
441
|
+
</td>
|
|
442
|
+
<td class="rdp-cell" role="presentation">
|
|
443
|
+
<button
|
|
444
|
+
name="day"
|
|
445
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
446
|
+
role="gridcell"
|
|
447
|
+
tabindex="-1"
|
|
448
|
+
>
|
|
449
|
+
28
|
|
450
|
+
</button>
|
|
451
|
+
</td>
|
|
452
|
+
<td class="rdp-cell" role="presentation">
|
|
453
|
+
<button
|
|
454
|
+
name="day"
|
|
455
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
456
|
+
role="gridcell"
|
|
457
|
+
tabindex="-1"
|
|
458
|
+
>
|
|
459
|
+
29
|
|
460
|
+
</button>
|
|
461
|
+
</td>
|
|
462
|
+
<td class="rdp-cell" role="presentation">
|
|
463
|
+
<button
|
|
464
|
+
name="day"
|
|
465
|
+
class="rdp-button_reset rdp-button rdp-day"
|
|
466
|
+
role="gridcell"
|
|
467
|
+
tabindex="-1"
|
|
468
|
+
>
|
|
469
|
+
30
|
|
470
|
+
</button>
|
|
471
|
+
</td>
|
|
472
|
+
<td class="rdp-cell" role="presentation">
|
|
473
|
+
<button
|
|
474
|
+
name="day"
|
|
475
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_outside"
|
|
476
|
+
role="gridcell"
|
|
477
|
+
tabindex="-1"
|
|
478
|
+
>
|
|
479
|
+
1
|
|
480
|
+
</button>
|
|
481
|
+
</td>
|
|
482
|
+
<td class="rdp-cell" role="presentation">
|
|
483
|
+
<button
|
|
484
|
+
name="day"
|
|
485
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_outside"
|
|
486
|
+
role="gridcell"
|
|
487
|
+
tabindex="-1"
|
|
488
|
+
>
|
|
489
|
+
2
|
|
490
|
+
</button>
|
|
491
|
+
</td>
|
|
492
|
+
<td class="rdp-cell" role="presentation">
|
|
493
|
+
<button
|
|
494
|
+
name="day"
|
|
495
|
+
class="rdp-button_reset rdp-button rdp-day rdp-day_outside"
|
|
496
|
+
role="gridcell"
|
|
497
|
+
tabindex="-1"
|
|
498
|
+
>
|
|
499
|
+
3
|
|
500
|
+
</button>
|
|
501
|
+
</td>
|
|
502
|
+
</tr>
|
|
503
|
+
</tbody>
|
|
504
|
+
</table>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
507
|
+
</div>
|
|
508
|
+
</div>
|
|
509
|
+
</div>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Class names are augmented with the following flags if true:
|
|
513
|
+
|
|
514
|
+
- \--is-valid
|
|
515
|
+
- \--is-invalid
|
|
516
|
+
- \--is-required
|
|
517
|
+
- \--is-optional
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
[See on Github](https://github.com/simplybusiness/mobius/tree/master/packages/mobius/src/components/DatePicker) | [Give feedback](https://simplybusiness.atlassian.net/CreateIssue.jspa?issuetype=10103&pid=10609) | [Get support](https://simplybusiness.slack.com/archives/C016CC0NDNE)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/react";
|
|
2
|
+
import { excludeControls } from "../../utils/excludeControls";
|
|
3
|
+
import { NewDatePicker, NewDatePickerProps } from "./NewDatePicker";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Forms/NewDatePicker",
|
|
7
|
+
component: NewDatePicker,
|
|
8
|
+
argTypes: {
|
|
9
|
+
validationState: {
|
|
10
|
+
options: ["valid", "invalid", "neither"],
|
|
11
|
+
control: { type: "radio" },
|
|
12
|
+
mapping: {
|
|
13
|
+
valid: "valid",
|
|
14
|
+
invalid: "invalid",
|
|
15
|
+
neither: "",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
...excludeControls(
|
|
19
|
+
"onChange",
|
|
20
|
+
"id",
|
|
21
|
+
"className",
|
|
22
|
+
"description",
|
|
23
|
+
"type",
|
|
24
|
+
"aria-label",
|
|
25
|
+
"aria-labelledby",
|
|
26
|
+
"labelElementType",
|
|
27
|
+
"inputElementType",
|
|
28
|
+
"isReadOnly",
|
|
29
|
+
"aria-describedby",
|
|
30
|
+
"aria-errormessage",
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
args: {
|
|
34
|
+
defaultValue: "",
|
|
35
|
+
errorMessage: "",
|
|
36
|
+
isDisabled: false,
|
|
37
|
+
isRequired: false,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Normal: Meta<typeof NewDatePicker> = {
|
|
42
|
+
render: (args: NewDatePickerProps) => <NewDatePicker {...args} />,
|
|
43
|
+
args: {
|
|
44
|
+
label: "Start date",
|
|
45
|
+
},
|
|
46
|
+
};
|