@primer/components 0.0.0-20219293614 → 0.0.0-2021931194230
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 +1 -7
- package/dist/browser.esm.js +439 -436
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +443 -440
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Item.d.ts +0 -6
- package/lib/ActionList/Item.js +1 -5
- package/lib/ActionMenu.js +2 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib/Autocomplete/Autocomplete.d.ts +13 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +13 -11
- package/lib/Button/Button.d.ts +11 -11
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +29 -29
- package/lib/Button/ButtonDanger.d.ts +11 -11
- package/lib/Button/ButtonInvisible.d.ts +11 -11
- package/lib/Button/ButtonOutline.d.ts +11 -11
- package/lib/Button/ButtonPrimary.d.ts +11 -11
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +33 -33
- package/lib/DatePicker/DatePicker.d.ts +48 -0
- package/lib/DatePicker/DatePicker.js +106 -0
- package/lib/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib/DatePicker/DatePickerAnchor.js +223 -0
- package/lib/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib/DatePicker/DatePickerOverlay.js +48 -0
- package/lib/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib/DatePicker/DatePickerPanel.js +143 -0
- package/lib/DatePicker/Day.d.ts +14 -0
- package/lib/DatePicker/Day.js +192 -0
- package/lib/DatePicker/Month.d.ts +9 -0
- package/lib/DatePicker/Month.js +122 -0
- package/lib/DatePicker/dateParser.d.ts +11 -0
- package/lib/DatePicker/dateParser.js +192 -0
- package/lib/DatePicker/index.d.ts +2 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/useDatePicker.d.ts +89 -0
- package/lib/DatePicker/useDatePicker.js +439 -0
- package/lib/Dialog/Dialog.d.ts +4 -4
- package/lib/Dialog/Dialog.js +22 -12
- package/lib/Dialog.d.ts +35 -35
- package/lib/Dropdown.d.ts +165 -85
- package/lib/Dropdown.js +5 -6
- package/lib/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib/FilterList.d.ts +26 -26
- package/lib/Label.d.ts +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.d.ts +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +153 -151
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +13 -11
- package/lib/Timeline.d.ts +33 -33
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/_TextInputWrapper.d.ts +1 -1
- package/lib/constants.js +1 -3
- package/lib/hooks/useDebounce.d.ts +2 -0
- package/lib/hooks/useDebounce.js +24 -0
- package/lib/hooks/useResizeObserver.d.ts +1 -1
- package/lib/hooks/useResizeObserver.js +1 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -8
- package/lib/theme-preval.js +2 -2
- package/lib/utils/testing.d.ts +1 -1
- package/lib-esm/ActionList/Item.d.ts +0 -6
- package/lib-esm/ActionList/Item.js +1 -5
- package/lib-esm/ActionMenu.js +2 -2
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +4 -2
- package/lib-esm/Autocomplete/Autocomplete.d.ts +13 -11
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +13 -11
- package/lib-esm/Button/Button.d.ts +11 -11
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +29 -29
- package/lib-esm/Button/ButtonDanger.d.ts +11 -11
- package/lib-esm/Button/ButtonInvisible.d.ts +11 -11
- package/lib-esm/Button/ButtonOutline.d.ts +11 -11
- package/lib-esm/Button/ButtonPrimary.d.ts +11 -11
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +33 -33
- package/lib-esm/DatePicker/DatePicker.d.ts +48 -0
- package/lib-esm/DatePicker/DatePicker.js +89 -0
- package/lib-esm/DatePicker/DatePickerAnchor.d.ts +5 -0
- package/lib-esm/DatePicker/DatePickerAnchor.js +196 -0
- package/lib-esm/DatePicker/DatePickerOverlay.d.ts +3 -0
- package/lib-esm/DatePicker/DatePickerOverlay.js +29 -0
- package/lib-esm/DatePicker/DatePickerPanel.d.ts +2 -0
- package/lib-esm/DatePicker/DatePickerPanel.js +116 -0
- package/lib-esm/DatePicker/Day.d.ts +14 -0
- package/lib-esm/DatePicker/Day.js +169 -0
- package/lib-esm/DatePicker/Month.d.ts +9 -0
- package/lib-esm/DatePicker/Month.js +98 -0
- package/lib-esm/DatePicker/dateParser.d.ts +11 -0
- package/lib-esm/DatePicker/dateParser.js +178 -0
- package/lib-esm/DatePicker/index.d.ts +2 -0
- package/lib-esm/DatePicker/index.js +1 -0
- package/lib-esm/DatePicker/useDatePicker.d.ts +89 -0
- package/lib-esm/DatePicker/useDatePicker.js +408 -0
- package/lib-esm/Dialog/Dialog.d.ts +4 -4
- package/lib-esm/Dialog/Dialog.js +21 -12
- package/lib-esm/Dialog.d.ts +35 -35
- package/lib-esm/Dropdown.d.ts +165 -85
- package/lib-esm/Dropdown.js +3 -4
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +30 -30
- package/lib-esm/FilterList.d.ts +26 -26
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +153 -151
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +13 -11
- package/lib-esm/Timeline.d.ts +33 -33
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/_TextInputWrapper.d.ts +1 -1
- package/lib-esm/constants.js +1 -3
- package/lib-esm/hooks/useDebounce.d.ts +2 -0
- package/lib-esm/hooks/useDebounce.js +16 -0
- package/lib-esm/hooks/useResizeObserver.d.ts +1 -1
- package/lib-esm/hooks/useResizeObserver.js +1 -1
- package/lib-esm/index.d.ts +0 -2
- package/lib-esm/index.js +0 -1
- package/lib-esm/theme-preval.js +2 -2
- package/lib-esm/utils/testing.d.ts +1 -1
- package/package.json +14 -13
- package/lib/NewButton/button.d.ts +0 -579
- package/lib/NewButton/button.js +0 -298
- package/lib/NewButton/counter.d.ts +0 -6
- package/lib/NewButton/counter.js +0 -33
- package/lib/NewButton/index.d.ts +0 -4
- package/lib/NewButton/index.js +0 -21
- package/lib-esm/NewButton/button.d.ts +0 -579
- package/lib-esm/NewButton/button.js +0 -274
- package/lib-esm/NewButton/counter.d.ts +0 -6
- package/lib-esm/NewButton/counter.js +0 -21
- package/lib-esm/NewButton/index.d.ts +0 -4
- package/lib-esm/NewButton/index.js +0 -3
@@ -0,0 +1,98 @@
|
|
1
|
+
import { format, isEqual, lastDayOfMonth, getDaysInMonth, eachDayOfInterval, startOfWeek, endOfWeek } from 'date-fns';
|
2
|
+
import React, { useMemo, useState } from 'react';
|
3
|
+
import styled from 'styled-components';
|
4
|
+
import Box from '../Box';
|
5
|
+
import Text from '../Text';
|
6
|
+
import { get } from '../constants';
|
7
|
+
import { BlankDay, Day } from './Day';
|
8
|
+
import useDatePicker from './useDatePicker';
|
9
|
+
const weekdayEnum = {
|
10
|
+
Sunday: 0,
|
11
|
+
Monday: 1,
|
12
|
+
Tuesday: 2,
|
13
|
+
Wednesday: 3,
|
14
|
+
Thursday: 4,
|
15
|
+
Friday: 5,
|
16
|
+
Saturday: 6
|
17
|
+
};
|
18
|
+
const MonthComponent = styled(Box).withConfig({
|
19
|
+
displayName: "Month__MonthComponent",
|
20
|
+
componentId: "l6j7o0-0"
|
21
|
+
})(["display:grid;grid-auto-rows:min-content;grid-template-columns:repeat(1fr,7);grid-template-rows:1fr;gap:0px 0px;grid-template-areas:'month month month month month month month' 'sunday monday tuesday wednesday thursday friday saturday';justify-items:stretch;align-items:stretch;"]);
|
22
|
+
const MonthTitle = styled(Text).withConfig({
|
23
|
+
displayName: "Month__MonthTitle",
|
24
|
+
componentId: "l6j7o0-1"
|
25
|
+
})(["font-size:", ";font-weight:", ";grid-area:month;justify-self:center;"], get('fontSizes.1'), get('fontWeights.bold'));
|
26
|
+
const WeekdayHeader = styled(Text).withConfig({
|
27
|
+
displayName: "Month__WeekdayHeader",
|
28
|
+
componentId: "l6j7o0-2"
|
29
|
+
})(["color:", ";font-family:", ";font-size:", ";justify-self:center;padding:", " 0 ", ";"], get('colors.fg.subtle'), get('fonts.mono'), get('fontSizes.0'), get('space.3'), get('space.2'));
|
30
|
+
export const Month = ({
|
31
|
+
month,
|
32
|
+
year
|
33
|
+
}) => {
|
34
|
+
const {
|
35
|
+
configuration
|
36
|
+
} = useDatePicker();
|
37
|
+
const [selectedDay, setSelectedDay] = useState(null);
|
38
|
+
const getTitle = useMemo(() => `${format(new Date(year, month), 'MMMM yyyy')}`, [month, year]);
|
39
|
+
const weekdayHeaders = useMemo(() => {
|
40
|
+
var _configuration$weekSt;
|
41
|
+
|
42
|
+
const now = new Date(year, month);
|
43
|
+
const weekOptions = {
|
44
|
+
weekStartsOn: weekdayEnum[(_configuration$weekSt = configuration.weekStartsOn) !== null && _configuration$weekSt !== void 0 ? _configuration$weekSt : 'Sunday']
|
45
|
+
};
|
46
|
+
return eachDayOfInterval({
|
47
|
+
start: startOfWeek(now, weekOptions),
|
48
|
+
end: endOfWeek(now, weekOptions)
|
49
|
+
}).map(d => /*#__PURE__*/React.createElement(WeekdayHeader, {
|
50
|
+
key: `weekday-${d}-header`
|
51
|
+
}, format(d, 'EEEEEE')));
|
52
|
+
}, [configuration.weekStartsOn, month, year]);
|
53
|
+
|
54
|
+
const dayAction = date => {
|
55
|
+
setSelectedDay(date);
|
56
|
+
};
|
57
|
+
|
58
|
+
const dayComponents = useMemo(() => {
|
59
|
+
var _configuration$weekSt2, _configuration$weekSt3;
|
60
|
+
|
61
|
+
const components = [];
|
62
|
+
const firstDay = new Date(year, month, 1);
|
63
|
+
const preBlanks = (firstDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt2 = configuration.weekStartsOn) !== null && _configuration$weekSt2 !== void 0 ? _configuration$weekSt2 : 'Sunday'])) % 7;
|
64
|
+
|
65
|
+
for (let i = 0; i < preBlanks; i++) {
|
66
|
+
components.push( /*#__PURE__*/React.createElement(BlankDay, {
|
67
|
+
key: `month-pre-blank-${i}`
|
68
|
+
}));
|
69
|
+
}
|
70
|
+
|
71
|
+
for (let i = 1; i <= getDaysInMonth(firstDay); i++) {
|
72
|
+
const date = new Date(year, month, i);
|
73
|
+
components.push( /*#__PURE__*/React.createElement(Day, {
|
74
|
+
key: `day-component-${date.toString()}`,
|
75
|
+
date: date,
|
76
|
+
selected: selectedDay ? isEqual(date, selectedDay) : false,
|
77
|
+
onAction: dayAction
|
78
|
+
}));
|
79
|
+
}
|
80
|
+
|
81
|
+
const lastDay = lastDayOfMonth(firstDay);
|
82
|
+
const postBlanks = (lastDay.getDay() + (7 - weekdayEnum[(_configuration$weekSt3 = configuration.weekStartsOn) !== null && _configuration$weekSt3 !== void 0 ? _configuration$weekSt3 : 'Sunday'])) % 7;
|
83
|
+
|
84
|
+
for (let i = 6; i > postBlanks; i--) {
|
85
|
+
components.push( /*#__PURE__*/React.createElement(BlankDay, {
|
86
|
+
key: `month-post-blank-${i}`
|
87
|
+
}));
|
88
|
+
}
|
89
|
+
|
90
|
+
return components;
|
91
|
+
}, [configuration.weekStartsOn, month, selectedDay, year]);
|
92
|
+
return /*#__PURE__*/React.createElement(MonthComponent, {
|
93
|
+
role: "grid"
|
94
|
+
}, /*#__PURE__*/React.createElement(MonthTitle, {
|
95
|
+
"aria-live": "polite"
|
96
|
+
}, getTitle), weekdayHeaders, dayComponents);
|
97
|
+
};
|
98
|
+
Month.displayName = "Month";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { AnchorVariant, Selection, SelectionVariant } from './useDatePicker';
|
2
|
+
export declare const parseDate: (dateString: string, variant?: SelectionVariant) => Selection;
|
3
|
+
declare type FormatDateOptions = {
|
4
|
+
selection?: Selection;
|
5
|
+
anchorVariant?: AnchorVariant;
|
6
|
+
dateFormat?: string;
|
7
|
+
placeholder?: string;
|
8
|
+
variant?: SelectionVariant;
|
9
|
+
};
|
10
|
+
export declare const formatDate: ({ selection, anchorVariant, dateFormat, placeholder, variant }: FormatDateOptions) => string;
|
11
|
+
export {};
|
@@ -0,0 +1,178 @@
|
|
1
|
+
import { eachDayOfInterval, format, isBefore } from 'date-fns';
|
2
|
+
import { isRangeSelection } from './useDatePicker';
|
3
|
+
const INVALID_DATE = 'Invalid Date';
|
4
|
+
const DATE_REGEX = new RegExp(/(\d{1,2}[-/.]\d{1,2}[-/.](?:\d{2}){1,2})(?:\s?-\s?)?(\d{1,2}[-/.]\d{1,2}[-/.](?:\d{2}){1,2})?/g);
|
5
|
+
|
6
|
+
const sanitizeDate = dateString => {
|
7
|
+
return dateString.replaceAll('.', '/').replaceAll('-', '/');
|
8
|
+
};
|
9
|
+
|
10
|
+
export const parseDate = (dateString, variant = 'single') => {
|
11
|
+
const dateItems = dateString.matchAll(DATE_REGEX);
|
12
|
+
const parsedDateItems = []; // Determine Format
|
13
|
+
|
14
|
+
for (const d of dateItems) {
|
15
|
+
const tempD1 = new Date(sanitizeDate(d[1]));
|
16
|
+
const tempD2 = d[2] ? new Date(sanitizeDate(d[2])) : null;
|
17
|
+
|
18
|
+
if (tempD2) {
|
19
|
+
// Range
|
20
|
+
if (tempD1.toString() !== INVALID_DATE && tempD2.toString() !== INVALID_DATE) {
|
21
|
+
parsedDateItems.push(isBefore(tempD1, tempD2) ? {
|
22
|
+
from: tempD1,
|
23
|
+
to: tempD2
|
24
|
+
} : {
|
25
|
+
from: tempD2,
|
26
|
+
to: tempD1
|
27
|
+
});
|
28
|
+
} else if (tempD1.toString() !== INVALID_DATE) {
|
29
|
+
parsedDateItems.push(tempD1);
|
30
|
+
} else if (tempD2.toString() !== INVALID_DATE) {
|
31
|
+
parsedDateItems.push(tempD2);
|
32
|
+
}
|
33
|
+
} else {
|
34
|
+
if (tempD1.toString() !== INVALID_DATE) {
|
35
|
+
parsedDateItems.push(tempD1);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
if (parsedDateItems.length === 0) {
|
41
|
+
// No Valid Dates
|
42
|
+
return null;
|
43
|
+
} // Cast Format based on variant
|
44
|
+
|
45
|
+
|
46
|
+
switch (variant) {
|
47
|
+
case 'single':
|
48
|
+
{
|
49
|
+
return parsedDateItems[0];
|
50
|
+
}
|
51
|
+
|
52
|
+
case 'multi':
|
53
|
+
{
|
54
|
+
const expandedParsedItems = [];
|
55
|
+
|
56
|
+
for (const item of parsedDateItems) {
|
57
|
+
if (isRangeSelection(item)) {
|
58
|
+
if (item.to) {
|
59
|
+
eachDayOfInterval({
|
60
|
+
start: item.from,
|
61
|
+
end: item.to
|
62
|
+
}).map(d => expandedParsedItems.push(d));
|
63
|
+
} else {
|
64
|
+
expandedParsedItems.push(item.from);
|
65
|
+
}
|
66
|
+
} else {
|
67
|
+
if (item) {
|
68
|
+
if (Array.isArray(item)) {
|
69
|
+
item.map(d => expandedParsedItems.push(d));
|
70
|
+
} else {
|
71
|
+
expandedParsedItems.push(item);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
return expandedParsedItems;
|
78
|
+
}
|
79
|
+
|
80
|
+
case 'range':
|
81
|
+
{
|
82
|
+
return parsedDateItems.filter(d => isRangeSelection(d))[0];
|
83
|
+
}
|
84
|
+
|
85
|
+
default:
|
86
|
+
{
|
87
|
+
return parsedDateItems[0];
|
88
|
+
}
|
89
|
+
}
|
90
|
+
};
|
91
|
+
export const formatDate = ({
|
92
|
+
selection,
|
93
|
+
anchorVariant = 'button',
|
94
|
+
dateFormat = 'short',
|
95
|
+
placeholder = 'Select a Date',
|
96
|
+
variant = 'single'
|
97
|
+
}) => {
|
98
|
+
if (!selection) {
|
99
|
+
if (anchorVariant === 'input') return '';
|
100
|
+
return placeholder;
|
101
|
+
}
|
102
|
+
|
103
|
+
let template = 'MMM d';
|
104
|
+
|
105
|
+
if (anchorVariant !== 'input' && dateFormat) {
|
106
|
+
switch (dateFormat) {
|
107
|
+
case 'short':
|
108
|
+
template = 'MMM d';
|
109
|
+
break;
|
110
|
+
|
111
|
+
case 'long':
|
112
|
+
template = 'MMM d, yyyy';
|
113
|
+
break;
|
114
|
+
|
115
|
+
default:
|
116
|
+
template = dateFormat;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
} else {
|
120
|
+
template = 'MM/dd/yyyy';
|
121
|
+
}
|
122
|
+
|
123
|
+
switch (variant) {
|
124
|
+
case 'single':
|
125
|
+
{
|
126
|
+
if (selection instanceof Date) {
|
127
|
+
return format(selection, template);
|
128
|
+
} else if (Array.isArray(selection)) {
|
129
|
+
return format(selection[0], template);
|
130
|
+
} else if (isRangeSelection(selection)) {
|
131
|
+
return format(selection.from, template);
|
132
|
+
} else {
|
133
|
+
return 'Invalid Selection';
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
case 'multi':
|
138
|
+
{
|
139
|
+
if (Array.isArray(selection)) {
|
140
|
+
if (selection.length > 3 && anchorVariant !== 'input') return `${selection.length} Selected`;
|
141
|
+
const formatted = selection.map(d => format(d, template)).join(', ');
|
142
|
+
return formatted;
|
143
|
+
} else if (selection instanceof Date) {
|
144
|
+
return [selection].map(d => format(d, template)).join(', ');
|
145
|
+
} else if (isRangeSelection(selection)) {
|
146
|
+
return [selection.to, selection.from].map(d => d ? format(d, template) : '').join(', ');
|
147
|
+
} else {
|
148
|
+
return 'Invalid Selection';
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
case 'range':
|
153
|
+
{
|
154
|
+
if (isRangeSelection(selection)) {
|
155
|
+
return Object.entries(selection).map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
156
|
+
} else if (selection instanceof Date) {
|
157
|
+
return Object.entries({
|
158
|
+
from: selection,
|
159
|
+
to: null
|
160
|
+
}).map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
161
|
+
} else if (Array.isArray(selection)) {
|
162
|
+
return Object.entries({
|
163
|
+
from: selection[0],
|
164
|
+
to: selection[1]
|
165
|
+
}) // to date can still be null
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
167
|
+
.map(([_, date]) => date ? format(date, template) : '').join(' - ');
|
168
|
+
} else {
|
169
|
+
return 'Invalid Selection';
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
default:
|
174
|
+
{
|
175
|
+
return 'Invalid Configuration';
|
176
|
+
}
|
177
|
+
}
|
178
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { DatePicker } from './DatePicker';
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
export declare type AnchorVariant = 'input' | 'button' | 'icon-only';
|
3
|
+
export declare type DateFormat = 'short' | 'long' | string;
|
4
|
+
export declare type SelectionVariant = 'single' | 'multi' | 'range';
|
5
|
+
export interface DatePickerConfiguration {
|
6
|
+
anchorVariant?: AnchorVariant;
|
7
|
+
blockedDates?: Array<Date>;
|
8
|
+
confirmation?: boolean;
|
9
|
+
confirmUnsavedClose?: boolean;
|
10
|
+
dateFormat?: DateFormat;
|
11
|
+
disableWeekends?: boolean;
|
12
|
+
iconPlacement?: 'start' | 'end' | 'none';
|
13
|
+
maxDate?: Date | null;
|
14
|
+
maxSelections?: number;
|
15
|
+
maxRangeSize?: number;
|
16
|
+
minDate?: Date | null;
|
17
|
+
placeholder?: string;
|
18
|
+
rangeIncrement?: number;
|
19
|
+
showInputPrompt?: boolean;
|
20
|
+
variant?: SelectionVariant;
|
21
|
+
view?: '1-month' | '2-month';
|
22
|
+
weekStartsOn?: 'Sunday' | 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday';
|
23
|
+
}
|
24
|
+
export declare type RangeSelection = {
|
25
|
+
from: Date;
|
26
|
+
to: Date | null;
|
27
|
+
};
|
28
|
+
export declare type StringRangeSelection = {
|
29
|
+
from: string;
|
30
|
+
to: string;
|
31
|
+
};
|
32
|
+
export interface DatePickerContext {
|
33
|
+
disabled?: boolean;
|
34
|
+
configuration: DatePickerConfiguration;
|
35
|
+
currentViewingDate: Date;
|
36
|
+
goToMonth: (date: Date) => void;
|
37
|
+
hoverRange?: RangeSelection | null;
|
38
|
+
selection?: Selection;
|
39
|
+
softSelection?: Partial<RangeSelection> | null;
|
40
|
+
selectionActive?: boolean;
|
41
|
+
formattedDate: string;
|
42
|
+
nextMonth: () => void;
|
43
|
+
onClose: () => void;
|
44
|
+
onDateInput: (updatedSelection: Selection) => void;
|
45
|
+
onDayFocus: (date: Date) => void;
|
46
|
+
onSelection: (date: Date) => void;
|
47
|
+
previousMonth: () => void;
|
48
|
+
revertValue: () => void;
|
49
|
+
saveValue: (selection?: Selection) => void;
|
50
|
+
}
|
51
|
+
export declare type Selection = Date | Array<Date> | RangeSelection | null;
|
52
|
+
export declare type StringSelection = string | Array<string> | {
|
53
|
+
to: string;
|
54
|
+
from: string;
|
55
|
+
} | null;
|
56
|
+
export declare type DaySelection = boolean | 'start' | 'middle' | 'end';
|
57
|
+
declare const useDatePicker: (date?: Date | undefined) => {
|
58
|
+
blocked: boolean | undefined;
|
59
|
+
disabled: boolean;
|
60
|
+
selected: DaySelection;
|
61
|
+
today: boolean;
|
62
|
+
configuration: DatePickerConfiguration;
|
63
|
+
currentViewingDate: Date;
|
64
|
+
goToMonth: (date: Date) => void;
|
65
|
+
hoverRange?: RangeSelection | null | undefined;
|
66
|
+
selection?: Selection | undefined;
|
67
|
+
softSelection?: Partial<RangeSelection> | null | undefined;
|
68
|
+
selectionActive?: boolean | undefined;
|
69
|
+
formattedDate: string;
|
70
|
+
nextMonth: () => void;
|
71
|
+
onClose: () => void;
|
72
|
+
onDateInput: (updatedSelection: Selection) => void;
|
73
|
+
onDayFocus: (date: Date) => void;
|
74
|
+
onSelection: (date: Date) => void;
|
75
|
+
previousMonth: () => void;
|
76
|
+
revertValue: () => void;
|
77
|
+
saveValue: (selection?: Selection | undefined) => void;
|
78
|
+
};
|
79
|
+
export default useDatePicker;
|
80
|
+
export interface DatePickerProviderProps {
|
81
|
+
closePicker?: () => void;
|
82
|
+
configuration?: DatePickerConfiguration;
|
83
|
+
value?: Selection | StringSelection;
|
84
|
+
}
|
85
|
+
export declare function isSingleSelection(selection: Selection): selection is Date;
|
86
|
+
export declare function isMultiSelection(selection: Selection | StringSelection): selection is Array<Date> | Array<string>;
|
87
|
+
export declare function isRangeSelection(selection: Selection | StringSelection): selection is RangeSelection | StringRangeSelection;
|
88
|
+
export declare function isStringRangeSelection(selection: StringSelection): selection is StringRangeSelection;
|
89
|
+
export declare const DatePickerProvider: React.FC<DatePickerProviderProps>;
|