@zohodesk/components 1.0.0-alpha-270 → 1.0.0-alpha-272
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 +16 -0
- package/es/Accordion/Accordion.js +7 -3
- package/es/Accordion/AccordionItem.js +4 -2
- package/es/Animation/Animation.js +3 -3
- package/es/AppContainer/AppContainer.js +13 -5
- package/es/Avatar/Avatar.js +23 -11
- package/es/AvatarTeam/AvatarTeam.js +3 -3
- package/es/Button/Button.js +4 -3
- package/es/Buttongroup/Buttongroup.js +3 -3
- package/es/Card/Card.js +21 -10
- package/es/CheckBox/CheckBox.js +5 -3
- package/es/DateTime/CalendarView.js +32 -20
- package/es/DateTime/DateTime.js +75 -10
- package/es/DateTime/DateTimePopupFooter.js +4 -2
- package/es/DateTime/DateTimePopupHeader.js +8 -2
- package/es/DateTime/DateWidget.js +98 -35
- package/es/DateTime/DaysRow.js +4 -2
- package/es/DateTime/Time.js +10 -2
- package/es/DateTime/YearView.js +28 -4
- package/es/DateTime/__tests__/CalendarView.spec.js +1 -0
- package/es/DateTime/__tests__/DateTime.spec.js +1 -0
- package/es/DateTime/__tests__/DateWidget.spec.js +2 -3
- package/es/DateTime/common.js +3 -0
- package/es/DateTime/constants.js +1 -0
- package/es/DateTime/dateFormatUtils/dateFormat.js +63 -30
- package/es/DateTime/dateFormatUtils/dateFormats.js +0 -1
- package/es/DateTime/dateFormatUtils/dayChange.js +13 -4
- package/es/DateTime/dateFormatUtils/index.js +32 -2
- package/es/DateTime/dateFormatUtils/monthChange.js +8 -0
- package/es/DateTime/dateFormatUtils/timeChange.js +22 -6
- package/es/DateTime/dateFormatUtils/yearChange.js +11 -2
- package/es/DateTime/objectUtils.js +14 -20
- package/es/DateTime/props/defaultProps.js +2 -1
- package/es/DateTime/typeChecker.js +3 -0
- package/es/DateTime/validator.js +58 -6
- package/es/DropBox/DropBox.js +9 -5
- package/es/DropBox/DropBoxElement/DropBoxElement.js +15 -6
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +9 -3
- package/es/DropBox/DropBoxElement/css/cssJSLogic.js +6 -4
- package/es/DropBox/DropBoxElement/props/propTypes.js +1 -1
- package/es/DropBox/DropBoxElement/useDropboxPosCalc.js +3 -0
- package/es/DropBox/__tests__/DropBox.spec.js +2 -2
- package/es/DropBox/props/defaultProps.js +1 -2
- package/es/DropBox/props/propTypes.js +1 -2
- package/es/DropDown/DropDown.js +8 -4
- package/es/DropDown/DropDownHeading.js +4 -5
- package/es/DropDown/DropDownItem.js +6 -0
- package/es/DropDown/DropDownSearch.js +4 -0
- package/es/DropDown/DropDownSeparator.js +1 -0
- package/es/DropDown/__tests__/DropDown.spec.js +1 -2
- package/es/Heading/Heading.js +2 -3
- package/es/Label/Label.js +2 -3
- package/es/Layout/Box.js +13 -0
- package/es/Layout/Container.js +12 -1
- package/es/Layout/index.js +1 -2
- package/es/ListItem/ListContainer.js +8 -3
- package/es/ListItem/ListItem.js +9 -3
- package/es/ListItem/ListItemWithAvatar.js +9 -3
- package/es/ListItem/ListItemWithCheckBox.js +7 -2
- package/es/ListItem/ListItemWithIcon.js +8 -3
- package/es/ListItem/ListItemWithRadio.js +7 -3
- package/es/Modal/Modal.js +28 -11
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +89 -13
- package/es/MultiSelect/AdvancedMultiSelect.js +32 -9
- package/es/MultiSelect/EmptyState.js +2 -0
- package/es/MultiSelect/MultiSelect.js +99 -32
- package/es/MultiSelect/MultiSelectHeader.js +3 -0
- package/es/MultiSelect/MultiSelectWithAvatar.js +12 -6
- package/es/MultiSelect/SelectedOptions.js +6 -3
- package/es/MultiSelect/Suggestions.js +7 -3
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +4 -6
- package/es/MultiSelect/props/propTypes.js +2 -0
- package/es/PopOver/PopOver.js +18 -2
- package/es/PopOver/__tests__/PopOver.spec.js +2 -1
- package/es/Popup/Popup.js +77 -24
- package/es/Popup/__tests__/Popup.spec.js +17 -5
- package/es/Popup/viewPort.js +16 -4
- package/es/Provider/IdProvider.js +10 -5
- package/es/Provider/LibraryContext.js +6 -4
- package/es/Provider/NumberGenerator/NumberGenerator.js +21 -7
- package/es/Provider/ZindexProvider.js +9 -2
- package/es/Radio/Radio.js +4 -2
- package/es/Responsive/CustomResponsive.js +30 -18
- package/es/Responsive/RefWrapper.js +6 -7
- package/es/Responsive/ResizeComponent.js +35 -25
- package/es/Responsive/ResizeObserver.js +26 -6
- package/es/Responsive/Responsive.js +34 -20
- package/es/Responsive/index.js +1 -3
- package/es/Responsive/sizeObservers.js +28 -7
- package/es/Responsive/utils/index.js +7 -5
- package/es/Responsive/utils/shallowCompare.js +7 -2
- package/es/Responsive/windowResizeObserver.js +7 -0
- package/es/ResponsiveDropBox/ResponsiveDropBox.js +4 -0
- package/es/Ribbon/Ribbon.js +3 -2
- package/es/RippleEffect/RippleEffect.js +1 -3
- package/es/Select/GroupSelect.js +58 -14
- package/es/Select/Select.js +79 -33
- package/es/Select/SelectWithAvatar.js +17 -4
- package/es/Select/SelectWithIcon.js +46 -5
- package/es/Select/__tests__/Select.spec.js +6 -8
- package/es/Select/props/propTypes.js +1 -0
- package/es/Stencils/Stencils.js +3 -3
- package/es/Switch/Switch.js +5 -3
- package/es/Tab/Tab.js +4 -4
- package/es/Tab/TabContent.js +1 -0
- package/es/Tab/TabContentWrapper.js +2 -0
- package/es/Tab/TabWrapper.js +5 -2
- package/es/Tab/Tabs.js +54 -7
- package/es/Tab/Tabs.module.css +2 -20
- package/es/Tab/__tests__/Tab.spec.js +1 -3
- package/es/Tab/__tests__/TabWrapper.spec.js +1 -0
- package/es/Tag/Tag.js +6 -3
- package/es/TextBox/TextBox.js +15 -3
- package/es/TextBox/__tests__/TextBox.spec.js +1 -4
- package/es/TextBoxIcon/TextBoxIcon.js +9 -2
- package/es/TextBoxIcon/__tests__/TextBoxIcon.spec.js +2 -7
- package/es/Textarea/Textarea.js +12 -3
- package/es/Textarea/__tests__/Textarea.spec.js +2 -2
- package/es/Tooltip/Tooltip.js +58 -14
- package/es/Tooltip/__tests__/Tooltip.spec.js +5 -0
- package/es/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +3 -2
- package/es/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +7 -5
- package/es/deprecated/PortalLayer/PortalLayer.js +25 -20
- package/es/semantic/Button/Button.js +3 -2
- package/es/utils/Common.js +58 -9
- package/es/utils/ContextOptimizer.js +4 -5
- package/es/utils/__tests__/debounce.spec.js +2 -2
- package/es/utils/constructFullName.js +2 -0
- package/es/utils/css/compileClassNames.js +5 -0
- package/es/utils/css/mergeStyle.js +7 -6
- package/es/utils/css/utils.js +1 -0
- package/es/utils/datetime/GMTZones.js +48 -0
- package/es/utils/datetime/common.js +31 -7
- package/es/utils/debounce.js +5 -1
- package/es/utils/dropDownUtils.js +68 -11
- package/es/utils/getInitial.js +4 -0
- package/es/utils/shallowEqual.js +6 -0
- package/lib/Accordion/Accordion.js +42 -18
- package/lib/Accordion/AccordionItem.js +40 -18
- package/lib/Accordion/__tests__/Accordion.spec.js +3 -0
- package/lib/Accordion/index.js +3 -0
- package/lib/Accordion/props/propTypes.js +3 -0
- package/lib/Animation/Animation.js +38 -18
- package/lib/Animation/__tests__/Animation.spec.js +11 -7
- package/lib/Animation/props/propTypes.js +3 -0
- package/lib/AppContainer/AppContainer.js +56 -21
- package/lib/AppContainer/props/propTypes.js +3 -0
- package/lib/Avatar/Avatar.js +78 -38
- package/lib/Avatar/__tests__/Avatar.spec.js +44 -0
- package/lib/Avatar/props/propTypes.js +3 -0
- package/lib/AvatarTeam/AvatarTeam.js +52 -30
- package/lib/AvatarTeam/__tests__/AvatarTeam.spec.js +13 -0
- package/lib/AvatarTeam/props/propTypes.js +3 -0
- package/lib/Button/Button.js +31 -20
- package/lib/Button/css/cssJSLogic.js +18 -17
- package/lib/Button/index.js +3 -0
- package/lib/Button/props/defaultProps.js +2 -0
- package/lib/Button/props/propTypes.js +3 -0
- package/lib/Buttongroup/Buttongroup.js +32 -12
- package/lib/Buttongroup/__test__/Buttongroup.spec.js +10 -0
- package/lib/Buttongroup/props/propTypes.js +3 -0
- package/lib/Card/Card.js +102 -46
- package/lib/Card/__tests__/Card.spec.js +10 -1
- package/lib/Card/index.js +4 -0
- package/lib/Card/props/propTypes.js +3 -0
- package/lib/CheckBox/CheckBox.js +71 -47
- package/lib/CheckBox/__tests__/CheckBox.spec.js +3 -0
- package/lib/CheckBox/props/propTypes.js +3 -0
- package/lib/DateTime/CalendarView.js +82 -42
- package/lib/DateTime/DateTime.js +246 -158
- package/lib/DateTime/DateTimePopupFooter.js +31 -8
- package/lib/DateTime/DateTimePopupHeader.js +48 -17
- package/lib/DateTime/DateWidget.js +352 -250
- package/lib/DateTime/DaysRow.js +27 -5
- package/lib/DateTime/Time.js +73 -32
- package/lib/DateTime/YearView.js +77 -28
- package/lib/DateTime/__tests__/CalendarView.spec.js +13 -5
- package/lib/DateTime/__tests__/DateTime.spec.js +51 -37
- package/lib/DateTime/__tests__/DateWidget.spec.js +10 -8
- package/lib/DateTime/common.js +6 -0
- package/lib/DateTime/constants.js +1 -0
- package/lib/DateTime/dateFormatUtils/dateFormat.js +184 -122
- package/lib/DateTime/dateFormatUtils/dateFormats.js +0 -1
- package/lib/DateTime/dateFormatUtils/dayChange.js +14 -7
- package/lib/DateTime/dateFormatUtils/index.js +74 -16
- package/lib/DateTime/dateFormatUtils/monthChange.js +19 -9
- package/lib/DateTime/dateFormatUtils/timeChange.js +54 -22
- package/lib/DateTime/dateFormatUtils/yearChange.js +22 -11
- package/lib/DateTime/index.js +2 -0
- package/lib/DateTime/objectUtils.js +24 -20
- package/lib/DateTime/props/defaultProps.js +2 -1
- package/lib/DateTime/props/propTypes.js +11 -1
- package/lib/DateTime/typeChecker.js +4 -0
- package/lib/DateTime/validator.js +73 -10
- package/lib/DropBox/DropBox.js +36 -12
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +65 -42
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +9 -3
- package/lib/DropBox/DropBoxElement/css/cssJSLogic.js +43 -34
- package/lib/DropBox/DropBoxElement/props/propTypes.js +4 -1
- package/lib/DropBox/DropBoxElement/useDropboxPosCalc.js +14 -9
- package/lib/DropBox/__tests__/DropBox.spec.js +8 -4
- package/lib/DropBox/css/cssJSLogic.js +3 -1
- package/lib/DropBox/props/defaultProps.js +8 -4
- package/lib/DropBox/props/propTypes.js +10 -4
- package/lib/DropDown/DropDown.js +52 -8
- package/lib/DropDown/DropDownHeading.js +39 -20
- package/lib/DropDown/DropDownItem.js +42 -20
- package/lib/DropDown/DropDownSearch.js +40 -17
- package/lib/DropDown/DropDownSeparator.js +24 -4
- package/lib/DropDown/__tests__/DropDown.spec.js +15 -9
- package/lib/DropDown/__tests__/DropDownItem.spec.js +9 -4
- package/lib/DropDown/__tests__/DropDownSearch.spec.js +3 -0
- package/lib/DropDown/index.js +9 -0
- package/lib/DropDown/props/propTypes.js +6 -4
- package/lib/Heading/Heading.js +37 -15
- package/lib/Heading/props/propTypes.js +3 -0
- package/lib/Label/Label.js +39 -19
- package/lib/Label/__tests__/Label.spec.js +14 -1
- package/lib/Label/props/propTypes.js +3 -0
- package/lib/Layout/Box.js +31 -11
- package/lib/Layout/Container.js +29 -10
- package/lib/Layout/__tests__/Box.spec.js +65 -49
- package/lib/Layout/__tests__/Container.spec.js +67 -50
- package/lib/Layout/index.js +3 -0
- package/lib/Layout/props/propTypes.js +3 -0
- package/lib/Layout/utils.js +10 -0
- package/lib/ListItem/ListContainer.js +48 -27
- package/lib/ListItem/ListItem.js +69 -45
- package/lib/ListItem/ListItemWithAvatar.js +75 -48
- package/lib/ListItem/ListItemWithCheckBox.js +64 -39
- package/lib/ListItem/ListItemWithIcon.js +68 -44
- package/lib/ListItem/ListItemWithRadio.js +65 -41
- package/lib/ListItem/index.js +7 -0
- package/lib/ListItem/props/propTypes.js +6 -4
- package/lib/Modal/Modal.js +45 -10
- package/lib/Modal/props/propTypes.js +3 -0
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +294 -166
- package/lib/MultiSelect/AdvancedMultiSelect.js +202 -125
- package/lib/MultiSelect/EmptyState.js +45 -24
- package/lib/MultiSelect/MultiSelect.js +323 -206
- package/lib/MultiSelect/MultiSelectHeader.js +30 -8
- package/lib/MultiSelect/MultiSelectWithAvatar.js +105 -63
- package/lib/MultiSelect/SelectedOptions.js +43 -17
- package/lib/MultiSelect/Suggestions.js +64 -32
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +86 -75
- package/lib/MultiSelect/index.js +5 -0
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +5 -0
- package/lib/PopOver/PopOver.js +95 -49
- package/lib/PopOver/__tests__/PopOver.spec.js +4 -1
- package/lib/PopOver/index.js +4 -0
- package/lib/PopOver/props/propTypes.js +3 -0
- package/lib/Popup/Popup.js +158 -81
- package/lib/Popup/__tests__/Popup.spec.js +43 -8
- package/lib/Popup/viewPort.js +28 -14
- package/lib/Provider/AvatarSize.js +4 -0
- package/lib/Provider/Config.js +2 -0
- package/lib/Provider/CssProvider.js +4 -0
- package/lib/Provider/IdProvider.js +17 -6
- package/lib/Provider/LibraryContext.js +35 -15
- package/lib/Provider/LibraryContextInit.js +4 -0
- package/lib/Provider/NumberGenerator/NumberGenerator.js +44 -15
- package/lib/Provider/ZindexProvider.js +15 -3
- package/lib/Provider/index.js +5 -0
- package/lib/Radio/Radio.js +61 -38
- package/lib/Radio/__tests__/Radiospec.js +9 -5
- package/lib/Radio/props/propTypes.js +3 -0
- package/lib/Responsive/CustomResponsive.js +73 -29
- package/lib/Responsive/RefWrapper.js +17 -11
- package/lib/Responsive/ResizeComponent.js +62 -36
- package/lib/Responsive/ResizeObserver.js +24 -10
- package/lib/Responsive/Responsive.js +80 -30
- package/lib/Responsive/index.js +4 -0
- package/lib/Responsive/props/propTypes.js +3 -0
- package/lib/Responsive/sizeObservers.js +53 -17
- package/lib/Responsive/utils/index.js +11 -3
- package/lib/Responsive/utils/shallowCompare.js +11 -2
- package/lib/Responsive/windowResizeObserver.js +8 -0
- package/lib/ResponsiveDropBox/ResponsiveDropBox.js +45 -17
- package/lib/ResponsiveDropBox/props/propTypes.js +3 -0
- package/lib/Ribbon/Ribbon.js +33 -13
- package/lib/Ribbon/__tests__/Ribbon.spec.js +22 -0
- package/lib/Ribbon/props/propTypes.js +3 -0
- package/lib/RippleEffect/RippleEffect.js +18 -10
- package/lib/RippleEffect/props/propTypes.js +3 -0
- package/lib/Select/GroupSelect.js +229 -130
- package/lib/Select/Select.js +290 -209
- package/lib/Select/SelectWithAvatar.js +102 -56
- package/lib/Select/SelectWithIcon.js +132 -76
- package/lib/Select/__tests__/Select.spec.js +133 -91
- package/lib/Select/index.js +5 -0
- package/lib/Select/props/defaultProps.js +5 -4
- package/lib/Select/props/propTypes.js +4 -0
- package/lib/Stencils/Stencils.js +29 -10
- package/lib/Stencils/__tests__/Stencils.spec.js +12 -0
- package/lib/Stencils/props/propTypes.js +3 -0
- package/lib/Switch/Switch.js +57 -34
- package/lib/Switch/props/propTypes.js +3 -0
- package/lib/Tab/Tab.js +40 -27
- package/lib/Tab/TabContent.js +12 -5
- package/lib/Tab/TabContentWrapper.js +13 -6
- package/lib/Tab/TabWrapper.js +37 -19
- package/lib/Tab/Tabs.js +171 -91
- package/lib/Tab/Tabs.module.css +2 -20
- package/lib/Tab/__tests__/Tab.spec.js +67 -58
- package/lib/Tab/__tests__/TabContent.spec.js +10 -6
- package/lib/Tab/__tests__/TabContentWrapper.spec.js +28 -20
- package/lib/Tab/__tests__/TabWrapper.spec.js +12 -0
- package/lib/Tab/__tests__/Tabs.spec.js +53 -39
- package/lib/Tab/index.js +6 -0
- package/lib/Tab/props/propTypes.js +3 -0
- package/lib/Tag/Tag.js +72 -43
- package/lib/Tag/__tests__/Tag.spec.js +14 -8
- package/lib/Tag/props/propTypes.js +3 -0
- package/lib/TextBox/TextBox.js +85 -59
- package/lib/TextBox/__tests__/TextBox.spec.js +14 -4
- package/lib/TextBox/props/propTypes.js +6 -4
- package/lib/TextBoxIcon/TextBoxIcon.js +79 -52
- package/lib/TextBoxIcon/__tests__/TextBoxIcon.spec.js +14 -5
- package/lib/TextBoxIcon/props/propTypes.js +3 -0
- package/lib/Textarea/Textarea.js +54 -29
- package/lib/Textarea/__tests__/Textarea.spec.js +14 -2
- package/lib/Textarea/props/propTypes.js +3 -0
- package/lib/Tooltip/Tooltip.js +94 -31
- package/lib/Tooltip/__tests__/Tooltip.spec.js +24 -3
- package/lib/Tooltip/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +40 -16
- package/lib/VelocityAnimation/VelocityAnimation/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +53 -25
- package/lib/VelocityAnimation/VelocityAnimationGroup/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/index.js +3 -0
- package/lib/css.js +40 -0
- package/lib/deprecated/PortalLayer/PortalLayer.js +46 -23
- package/lib/deprecated/PortalLayer/props/propTypes.js +3 -0
- package/lib/index.js +57 -0
- package/lib/semantic/Button/Button.js +42 -22
- package/lib/semantic/Button/props/propTypes.js +3 -0
- package/lib/semantic/index.js +2 -0
- package/lib/utils/Common.js +117 -19
- package/lib/utils/ContextOptimizer.js +16 -10
- package/lib/utils/__tests__/constructFullName.spec.js +1 -0
- package/lib/utils/__tests__/debounce.spec.js +3 -2
- package/lib/utils/__tests__/getInitial.spec.js +1 -0
- package/lib/utils/constructFullName.js +13 -4
- package/lib/utils/css/compileClassNames.js +6 -0
- package/lib/utils/css/mergeStyle.js +10 -7
- package/lib/utils/css/utils.js +8 -0
- package/lib/utils/datetime/GMTZones.js +55 -0
- package/lib/utils/datetime/common.js +52 -7
- package/lib/utils/debounce.js +6 -1
- package/lib/utils/dropDownUtils.js +175 -59
- package/lib/utils/dummyFunction.js +2 -0
- package/lib/utils/getHTMLFontSize.js +1 -0
- package/lib/utils/getInitial.js +6 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/scrollTo.js +2 -0
- package/lib/utils/shallowEqual.js +8 -0
- package/package.json +1 -1
package/es/DateTime/YearView.js
CHANGED
|
@@ -2,34 +2,40 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { YearView_propTypes } from './props/propTypes';
|
|
4
4
|
import { YearView_defaultProps } from './props/defaultProps';
|
|
5
|
-
|
|
6
5
|
/**** Components ****/
|
|
6
|
+
|
|
7
7
|
import { Virtualizer } from '@zohodesk/virtualizer';
|
|
8
8
|
import { Container, Box } from '../Layout';
|
|
9
9
|
import { Icon } from '@zohodesk/icons';
|
|
10
10
|
import Heading from '../Heading/Heading';
|
|
11
11
|
/**** CSS ****/
|
|
12
|
-
import style from './YearView.module.css';
|
|
13
12
|
|
|
13
|
+
import style from './YearView.module.css';
|
|
14
14
|
/**** Methods ****/
|
|
15
|
+
|
|
15
16
|
import { getYearDetails } from './dateFormatUtils';
|
|
16
17
|
const monthNamesData = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
18
|
+
|
|
17
19
|
function getYears() {
|
|
18
20
|
const years = [];
|
|
19
21
|
const {
|
|
20
22
|
startPoint,
|
|
21
23
|
endPoint
|
|
22
24
|
} = getYearDetails();
|
|
25
|
+
|
|
23
26
|
for (let i = startPoint; i <= endPoint; i++) {
|
|
24
27
|
years.push(i);
|
|
25
28
|
}
|
|
29
|
+
|
|
26
30
|
return years;
|
|
27
31
|
}
|
|
32
|
+
|
|
28
33
|
class Year extends React.PureComponent {
|
|
29
34
|
constructor(props) {
|
|
30
35
|
super(props);
|
|
31
36
|
this.handleClick = this.handleClick.bind(this);
|
|
32
37
|
}
|
|
38
|
+
|
|
33
39
|
handleClick() {
|
|
34
40
|
const {
|
|
35
41
|
year,
|
|
@@ -37,6 +43,7 @@ class Year extends React.PureComponent {
|
|
|
37
43
|
} = this.props;
|
|
38
44
|
onClick && onClick(year);
|
|
39
45
|
}
|
|
46
|
+
|
|
40
47
|
render() {
|
|
41
48
|
const {
|
|
42
49
|
year,
|
|
@@ -66,12 +73,15 @@ class Year extends React.PureComponent {
|
|
|
66
73
|
iconClass: isOpen ? `${style.arrow} ${style.arrowActive}` : style.arrow
|
|
67
74
|
})));
|
|
68
75
|
}
|
|
76
|
+
|
|
69
77
|
}
|
|
78
|
+
|
|
70
79
|
class Month extends React.PureComponent {
|
|
71
80
|
constructor(props) {
|
|
72
81
|
super(props);
|
|
73
82
|
this.handleClick = this.handleClick.bind(this);
|
|
74
83
|
}
|
|
84
|
+
|
|
75
85
|
handleClick() {
|
|
76
86
|
const {
|
|
77
87
|
month,
|
|
@@ -81,6 +91,7 @@ class Month extends React.PureComponent {
|
|
|
81
91
|
monthIndex = monthIndex === -1 ? 0 : monthIndex;
|
|
82
92
|
onClick && onClick(monthIndex);
|
|
83
93
|
}
|
|
94
|
+
|
|
84
95
|
render() {
|
|
85
96
|
const {
|
|
86
97
|
month,
|
|
@@ -96,7 +107,9 @@ class Month extends React.PureComponent {
|
|
|
96
107
|
"aria-label": month
|
|
97
108
|
}, displayText);
|
|
98
109
|
}
|
|
110
|
+
|
|
99
111
|
}
|
|
112
|
+
|
|
100
113
|
export default class YearView extends React.PureComponent {
|
|
101
114
|
constructor(props) {
|
|
102
115
|
super(props);
|
|
@@ -111,10 +124,12 @@ export default class YearView extends React.PureComponent {
|
|
|
111
124
|
localYear: ''
|
|
112
125
|
};
|
|
113
126
|
}
|
|
127
|
+
|
|
114
128
|
componentDidMount() {
|
|
115
129
|
this.handleScrollToYear(this.props);
|
|
116
130
|
this.handleUpdateLocalYear(this.props);
|
|
117
131
|
}
|
|
132
|
+
|
|
118
133
|
componentDidUpdate(prevProps) {
|
|
119
134
|
let {
|
|
120
135
|
viewedYear
|
|
@@ -124,11 +139,13 @@ export default class YearView extends React.PureComponent {
|
|
|
124
139
|
viewedYear: oldViewedYear
|
|
125
140
|
} = prevProps;
|
|
126
141
|
oldViewedYear = parseInt(oldViewedYear) || 0;
|
|
142
|
+
|
|
127
143
|
if (viewedYear !== oldViewedYear) {
|
|
128
144
|
this.handleScrollToYear(this.props);
|
|
129
145
|
this.handleUpdateLocalYear(this.props);
|
|
130
146
|
}
|
|
131
147
|
}
|
|
148
|
+
|
|
132
149
|
handleUpdateLocalYear(props) {
|
|
133
150
|
let {
|
|
134
151
|
viewedYear
|
|
@@ -140,6 +157,7 @@ export default class YearView extends React.PureComponent {
|
|
|
140
157
|
});
|
|
141
158
|
}, 150);
|
|
142
159
|
}
|
|
160
|
+
|
|
143
161
|
handleScrollToYear(props) {
|
|
144
162
|
const {
|
|
145
163
|
years = [],
|
|
@@ -154,24 +172,28 @@ export default class YearView extends React.PureComponent {
|
|
|
154
172
|
duration: 0
|
|
155
173
|
});
|
|
156
174
|
}
|
|
175
|
+
|
|
157
176
|
getPublicMethods(methods) {
|
|
158
177
|
const {
|
|
159
178
|
scrollToIndex
|
|
160
179
|
} = methods;
|
|
161
180
|
this.scrollToIndex = scrollToIndex;
|
|
162
181
|
}
|
|
182
|
+
|
|
163
183
|
handleMonthClick(month) {
|
|
164
184
|
const {
|
|
165
185
|
onSelectMonth
|
|
166
186
|
} = this.props;
|
|
167
187
|
onSelectMonth && onSelectMonth(month);
|
|
168
188
|
}
|
|
189
|
+
|
|
169
190
|
handleYearClick(year) {
|
|
170
191
|
const {
|
|
171
192
|
onSelectYear
|
|
172
193
|
} = this.props;
|
|
173
194
|
onSelectYear && onSelectYear(year);
|
|
174
195
|
}
|
|
196
|
+
|
|
175
197
|
renderListItem(_ref) {
|
|
176
198
|
let {
|
|
177
199
|
index,
|
|
@@ -218,11 +240,12 @@ export default class YearView extends React.PureComponent {
|
|
|
218
240
|
month: month,
|
|
219
241
|
onClick: this.handleMonthClick,
|
|
220
242
|
isActive: monthIndex === viewedMonth,
|
|
221
|
-
displayText: monthNamesShort[index]
|
|
222
|
-
|
|
243
|
+
displayText: monthNamesShort[index] // hoverText={monthNames[index]}
|
|
244
|
+
|
|
223
245
|
});
|
|
224
246
|
}))) : null);
|
|
225
247
|
}
|
|
248
|
+
|
|
226
249
|
render() {
|
|
227
250
|
const {
|
|
228
251
|
years = []
|
|
@@ -236,6 +259,7 @@ export default class YearView extends React.PureComponent {
|
|
|
236
259
|
dataId: "yearList"
|
|
237
260
|
});
|
|
238
261
|
}
|
|
262
|
+
|
|
239
263
|
}
|
|
240
264
|
YearView.propTypes = YearView_propTypes;
|
|
241
265
|
YearView.defaultProps = YearView_defaultProps;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
|
+
|
|
2
3
|
/*eslint-disable no-unused-vars*/
|
|
3
4
|
import DateWidget from '../DateWidget';
|
|
4
5
|
import React from 'react';
|
|
@@ -50,9 +51,7 @@ describe('DateWidgetComponent testing', () => {
|
|
|
50
51
|
}));
|
|
51
52
|
let dropboxComponent = TestUtils.scryRenderedComponentsWithTestid(renderedDOM, 'dateWidget_dateBoxContainer');
|
|
52
53
|
expect(dropboxComponent.length).toBe(0);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// it('Should render dateTime if isReadOnly is false', () => {
|
|
54
|
+
}); // it('Should render dateTime if isReadOnly is false', () => {
|
|
56
55
|
// const { props, renderedDOM } = setup(DateWidget, Object.assign({}, defaultProps, { isReadOnly: false }));
|
|
57
56
|
// let dropboxComponent = TestUtils.scryRenderedComponentsWithTestid(
|
|
58
57
|
// renderedDOM,
|
package/es/DateTime/common.js
CHANGED
|
@@ -2,6 +2,7 @@ export function bind() {
|
|
|
2
2
|
for (var _len = arguments.length, handlers = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3
3
|
handlers[_key] = arguments[_key];
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
handlers.forEach(handler => {
|
|
6
7
|
this[handler] = this[handler].bind(this);
|
|
7
8
|
});
|
|
@@ -12,11 +13,13 @@ export function formatValue() {
|
|
|
12
13
|
let textField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'name';
|
|
13
14
|
return values && values.map(value => {
|
|
14
15
|
let formattedValue = value;
|
|
16
|
+
|
|
15
17
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
16
18
|
formattedValue = {};
|
|
17
19
|
formattedValue[valueField] = value;
|
|
18
20
|
formattedValue[textField] = value;
|
|
19
21
|
}
|
|
22
|
+
|
|
20
23
|
return formattedValue;
|
|
21
24
|
}) || [];
|
|
22
25
|
}
|
package/es/DateTime/constants.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
/** * Libraries ** */
|
|
4
4
|
import datetime from '@zohodesk/datetimejs';
|
|
5
|
-
|
|
6
5
|
/** * Methods ** */
|
|
6
|
+
|
|
7
7
|
import { getDayEnd, convertYearToTwoDigit, addZero, getMonthDetails, getYearDetails, getDayDetails, getHourDetails, getMinuteDetails, getNoonDetails, getIsCurrentYear, removeYearPattern } from './index';
|
|
8
8
|
import { getIsEmptyValue } from '../../utils/Common';
|
|
9
9
|
import { formatDate } from '../../utils/datetime/common';
|
|
10
|
-
|
|
11
10
|
/** * Constants ** */
|
|
12
|
-
|
|
13
|
-
// patternChangeStr,
|
|
11
|
+
|
|
12
|
+
import { defaultFormat, supportedPatterns, // patternChangeStr,
|
|
14
13
|
patternSplitStr, INCONSTANT, flags } from '../constants';
|
|
14
|
+
|
|
15
15
|
function getDateFormatString() {
|
|
16
16
|
let dateFormatArr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
17
17
|
let datePatternArr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -21,19 +21,23 @@ function getDateFormatString() {
|
|
|
21
21
|
return res;
|
|
22
22
|
}, '');
|
|
23
23
|
}
|
|
24
|
+
|
|
24
25
|
function getIsValidPattern() {
|
|
25
26
|
let dateFormatArr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
26
27
|
let datePatternArr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
28
|
+
|
|
27
29
|
const isValueInArray = function () {
|
|
28
30
|
let possibleFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
29
31
|
return possibleFormat.some(str => dateFormatArr.indexOf(str) >= 0);
|
|
30
32
|
};
|
|
33
|
+
|
|
31
34
|
const haveDay = isValueInArray(flags.day);
|
|
32
35
|
const haveMonth = isValueInArray(flags.month);
|
|
33
36
|
const haveYear = isValueInArray(flags.year);
|
|
34
37
|
const isValidPattern = datePatternArr.length && datePatternArr.length <= 2 && datePatternArr.every(patternStr => supportedPatterns.indexOf(patternStr) >= 0);
|
|
35
38
|
return haveDay && haveMonth && (haveYear || !haveYear) && isValidPattern;
|
|
36
39
|
}
|
|
40
|
+
|
|
37
41
|
export function getDateFormatDetails() {
|
|
38
42
|
let dateFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
39
43
|
let {
|
|
@@ -55,17 +59,20 @@ export function getDateFormatDetails() {
|
|
|
55
59
|
isDateTime
|
|
56
60
|
});
|
|
57
61
|
const isHideYear = isHideCurrentYear ? isCurrentYear : false;
|
|
62
|
+
|
|
58
63
|
function getDateFormat(dateFormat) {
|
|
59
64
|
const token = /D{1,4}|M{1,4}|YY(?:YY)?|([HhmsA])\1?|[LloSZWN]|\[[^\]]*\]|'[^']*'/gi;
|
|
60
65
|
dateFormatArr = [];
|
|
61
66
|
patternArr = [];
|
|
62
67
|
const newDateFormat = dateFormat.replace(token, match => {
|
|
63
68
|
const dateFormatArrLen = dateFormatArr.length;
|
|
69
|
+
|
|
64
70
|
if (match in flags) {
|
|
65
71
|
dateFormatArr.push(match);
|
|
66
72
|
const {
|
|
67
73
|
type
|
|
68
74
|
} = flags[match];
|
|
75
|
+
|
|
69
76
|
if (type === 'day') {
|
|
70
77
|
dayInfo = Object.assign({}, flags[match], {
|
|
71
78
|
index: dateFormatArrLen
|
|
@@ -79,28 +86,35 @@ export function getDateFormatDetails() {
|
|
|
79
86
|
index: dateFormatArrLen
|
|
80
87
|
});
|
|
81
88
|
}
|
|
89
|
+
|
|
82
90
|
return patternSplitStr;
|
|
83
91
|
}
|
|
92
|
+
|
|
84
93
|
return match.slice(1, match.length - 1);
|
|
85
94
|
});
|
|
86
95
|
patternArr = newDateFormat.split(patternSplitStr).reduce((res, patternStr) => {
|
|
87
96
|
if (patternStr) {
|
|
88
97
|
res.push(patternStr);
|
|
89
98
|
}
|
|
99
|
+
|
|
90
100
|
return res;
|
|
91
101
|
}, []);
|
|
92
102
|
}
|
|
103
|
+
|
|
93
104
|
getDateFormat(dateFormat);
|
|
94
105
|
const isValidPattern = getIsValidPattern(dateFormatArr, patternArr);
|
|
106
|
+
|
|
95
107
|
if (!isValidPattern) {
|
|
96
108
|
getDateFormat(defaultFormat);
|
|
97
109
|
}
|
|
110
|
+
|
|
98
111
|
if (isHideYear) {
|
|
99
112
|
({
|
|
100
113
|
dateFormatArr,
|
|
101
114
|
patternArr
|
|
102
115
|
} = removeYearPattern(dateFormatArr, patternArr));
|
|
103
116
|
}
|
|
117
|
+
|
|
104
118
|
return {
|
|
105
119
|
dateFormat: getDateFormatString(dateFormatArr, patternArr),
|
|
106
120
|
dateFormatArr,
|
|
@@ -111,6 +125,7 @@ export function getDateFormatDetails() {
|
|
|
111
125
|
isValidPattern
|
|
112
126
|
};
|
|
113
127
|
}
|
|
128
|
+
|
|
114
129
|
function getDisplayFormatValue(dateVal, formatVal) {
|
|
115
130
|
let {
|
|
116
131
|
i18nShortMonths = [],
|
|
@@ -120,18 +135,22 @@ function getDisplayFormatValue(dateVal, formatVal) {
|
|
|
120
135
|
length,
|
|
121
136
|
type
|
|
122
137
|
} = flags[formatVal] || {};
|
|
138
|
+
|
|
123
139
|
if (length === INCONSTANT) {
|
|
124
140
|
if (dateVal && formatVal === 'MMM' && i18nShortMonths.length) {
|
|
125
141
|
return i18nShortMonths[dateVal - 1];
|
|
126
142
|
} else if (dateVal && formatVal === 'MMMM' && i18nMonths.length) {
|
|
127
143
|
return i18nMonths[dateVal - 1];
|
|
128
144
|
}
|
|
145
|
+
|
|
129
146
|
return addZero(dateVal, formatVal.length ? formatVal.length : 1);
|
|
130
147
|
} else if (type === 'year' && length === 2) {
|
|
131
148
|
return addZero(convertYearToTwoDigit(dateVal), length);
|
|
132
149
|
}
|
|
150
|
+
|
|
133
151
|
return addZero(dateVal, length);
|
|
134
152
|
}
|
|
153
|
+
|
|
135
154
|
function concatDate(values, dateFormatArr, patternArr, fillPlaceHolder) {
|
|
136
155
|
let {
|
|
137
156
|
i18nShortMonths,
|
|
@@ -152,6 +171,7 @@ function concatDate(values, dateFormatArr, patternArr, fillPlaceHolder) {
|
|
|
152
171
|
}, '');
|
|
153
172
|
return dateString;
|
|
154
173
|
}
|
|
174
|
+
|
|
155
175
|
export function getDateTimeString() {
|
|
156
176
|
let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
157
177
|
let dateFormatDetails = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -184,11 +204,13 @@ export function getDateTimeString() {
|
|
|
184
204
|
i18nMonths
|
|
185
205
|
});
|
|
186
206
|
let timeString = '';
|
|
207
|
+
|
|
187
208
|
if (isDateTime) {
|
|
188
209
|
hour = !getIsEmptyValue(hour) ? addZero(hour, 2) : is24Hour ? 'HH' : 'hh';
|
|
189
210
|
minute = !getIsEmptyValue(minute) ? addZero(minute, 2) : 'mm';
|
|
190
211
|
timeString = ` ${hour}:${minute} ${is24Hour ? '' : `${noon || '--'}`}`;
|
|
191
212
|
}
|
|
213
|
+
|
|
192
214
|
return `${dateString}${timeString}`;
|
|
193
215
|
}
|
|
194
216
|
export function getDateDetails(value, localValues, isDateTime, timeZone, _ref) {
|
|
@@ -203,6 +225,7 @@ export function getDateDetails(value, localValues, isDateTime, timeZone, _ref) {
|
|
|
203
225
|
minute,
|
|
204
226
|
noon
|
|
205
227
|
} = localValues;
|
|
228
|
+
|
|
206
229
|
if (value) {
|
|
207
230
|
const dateObj = isDateTime ? datetime.toDate(datetime.tz.utcToTz(value, timeZone)) : value ? datetime.toDate(value) : new Date();
|
|
208
231
|
const selectedDay = dateObj.getDate();
|
|
@@ -211,13 +234,16 @@ export function getDateDetails(value, localValues, isDateTime, timeZone, _ref) {
|
|
|
211
234
|
const newDay = day ? day : selectedDay;
|
|
212
235
|
const newMonth = month ? month : selectedMonth + 1;
|
|
213
236
|
const newYear = year ? year : selectedYear;
|
|
237
|
+
|
|
214
238
|
if (isDateTime) {
|
|
215
239
|
let selectedHour = dateObj.getHours();
|
|
216
240
|
const selectedMinute = dateObj.getMinutes();
|
|
217
241
|
const selectedNoon = selectedHour < 12 ? 'AM' : 'PM';
|
|
242
|
+
|
|
218
243
|
if (!is24Hour) {
|
|
219
244
|
selectedHour = selectedHour === 0 ? 12 : selectedHour > 12 ? selectedHour - 12 : selectedHour;
|
|
220
245
|
}
|
|
246
|
+
|
|
221
247
|
const newHour = hour ? hour : selectedHour;
|
|
222
248
|
const newMinute = minute ? minute : selectedMinute;
|
|
223
249
|
const newNoon = noon ? noon : selectedNoon;
|
|
@@ -230,12 +256,14 @@ export function getDateDetails(value, localValues, isDateTime, timeZone, _ref) {
|
|
|
230
256
|
noon: newNoon
|
|
231
257
|
};
|
|
232
258
|
}
|
|
259
|
+
|
|
233
260
|
return {
|
|
234
261
|
day: newDay,
|
|
235
262
|
month: newMonth,
|
|
236
263
|
year: newYear
|
|
237
264
|
};
|
|
238
265
|
}
|
|
266
|
+
|
|
239
267
|
return localValues;
|
|
240
268
|
}
|
|
241
269
|
export function getIsValidDate(values, isDateTime, _ref2) {
|
|
@@ -259,6 +287,7 @@ export function getIsValidDate(values, isDateTime, _ref2) {
|
|
|
259
287
|
const value = parseInt(val);
|
|
260
288
|
return getIsEmptyValue(value);
|
|
261
289
|
}
|
|
290
|
+
|
|
262
291
|
return getIsEmptyValue(val);
|
|
263
292
|
});
|
|
264
293
|
const haveAllValues = valuesArr.every((val, index) => {
|
|
@@ -274,8 +303,10 @@ export function getIsValidDate(values, isDateTime, _ref2) {
|
|
|
274
303
|
} else if (val) {
|
|
275
304
|
return true;
|
|
276
305
|
}
|
|
306
|
+
|
|
277
307
|
return false;
|
|
278
308
|
});
|
|
309
|
+
|
|
279
310
|
if (haveAllValues) {
|
|
280
311
|
const dayEnd = getDayEnd(month, year);
|
|
281
312
|
const {
|
|
@@ -300,6 +331,7 @@ export function getIsValidDate(values, isDateTime, _ref2) {
|
|
|
300
331
|
const {
|
|
301
332
|
allowedValues: noonAllowedValues
|
|
302
333
|
} = getNoonDetails();
|
|
334
|
+
|
|
303
335
|
if (dayEnd < day || dayStart > day) {
|
|
304
336
|
isError = true;
|
|
305
337
|
message = 'Wrong Day';
|
|
@@ -323,6 +355,7 @@ export function getIsValidDate(values, isDateTime, _ref2) {
|
|
|
323
355
|
isError = true;
|
|
324
356
|
message = 'Empty value';
|
|
325
357
|
}
|
|
358
|
+
|
|
326
359
|
return {
|
|
327
360
|
isError,
|
|
328
361
|
message,
|
|
@@ -347,21 +380,25 @@ export function getSelectedDate(values, props) {
|
|
|
347
380
|
isDateTime,
|
|
348
381
|
is24Hour
|
|
349
382
|
} = props;
|
|
383
|
+
|
|
350
384
|
if (!is24Hour) {
|
|
351
385
|
if (parseInt(hour) === 12) {
|
|
352
386
|
hour = noon === 'AM' ? 0 : 12;
|
|
353
387
|
}
|
|
388
|
+
|
|
354
389
|
if (noon === 'PM') {
|
|
355
390
|
if (hour < 12) {
|
|
356
391
|
hour = parseInt(hour) + 12;
|
|
357
392
|
}
|
|
358
393
|
}
|
|
359
394
|
}
|
|
395
|
+
|
|
360
396
|
month = parseInt(month) - 1;
|
|
361
397
|
const minInMillis = min ? datetime.millis(min) : null,
|
|
362
|
-
|
|
398
|
+
maxInMillis = max ? datetime.millis(max) : null;
|
|
363
399
|
let selectedInMillis,
|
|
364
|
-
|
|
400
|
+
selectedValue = '';
|
|
401
|
+
|
|
365
402
|
if (isDateTime) {
|
|
366
403
|
selectedInMillis = datetime.tz.tzToUtc(Date.UTC(year, month, date, hour, mins), timeZone);
|
|
367
404
|
selectedValue = datetime.ISO(selectedInMillis);
|
|
@@ -369,8 +406,10 @@ export function getSelectedDate(values, props) {
|
|
|
369
406
|
selectedInMillis = Date.UTC(year, month, date);
|
|
370
407
|
selectedValue = formatDate(new Date(year, month, date), 'YYYY-MM-DD');
|
|
371
408
|
}
|
|
409
|
+
|
|
372
410
|
let isError = false;
|
|
373
411
|
let errorType = '';
|
|
412
|
+
|
|
374
413
|
if (minInMillis && minInMillis > selectedInMillis) {
|
|
375
414
|
isError = true;
|
|
376
415
|
errorType = 'MIN';
|
|
@@ -378,12 +417,14 @@ export function getSelectedDate(values, props) {
|
|
|
378
417
|
isError = true;
|
|
379
418
|
errorType = 'MAX';
|
|
380
419
|
}
|
|
420
|
+
|
|
381
421
|
return {
|
|
382
422
|
isError,
|
|
383
423
|
errorType,
|
|
384
424
|
selectedValue: selectedValue
|
|
385
425
|
};
|
|
386
426
|
}
|
|
427
|
+
|
|
387
428
|
function getDateFormatLength(type, length) {
|
|
388
429
|
let formatVal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
389
430
|
let {
|
|
@@ -412,16 +453,20 @@ function getDateFormatLength(type, length) {
|
|
|
412
453
|
}, isDateTime, timeZone, {
|
|
413
454
|
is24Hour
|
|
414
455
|
});
|
|
456
|
+
|
|
415
457
|
if (length === INCONSTANT) {
|
|
416
458
|
if (selectedMonth && formatVal === 'MMM' && i18nShortMonths.length) {
|
|
417
459
|
return i18nShortMonths[selectedMonth - 1].length;
|
|
418
460
|
} else if (selectedMonth && formatVal === 'MMMM' && i18nMonths.length) {
|
|
419
461
|
return i18nMonths[selectedMonth - 1].length;
|
|
420
462
|
}
|
|
463
|
+
|
|
421
464
|
return formatVal.length ? formatVal.length : 1;
|
|
422
465
|
}
|
|
466
|
+
|
|
423
467
|
return length;
|
|
424
468
|
}
|
|
469
|
+
|
|
425
470
|
export function getDateFormatSelection(dateFormatDetails, isDateTime) {
|
|
426
471
|
let {
|
|
427
472
|
i18nShortMonths,
|
|
@@ -444,20 +489,24 @@ export function getDateFormatSelection(dateFormatDetails, isDateTime) {
|
|
|
444
489
|
const clickIndex = {};
|
|
445
490
|
const order = [];
|
|
446
491
|
let tempLength = 0;
|
|
492
|
+
|
|
447
493
|
function addResult(type, length) {
|
|
448
494
|
const startIndex = tempLength;
|
|
449
495
|
const endIndex = tempLength + length;
|
|
450
496
|
const orderLen = order.length;
|
|
451
497
|
focusedIndex[`${startIndex}_${endIndex}`] = orderLen;
|
|
498
|
+
|
|
452
499
|
for (let i = startIndex; i <= endIndex; i++) {
|
|
453
500
|
clickIndex[i] = orderLen;
|
|
454
501
|
}
|
|
502
|
+
|
|
455
503
|
order.push({
|
|
456
504
|
type,
|
|
457
505
|
index: [startIndex, endIndex]
|
|
458
506
|
});
|
|
459
507
|
tempLength += length;
|
|
460
508
|
}
|
|
509
|
+
|
|
461
510
|
dateFormatArr.forEach((formatVal, index) => {
|
|
462
511
|
const {
|
|
463
512
|
type,
|
|
@@ -481,38 +530,32 @@ export function getDateFormatSelection(dateFormatDetails, isDateTime) {
|
|
|
481
530
|
addResult(type, validLength);
|
|
482
531
|
tempLength += patternVal.length;
|
|
483
532
|
});
|
|
533
|
+
|
|
484
534
|
if (isDateTime) {
|
|
485
535
|
//For space between date and time
|
|
486
|
-
tempLength += 1;
|
|
536
|
+
tempLength += 1; //hour
|
|
487
537
|
|
|
488
|
-
//
|
|
489
|
-
addResult('hour', 2);
|
|
538
|
+
addResult('hour', 2); //For :
|
|
490
539
|
|
|
491
|
-
//
|
|
492
|
-
tempLength += 1;
|
|
540
|
+
tempLength += 1; //minute
|
|
493
541
|
|
|
494
|
-
//
|
|
495
|
-
addResult('minute', 2);
|
|
542
|
+
addResult('minute', 2); //For space between time and noon
|
|
496
543
|
|
|
497
|
-
|
|
498
|
-
tempLength += 1;
|
|
544
|
+
tempLength += 1; //noon
|
|
499
545
|
|
|
500
|
-
//noon
|
|
501
546
|
if (!is24Hour) {
|
|
502
547
|
addResult('noon', 2);
|
|
503
548
|
}
|
|
504
549
|
}
|
|
550
|
+
|
|
505
551
|
return {
|
|
506
552
|
focusedIndex,
|
|
507
553
|
clickIndex,
|
|
508
554
|
order
|
|
509
555
|
};
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// export function getDateValues(date = '', dateFormatDetails = {}) {
|
|
556
|
+
} // export function getDateValues(date = '', dateFormatDetails = {}) {
|
|
513
557
|
// const { dateFormatArr, patternArr, dayInfo, monthInfo, yearInfo } =
|
|
514
558
|
// dateFormatDetails;
|
|
515
|
-
|
|
516
559
|
// const newDate = date.split('').reduce((res, str) => {
|
|
517
560
|
// if (patternArr.indexOf(str) >= 0) {
|
|
518
561
|
// res += patternChangeStr;
|
|
@@ -521,21 +564,16 @@ export function getDateFormatSelection(dateFormatDetails, isDateTime) {
|
|
|
521
564
|
// }
|
|
522
565
|
// return res;
|
|
523
566
|
// }, '');
|
|
524
|
-
|
|
525
567
|
// const dateArr = newDate.split(patternChangeStr);
|
|
526
|
-
|
|
527
568
|
// const { index: dayIndex, length: dayLength } = dayInfo;
|
|
528
569
|
// let day = dateArr[dayIndex];
|
|
529
570
|
// day = addZero(day, dayLength);
|
|
530
|
-
|
|
531
571
|
// const { index: monthIndex, length: monthLength } = monthInfo;
|
|
532
572
|
// let month = dateArr[monthIndex];
|
|
533
573
|
// month = addZero(month, monthLength);
|
|
534
|
-
|
|
535
574
|
// const { index: yearIndex, length: yearLength } = yearInfo;
|
|
536
575
|
// let year = dateArr[yearIndex];
|
|
537
576
|
// year = addZero(year, yearLength);
|
|
538
|
-
|
|
539
577
|
// return {
|
|
540
578
|
// day,
|
|
541
579
|
// month,
|
|
@@ -543,21 +581,16 @@ export function getDateFormatSelection(dateFormatDetails, isDateTime) {
|
|
|
543
581
|
// dateString: concatDate({ day, month, year }, dateFormatArr, patternArr)
|
|
544
582
|
// };
|
|
545
583
|
// }
|
|
546
|
-
|
|
547
584
|
// export function getDateTimeValues(value = '', dateFormatDetails = {}) {
|
|
548
585
|
// const [date, time = '', noon = ''] = value.split(' ');
|
|
549
|
-
|
|
550
586
|
// let [hour = '', minute = ''] = time.split(':');
|
|
551
587
|
// hour = addZero(hour, 2);
|
|
552
588
|
// minute = addZero(minute, 2);
|
|
553
|
-
|
|
554
589
|
// const { day, month, year, dateString } = getDateValues(
|
|
555
590
|
// date,
|
|
556
591
|
// dateFormatDetails
|
|
557
592
|
// );
|
|
558
|
-
|
|
559
593
|
// const timeString = `${hour}:${minute}`;
|
|
560
|
-
|
|
561
594
|
// return {
|
|
562
595
|
// day,
|
|
563
596
|
// month,
|