@hyphen/hyphen-components 6.15.1 → 7.0.0-beta.1
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/components/Calendar/Calendar.d.ts +5 -0
- package/dist/components/Calendar/Calendar.stories.d.ts +12 -0
- package/dist/css/index.css +2 -3
- package/dist/css/utilities.css +8 -0
- package/dist/hyphen-components.cjs.development.js +644 -809
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +645 -808
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/package.json +2 -3
- package/src/components/Calendar/Calendar.mdx +28 -0
- package/src/components/Calendar/Calendar.stories.tsx +217 -0
- package/src/components/Calendar/Calendar.tsx +117 -0
- package/src/components/Formik/Formik.stories.tsx +10 -21
- package/src/index.ts +1 -2
- package/src/styles/utilities.scss +8 -0
- package/dist/components/DateInput/DateInput.d.ts +0 -57
- package/dist/components/DateInput/DateInput.stories.d.ts +0 -11
- package/dist/components/DatePicker/DatePicker.d.ts +0 -86
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -13
- package/src/components/DateInput/DateInput.mdx +0 -61
- package/src/components/DateInput/DateInput.stories.tsx +0 -168
- package/src/components/DateInput/DateInput.test.tsx +0 -176
- package/src/components/DateInput/DateInput.tsx +0 -212
- package/src/components/DatePicker/DatePicker.mdx +0 -52
- package/src/components/DatePicker/DatePicker.module.scss +0 -603
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -199
- package/src/components/DatePicker/DatePicker.test.tsx +0 -26
- package/src/components/DatePicker/DatePicker.tsx +0 -138
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,11 @@ export * from './components/AspectRatio/AspectRatio';
|
|
|
3
3
|
export * from './components/Badge/Badge';
|
|
4
4
|
export * from './components/Box/Box';
|
|
5
5
|
export * from './components/Button/Button';
|
|
6
|
+
export * from './components/Calendar/Calendar';
|
|
6
7
|
export * from './components/Card/Card';
|
|
7
8
|
export * from './components/CheckboxInput/components/Checkbox';
|
|
8
9
|
export * from './components/CheckboxInput/CheckboxInput';
|
|
9
10
|
export * from './components/Collapsible/Collapsible';
|
|
10
|
-
export * from './components/DateInput/DateInput';
|
|
11
|
-
export * from './components/DatePicker/DatePicker';
|
|
12
11
|
export * from './components/Details/Details';
|
|
13
12
|
export * from './components/Details/DetailsSummary';
|
|
14
13
|
export * from './components/Drawer/Drawer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyphen/hyphen-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "@hyphen"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"classnames": "^2.5.1",
|
|
76
76
|
"date-fns": "^2.30.0",
|
|
77
77
|
"formik": "^2.4.6",
|
|
78
|
-
"react-
|
|
78
|
+
"react-day-picker": "^9.11.3",
|
|
79
79
|
"react-focus-lock": "^2.13.2",
|
|
80
80
|
"react-modal": "^3.16.3",
|
|
81
81
|
"react-remove-scroll": "^2.6.3",
|
|
@@ -100,7 +100,6 @@
|
|
|
100
100
|
"@tsconfig/vite-react": "^3.0.2",
|
|
101
101
|
"@types/node": "^22.9.0",
|
|
102
102
|
"@types/react": "^18.3.5",
|
|
103
|
-
"@types/react-datepicker": "^6.2.0",
|
|
104
103
|
"@types/react-dom": "^18.3.0",
|
|
105
104
|
"@types/react-modal": "^3.16.3",
|
|
106
105
|
"autoprefixer": "^10.4.20",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Canvas, Meta, ArgTypes } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as Stories from './Calendar.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Calendar
|
|
7
|
+
|
|
8
|
+
Calendar component for selecting dates and date ranges.
|
|
9
|
+
|
|
10
|
+
This component is extended from [React DayPicker](https://daypicker.dev/).
|
|
11
|
+
|
|
12
|
+
[API Reference](https://daypicker.dev/api)
|
|
13
|
+
|
|
14
|
+
## Basic Usage
|
|
15
|
+
|
|
16
|
+
<Canvas of={Stories.BasicUsage} sourceState="shown"/>
|
|
17
|
+
|
|
18
|
+
## Range Selection
|
|
19
|
+
|
|
20
|
+
<Canvas of={Stories.RangeSelection} sourceState="shown" />
|
|
21
|
+
|
|
22
|
+
## Month/Year Dropdown
|
|
23
|
+
|
|
24
|
+
<Canvas of={Stories.Dropdown} sourceState="shown" />
|
|
25
|
+
|
|
26
|
+
## Footer Content
|
|
27
|
+
|
|
28
|
+
<Canvas of={Stories.FooterContent} sourceState="shown" />
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import Calendar from './Calendar';
|
|
2
|
+
|
|
3
|
+
import type { Meta } from '@storybook/react-vite';
|
|
4
|
+
import React, { useState, ChangeEvent } from 'react';
|
|
5
|
+
import { type DateRange } from 'react-day-picker';
|
|
6
|
+
import { TextInput } from '../TextInput/TextInput';
|
|
7
|
+
import { format, isValid, parse } from 'date-fns';
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Calendar> = {
|
|
10
|
+
title: 'Components/Calendar',
|
|
11
|
+
component: Calendar,
|
|
12
|
+
parameters: {
|
|
13
|
+
controls: { hideNoControlsWarning: true },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
|
|
19
|
+
export const BasicUsage = () => {
|
|
20
|
+
const [date, setDate] = useState<Date | undefined>(new Date(2025, 11, 12));
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Calendar
|
|
24
|
+
mode="single"
|
|
25
|
+
selected={date}
|
|
26
|
+
defaultMonth={date}
|
|
27
|
+
onSelect={setDate}
|
|
28
|
+
disabled={{
|
|
29
|
+
before: new Date(2025, 11, 12),
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const RangeSelection = () => {
|
|
36
|
+
const [dateRange, setDateRange] = useState<DateRange | undefined>({
|
|
37
|
+
from: new Date(2025, 5, 21),
|
|
38
|
+
to: new Date(2025, 6, 15),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Calendar
|
|
43
|
+
mode="range"
|
|
44
|
+
defaultMonth={dateRange?.from}
|
|
45
|
+
selected={dateRange}
|
|
46
|
+
onSelect={setDateRange}
|
|
47
|
+
numberOfMonths={2}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const MultipleSelection = () => {
|
|
53
|
+
const [dates, setDates] = useState<Date[] | undefined>([
|
|
54
|
+
new Date(2025, 5, 21),
|
|
55
|
+
new Date(2025, 6, 15),
|
|
56
|
+
new Date(2025, 6, 16),
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Calendar
|
|
61
|
+
mode="multiple"
|
|
62
|
+
selected={dates}
|
|
63
|
+
onSelect={setDates}
|
|
64
|
+
defaultMonth={dates ? dates[0] : undefined}
|
|
65
|
+
numberOfMonths={2}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Dropdown = () => {
|
|
71
|
+
const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 16));
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Calendar
|
|
75
|
+
mode="single"
|
|
76
|
+
captionLayout="dropdown"
|
|
77
|
+
selected={date}
|
|
78
|
+
defaultMonth={date}
|
|
79
|
+
onSelect={setDate}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const FooterContent = () => {
|
|
85
|
+
const [date, setDate] = useState<Date | undefined>(new Date(2025, 5, 16));
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Calendar
|
|
89
|
+
mode="single"
|
|
90
|
+
selected={date}
|
|
91
|
+
defaultMonth={date}
|
|
92
|
+
onSelect={setDate}
|
|
93
|
+
footer={
|
|
94
|
+
date
|
|
95
|
+
? `You picked ${date.toLocaleDateString()}.`
|
|
96
|
+
: 'Please pick a date.'
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const DateInput = () => {
|
|
103
|
+
const [selectedDate, setSelectedDate] = useState<Date | undefined>(
|
|
104
|
+
new Date(2017, 4, 21)
|
|
105
|
+
);
|
|
106
|
+
const [inputValue, setInputValue] = useState('05/21/2017');
|
|
107
|
+
|
|
108
|
+
// Hold the month in state to control the calendar when the input changes
|
|
109
|
+
const [month, setMonth] = useState(new Date(2017, 4, 21));
|
|
110
|
+
|
|
111
|
+
// Update input when calendar changes
|
|
112
|
+
const handleCalendarSelect = (date: Date | undefined) => {
|
|
113
|
+
if (!date) {
|
|
114
|
+
setInputValue('');
|
|
115
|
+
setSelectedDate(undefined);
|
|
116
|
+
} else {
|
|
117
|
+
setSelectedDate(date);
|
|
118
|
+
setMonth(date);
|
|
119
|
+
setInputValue(format(date, 'MM/dd/yyyy'));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Update calendar when input changes
|
|
124
|
+
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
125
|
+
setInputValue(e.target.value); // Keep the input value in sync
|
|
126
|
+
|
|
127
|
+
const parsedDate = parse(e.target.value, 'MM/dd/yyyy', new Date());
|
|
128
|
+
|
|
129
|
+
if (isValid(parsedDate)) {
|
|
130
|
+
setSelectedDate(parsedDate);
|
|
131
|
+
setMonth(parsedDate);
|
|
132
|
+
} else {
|
|
133
|
+
setSelectedDate(undefined);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div>
|
|
139
|
+
<TextInput
|
|
140
|
+
id="date-input"
|
|
141
|
+
label="Date"
|
|
142
|
+
type="text"
|
|
143
|
+
value={inputValue}
|
|
144
|
+
onChange={handleInputChange}
|
|
145
|
+
/>
|
|
146
|
+
<div style={{ marginTop: 16 }}>
|
|
147
|
+
<Calendar
|
|
148
|
+
month={month}
|
|
149
|
+
onMonthChange={setMonth}
|
|
150
|
+
mode="single"
|
|
151
|
+
selected={selectedDate}
|
|
152
|
+
onSelect={handleCalendarSelect}
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const DateRangeInput = () => {
|
|
160
|
+
const [range, setRange] = useState<DateRange>({
|
|
161
|
+
from: undefined,
|
|
162
|
+
to: undefined,
|
|
163
|
+
});
|
|
164
|
+
const [inputValue, setInputValue] = useState('');
|
|
165
|
+
|
|
166
|
+
// Format range as string using date-fns
|
|
167
|
+
const formatRange = (from?: Date, to?: Date) => {
|
|
168
|
+
if (!from && !to) return '';
|
|
169
|
+
const fromStr = from && isValid(from) ? format(from, 'MM/dd/yyyy') : '';
|
|
170
|
+
const toStr = to && isValid(to) ? format(to, 'MM/dd/yyyy') : '';
|
|
171
|
+
return fromStr && toStr ? `${fromStr} - ${toStr}` : fromStr || toStr;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Parse string to range using date-fns
|
|
175
|
+
const parseRange = (value: string): DateRange => {
|
|
176
|
+
const [fromStr, toStr] = value.split('-').map((s) => s.trim());
|
|
177
|
+
const from = fromStr ? parse(fromStr, 'MM/dd/yyyy', new Date()) : undefined;
|
|
178
|
+
const to = toStr ? parse(toStr, 'MM/dd/yyyy', new Date()) : undefined;
|
|
179
|
+
return {
|
|
180
|
+
from: from && isValid(from) ? from : undefined,
|
|
181
|
+
to: to && isValid(to) ? to : undefined,
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Update input when calendar changes
|
|
186
|
+
const handleCalendarSelect = (selected: DateRange | undefined) => {
|
|
187
|
+
setRange(selected ?? { from: undefined, to: undefined });
|
|
188
|
+
setInputValue(formatRange(selected?.from, selected?.to));
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// Update calendar when input changes
|
|
192
|
+
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
193
|
+
const value = e.target.value;
|
|
194
|
+
setInputValue(value);
|
|
195
|
+
setRange(parseRange(value));
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<div style={{ maxWidth: 320 }}>
|
|
200
|
+
<TextInput
|
|
201
|
+
id="date-range-input"
|
|
202
|
+
label="Date Range"
|
|
203
|
+
type="text"
|
|
204
|
+
value={inputValue}
|
|
205
|
+
onChange={handleInputChange}
|
|
206
|
+
placeholder="MM/DD/YYYY - MM/DD/YYYY"
|
|
207
|
+
/>
|
|
208
|
+
<div style={{ marginTop: 16 }}>
|
|
209
|
+
<Calendar
|
|
210
|
+
mode="range"
|
|
211
|
+
selected={range}
|
|
212
|
+
onSelect={handleCalendarSelect}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { DayPicker, getDefaultClassNames } from 'react-day-picker';
|
|
4
|
+
import 'react-day-picker/style.css';
|
|
5
|
+
import { Icon } from '../Icon/Icon';
|
|
6
|
+
|
|
7
|
+
function Calendar({
|
|
8
|
+
captionLayout = 'label',
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DayPicker>) {
|
|
12
|
+
const defaultClassNames = getDefaultClassNames();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<DayPicker
|
|
16
|
+
className={className ? className : 'p-lg bw-sm br-sm'}
|
|
17
|
+
captionLayout={captionLayout}
|
|
18
|
+
style={
|
|
19
|
+
{
|
|
20
|
+
'--rdp-accent-color': 'var(--color-font-base)',
|
|
21
|
+
'--rdp-accent-background-color':
|
|
22
|
+
'var(--color-background-color-button-primary)',
|
|
23
|
+
'--rdp-day-height': 'var(--size-dimension-4xl)',
|
|
24
|
+
'--rdp-day-width': 'var(--size-dimension-4xl)',
|
|
25
|
+
'--rdp-day_button-height': 'var(--size-dimension-4xl)',
|
|
26
|
+
'--rdp-day_button-width': 'var(--size-dimension-4xl)',
|
|
27
|
+
'--rdp-day_button-border-radius': '0',
|
|
28
|
+
'--rdp-selected-border': '1px solid var(--color-font-base)',
|
|
29
|
+
'--rdp-today-color': 'var(--rdp-accent-color)',
|
|
30
|
+
'--rdp-nav-height': 'var(--size-dimension-4xl)',
|
|
31
|
+
'--rdp-range_middle-background-color':
|
|
32
|
+
'var(--color-background-tertiary)',
|
|
33
|
+
'--rdp-range_middle-color': 'var(--color-font-base)',
|
|
34
|
+
'--rdp-range_start-color': 'var(--color-font-inverse)',
|
|
35
|
+
'--rdp-range_end-color': 'var(--color-font-inverse)',
|
|
36
|
+
} as React.CSSProperties
|
|
37
|
+
}
|
|
38
|
+
classNames={{
|
|
39
|
+
root: classNames(
|
|
40
|
+
defaultClassNames.root,
|
|
41
|
+
'w-fit font-color-secondary font-size-sm'
|
|
42
|
+
),
|
|
43
|
+
months: classNames(
|
|
44
|
+
defaultClassNames.months,
|
|
45
|
+
'display-flex flex-direction-column flex-direction-row-tablet g-md position-relative'
|
|
46
|
+
),
|
|
47
|
+
nav: classNames(
|
|
48
|
+
defaultClassNames.nav,
|
|
49
|
+
'display-flex flex-direction-row w-100 g-md position-absolute h-4xl align-items-center justify-content-space-between'
|
|
50
|
+
),
|
|
51
|
+
button_previous: classNames(
|
|
52
|
+
'p-0 select-none background-color-transparent bw-0',
|
|
53
|
+
defaultClassNames.button_previous
|
|
54
|
+
),
|
|
55
|
+
button_next: classNames(
|
|
56
|
+
'p-0 select-none background-color-transparent bw-0',
|
|
57
|
+
defaultClassNames.button_next
|
|
58
|
+
),
|
|
59
|
+
month_caption: classNames(
|
|
60
|
+
'display-flex align-items-center justify-content-center font-size-sm h-4xl'
|
|
61
|
+
),
|
|
62
|
+
weekday: classNames(
|
|
63
|
+
defaultClassNames.weekday,
|
|
64
|
+
'font-weight-normal font-color-secondary'
|
|
65
|
+
),
|
|
66
|
+
today: 'font-weight-bold',
|
|
67
|
+
selected: classNames(
|
|
68
|
+
'font-color-inverse background-color-inverse hover:font-color-inverse'
|
|
69
|
+
),
|
|
70
|
+
month_grid: classNames(defaultClassNames.month_grid, 'm-top-lg'),
|
|
71
|
+
day: classNames(defaultClassNames.day, 'hover:font-color-base'),
|
|
72
|
+
day_button: classNames(defaultClassNames.day_button),
|
|
73
|
+
range_middle: classNames(defaultClassNames.range_middle),
|
|
74
|
+
table: classNames('w-100'),
|
|
75
|
+
dropdowns: classNames(defaultClassNames.dropdowns, 'h-100'),
|
|
76
|
+
caption_label: classNames(defaultClassNames.caption_label, 'g-2xs'),
|
|
77
|
+
}}
|
|
78
|
+
components={{
|
|
79
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
80
|
+
if (orientation === 'left') {
|
|
81
|
+
return (
|
|
82
|
+
<Icon
|
|
83
|
+
name="caret-left"
|
|
84
|
+
className={classNames(className)}
|
|
85
|
+
{...props}
|
|
86
|
+
size="md"
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (orientation === 'right') {
|
|
92
|
+
return (
|
|
93
|
+
<Icon
|
|
94
|
+
name="caret-right"
|
|
95
|
+
className={classNames(className)}
|
|
96
|
+
{...props}
|
|
97
|
+
size="md"
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Icon
|
|
104
|
+
name="caret-sm-down"
|
|
105
|
+
className={classNames(className)}
|
|
106
|
+
{...props}
|
|
107
|
+
size="md"
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
}}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default Calendar;
|
|
@@ -6,7 +6,6 @@ import { FormikSelectInput } from './FormikSelectInput/FormikSelectInput';
|
|
|
6
6
|
import { FormikSelectInputNative } from './FormikSelectInputNative/FormikSelectInputNative';
|
|
7
7
|
import { FormikRadioGroup } from './FormikRadioGroup/FormikRadioGroup';
|
|
8
8
|
import { FormikTextareaInput } from './FormikTextareaInput/FormikTextareaInput';
|
|
9
|
-
import { DateInput } from '../DateInput/DateInput';
|
|
10
9
|
import { FormikSwitch } from './FormikSwitch/FormikSwitch';
|
|
11
10
|
import { Button } from '../Button/Button';
|
|
12
11
|
import { Box } from '../Box/Box';
|
|
@@ -21,6 +20,7 @@ import { Tooltip, TooltipContent, TooltipProvider } from '../Tooltip/Tooltip';
|
|
|
21
20
|
import { TooltipTrigger } from '@radix-ui/react-tooltip';
|
|
22
21
|
import { FormikToggleGroupMulti } from './FormikToggleGroupMulti/FormikToggleGroupMulti';
|
|
23
22
|
import { Icon } from '../Icon/Icon';
|
|
23
|
+
import Calendar from '../Calendar/Calendar';
|
|
24
24
|
|
|
25
25
|
const meta = {
|
|
26
26
|
title: 'Patterns/Formik Form',
|
|
@@ -185,7 +185,7 @@ export const FormikForm = () =>
|
|
|
185
185
|
sizes: null,
|
|
186
186
|
timePicker: null,
|
|
187
187
|
timePickerNative: null,
|
|
188
|
-
dateInput:
|
|
188
|
+
dateInput: new Date(2017, 4, 21),
|
|
189
189
|
message: '',
|
|
190
190
|
country: '',
|
|
191
191
|
availability: '99',
|
|
@@ -194,7 +194,7 @@ export const FormikForm = () =>
|
|
|
194
194
|
validate={handleValidation}
|
|
195
195
|
onSubmit={handleSubmit}
|
|
196
196
|
>
|
|
197
|
-
{({ isSubmitting, values, setFieldValue,
|
|
197
|
+
{({ isSubmitting, values, setFieldValue, errors }) => (
|
|
198
198
|
<Form noValidate>
|
|
199
199
|
<Box gap="3xl">
|
|
200
200
|
<Field
|
|
@@ -371,25 +371,14 @@ export const FormikForm = () =>
|
|
|
371
371
|
</ToggleGroupItem>
|
|
372
372
|
))}
|
|
373
373
|
</FormikToggleGroupMulti>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
selected: values.dateInput as unknown as Date,
|
|
381
|
-
}}
|
|
382
|
-
textInputProps={{
|
|
383
|
-
label: 'Date Input',
|
|
384
|
-
name: 'dateInput',
|
|
385
|
-
id: 'dateInput',
|
|
386
|
-
error: errors.dateInput,
|
|
387
|
-
isRequired: true,
|
|
388
|
-
onClear: () => {
|
|
389
|
-
setFieldValue('dateInput', null);
|
|
390
|
-
},
|
|
391
|
-
onBlur: handleBlur,
|
|
374
|
+
<Calendar
|
|
375
|
+
mode="single"
|
|
376
|
+
required={true}
|
|
377
|
+
selected={values.dateInput}
|
|
378
|
+
onSelect={(date: Date | undefined) => {
|
|
379
|
+
setFieldValue('dateInput', date);
|
|
392
380
|
}}
|
|
381
|
+
month={values.dateInput}
|
|
393
382
|
/>
|
|
394
383
|
<Button type="submit" isLoading={isSubmitting}>
|
|
395
384
|
Submit
|
package/src/index.ts
CHANGED
|
@@ -3,12 +3,11 @@ export * from './components/AspectRatio/AspectRatio';
|
|
|
3
3
|
export * from './components/Badge/Badge';
|
|
4
4
|
export * from './components/Box/Box';
|
|
5
5
|
export * from './components/Button/Button';
|
|
6
|
+
export * from './components/Calendar/Calendar';
|
|
6
7
|
export * from './components/Card/Card';
|
|
7
8
|
export * from './components/CheckboxInput/components/Checkbox';
|
|
8
9
|
export * from './components/CheckboxInput/CheckboxInput';
|
|
9
10
|
export * from './components/Collapsible/Collapsible';
|
|
10
|
-
export * from './components/DateInput/DateInput';
|
|
11
|
-
export * from './components/DatePicker/DatePicker';
|
|
12
11
|
export * from './components/Details/Details';
|
|
13
12
|
export * from './components/Details/DetailsSummary';
|
|
14
13
|
export * from './components/Drawer/Drawer';
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { DatePickerProps } from '../DatePicker/DatePicker';
|
|
3
|
-
import { TextInputProps } from '../TextInput/TextInput';
|
|
4
|
-
export interface DateInputProps {
|
|
5
|
-
/**
|
|
6
|
-
* Props object for DatePicker component.
|
|
7
|
-
*/
|
|
8
|
-
datePickerProps: DatePickerProps;
|
|
9
|
-
/**
|
|
10
|
-
* Props object for TextInput component.
|
|
11
|
-
*/
|
|
12
|
-
textInputProps: Omit<TextInputProps, 'onChange'>;
|
|
13
|
-
/**
|
|
14
|
-
* Format for final date to be displayed.
|
|
15
|
-
* Relies on date-fns/format --> https://date-fns.org/v1.9.0/docs/format
|
|
16
|
-
*/
|
|
17
|
-
dateFormat?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Additional settings for formatting date.
|
|
20
|
-
*/
|
|
21
|
-
dateOptions?: {
|
|
22
|
-
/**
|
|
23
|
-
* The user's locale.
|
|
24
|
-
*/
|
|
25
|
-
locale?: globalThis.Locale | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Start of week.
|
|
28
|
-
*/
|
|
29
|
-
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Should determine which week is week 1 of a new year.
|
|
32
|
-
*/
|
|
33
|
-
firstWeekContainsDate?: number | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Whether to accept unicode tokens in format.
|
|
36
|
-
* See here --> https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
37
|
-
*/
|
|
38
|
-
useAdditionalWeekYearTokens?: boolean | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Whether to accept unicode tokens in format.
|
|
41
|
-
* See here --> https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
|
|
42
|
-
*/
|
|
43
|
-
useAdditionalDayOfYearTokens?: boolean | undefined;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Props to pass down to the Popover component.
|
|
47
|
-
*/
|
|
48
|
-
popoverProps?: {
|
|
49
|
-
side: 'top' | 'bottom' | 'left' | 'right';
|
|
50
|
-
align: 'start' | 'center' | 'end';
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Additional props to be spread to the `TextInput` element.
|
|
54
|
-
*/
|
|
55
|
-
[x: string]: any;
|
|
56
|
-
}
|
|
57
|
-
export declare const DateInput: FC<DateInputProps>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta } from '@storybook/react-vite';
|
|
3
|
-
import { DateInput } from './DateInput';
|
|
4
|
-
declare const meta: Meta<typeof DateInput>;
|
|
5
|
-
export default meta;
|
|
6
|
-
export declare const Basic: () => React.JSX.Element;
|
|
7
|
-
export declare const Default: () => React.JSX.Element;
|
|
8
|
-
export declare const DateRange: () => React.JSX.Element;
|
|
9
|
-
export declare const WithMinAndMaxDates: () => React.JSX.Element;
|
|
10
|
-
export declare const CustomDateFormat: () => React.JSX.Element;
|
|
11
|
-
export declare const InputBlurEvent: () => React.JSX.Element;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React, { FC, SyntheticEvent, ReactNode } from 'react';
|
|
2
|
-
import { ReactDatePickerProps } from 'react-datepicker';
|
|
3
|
-
export interface DatePickerProps extends ReactDatePickerProps<any, any> {
|
|
4
|
-
/**
|
|
5
|
-
* React children (to be rendered below the calendar dates).
|
|
6
|
-
*/
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* Custom classname to be applied to the DatePicker container.
|
|
10
|
-
*/
|
|
11
|
-
className?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Callback that fires when a date is changed/selected.
|
|
14
|
-
*/
|
|
15
|
-
onChange: (date: Date | [Date, Date] | null, event?: React.SyntheticEvent<any> | undefined) => void;
|
|
16
|
-
/**
|
|
17
|
-
* Callback that fires when a date is clicked.
|
|
18
|
-
*/
|
|
19
|
-
onSelect?: ((date: Date, event: SyntheticEvent<any, Event> | undefined) => void) | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Custom Class to be applied to a single day element based on a date.
|
|
22
|
-
*/
|
|
23
|
-
dayClassName?: ((date: Date) => string | null) | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Custom Class to be applied to a single week element based on a date.
|
|
26
|
-
*/
|
|
27
|
-
weekClassName?: ((date: Date) => string | null) | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Custom Class to be applied to a single month element based on a date.
|
|
30
|
-
*/
|
|
31
|
-
monthClassName?: ((date: Date) => string | null) | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Custom Class to be applied to a specific time.
|
|
34
|
-
*/
|
|
35
|
-
timeClassName?: ((date: Date) => string | null) | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Custom format for weekday.
|
|
38
|
-
*/
|
|
39
|
-
formatWeekDay?: (formattedDate: string) => string;
|
|
40
|
-
/**
|
|
41
|
-
* Last allowable/shown date
|
|
42
|
-
*/
|
|
43
|
-
maxDate?: Date | null;
|
|
44
|
-
/**
|
|
45
|
-
* First allowable/shown date
|
|
46
|
-
*/
|
|
47
|
-
minDate?: Date | null;
|
|
48
|
-
/**
|
|
49
|
-
* Months to be shown at one time
|
|
50
|
-
*/
|
|
51
|
-
monthsShown?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Date that the calendar will open to by default.
|
|
54
|
-
*/
|
|
55
|
-
openToDate?: Date;
|
|
56
|
-
/**
|
|
57
|
-
* Currently selected date.
|
|
58
|
-
*/
|
|
59
|
-
selected?: Date | null;
|
|
60
|
-
/**
|
|
61
|
-
* Whether or not the picker will return a range of dates.
|
|
62
|
-
*/
|
|
63
|
-
selectsRange?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Start date in a range
|
|
66
|
-
*/
|
|
67
|
-
startDate?: Date | null;
|
|
68
|
-
/**
|
|
69
|
-
* Show month picker in two columns
|
|
70
|
-
*/
|
|
71
|
-
showTwoColumnMonthYearPicker?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* See full month name in the month picker
|
|
74
|
-
*/
|
|
75
|
-
showFullMonthYearPicker?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Use the month picker
|
|
78
|
-
*/
|
|
79
|
-
showMonthYearPicker?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Additional props to be spread to rendered element
|
|
82
|
-
*/
|
|
83
|
-
[x: string]: any;
|
|
84
|
-
}
|
|
85
|
-
export declare const DatePicker: FC<DatePickerProps>;
|
|
86
|
-
export default DatePicker;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DatePicker } from './DatePicker';
|
|
3
|
-
import type { Meta } from '@storybook/react-vite';
|
|
4
|
-
declare const meta: Meta<typeof DatePicker>;
|
|
5
|
-
export default meta;
|
|
6
|
-
export declare const BasicExample: () => React.JSX.Element;
|
|
7
|
-
export declare const DateRange: () => React.JSX.Element;
|
|
8
|
-
export declare const MinAndMaxDates: () => React.JSX.Element;
|
|
9
|
-
export declare const MonthPicker: () => React.JSX.Element;
|
|
10
|
-
export declare const ShowMultipleMonths: () => React.JSX.Element;
|
|
11
|
-
export declare const WithTimePicker: () => React.JSX.Element;
|
|
12
|
-
export declare const OpenByDefaultOnASpecificDate: () => React.JSX.Element;
|
|
13
|
-
export declare const WithChildren: () => React.JSX.Element;
|