@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.
Files changed (25) hide show
  1. package/README.md +5 -5
  2. package/dist/index.cjs.js +169 -200
  3. package/dist/index.esm.js +169 -200
  4. package/dist/typings/elements/{Datepicker/Datepicker.d.ts → DatePicker/DatePicker.d.ts} +2 -2
  5. package/dist/typings/elements/DatePicker/components/Input.d.ts +16 -0
  6. package/dist/typings/elements/{Datepicker/utils/datepicker-reducer.d.ts → DatePicker/utils/date-picker-reducer.d.ts} +6 -6
  7. package/dist/typings/elements/DatePicker/utils/useDatePickerContext.d.ts +18 -0
  8. package/dist/typings/elements/{DatepickerRange/DatepickerRange.d.ts → DatePickerRange/DatePickerRange.d.ts} +3 -3
  9. package/dist/typings/elements/{DatepickerRange/utils/datepicker-range-reducer.d.ts → DatePickerRange/utils/date-picker-range-reducer.d.ts} +6 -6
  10. package/dist/typings/elements/{DatepickerRange/utils/useDatepickerRangeContext.d.ts → DatePickerRange/utils/useDatePickerRangeContext.d.ts} +7 -7
  11. package/dist/typings/index.d.ts +3 -5
  12. package/dist/typings/styled/{StyledDatepicker.d.ts → StyledDatePicker.d.ts} +3 -3
  13. package/dist/typings/styled/StyledMenuWrapper.d.ts +2 -2
  14. package/dist/typings/styled/index.d.ts +1 -1
  15. package/dist/typings/types/index.d.ts +5 -14
  16. package/dist/typings/utils/calendar-utils.d.ts +2 -2
  17. package/package.json +5 -4
  18. package/dist/typings/elements/Datepicker/utils/garden-placements.d.ts +0 -21
  19. package/dist/typings/elements/Datepicker/utils/useDatepickerContext.d.ts +0 -18
  20. /package/dist/typings/elements/{Datepicker → DatePicker}/components/Calendar.d.ts +0 -0
  21. /package/dist/typings/elements/{Datepicker → DatePicker}/components/MonthSelector.d.ts +0 -0
  22. /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Calendar.d.ts +0 -0
  23. /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/End.d.ts +0 -0
  24. /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Month.d.ts +0 -0
  25. /package/dist/typings/elements/{DatepickerRange → DatePickerRange}/components/Start.d.ts +0 -0
package/dist/index.esm.js CHANGED
@@ -6,11 +6,12 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import React__default, { createContext, useContext, useCallback, forwardRef, useReducer, useRef, useEffect, useState, useMemo } from 'react';
9
+ import React__default, { createContext, useContext, useCallback, forwardRef, useRef, cloneElement, useReducer, useState, useMemo, useEffect } from 'react';
10
10
  import PropTypes from 'prop-types';
11
+ import { mergeRefs } from 'react-merge-refs';
11
12
  import styled, { css, ThemeContext } from 'styled-components';
12
- import { Manager, Reference, Popper } from 'react-popper';
13
- import { composeEventHandlers, KEYS } from '@zendeskgarden/container-utilities';
13
+ import { useFloating, autoPlacement, flip, autoUpdate } from '@floating-ui/react-dom';
14
+ import { PLACEMENT as PLACEMENT$1, retrieveComponentStyles, DEFAULT_THEME, menuStyles, getMenuPosition, getColor, getFloatingPlacements } from '@zendeskgarden/react-theming';
14
15
  import { startOfMonth } from 'date-fns/startOfMonth';
15
16
  import { endOfMonth } from 'date-fns/endOfMonth';
16
17
  import { startOfWeek } from 'date-fns/startOfWeek';
@@ -23,71 +24,21 @@ import { isSameMonth } from 'date-fns/isSameMonth';
23
24
  import { isBefore } from 'date-fns/isBefore';
24
25
  import { isAfter } from 'date-fns/isAfter';
25
26
  import { getDate } from 'date-fns/getDate';
26
- import { retrieveComponentStyles, DEFAULT_THEME, menuStyles, getColor } from '@zendeskgarden/react-theming';
27
27
  import { addMonths } from 'date-fns/addMonths';
28
28
  import { subMonths } from 'date-fns/subMonths';
29
29
  import { isValid } from 'date-fns/isValid';
30
30
  import { parse } from 'date-fns/parse';
31
+ import { composeEventHandlers, KEYS } from '@zendeskgarden/container-utilities';
31
32
  import { compareAsc } from 'date-fns/compareAsc';
32
33
  import { subDays } from 'date-fns/subDays';
33
34
 
34
35
  const WEEK_STARTS_ON = [0, 1, 2, 3, 4, 5, 6];
35
- const SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
36
- const PLACEMENT = [...SHARED_PLACEMENT, 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
37
-
38
- function getPopperPlacement(gardenPlacement) {
39
- switch (gardenPlacement) {
40
- case 'end':
41
- return 'right';
42
- case 'end-top':
43
- return 'right-start';
44
- case 'end-bottom':
45
- return 'right-end';
46
- case 'start':
47
- return 'left';
48
- case 'start-top':
49
- return 'left-start';
50
- case 'start-bottom':
51
- return 'left-end';
52
- default:
53
- return gardenPlacement;
54
- }
55
- }
56
- function getRtlPopperPlacement(gardenPlacement) {
57
- const popperPlacement = getPopperPlacement(gardenPlacement);
58
- switch (popperPlacement) {
59
- case 'left':
60
- return 'right';
61
- case 'left-start':
62
- return 'right-start';
63
- case 'left-end':
64
- return 'right-end';
65
- case 'top-start':
66
- return 'top-end';
67
- case 'top-end':
68
- return 'top-start';
69
- case 'right':
70
- return 'left';
71
- case 'right-start':
72
- return 'left-start';
73
- case 'right-end':
74
- return 'left-end';
75
- case 'bottom-start':
76
- return 'bottom-end';
77
- case 'bottom-end':
78
- return 'bottom-start';
79
- default:
80
- return popperPlacement;
81
- }
82
- }
83
- function getMenuPosition(popperPlacement) {
84
- return popperPlacement ? popperPlacement.split('-')[0] : 'bottom';
85
- }
36
+ const PLACEMENT = ['auto', ...PLACEMENT$1];
86
37
 
87
38
  const COMPONENT_ID$b = 'datepickers.menu';
88
39
  const StyledMenu = styled.div.attrs({
89
40
  'data-garden-id': COMPONENT_ID$b,
90
- 'data-garden-version': '9.0.0-next.1'
41
+ 'data-garden-version': '9.0.0-next.3'
91
42
  }).withConfig({
92
43
  displayName: "StyledMenu",
93
44
  componentId: "sc-1npbkk0-0"
@@ -102,7 +53,7 @@ const StyledMenuWrapper = styled.div.attrs(props => ({
102
53
  })).withConfig({
103
54
  displayName: "StyledMenuWrapper",
104
55
  componentId: "sc-6fowoz-0"
105
- })(["", ";", ";"], props => menuStyles(getMenuPosition(props.placement), {
56
+ })(["top:0;left:0;", ";", ";"], props => menuStyles(getMenuPosition(props.placement), {
106
57
  theme: props.theme,
107
58
  hidden: props.isHidden,
108
59
  margin: `${props.theme.space.base}px`,
@@ -125,13 +76,13 @@ const retrievePadding = _ref => {
125
76
  }
126
77
  return `margin: ${value}px;`;
127
78
  };
128
- const StyledDatepicker = styled.div.attrs({
79
+ const StyledDatePicker = styled.div.attrs({
129
80
  'data-garden-id': COMPONENT_ID$9
130
81
  }).withConfig({
131
- displayName: "StyledDatepicker",
132
- componentId: "sc-w3zqsp-0"
82
+ displayName: "StyledDatePicker",
83
+ componentId: "sc-15hwqzh-0"
133
84
  })(["direction:", ";", " background-color:", ";color:", ";", ";"], props => props.theme.rtl && 'rtl', retrievePadding, props => props.theme.colors.background, props => props.theme.colors.foreground, props => retrieveComponentStyles(COMPONENT_ID$9, props));
134
- StyledDatepicker.defaultProps = {
85
+ StyledDatePicker.defaultProps = {
135
86
  theme: DEFAULT_THEME
136
87
  };
137
88
 
@@ -141,7 +92,7 @@ const StyledRangeCalendar = styled.div.attrs({
141
92
  }).withConfig({
142
93
  displayName: "StyledRangeCalendar",
143
94
  componentId: "sc-1og46sy-0"
144
- })(["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 => retrieveComponentStyles(COMPONENT_ID$8, props));
95
+ })(["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 => retrieveComponentStyles(COMPONENT_ID$8, props));
145
96
  StyledRangeCalendar.defaultProps = {
146
97
  theme: DEFAULT_THEME
147
98
  };
@@ -326,9 +277,9 @@ StyledDay.defaultProps = {
326
277
  theme: DEFAULT_THEME
327
278
  };
328
279
 
329
- const DatepickerContext = createContext(undefined);
330
- const useDatepickerContext$1 = () => {
331
- return useContext(DatepickerContext);
280
+ const DatePickerContext = createContext(undefined);
281
+ const useDatePickerContext$1 = () => {
282
+ return useContext(DatePickerContext);
332
283
  };
333
284
 
334
285
  const REGION_MAPPINGS = {
@@ -452,7 +403,7 @@ const MonthSelector = _ref => {
452
403
  const {
453
404
  state,
454
405
  dispatch
455
- } = useDatepickerContext$1();
406
+ } = useDatePickerContext$1();
456
407
  const headerLabelFormatter = useCallback(date => {
457
408
  const formatter = new Intl.DateTimeFormat(locale, {
458
409
  month: 'long',
@@ -493,7 +444,7 @@ const Calendar$1 = forwardRef((_ref, ref) => {
493
444
  const {
494
445
  state,
495
446
  dispatch
496
- } = useDatepickerContext$1();
447
+ } = useDatePickerContext$1();
497
448
  const preferredWeekStartsOn = weekStartsOn || getStartOfWeek(locale);
498
449
  const monthStartDate = startOfMonth(state.previewDate);
499
450
  const monthEndDate = endOfMonth(monthStartDate);
@@ -555,7 +506,7 @@ const Calendar$1 = forwardRef((_ref, ref) => {
555
506
  }
556
507
  }, formattedDayLabel));
557
508
  });
558
- return React__default.createElement(StyledDatepicker, {
509
+ return React__default.createElement(StyledDatePicker, {
559
510
  ref: ref,
560
511
  isCompact: isCompact,
561
512
  onMouseDown: e => {
@@ -743,12 +694,76 @@ function retrieveInitialState$1(initialProps) {
743
694
  };
744
695
  }
745
696
 
746
- const Datepicker = forwardRef((props, calendarRef) => {
697
+ const Input = forwardRef((_ref, ref) => {
698
+ let {
699
+ element,
700
+ dispatch,
701
+ state,
702
+ refKey
703
+ } = _ref;
704
+ const isInputMouseDownRef = useRef(false);
705
+ const handleBlur = () => {
706
+ dispatch({
707
+ type: 'CLOSE'
708
+ });
709
+ };
710
+ const handleChange = e => {
711
+ dispatch({
712
+ type: 'MANUALLY_UPDATE_INPUT',
713
+ value: e.target.value
714
+ });
715
+ };
716
+ const handleClick = () => {
717
+ if (isInputMouseDownRef.current && !state.isOpen) {
718
+ dispatch({
719
+ type: 'OPEN'
720
+ });
721
+ }
722
+ };
723
+ const handleKeyDown = e => {
724
+ switch (e.key) {
725
+ case KEYS.ESCAPE:
726
+ case KEYS.ENTER:
727
+ dispatch({
728
+ type: 'CLOSE'
729
+ });
730
+ break;
731
+ case KEYS.UP:
732
+ case KEYS.DOWN:
733
+ case KEYS.SPACE:
734
+ dispatch({
735
+ type: 'OPEN'
736
+ });
737
+ break;
738
+ }
739
+ };
740
+ const handleMouseDown = () => {
741
+ isInputMouseDownRef.current = true;
742
+ };
743
+ const handleMouseUp = () => {
744
+ setTimeout(() => {
745
+ isInputMouseDownRef.current = false;
746
+ }, 0);
747
+ };
748
+ return cloneElement(element, {
749
+ [refKey]: ref,
750
+ onMouseDown: composeEventHandlers(element.props.onMouseDown, handleMouseDown),
751
+ onMouseUp: composeEventHandlers(element.props.onMouseUp, handleMouseUp),
752
+ onClick: composeEventHandlers(element.props.onClick, handleClick),
753
+ onBlur: composeEventHandlers(element.props.onBlur, handleBlur),
754
+ onChange: composeEventHandlers(element.props.onChange, handleChange),
755
+ onKeyDown: composeEventHandlers(element.props.onKeyDown, handleKeyDown),
756
+ autoComplete: 'off',
757
+ value: state.inputValue
758
+ });
759
+ });
760
+ Input.displayName = 'Input';
761
+
762
+ const PLACEMENT_DEFAULT = 'bottom-start';
763
+ const DatePicker = forwardRef((props, calendarRef) => {
747
764
  const {
748
765
  children,
749
- placement,
750
- popperModifiers,
751
- eventsEnabled,
766
+ placement: _placement,
752
767
  zIndex,
753
768
  isAnimated,
754
769
  refKey,
@@ -763,7 +778,7 @@ const Datepicker = forwardRef((props, calendarRef) => {
763
778
  customParseDate,
764
779
  ...menuProps
765
780
  } = props;
766
- const theme = useContext(ThemeContext);
781
+ const theme = useContext(ThemeContext) || DEFAULT_THEME;
767
782
  const memoizedReducer = useCallback(datepickerReducer({
768
783
  value,
769
784
  formatDate,
@@ -772,15 +787,39 @@ const Datepicker = forwardRef((props, calendarRef) => {
772
787
  onChange
773
788
  }), [value, formatDate, locale, onChange, customParseDate]);
774
789
  const [state, dispatch] = useReducer(memoizedReducer, retrieveInitialState$1(props));
775
- const scheduleUpdateRef = useRef(undefined);
776
- const inputRef = useRef(null);
777
- const isInputMouseDownRef = useRef(false);
778
- useEffect(() => {
779
- if (state.isOpen && scheduleUpdateRef.current) {
780
- scheduleUpdateRef.current();
790
+ const triggerRef = useRef(null);
791
+ const floatingRef = useRef(null);
792
+ const [isVisible, setIsVisible] = useState(state.isOpen);
793
+ const contextValue = useMemo(() => ({
794
+ state,
795
+ dispatch
796
+ }), [state, dispatch]);
797
+ const [floatingPlacement] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
798
+ const {
799
+ refs,
800
+ placement,
801
+ update,
802
+ floatingStyles: {
803
+ transform
781
804
  }
805
+ } = useFloating({
806
+ elements: {
807
+ reference: triggerRef?.current,
808
+ floating: floatingRef?.current
809
+ },
810
+ placement: floatingPlacement,
811
+ middleware: [_placement === 'auto' ? autoPlacement() : flip()]
782
812
  });
783
- const [isVisible, setIsVisible] = useState(state.isOpen);
813
+ const Child = React__default.Children.only(children);
814
+ useEffect(() => {
815
+ let cleanup;
816
+ if (state.isOpen && refs.reference.current && refs.floating.current) {
817
+ cleanup = autoUpdate(refs.reference.current, refs.floating.current, update, {
818
+ elementResize: typeof ResizeObserver === 'function'
819
+ });
820
+ }
821
+ return () => cleanup && cleanup();
822
+ }, [state.isOpen, refs.reference, refs.floating, update]);
784
823
  useEffect(() => {
785
824
  let timeout;
786
825
  if (state.isOpen) {
@@ -803,102 +842,35 @@ const Datepicker = forwardRef((props, calendarRef) => {
803
842
  type: 'CONTROLLED_LOCALE_CHANGE'
804
843
  });
805
844
  }, [locale]);
806
- const popperPlacement = theme.rtl ? getRtlPopperPlacement(placement) : getPopperPlacement(placement);
807
- const contextValue = useMemo(() => ({
808
- state,
809
- dispatch
810
- }), [state, dispatch]);
811
- return React__default.createElement(DatepickerContext.Provider, {
845
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(Input, {
846
+ element: Child,
847
+ dispatch: dispatch,
848
+ state: state,
849
+ refKey: refKey,
850
+ ref: mergeRefs([triggerRef, Child.ref ? Child.ref : null])
851
+ }), React__default.createElement(DatePickerContext.Provider, {
812
852
  value: contextValue
813
- }, React__default.createElement(Manager, null, React__default.createElement(Reference, null, _ref => {
814
- let {
815
- ref
816
- } = _ref;
817
- const childElement = React__default.Children.only(children);
818
- return React__default.cloneElement(childElement, {
819
- [refKey]: refValue => {
820
- ref(refValue);
821
- inputRef.current = refValue;
822
- },
823
- onMouseDown: composeEventHandlers(childElement.props.onMouseDown, () => {
824
- isInputMouseDownRef.current = true;
825
- }),
826
- onMouseUp: composeEventHandlers(childElement.props.onMouseUp, () => {
827
- setTimeout(() => {
828
- isInputMouseDownRef.current = false;
829
- }, 0);
830
- }),
831
- onClick: composeEventHandlers(childElement.props.onClick, () => {
832
- if (isInputMouseDownRef.current && !state.isOpen) {
833
- dispatch({
834
- type: 'OPEN'
835
- });
836
- }
837
- }),
838
- onBlur: composeEventHandlers(childElement.props.onBlur, () => {
839
- dispatch({
840
- type: 'CLOSE'
841
- });
842
- }),
843
- onChange: composeEventHandlers(childElement.props.onChange, e => {
844
- dispatch({
845
- type: 'MANUALLY_UPDATE_INPUT',
846
- value: e.target.value
847
- });
848
- }),
849
- onKeyDown: composeEventHandlers(childElement.props.onKeyDown, e => {
850
- switch (e.key) {
851
- case KEYS.ESCAPE:
852
- case KEYS.ENTER:
853
- dispatch({
854
- type: 'CLOSE'
855
- });
856
- break;
857
- case KEYS.UP:
858
- case KEYS.DOWN:
859
- case KEYS.SPACE:
860
- dispatch({
861
- type: 'OPEN'
862
- });
863
- break;
864
- }
865
- }),
866
- autoComplete: 'off',
867
- value: state.inputValue
868
- });
869
- }), React__default.createElement(Popper, {
870
- placement: popperPlacement,
871
- modifiers: popperModifiers
872
- ,
873
- eventsEnabled: state.isOpen && eventsEnabled
874
- }, _ref2 => {
875
- let {
876
- ref,
877
- style,
878
- scheduleUpdate,
879
- placement: currentPlacement
880
- } = _ref2;
881
- scheduleUpdateRef.current = scheduleUpdate;
882
- return React__default.createElement(StyledMenuWrapper, {
883
- ref: ref,
884
- style: style,
885
- isHidden: !state.isOpen,
886
- isAnimated: isAnimated && (state.isOpen || isVisible),
887
- placement: currentPlacement,
888
- zIndex: zIndex
889
- }, (state.isOpen || isVisible) && React__default.createElement(StyledMenu, menuProps, React__default.createElement(Calendar$1, {
890
- ref: calendarRef,
891
- isCompact: isCompact,
892
- value: value,
893
- minValue: minValue,
894
- maxValue: maxValue,
895
- locale: locale,
896
- weekStartsOn: weekStartsOn
897
- })));
898
- })));
853
+ }, React__default.createElement(StyledMenuWrapper, {
854
+ ref: floatingRef,
855
+ style: {
856
+ transform
857
+ },
858
+ isHidden: !state.isOpen,
859
+ isAnimated: isAnimated && (state.isOpen || isVisible),
860
+ placement: placement,
861
+ zIndex: zIndex
862
+ }, (state.isOpen || isVisible) && React__default.createElement(StyledMenu, menuProps, React__default.createElement(Calendar$1, {
863
+ ref: calendarRef,
864
+ isCompact: isCompact,
865
+ value: value,
866
+ minValue: minValue,
867
+ maxValue: maxValue,
868
+ locale: locale,
869
+ weekStartsOn: weekStartsOn
870
+ })))));
899
871
  });
900
- Datepicker.displayName = 'Datepicker';
901
- Datepicker.propTypes = {
872
+ DatePicker.displayName = 'DatePicker';
873
+ DatePicker.propTypes = {
902
874
  value: PropTypes.any,
903
875
  onChange: PropTypes.any,
904
876
  formatDate: PropTypes.func,
@@ -910,16 +882,13 @@ Datepicker.propTypes = {
910
882
  customParseDate: PropTypes.any,
911
883
  refKey: PropTypes.string,
912
884
  placement: PropTypes.oneOf(PLACEMENT),
913
- popperModifiers: PropTypes.any,
914
885
  isAnimated: PropTypes.bool,
915
- eventsEnabled: PropTypes.bool,
916
886
  zIndex: PropTypes.number
917
887
  };
918
- Datepicker.defaultProps = {
919
- placement: 'bottom-start',
888
+ DatePicker.defaultProps = {
889
+ placement: PLACEMENT_DEFAULT,
920
890
  refKey: 'ref',
921
891
  isAnimated: true,
922
- eventsEnabled: true,
923
892
  zIndex: 1000,
924
893
  locale: 'en-US'
925
894
  };
@@ -1225,9 +1194,9 @@ function retrieveInitialState(initialProps) {
1225
1194
  };
1226
1195
  }
1227
1196
 
1228
- const DatepickerRangeContext = createContext(undefined);
1229
- const useDatepickerContext = () => {
1230
- return useContext(DatepickerRangeContext);
1197
+ const DatePickerRangeContext = createContext(undefined);
1198
+ const useDatePickerContext = () => {
1199
+ return useContext(DatePickerRangeContext);
1231
1200
  };
1232
1201
 
1233
1202
  const Start = props => {
@@ -1239,7 +1208,7 @@ const Start = props => {
1239
1208
  endValue,
1240
1209
  startInputRef,
1241
1210
  customParseDate
1242
- } = useDatepickerContext();
1211
+ } = useDatePickerContext();
1243
1212
  const onChangeCallback = useCallback(e => {
1244
1213
  dispatch({
1245
1214
  type: 'START_INPUT_ONCHANGE',
@@ -1293,7 +1262,7 @@ const Start = props => {
1293
1262
  onBlur: composeEventHandlers(childElement.props.onBlur, onBlurCallback)
1294
1263
  });
1295
1264
  };
1296
- Start.displayName = 'DatepickerRange.Start';
1265
+ Start.displayName = 'DatePickerRange.Start';
1297
1266
 
1298
1267
  const End = props => {
1299
1268
  const {
@@ -1304,7 +1273,7 @@ const End = props => {
1304
1273
  endValue,
1305
1274
  endInputRef,
1306
1275
  customParseDate
1307
- } = useDatepickerContext();
1276
+ } = useDatePickerContext();
1308
1277
  const onChangeCallback = useCallback(e => {
1309
1278
  dispatch({
1310
1279
  type: 'END_INPUT_ONCHANGE',
@@ -1358,7 +1327,7 @@ const End = props => {
1358
1327
  onBlur: composeEventHandlers(childElement.props.onBlur, onBlurCallback)
1359
1328
  });
1360
1329
  };
1361
- End.displayName = 'DatepickerRange.End';
1330
+ End.displayName = 'DatePickerRange.End';
1362
1331
 
1363
1332
  function _extends() {
1364
1333
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -1392,7 +1361,7 @@ const Month = forwardRef((_ref, ref) => {
1392
1361
  startValue,
1393
1362
  endValue,
1394
1363
  onChange
1395
- } = useDatepickerContext();
1364
+ } = useDatePickerContext();
1396
1365
  const headerLabelFormatter = useCallback(date => {
1397
1366
  const formatter = new Intl.DateTimeFormat(locale, {
1398
1367
  month: 'long',
@@ -1569,7 +1538,7 @@ const Month = forwardRef((_ref, ref) => {
1569
1538
  }
1570
1539
  }, formattedDayLabel));
1571
1540
  });
1572
- return React__default.createElement(StyledDatepicker, {
1541
+ return React__default.createElement(StyledDatePicker, {
1573
1542
  ref: ref,
1574
1543
  isCompact: isCompact,
1575
1544
  onMouseDown: e => {
@@ -1610,11 +1579,11 @@ Month.displayName = 'Month';
1610
1579
  const Calendar = forwardRef((props, ref) => {
1611
1580
  const {
1612
1581
  state
1613
- } = useDatepickerContext();
1582
+ } = useDatePickerContext();
1614
1583
  return React__default.createElement(StyledRangeCalendar, _extends({
1615
1584
  ref: ref,
1616
1585
  "data-garden-id": "datepickers.range",
1617
- "data-garden-version": '9.0.0-next.1'
1586
+ "data-garden-version": '9.0.0-next.3'
1618
1587
  }, props), React__default.createElement(Month, {
1619
1588
  displayDate: state.previewDate,
1620
1589
  isNextHidden: true
@@ -1623,9 +1592,9 @@ const Calendar = forwardRef((props, ref) => {
1623
1592
  isPreviousHidden: true
1624
1593
  }));
1625
1594
  });
1626
- Calendar.displayName = 'DatepickerRange.Calendar';
1595
+ Calendar.displayName = 'DatePickerRange.Calendar';
1627
1596
 
1628
- const DatepickerRangeComponent = props => {
1597
+ const DatePickerRangeComponent = props => {
1629
1598
  const {
1630
1599
  startValue,
1631
1600
  locale,
@@ -1686,11 +1655,11 @@ const DatepickerRangeComponent = props => {
1686
1655
  endInputRef,
1687
1656
  customParseDate
1688
1657
  }), [state, dispatch, isCompact, locale, weekStartsOn, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
1689
- return React__default.createElement(DatepickerRangeContext.Provider, {
1658
+ return React__default.createElement(DatePickerRangeContext.Provider, {
1690
1659
  value: value
1691
1660
  }, children);
1692
1661
  };
1693
- DatepickerRangeComponent.propTypes = {
1662
+ DatePickerRangeComponent.propTypes = {
1694
1663
  locale: PropTypes.string,
1695
1664
  weekStartsOn: PropTypes.number,
1696
1665
  startValue: PropTypes.instanceOf(Date),
@@ -1702,13 +1671,13 @@ DatepickerRangeComponent.propTypes = {
1702
1671
  customParseDate: PropTypes.func,
1703
1672
  isCompact: PropTypes.bool
1704
1673
  };
1705
- DatepickerRangeComponent.defaultProps = {
1674
+ DatePickerRangeComponent.defaultProps = {
1706
1675
  locale: 'en-US',
1707
1676
  isCompact: false
1708
1677
  };
1709
- const DatepickerRange = DatepickerRangeComponent;
1710
- DatepickerRange.Calendar = Calendar;
1711
- DatepickerRange.End = End;
1712
- DatepickerRange.Start = Start;
1678
+ const DatePickerRange = DatePickerRangeComponent;
1679
+ DatePickerRange.Calendar = Calendar;
1680
+ DatePickerRange.End = End;
1681
+ DatePickerRange.Start = Start;
1713
1682
 
1714
- export { Datepicker, DatepickerRange };
1683
+ export { DatePicker, DatePickerRange };
@@ -5,8 +5,8 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import React from 'react';
8
- import { IDatepickerProps } from '../../types';
8
+ import { IDatePickerProps } from '../../types';
9
9
  /**
10
10
  * @extends HTMLAttributes<HTMLDivElement>
11
11
  */
12
- export declare const Datepicker: React.ForwardRefExoticComponent<IDatepickerProps & React.RefAttributes<HTMLDivElement>>;
12
+ export declare const DatePicker: React.ForwardRefExoticComponent<IDatePickerProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { Dispatch, ReactElement, RefAttributes } from 'react';
8
+ import { DatePickerAction, IDatePickerState } from '../utils/date-picker-reducer';
9
+ interface IInputProps {
10
+ dispatch: Dispatch<DatePickerAction>;
11
+ element: ReactElement & RefAttributes<HTMLInputElement>;
12
+ refKey: string;
13
+ state: IDatePickerState;
14
+ }
15
+ export declare const Input: import("react").ForwardRefExoticComponent<IInputProps & RefAttributes<HTMLInputElement>>;
16
+ export {};
@@ -4,13 +4,13 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { IDatepickerProps } from '../../../types';
8
- export interface IDatepickerState {
7
+ import { IDatePickerProps } from '../../../types';
8
+ export interface IDatePickerState {
9
9
  isOpen: boolean;
10
10
  previewDate: Date;
11
11
  inputValue: string;
12
12
  }
13
- export type DatepickerAction = {
13
+ export type DatePickerAction = {
14
14
  type: 'OPEN';
15
15
  } | {
16
16
  type: 'CLOSE';
@@ -36,8 +36,8 @@ export declare const datepickerReducer: ({ value, formatDate, locale, customPars
36
36
  locale: any;
37
37
  customParseDate?: ((inputValue: string) => Date) | undefined;
38
38
  onChange?: ((date: Date) => void) | undefined;
39
- }) => (state: IDatepickerState, action: DatepickerAction) => IDatepickerState;
39
+ }) => (state: IDatePickerState, action: DatePickerAction) => IDatePickerState;
40
40
  /**
41
- * Retrieve initial state for the Datepicker reducer
41
+ * Retrieve initial state for the DatePicker reducer
42
42
  */
43
- export declare function retrieveInitialState(initialProps: IDatepickerProps): IDatepickerState;
43
+ export declare function retrieveInitialState(initialProps: IDatePickerProps): IDatePickerState;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ /// <reference types="react" />
8
+ import { IDatePickerState, DatePickerAction } from './date-picker-reducer';
9
+ export interface IDatePickerContext {
10
+ state: IDatePickerState;
11
+ dispatch: React.Dispatch<DatePickerAction>;
12
+ }
13
+ export declare const DatePickerContext: import("react").Context<IDatePickerContext | undefined>;
14
+ /**
15
+ * Retrieve Dropdown component context
16
+ */
17
+ declare const useDatePickerContext: () => IDatePickerContext;
18
+ export default useDatePickerContext;
@@ -6,12 +6,12 @@
6
6
  */
7
7
  import React, { PropsWithChildren } from 'react';
8
8
  import PropTypes from 'prop-types';
9
- import { IDatepickerRangeProps } from '../../types';
9
+ import { IDatePickerRangeProps } from '../../types';
10
10
  import { Start } from './components/Start';
11
11
  import { End } from './components/End';
12
12
  import { Calendar } from './components/Calendar';
13
- export declare const DatepickerRange: {
14
- (props: PropsWithChildren<IDatepickerRangeProps>): React.JSX.Element;
13
+ export declare const DatePickerRange: {
14
+ (props: PropsWithChildren<IDatePickerRangeProps>): React.JSX.Element;
15
15
  propTypes: {
16
16
  locale: PropTypes.Requireable<string>;
17
17
  weekStartsOn: PropTypes.Requireable<number>;