@zohodesk/components 1.2.4 → 1.2.5

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 (200) hide show
  1. package/README.md +4 -0
  2. package/coverage/Button/Button.js.html +1 -1
  3. package/coverage/Button/css/Button.module.css.html +1 -1
  4. package/coverage/Button/css/cssJSLogic.js.html +1 -1
  5. package/coverage/Button/css/index.html +1 -1
  6. package/coverage/Button/index.html +1 -1
  7. package/coverage/Button/props/defaultProps.js.html +1 -1
  8. package/coverage/Button/props/index.html +1 -1
  9. package/coverage/Button/props/propTypes.js.html +1 -1
  10. package/coverage/Buttongroup/Buttongroup.js.html +1 -1
  11. package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
  12. package/coverage/Buttongroup/index.html +1 -1
  13. package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
  14. package/coverage/Buttongroup/props/index.html +1 -1
  15. package/coverage/Buttongroup/props/propTypes.js.html +1 -1
  16. package/coverage/index.html +1 -1
  17. package/coverage/utils/dummyFunction.js.html +1 -1
  18. package/coverage/utils/index.html +1 -1
  19. package/es/v1/Accordion/Accordion.js +65 -0
  20. package/es/v1/Accordion/AccordionItem.js +57 -0
  21. package/es/v1/Accordion/index.js +2 -0
  22. package/es/v1/Animation/Animation.js +127 -0
  23. package/es/v1/AppContainer/AppContainer.js +134 -0
  24. package/es/v1/Avatar/Avatar.js +189 -0
  25. package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
  26. package/es/v1/Button/Button.js +68 -0
  27. package/es/v1/Buttongroup/Buttongroup.js +31 -0
  28. package/es/v1/Card/Card.js +271 -0
  29. package/es/v1/CheckBox/CheckBox.js +155 -0
  30. package/es/v1/DateTime/CalendarView.js +218 -0
  31. package/es/v1/DateTime/DateTime.js +783 -0
  32. package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
  33. package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
  34. package/es/v1/DateTime/DateWidget.js +1098 -0
  35. package/es/v1/DateTime/DaysRow.js +31 -0
  36. package/es/v1/DateTime/Time.js +166 -0
  37. package/es/v1/DateTime/YearView.js +264 -0
  38. package/es/v1/DateTime/index.js +1 -0
  39. package/es/v1/DropBox/DropBox.js +91 -0
  40. package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
  41. package/es/v1/DropDown/DropDown.js +73 -0
  42. package/es/v1/DropDown/DropDownHeading.js +44 -0
  43. package/es/v1/DropDown/DropDownItem.js +76 -0
  44. package/es/v1/DropDown/DropDownSearch.js +63 -0
  45. package/es/v1/DropDown/DropDownSeparator.js +15 -0
  46. package/es/v1/Heading/Heading.js +32 -0
  47. package/es/v1/Label/Label.js +40 -0
  48. package/es/v1/Layout/Box.js +115 -0
  49. package/es/v1/Layout/Container.js +132 -0
  50. package/es/v1/Layout/index.js +2 -0
  51. package/es/v1/ListItem/ListContainer.js +102 -0
  52. package/es/v1/ListItem/ListItem.js +124 -0
  53. package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
  54. package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
  55. package/es/v1/ListItem/ListItemWithIcon.js +127 -0
  56. package/es/v1/ListItem/ListItemWithRadio.js +105 -0
  57. package/es/v1/ListItem/index.js +6 -0
  58. package/es/v1/Modal/Modal.js +154 -0
  59. package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
  60. package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
  61. package/es/v1/MultiSelect/EmptyState.js +64 -0
  62. package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
  63. package/es/v1/MultiSelect/MultiSelect.js +1120 -0
  64. package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
  65. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
  66. package/es/v1/MultiSelect/SelectedOptions.js +82 -0
  67. package/es/v1/MultiSelect/Suggestions.js +142 -0
  68. package/es/v1/MultiSelect/index.js +4 -0
  69. package/es/v1/PopOver/PopOver.js +211 -0
  70. package/es/v1/Popup/Popup.js +645 -0
  71. package/es/v1/Radio/Radio.js +115 -0
  72. package/es/v1/Responsive/CustomResponsive.js +195 -0
  73. package/es/v1/Responsive/RefWrapper.js +39 -0
  74. package/es/v1/Responsive/ResizeComponent.js +197 -0
  75. package/es/v1/Responsive/ResizeObserver.js +140 -0
  76. package/es/v1/Responsive/Responsive.js +194 -0
  77. package/es/v1/Responsive/index.js +9 -0
  78. package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
  79. package/es/v1/Ribbon/Ribbon.js +33 -0
  80. package/es/v1/RippleEffect/RippleEffect.js +24 -0
  81. package/es/v1/Select/GroupSelect.js +803 -0
  82. package/es/v1/Select/Select.js +969 -0
  83. package/es/v1/Select/SelectWithAvatar.js +344 -0
  84. package/es/v1/Select/SelectWithIcon.js +535 -0
  85. package/es/v1/Select/index.js +4 -0
  86. package/es/v1/Stencils/Stencils.js +26 -0
  87. package/es/v1/Switch/Switch.js +94 -0
  88. package/es/v1/Tab/Tab.js +108 -0
  89. package/es/v1/Tab/TabContent.js +30 -0
  90. package/es/v1/Tab/TabContentWrapper.js +29 -0
  91. package/es/v1/Tab/TabWrapper.js +57 -0
  92. package/es/v1/Tab/Tabs.js +612 -0
  93. package/es/v1/Tab/index.js +5 -0
  94. package/es/v1/Tag/Tag.js +134 -0
  95. package/es/v1/TextBox/TextBox.js +154 -0
  96. package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
  97. package/es/v1/Textarea/Textarea.js +102 -0
  98. package/es/v1/Tooltip/Tooltip.js +518 -0
  99. package/es/v1/Typography/Typography.js +38 -0
  100. package/es/v1/Typography/css/Typography.module.css +376 -0
  101. package/es/v1/Typography/css/cssJSLogic.js +46 -0
  102. package/es/v1/Typography/css/letterSpacingMap.js +12 -0
  103. package/es/v1/Typography/props/defaultProps.js +8 -0
  104. package/es/v1/Typography/props/propTypes.js +24 -0
  105. package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
  106. package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
  107. package/es/v1/semantic/Button/Button.js +53 -0
  108. package/es/v1/semantic/index.js +1 -0
  109. package/lib/v1/Accordion/Accordion.js +96 -0
  110. package/lib/v1/Accordion/AccordionItem.js +68 -0
  111. package/lib/v1/Accordion/index.js +23 -0
  112. package/lib/v1/Animation/Animation.js +143 -0
  113. package/lib/v1/AppContainer/AppContainer.js +204 -0
  114. package/lib/v1/Avatar/Avatar.js +246 -0
  115. package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
  116. package/lib/v1/Button/Button.js +82 -0
  117. package/lib/v1/Buttongroup/Buttongroup.js +44 -0
  118. package/lib/v1/Card/Card.js +365 -0
  119. package/lib/v1/CheckBox/CheckBox.js +166 -0
  120. package/lib/v1/DateTime/CalendarView.js +285 -0
  121. package/lib/v1/DateTime/DateTime.js +872 -0
  122. package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
  123. package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
  124. package/lib/v1/DateTime/DateWidget.js +1125 -0
  125. package/lib/v1/DateTime/DaysRow.js +80 -0
  126. package/lib/v1/DateTime/Time.js +254 -0
  127. package/lib/v1/DateTime/YearView.js +325 -0
  128. package/lib/v1/DateTime/index.js +15 -0
  129. package/lib/v1/DropBox/DropBox.js +119 -0
  130. package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
  131. package/lib/v1/DropDown/DropDown.js +170 -0
  132. package/lib/v1/DropDown/DropDownHeading.js +93 -0
  133. package/lib/v1/DropDown/DropDownItem.js +127 -0
  134. package/lib/v1/DropDown/DropDownSearch.js +113 -0
  135. package/lib/v1/DropDown/DropDownSeparator.js +64 -0
  136. package/lib/v1/Heading/Heading.js +49 -0
  137. package/lib/v1/Label/Label.js +51 -0
  138. package/lib/v1/Layout/Box.js +128 -0
  139. package/lib/v1/Layout/Container.js +145 -0
  140. package/lib/v1/Layout/index.js +23 -0
  141. package/lib/v1/ListItem/ListContainer.js +120 -0
  142. package/lib/v1/ListItem/ListItem.js +138 -0
  143. package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
  144. package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
  145. package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
  146. package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
  147. package/lib/v1/ListItem/index.js +55 -0
  148. package/lib/v1/Modal/Modal.js +212 -0
  149. package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
  150. package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
  151. package/lib/v1/MultiSelect/EmptyState.js +112 -0
  152. package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
  153. package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
  154. package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
  155. package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
  156. package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
  157. package/lib/v1/MultiSelect/Suggestions.js +195 -0
  158. package/lib/v1/MultiSelect/index.js +39 -0
  159. package/lib/v1/PopOver/PopOver.js +293 -0
  160. package/lib/v1/Popup/Popup.js +715 -0
  161. package/lib/v1/Radio/Radio.js +126 -0
  162. package/lib/v1/Responsive/CustomResponsive.js +242 -0
  163. package/lib/v1/Responsive/RefWrapper.js +57 -0
  164. package/lib/v1/Responsive/ResizeComponent.js +268 -0
  165. package/lib/v1/Responsive/ResizeObserver.js +168 -0
  166. package/lib/v1/Responsive/Responsive.js +274 -0
  167. package/lib/v1/Responsive/index.js +55 -0
  168. package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
  169. package/lib/v1/Ribbon/Ribbon.js +44 -0
  170. package/lib/v1/RippleEffect/RippleEffect.js +39 -0
  171. package/lib/v1/Select/GroupSelect.js +877 -0
  172. package/lib/v1/Select/Select.js +1013 -0
  173. package/lib/v1/Select/SelectWithAvatar.js +394 -0
  174. package/lib/v1/Select/SelectWithIcon.js +597 -0
  175. package/lib/v1/Select/index.js +39 -0
  176. package/lib/v1/Stencils/Stencils.js +43 -0
  177. package/lib/v1/Switch/Switch.js +108 -0
  178. package/lib/v1/Tab/Tab.js +132 -0
  179. package/lib/v1/Tab/TabContent.js +42 -0
  180. package/lib/v1/Tab/TabContentWrapper.js +42 -0
  181. package/lib/v1/Tab/TabWrapper.js +89 -0
  182. package/lib/v1/Tab/Tabs.js +680 -0
  183. package/lib/v1/Tab/index.js +47 -0
  184. package/lib/v1/Tag/Tag.js +154 -0
  185. package/lib/v1/TextBox/TextBox.js +168 -0
  186. package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
  187. package/lib/v1/Textarea/Textarea.js +118 -0
  188. package/lib/v1/Tooltip/Tooltip.js +586 -0
  189. package/lib/v1/Typography/Typography.js +56 -0
  190. package/lib/v1/Typography/css/Typography.module.css +376 -0
  191. package/lib/v1/Typography/css/cssJSLogic.js +41 -0
  192. package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
  193. package/lib/v1/Typography/props/defaultProps.js +15 -0
  194. package/lib/v1/Typography/props/propTypes.js +35 -0
  195. package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
  196. package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
  197. package/lib/v1/semantic/Button/Button.js +63 -0
  198. package/lib/v1/semantic/index.js +15 -0
  199. package/package.json +1 -1
  200. package/result.json +1 -1
@@ -0,0 +1,1125 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _propTypes = require("../../DateTime/props/propTypes");
13
+
14
+ var _defaultProps = require("../../DateTime/props/defaultProps");
15
+
16
+ var _datetimejs = _interopRequireDefault(require("@zohodesk/datetimejs"));
17
+
18
+ var _DateTime = _interopRequireDefault(require("./DateTime"));
19
+
20
+ var _Popup = _interopRequireDefault(require("../Popup/Popup"));
21
+
22
+ var _icons = require("@zohodesk/icons");
23
+
24
+ var _Layout = require("../Layout");
25
+
26
+ var _TextBoxIcon = _interopRequireDefault(require("../TextBoxIcon/TextBoxIcon"));
27
+
28
+ var _DateWidgetModule = _interopRequireDefault(require("../../DateTime/DateWidget.module.css"));
29
+
30
+ var _validator = _interopRequireDefault(require("../../DateTime/validator"));
31
+
32
+ var _common = require("../../utils/datetime/common");
33
+
34
+ var _dateFormatUtils = require("../../DateTime/dateFormatUtils");
35
+
36
+ var _dateFormat = require("../../DateTime/dateFormatUtils/dateFormat");
37
+
38
+ var _dayChange = require("../../DateTime/dateFormatUtils/dayChange");
39
+
40
+ var _monthChange = require("../../DateTime/dateFormatUtils/monthChange");
41
+
42
+ var _yearChange = require("../../DateTime/dateFormatUtils/yearChange");
43
+
44
+ var _timeChange = require("../../DateTime/dateFormatUtils/timeChange");
45
+
46
+ var _Common = require("../../utils/Common");
47
+
48
+ var _constants = require("../../DateTime/constants");
49
+
50
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
51
+
52
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
53
+
54
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
55
+
56
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
57
+
58
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
59
+
60
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
61
+
62
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
63
+
64
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
65
+
66
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
67
+
68
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
69
+
70
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
71
+
72
+ /* eslint-disable react/no-unused-prop-types */
73
+
74
+ /* eslint css-modules/no-unused-class: [0, { markAsUsed: 'inputLine'] }] */
75
+ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
76
+ _inherits(DateWidgetComponent, _React$Component);
77
+
78
+ var _super = _createSuper(DateWidgetComponent);
79
+
80
+ function DateWidgetComponent(props) {
81
+ var _this;
82
+
83
+ _classCallCheck(this, DateWidgetComponent);
84
+
85
+ _this = _super.call(this, props);
86
+ _this.handleSelect = _this.handleSelect.bind(_assertThisInitialized(_this));
87
+ _this.handleTogglePopup = _this.handleTogglePopup.bind(_assertThisInitialized(_this));
88
+ _this.handleGetDisplayText = _this.handleGetDisplayText.bind(_assertThisInitialized(_this));
89
+ _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
90
+ _this.handleFocus = _this.handleFocus.bind(_assertThisInitialized(_this));
91
+ _this.getValueInputRef = _this.getValueInputRef.bind(_assertThisInitialized(_this));
92
+ _this.handleGetMethods = _this.handleGetMethods.bind(_assertThisInitialized(_this));
93
+ _this.handleInputClick = _this.handleInputClick.bind(_assertThisInitialized(_this));
94
+ _this.handleGetShowValue = _this.handleGetShowValue.bind(_assertThisInitialized(_this));
95
+ _this.handleSelection = _this.handleSelection.bind(_assertThisInitialized(_this));
96
+ _this.handleDateType = _this.handleDateType.bind(_assertThisInitialized(_this));
97
+ _this.handleBlur = _this.handleBlur.bind(_assertThisInitialized(_this));
98
+ _this.handleGetAllowedType = _this.handleGetAllowedType.bind(_assertThisInitialized(_this));
99
+ _this.handleDateClear = _this.handleDateClear.bind(_assertThisInitialized(_this));
100
+ _this.handleDateTimeClear = _this.handleDateTimeClear.bind(_assertThisInitialized(_this));
101
+ _this.handleMouseDown = _this.handleMouseDown.bind(_assertThisInitialized(_this));
102
+ _this.handleDateIconClick = _this.handleDateIconClick.bind(_assertThisInitialized(_this));
103
+ _this.handleSelectionRangeDetails = _this.handleSelectionRangeDetails.bind(_assertThisInitialized(_this));
104
+ _this.handleBlurSelectionRange = _this.handleBlurSelectionRange.bind(_assertThisInitialized(_this));
105
+ _this.state = {
106
+ selected: '',
107
+ displayText: '',
108
+ dateFormatDetails: {},
109
+ dateFormatSelection: {},
110
+ day: '',
111
+ month: '',
112
+ year: '',
113
+ hour: '',
114
+ minute: '',
115
+ noon: '',
116
+ isDateEdited: false,
117
+ stateFocusOrder: '',
118
+ isError: false,
119
+ isFocused: false
120
+ };
121
+ _this.oldFocusOrder = '';
122
+ _this.focusOrder = '';
123
+ _this.oldKeyDownAction = ''; //'Arrow' || 'valueTyped'
124
+
125
+ _this.keyDownAction = ''; //'Arrow' || 'valueTyped'
126
+
127
+ _this.isMouseDown = false;
128
+ return _this;
129
+ }
130
+
131
+ _createClass(DateWidgetComponent, [{
132
+ key: "componentDidMount",
133
+ value: function componentDidMount() {
134
+ var validation = this.props.validation;
135
+ var selected = this.state.selected;
136
+
137
+ if (validation && validation.validate) {
138
+ this.validateOnSelect(selected, this.props);
139
+ }
140
+
141
+ var _this$handleGetDispla = this.handleGetDisplayText(this.props),
142
+ displayText = _this$handleGetDispla.displayText,
143
+ newSelected = _this$handleGetDispla.selected;
144
+
145
+ this.setState({
146
+ displayText: displayText,
147
+ selected: newSelected
148
+ });
149
+ this.handleSelectionRangeDetails(this.props);
150
+ }
151
+ }, {
152
+ key: "componentDidUpdate",
153
+ value: function componentDidUpdate(prevProps, prevState) {
154
+ var _this$state = this.state,
155
+ selected = _this$state.selected,
156
+ day = _this$state.day,
157
+ month = _this$state.month,
158
+ year = _this$state.year,
159
+ hour = _this$state.hour,
160
+ minute = _this$state.minute,
161
+ noon = _this$state.noon,
162
+ isDateEdited = _this$state.isDateEdited,
163
+ stateFocusOrder = _this$state.stateFocusOrder,
164
+ isFocused = _this$state.isFocused;
165
+ var _this$props = this.props,
166
+ value = _this$props.value,
167
+ validation = _this$props.validation,
168
+ isPopupReady = _this$props.isPopupReady,
169
+ _this$props$dateForma = _this$props.dateFormat,
170
+ dateFormat = _this$props$dateForma === void 0 ? '' : _this$props$dateForma,
171
+ is24Hour = _this$props.is24Hour,
172
+ isHideCurrentYear = _this$props.isHideCurrentYear;
173
+
174
+ if (validation && validation.validate) {
175
+ this.validateOnSelect(selected, this.props);
176
+ }
177
+
178
+ if (value !== prevProps.value || dateFormat !== prevProps.dateFormat || is24Hour !== prevProps.is24Hour || isHideCurrentYear !== prevProps.isHideCurrentYear) {
179
+ var _this$handleGetDispla2 = this.handleGetDisplayText(this.props),
180
+ displayText = _this$handleGetDispla2.displayText,
181
+ _selected = _this$handleGetDispla2.selected;
182
+
183
+ this.setState({
184
+ selected: _selected,
185
+ displayText: displayText
186
+ });
187
+
188
+ if (value !== _constants.INVALID_DATE) {
189
+ this.setState({
190
+ day: '',
191
+ month: '',
192
+ year: '',
193
+ hour: '',
194
+ minute: '',
195
+ noon: '',
196
+ isDateEdited: false,
197
+ isError: false
198
+ });
199
+ }
200
+ }
201
+
202
+ if (prevProps.isPopupReady !== isPopupReady) {
203
+ if (isPopupReady) {
204
+ this.resetLocalDate && this.resetLocalDate();
205
+ }
206
+ }
207
+
208
+ var haveLocalValue = [day, month, year, hour, minute, noon].some(function (value) {
209
+ return !(0, _Common.getIsEmptyValue)(value);
210
+ });
211
+
212
+ if (isDateEdited !== haveLocalValue) {
213
+ this.setState({
214
+ isDateEdited: haveLocalValue
215
+ });
216
+ }
217
+
218
+ if (value !== prevProps.value || dateFormat !== prevProps.dateFormat || is24Hour !== prevProps.is24Hour || (0, _dateFormatUtils.arrayIsNotEqual)([day, month, year, hour, minute, noon], [prevState.day, prevState.month, prevState.year, prevState.hour, prevState.minute, prevState.noon])) {
219
+ this.handleSelectionRangeDetails(this.props);
220
+ } // if (stateFocusOrder !== prevState.stateFocusOrder) {
221
+
222
+
223
+ isFocused && !(0, _Common.getIsEmptyValue)(stateFocusOrder) && this.handleSelection(stateFocusOrder);
224
+ this.handleBlurSelectionRange(stateFocusOrder, prevState.stateFocusOrder); // }
225
+ // if (prevProps.isPopupOpen !== isPopupOpen) {
226
+ // if (!isPopupOpen) {
227
+ // this.valueInput && this.valueInput.focus({preventScroll:true});
228
+ // }
229
+ // }
230
+ }
231
+ }, {
232
+ key: "handleSelect",
233
+ value: function handleSelect(userZoneSelectedTime, fotmattedValue, e) {
234
+ var _this$props2 = this.props,
235
+ id = _this$props2.id,
236
+ onSelect = _this$props2.onSelect,
237
+ closePopupOnly = _this$props2.closePopupOnly,
238
+ validation = _this$props2.validation;
239
+
240
+ if (validation && validation.validateOn) {
241
+ var selected = this.state.selected;
242
+ this.validateOnSelect(selected, this.props);
243
+ }
244
+
245
+ onSelect && onSelect(userZoneSelectedTime, id);
246
+ this.valueInput && this.valueInput.focus({
247
+ preventScroll: true
248
+ });
249
+ closePopupOnly(e);
250
+ }
251
+ }, {
252
+ key: "validateOnSelect",
253
+ value: function validateOnSelect(value, props) {
254
+ var defaultCheckPropsRules = ['required'];
255
+ var defaultValidateRules = ['required'];
256
+ var defaultType = 'onegroup';
257
+ var validation = props.validation,
258
+ onPassValidation = props.onPassValidation,
259
+ onFailValidation = props.onFailValidation;
260
+ var targetTag = this.elementRef;
261
+
262
+ if (validation) {
263
+ //validateOn won't work here ...
264
+ var newValidation = _validator["default"].combinePropsValidation(this.props, defaultType, 'onSelect', validation, defaultCheckPropsRules, defaultValidateRules);
265
+
266
+ var validationObj = {
267
+ validation: newValidation,
268
+ onPassValidation: onPassValidation,
269
+ onFailValidation: onFailValidation
270
+ };
271
+
272
+ _validator["default"].executeValidation(value, targetTag, validationObj, defaultType);
273
+ } else {
274
+ onPassValidation && onPassValidation(value, targetTag);
275
+ }
276
+ }
277
+ }, {
278
+ key: "handleTogglePopup",
279
+ value: function handleTogglePopup(e, isOpenOnly) {
280
+ var _this$props3 = this.props,
281
+ togglePopup = _this$props3.togglePopup,
282
+ _this$props3$defaultP = _this$props3.defaultPosition,
283
+ defaultPosition = _this$props3$defaultP === void 0 ? 'bottom' : _this$props3$defaultP,
284
+ isPopupOpen = _this$props3.isPopupOpen,
285
+ removeClose = _this$props3.removeClose;
286
+
287
+ if (isOpenOnly) {
288
+ if (!isPopupOpen) {
289
+ togglePopup(e, "".concat(defaultPosition, "Right"));
290
+ } else {
291
+ removeClose(e);
292
+ }
293
+ }
294
+
295
+ !isOpenOnly && togglePopup(e, "".concat(defaultPosition, "Right"));
296
+ }
297
+ }, {
298
+ key: "handleSelectionRangeDetails",
299
+ value: function handleSelectionRangeDetails(props) {
300
+ var timeZone = props.timeZone,
301
+ dateFormat = props.dateFormat,
302
+ isDateTime = props.isDateTime,
303
+ value = props.value,
304
+ is24Hour = props.is24Hour;
305
+ var _this$state2 = this.state,
306
+ day = _this$state2.day,
307
+ month = _this$state2.month,
308
+ year = _this$state2.year,
309
+ hour = _this$state2.hour,
310
+ minute = _this$state2.minute,
311
+ noon = _this$state2.noon;
312
+ var selected = value === _constants.INVALID_DATE ? '' : value; //New UI Changes
313
+
314
+ var dateFormatDetails = (0, _dateFormat.getDateFormatDetails)(dateFormat, {
315
+ isHideCurrentYear: false,
316
+ value: value,
317
+ timeZone: timeZone,
318
+ isDateTime: isDateTime
319
+ });
320
+ var dateFormatSelection = (0, _dateFormat.getDateFormatSelection)(dateFormatDetails, isDateTime, {
321
+ i18nShortMonths: _constants.i18nShortMonths,
322
+ i18nMonths: _constants.i18nMonths,
323
+ selectedValue: selected,
324
+ day: day,
325
+ month: month,
326
+ year: year,
327
+ hour: hour,
328
+ minute: minute,
329
+ noon: noon,
330
+ timeZone: timeZone,
331
+ is24Hour: is24Hour
332
+ });
333
+ var newDateFormat = dateFormatDetails.dateFormat;
334
+ this.setState({
335
+ dateFormatDetails: dateFormatDetails,
336
+ dateFormatSelection: dateFormatSelection,
337
+ newDateFormat: newDateFormat
338
+ });
339
+ }
340
+ }, {
341
+ key: "handleGetDisplayText",
342
+ value: function handleGetDisplayText(props) {
343
+ var timeZone = props.timeZone,
344
+ dateFormat = props.dateFormat,
345
+ isDateTime = props.isDateTime,
346
+ value = props.value,
347
+ is24Hour = props.is24Hour,
348
+ isHideCurrentYear = props.isHideCurrentYear;
349
+ var dateFormatDetails = (0, _dateFormat.getDateFormatDetails)(dateFormat, {
350
+ isHideCurrentYear: isHideCurrentYear,
351
+ value: value,
352
+ timeZone: timeZone,
353
+ isDateTime: isDateTime
354
+ });
355
+ var newDateFormat = dateFormatDetails.dateFormat;
356
+ var displayText = '';
357
+ var selected = value === _constants.INVALID_DATE ? '' : value;
358
+
359
+ if (selected) {
360
+ var format = newDateFormat,
361
+ convertedValue;
362
+
363
+ if (isDateTime) {
364
+ convertedValue = _datetimejs["default"].toDate(_datetimejs["default"].tz.utcToTz(value, timeZone));
365
+ format = "".concat(newDateFormat, " ").concat(is24Hour ? 'HH:mm' : 'hh:mm A');
366
+ } else {
367
+ convertedValue = _datetimejs["default"].toDate(value);
368
+ }
369
+
370
+ displayText = (0, _common.formatDate)(convertedValue, format);
371
+ }
372
+
373
+ return {
374
+ displayText: displayText,
375
+ selected: selected
376
+ };
377
+ }
378
+ }, {
379
+ key: "handleKeyDown",
380
+ value: function handleKeyDown(e) {
381
+ var keyCode = e.keyCode;
382
+ var _this$props4 = this.props,
383
+ isPopupOpen = _this$props4.isPopupOpen,
384
+ isPopupOpenOnEnter = _this$props4.isPopupOpenOnEnter,
385
+ onKeyDown = _this$props4.onKeyDown,
386
+ closePopupOnly = _this$props4.closePopupOnly,
387
+ cantEditOnPopupOpen = _this$props4.cantEditOnPopupOpen;
388
+ var isAllowedDateType = this.handleGetAllowedType();
389
+
390
+ if (isPopupOpen) {
391
+ if (keyCode === 9 && !isAllowedDateType) {
392
+ //on tab click popup close
393
+ closePopupOnly(e);
394
+ } // ~~~~~~~ handle date navigation in dateTime popup ~~~~~
395
+
396
+
397
+ if (isAllowedDateType) {
398
+ cantEditOnPopupOpen && this.handleDateType(e);
399
+ }
400
+ } else if (!isPopupOpen) {
401
+ if (isPopupOpenOnEnter && keyCode === 13) {
402
+ //onEnter popup open
403
+ this.handleTogglePopup(e);
404
+ } else if (keyCode === 13) {
405
+ //onEnter submit case
406
+ onKeyDown && onKeyDown(e);
407
+ } else if (isAllowedDateType) {
408
+ this.handleDateType(e);
409
+ }
410
+ }
411
+ }
412
+ }, {
413
+ key: "getValueInputRef",
414
+ value: function getValueInputRef(el) {
415
+ var getRef = this.props.getRef;
416
+ this.valueInput = el;
417
+ getRef && getRef(el);
418
+ }
419
+ }, {
420
+ key: "handleFocus",
421
+ value: function handleFocus() {
422
+ var isAllowedDateType = this.handleGetAllowedType();
423
+ var isMouseDown = this.isMouseDown;
424
+
425
+ if (isAllowedDateType && !isMouseDown) {
426
+ var dateFormatSelection = this.state.dateFormatSelection;
427
+ var focusedIndex = dateFormatSelection.focusedIndex;
428
+ var _this$valueInput = this.valueInput,
429
+ newSelectionStart = _this$valueInput.selectionStart,
430
+ newSelectionEnd = _this$valueInput.selectionEnd;
431
+ var focusedOrder = focusedIndex["".concat(newSelectionStart, "_").concat(newSelectionEnd)] || 0;
432
+ isAllowedDateType && this.setState({
433
+ stateFocusOrder: focusedOrder,
434
+ isFocused: true
435
+ });
436
+ } else if (!isAllowedDateType) {
437
+ var valueInput = this.valueInput;
438
+ document.getSelection().removeAllRanges();
439
+ valueInput && valueInput.setSelectionRange(0, 0);
440
+ this.setState({
441
+ isFocused: true
442
+ });
443
+ }
444
+
445
+ var onFocus = this.props.onFocus;
446
+ onFocus && onFocus();
447
+ }
448
+ }, {
449
+ key: "handleBlur",
450
+ value: function handleBlur() {
451
+ this.focusOrder = '';
452
+ this.oldFocusOrder = '';
453
+ this.oldKeyDownAction = '';
454
+ this.keyDownAction = '';
455
+ this.setState({
456
+ isFocused: false
457
+ }); // const { valueInput } = this;
458
+ // document.getSelection().removeAllRanges();
459
+ // valueInput && valueInput.setSelectionRange(0, 0);
460
+
461
+ var onBlur = this.props.onBlur;
462
+ onBlur && onBlur();
463
+ }
464
+ }, {
465
+ key: "handleGetMethods",
466
+ value: function handleGetMethods(methods) {
467
+ var getMethods = this.props.getMethods;
468
+ var resetLocalDate = methods.resetLocalDate,
469
+ getStateValues = methods.getStateValues,
470
+ toggleYearView = methods.toggleYearView;
471
+ this.resetLocalDate = resetLocalDate;
472
+ this.getDateTimeStateValues = getStateValues;
473
+ this.DateTimeYearViewToggle = toggleYearView;
474
+ getMethods && getMethods(methods);
475
+ }
476
+ }, {
477
+ key: "handleDateType",
478
+ value: function handleDateType(e) {
479
+ var _this2 = this;
480
+
481
+ var keyCode = e.keyCode,
482
+ shiftKey = e.shiftKey;
483
+ var input = e.target;
484
+
485
+ if ((0, _dateFormatUtils.getIsSupportedKey)(e)) {
486
+ e.preventDefault();
487
+ }
488
+
489
+ var _this$props5 = this.props,
490
+ isDateTime = _this$props5.isDateTime,
491
+ timeZone = _this$props5.timeZone,
492
+ value = _this$props5.value,
493
+ onSelect = _this$props5.onSelect,
494
+ id = _this$props5.id,
495
+ min = _this$props5.min,
496
+ max = _this$props5.max,
497
+ minErrorText = _this$props5.minErrorText,
498
+ maxErrorText = _this$props5.maxErrorText,
499
+ onError = _this$props5.onError,
500
+ closePopupOnly = _this$props5.closePopupOnly,
501
+ is24Hour = _this$props5.is24Hour;
502
+ var _this$state3 = this.state,
503
+ dateFormatSelection = _this$state3.dateFormatSelection,
504
+ day = _this$state3.day,
505
+ month = _this$state3.month,
506
+ year = _this$state3.year,
507
+ hour = _this$state3.hour,
508
+ minute = _this$state3.minute,
509
+ noon = _this$state3.noon,
510
+ selected = _this$state3.selected,
511
+ dateFormatDetails = _this$state3.dateFormatDetails;
512
+ var focusedIndex = dateFormatSelection.focusedIndex,
513
+ order = dateFormatSelection.order;
514
+ var yearInfo = dateFormatDetails.yearInfo;
515
+
516
+ var _getDateDetails = (0, _dateFormat.getDateDetails)(selected, {
517
+ day: day,
518
+ month: month,
519
+ year: year,
520
+ hour: hour,
521
+ minute: minute,
522
+ noon: noon
523
+ }, isDateTime, timeZone, {
524
+ is24Hour: is24Hour
525
+ }),
526
+ _getDateDetails$day = _getDateDetails.day,
527
+ selectedDay = _getDateDetails$day === void 0 ? '' : _getDateDetails$day,
528
+ _getDateDetails$month = _getDateDetails.month,
529
+ selectedMonth = _getDateDetails$month === void 0 ? '' : _getDateDetails$month,
530
+ _getDateDetails$year = _getDateDetails.year,
531
+ selectedYear = _getDateDetails$year === void 0 ? '' : _getDateDetails$year,
532
+ _getDateDetails$hour = _getDateDetails.hour,
533
+ selectedHour = _getDateDetails$hour === void 0 ? '' : _getDateDetails$hour,
534
+ _getDateDetails$minut = _getDateDetails.minute,
535
+ selectedMinute = _getDateDetails$minut === void 0 ? '' : _getDateDetails$minut,
536
+ _getDateDetails$noon = _getDateDetails.noon,
537
+ selectedNoon = _getDateDetails$noon === void 0 ? '' : _getDateDetails$noon;
538
+
539
+ var newSelectionStart = input.selectionStart,
540
+ newSelectionEnd = input.selectionEnd;
541
+ var focusedOrder = focusedIndex["".concat(newSelectionStart, "_").concat(newSelectionEnd)];
542
+
543
+ var _ref = order[focusedOrder] || {},
544
+ type = _ref.type;
545
+
546
+ this.oldFocusOrder = this.focusOrder;
547
+ this.focusOrder = focusedOrder;
548
+
549
+ if (keyCode === 38 || keyCode === 40) {
550
+ //up arrow && down arrow
551
+ this.oldKeyDownAction = this.keyDownAction;
552
+ this.keyDownAction = 'Arrow';
553
+ } else {
554
+ this.oldKeyDownAction = this.keyDownAction;
555
+ this.keyDownAction = 'valueTyped';
556
+ }
557
+
558
+ var focusedOrders = {
559
+ focusOrder: this.focusOrder,
560
+ oldFocusOrder: this.oldFocusOrder
561
+ };
562
+ var keyActions = {
563
+ oldKeyAction: this.oldKeyDownAction,
564
+ keyAction: this.keyDownAction
565
+ };
566
+ var newDay = selectedDay,
567
+ newMonth = selectedMonth,
568
+ newYear = selectedYear,
569
+ newHour = selectedHour,
570
+ newMinute = selectedMinute,
571
+ newNoon = selectedNoon,
572
+ isValueChanged = false,
573
+ newFocusOrder = focusedOrder;
574
+
575
+ if (keyCode === 9 && shiftKey && !(0, _Common.getIsEmptyValue)(focusedOrder) && focusedOrder !== 0) {
576
+ e.preventDefault();
577
+ this.setState({
578
+ stateFocusOrder: focusedOrder - 1
579
+ });
580
+ } else if (keyCode === 9 && !shiftKey && !(0, _Common.getIsEmptyValue)(focusedOrder) && order.length - 1 !== focusedOrder) {
581
+ e.preventDefault();
582
+ this.setState({
583
+ stateFocusOrder: focusedOrder + 1
584
+ });
585
+ } else if (keyCode === 39) {
586
+ //arrow right
587
+ (0, _Common.getIsEmptyValue)(focusedOrder) ? this.setState({
588
+ stateFocusOrder: 0
589
+ }) : this.setState({
590
+ stateFocusOrder: focusedOrder + 1
591
+ });
592
+ } else if (keyCode === 37) {
593
+ //arrow left
594
+ (0, _Common.getIsEmptyValue)(focusedOrder) ? this.setState({
595
+ stateFocusOrder: order.length - 1
596
+ }) : this.setState({
597
+ stateFocusOrder: focusedOrder - 1
598
+ });
599
+ } else if (keyCode === 9) {
600
+ //on tab click popup close
601
+ closePopupOnly(e);
602
+ } else if (type === 'day') {
603
+ var _getChangedDay = (0, _dayChange.getChangedDay)({
604
+ day: selectedDay,
605
+ month: selectedMonth,
606
+ year: selectedYear
607
+ }, e, focusedOrders, keyActions);
608
+
609
+ newDay = _getChangedDay.day;
610
+ isValueChanged = _getChangedDay.isChanged;
611
+ newFocusOrder = _getChangedDay.focusOrder;
612
+ } else if (type === 'month') {
613
+ var _getChangedMonth = (0, _monthChange.getChangedMonth)({
614
+ day: selectedDay,
615
+ month: selectedMonth,
616
+ year: selectedYear
617
+ }, e, focusedOrders, keyActions);
618
+
619
+ newMonth = _getChangedMonth.month;
620
+ isValueChanged = _getChangedMonth.isChanged;
621
+ newFocusOrder = _getChangedMonth.focusOrder;
622
+ } else if (type === 'year') {
623
+ var _getChangedYear = (0, _yearChange.getChangedYear)({
624
+ day: selectedDay,
625
+ month: selectedMonth,
626
+ year: selectedYear
627
+ }, e, focusedOrders, keyActions, {
628
+ yearInfo: yearInfo
629
+ });
630
+
631
+ newYear = _getChangedYear.year;
632
+ isValueChanged = _getChangedYear.isChanged;
633
+ newFocusOrder = _getChangedYear.focusOrder;
634
+ } else if (type === 'hour') {
635
+ var _getChangedHour = (0, _timeChange.getChangedHour)({
636
+ hour: selectedHour
637
+ }, e, focusedOrders, keyActions, {
638
+ is24Hour: is24Hour
639
+ });
640
+
641
+ newHour = _getChangedHour.hour;
642
+ isValueChanged = _getChangedHour.isChanged;
643
+ newFocusOrder = _getChangedHour.focusOrder;
644
+ } else if (type === 'minute') {
645
+ var _getChangedMinute = (0, _timeChange.getChangedMinute)({
646
+ minute: selectedMinute
647
+ }, e, focusedOrders, keyActions);
648
+
649
+ newMinute = _getChangedMinute.minute;
650
+ isValueChanged = _getChangedMinute.isChanged;
651
+ newFocusOrder = _getChangedMinute.focusOrder;
652
+ } else if (type === 'noon') {
653
+ var _getChangedNoon = (0, _timeChange.getChangedNoon)({
654
+ noon: selectedNoon
655
+ }, e, focusedOrders, keyActions);
656
+
657
+ newNoon = _getChangedNoon.noon;
658
+ isValueChanged = _getChangedNoon.isChanged;
659
+ newFocusOrder = _getChangedNoon.focusOrder;
660
+ }
661
+
662
+ if (isValueChanged) {
663
+ var currentValue = {
664
+ day: newDay,
665
+ month: newMonth,
666
+ year: newYear,
667
+ hour: newHour,
668
+ minute: newMinute,
669
+ noon: newNoon
670
+ };
671
+
672
+ var errorCaseHandle = function errorCaseHandle(isEmptyValError) {
673
+ _this2.setState(function () {
674
+ return {
675
+ day: newDay,
676
+ month: newMonth,
677
+ year: newYear,
678
+ hour: newHour,
679
+ minute: newMinute,
680
+ noon: newNoon,
681
+ stateFocusOrder: newFocusOrder,
682
+ isDateEdited: true,
683
+ isError: !isEmptyValError
684
+ };
685
+ });
686
+
687
+ var newSelected = isEmptyValError ? '' : _constants.INVALID_DATE;
688
+ value !== newSelected && onSelect && onSelect(newSelected, id);
689
+ };
690
+
691
+ var _getIsValidDate = (0, _dateFormat.getIsValidDate)(currentValue, isDateTime, {
692
+ is24Hour: is24Hour
693
+ }),
694
+ isError = _getIsValidDate.isError,
695
+ isEmptyValError = _getIsValidDate.isEmptyValError;
696
+
697
+ if (isError) {
698
+ errorCaseHandle(isEmptyValError);
699
+ } else {
700
+ var _getSelectedDate = (0, _dateFormat.getSelectedDate)(currentValue, {
701
+ min: min,
702
+ max: max,
703
+ timeZone: timeZone,
704
+ isDateTime: isDateTime,
705
+ is24Hour: is24Hour
706
+ }),
707
+ selectedValue = _getSelectedDate.selectedValue,
708
+ selectedDateError = _getSelectedDate.isError,
709
+ errorType = _getSelectedDate.errorType;
710
+
711
+ if (selectedDateError) {
712
+ if (errorType === 'MIN') {
713
+ onError && onError(minErrorText, true);
714
+ } else if (errorType === 'MAX') {
715
+ onError && onError(maxErrorText, true);
716
+ }
717
+
718
+ errorCaseHandle();
719
+ } else {
720
+ this.setState(function () {
721
+ return {
722
+ day: '',
723
+ month: '',
724
+ year: '',
725
+ hour: '',
726
+ minute: '',
727
+ noon: '',
728
+ isDateEdited: false,
729
+ stateFocusOrder: newFocusOrder,
730
+ isError: false
731
+ };
732
+ });
733
+ onSelect && onSelect(selectedValue, id);
734
+ }
735
+ }
736
+ }
737
+ }
738
+ }, {
739
+ key: "handleSelection",
740
+ value: function handleSelection() {
741
+ var focusOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
742
+ var isAllowedDateType = this.handleGetAllowedType();
743
+
744
+ if (isAllowedDateType) {
745
+ var dateFormatSelection = this.state.dateFormatSelection;
746
+ var _dateFormatSelection$ = dateFormatSelection.order,
747
+ order = _dateFormatSelection$ === void 0 ? {} : _dateFormatSelection$;
748
+
749
+ var _ref2 = order[focusOrder] || {},
750
+ index = _ref2.index;
751
+
752
+ if (!index) {
753
+ focusOrder = 0;
754
+
755
+ var _ref3 = order[focusOrder] || {};
756
+
757
+ index = _ref3.index;
758
+ }
759
+
760
+ if (index && this.valueInput) {
761
+ document.getSelection().removeAllRanges();
762
+ this.valueInput.setSelectionRange(index[0], index[1]);
763
+ }
764
+ }
765
+ }
766
+ }, {
767
+ key: "handleInputClick",
768
+ value: function handleInputClick(e) {
769
+ this.isMouseDown = false;
770
+ var dateFormatSelection = this.state.dateFormatSelection;
771
+ var input = e.target;
772
+ var selectionEnd = input.selectionEnd;
773
+ e.preventDefault();
774
+ var clickIndex = dateFormatSelection.clickIndex;
775
+ var focusOrder = clickIndex[selectionEnd] || clickIndex[selectionEnd - 1] || 0;
776
+ var isAllowedDateType = this.handleGetAllowedType();
777
+
778
+ if (isAllowedDateType) {
779
+ this.setState({
780
+ stateFocusOrder: focusOrder,
781
+ isFocused: true
782
+ });
783
+ }
784
+
785
+ if (!isAllowedDateType) {
786
+ this.handleTogglePopup(e);
787
+ } else {
788
+ var _this$props6 = this.props,
789
+ isPopupOpenOnClick = _this$props6.isPopupOpenOnClick,
790
+ isReadOnly = _this$props6.isReadOnly,
791
+ isDisabled = _this$props6.isDisabled;
792
+
793
+ if (isPopupOpenOnClick && (!isReadOnly || !isDisabled)) {
794
+ this.handleTogglePopup(e, true);
795
+ }
796
+
797
+ var _this$props7 = this.props,
798
+ isPopupCloseOnClick = _this$props7.isPopupCloseOnClick,
799
+ isPopupOpen = _this$props7.isPopupOpen,
800
+ closePopupOnly = _this$props7.closePopupOnly;
801
+
802
+ if (isPopupCloseOnClick && !isPopupOpen) {
803
+ closePopupOnly && closePopupOnly(e);
804
+ }
805
+ }
806
+ }
807
+ }, {
808
+ key: "handleMouseDown",
809
+ value: function handleMouseDown() {
810
+ this.isMouseDown = true;
811
+ }
812
+ }, {
813
+ key: "handleGetShowValue",
814
+ value: function handleGetShowValue() {
815
+ var _this$state4 = this.state,
816
+ day = _this$state4.day,
817
+ month = _this$state4.month,
818
+ year = _this$state4.year,
819
+ hour = _this$state4.hour,
820
+ minute = _this$state4.minute,
821
+ noon = _this$state4.noon,
822
+ dateFormatDetails = _this$state4.dateFormatDetails,
823
+ displayText = _this$state4.displayText,
824
+ newDateFormat = _this$state4.newDateFormat,
825
+ isDateEdited = _this$state4.isDateEdited,
826
+ isFocused = _this$state4.isFocused,
827
+ selected = _this$state4.selected;
828
+ var _this$props8 = this.props,
829
+ isDateTime = _this$props8.isDateTime,
830
+ is24Hour = _this$props8.is24Hour,
831
+ isPopupReady = _this$props8.isPopupReady,
832
+ timeZone = _this$props8.timeZone,
833
+ isPopupOpen = _this$props8.isPopupOpen;
834
+
835
+ if (isDateEdited || isFocused || isPopupReady || isPopupOpen) {
836
+ var _getDateDetails2 = (0, _dateFormat.getDateDetails)(selected, {
837
+ day: day,
838
+ month: month,
839
+ year: year,
840
+ hour: hour,
841
+ minute: minute,
842
+ noon: noon
843
+ }, isDateTime, timeZone, {
844
+ is24Hour: is24Hour
845
+ }),
846
+ _getDateDetails2$day = _getDateDetails2.day,
847
+ selectedDay = _getDateDetails2$day === void 0 ? '' : _getDateDetails2$day,
848
+ _getDateDetails2$mont = _getDateDetails2.month,
849
+ selectedMonth = _getDateDetails2$mont === void 0 ? '' : _getDateDetails2$mont,
850
+ _getDateDetails2$year = _getDateDetails2.year,
851
+ selectedYear = _getDateDetails2$year === void 0 ? '' : _getDateDetails2$year,
852
+ _getDateDetails2$hour = _getDateDetails2.hour,
853
+ selectedHour = _getDateDetails2$hour === void 0 ? '' : _getDateDetails2$hour,
854
+ _getDateDetails2$minu = _getDateDetails2.minute,
855
+ selectedMinute = _getDateDetails2$minu === void 0 ? '' : _getDateDetails2$minu,
856
+ _getDateDetails2$noon = _getDateDetails2.noon,
857
+ selectedNoon = _getDateDetails2$noon === void 0 ? '' : _getDateDetails2$noon;
858
+
859
+ var dateTimeString = (0, _dateFormat.getDateTimeString)({
860
+ day: selectedDay,
861
+ month: selectedMonth,
862
+ year: selectedYear,
863
+ hour: selectedHour,
864
+ minute: selectedMinute,
865
+ noon: selectedNoon
866
+ }, dateFormatDetails, isDateTime, {
867
+ i18nShortMonths: _constants.i18nShortMonths,
868
+ i18nMonths: _constants.i18nMonths,
869
+ is24Hour: is24Hour
870
+ });
871
+ return dateTimeString;
872
+ } else if (displayText) {
873
+ return displayText;
874
+ }
875
+
876
+ var timeFormat = is24Hour ? ' HH:mm' : ' hh:mm --';
877
+ var dateTimeFormat = isDateTime ? "".concat(newDateFormat).concat(timeFormat) : newDateFormat;
878
+ return dateTimeFormat || '';
879
+ }
880
+ }, {
881
+ key: "handleGetAllowedType",
882
+ value: function handleGetAllowedType() {
883
+ var _this$props9 = this.props,
884
+ isReadOnly = _this$props9.isReadOnly,
885
+ isDisabled = _this$props9.isDisabled,
886
+ isEditable = _this$props9.isEditable;
887
+
888
+ if (isEditable) {
889
+ if (isReadOnly || isDisabled) {
890
+ return false;
891
+ }
892
+
893
+ return true;
894
+ }
895
+
896
+ return false;
897
+ }
898
+ }, {
899
+ key: "handleDateClear",
900
+ value: function handleDateClear() {
901
+ var _this$props10 = this.props,
902
+ id = _this$props10.id,
903
+ onSelect = _this$props10.onSelect,
904
+ value = _this$props10.value;
905
+ this.setState({
906
+ day: '',
907
+ month: '',
908
+ year: '',
909
+ hour: '',
910
+ minute: '',
911
+ noon: '',
912
+ isDateEdited: false,
913
+ stateFocusOrder: 0,
914
+ isError: false
915
+ });
916
+ value && onSelect && onSelect('', id); // this.valueInput && this.valueInput.focus({ preventScroll: true });
917
+ }
918
+ }, {
919
+ key: "handleDateTimeClear",
920
+ value: function handleDateTimeClear(e) {
921
+ this.handleDateClear();
922
+ var closePopupOnly = this.props.closePopupOnly;
923
+ closePopupOnly(e);
924
+ }
925
+ }, {
926
+ key: "handleDateIconClick",
927
+ value: function handleDateIconClick(e) {
928
+ this.handleTogglePopup(e);
929
+ this.valueInput && this.valueInput.focus({
930
+ preventScroll: true
931
+ });
932
+ }
933
+ }, {
934
+ key: "handleBlurSelectionRange",
935
+ value: function handleBlurSelectionRange() {
936
+ var focusOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
937
+ var oldFocusOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
938
+ var isAllowedDateType = this.handleGetAllowedType();
939
+
940
+ if (isAllowedDateType) {
941
+ // if (focusOrder !== oldFocusOrder) {
942
+ var _this$state$dateForma = this.state.dateFormatSelection,
943
+ dateFormatSelection = _this$state$dateForma === void 0 ? {} : _this$state$dateForma;
944
+ var _dateFormatSelection$2 = dateFormatSelection.order,
945
+ order = _dateFormatSelection$2 === void 0 ? [] : _dateFormatSelection$2;
946
+ var isPopupOpen = this.props.isPopupOpen; // const { type: oldFocusedType = '' } = order[oldFocusOrder] || {};
947
+
948
+ var _ref4 = order[focusOrder] || {},
949
+ _ref4$type = _ref4.type,
950
+ focusedType = _ref4$type === void 0 ? '' : _ref4$type;
951
+
952
+ var _this$getDateTimeStat = this.getDateTimeStateValues(),
953
+ isYearView = _this$getDateTimeStat.isYearView,
954
+ oldIsMonthOpen = _this$getDateTimeStat.isMonthOpen;
955
+
956
+ var yearViewTypes = ['month', 'year'];
957
+ var isMonthOpen = focusedType === 'month';
958
+
959
+ if (isPopupOpen) {
960
+ if (yearViewTypes.indexOf(focusedType) >= 0 && (!isYearView || isMonthOpen !== oldIsMonthOpen)) {
961
+ this.DateTimeYearViewToggle(true, isMonthOpen);
962
+ } else if (yearViewTypes.indexOf(focusedType) === -1 && isYearView) {
963
+ this.DateTimeYearViewToggle(false, false);
964
+ }
965
+ } // }
966
+
967
+ }
968
+ }
969
+ }, {
970
+ key: "render",
971
+ value: function render() {
972
+ var _this$props11 = this.props,
973
+ removeClose = _this$props11.removeClose,
974
+ minErrorText = _this$props11.minErrorText,
975
+ maxErrorText = _this$props11.maxErrorText,
976
+ min = _this$props11.min,
977
+ max = _this$props11.max,
978
+ placeholder = _this$props11.placeholder,
979
+ isPopupOpen = _this$props11.isPopupOpen,
980
+ isPopupReady = _this$props11.isPopupReady,
981
+ isDateTime = _this$props11.isDateTime,
982
+ position = _this$props11.position,
983
+ textBoxVariant = _this$props11.textBoxVariant,
984
+ textBoxSize = _this$props11.textBoxSize,
985
+ _this$props11$childre = _this$props11.children,
986
+ children = _this$props11$childre === void 0 ? null : _this$props11$childre,
987
+ isDisabled = _this$props11.isDisabled,
988
+ getContainerRef = _this$props11.getContainerRef,
989
+ getTargetRef = _this$props11.getTargetRef,
990
+ timeZone = _this$props11.timeZone,
991
+ isReadOnly = _this$props11.isReadOnly,
992
+ dataId = _this$props11.dataId,
993
+ needResponsive = _this$props11.needResponsive,
994
+ className = _this$props11.className,
995
+ needBorder = _this$props11.needBorder,
996
+ defaultTime = _this$props11.defaultTime,
997
+ needDefaultTime = _this$props11.needDefaultTime,
998
+ borderColor = _this$props11.borderColor,
999
+ i18nKeys = _this$props11.i18nKeys,
1000
+ needErrorOnBlur = _this$props11.needErrorOnBlur,
1001
+ htmlId = _this$props11.htmlId,
1002
+ iconOnHover = _this$props11.iconOnHover,
1003
+ is24Hour = _this$props11.is24Hour,
1004
+ isAbsolutePositioningNeeded = _this$props11.isAbsolutePositioningNeeded,
1005
+ positionsOffset = _this$props11.positionsOffset,
1006
+ targetOffset = _this$props11.targetOffset,
1007
+ isRestrictScroll = _this$props11.isRestrictScroll,
1008
+ dropBoxPortalId = _this$props11.dropBoxPortalId,
1009
+ a11y = _this$props11.a11y,
1010
+ boxSize = _this$props11.boxSize,
1011
+ onError = _this$props11.onError;
1012
+ var _this$state5 = this.state,
1013
+ _this$state5$selected = _this$state5.selected,
1014
+ value = _this$state5$selected === void 0 ? '' : _this$state5$selected,
1015
+ isError = _this$state5.isError,
1016
+ isDateEdited = _this$state5.isDateEdited,
1017
+ isFocused = _this$state5.isFocused;
1018
+ var showValue = this.handleGetShowValue();
1019
+ var isAllowedDateType = this.handleGetAllowedType();
1020
+ var showClear = !(isDisabled || isReadOnly) && (isDateEdited || value) ? true : false;
1021
+ var showError = needErrorOnBlur ? isError && !isFocused && !isPopupOpen : isError;
1022
+ return /*#__PURE__*/_react["default"].createElement("div", {
1023
+ className: "".concat(_DateWidgetModule["default"].container)
1024
+ }, children ? /*#__PURE__*/_react["default"].createElement("div", {
1025
+ "data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : "".concat(dataId, "_widget")),
1026
+ "data-test-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : "".concat(dataId, "_widget")),
1027
+ onClick: isDisabled || isReadOnly ? null : this.handleTogglePopup,
1028
+ ref: getTargetRef,
1029
+ className: "".concat(className ? className : '', " ").concat(isDisabled ? _DateWidgetModule["default"].disabled : _DateWidgetModule["default"].enabled)
1030
+ }, children) : /*#__PURE__*/_react["default"].createElement("div", {
1031
+ "data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : "".concat(dataId, "_widget")),
1032
+ "data-test-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : "".concat(dataId, "_widget")),
1033
+ className: "".concat(className ? className : '', " ").concat(_DateWidgetModule["default"].textBox, " ").concat(isPopupOpen && !isDisabled ? _DateWidgetModule["default"].textBoxFocus : '', " ").concat(isDisabled ? _DateWidgetModule["default"].disabled : isReadOnly ? _DateWidgetModule["default"].readOnly : _DateWidgetModule["default"].enabled),
1034
+ onClick: !isAllowedDateType ? isDisabled || isReadOnly ? null : this.handleTogglePopup : null,
1035
+ ref: getTargetRef
1036
+ }, /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"], {
1037
+ htmlId: htmlId,
1038
+ value: showValue ? showValue : placeholder,
1039
+ needBorder: needBorder,
1040
+ size: textBoxSize,
1041
+ variant: textBoxVariant,
1042
+ inputRef: this.getValueInputRef,
1043
+ isDisabled: isDisabled,
1044
+ dataId: dataId,
1045
+ needReadOnlyStyle: isReadOnly || isDisabled,
1046
+ onKeyDown: this.handleKeyDown,
1047
+ onFocus: this.handleFocus,
1048
+ borderColor: showError ? 'error' : borderColor,
1049
+ needEffect: !(isDisabled || isReadOnly || showError),
1050
+ isClickable: true,
1051
+ onClick: isDisabled || isReadOnly ? null : this.handleInputClick,
1052
+ onBlur: this.handleBlur,
1053
+ onClear: showClear ? this.handleDateClear : null,
1054
+ isReadOnly: isReadOnly,
1055
+ onMouseDown: this.handleMouseDown,
1056
+ showClearIcon: showClear,
1057
+ customClass: {
1058
+ customTBoxWrap: isDateEdited || value ? '' : _DateWidgetModule["default"].placeHolder
1059
+ },
1060
+ iconOnHover: iconOnHover,
1061
+ isFocus: isPopupReady,
1062
+ autoComplete: false,
1063
+ a11y: a11y
1064
+ }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
1065
+ align: "both",
1066
+ onClick: isDisabled || isReadOnly ? null : this.handleDateIconClick
1067
+ }, /*#__PURE__*/_react["default"].createElement(_icons.Icon, {
1068
+ name: "ZD-datepicker",
1069
+ size: "12"
1070
+ })))), isReadOnly || isDisabled ? null : /*#__PURE__*/_react["default"].createElement(_DateTime["default"], {
1071
+ value: value,
1072
+ isDateTimeField: isDateTime,
1073
+ onSelect: this.handleSelect,
1074
+ timeZone: timeZone,
1075
+ min: min,
1076
+ max: max,
1077
+ maxErrorText: maxErrorText,
1078
+ minErrorText: minErrorText,
1079
+ position: position,
1080
+ isReady: isPopupOpen,
1081
+ isActive: isPopupReady,
1082
+ getRef: getContainerRef,
1083
+ onClick: removeClose,
1084
+ needResponsive: needResponsive,
1085
+ dataId: dataId,
1086
+ defaultTime: defaultTime,
1087
+ needDefaultTime: needDefaultTime,
1088
+ getMethods: this.handleGetMethods,
1089
+ onClear: this.handleDateTimeClear,
1090
+ needAction: isDateTime,
1091
+ onDateSelect: !isDateTime ? this.handleSelect : null,
1092
+ i18nKeys: i18nKeys,
1093
+ is24Hour: is24Hour,
1094
+ isAbsolute: isAbsolutePositioningNeeded,
1095
+ positionsOffset: positionsOffset,
1096
+ targetOffset: targetOffset,
1097
+ isRestrictScroll: isRestrictScroll,
1098
+ dropBoxPortalId: dropBoxPortalId,
1099
+ boxSize: boxSize,
1100
+ onError: onError
1101
+ }));
1102
+ }
1103
+ }]);
1104
+
1105
+ return DateWidgetComponent;
1106
+ }(_react["default"].Component);
1107
+
1108
+ DateWidgetComponent.defaultProps = _defaultProps.DateWidget_defaultProps;
1109
+ DateWidgetComponent.propTypes = _propTypes.DateWidget_propTypes;
1110
+ var DateWidget = (0, _Popup["default"])(DateWidgetComponent);
1111
+ DateWidget.defaultProps = DateWidgetComponent.defaultProps;
1112
+ DateWidget.propTypes = DateWidgetComponent.propTypes; // eslint-disable-next-line no-undef
1113
+ // if (__DOCS__) {
1114
+ // DateWidgetComponent.docs = {
1115
+ // componentGroup: 'Form Elements',
1116
+ // folderName: 'Style Guide',
1117
+ // external: true,
1118
+ // description: ' '
1119
+ // };
1120
+ // // eslint-disable-next-line react/forbid-foreign-prop-types
1121
+ // DateWidget.propTypes = DateWidgetComponent.propTypes;
1122
+ // }
1123
+
1124
+ var _default = DateWidget;
1125
+ exports["default"] = _default;