@zendeskgarden/react-datepickers 9.0.0-next.1 → 9.0.0-next.3
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/README.md +5 -5
- package/dist/index.cjs.js +169 -200
- package/dist/index.esm.js +169 -200
- package/dist/typings/elements/{Datepicker/Datepicker.d.ts → DatePicker/DatePicker.d.ts} +2 -2
- package/dist/typings/elements/DatePicker/components/Input.d.ts +16 -0
- package/dist/typings/elements/{Datepicker/utils/datepicker-reducer.d.ts → DatePicker/utils/date-picker-reducer.d.ts} +6 -6
- package/dist/typings/elements/DatePicker/utils/useDatePickerContext.d.ts +18 -0
- package/dist/typings/elements/{DatepickerRange/DatepickerRange.d.ts → DatePickerRange/DatePickerRange.d.ts} +3 -3
- package/dist/typings/elements/{DatepickerRange/utils/datepicker-range-reducer.d.ts → DatePickerRange/utils/date-picker-range-reducer.d.ts} +6 -6
- package/dist/typings/elements/{DatepickerRange/utils/useDatepickerRangeContext.d.ts → DatePickerRange/utils/useDatePickerRangeContext.d.ts} +7 -7
- package/dist/typings/index.d.ts +3 -5
- package/dist/typings/styled/{StyledDatepicker.d.ts → StyledDatePicker.d.ts} +3 -3
- package/dist/typings/styled/StyledMenuWrapper.d.ts +2 -2
- package/dist/typings/styled/index.d.ts +1 -1
- package/dist/typings/types/index.d.ts +5 -14
- package/dist/typings/utils/calendar-utils.d.ts +2 -2
- package/package.json +5 -4
- package/dist/typings/elements/Datepicker/utils/garden-placements.d.ts +0 -21
- package/dist/typings/elements/Datepicker/utils/useDatepickerContext.d.ts +0 -18
- /package/dist/typings/elements/{Datepicker → DatePicker}/components/Calendar.d.ts +0 -0
- /package/dist/typings/elements/{Datepicker → DatePicker}/components/MonthSelector.d.ts +0 -0
- /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Calendar.d.ts +0 -0
- /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/End.d.ts +0 -0
- /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Month.d.ts +0 -0
- /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Start.d.ts +0 -0
package/README.md
CHANGED
|
@@ -14,16 +14,16 @@ npm install react react-dom styled-components @zendeskgarden/react-theming
|
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
-
The `<
|
|
17
|
+
The `<DatePicker>` component allows users to select a
|
|
18
18
|
date with a dropdown selection or a variety of localizable
|
|
19
|
-
text formats. Internally, the `<
|
|
19
|
+
text formats. Internally, the `<DatePicker>` uses [date-fns](https://date-fns.org/)
|
|
20
20
|
for it's date calculations and the [Intl.DateTimeFormat utility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
|
|
21
21
|
for localization support.
|
|
22
22
|
|
|
23
23
|
```jsx
|
|
24
24
|
import { ThemeProvider } from '@zendeskgarden/react-theming';
|
|
25
25
|
import { Field, Label, Input } from '@zendeskgarden/react-forms';
|
|
26
|
-
import {
|
|
26
|
+
import { DatePicker } from '@zendeskgarden/react-datepickers';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Place a `ThemeProvider` at the root of your React application
|
|
@@ -31,9 +31,9 @@ import { Datepicker } from '@zendeskgarden/react-datepickers';
|
|
|
31
31
|
<ThemeProvider>
|
|
32
32
|
<Field>
|
|
33
33
|
<Label>Example datepicker</Label>
|
|
34
|
-
<
|
|
34
|
+
<DatePicker value={new Date()} onChange={selectedDate => console.log(selectedDate)}>
|
|
35
35
|
<Input />
|
|
36
|
-
</
|
|
36
|
+
</DatePicker>
|
|
37
37
|
</Field>
|
|
38
38
|
</ThemeProvider>;
|
|
39
39
|
```
|
package/dist/index.cjs.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var PropTypes = require('prop-types');
|
|
12
|
+
var reactMergeRefs = require('react-merge-refs');
|
|
12
13
|
var styled = require('styled-components');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
14
|
+
var reactDom = require('@floating-ui/react-dom');
|
|
15
|
+
var reactTheming = require('@zendeskgarden/react-theming');
|
|
15
16
|
var startOfMonth = require('date-fns/startOfMonth');
|
|
16
17
|
var endOfMonth = require('date-fns/endOfMonth');
|
|
17
18
|
var startOfWeek = require('date-fns/startOfWeek');
|
|
@@ -24,11 +25,11 @@ var isSameMonth = require('date-fns/isSameMonth');
|
|
|
24
25
|
var isBefore = require('date-fns/isBefore');
|
|
25
26
|
var isAfter = require('date-fns/isAfter');
|
|
26
27
|
var getDate = require('date-fns/getDate');
|
|
27
|
-
var reactTheming = require('@zendeskgarden/react-theming');
|
|
28
28
|
var addMonths = require('date-fns/addMonths');
|
|
29
29
|
var subMonths = require('date-fns/subMonths');
|
|
30
30
|
var isValid = require('date-fns/isValid');
|
|
31
31
|
var parse = require('date-fns/parse');
|
|
32
|
+
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
32
33
|
var compareAsc = require('date-fns/compareAsc');
|
|
33
34
|
var subDays = require('date-fns/subDays');
|
|
34
35
|
|
|
@@ -57,62 +58,12 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
57
58
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
58
59
|
|
|
59
60
|
const WEEK_STARTS_ON = [0, 1, 2, 3, 4, 5, 6];
|
|
60
|
-
const
|
|
61
|
-
const PLACEMENT = [...SHARED_PLACEMENT, 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
62
|
-
|
|
63
|
-
function getPopperPlacement(gardenPlacement) {
|
|
64
|
-
switch (gardenPlacement) {
|
|
65
|
-
case 'end':
|
|
66
|
-
return 'right';
|
|
67
|
-
case 'end-top':
|
|
68
|
-
return 'right-start';
|
|
69
|
-
case 'end-bottom':
|
|
70
|
-
return 'right-end';
|
|
71
|
-
case 'start':
|
|
72
|
-
return 'left';
|
|
73
|
-
case 'start-top':
|
|
74
|
-
return 'left-start';
|
|
75
|
-
case 'start-bottom':
|
|
76
|
-
return 'left-end';
|
|
77
|
-
default:
|
|
78
|
-
return gardenPlacement;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function getRtlPopperPlacement(gardenPlacement) {
|
|
82
|
-
const popperPlacement = getPopperPlacement(gardenPlacement);
|
|
83
|
-
switch (popperPlacement) {
|
|
84
|
-
case 'left':
|
|
85
|
-
return 'right';
|
|
86
|
-
case 'left-start':
|
|
87
|
-
return 'right-start';
|
|
88
|
-
case 'left-end':
|
|
89
|
-
return 'right-end';
|
|
90
|
-
case 'top-start':
|
|
91
|
-
return 'top-end';
|
|
92
|
-
case 'top-end':
|
|
93
|
-
return 'top-start';
|
|
94
|
-
case 'right':
|
|
95
|
-
return 'left';
|
|
96
|
-
case 'right-start':
|
|
97
|
-
return 'left-start';
|
|
98
|
-
case 'right-end':
|
|
99
|
-
return 'left-end';
|
|
100
|
-
case 'bottom-start':
|
|
101
|
-
return 'bottom-end';
|
|
102
|
-
case 'bottom-end':
|
|
103
|
-
return 'bottom-start';
|
|
104
|
-
default:
|
|
105
|
-
return popperPlacement;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function getMenuPosition(popperPlacement) {
|
|
109
|
-
return popperPlacement ? popperPlacement.split('-')[0] : 'bottom';
|
|
110
|
-
}
|
|
61
|
+
const PLACEMENT = ['auto', ...reactTheming.PLACEMENT];
|
|
111
62
|
|
|
112
63
|
const COMPONENT_ID$b = 'datepickers.menu';
|
|
113
64
|
const StyledMenu = styled__default.default.div.attrs({
|
|
114
65
|
'data-garden-id': COMPONENT_ID$b,
|
|
115
|
-
'data-garden-version': '9.0.0-next.
|
|
66
|
+
'data-garden-version': '9.0.0-next.3'
|
|
116
67
|
}).withConfig({
|
|
117
68
|
displayName: "StyledMenu",
|
|
118
69
|
componentId: "sc-1npbkk0-0"
|
|
@@ -127,7 +78,7 @@ const StyledMenuWrapper = styled__default.default.div.attrs(props => ({
|
|
|
127
78
|
})).withConfig({
|
|
128
79
|
displayName: "StyledMenuWrapper",
|
|
129
80
|
componentId: "sc-6fowoz-0"
|
|
130
|
-
})(["", ";", ";"], props => reactTheming.menuStyles(getMenuPosition(props.placement), {
|
|
81
|
+
})(["top:0;left:0;", ";", ";"], props => reactTheming.menuStyles(reactTheming.getMenuPosition(props.placement), {
|
|
131
82
|
theme: props.theme,
|
|
132
83
|
hidden: props.isHidden,
|
|
133
84
|
margin: `${props.theme.space.base}px`,
|
|
@@ -150,13 +101,13 @@ const retrievePadding = _ref => {
|
|
|
150
101
|
}
|
|
151
102
|
return `margin: ${value}px;`;
|
|
152
103
|
};
|
|
153
|
-
const
|
|
104
|
+
const StyledDatePicker = styled__default.default.div.attrs({
|
|
154
105
|
'data-garden-id': COMPONENT_ID$9
|
|
155
106
|
}).withConfig({
|
|
156
|
-
displayName: "
|
|
157
|
-
componentId: "sc-
|
|
107
|
+
displayName: "StyledDatePicker",
|
|
108
|
+
componentId: "sc-15hwqzh-0"
|
|
158
109
|
})(["direction:", ";", " background-color:", ";color:", ";", ";"], props => props.theme.rtl && 'rtl', retrievePadding, props => props.theme.colors.background, props => props.theme.colors.foreground, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
159
|
-
|
|
110
|
+
StyledDatePicker.defaultProps = {
|
|
160
111
|
theme: reactTheming.DEFAULT_THEME
|
|
161
112
|
};
|
|
162
113
|
|
|
@@ -166,7 +117,7 @@ const StyledRangeCalendar = styled__default.default.div.attrs({
|
|
|
166
117
|
}).withConfig({
|
|
167
118
|
displayName: "StyledRangeCalendar",
|
|
168
119
|
componentId: "sc-1og46sy-0"
|
|
169
|
-
})(["display:flex;overflow:auto;", "{margin:0;", "}", ";"],
|
|
120
|
+
})(["display:flex;overflow:auto;", "{margin:0;", "}", ";"], StyledDatePicker, props => props.theme.rtl ? `&:last-of-type {margin-right: ${props.theme.space.base * 5}px}` : `&:first-of-type {margin-right: ${props.theme.space.base * 5}px}`, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
170
121
|
StyledRangeCalendar.defaultProps = {
|
|
171
122
|
theme: reactTheming.DEFAULT_THEME
|
|
172
123
|
};
|
|
@@ -351,9 +302,9 @@ StyledDay.defaultProps = {
|
|
|
351
302
|
theme: reactTheming.DEFAULT_THEME
|
|
352
303
|
};
|
|
353
304
|
|
|
354
|
-
const
|
|
355
|
-
const
|
|
356
|
-
return React.useContext(
|
|
305
|
+
const DatePickerContext = React.createContext(undefined);
|
|
306
|
+
const useDatePickerContext$1 = () => {
|
|
307
|
+
return React.useContext(DatePickerContext);
|
|
357
308
|
};
|
|
358
309
|
|
|
359
310
|
const REGION_MAPPINGS = {
|
|
@@ -477,7 +428,7 @@ const MonthSelector = _ref => {
|
|
|
477
428
|
const {
|
|
478
429
|
state,
|
|
479
430
|
dispatch
|
|
480
|
-
} =
|
|
431
|
+
} = useDatePickerContext$1();
|
|
481
432
|
const headerLabelFormatter = React.useCallback(date => {
|
|
482
433
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
483
434
|
month: 'long',
|
|
@@ -518,7 +469,7 @@ const Calendar$1 = React.forwardRef((_ref, ref) => {
|
|
|
518
469
|
const {
|
|
519
470
|
state,
|
|
520
471
|
dispatch
|
|
521
|
-
} =
|
|
472
|
+
} = useDatePickerContext$1();
|
|
522
473
|
const preferredWeekStartsOn = weekStartsOn || getStartOfWeek(locale);
|
|
523
474
|
const monthStartDate = startOfMonth.startOfMonth(state.previewDate);
|
|
524
475
|
const monthEndDate = endOfMonth.endOfMonth(monthStartDate);
|
|
@@ -580,7 +531,7 @@ const Calendar$1 = React.forwardRef((_ref, ref) => {
|
|
|
580
531
|
}
|
|
581
532
|
}, formattedDayLabel));
|
|
582
533
|
});
|
|
583
|
-
return React__namespace.default.createElement(
|
|
534
|
+
return React__namespace.default.createElement(StyledDatePicker, {
|
|
584
535
|
ref: ref,
|
|
585
536
|
isCompact: isCompact,
|
|
586
537
|
onMouseDown: e => {
|
|
@@ -768,12 +719,76 @@ function retrieveInitialState$1(initialProps) {
|
|
|
768
719
|
};
|
|
769
720
|
}
|
|
770
721
|
|
|
771
|
-
const
|
|
722
|
+
const Input = React.forwardRef((_ref, ref) => {
|
|
723
|
+
let {
|
|
724
|
+
element,
|
|
725
|
+
dispatch,
|
|
726
|
+
state,
|
|
727
|
+
refKey
|
|
728
|
+
} = _ref;
|
|
729
|
+
const isInputMouseDownRef = React.useRef(false);
|
|
730
|
+
const handleBlur = () => {
|
|
731
|
+
dispatch({
|
|
732
|
+
type: 'CLOSE'
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
const handleChange = e => {
|
|
736
|
+
dispatch({
|
|
737
|
+
type: 'MANUALLY_UPDATE_INPUT',
|
|
738
|
+
value: e.target.value
|
|
739
|
+
});
|
|
740
|
+
};
|
|
741
|
+
const handleClick = () => {
|
|
742
|
+
if (isInputMouseDownRef.current && !state.isOpen) {
|
|
743
|
+
dispatch({
|
|
744
|
+
type: 'OPEN'
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
const handleKeyDown = e => {
|
|
749
|
+
switch (e.key) {
|
|
750
|
+
case containerUtilities.KEYS.ESCAPE:
|
|
751
|
+
case containerUtilities.KEYS.ENTER:
|
|
752
|
+
dispatch({
|
|
753
|
+
type: 'CLOSE'
|
|
754
|
+
});
|
|
755
|
+
break;
|
|
756
|
+
case containerUtilities.KEYS.UP:
|
|
757
|
+
case containerUtilities.KEYS.DOWN:
|
|
758
|
+
case containerUtilities.KEYS.SPACE:
|
|
759
|
+
dispatch({
|
|
760
|
+
type: 'OPEN'
|
|
761
|
+
});
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
const handleMouseDown = () => {
|
|
766
|
+
isInputMouseDownRef.current = true;
|
|
767
|
+
};
|
|
768
|
+
const handleMouseUp = () => {
|
|
769
|
+
setTimeout(() => {
|
|
770
|
+
isInputMouseDownRef.current = false;
|
|
771
|
+
}, 0);
|
|
772
|
+
};
|
|
773
|
+
return React.cloneElement(element, {
|
|
774
|
+
[refKey]: ref,
|
|
775
|
+
onMouseDown: containerUtilities.composeEventHandlers(element.props.onMouseDown, handleMouseDown),
|
|
776
|
+
onMouseUp: containerUtilities.composeEventHandlers(element.props.onMouseUp, handleMouseUp),
|
|
777
|
+
onClick: containerUtilities.composeEventHandlers(element.props.onClick, handleClick),
|
|
778
|
+
onBlur: containerUtilities.composeEventHandlers(element.props.onBlur, handleBlur),
|
|
779
|
+
onChange: containerUtilities.composeEventHandlers(element.props.onChange, handleChange),
|
|
780
|
+
onKeyDown: containerUtilities.composeEventHandlers(element.props.onKeyDown, handleKeyDown),
|
|
781
|
+
autoComplete: 'off',
|
|
782
|
+
value: state.inputValue
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
Input.displayName = 'Input';
|
|
786
|
+
|
|
787
|
+
const PLACEMENT_DEFAULT = 'bottom-start';
|
|
788
|
+
const DatePicker = React.forwardRef((props, calendarRef) => {
|
|
772
789
|
const {
|
|
773
790
|
children,
|
|
774
|
-
placement,
|
|
775
|
-
popperModifiers,
|
|
776
|
-
eventsEnabled,
|
|
791
|
+
placement: _placement,
|
|
777
792
|
zIndex,
|
|
778
793
|
isAnimated,
|
|
779
794
|
refKey,
|
|
@@ -788,7 +803,7 @@ const Datepicker = React.forwardRef((props, calendarRef) => {
|
|
|
788
803
|
customParseDate,
|
|
789
804
|
...menuProps
|
|
790
805
|
} = props;
|
|
791
|
-
const theme = React.useContext(styled.ThemeContext);
|
|
806
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
792
807
|
const memoizedReducer = React.useCallback(datepickerReducer({
|
|
793
808
|
value,
|
|
794
809
|
formatDate,
|
|
@@ -797,15 +812,39 @@ const Datepicker = React.forwardRef((props, calendarRef) => {
|
|
|
797
812
|
onChange
|
|
798
813
|
}), [value, formatDate, locale, onChange, customParseDate]);
|
|
799
814
|
const [state, dispatch] = React.useReducer(memoizedReducer, retrieveInitialState$1(props));
|
|
800
|
-
const
|
|
801
|
-
const
|
|
802
|
-
const
|
|
803
|
-
React.
|
|
804
|
-
|
|
805
|
-
|
|
815
|
+
const triggerRef = React.useRef(null);
|
|
816
|
+
const floatingRef = React.useRef(null);
|
|
817
|
+
const [isVisible, setIsVisible] = React.useState(state.isOpen);
|
|
818
|
+
const contextValue = React.useMemo(() => ({
|
|
819
|
+
state,
|
|
820
|
+
dispatch
|
|
821
|
+
}), [state, dispatch]);
|
|
822
|
+
const [floatingPlacement] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
|
|
823
|
+
const {
|
|
824
|
+
refs,
|
|
825
|
+
placement,
|
|
826
|
+
update,
|
|
827
|
+
floatingStyles: {
|
|
828
|
+
transform
|
|
806
829
|
}
|
|
830
|
+
} = reactDom.useFloating({
|
|
831
|
+
elements: {
|
|
832
|
+
reference: triggerRef?.current,
|
|
833
|
+
floating: floatingRef?.current
|
|
834
|
+
},
|
|
835
|
+
placement: floatingPlacement,
|
|
836
|
+
middleware: [_placement === 'auto' ? reactDom.autoPlacement() : reactDom.flip()]
|
|
807
837
|
});
|
|
808
|
-
const
|
|
838
|
+
const Child = React__namespace.default.Children.only(children);
|
|
839
|
+
React.useEffect(() => {
|
|
840
|
+
let cleanup;
|
|
841
|
+
if (state.isOpen && refs.reference.current && refs.floating.current) {
|
|
842
|
+
cleanup = reactDom.autoUpdate(refs.reference.current, refs.floating.current, update, {
|
|
843
|
+
elementResize: typeof ResizeObserver === 'function'
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return () => cleanup && cleanup();
|
|
847
|
+
}, [state.isOpen, refs.reference, refs.floating, update]);
|
|
809
848
|
React.useEffect(() => {
|
|
810
849
|
let timeout;
|
|
811
850
|
if (state.isOpen) {
|
|
@@ -828,102 +867,35 @@ const Datepicker = React.forwardRef((props, calendarRef) => {
|
|
|
828
867
|
type: 'CONTROLLED_LOCALE_CHANGE'
|
|
829
868
|
});
|
|
830
869
|
}, [locale]);
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
870
|
+
return React__namespace.default.createElement(React__namespace.default.Fragment, null, React__namespace.default.createElement(Input, {
|
|
871
|
+
element: Child,
|
|
872
|
+
dispatch: dispatch,
|
|
873
|
+
state: state,
|
|
874
|
+
refKey: refKey,
|
|
875
|
+
ref: reactMergeRefs.mergeRefs([triggerRef, Child.ref ? Child.ref : null])
|
|
876
|
+
}), React__namespace.default.createElement(DatePickerContext.Provider, {
|
|
837
877
|
value: contextValue
|
|
838
|
-
}, React__namespace.default.createElement(
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
onClick: containerUtilities.composeEventHandlers(childElement.props.onClick, () => {
|
|
857
|
-
if (isInputMouseDownRef.current && !state.isOpen) {
|
|
858
|
-
dispatch({
|
|
859
|
-
type: 'OPEN'
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
}),
|
|
863
|
-
onBlur: containerUtilities.composeEventHandlers(childElement.props.onBlur, () => {
|
|
864
|
-
dispatch({
|
|
865
|
-
type: 'CLOSE'
|
|
866
|
-
});
|
|
867
|
-
}),
|
|
868
|
-
onChange: containerUtilities.composeEventHandlers(childElement.props.onChange, e => {
|
|
869
|
-
dispatch({
|
|
870
|
-
type: 'MANUALLY_UPDATE_INPUT',
|
|
871
|
-
value: e.target.value
|
|
872
|
-
});
|
|
873
|
-
}),
|
|
874
|
-
onKeyDown: containerUtilities.composeEventHandlers(childElement.props.onKeyDown, e => {
|
|
875
|
-
switch (e.key) {
|
|
876
|
-
case containerUtilities.KEYS.ESCAPE:
|
|
877
|
-
case containerUtilities.KEYS.ENTER:
|
|
878
|
-
dispatch({
|
|
879
|
-
type: 'CLOSE'
|
|
880
|
-
});
|
|
881
|
-
break;
|
|
882
|
-
case containerUtilities.KEYS.UP:
|
|
883
|
-
case containerUtilities.KEYS.DOWN:
|
|
884
|
-
case containerUtilities.KEYS.SPACE:
|
|
885
|
-
dispatch({
|
|
886
|
-
type: 'OPEN'
|
|
887
|
-
});
|
|
888
|
-
break;
|
|
889
|
-
}
|
|
890
|
-
}),
|
|
891
|
-
autoComplete: 'off',
|
|
892
|
-
value: state.inputValue
|
|
893
|
-
});
|
|
894
|
-
}), React__namespace.default.createElement(reactPopper.Popper, {
|
|
895
|
-
placement: popperPlacement,
|
|
896
|
-
modifiers: popperModifiers
|
|
897
|
-
,
|
|
898
|
-
eventsEnabled: state.isOpen && eventsEnabled
|
|
899
|
-
}, _ref2 => {
|
|
900
|
-
let {
|
|
901
|
-
ref,
|
|
902
|
-
style,
|
|
903
|
-
scheduleUpdate,
|
|
904
|
-
placement: currentPlacement
|
|
905
|
-
} = _ref2;
|
|
906
|
-
scheduleUpdateRef.current = scheduleUpdate;
|
|
907
|
-
return React__namespace.default.createElement(StyledMenuWrapper, {
|
|
908
|
-
ref: ref,
|
|
909
|
-
style: style,
|
|
910
|
-
isHidden: !state.isOpen,
|
|
911
|
-
isAnimated: isAnimated && (state.isOpen || isVisible),
|
|
912
|
-
placement: currentPlacement,
|
|
913
|
-
zIndex: zIndex
|
|
914
|
-
}, (state.isOpen || isVisible) && React__namespace.default.createElement(StyledMenu, menuProps, React__namespace.default.createElement(Calendar$1, {
|
|
915
|
-
ref: calendarRef,
|
|
916
|
-
isCompact: isCompact,
|
|
917
|
-
value: value,
|
|
918
|
-
minValue: minValue,
|
|
919
|
-
maxValue: maxValue,
|
|
920
|
-
locale: locale,
|
|
921
|
-
weekStartsOn: weekStartsOn
|
|
922
|
-
})));
|
|
923
|
-
})));
|
|
878
|
+
}, React__namespace.default.createElement(StyledMenuWrapper, {
|
|
879
|
+
ref: floatingRef,
|
|
880
|
+
style: {
|
|
881
|
+
transform
|
|
882
|
+
},
|
|
883
|
+
isHidden: !state.isOpen,
|
|
884
|
+
isAnimated: isAnimated && (state.isOpen || isVisible),
|
|
885
|
+
placement: placement,
|
|
886
|
+
zIndex: zIndex
|
|
887
|
+
}, (state.isOpen || isVisible) && React__namespace.default.createElement(StyledMenu, menuProps, React__namespace.default.createElement(Calendar$1, {
|
|
888
|
+
ref: calendarRef,
|
|
889
|
+
isCompact: isCompact,
|
|
890
|
+
value: value,
|
|
891
|
+
minValue: minValue,
|
|
892
|
+
maxValue: maxValue,
|
|
893
|
+
locale: locale,
|
|
894
|
+
weekStartsOn: weekStartsOn
|
|
895
|
+
})))));
|
|
924
896
|
});
|
|
925
|
-
|
|
926
|
-
|
|
897
|
+
DatePicker.displayName = 'DatePicker';
|
|
898
|
+
DatePicker.propTypes = {
|
|
927
899
|
value: PropTypes__default.default.any,
|
|
928
900
|
onChange: PropTypes__default.default.any,
|
|
929
901
|
formatDate: PropTypes__default.default.func,
|
|
@@ -935,16 +907,13 @@ Datepicker.propTypes = {
|
|
|
935
907
|
customParseDate: PropTypes__default.default.any,
|
|
936
908
|
refKey: PropTypes__default.default.string,
|
|
937
909
|
placement: PropTypes__default.default.oneOf(PLACEMENT),
|
|
938
|
-
popperModifiers: PropTypes__default.default.any,
|
|
939
910
|
isAnimated: PropTypes__default.default.bool,
|
|
940
|
-
eventsEnabled: PropTypes__default.default.bool,
|
|
941
911
|
zIndex: PropTypes__default.default.number
|
|
942
912
|
};
|
|
943
|
-
|
|
944
|
-
placement:
|
|
913
|
+
DatePicker.defaultProps = {
|
|
914
|
+
placement: PLACEMENT_DEFAULT,
|
|
945
915
|
refKey: 'ref',
|
|
946
916
|
isAnimated: true,
|
|
947
|
-
eventsEnabled: true,
|
|
948
917
|
zIndex: 1000,
|
|
949
918
|
locale: 'en-US'
|
|
950
919
|
};
|
|
@@ -1250,9 +1219,9 @@ function retrieveInitialState(initialProps) {
|
|
|
1250
1219
|
};
|
|
1251
1220
|
}
|
|
1252
1221
|
|
|
1253
|
-
const
|
|
1254
|
-
const
|
|
1255
|
-
return React.useContext(
|
|
1222
|
+
const DatePickerRangeContext = React.createContext(undefined);
|
|
1223
|
+
const useDatePickerContext = () => {
|
|
1224
|
+
return React.useContext(DatePickerRangeContext);
|
|
1256
1225
|
};
|
|
1257
1226
|
|
|
1258
1227
|
const Start = props => {
|
|
@@ -1264,7 +1233,7 @@ const Start = props => {
|
|
|
1264
1233
|
endValue,
|
|
1265
1234
|
startInputRef,
|
|
1266
1235
|
customParseDate
|
|
1267
|
-
} =
|
|
1236
|
+
} = useDatePickerContext();
|
|
1268
1237
|
const onChangeCallback = React.useCallback(e => {
|
|
1269
1238
|
dispatch({
|
|
1270
1239
|
type: 'START_INPUT_ONCHANGE',
|
|
@@ -1318,7 +1287,7 @@ const Start = props => {
|
|
|
1318
1287
|
onBlur: containerUtilities.composeEventHandlers(childElement.props.onBlur, onBlurCallback)
|
|
1319
1288
|
});
|
|
1320
1289
|
};
|
|
1321
|
-
Start.displayName = '
|
|
1290
|
+
Start.displayName = 'DatePickerRange.Start';
|
|
1322
1291
|
|
|
1323
1292
|
const End = props => {
|
|
1324
1293
|
const {
|
|
@@ -1329,7 +1298,7 @@ const End = props => {
|
|
|
1329
1298
|
endValue,
|
|
1330
1299
|
endInputRef,
|
|
1331
1300
|
customParseDate
|
|
1332
|
-
} =
|
|
1301
|
+
} = useDatePickerContext();
|
|
1333
1302
|
const onChangeCallback = React.useCallback(e => {
|
|
1334
1303
|
dispatch({
|
|
1335
1304
|
type: 'END_INPUT_ONCHANGE',
|
|
@@ -1383,7 +1352,7 @@ const End = props => {
|
|
|
1383
1352
|
onBlur: containerUtilities.composeEventHandlers(childElement.props.onBlur, onBlurCallback)
|
|
1384
1353
|
});
|
|
1385
1354
|
};
|
|
1386
|
-
End.displayName = '
|
|
1355
|
+
End.displayName = 'DatePickerRange.End';
|
|
1387
1356
|
|
|
1388
1357
|
function _extends() {
|
|
1389
1358
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -1417,7 +1386,7 @@ const Month = React.forwardRef((_ref, ref) => {
|
|
|
1417
1386
|
startValue,
|
|
1418
1387
|
endValue,
|
|
1419
1388
|
onChange
|
|
1420
|
-
} =
|
|
1389
|
+
} = useDatePickerContext();
|
|
1421
1390
|
const headerLabelFormatter = React.useCallback(date => {
|
|
1422
1391
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
1423
1392
|
month: 'long',
|
|
@@ -1594,7 +1563,7 @@ const Month = React.forwardRef((_ref, ref) => {
|
|
|
1594
1563
|
}
|
|
1595
1564
|
}, formattedDayLabel));
|
|
1596
1565
|
});
|
|
1597
|
-
return React__namespace.default.createElement(
|
|
1566
|
+
return React__namespace.default.createElement(StyledDatePicker, {
|
|
1598
1567
|
ref: ref,
|
|
1599
1568
|
isCompact: isCompact,
|
|
1600
1569
|
onMouseDown: e => {
|
|
@@ -1635,11 +1604,11 @@ Month.displayName = 'Month';
|
|
|
1635
1604
|
const Calendar = React.forwardRef((props, ref) => {
|
|
1636
1605
|
const {
|
|
1637
1606
|
state
|
|
1638
|
-
} =
|
|
1607
|
+
} = useDatePickerContext();
|
|
1639
1608
|
return React__namespace.default.createElement(StyledRangeCalendar, _extends({
|
|
1640
1609
|
ref: ref,
|
|
1641
1610
|
"data-garden-id": "datepickers.range",
|
|
1642
|
-
"data-garden-version": '9.0.0-next.
|
|
1611
|
+
"data-garden-version": '9.0.0-next.3'
|
|
1643
1612
|
}, props), React__namespace.default.createElement(Month, {
|
|
1644
1613
|
displayDate: state.previewDate,
|
|
1645
1614
|
isNextHidden: true
|
|
@@ -1648,9 +1617,9 @@ const Calendar = React.forwardRef((props, ref) => {
|
|
|
1648
1617
|
isPreviousHidden: true
|
|
1649
1618
|
}));
|
|
1650
1619
|
});
|
|
1651
|
-
Calendar.displayName = '
|
|
1620
|
+
Calendar.displayName = 'DatePickerRange.Calendar';
|
|
1652
1621
|
|
|
1653
|
-
const
|
|
1622
|
+
const DatePickerRangeComponent = props => {
|
|
1654
1623
|
const {
|
|
1655
1624
|
startValue,
|
|
1656
1625
|
locale,
|
|
@@ -1711,11 +1680,11 @@ const DatepickerRangeComponent = props => {
|
|
|
1711
1680
|
endInputRef,
|
|
1712
1681
|
customParseDate
|
|
1713
1682
|
}), [state, dispatch, isCompact, locale, weekStartsOn, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
|
|
1714
|
-
return React__namespace.default.createElement(
|
|
1683
|
+
return React__namespace.default.createElement(DatePickerRangeContext.Provider, {
|
|
1715
1684
|
value: value
|
|
1716
1685
|
}, children);
|
|
1717
1686
|
};
|
|
1718
|
-
|
|
1687
|
+
DatePickerRangeComponent.propTypes = {
|
|
1719
1688
|
locale: PropTypes__default.default.string,
|
|
1720
1689
|
weekStartsOn: PropTypes__default.default.number,
|
|
1721
1690
|
startValue: PropTypes__default.default.instanceOf(Date),
|
|
@@ -1727,14 +1696,14 @@ DatepickerRangeComponent.propTypes = {
|
|
|
1727
1696
|
customParseDate: PropTypes__default.default.func,
|
|
1728
1697
|
isCompact: PropTypes__default.default.bool
|
|
1729
1698
|
};
|
|
1730
|
-
|
|
1699
|
+
DatePickerRangeComponent.defaultProps = {
|
|
1731
1700
|
locale: 'en-US',
|
|
1732
1701
|
isCompact: false
|
|
1733
1702
|
};
|
|
1734
|
-
const
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1703
|
+
const DatePickerRange = DatePickerRangeComponent;
|
|
1704
|
+
DatePickerRange.Calendar = Calendar;
|
|
1705
|
+
DatePickerRange.End = End;
|
|
1706
|
+
DatePickerRange.Start = Start;
|
|
1738
1707
|
|
|
1739
|
-
exports.
|
|
1740
|
-
exports.
|
|
1708
|
+
exports.DatePicker = DatePicker;
|
|
1709
|
+
exports.DatePickerRange = DatePickerRange;
|