@bigbinary/neetoui 6.5.11-beta.1 → 6.5.12

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 (187) hide show
  1. package/dist/Accordion.js +1 -1
  2. package/dist/ActionDropdown.js +4 -4
  3. package/dist/Alert.js +5 -5
  4. package/dist/Avatar.js +10 -3
  5. package/dist/Avatar.js.map +1 -1
  6. package/dist/Button.js +3 -4
  7. package/dist/Button.js.map +1 -1
  8. package/dist/Checkbox.js +3 -3
  9. package/dist/ColorPicker.js +9 -8
  10. package/dist/ColorPicker.js.map +1 -1
  11. package/dist/DatePicker.js +3 -3
  12. package/dist/DateTimePicker.js +6 -7
  13. package/dist/DateTimePicker.js.map +1 -1
  14. package/dist/Dropdown.js +4 -4
  15. package/dist/Input.js +3 -3
  16. package/dist/Kbd.js +1 -2
  17. package/dist/Kbd.js.map +1 -1
  18. package/dist/Label.js +1 -2
  19. package/dist/Label.js.map +1 -1
  20. package/dist/Modal.js +5 -5
  21. package/dist/MultiEmailInput.js +5 -6
  22. package/dist/MultiEmailInput.js.map +1 -1
  23. package/dist/NoData.js +2 -3
  24. package/dist/NoData.js.map +1 -1
  25. package/dist/Pagination.js +3 -2
  26. package/dist/Pagination.js.map +1 -1
  27. package/dist/Pane.js +5 -5
  28. package/dist/Popover.js +1 -2
  29. package/dist/Popover.js.map +1 -1
  30. package/dist/Radio.js +3 -3
  31. package/dist/Select.js +183 -30
  32. package/dist/Select.js.map +1 -1
  33. package/dist/Sidebar.js +3 -4
  34. package/dist/Sidebar.js.map +1 -1
  35. package/dist/Slider.js +3 -3
  36. package/dist/Switch.js +3 -3
  37. package/dist/Table.js +4527 -391
  38. package/dist/Table.js.map +1 -1
  39. package/dist/Textarea.js +3 -3
  40. package/dist/TimePicker.js +3 -3
  41. package/dist/TimePickerInput.js +7 -8
  42. package/dist/TimePickerInput.js.map +1 -1
  43. package/dist/Toastr.js +1654 -3
  44. package/dist/Toastr.js.map +1 -1
  45. package/dist/Tooltip.js +1 -2
  46. package/dist/Tooltip.js.map +1 -1
  47. package/dist/Tree.js +2 -1
  48. package/dist/Tree.js.map +1 -1
  49. package/dist/TreeSelect.js +3 -3
  50. package/dist/_commonjsHelpers-ced4e05c.js +29 -0
  51. package/dist/_commonjsHelpers-ced4e05c.js.map +1 -0
  52. package/dist/cjs/Accordion.js +14 -14
  53. package/dist/cjs/Accordion.js.map +1 -1
  54. package/dist/cjs/ActionDropdown.js +4 -4
  55. package/dist/cjs/Alert.js +5 -5
  56. package/dist/cjs/Avatar.js +11 -5
  57. package/dist/cjs/Avatar.js.map +1 -1
  58. package/dist/cjs/Button.js +11 -12
  59. package/dist/cjs/Button.js.map +1 -1
  60. package/dist/cjs/Checkbox.js +3 -3
  61. package/dist/cjs/ColorPicker.js +8 -7
  62. package/dist/cjs/ColorPicker.js.map +1 -1
  63. package/dist/cjs/DatePicker.js +3 -3
  64. package/dist/cjs/DateTimePicker.js +6 -7
  65. package/dist/cjs/DateTimePicker.js.map +1 -1
  66. package/dist/cjs/Dropdown.js +4 -4
  67. package/dist/cjs/Input.js +3 -3
  68. package/dist/cjs/Kbd.js +1 -2
  69. package/dist/cjs/Kbd.js.map +1 -1
  70. package/dist/cjs/Label.js +1 -2
  71. package/dist/cjs/Label.js.map +1 -1
  72. package/dist/cjs/Modal.js +5 -5
  73. package/dist/cjs/MultiEmailInput.js +13 -15
  74. package/dist/cjs/MultiEmailInput.js.map +1 -1
  75. package/dist/cjs/NoData.js +2 -3
  76. package/dist/cjs/NoData.js.map +1 -1
  77. package/dist/cjs/Pagination.js +3 -2
  78. package/dist/cjs/Pagination.js.map +1 -1
  79. package/dist/cjs/Pane.js +5 -5
  80. package/dist/cjs/Popover.js +1 -2
  81. package/dist/cjs/Popover.js.map +1 -1
  82. package/dist/cjs/Radio.js +3 -3
  83. package/dist/cjs/Select.js +193 -26
  84. package/dist/cjs/Select.js.map +1 -1
  85. package/dist/cjs/Sidebar.js +3 -4
  86. package/dist/cjs/Sidebar.js.map +1 -1
  87. package/dist/cjs/Slider.js +3 -3
  88. package/dist/cjs/Switch.js +3 -3
  89. package/dist/cjs/Table.js +4551 -415
  90. package/dist/cjs/Table.js.map +1 -1
  91. package/dist/cjs/Textarea.js +3 -3
  92. package/dist/cjs/TimePicker.js +3 -3
  93. package/dist/cjs/TimePickerInput.js +7 -8
  94. package/dist/cjs/TimePickerInput.js.map +1 -1
  95. package/dist/cjs/Toastr.js +1657 -6
  96. package/dist/cjs/Toastr.js.map +1 -1
  97. package/dist/cjs/Tooltip.js +1 -2
  98. package/dist/cjs/Tooltip.js.map +1 -1
  99. package/dist/cjs/Tree.js +2 -1
  100. package/dist/cjs/Tree.js.map +1 -1
  101. package/dist/cjs/TreeSelect.js +3 -3
  102. package/dist/cjs/_commonjsHelpers-44e4a143.js +33 -0
  103. package/dist/cjs/_commonjsHelpers-44e4a143.js.map +1 -0
  104. package/dist/cjs/formik/ActionBlock.js +2 -3
  105. package/dist/cjs/formik/ActionBlock.js.map +1 -1
  106. package/dist/cjs/formik/BlockNavigation.js +5 -5
  107. package/dist/cjs/formik/Button.js +2 -3
  108. package/dist/cjs/formik/Button.js.map +1 -1
  109. package/dist/cjs/formik/Checkbox.js +3 -3
  110. package/dist/cjs/formik/Input.js +3 -3
  111. package/dist/cjs/formik/MultiEmailInput.js +5 -6
  112. package/dist/cjs/formik/MultiEmailInput.js.map +1 -1
  113. package/dist/cjs/formik/Radio.js +3 -3
  114. package/dist/cjs/formik/Select.js +5 -8
  115. package/dist/cjs/formik/Select.js.map +1 -1
  116. package/dist/cjs/formik/Slider.js +3 -3
  117. package/dist/cjs/formik/Switch.js +3 -3
  118. package/dist/cjs/formik/Textarea.js +3 -3
  119. package/dist/cjs/formik/TreeSelect.js +3 -3
  120. package/dist/cjs/formik/index.js +6 -9
  121. package/dist/cjs/formik/index.js.map +1 -1
  122. package/dist/cjs/index-0e68cfff.js +3934 -0
  123. package/dist/cjs/index-0e68cfff.js.map +1 -0
  124. package/dist/cjs/index-1ad9d2c1.js +9176 -0
  125. package/dist/cjs/index-1ad9d2c1.js.map +1 -0
  126. package/dist/cjs/{index-6e09c7bc.js → index-68589e5c.js} +7 -9
  127. package/dist/cjs/{index-6e09c7bc.js.map → index-68589e5c.js.map} +1 -1
  128. package/dist/cjs/index-a780bb4a.js +3841 -0
  129. package/dist/cjs/index-a780bb4a.js.map +1 -0
  130. package/dist/cjs/index.css +1 -1
  131. package/dist/cjs/index.js +8 -18
  132. package/dist/cjs/index.js.map +1 -1
  133. package/dist/cjs/layouts.js +3 -4
  134. package/dist/cjs/layouts.js.map +1 -1
  135. package/dist/cjs/react-select-creatable.esm-b39742a3.js +6675 -0
  136. package/dist/cjs/react-select-creatable.esm-b39742a3.js.map +1 -0
  137. package/dist/cjs/{useOverlayManager-359ed795.js → useOverlayManager-b8f5f220.js} +2 -2
  138. package/dist/cjs/{useOverlayManager-359ed795.js.map → useOverlayManager-b8f5f220.js.map} +1 -1
  139. package/dist/cjs/{useQueryParams-14f054b3.js → useQueryParams-dcfba9f0.js} +2 -2
  140. package/dist/cjs/{useQueryParams-14f054b3.js.map → useQueryParams-dcfba9f0.js.map} +1 -1
  141. package/dist/formik/ActionBlock.js +2 -3
  142. package/dist/formik/ActionBlock.js.map +1 -1
  143. package/dist/formik/BlockNavigation.js +5 -5
  144. package/dist/formik/Button.js +2 -3
  145. package/dist/formik/Button.js.map +1 -1
  146. package/dist/formik/Checkbox.js +3 -3
  147. package/dist/formik/Input.js +3 -3
  148. package/dist/formik/MultiEmailInput.js +5 -6
  149. package/dist/formik/MultiEmailInput.js.map +1 -1
  150. package/dist/formik/Radio.js +3 -3
  151. package/dist/formik/Select.js +5 -8
  152. package/dist/formik/Select.js.map +1 -1
  153. package/dist/formik/Slider.js +3 -3
  154. package/dist/formik/Switch.js +3 -3
  155. package/dist/formik/Textarea.js +3 -3
  156. package/dist/formik/TreeSelect.js +3 -3
  157. package/dist/formik/index.js +6 -9
  158. package/dist/formik/index.js.map +1 -1
  159. package/dist/index-2123b5e9.js +3927 -0
  160. package/dist/index-2123b5e9.js.map +1 -0
  161. package/dist/index-4883abd9.js +3834 -0
  162. package/dist/index-4883abd9.js.map +1 -0
  163. package/dist/index-75a336d9.js +9151 -0
  164. package/dist/index-75a336d9.js.map +1 -0
  165. package/dist/{index-c8d9113c.js → index-c3d336a5.js} +3 -4
  166. package/dist/index-c3d336a5.js.map +1 -0
  167. package/dist/index.css +1 -1
  168. package/dist/index.js +8 -18
  169. package/dist/index.js.map +1 -1
  170. package/dist/layouts.js +3 -4
  171. package/dist/layouts.js.map +1 -1
  172. package/dist/react-select-creatable.esm-93affeca.js +6644 -0
  173. package/dist/react-select-creatable.esm-93affeca.js.map +1 -0
  174. package/dist/{useOverlayManager-95a474d5.js → useOverlayManager-8651b46d.js} +2 -2
  175. package/dist/{useOverlayManager-95a474d5.js.map → useOverlayManager-8651b46d.js.map} +1 -1
  176. package/dist/{useQueryParams-4e7ddcf8.js → useQueryParams-5059df24.js} +2 -2
  177. package/dist/{useQueryParams-4e7ddcf8.js.map → useQueryParams-5059df24.js.map} +1 -1
  178. package/package.json +2 -13
  179. package/dist/cjs/index-773961dd.js +0 -453
  180. package/dist/cjs/index-773961dd.js.map +0 -1
  181. package/dist/cjs/index-b1ac86d6.js +0 -258
  182. package/dist/cjs/index-b1ac86d6.js.map +0 -1
  183. package/dist/index-b3a8dd29.js +0 -249
  184. package/dist/index-b3a8dd29.js.map +0 -1
  185. package/dist/index-c442518b.js +0 -445
  186. package/dist/index-c442518b.js.map +0 -1
  187. package/dist/index-c8d9113c.js.map +0 -1
@@ -0,0 +1,3841 @@
1
+ 'use strict';
2
+
3
+ var _extends = require('./extends-1b35a664.js');
4
+ var defineProperty = require('./defineProperty-ee86604b.js');
5
+ var slicedToArray = require('./slicedToArray-732a2048.js');
6
+ var objectWithoutProperties = require('./objectWithoutProperties-2fed2d7d.js');
7
+ var React = require('react');
8
+ var ReactDOM = require('react-dom');
9
+ var index = require('./index-63580e68.js');
10
+ var _commonjsHelpers = require('./_commonjsHelpers-44e4a143.js');
11
+ var index$2 = require('./index-302c3d37.js');
12
+ var index$1 = require('./index-68589e5c.js');
13
+ var neetoCist = require('@bigbinary/neeto-cist');
14
+ var Label = require('./Label.js');
15
+ var useId = require('./useId-4e3deb5c.js');
16
+ require('react-router-dom');
17
+ require('./index-a8cc581e.js');
18
+ require('./overlayManager.js');
19
+ var neetoIcons = require('@bigbinary/neeto-icons');
20
+
21
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
+
23
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
+
25
+ var customParseFormat$1 = {exports: {}};
26
+
27
+ (function (module, exports) {
28
+ !function(e,t){module.exports=t();}(_commonjsHelpers.commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
29
+ } (customParseFormat$1));
30
+
31
+ var customParseFormat = customParseFormat$1.exports;
32
+
33
+ var __spreadArray$3 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
34
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
35
+ if (ar || !(i in from)) {
36
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
37
+ ar[i] = from[i];
38
+ }
39
+ }
40
+ return to.concat(ar || Array.prototype.slice.call(from));
41
+ };
42
+ // As defined on the list of supported events: https://reactjs.org/docs/events.html
43
+ var clipboardEvents = ['onCopy', 'onCut', 'onPaste'];
44
+ var compositionEvents = [
45
+ 'onCompositionEnd',
46
+ 'onCompositionStart',
47
+ 'onCompositionUpdate',
48
+ ];
49
+ var focusEvents = ['onFocus', 'onBlur'];
50
+ var formEvents = ['onInput', 'onInvalid', 'onReset', 'onSubmit'];
51
+ var imageEvents = ['onLoad', 'onError'];
52
+ var keyboardEvents = ['onKeyDown', 'onKeyPress', 'onKeyUp'];
53
+ var mediaEvents = [
54
+ 'onAbort',
55
+ 'onCanPlay',
56
+ 'onCanPlayThrough',
57
+ 'onDurationChange',
58
+ 'onEmptied',
59
+ 'onEncrypted',
60
+ 'onEnded',
61
+ 'onError',
62
+ 'onLoadedData',
63
+ 'onLoadedMetadata',
64
+ 'onLoadStart',
65
+ 'onPause',
66
+ 'onPlay',
67
+ 'onPlaying',
68
+ 'onProgress',
69
+ 'onRateChange',
70
+ 'onSeeked',
71
+ 'onSeeking',
72
+ 'onStalled',
73
+ 'onSuspend',
74
+ 'onTimeUpdate',
75
+ 'onVolumeChange',
76
+ 'onWaiting',
77
+ ];
78
+ var mouseEvents = [
79
+ 'onClick',
80
+ 'onContextMenu',
81
+ 'onDoubleClick',
82
+ 'onMouseDown',
83
+ 'onMouseEnter',
84
+ 'onMouseLeave',
85
+ 'onMouseMove',
86
+ 'onMouseOut',
87
+ 'onMouseOver',
88
+ 'onMouseUp',
89
+ ];
90
+ var dragEvents = [
91
+ 'onDrag',
92
+ 'onDragEnd',
93
+ 'onDragEnter',
94
+ 'onDragExit',
95
+ 'onDragLeave',
96
+ 'onDragOver',
97
+ 'onDragStart',
98
+ 'onDrop',
99
+ ];
100
+ var selectionEvents = ['onSelect'];
101
+ var touchEvents = ['onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart'];
102
+ var pointerEvents = [
103
+ 'onPointerDown',
104
+ 'onPointerMove',
105
+ 'onPointerUp',
106
+ 'onPointerCancel',
107
+ 'onGotPointerCapture',
108
+ 'onLostPointerCapture',
109
+ 'onPointerEnter',
110
+ 'onPointerLeave',
111
+ 'onPointerOver',
112
+ 'onPointerOut',
113
+ ];
114
+ var uiEvents = ['onScroll'];
115
+ var wheelEvents = ['onWheel'];
116
+ var animationEvents = [
117
+ 'onAnimationStart',
118
+ 'onAnimationEnd',
119
+ 'onAnimationIteration',
120
+ ];
121
+ var transitionEvents = ['onTransitionEnd'];
122
+ var otherEvents = ['onToggle'];
123
+ var changeEvents = ['onChange'];
124
+ var allEvents = __spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3(__spreadArray$3([], clipboardEvents, true), compositionEvents, true), focusEvents, true), formEvents, true), imageEvents, true), keyboardEvents, true), mediaEvents, true), mouseEvents, true), dragEvents, true), selectionEvents, true), touchEvents, true), pointerEvents, true), uiEvents, true), wheelEvents, true), animationEvents, true), transitionEvents, true), changeEvents, true), otherEvents, true);
125
+ /**
126
+ * Returns an object with on-event callback props curried with provided args.
127
+ * @param {Object} props Props passed to a component.
128
+ * @param {Function=} getArgs A function that returns argument(s) on-event callbacks
129
+ * shall be curried with.
130
+ */
131
+ function makeEventProps(props, getArgs) {
132
+ var eventProps = {};
133
+ allEvents.forEach(function (eventName) {
134
+ var eventHandler = props[eventName];
135
+ if (!eventHandler) {
136
+ return;
137
+ }
138
+ if (getArgs) {
139
+ eventProps[eventName] = (function (event) {
140
+ return eventHandler(event, getArgs(eventName));
141
+ });
142
+ }
143
+ else {
144
+ eventProps[eventName] = eventHandler;
145
+ }
146
+ });
147
+ return eventProps;
148
+ }
149
+
150
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
151
+
152
+ /**
153
+ * Utils
154
+ */
155
+ /**
156
+ * Gets hours from a given date.
157
+ *
158
+ * @param {Date | string} date Date to get hours from
159
+ * @returns {number} Hours
160
+ */
161
+ function getHours(date) {
162
+ if (date instanceof Date) {
163
+ return date.getHours();
164
+ }
165
+ if (typeof date === 'string') {
166
+ var datePieces = date.split(':');
167
+ if (datePieces.length >= 2) {
168
+ var hoursString = datePieces[0];
169
+ if (hoursString) {
170
+ var hours = parseInt(hoursString, 10);
171
+ if (!isNaN(hours)) {
172
+ return hours;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ throw new Error("Failed to get hours from date: ".concat(date, "."));
178
+ }
179
+ /**
180
+ * Gets minutes from a given date.
181
+ *
182
+ * @param {Date | string} date Date to get minutes from
183
+ * @returns {number} Minutes
184
+ */
185
+ function getMinutes(date) {
186
+ if (date instanceof Date) {
187
+ return date.getMinutes();
188
+ }
189
+ if (typeof date === 'string') {
190
+ var datePieces = date.split(':');
191
+ if (datePieces.length >= 2) {
192
+ var minutesString = datePieces[1] || '0';
193
+ var minutes = parseInt(minutesString, 10);
194
+ if (!isNaN(minutes)) {
195
+ return minutes;
196
+ }
197
+ }
198
+ }
199
+ throw new Error("Failed to get minutes from date: ".concat(date, "."));
200
+ }
201
+ /**
202
+ * Gets seconds from a given date.
203
+ *
204
+ * @param {Date | string} date Date to get seconds from
205
+ * @returns {number} Seconds
206
+ */
207
+ function getSeconds(date) {
208
+ if (date instanceof Date) {
209
+ return date.getSeconds();
210
+ }
211
+ if (typeof date === 'string') {
212
+ var datePieces = date.split(':');
213
+ if (datePieces.length >= 2) {
214
+ var secondsWithMillisecondsString = datePieces[2] || '0';
215
+ var seconds = parseInt(secondsWithMillisecondsString, 10);
216
+ if (!isNaN(seconds)) {
217
+ return seconds;
218
+ }
219
+ }
220
+ }
221
+ throw new Error("Failed to get seconds from date: ".concat(date, "."));
222
+ }
223
+ /**
224
+ * Gets milliseconds from a given date.
225
+ *
226
+ * @param {Date | string} date Date to get milliseconds from
227
+ * @returns {number} Milliseconds
228
+ */
229
+ function getMilliseconds(date) {
230
+ if (date instanceof Date) {
231
+ return date.getMilliseconds();
232
+ }
233
+ if (typeof date === 'string') {
234
+ var datePieces = date.split(':');
235
+ if (datePieces.length >= 2) {
236
+ var secondsWithMillisecondsString = datePieces[2] || '0';
237
+ var millisecondsString = secondsWithMillisecondsString.split('.')[1] || '0';
238
+ var milliseconds = parseInt(millisecondsString, 10);
239
+ if (!isNaN(milliseconds)) {
240
+ return milliseconds;
241
+ }
242
+ }
243
+ }
244
+ throw new Error("Failed to get seconds from date: ".concat(date, "."));
245
+ }
246
+ function padStart(num, val) {
247
+ if (val === void 0) { val = 2; }
248
+ var numStr = "".concat(num);
249
+ if (numStr.length >= val) {
250
+ return num;
251
+ }
252
+ return "0000".concat(numStr).slice(-val);
253
+ }
254
+ /**
255
+ * Returns local hours and minutes (hh:mm).
256
+ *
257
+ * @param {Date | string} date Date to get hours and minutes from
258
+ * @returns {string} Local hours and minutes
259
+ */
260
+ function getHoursMinutes(date) {
261
+ var hours = padStart(getHours(date));
262
+ var minutes = padStart(getMinutes(date));
263
+ return "".concat(hours, ":").concat(minutes);
264
+ }
265
+ /**
266
+ * Returns local hours, minutes and seconds (hh:mm:ss).
267
+ *
268
+ * @param {Date | string} date Date to get hours, minutes and seconds from
269
+ * @returns {string} Local hours, minutes and seconds
270
+ */
271
+ function getHoursMinutesSeconds(date) {
272
+ var hours = padStart(getHours(date));
273
+ var minutes = padStart(getMinutes(date));
274
+ var seconds = padStart(getSeconds(date));
275
+ return "".concat(hours, ":").concat(minutes, ":").concat(seconds);
276
+ }
277
+
278
+ function Hand(_a) {
279
+ var _b = _a.angle, angle = _b === void 0 ? 0 : _b, name = _a.name, _c = _a.length, length = _c === void 0 ? 100 : _c, _d = _a.oppositeLength, oppositeLength = _d === void 0 ? 10 : _d, _e = _a.width, width = _e === void 0 ? 1 : _e;
280
+ return (React__default["default"].createElement("div", { className: "react-clock__hand react-clock__".concat(name, "-hand"), style: {
281
+ transform: "rotate(".concat(angle, "deg)"),
282
+ } },
283
+ React__default["default"].createElement("div", { className: "react-clock__hand__body react-clock__".concat(name, "-hand__body"), style: {
284
+ width: "".concat(width, "px"),
285
+ top: "".concat(50 - length / 2, "%"),
286
+ bottom: "".concat(50 - oppositeLength / 2, "%"),
287
+ } })));
288
+ }
289
+
290
+ function Mark(_a) {
291
+ var _b = _a.angle, angle = _b === void 0 ? 0 : _b, _c = _a.length, length = _c === void 0 ? 10 : _c, name = _a.name, _d = _a.width, width = _d === void 0 ? 1 : _d, number = _a.number;
292
+ return (React__default["default"].createElement("div", { className: "react-clock__mark react-clock__".concat(name, "-mark"), style: {
293
+ transform: "rotate(".concat(angle, "deg)"),
294
+ } },
295
+ React__default["default"].createElement("div", { className: "react-clock__mark__body react-clock__".concat(name, "-mark__body"), style: {
296
+ width: "".concat(width, "px"),
297
+ top: 0,
298
+ bottom: "".concat(100 - length / 2, "%"),
299
+ } }),
300
+ number ? (React__default["default"].createElement("div", { className: "react-clock__mark__number", style: {
301
+ transform: "rotate(-".concat(angle, "deg)"),
302
+ top: "".concat(length / 2, "%"),
303
+ } }, number)) : null));
304
+ }
305
+
306
+ var __assign$e = (undefined && undefined.__assign) || function () {
307
+ __assign$e = Object.assign || function(t) {
308
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
309
+ s = arguments[i];
310
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
311
+ t[p] = s[p];
312
+ }
313
+ return t;
314
+ };
315
+ return __assign$e.apply(this, arguments);
316
+ };
317
+ var MinuteMark = React.memo(function MinuteMark(props) {
318
+ return React__default["default"].createElement(Mark, __assign$e({}, props));
319
+ });
320
+
321
+ /**
322
+ * lodash (Custom Build) <https://lodash.com/>
323
+ * Build: `lodash modularize exports="npm" -o ./`
324
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
325
+ * Released under MIT license <https://lodash.com/license>
326
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
327
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
328
+ */
329
+
330
+ /** Used as the `TypeError` message for "Functions" methods. */
331
+ var FUNC_ERROR_TEXT = 'Expected a function';
332
+
333
+ /** Used to stand-in for `undefined` hash values. */
334
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
335
+
336
+ /** `Object#toString` result references. */
337
+ var funcTag = '[object Function]',
338
+ genTag = '[object GeneratorFunction]';
339
+
340
+ /**
341
+ * Used to match `RegExp`
342
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
343
+ */
344
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
345
+
346
+ /** Used to detect host constructors (Safari). */
347
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
348
+
349
+ /** Detect free variable `global` from Node.js. */
350
+ var freeGlobal = typeof _commonjsHelpers.commonjsGlobal == 'object' && _commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.Object === Object && _commonjsHelpers.commonjsGlobal;
351
+
352
+ /** Detect free variable `self`. */
353
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
354
+
355
+ /** Used as a reference to the global object. */
356
+ var root = freeGlobal || freeSelf || Function('return this')();
357
+
358
+ /**
359
+ * Gets the value at `key` of `object`.
360
+ *
361
+ * @private
362
+ * @param {Object} [object] The object to query.
363
+ * @param {string} key The key of the property to get.
364
+ * @returns {*} Returns the property value.
365
+ */
366
+ function getValue(object, key) {
367
+ return object == null ? undefined : object[key];
368
+ }
369
+
370
+ /**
371
+ * Checks if `value` is a host object in IE < 9.
372
+ *
373
+ * @private
374
+ * @param {*} value The value to check.
375
+ * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
376
+ */
377
+ function isHostObject(value) {
378
+ // Many host objects are `Object` objects that can coerce to strings
379
+ // despite having improperly defined `toString` methods.
380
+ var result = false;
381
+ if (value != null && typeof value.toString != 'function') {
382
+ try {
383
+ result = !!(value + '');
384
+ } catch (e) {}
385
+ }
386
+ return result;
387
+ }
388
+
389
+ /** Used for built-in method references. */
390
+ var arrayProto = Array.prototype,
391
+ funcProto = Function.prototype,
392
+ objectProto = Object.prototype;
393
+
394
+ /** Used to detect overreaching core-js shims. */
395
+ var coreJsData = root['__core-js_shared__'];
396
+
397
+ /** Used to detect methods masquerading as native. */
398
+ var maskSrcKey = (function() {
399
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
400
+ return uid ? ('Symbol(src)_1.' + uid) : '';
401
+ }());
402
+
403
+ /** Used to resolve the decompiled source of functions. */
404
+ var funcToString = funcProto.toString;
405
+
406
+ /** Used to check objects for own properties. */
407
+ var hasOwnProperty = objectProto.hasOwnProperty;
408
+
409
+ /**
410
+ * Used to resolve the
411
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
412
+ * of values.
413
+ */
414
+ var objectToString = objectProto.toString;
415
+
416
+ /** Used to detect if a method is native. */
417
+ var reIsNative = RegExp('^' +
418
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
419
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
420
+ );
421
+
422
+ /** Built-in value references. */
423
+ var splice = arrayProto.splice;
424
+
425
+ /* Built-in method references that are verified to be native. */
426
+ var Map$1 = getNative(root, 'Map'),
427
+ nativeCreate = getNative(Object, 'create');
428
+
429
+ /**
430
+ * Creates a hash object.
431
+ *
432
+ * @private
433
+ * @constructor
434
+ * @param {Array} [entries] The key-value pairs to cache.
435
+ */
436
+ function Hash(entries) {
437
+ var index = -1,
438
+ length = entries ? entries.length : 0;
439
+
440
+ this.clear();
441
+ while (++index < length) {
442
+ var entry = entries[index];
443
+ this.set(entry[0], entry[1]);
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Removes all key-value entries from the hash.
449
+ *
450
+ * @private
451
+ * @name clear
452
+ * @memberOf Hash
453
+ */
454
+ function hashClear() {
455
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
456
+ }
457
+
458
+ /**
459
+ * Removes `key` and its value from the hash.
460
+ *
461
+ * @private
462
+ * @name delete
463
+ * @memberOf Hash
464
+ * @param {Object} hash The hash to modify.
465
+ * @param {string} key The key of the value to remove.
466
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
467
+ */
468
+ function hashDelete(key) {
469
+ return this.has(key) && delete this.__data__[key];
470
+ }
471
+
472
+ /**
473
+ * Gets the hash value for `key`.
474
+ *
475
+ * @private
476
+ * @name get
477
+ * @memberOf Hash
478
+ * @param {string} key The key of the value to get.
479
+ * @returns {*} Returns the entry value.
480
+ */
481
+ function hashGet(key) {
482
+ var data = this.__data__;
483
+ if (nativeCreate) {
484
+ var result = data[key];
485
+ return result === HASH_UNDEFINED ? undefined : result;
486
+ }
487
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
488
+ }
489
+
490
+ /**
491
+ * Checks if a hash value for `key` exists.
492
+ *
493
+ * @private
494
+ * @name has
495
+ * @memberOf Hash
496
+ * @param {string} key The key of the entry to check.
497
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
498
+ */
499
+ function hashHas(key) {
500
+ var data = this.__data__;
501
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
502
+ }
503
+
504
+ /**
505
+ * Sets the hash `key` to `value`.
506
+ *
507
+ * @private
508
+ * @name set
509
+ * @memberOf Hash
510
+ * @param {string} key The key of the value to set.
511
+ * @param {*} value The value to set.
512
+ * @returns {Object} Returns the hash instance.
513
+ */
514
+ function hashSet(key, value) {
515
+ var data = this.__data__;
516
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
517
+ return this;
518
+ }
519
+
520
+ // Add methods to `Hash`.
521
+ Hash.prototype.clear = hashClear;
522
+ Hash.prototype['delete'] = hashDelete;
523
+ Hash.prototype.get = hashGet;
524
+ Hash.prototype.has = hashHas;
525
+ Hash.prototype.set = hashSet;
526
+
527
+ /**
528
+ * Creates an list cache object.
529
+ *
530
+ * @private
531
+ * @constructor
532
+ * @param {Array} [entries] The key-value pairs to cache.
533
+ */
534
+ function ListCache(entries) {
535
+ var index = -1,
536
+ length = entries ? entries.length : 0;
537
+
538
+ this.clear();
539
+ while (++index < length) {
540
+ var entry = entries[index];
541
+ this.set(entry[0], entry[1]);
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Removes all key-value entries from the list cache.
547
+ *
548
+ * @private
549
+ * @name clear
550
+ * @memberOf ListCache
551
+ */
552
+ function listCacheClear() {
553
+ this.__data__ = [];
554
+ }
555
+
556
+ /**
557
+ * Removes `key` and its value from the list cache.
558
+ *
559
+ * @private
560
+ * @name delete
561
+ * @memberOf ListCache
562
+ * @param {string} key The key of the value to remove.
563
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
564
+ */
565
+ function listCacheDelete(key) {
566
+ var data = this.__data__,
567
+ index = assocIndexOf(data, key);
568
+
569
+ if (index < 0) {
570
+ return false;
571
+ }
572
+ var lastIndex = data.length - 1;
573
+ if (index == lastIndex) {
574
+ data.pop();
575
+ } else {
576
+ splice.call(data, index, 1);
577
+ }
578
+ return true;
579
+ }
580
+
581
+ /**
582
+ * Gets the list cache value for `key`.
583
+ *
584
+ * @private
585
+ * @name get
586
+ * @memberOf ListCache
587
+ * @param {string} key The key of the value to get.
588
+ * @returns {*} Returns the entry value.
589
+ */
590
+ function listCacheGet(key) {
591
+ var data = this.__data__,
592
+ index = assocIndexOf(data, key);
593
+
594
+ return index < 0 ? undefined : data[index][1];
595
+ }
596
+
597
+ /**
598
+ * Checks if a list cache value for `key` exists.
599
+ *
600
+ * @private
601
+ * @name has
602
+ * @memberOf ListCache
603
+ * @param {string} key The key of the entry to check.
604
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
605
+ */
606
+ function listCacheHas(key) {
607
+ return assocIndexOf(this.__data__, key) > -1;
608
+ }
609
+
610
+ /**
611
+ * Sets the list cache `key` to `value`.
612
+ *
613
+ * @private
614
+ * @name set
615
+ * @memberOf ListCache
616
+ * @param {string} key The key of the value to set.
617
+ * @param {*} value The value to set.
618
+ * @returns {Object} Returns the list cache instance.
619
+ */
620
+ function listCacheSet(key, value) {
621
+ var data = this.__data__,
622
+ index = assocIndexOf(data, key);
623
+
624
+ if (index < 0) {
625
+ data.push([key, value]);
626
+ } else {
627
+ data[index][1] = value;
628
+ }
629
+ return this;
630
+ }
631
+
632
+ // Add methods to `ListCache`.
633
+ ListCache.prototype.clear = listCacheClear;
634
+ ListCache.prototype['delete'] = listCacheDelete;
635
+ ListCache.prototype.get = listCacheGet;
636
+ ListCache.prototype.has = listCacheHas;
637
+ ListCache.prototype.set = listCacheSet;
638
+
639
+ /**
640
+ * Creates a map cache object to store key-value pairs.
641
+ *
642
+ * @private
643
+ * @constructor
644
+ * @param {Array} [entries] The key-value pairs to cache.
645
+ */
646
+ function MapCache(entries) {
647
+ var index = -1,
648
+ length = entries ? entries.length : 0;
649
+
650
+ this.clear();
651
+ while (++index < length) {
652
+ var entry = entries[index];
653
+ this.set(entry[0], entry[1]);
654
+ }
655
+ }
656
+
657
+ /**
658
+ * Removes all key-value entries from the map.
659
+ *
660
+ * @private
661
+ * @name clear
662
+ * @memberOf MapCache
663
+ */
664
+ function mapCacheClear() {
665
+ this.__data__ = {
666
+ 'hash': new Hash,
667
+ 'map': new (Map$1 || ListCache),
668
+ 'string': new Hash
669
+ };
670
+ }
671
+
672
+ /**
673
+ * Removes `key` and its value from the map.
674
+ *
675
+ * @private
676
+ * @name delete
677
+ * @memberOf MapCache
678
+ * @param {string} key The key of the value to remove.
679
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
680
+ */
681
+ function mapCacheDelete(key) {
682
+ return getMapData(this, key)['delete'](key);
683
+ }
684
+
685
+ /**
686
+ * Gets the map value for `key`.
687
+ *
688
+ * @private
689
+ * @name get
690
+ * @memberOf MapCache
691
+ * @param {string} key The key of the value to get.
692
+ * @returns {*} Returns the entry value.
693
+ */
694
+ function mapCacheGet(key) {
695
+ return getMapData(this, key).get(key);
696
+ }
697
+
698
+ /**
699
+ * Checks if a map value for `key` exists.
700
+ *
701
+ * @private
702
+ * @name has
703
+ * @memberOf MapCache
704
+ * @param {string} key The key of the entry to check.
705
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
706
+ */
707
+ function mapCacheHas(key) {
708
+ return getMapData(this, key).has(key);
709
+ }
710
+
711
+ /**
712
+ * Sets the map `key` to `value`.
713
+ *
714
+ * @private
715
+ * @name set
716
+ * @memberOf MapCache
717
+ * @param {string} key The key of the value to set.
718
+ * @param {*} value The value to set.
719
+ * @returns {Object} Returns the map cache instance.
720
+ */
721
+ function mapCacheSet(key, value) {
722
+ getMapData(this, key).set(key, value);
723
+ return this;
724
+ }
725
+
726
+ // Add methods to `MapCache`.
727
+ MapCache.prototype.clear = mapCacheClear;
728
+ MapCache.prototype['delete'] = mapCacheDelete;
729
+ MapCache.prototype.get = mapCacheGet;
730
+ MapCache.prototype.has = mapCacheHas;
731
+ MapCache.prototype.set = mapCacheSet;
732
+
733
+ /**
734
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
735
+ *
736
+ * @private
737
+ * @param {Array} array The array to inspect.
738
+ * @param {*} key The key to search for.
739
+ * @returns {number} Returns the index of the matched value, else `-1`.
740
+ */
741
+ function assocIndexOf(array, key) {
742
+ var length = array.length;
743
+ while (length--) {
744
+ if (eq(array[length][0], key)) {
745
+ return length;
746
+ }
747
+ }
748
+ return -1;
749
+ }
750
+
751
+ /**
752
+ * The base implementation of `_.isNative` without bad shim checks.
753
+ *
754
+ * @private
755
+ * @param {*} value The value to check.
756
+ * @returns {boolean} Returns `true` if `value` is a native function,
757
+ * else `false`.
758
+ */
759
+ function baseIsNative(value) {
760
+ if (!isObject(value) || isMasked(value)) {
761
+ return false;
762
+ }
763
+ var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
764
+ return pattern.test(toSource(value));
765
+ }
766
+
767
+ /**
768
+ * Gets the data for `map`.
769
+ *
770
+ * @private
771
+ * @param {Object} map The map to query.
772
+ * @param {string} key The reference key.
773
+ * @returns {*} Returns the map data.
774
+ */
775
+ function getMapData(map, key) {
776
+ var data = map.__data__;
777
+ return isKeyable(key)
778
+ ? data[typeof key == 'string' ? 'string' : 'hash']
779
+ : data.map;
780
+ }
781
+
782
+ /**
783
+ * Gets the native function at `key` of `object`.
784
+ *
785
+ * @private
786
+ * @param {Object} object The object to query.
787
+ * @param {string} key The key of the method to get.
788
+ * @returns {*} Returns the function if it's native, else `undefined`.
789
+ */
790
+ function getNative(object, key) {
791
+ var value = getValue(object, key);
792
+ return baseIsNative(value) ? value : undefined;
793
+ }
794
+
795
+ /**
796
+ * Checks if `value` is suitable for use as unique object key.
797
+ *
798
+ * @private
799
+ * @param {*} value The value to check.
800
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
801
+ */
802
+ function isKeyable(value) {
803
+ var type = typeof value;
804
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
805
+ ? (value !== '__proto__')
806
+ : (value === null);
807
+ }
808
+
809
+ /**
810
+ * Checks if `func` has its source masked.
811
+ *
812
+ * @private
813
+ * @param {Function} func The function to check.
814
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
815
+ */
816
+ function isMasked(func) {
817
+ return !!maskSrcKey && (maskSrcKey in func);
818
+ }
819
+
820
+ /**
821
+ * Converts `func` to its source code.
822
+ *
823
+ * @private
824
+ * @param {Function} func The function to process.
825
+ * @returns {string} Returns the source code.
826
+ */
827
+ function toSource(func) {
828
+ if (func != null) {
829
+ try {
830
+ return funcToString.call(func);
831
+ } catch (e) {}
832
+ try {
833
+ return (func + '');
834
+ } catch (e) {}
835
+ }
836
+ return '';
837
+ }
838
+
839
+ /**
840
+ * Creates a function that memoizes the result of `func`. If `resolver` is
841
+ * provided, it determines the cache key for storing the result based on the
842
+ * arguments provided to the memoized function. By default, the first argument
843
+ * provided to the memoized function is used as the map cache key. The `func`
844
+ * is invoked with the `this` binding of the memoized function.
845
+ *
846
+ * **Note:** The cache is exposed as the `cache` property on the memoized
847
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
848
+ * constructor with one whose instances implement the
849
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
850
+ * method interface of `delete`, `get`, `has`, and `set`.
851
+ *
852
+ * @static
853
+ * @memberOf _
854
+ * @since 0.1.0
855
+ * @category Function
856
+ * @param {Function} func The function to have its output memoized.
857
+ * @param {Function} [resolver] The function to resolve the cache key.
858
+ * @returns {Function} Returns the new memoized function.
859
+ * @example
860
+ *
861
+ * var object = { 'a': 1, 'b': 2 };
862
+ * var other = { 'c': 3, 'd': 4 };
863
+ *
864
+ * var values = _.memoize(_.values);
865
+ * values(object);
866
+ * // => [1, 2]
867
+ *
868
+ * values(other);
869
+ * // => [3, 4]
870
+ *
871
+ * object.a = 2;
872
+ * values(object);
873
+ * // => [1, 2]
874
+ *
875
+ * // Modify the result cache.
876
+ * values.cache.set(object, ['a', 'b']);
877
+ * values(object);
878
+ * // => ['a', 'b']
879
+ *
880
+ * // Replace `_.memoize.Cache`.
881
+ * _.memoize.Cache = WeakMap;
882
+ */
883
+ function memoize(func, resolver) {
884
+ if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
885
+ throw new TypeError(FUNC_ERROR_TEXT);
886
+ }
887
+ var memoized = function() {
888
+ var args = arguments,
889
+ key = resolver ? resolver.apply(this, args) : args[0],
890
+ cache = memoized.cache;
891
+
892
+ if (cache.has(key)) {
893
+ return cache.get(key);
894
+ }
895
+ var result = func.apply(this, args);
896
+ memoized.cache = cache.set(key, result);
897
+ return result;
898
+ };
899
+ memoized.cache = new (memoize.Cache || MapCache);
900
+ return memoized;
901
+ }
902
+
903
+ // Assign cache to `_.memoize`.
904
+ memoize.Cache = MapCache;
905
+
906
+ /**
907
+ * Performs a
908
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
909
+ * comparison between two values to determine if they are equivalent.
910
+ *
911
+ * @static
912
+ * @memberOf _
913
+ * @since 4.0.0
914
+ * @category Lang
915
+ * @param {*} value The value to compare.
916
+ * @param {*} other The other value to compare.
917
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
918
+ * @example
919
+ *
920
+ * var object = { 'a': 1 };
921
+ * var other = { 'a': 1 };
922
+ *
923
+ * _.eq(object, object);
924
+ * // => true
925
+ *
926
+ * _.eq(object, other);
927
+ * // => false
928
+ *
929
+ * _.eq('a', 'a');
930
+ * // => true
931
+ *
932
+ * _.eq('a', Object('a'));
933
+ * // => false
934
+ *
935
+ * _.eq(NaN, NaN);
936
+ * // => true
937
+ */
938
+ function eq(value, other) {
939
+ return value === other || (value !== value && other !== other);
940
+ }
941
+
942
+ /**
943
+ * Checks if `value` is classified as a `Function` object.
944
+ *
945
+ * @static
946
+ * @memberOf _
947
+ * @since 0.1.0
948
+ * @category Lang
949
+ * @param {*} value The value to check.
950
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
951
+ * @example
952
+ *
953
+ * _.isFunction(_);
954
+ * // => true
955
+ *
956
+ * _.isFunction(/abc/);
957
+ * // => false
958
+ */
959
+ function isFunction(value) {
960
+ // The use of `Object#toString` avoids issues with the `typeof` operator
961
+ // in Safari 8-9 which returns 'object' for typed array and other constructors.
962
+ var tag = isObject(value) ? objectToString.call(value) : '';
963
+ return tag == funcTag || tag == genTag;
964
+ }
965
+
966
+ /**
967
+ * Checks if `value` is the
968
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
969
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
970
+ *
971
+ * @static
972
+ * @memberOf _
973
+ * @since 0.1.0
974
+ * @category Lang
975
+ * @param {*} value The value to check.
976
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
977
+ * @example
978
+ *
979
+ * _.isObject({});
980
+ * // => true
981
+ *
982
+ * _.isObject([1, 2, 3]);
983
+ * // => true
984
+ *
985
+ * _.isObject(_.noop);
986
+ * // => true
987
+ *
988
+ * _.isObject(null);
989
+ * // => false
990
+ */
991
+ function isObject(value) {
992
+ var type = typeof value;
993
+ return !!value && (type == 'object' || type == 'function');
994
+ }
995
+
996
+ var lodash_memoize = memoize;
997
+
998
+ function resolver(options) {
999
+ return JSON.stringify(options);
1000
+ }
1001
+ function isString(el) {
1002
+ return typeof el === 'string';
1003
+ }
1004
+ function isUnique(el, index, arr) {
1005
+ return arr.indexOf(el) === index;
1006
+ }
1007
+ function isAllLowerCase(el) {
1008
+ return el.toLowerCase() === el;
1009
+ }
1010
+ function fixCommas(el) {
1011
+ return el.indexOf(',') === -1 ? el : el.split(',');
1012
+ }
1013
+ function normalizeLocale(locale) {
1014
+ if (!locale) {
1015
+ return locale;
1016
+ }
1017
+ if (locale === 'C' || locale === 'posix' || locale === 'POSIX') {
1018
+ return 'en-US';
1019
+ }
1020
+ // If there's a dot (.) in the locale, it's likely in the format of "en-US.UTF-8", so we only take the first part
1021
+ if (locale.indexOf('.') !== -1) {
1022
+ var _a = locale.split('.')[0], actualLocale = _a === void 0 ? '' : _a;
1023
+ return normalizeLocale(actualLocale);
1024
+ }
1025
+ // If there's an at sign (@) in the locale, it's likely in the format of "en-US@posix", so we only take the first part
1026
+ if (locale.indexOf('@') !== -1) {
1027
+ var _b = locale.split('@')[0], actualLocale = _b === void 0 ? '' : _b;
1028
+ return normalizeLocale(actualLocale);
1029
+ }
1030
+ // If there's a dash (-) in the locale and it's not all lower case, it's already in the format of "en-US", so we return it
1031
+ if (locale.indexOf('-') === -1 || !isAllLowerCase(locale)) {
1032
+ return locale;
1033
+ }
1034
+ var _c = locale.split('-'), splitEl1 = _c[0], _d = _c[1], splitEl2 = _d === void 0 ? '' : _d;
1035
+ return "".concat(splitEl1, "-").concat(splitEl2.toUpperCase());
1036
+ }
1037
+ function getUserLocalesInternal(_a) {
1038
+ var _b = _a === void 0 ? {} : _a, _c = _b.useFallbackLocale, useFallbackLocale = _c === void 0 ? true : _c, _d = _b.fallbackLocale, fallbackLocale = _d === void 0 ? 'en-US' : _d;
1039
+ var languageList = [];
1040
+ if (typeof navigator !== 'undefined') {
1041
+ var rawLanguages = navigator.languages || [];
1042
+ var languages = [];
1043
+ for (var _i = 0, rawLanguages_1 = rawLanguages; _i < rawLanguages_1.length; _i++) {
1044
+ var rawLanguagesItem = rawLanguages_1[_i];
1045
+ languages = languages.concat(fixCommas(rawLanguagesItem));
1046
+ }
1047
+ var rawLanguage = navigator.language;
1048
+ var language = rawLanguage ? fixCommas(rawLanguage) : rawLanguage;
1049
+ languageList = languageList.concat(languages, language);
1050
+ }
1051
+ if (useFallbackLocale) {
1052
+ languageList.push(fallbackLocale);
1053
+ }
1054
+ return languageList.filter(isString).map(normalizeLocale).filter(isUnique);
1055
+ }
1056
+ var getUserLocales = lodash_memoize(getUserLocalesInternal, resolver);
1057
+ function getUserLocaleInternal(options) {
1058
+ return getUserLocales(options)[0] || null;
1059
+ }
1060
+ var getUserLocale = lodash_memoize(getUserLocaleInternal, resolver);
1061
+
1062
+ function formatHour(locale, hour) {
1063
+ return hour.toLocaleString(locale || getUserLocale() || undefined);
1064
+ }
1065
+
1066
+ var __assign$d = (undefined && undefined.__assign) || function () {
1067
+ __assign$d = Object.assign || function(t) {
1068
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1069
+ s = arguments[i];
1070
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1071
+ t[p] = s[p];
1072
+ }
1073
+ return t;
1074
+ };
1075
+ return __assign$d.apply(this, arguments);
1076
+ };
1077
+ var __rest$b = (undefined && undefined.__rest) || function (s, e) {
1078
+ var t = {};
1079
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1080
+ t[p] = s[p];
1081
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1082
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1083
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1084
+ t[p[i]] = s[p[i]];
1085
+ }
1086
+ return t;
1087
+ };
1088
+ var HourMark = React.memo(function HourMark(_a) {
1089
+ var _b = _a.formatHour, formatHour$1 = _b === void 0 ? formatHour : _b, locale = _a.locale, number = _a.number, otherProps = __rest$b(_a, ["formatHour", "locale", "number"]);
1090
+ return React__default["default"].createElement(Mark, __assign$d({ number: number ? formatHour$1(locale, number) : null }, otherProps));
1091
+ });
1092
+
1093
+ function isNumberBetween(min, max) {
1094
+ return function (props, propName, componentName) {
1095
+ var _a = props, _b = propName, value = _a[_b];
1096
+ if (typeof value !== 'undefined') {
1097
+ if (typeof value !== 'number') {
1098
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof value, "` supplied to `").concat(componentName, "`, expected `number`."));
1099
+ }
1100
+ if (value < min || value > max) {
1101
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof value, "` supplied to `").concat(componentName, "`, length must be between ").concat(min, " and ").concat(max, "."));
1102
+ }
1103
+ }
1104
+ // Everything is fine
1105
+ return null;
1106
+ };
1107
+ }
1108
+ var isHandLength = isNumberBetween(0, 100);
1109
+ var isOppositeHandLength = isNumberBetween(-100, 100);
1110
+ var isHandWidth = function isHandWidth(props, propName, componentName) {
1111
+ var _a = props, _b = propName, width = _a[_b];
1112
+ if (typeof width !== 'undefined') {
1113
+ if (typeof width !== 'number') {
1114
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof width, "` supplied to `").concat(componentName, "`, expected `number`."));
1115
+ }
1116
+ if (width < 0) {
1117
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof width, "` supplied to `").concat(componentName, "`, width must be greater or equal to 0."));
1118
+ }
1119
+ }
1120
+ // Everything is fine
1121
+ return null;
1122
+ };
1123
+ var isMarkLength = isHandLength;
1124
+ var isMarkWidth = isHandWidth;
1125
+
1126
+ var Clock = function Clock(_a) {
1127
+ var className = _a.className, formatHour = _a.formatHour, _b = _a.hourHandLength, hourHandLength = _b === void 0 ? 50 : _b, hourHandOppositeLength = _a.hourHandOppositeLength, _c = _a.hourHandWidth, hourHandWidth = _c === void 0 ? 4 : _c, _d = _a.hourMarksLength, hourMarksLength = _d === void 0 ? 10 : _d, _e = _a.hourMarksWidth, hourMarksWidth = _e === void 0 ? 3 : _e, locale = _a.locale, _f = _a.minuteHandLength, minuteHandLength = _f === void 0 ? 70 : _f, minuteHandOppositeLength = _a.minuteHandOppositeLength, _g = _a.minuteHandWidth, minuteHandWidth = _g === void 0 ? 2 : _g, _h = _a.minuteMarksLength, minuteMarksLength = _h === void 0 ? 6 : _h, _j = _a.minuteMarksWidth, minuteMarksWidth = _j === void 0 ? 1 : _j, _k = _a.renderHourMarks, renderHourMarks = _k === void 0 ? true : _k, _l = _a.renderMinuteHand, renderMinuteHand = _l === void 0 ? true : _l, _m = _a.renderMinuteMarks, renderMinuteMarks = _m === void 0 ? true : _m, renderNumbers = _a.renderNumbers, _o = _a.renderSecondHand, renderSecondHand = _o === void 0 ? true : _o, _p = _a.secondHandLength, secondHandLength = _p === void 0 ? 90 : _p, secondHandOppositeLength = _a.secondHandOppositeLength, _q = _a.secondHandWidth, secondHandWidth = _q === void 0 ? 1 : _q, _r = _a.size, size = _r === void 0 ? 150 : _r, useMillisecondPrecision = _a.useMillisecondPrecision, value = _a.value;
1128
+ function renderMinuteMarksFn() {
1129
+ if (!renderMinuteMarks) {
1130
+ return null;
1131
+ }
1132
+ var minuteMarks = [];
1133
+ for (var i = 1; i <= 60; i += 1) {
1134
+ var isHourMark = renderHourMarks && !(i % 5);
1135
+ if (!isHourMark) {
1136
+ minuteMarks.push(React__default["default"].createElement(MinuteMark, { key: "minute_".concat(i), angle: i * 6, length: minuteMarksLength, name: "minute", width: minuteMarksWidth }));
1137
+ }
1138
+ }
1139
+ return minuteMarks;
1140
+ }
1141
+ function renderHourMarksFn() {
1142
+ if (!renderHourMarks) {
1143
+ return null;
1144
+ }
1145
+ var hourMarks = [];
1146
+ for (var i = 1; i <= 12; i += 1) {
1147
+ hourMarks.push(React__default["default"].createElement(HourMark, { key: "hour_".concat(i), angle: i * 30, formatHour: formatHour, length: hourMarksLength, locale: locale, name: "hour", number: renderNumbers ? i : undefined, width: hourMarksWidth }));
1148
+ }
1149
+ return hourMarks;
1150
+ }
1151
+ function renderFace() {
1152
+ return (React__default["default"].createElement("div", { className: "react-clock__face" },
1153
+ renderMinuteMarksFn(),
1154
+ renderHourMarksFn()));
1155
+ }
1156
+ function renderHourHandFn() {
1157
+ var angle = value
1158
+ ? getHours(value) * 30 +
1159
+ getMinutes(value) / 2 +
1160
+ getSeconds(value) / 120 +
1161
+ (useMillisecondPrecision ? getMilliseconds(value) / 120000 : 0)
1162
+ : 0;
1163
+ return (React__default["default"].createElement(Hand, { angle: angle, length: hourHandLength, name: "hour", oppositeLength: hourHandOppositeLength, width: hourHandWidth }));
1164
+ }
1165
+ function renderMinuteHandFn() {
1166
+ if (!renderMinuteHand) {
1167
+ return null;
1168
+ }
1169
+ var angle = value
1170
+ ? getHours(value) * 360 +
1171
+ getMinutes(value) * 6 +
1172
+ getSeconds(value) / 10 +
1173
+ (useMillisecondPrecision ? getMilliseconds(value) / 10000 : 0)
1174
+ : 0;
1175
+ return (React__default["default"].createElement(Hand, { angle: angle, length: minuteHandLength, name: "minute", oppositeLength: minuteHandOppositeLength, width: minuteHandWidth }));
1176
+ }
1177
+ function renderSecondHandFn() {
1178
+ if (!renderSecondHand) {
1179
+ return null;
1180
+ }
1181
+ var angle = value
1182
+ ? getMinutes(value) * 360 +
1183
+ getSeconds(value) * 6 +
1184
+ (useMillisecondPrecision ? getMilliseconds(value) * 0.006 : 0)
1185
+ : 0;
1186
+ return (React__default["default"].createElement(Hand, { angle: angle, length: secondHandLength, name: "second", oppositeLength: secondHandOppositeLength, width: secondHandWidth }));
1187
+ }
1188
+ return (React__default["default"].createElement("time", { className: clsx('react-clock', className), dateTime: value instanceof Date ? value.toISOString() : value || undefined, style: {
1189
+ width: size,
1190
+ height: size,
1191
+ } },
1192
+ renderFace(),
1193
+ renderHourHandFn(),
1194
+ renderMinuteHandFn(),
1195
+ renderSecondHandFn()));
1196
+ };
1197
+ Clock.propTypes = {
1198
+ className: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.arrayOf(index.propTypes.exports.string)]),
1199
+ formatHour: index.propTypes.exports.func,
1200
+ hourHandLength: isHandLength,
1201
+ hourHandOppositeLength: isOppositeHandLength,
1202
+ hourHandWidth: isHandWidth,
1203
+ hourMarksLength: isMarkLength,
1204
+ hourMarksWidth: isMarkWidth,
1205
+ locale: index.propTypes.exports.string,
1206
+ minuteHandLength: isHandLength,
1207
+ minuteHandOppositeLength: isOppositeHandLength,
1208
+ minuteHandWidth: isHandWidth,
1209
+ minuteMarksLength: isMarkLength,
1210
+ minuteMarksWidth: isMarkWidth,
1211
+ renderHourMarks: index.propTypes.exports.bool,
1212
+ renderMinuteHand: index.propTypes.exports.bool,
1213
+ renderMinuteMarks: index.propTypes.exports.bool,
1214
+ renderNumbers: index.propTypes.exports.bool,
1215
+ renderSecondHand: index.propTypes.exports.bool,
1216
+ secondHandLength: isHandLength,
1217
+ secondHandOppositeLength: isOppositeHandLength,
1218
+ secondHandWidth: isHandWidth,
1219
+ size: index.propTypes.exports.oneOfType([index.propTypes.exports.number, index.propTypes.exports.string]),
1220
+ value: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.instanceOf(Date)]),
1221
+ };
1222
+
1223
+ function getRect(element) {
1224
+ return element.getBoundingClientRect();
1225
+ }
1226
+ function detectElementOverflow(element, container) {
1227
+ return {
1228
+ get collidedTop() {
1229
+ return getRect(element).top < getRect(container).top;
1230
+ },
1231
+ get collidedBottom() {
1232
+ return getRect(element).bottom > getRect(container).bottom;
1233
+ },
1234
+ get collidedLeft() {
1235
+ return getRect(element).left < getRect(container).left;
1236
+ },
1237
+ get collidedRight() {
1238
+ return getRect(element).right > getRect(container).right;
1239
+ },
1240
+ get overflowTop() {
1241
+ return getRect(container).top - getRect(element).top;
1242
+ },
1243
+ get overflowBottom() {
1244
+ return getRect(element).bottom - getRect(container).bottom;
1245
+ },
1246
+ get overflowLeft() {
1247
+ return getRect(container).left - getRect(element).left;
1248
+ },
1249
+ get overflowRight() {
1250
+ return getRect(element).right - getRect(container).right;
1251
+ },
1252
+ };
1253
+ }
1254
+
1255
+ var __extends = (undefined && undefined.__extends) || (function () {
1256
+ var extendStatics = function (d, b) {
1257
+ extendStatics = Object.setPrototypeOf ||
1258
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1259
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1260
+ return extendStatics(d, b);
1261
+ };
1262
+ return function (d, b) {
1263
+ if (typeof b !== "function" && b !== null)
1264
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1265
+ extendStatics(d, b);
1266
+ function __() { this.constructor = d; }
1267
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1268
+ };
1269
+ })();
1270
+ var __assign$c = (undefined && undefined.__assign) || function () {
1271
+ __assign$c = Object.assign || function(t) {
1272
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1273
+ s = arguments[i];
1274
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1275
+ t[p] = s[p];
1276
+ }
1277
+ return t;
1278
+ };
1279
+ return __assign$c.apply(this, arguments);
1280
+ };
1281
+ var __rest$a = (undefined && undefined.__rest) || function (s, e) {
1282
+ var t = {};
1283
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1284
+ t[p] = s[p];
1285
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1286
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1287
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1288
+ t[p[i]] = s[p[i]];
1289
+ }
1290
+ return t;
1291
+ };
1292
+ var isBrowser$4 = typeof document !== 'undefined';
1293
+ var isDisplayContentsSupported = isBrowser$4 && 'CSS' in window && 'supports' in window.CSS && CSS.supports('display', 'contents');
1294
+ var isMutationObserverSupported = isBrowser$4 && 'MutationObserver' in window;
1295
+ function capitalize(string) {
1296
+ return (string.charAt(0).toUpperCase() + string.slice(1));
1297
+ }
1298
+ function findScrollContainer(element) {
1299
+ var parent = element.parentElement;
1300
+ while (parent) {
1301
+ var overflow = window.getComputedStyle(parent).overflow;
1302
+ if (overflow.split(' ').every(function (o) { return o === 'auto' || o === 'scroll'; })) {
1303
+ return parent;
1304
+ }
1305
+ parent = parent.parentElement;
1306
+ }
1307
+ return document.documentElement;
1308
+ }
1309
+ function alignAxis(_a) {
1310
+ var axis = _a.axis, container = _a.container, element = _a.element, invertAxis = _a.invertAxis, scrollContainer = _a.scrollContainer, secondary = _a.secondary, spacing = _a.spacing;
1311
+ var style = window.getComputedStyle(element);
1312
+ var parent = container.parentElement;
1313
+ if (!parent) {
1314
+ return;
1315
+ }
1316
+ var scrollContainerCollisions = detectElementOverflow(parent, scrollContainer);
1317
+ var documentCollisions = detectElementOverflow(parent, document.documentElement);
1318
+ var isX = axis === 'x';
1319
+ var startProperty = isX ? 'left' : 'top';
1320
+ var endProperty = isX ? 'right' : 'bottom';
1321
+ var sizeProperty = isX ? 'width' : 'height';
1322
+ var overflowStartProperty = "overflow".concat(capitalize(startProperty));
1323
+ var overflowEndProperty = "overflow".concat(capitalize(endProperty));
1324
+ var scrollProperty = "scroll".concat(capitalize(startProperty));
1325
+ var uppercasedSizeProperty = capitalize(sizeProperty);
1326
+ var offsetSizeProperty = "offset".concat(uppercasedSizeProperty);
1327
+ var clientSizeProperty = "client".concat(uppercasedSizeProperty);
1328
+ var minSizeProperty = "min-".concat(sizeProperty);
1329
+ var scrollbarWidth = scrollContainer[offsetSizeProperty] - scrollContainer[clientSizeProperty];
1330
+ var startSpacing = typeof spacing === 'object' ? spacing[startProperty] : spacing;
1331
+ var availableStartSpace = -Math.max(scrollContainerCollisions[overflowStartProperty], documentCollisions[overflowStartProperty] + document.documentElement[scrollProperty]) - startSpacing;
1332
+ var endSpacing = typeof spacing === 'object' ? spacing[endProperty] : spacing;
1333
+ var availableEndSpace = -Math.max(scrollContainerCollisions[overflowEndProperty], documentCollisions[overflowEndProperty] - document.documentElement[scrollProperty]) -
1334
+ endSpacing -
1335
+ scrollbarWidth;
1336
+ if (secondary) {
1337
+ availableStartSpace += parent[clientSizeProperty];
1338
+ availableEndSpace += parent[clientSizeProperty];
1339
+ }
1340
+ var offsetSize = element[offsetSizeProperty];
1341
+ function displayStart() {
1342
+ element.style[startProperty] = 'auto';
1343
+ element.style[endProperty] = secondary ? '0' : '100%';
1344
+ }
1345
+ function displayEnd() {
1346
+ element.style[startProperty] = secondary ? '0' : '100%';
1347
+ element.style[endProperty] = 'auto';
1348
+ }
1349
+ function displayIfFits(availableSpace, display) {
1350
+ var fits = offsetSize <= availableSpace;
1351
+ if (fits) {
1352
+ display();
1353
+ }
1354
+ return fits;
1355
+ }
1356
+ function displayStartIfFits() {
1357
+ return displayIfFits(availableStartSpace, displayStart);
1358
+ }
1359
+ function displayEndIfFits() {
1360
+ return displayIfFits(availableEndSpace, displayEnd);
1361
+ }
1362
+ function displayWhereverShrinkedFits() {
1363
+ var moreSpaceStart = availableStartSpace > availableEndSpace;
1364
+ var rawMinSize = style.getPropertyValue(minSizeProperty);
1365
+ var minSize = rawMinSize ? parseInt(rawMinSize, 10) : null;
1366
+ function shrinkToSize(size) {
1367
+ var newSize = Math.max(size, minSize || 0);
1368
+ element.style[sizeProperty] = "".concat(newSize, "px");
1369
+ }
1370
+ if (moreSpaceStart) {
1371
+ shrinkToSize(availableStartSpace);
1372
+ displayStart();
1373
+ }
1374
+ else {
1375
+ shrinkToSize(availableEndSpace);
1376
+ displayEnd();
1377
+ }
1378
+ }
1379
+ var fits;
1380
+ if (invertAxis) {
1381
+ fits = displayStartIfFits() || displayEndIfFits();
1382
+ }
1383
+ else {
1384
+ fits = displayEndIfFits() || displayStartIfFits();
1385
+ }
1386
+ if (!fits) {
1387
+ displayWhereverShrinkedFits();
1388
+ }
1389
+ }
1390
+ function alignMainAxis(args) {
1391
+ alignAxis(args);
1392
+ }
1393
+ function alignSecondaryAxis(args) {
1394
+ alignAxis(__assign$c(__assign$c({}, args), { axis: args.axis === 'x' ? 'y' : 'x', secondary: true }));
1395
+ }
1396
+ function alignBothAxis(args) {
1397
+ var invertAxis = args.invertAxis, invertSecondaryAxis = args.invertSecondaryAxis, commonArgs = __rest$a(args, ["invertAxis", "invertSecondaryAxis"]);
1398
+ alignMainAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertAxis }));
1399
+ alignSecondaryAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertSecondaryAxis }));
1400
+ }
1401
+ var Fit = /** @class */ (function (_super) {
1402
+ __extends(Fit, _super);
1403
+ function Fit() {
1404
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1405
+ _this.fit = function () {
1406
+ var _a = _this, scrollContainer = _a.scrollContainer, container = _a.container, element = _a.element;
1407
+ if (!scrollContainer || !container || !element) {
1408
+ return;
1409
+ }
1410
+ var elementWidth = element.clientWidth;
1411
+ var elementHeight = element.clientHeight;
1412
+ // No need to recalculate - already did that for current dimensions
1413
+ if (_this.elementWidth === elementWidth && _this.elementHeight === elementHeight) {
1414
+ return;
1415
+ }
1416
+ // Save the dimensions so that we know we don't need to repeat the function if unchanged
1417
+ _this.elementWidth = elementWidth;
1418
+ _this.elementHeight = elementHeight;
1419
+ var parent = container.parentElement;
1420
+ // Container was unmounted
1421
+ if (!parent) {
1422
+ return;
1423
+ }
1424
+ /**
1425
+ * We need to ensure that <Fit />'s child has a absolute position. Otherwise,
1426
+ * we wouldn't be able to place the child in the correct position.
1427
+ */
1428
+ var style = window.getComputedStyle(element);
1429
+ var position = style.position;
1430
+ if (position !== 'absolute') {
1431
+ element.style.position = 'absolute';
1432
+ }
1433
+ /**
1434
+ * We need to ensure that <Fit />'s parent has a relative or absolute position. Otherwise,
1435
+ * we wouldn't be able to place the child in the correct position.
1436
+ */
1437
+ var parentStyle = window.getComputedStyle(parent);
1438
+ var parentPosition = parentStyle.position;
1439
+ if (parentPosition !== 'relative' && parentPosition !== 'absolute') {
1440
+ parent.style.position = 'relative';
1441
+ }
1442
+ var _b = _this.props, invertAxis = _b.invertAxis, invertSecondaryAxis = _b.invertSecondaryAxis, _c = _b.mainAxis, mainAxis = _c === void 0 ? 'y' : _c, _d = _b.spacing, spacing = _d === void 0 ? 8 : _d;
1443
+ alignBothAxis({
1444
+ axis: mainAxis,
1445
+ container: container,
1446
+ element: element,
1447
+ invertAxis: invertAxis,
1448
+ invertSecondaryAxis: invertSecondaryAxis,
1449
+ scrollContainer: scrollContainer,
1450
+ spacing: spacing,
1451
+ });
1452
+ };
1453
+ return _this;
1454
+ }
1455
+ Fit.prototype.componentDidMount = function () {
1456
+ var _this = this;
1457
+ if (!isDisplayContentsSupported) {
1458
+ // eslint-disable-next-line react/no-find-dom-node
1459
+ var element = ReactDOM.findDOMNode(this);
1460
+ if (!element || !(element instanceof HTMLElement)) {
1461
+ return;
1462
+ }
1463
+ this.container = element;
1464
+ this.element = element;
1465
+ this.scrollContainer = findScrollContainer(element);
1466
+ }
1467
+ this.fit();
1468
+ var onMutation = function () {
1469
+ _this.fit();
1470
+ };
1471
+ if (isMutationObserverSupported && this.element) {
1472
+ var mutationObserver = new MutationObserver(onMutation);
1473
+ mutationObserver.observe(this.element, {
1474
+ attributes: true,
1475
+ attributeFilter: ['class', 'style'],
1476
+ });
1477
+ }
1478
+ };
1479
+ Fit.prototype.render = function () {
1480
+ var _this = this;
1481
+ var children = this.props.children;
1482
+ var child = React__default["default"].Children.only(children);
1483
+ if (isDisplayContentsSupported) {
1484
+ return (React__default["default"].createElement("span", { ref: function (container) {
1485
+ _this.container = container;
1486
+ var element = container && container.firstElementChild;
1487
+ if (!element || !(element instanceof HTMLElement)) {
1488
+ return;
1489
+ }
1490
+ _this.element = element;
1491
+ _this.scrollContainer = findScrollContainer(element);
1492
+ }, style: { display: 'contents' } }, child));
1493
+ }
1494
+ return child;
1495
+ };
1496
+ Fit.propTypes = {
1497
+ children: index.propTypes.exports.node.isRequired,
1498
+ invertAxis: index.propTypes.exports.bool,
1499
+ invertSecondaryAxis: index.propTypes.exports.bool,
1500
+ mainAxis: index.propTypes.exports.oneOf(['x', 'y']),
1501
+ spacing: index.propTypes.exports.oneOfType([
1502
+ index.propTypes.exports.number,
1503
+ index.propTypes.exports.shape({
1504
+ bottom: index.propTypes.exports.number.isRequired,
1505
+ left: index.propTypes.exports.number.isRequired,
1506
+ right: index.propTypes.exports.number.isRequired,
1507
+ top: index.propTypes.exports.number.isRequired,
1508
+ }),
1509
+ ]),
1510
+ };
1511
+ return Fit;
1512
+ }(React.Component));
1513
+
1514
+ function Divider$1(_a) {
1515
+ var children = _a.children;
1516
+ return React__default["default"].createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
1517
+ }
1518
+
1519
+ var allowedVariants = ['normal', 'small-caps'];
1520
+ /**
1521
+ * Gets font CSS shorthand property given element.
1522
+ *
1523
+ * @param {HTMLElement} element Element to get font CSS shorthand property from
1524
+ */
1525
+ function getFontShorthand(element) {
1526
+ if (!element) {
1527
+ return '';
1528
+ }
1529
+ var style = window.getComputedStyle(element);
1530
+ if (style.font) {
1531
+ return style.font;
1532
+ }
1533
+ var isFontDefined = style.fontFamily !== '';
1534
+ if (!isFontDefined) {
1535
+ return '';
1536
+ }
1537
+ var fontVariant = allowedVariants.includes(style.fontVariant) ? style.fontVariant : 'normal';
1538
+ return "".concat(style.fontStyle, " ").concat(fontVariant, " ").concat(style.fontWeight, " ").concat(style.fontSize, " / ").concat(style.lineHeight, " ").concat(style.fontFamily);
1539
+ }
1540
+ var cachedCanvas;
1541
+ /**
1542
+ * Measures text width given text and font CSS shorthand.
1543
+ *
1544
+ * @param {string} text Text to measure
1545
+ * @param {string} font Font to use when measuring the text
1546
+ */
1547
+ function measureText(text, font) {
1548
+ var canvas = cachedCanvas || (cachedCanvas = document.createElement('canvas'));
1549
+ var context = canvas.getContext('2d');
1550
+ // Context type not supported
1551
+ if (!context) {
1552
+ return null;
1553
+ }
1554
+ context.font = font;
1555
+ var width = context.measureText(text).width;
1556
+ return Math.ceil(width);
1557
+ }
1558
+ /**
1559
+ * Updates input element width to fit its content given input element
1560
+ * @param {HTMLInputElement} element
1561
+ */
1562
+ function updateInputWidth(element) {
1563
+ if (typeof document === 'undefined' || !element) {
1564
+ return null;
1565
+ }
1566
+ var font = getFontShorthand(element);
1567
+ var text = element.value || element.placeholder;
1568
+ var width = measureText(text, font);
1569
+ if (width === null) {
1570
+ return null;
1571
+ }
1572
+ element.style.width = "".concat(width, "px");
1573
+ return width;
1574
+ }
1575
+
1576
+ var isBrowser$3 = typeof document !== 'undefined';
1577
+ var useIsomorphicLayoutEffect$1 = isBrowser$3 ? React.useLayoutEffect : React.useEffect;
1578
+ var isIEOrEdgeLegacy$1 = isBrowser$3 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
1579
+ var isFirefox$1 = isBrowser$3 && /Firefox/.test(navigator.userAgent);
1580
+ function onFocus$1(event) {
1581
+ var target = event.target;
1582
+ if (isIEOrEdgeLegacy$1) {
1583
+ requestAnimationFrame(function () { return target.select(); });
1584
+ }
1585
+ else {
1586
+ target.select();
1587
+ }
1588
+ }
1589
+ function updateInputWidthOnLoad$1(element) {
1590
+ if (document.readyState === 'complete') {
1591
+ return;
1592
+ }
1593
+ function onLoad() {
1594
+ updateInputWidth(element);
1595
+ }
1596
+ window.addEventListener('load', onLoad);
1597
+ }
1598
+ function updateInputWidthOnFontLoad$1(element) {
1599
+ if (!document.fonts) {
1600
+ return;
1601
+ }
1602
+ var font = getFontShorthand(element);
1603
+ if (!font) {
1604
+ return;
1605
+ }
1606
+ var isFontLoaded = document.fonts.check(font);
1607
+ if (isFontLoaded) {
1608
+ return;
1609
+ }
1610
+ function onLoadingDone() {
1611
+ updateInputWidth(element);
1612
+ }
1613
+ document.fonts.addEventListener('loadingdone', onLoadingDone);
1614
+ }
1615
+ function getSelectionString$1(input) {
1616
+ /**
1617
+ * window.getSelection().toString() returns empty string in IE11 and Firefox,
1618
+ * so alternatives come first.
1619
+ */
1620
+ if (input &&
1621
+ 'selectionStart' in input &&
1622
+ input.selectionStart !== null &&
1623
+ 'selectionEnd' in input &&
1624
+ input.selectionEnd !== null) {
1625
+ return input.value.slice(input.selectionStart, input.selectionEnd);
1626
+ }
1627
+ if ('getSelection' in window) {
1628
+ var selection = window.getSelection();
1629
+ return selection && selection.toString();
1630
+ }
1631
+ return null;
1632
+ }
1633
+ function makeOnKeyPress$1(maxLength) {
1634
+ if (maxLength === null) {
1635
+ return undefined;
1636
+ }
1637
+ /**
1638
+ * Prevents keystrokes that would not produce a number or when value after keystroke would
1639
+ * exceed maxLength.
1640
+ */
1641
+ return function onKeyPress(event) {
1642
+ if (isFirefox$1) {
1643
+ // See https://github.com/wojtekmaj/react-time-picker/issues/92
1644
+ return;
1645
+ }
1646
+ var key = event.key, input = event.target;
1647
+ var value = input.value;
1648
+ var isNumberKey = key.length === 1 && /\d/.test(key);
1649
+ var selection = getSelectionString$1(input);
1650
+ if (!isNumberKey || !(selection || value.length < maxLength)) {
1651
+ event.preventDefault();
1652
+ }
1653
+ };
1654
+ }
1655
+ function Input$1(_a) {
1656
+ var ariaLabel = _a.ariaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, inputRef = _a.inputRef, max = _a.max, min = _a.min, name = _a.name, nameForClass = _a.nameForClass, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, _b = _a.placeholder, placeholder = _b === void 0 ? '--' : _b, required = _a.required, showLeadingZeros = _a.showLeadingZeros, step = _a.step, value = _a.value;
1657
+ useIsomorphicLayoutEffect$1(function () {
1658
+ if (!inputRef || !inputRef.current) {
1659
+ return;
1660
+ }
1661
+ updateInputWidth(inputRef.current);
1662
+ updateInputWidthOnLoad$1(inputRef.current);
1663
+ updateInputWidthOnFontLoad$1(inputRef.current);
1664
+ }, [inputRef, value]);
1665
+ var hasLeadingZero = showLeadingZeros &&
1666
+ value &&
1667
+ Number(value) < 10 &&
1668
+ (value === '0' || !value.toString().startsWith('0'));
1669
+ var maxLength = max ? max.toString().length : null;
1670
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
1671
+ hasLeadingZero ? React__default["default"].createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
1672
+ React__default["default"].createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx("".concat(className, "__input"), "".concat(className, "__").concat(nameForClass || name), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), "data-input": "true", disabled: disabled, inputMode: "numeric", max: max, min: min, name: name, onChange: onChange, onFocus: onFocus$1, onKeyDown: onKeyDown, onKeyPress: makeOnKeyPress$1(maxLength), onKeyUp: function (event) {
1673
+ updateInputWidth(event.target);
1674
+ if (onKeyUp) {
1675
+ onKeyUp(event);
1676
+ }
1677
+ }, placeholder: placeholder, ref: inputRef, required: required, step: step, type: "number", value: value !== null ? value : '' })));
1678
+ }
1679
+
1680
+ function convert12to24$1(hour12, amPm) {
1681
+ var hour24 = Number(hour12);
1682
+ if (amPm === 'am' && hour24 === 12) {
1683
+ hour24 = 0;
1684
+ }
1685
+ else if (amPm === 'pm' && hour24 < 12) {
1686
+ hour24 += 12;
1687
+ }
1688
+ return hour24;
1689
+ }
1690
+ function convert24to12$1(hour24) {
1691
+ var hour12 = Number(hour24) % 12 || 12;
1692
+ return [hour12, Number(hour24) < 12 ? 'am' : 'pm'];
1693
+ }
1694
+
1695
+ var formatterCache$1 = new Map();
1696
+ function getFormatter$1(options) {
1697
+ return function formatter(locale, date) {
1698
+ var localeWithDefault = locale || getUserLocale();
1699
+ if (!formatterCache$1.has(localeWithDefault)) {
1700
+ formatterCache$1.set(localeWithDefault, new Map());
1701
+ }
1702
+ var formatterCacheLocale = formatterCache$1.get(localeWithDefault);
1703
+ if (!formatterCacheLocale.has(options)) {
1704
+ formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault || undefined, options).format);
1705
+ }
1706
+ return formatterCacheLocale.get(options)(date);
1707
+ };
1708
+ }
1709
+ var numberFormatterCache$1 = new Map();
1710
+ function getNumberFormatter$1(options) {
1711
+ return function (locale, number) {
1712
+ var localeWithDefault = locale || getUserLocale();
1713
+ if (!numberFormatterCache$1.has(localeWithDefault)) {
1714
+ numberFormatterCache$1.set(localeWithDefault, new Map());
1715
+ }
1716
+ var numberFormatterCacheLocale = numberFormatterCache$1.get(localeWithDefault);
1717
+ if (!numberFormatterCacheLocale.has(options)) {
1718
+ numberFormatterCacheLocale.set(options, new Intl.NumberFormat(localeWithDefault || undefined, options).format);
1719
+ }
1720
+ return numberFormatterCacheLocale.get(options)(number);
1721
+ };
1722
+ }
1723
+
1724
+ var nines$1 = ['9', '٩'];
1725
+ var ninesRegExp$1 = new RegExp("[".concat(nines$1.join(''), "]"));
1726
+ var amPmFormatter$1 = getFormatter$1({ hour: 'numeric' });
1727
+ function getAmPmLabels$1(locale) {
1728
+ var amString = amPmFormatter$1(locale, new Date(2017, 0, 1, 9));
1729
+ var pmString = amPmFormatter$1(locale, new Date(2017, 0, 1, 21));
1730
+ var _a = amString.split(ninesRegExp$1), am1 = _a[0], am2 = _a[1];
1731
+ var _b = pmString.split(ninesRegExp$1), pm1 = _b[0], pm2 = _b[1];
1732
+ if (pm2 !== undefined) {
1733
+ // If pm2 is undefined, nine was not found in pmString - this locale is not using 12-hour time
1734
+ if (am1 !== pm1) {
1735
+ return [am1, pm1].map(function (el) { return el.trim(); });
1736
+ }
1737
+ if (am2 !== pm2) {
1738
+ return [am2, pm2].map(function (el) { return el.trim(); });
1739
+ }
1740
+ }
1741
+ // Fallback
1742
+ return ['AM', 'PM'];
1743
+ }
1744
+ function isValidNumber$1(num) {
1745
+ return num !== null && num !== false && !Number.isNaN(Number(num));
1746
+ }
1747
+ function safeMin$1() {
1748
+ var args = [];
1749
+ for (var _i = 0; _i < arguments.length; _i++) {
1750
+ args[_i] = arguments[_i];
1751
+ }
1752
+ return Math.min.apply(Math, args.filter(isValidNumber$1));
1753
+ }
1754
+ function safeMax$1() {
1755
+ var args = [];
1756
+ for (var _i = 0; _i < arguments.length; _i++) {
1757
+ args[_i] = arguments[_i];
1758
+ }
1759
+ return Math.max.apply(Math, args.filter(isValidNumber$1));
1760
+ }
1761
+
1762
+ var __assign$b = (undefined && undefined.__assign) || function () {
1763
+ __assign$b = Object.assign || function(t) {
1764
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1765
+ s = arguments[i];
1766
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1767
+ t[p] = s[p];
1768
+ }
1769
+ return t;
1770
+ };
1771
+ return __assign$b.apply(this, arguments);
1772
+ };
1773
+ var __rest$9 = (undefined && undefined.__rest) || function (s, e) {
1774
+ var t = {};
1775
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1776
+ t[p] = s[p];
1777
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1778
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1779
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1780
+ t[p[i]] = s[p[i]];
1781
+ }
1782
+ return t;
1783
+ };
1784
+ function Hour12Input$1(_a) {
1785
+ var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$9(_a, ["amPm", "maxTime", "minTime", "value"]);
1786
+ var maxHour = safeMin$1(12, maxTime &&
1787
+ (function () {
1788
+ var _a = convert24to12$1(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
1789
+ if (maxAmPm !== amPm) {
1790
+ // pm is always after am, so we should ignore validation
1791
+ return null;
1792
+ }
1793
+ return maxHourResult;
1794
+ })());
1795
+ var minHour = safeMax$1(1, minTime &&
1796
+ (function () {
1797
+ var _a = convert24to12$1(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
1798
+ if (
1799
+ // pm is always after am, so we should ignore validation
1800
+ minAmPm !== amPm ||
1801
+ // If minHour is 12 am/pm, user should be able to enter 12, 1, ..., 11.
1802
+ minHourResult === 12) {
1803
+ return null;
1804
+ }
1805
+ return minHourResult;
1806
+ })());
1807
+ var value12 = value ? convert24to12$1(value)[0].toString() : '';
1808
+ return (React__default["default"].createElement(Input$1, __assign$b({ max: maxHour, min: minHour, name: "hour12", nameForClass: "hour", value: value12 }, otherProps)));
1809
+ }
1810
+
1811
+ var __assign$a = (undefined && undefined.__assign) || function () {
1812
+ __assign$a = Object.assign || function(t) {
1813
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1814
+ s = arguments[i];
1815
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1816
+ t[p] = s[p];
1817
+ }
1818
+ return t;
1819
+ };
1820
+ return __assign$a.apply(this, arguments);
1821
+ };
1822
+ var __rest$8 = (undefined && undefined.__rest) || function (s, e) {
1823
+ var t = {};
1824
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1825
+ t[p] = s[p];
1826
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1827
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1828
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1829
+ t[p[i]] = s[p[i]];
1830
+ }
1831
+ return t;
1832
+ };
1833
+ function Hour24Input$1(_a) {
1834
+ var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$8(_a, ["maxTime", "minTime"]);
1835
+ var maxHour = safeMin$1(23, maxTime && getHours(maxTime));
1836
+ var minHour = safeMax$1(0, minTime && getHours(minTime));
1837
+ return React__default["default"].createElement(Input$1, __assign$a({ max: maxHour, min: minHour, name: "hour24", nameForClass: "hour" }, otherProps));
1838
+ }
1839
+
1840
+ var __assign$9 = (undefined && undefined.__assign) || function () {
1841
+ __assign$9 = Object.assign || function(t) {
1842
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1843
+ s = arguments[i];
1844
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1845
+ t[p] = s[p];
1846
+ }
1847
+ return t;
1848
+ };
1849
+ return __assign$9.apply(this, arguments);
1850
+ };
1851
+ var __rest$7 = (undefined && undefined.__rest) || function (s, e) {
1852
+ var t = {};
1853
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1854
+ t[p] = s[p];
1855
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1856
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1857
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1858
+ t[p[i]] = s[p[i]];
1859
+ }
1860
+ return t;
1861
+ };
1862
+ function MinuteInput$1(_a) {
1863
+ var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$7(_a, ["hour", "maxTime", "minTime", "showLeadingZeros"]);
1864
+ function isSameHour(date) {
1865
+ return hour === getHours(date).toString();
1866
+ }
1867
+ var maxMinute = safeMin$1(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
1868
+ var minMinute = safeMax$1(0, minTime && isSameHour(minTime) && getMinutes(minTime));
1869
+ return (React__default["default"].createElement(Input$1, __assign$9({ max: maxMinute, min: minMinute, name: "minute", showLeadingZeros: showLeadingZeros }, otherProps)));
1870
+ }
1871
+
1872
+ var __assign$8 = (undefined && undefined.__assign) || function () {
1873
+ __assign$8 = Object.assign || function(t) {
1874
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1875
+ s = arguments[i];
1876
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1877
+ t[p] = s[p];
1878
+ }
1879
+ return t;
1880
+ };
1881
+ return __assign$8.apply(this, arguments);
1882
+ };
1883
+ var __rest$6 = (undefined && undefined.__rest) || function (s, e) {
1884
+ var t = {};
1885
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1886
+ t[p] = s[p];
1887
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1888
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1889
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1890
+ t[p[i]] = s[p[i]];
1891
+ }
1892
+ return t;
1893
+ };
1894
+ function SecondInput$1(_a) {
1895
+ var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, minute = _a.minute, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$6(_a, ["hour", "maxTime", "minTime", "minute", "showLeadingZeros"]);
1896
+ function isSameMinute(date) {
1897
+ return hour === getHours(date).toString() && minute === getMinutes(date).toString();
1898
+ }
1899
+ var maxSecond = safeMin$1(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
1900
+ var minSecond = safeMax$1(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
1901
+ return (React__default["default"].createElement(Input$1, __assign$8({ max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros }, otherProps)));
1902
+ }
1903
+
1904
+ function NativeInput$1(_a) {
1905
+ var ariaLabel = _a.ariaLabel, disabled = _a.disabled, maxTime = _a.maxTime, minTime = _a.minTime, name = _a.name, onChange = _a.onChange, required = _a.required, value = _a.value, valueType = _a.valueType;
1906
+ var nativeValueParser = (function () {
1907
+ switch (valueType) {
1908
+ case 'hour':
1909
+ return function (receivedValue) { return "".concat(getHours(receivedValue), ":00"); };
1910
+ case 'minute':
1911
+ return getHoursMinutes;
1912
+ case 'second':
1913
+ return getHoursMinutesSeconds;
1914
+ default:
1915
+ throw new Error('Invalid valueType');
1916
+ }
1917
+ })();
1918
+ var step = (function () {
1919
+ switch (valueType) {
1920
+ case 'hour':
1921
+ return 3600;
1922
+ case 'minute':
1923
+ return 60;
1924
+ case 'second':
1925
+ return 1;
1926
+ default:
1927
+ throw new Error('Invalid valueType');
1928
+ }
1929
+ })();
1930
+ function stopPropagation(event) {
1931
+ event.stopPropagation();
1932
+ }
1933
+ return (React__default["default"].createElement("input", { "aria-label": ariaLabel, disabled: disabled, hidden: true, max: maxTime ? nativeValueParser(maxTime) : undefined, min: minTime ? nativeValueParser(minTime) : undefined, name: name, onChange: onChange, onFocus: stopPropagation, required: required, step: step, style: {
1934
+ visibility: 'hidden',
1935
+ position: 'absolute',
1936
+ zIndex: '-999',
1937
+ }, type: "time", value: value ? nativeValueParser(value) : '' }));
1938
+ }
1939
+
1940
+ function AmPm$1(_a) {
1941
+ var ariaLabel = _a.ariaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, inputRef = _a.inputRef, locale = _a.locale, maxTime = _a.maxTime, minTime = _a.minTime, onChange = _a.onChange, onKeyDown = _a.onKeyDown, required = _a.required, value = _a.value;
1942
+ var amDisabled = minTime ? convert24to12$1(getHours(minTime))[1] === 'pm' : false;
1943
+ var pmDisabled = maxTime ? convert24to12$1(getHours(maxTime))[1] === 'am' : false;
1944
+ var name = 'amPm';
1945
+ var _b = getAmPmLabels$1(locale), amLabel = _b[0], pmLabel = _b[1];
1946
+ return (React__default["default"].createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx("".concat(className, "__input"), "".concat(className, "__").concat(name)), "data-input": "true", "data-select": "true", disabled: disabled, name: name, onChange: onChange, onKeyDown: onKeyDown, ref: inputRef, required: required, value: value !== null ? value : '' },
1947
+ !value && React__default["default"].createElement("option", { value: "" }, "--"),
1948
+ React__default["default"].createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
1949
+ React__default["default"].createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
1950
+ }
1951
+
1952
+ var __assign$7 = (undefined && undefined.__assign) || function () {
1953
+ __assign$7 = Object.assign || function(t) {
1954
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1955
+ s = arguments[i];
1956
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1957
+ t[p] = s[p];
1958
+ }
1959
+ return t;
1960
+ };
1961
+ return __assign$7.apply(this, arguments);
1962
+ };
1963
+ var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
1964
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1965
+ if (ar || !(i in from)) {
1966
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1967
+ ar[i] = from[i];
1968
+ }
1969
+ }
1970
+ return to.concat(ar || Array.prototype.slice.call(from));
1971
+ };
1972
+ var getFormatterOptionsCache$1 = {};
1973
+ var allViews$4 = ['hour', 'minute', 'second'];
1974
+ function isInternalInput$1(element) {
1975
+ return element.dataset.input === 'true';
1976
+ }
1977
+ function findInput$1(element, property) {
1978
+ var nextElement = element;
1979
+ do {
1980
+ nextElement = nextElement[property];
1981
+ } while (nextElement && !isInternalInput$1(nextElement));
1982
+ return nextElement;
1983
+ }
1984
+ function focus$1(element) {
1985
+ if (element) {
1986
+ element.focus();
1987
+ }
1988
+ }
1989
+ function renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances) {
1990
+ var usedFunctions = [];
1991
+ var pattern = new RegExp(Object.keys(elementFunctions)
1992
+ .map(function (el) { return "".concat(el, "+"); })
1993
+ .join('|'), 'g');
1994
+ var matches = placeholder.match(pattern);
1995
+ return placeholder.split(pattern).reduce(function (arr, element, index) {
1996
+ var divider = element && (
1997
+ // eslint-disable-next-line react/no-array-index-key
1998
+ React__default["default"].createElement(Divider$1, { key: "separator_".concat(index) }, element));
1999
+ var res = __spreadArray$2(__spreadArray$2([], arr, true), [divider], false);
2000
+ var currentMatch = matches && matches[index];
2001
+ if (currentMatch) {
2002
+ var renderFunction = elementFunctions[currentMatch] ||
2003
+ elementFunctions[Object.keys(elementFunctions).find(function (elementFunction) {
2004
+ return currentMatch.match(elementFunction);
2005
+ })];
2006
+ if (!renderFunction) {
2007
+ return res;
2008
+ }
2009
+ if (!allowMultipleInstances && usedFunctions.includes(renderFunction)) {
2010
+ res.push(currentMatch);
2011
+ }
2012
+ else {
2013
+ res.push(renderFunction(currentMatch, index));
2014
+ usedFunctions.push(renderFunction);
2015
+ }
2016
+ }
2017
+ return res;
2018
+ }, []);
2019
+ }
2020
+ var formatNumber$1 = getNumberFormatter$1({ useGrouping: false });
2021
+ function TimeInput$1(_a) {
2022
+ var amPmAriaLabel = _a.amPmAriaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, format = _a.format, hourAriaLabel = _a.hourAriaLabel, hourPlaceholder = _a.hourPlaceholder, _b = _a.isClockOpen, isClockOpenProps = _b === void 0 ? null : _b, locale = _a.locale, _c = _a.maxDetail, maxDetail = _c === void 0 ? 'minute' : _c, maxTime = _a.maxTime, minTime = _a.minTime, minuteAriaLabel = _a.minuteAriaLabel, minutePlaceholder = _a.minutePlaceholder, _d = _a.name, name = _d === void 0 ? 'time' : _d, nativeInputAriaLabel = _a.nativeInputAriaLabel, onChangeProps = _a.onChange, onInvalidChange = _a.onInvalidChange, required = _a.required, secondAriaLabel = _a.secondAriaLabel, secondPlaceholder = _a.secondPlaceholder, valueProps = _a.value;
2023
+ var _e = React.useState(null), amPm = _e[0], setAmPm = _e[1];
2024
+ var _f = React.useState(null), hour = _f[0], setHour = _f[1];
2025
+ var _g = React.useState(null), minute = _g[0], setMinute = _g[1];
2026
+ var _h = React.useState(null), second = _h[0], setSecond = _h[1];
2027
+ var _j = React.useState(null), value = _j[0], setValue = _j[1];
2028
+ var amPmInput = React.useRef(null);
2029
+ var hour12Input = React.useRef(null);
2030
+ var hour24Input = React.useRef(null);
2031
+ var minuteInput = React.useRef(null);
2032
+ var secondInput = React.useRef(null);
2033
+ var _k = React.useState(isClockOpenProps), isClockOpen = _k[0], setIsClockOpen = _k[1];
2034
+ var lastPressedKey = React.useRef();
2035
+ React.useEffect(function () {
2036
+ setIsClockOpen(isClockOpenProps);
2037
+ }, [isClockOpenProps]);
2038
+ React.useEffect(function () {
2039
+ var nextValue = valueProps;
2040
+ if (nextValue) {
2041
+ setAmPm(convert24to12$1(getHours(nextValue))[1]);
2042
+ setHour(getHours(nextValue).toString());
2043
+ setMinute(getMinutes(nextValue).toString());
2044
+ setSecond(getSeconds(nextValue).toString());
2045
+ setValue(nextValue);
2046
+ }
2047
+ else {
2048
+ setAmPm(null);
2049
+ setHour(null);
2050
+ setMinute(null);
2051
+ setSecond(null);
2052
+ setValue(null);
2053
+ }
2054
+ }, [
2055
+ valueProps,
2056
+ minTime,
2057
+ maxTime,
2058
+ maxDetail,
2059
+ // Toggling clock visibility resets values
2060
+ isClockOpen,
2061
+ ]);
2062
+ var valueType = maxDetail;
2063
+ var formatTime = (function () {
2064
+ var level = allViews$4.indexOf(maxDetail);
2065
+ var formatterOptions = getFormatterOptionsCache$1[level] ||
2066
+ (function () {
2067
+ var options = { hour: 'numeric' };
2068
+ if (level >= 1) {
2069
+ options.minute = 'numeric';
2070
+ }
2071
+ if (level >= 2) {
2072
+ options.second = 'numeric';
2073
+ }
2074
+ getFormatterOptionsCache$1[level] = options;
2075
+ return options;
2076
+ })();
2077
+ return getFormatter$1(formatterOptions);
2078
+ })();
2079
+ /**
2080
+ * Gets current value in a desired format.
2081
+ */
2082
+ function getProcessedValue(value) {
2083
+ var processFunction = (function () {
2084
+ switch (valueType) {
2085
+ case 'hour':
2086
+ case 'minute':
2087
+ return getHoursMinutes;
2088
+ case 'second':
2089
+ return getHoursMinutesSeconds;
2090
+ default:
2091
+ throw new Error('Invalid valueType');
2092
+ }
2093
+ })();
2094
+ return processFunction(value);
2095
+ }
2096
+ var placeholder = format ||
2097
+ (function () {
2098
+ var hour24 = 21;
2099
+ var hour12 = 9;
2100
+ var minute = 13;
2101
+ var second = 14;
2102
+ var date = new Date(2017, 0, 1, hour24, minute, second);
2103
+ return formatTime(locale, date)
2104
+ .replace(formatNumber$1(locale, hour12), 'h')
2105
+ .replace(formatNumber$1(locale, hour24), 'H')
2106
+ .replace(formatNumber$1(locale, minute), 'mm')
2107
+ .replace(formatNumber$1(locale, second), 'ss')
2108
+ .replace(new RegExp(getAmPmLabels$1(locale).join('|')), 'a');
2109
+ })();
2110
+ var divider = (function () {
2111
+ var dividers = placeholder.match(/[^0-9a-z]/i);
2112
+ return dividers ? dividers[0] : null;
2113
+ })();
2114
+ function onClick(event) {
2115
+ if (event.target === event.currentTarget) {
2116
+ // Wrapper was directly clicked
2117
+ var firstInput = event.target.children[1];
2118
+ focus$1(firstInput);
2119
+ }
2120
+ }
2121
+ function onKeyDown(event) {
2122
+ lastPressedKey.current = event.key;
2123
+ switch (event.key) {
2124
+ case 'ArrowLeft':
2125
+ case 'ArrowRight':
2126
+ case divider: {
2127
+ event.preventDefault();
2128
+ var input = event.target;
2129
+ var property = event.key === 'ArrowLeft' ? 'previousElementSibling' : 'nextElementSibling';
2130
+ var nextInput = findInput$1(input, property);
2131
+ focus$1(nextInput);
2132
+ break;
2133
+ }
2134
+ }
2135
+ }
2136
+ function onKeyUp(event) {
2137
+ var key = event.key, input = event.target;
2138
+ var isLastPressedKey = lastPressedKey.current === key;
2139
+ if (!isLastPressedKey) {
2140
+ return;
2141
+ }
2142
+ var isNumberKey = !isNaN(Number(key));
2143
+ if (!isNumberKey) {
2144
+ return;
2145
+ }
2146
+ var max = input.getAttribute('max');
2147
+ if (!max) {
2148
+ return;
2149
+ }
2150
+ var value = input.value;
2151
+ /**
2152
+ * Given 1, the smallest possible number the user could type by adding another digit is 10.
2153
+ * 10 would be a valid value given max = 12, so we won't jump to the next input.
2154
+ * However, given 2, smallers possible number would be 20, and thus keeping the focus in
2155
+ * this field doesn't make sense.
2156
+ */
2157
+ if (Number(value) * 10 > Number(max) || value.length >= max.length) {
2158
+ var property = 'nextElementSibling';
2159
+ var nextInput = findInput$1(input, property);
2160
+ focus$1(nextInput);
2161
+ }
2162
+ }
2163
+ /**
2164
+ * Called after internal onChange. Checks input validity. If all fields are valid,
2165
+ * calls props.onChange.
2166
+ */
2167
+ function onChangeExternal() {
2168
+ if (!onChangeProps) {
2169
+ return;
2170
+ }
2171
+ function filterBoolean(value) {
2172
+ return Boolean(value);
2173
+ }
2174
+ var formElements = [
2175
+ amPmInput.current,
2176
+ hour12Input.current,
2177
+ hour24Input.current,
2178
+ minuteInput.current,
2179
+ secondInput.current,
2180
+ ].filter(filterBoolean);
2181
+ var formElementsWithoutSelect = formElements.slice(1);
2182
+ var values = {};
2183
+ formElements.forEach(function (formElement) {
2184
+ values[formElement.name] =
2185
+ formElement.type === 'number'
2186
+ ? 'valueAsNumber' in formElement
2187
+ ? formElement.valueAsNumber
2188
+ : Number(formElement.value)
2189
+ : formElement.value;
2190
+ });
2191
+ var isEveryValueEmpty = formElementsWithoutSelect.every(function (formElement) { return !formElement.value; });
2192
+ if (isEveryValueEmpty) {
2193
+ onChangeProps(null, false);
2194
+ return;
2195
+ }
2196
+ var isEveryValueFilled = formElements.every(function (formElement) { return formElement.value; });
2197
+ var isEveryValueValid = formElements.every(function (formElement) { return formElement.validity.valid; });
2198
+ if (isEveryValueFilled && isEveryValueValid) {
2199
+ var hour_1 = Number(values.hour24 ||
2200
+ (values.hour12 && values.amPm && convert12to24$1(values.hour12, values.amPm)) ||
2201
+ 0);
2202
+ var minute_1 = Number(values.minute || 0);
2203
+ var second_1 = Number(values.second || 0);
2204
+ var padStart = function (num) { return "0".concat(num).slice(-2); };
2205
+ var proposedValue = "".concat(padStart(hour_1), ":").concat(padStart(minute_1), ":").concat(padStart(second_1));
2206
+ var processedValue = getProcessedValue(proposedValue);
2207
+ onChangeProps(processedValue, false);
2208
+ return;
2209
+ }
2210
+ if (!onInvalidChange) {
2211
+ return;
2212
+ }
2213
+ onInvalidChange();
2214
+ }
2215
+ /**
2216
+ * Called when non-native date input is changed.
2217
+ */
2218
+ function onChange(event) {
2219
+ var _a = event.target, name = _a.name, value = _a.value;
2220
+ switch (name) {
2221
+ case 'amPm':
2222
+ setAmPm(value);
2223
+ break;
2224
+ case 'hour12':
2225
+ setHour(value ? convert12to24$1(value, amPm || 'am').toString() : '');
2226
+ break;
2227
+ case 'hour24':
2228
+ setHour(value);
2229
+ break;
2230
+ case 'minute':
2231
+ setMinute(value);
2232
+ break;
2233
+ case 'second':
2234
+ setSecond(value);
2235
+ break;
2236
+ }
2237
+ onChangeExternal();
2238
+ }
2239
+ /**
2240
+ * Called when native date input is changed.
2241
+ */
2242
+ function onChangeNative(event) {
2243
+ var value = event.target.value;
2244
+ if (!onChangeProps) {
2245
+ return;
2246
+ }
2247
+ var processedValue = value || null;
2248
+ onChangeProps(processedValue, false);
2249
+ }
2250
+ var commonInputProps = {
2251
+ className: className,
2252
+ disabled: disabled,
2253
+ maxTime: maxTime,
2254
+ minTime: minTime,
2255
+ onChange: onChange,
2256
+ onKeyDown: onKeyDown,
2257
+ onKeyUp: onKeyUp,
2258
+ // This is only for showing validity when editing
2259
+ required: Boolean(required || isClockOpen),
2260
+ };
2261
+ function renderHour12(currentMatch, index) {
2262
+ if (currentMatch && currentMatch.length > 2) {
2263
+ throw new Error("Unsupported token: ".concat(currentMatch));
2264
+ }
2265
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
2266
+ return (React__default["default"].createElement(Hour12Input$1, __assign$7({ key: "hour12" }, commonInputProps, { amPm: amPm, ariaLabel: hourAriaLabel,
2267
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2268
+ autoFocus: index === 0 && autoFocus, inputRef: hour12Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
2269
+ }
2270
+ function renderHour24(currentMatch, index) {
2271
+ if (currentMatch && currentMatch.length > 2) {
2272
+ throw new Error("Unsupported token: ".concat(currentMatch));
2273
+ }
2274
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
2275
+ return (React__default["default"].createElement(Hour24Input$1, __assign$7({ key: "hour24" }, commonInputProps, { ariaLabel: hourAriaLabel,
2276
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2277
+ autoFocus: index === 0 && autoFocus, inputRef: hour24Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
2278
+ }
2279
+ function renderHour(currentMatch, index) {
2280
+ if (/h/.test(currentMatch)) {
2281
+ return renderHour12(currentMatch, index);
2282
+ }
2283
+ return renderHour24(currentMatch, index);
2284
+ }
2285
+ function renderMinute(currentMatch, index) {
2286
+ if (currentMatch && currentMatch.length > 2) {
2287
+ throw new Error("Unsupported token: ".concat(currentMatch));
2288
+ }
2289
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
2290
+ return (React__default["default"].createElement(MinuteInput$1, __assign$7({ key: "minute" }, commonInputProps, { ariaLabel: minuteAriaLabel,
2291
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2292
+ autoFocus: index === 0 && autoFocus, hour: hour, inputRef: minuteInput, placeholder: minutePlaceholder, showLeadingZeros: showLeadingZeros, value: minute })));
2293
+ }
2294
+ function renderSecond(currentMatch, index) {
2295
+ if (currentMatch && currentMatch.length > 2) {
2296
+ throw new Error("Unsupported token: ".concat(currentMatch));
2297
+ }
2298
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : true;
2299
+ return (React__default["default"].createElement(SecondInput$1, __assign$7({ key: "second" }, commonInputProps, { ariaLabel: secondAriaLabel,
2300
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2301
+ autoFocus: index === 0 && autoFocus, hour: hour, inputRef: secondInput, minute: minute, placeholder: secondPlaceholder, showLeadingZeros: showLeadingZeros, value: second })));
2302
+ }
2303
+ function renderAmPm(currentMatch, index) {
2304
+ return (React__default["default"].createElement(AmPm$1, __assign$7({ key: "ampm" }, commonInputProps, { ariaLabel: amPmAriaLabel,
2305
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2306
+ autoFocus: index === 0 && autoFocus, inputRef: amPmInput, locale: locale, onChange: onChange, value: amPm })));
2307
+ }
2308
+ function renderCustomInputsInternal() {
2309
+ var elementFunctions = {
2310
+ h: renderHour,
2311
+ H: renderHour,
2312
+ m: renderMinute,
2313
+ s: renderSecond,
2314
+ a: renderAmPm,
2315
+ };
2316
+ var allowMultipleInstances = typeof format !== 'undefined';
2317
+ return renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances);
2318
+ }
2319
+ function renderNativeInput() {
2320
+ return (React__default["default"].createElement(NativeInput$1, { key: "time", ariaLabel: nativeInputAriaLabel, disabled: disabled, maxTime: maxTime, minTime: minTime, name: name, onChange: onChangeNative, required: required, value: value, valueType: valueType }));
2321
+ }
2322
+ return (
2323
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
2324
+ React__default["default"].createElement("div", { className: className, onClick: onClick },
2325
+ renderNativeInput(),
2326
+ renderCustomInputsInternal()));
2327
+ }
2328
+
2329
+ var hourOptionalSecondsRegExp$1 = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
2330
+ var isTime$1 = function isTime(props, propName, componentName) {
2331
+ var _a = props, _b = propName, time = _a[_b];
2332
+ if (time) {
2333
+ if (typeof time !== 'string' || !hourOptionalSecondsRegExp$1.test(time)) {
2334
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof time, "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format."));
2335
+ }
2336
+ }
2337
+ // Everything is fine
2338
+ return null;
2339
+ };
2340
+ var rangeOf$1 = function (type) {
2341
+ return index.propTypes.exports.arrayOf(type);
2342
+ };
2343
+
2344
+ var __assign$6 = (undefined && undefined.__assign) || function () {
2345
+ __assign$6 = Object.assign || function(t) {
2346
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2347
+ s = arguments[i];
2348
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2349
+ t[p] = s[p];
2350
+ }
2351
+ return t;
2352
+ };
2353
+ return __assign$6.apply(this, arguments);
2354
+ };
2355
+ var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
2356
+ var t = {};
2357
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2358
+ t[p] = s[p];
2359
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2360
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2361
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2362
+ t[p[i]] = s[p[i]];
2363
+ }
2364
+ return t;
2365
+ };
2366
+ var isBrowser$2 = typeof document !== 'undefined';
2367
+ var baseClassName$1 = 'react-timerange-picker';
2368
+ var outsideActionEvents$1 = ['mousedown', 'focusin', 'touchstart'];
2369
+ var allViews$3 = ['hour', 'minute', 'second'];
2370
+ var iconProps$1 = {
2371
+ xmlns: 'http://www.w3.org/2000/svg',
2372
+ width: 19,
2373
+ height: 19,
2374
+ viewBox: '0 0 19 19',
2375
+ stroke: 'black',
2376
+ strokeWidth: 2,
2377
+ };
2378
+ var ClockIcon$1 = (React__default["default"].createElement("svg", __assign$6({}, iconProps$1, { className: "".concat(baseClassName$1, "__clock-button__icon ").concat(baseClassName$1, "__button__icon"), fill: "none" }),
2379
+ React__default["default"].createElement("circle", { cx: "9.5", cy: "9.5", r: "7.5" }),
2380
+ React__default["default"].createElement("path", { d: "M9.5 4.5 v5 h4" })));
2381
+ var ClearIcon$1 = (React__default["default"].createElement("svg", __assign$6({}, iconProps$1, { className: "".concat(baseClassName$1, "__clear-button__icon ").concat(baseClassName$1, "__button__icon") }),
2382
+ React__default["default"].createElement("line", { x1: "4", x2: "15", y1: "4", y2: "15" }),
2383
+ React__default["default"].createElement("line", { x1: "15", x2: "4", y1: "4", y2: "15" })));
2384
+ var TimeRangePicker = function TimeRangePicker(props) {
2385
+ var amPmAriaLabel = props.amPmAriaLabel, autoFocus = props.autoFocus, className = props.className, clearAriaLabel = props.clearAriaLabel, _a = props.clearIcon, clearIcon = _a === void 0 ? ClearIcon$1 : _a, clockAriaLabel = props.clockAriaLabel, _b = props.clockIcon, clockIcon = _b === void 0 ? ClockIcon$1 : _b, _c = props.closeClock, shouldCloseClockOnSelect = _c === void 0 ? true : _c, dataTestid = props["data-testid"], disableClock = props.disableClock, disabled = props.disabled, format = props.format, hourAriaLabel = props.hourAriaLabel, hourPlaceholder = props.hourPlaceholder, id = props.id, _d = props.isOpen, isOpenProps = _d === void 0 ? null : _d, locale = props.locale, _e = props.maxDetail, maxDetail = _e === void 0 ? 'minute' : _e, maxTime = props.maxTime, minTime = props.minTime, minuteAriaLabel = props.minuteAriaLabel, minutePlaceholder = props.minutePlaceholder, _f = props.name, name = _f === void 0 ? 'timerange' : _f, nativeInputAriaLabel = props.nativeInputAriaLabel, onChangeProps = props.onChange, onClockClose = props.onClockClose, onClockOpen = props.onClockOpen, onFocusProps = props.onFocus, onInvalidChange = props.onInvalidChange, _g = props.openClockOnFocus, openClockOnFocus = _g === void 0 ? true : _g, _h = props.rangeDivider, rangeDivider = _h === void 0 ? '–' : _h, required = props.required, secondAriaLabel = props.secondAriaLabel, secondPlaceholder = props.secondPlaceholder, shouldCloseClock = props.shouldCloseClock, shouldOpenClock = props.shouldOpenClock, value = props.value, otherProps = __rest$5(props, ["amPmAriaLabel", "autoFocus", "className", "clearAriaLabel", "clearIcon", "clockAriaLabel", "clockIcon", "closeClock", 'data-testid', "disableClock", "disabled", "format", "hourAriaLabel", "hourPlaceholder", "id", "isOpen", "locale", "maxDetail", "maxTime", "minTime", "minuteAriaLabel", "minutePlaceholder", "name", "nativeInputAriaLabel", "onChange", "onClockClose", "onClockOpen", "onFocus", "onInvalidChange", "openClockOnFocus", "rangeDivider", "required", "secondAriaLabel", "secondPlaceholder", "shouldCloseClock", "shouldOpenClock", "value"]);
2386
+ var _j = React.useState(isOpenProps), isOpen = _j[0], setIsOpen = _j[1];
2387
+ var wrapper = React.useRef(null);
2388
+ var clockWrapper = React.useRef(null);
2389
+ React.useEffect(function () {
2390
+ setIsOpen(isOpenProps);
2391
+ }, [isOpenProps]);
2392
+ function openClock(_a) {
2393
+ var reason = _a.reason;
2394
+ if (shouldOpenClock) {
2395
+ if (!shouldOpenClock({ reason: reason })) {
2396
+ return;
2397
+ }
2398
+ }
2399
+ setIsOpen(true);
2400
+ if (onClockOpen) {
2401
+ onClockOpen();
2402
+ }
2403
+ }
2404
+ var closeClock = React.useCallback(function (_a) {
2405
+ var reason = _a.reason;
2406
+ if (shouldCloseClock) {
2407
+ if (!shouldCloseClock({ reason: reason })) {
2408
+ return;
2409
+ }
2410
+ }
2411
+ setIsOpen(false);
2412
+ if (onClockClose) {
2413
+ onClockClose();
2414
+ }
2415
+ }, [onClockClose, shouldCloseClock]);
2416
+ function toggleClock() {
2417
+ if (isOpen) {
2418
+ closeClock({ reason: 'buttonClick' });
2419
+ }
2420
+ else {
2421
+ openClock({ reason: 'buttonClick' });
2422
+ }
2423
+ }
2424
+ function onChange(value, shouldCloseClock) {
2425
+ if (shouldCloseClock === void 0) { shouldCloseClock = shouldCloseClockOnSelect; }
2426
+ if (shouldCloseClock) {
2427
+ closeClock({ reason: 'select' });
2428
+ }
2429
+ if (onChangeProps) {
2430
+ onChangeProps(value);
2431
+ }
2432
+ }
2433
+ function onChangeFrom(valueFrom, closeClock) {
2434
+ var _a = Array.isArray(value) ? value : [value], valueTo = _a[1];
2435
+ onChange([valueFrom, valueTo || null], closeClock);
2436
+ }
2437
+ function onChangeTo(valueTo, closeClock) {
2438
+ var valueFrom = (Array.isArray(value) ? value : [value])[0];
2439
+ onChange([valueFrom || null, valueTo], closeClock);
2440
+ }
2441
+ function onFocus(event) {
2442
+ if (onFocusProps) {
2443
+ onFocusProps(event);
2444
+ }
2445
+ if (
2446
+ // Internet Explorer still fires onFocus on disabled elements
2447
+ disabled ||
2448
+ isOpen ||
2449
+ !openClockOnFocus ||
2450
+ event.target.dataset.select === 'true') {
2451
+ return;
2452
+ }
2453
+ openClock({ reason: 'focus' });
2454
+ }
2455
+ var onKeyDown = React.useCallback(function (event) {
2456
+ if (event.key === 'Escape') {
2457
+ closeClock({ reason: 'escape' });
2458
+ }
2459
+ }, [closeClock]);
2460
+ function clear() {
2461
+ onChange(null);
2462
+ }
2463
+ function stopPropagation(event) {
2464
+ event.stopPropagation();
2465
+ }
2466
+ var onOutsideAction = React.useCallback(function (event) {
2467
+ var wrapperEl = wrapper.current;
2468
+ var clockWrapperEl = clockWrapper.current;
2469
+ // Try event.composedPath first to handle clicks inside a Shadow DOM.
2470
+ var target = ('composedPath' in event ? event.composedPath()[0] : event.target);
2471
+ if (target &&
2472
+ wrapperEl &&
2473
+ !wrapperEl.contains(target) &&
2474
+ (!clockWrapperEl || !clockWrapperEl.contains(target))) {
2475
+ closeClock({ reason: 'outsideAction' });
2476
+ }
2477
+ }, [clockWrapper, closeClock, wrapper]);
2478
+ var handleOutsideActionListeners = React.useCallback(function (shouldListen) {
2479
+ if (shouldListen === void 0) { shouldListen = isOpen; }
2480
+ outsideActionEvents$1.forEach(function (event) {
2481
+ if (shouldListen) {
2482
+ document.addEventListener(event, onOutsideAction);
2483
+ }
2484
+ else {
2485
+ document.removeEventListener(event, onOutsideAction);
2486
+ }
2487
+ });
2488
+ if (shouldListen) {
2489
+ document.addEventListener('keydown', onKeyDown);
2490
+ }
2491
+ else {
2492
+ document.removeEventListener('keydown', onKeyDown);
2493
+ }
2494
+ }, [isOpen, onOutsideAction, onKeyDown]);
2495
+ React.useEffect(function () {
2496
+ handleOutsideActionListeners();
2497
+ return function () {
2498
+ handleOutsideActionListeners(false);
2499
+ };
2500
+ }, [handleOutsideActionListeners, isOpen]);
2501
+ function renderInputs() {
2502
+ var _a = Array.isArray(value) ? value : [value], valueFrom = _a[0], valueTo = _a[1];
2503
+ var ariaLabelProps = {
2504
+ amPmAriaLabel: amPmAriaLabel,
2505
+ hourAriaLabel: hourAriaLabel,
2506
+ minuteAriaLabel: minuteAriaLabel,
2507
+ nativeInputAriaLabel: nativeInputAriaLabel,
2508
+ secondAriaLabel: secondAriaLabel,
2509
+ };
2510
+ var placeholderProps = {
2511
+ hourPlaceholder: hourPlaceholder,
2512
+ minutePlaceholder: minutePlaceholder,
2513
+ secondPlaceholder: secondPlaceholder,
2514
+ };
2515
+ var commonProps = __assign$6(__assign$6(__assign$6({}, ariaLabelProps), placeholderProps), { className: "".concat(baseClassName$1, "__inputGroup"), disabled: disabled, format: format, isClockOpen: isOpen, locale: locale, maxDetail: maxDetail, maxTime: maxTime, minTime: minTime, onInvalidChange: onInvalidChange, required: required });
2516
+ return (React__default["default"].createElement("div", { className: "".concat(baseClassName$1, "__wrapper") },
2517
+ React__default["default"].createElement(TimeInput$1, __assign$6({}, commonProps, {
2518
+ // eslint-disable-next-line jsx-a11y/no-autofocus
2519
+ autoFocus: autoFocus, name: "".concat(name, "_from"), onChange: onChangeFrom, value: valueFrom })),
2520
+ React__default["default"].createElement("span", { className: "".concat(baseClassName$1, "__range-divider") }, rangeDivider),
2521
+ React__default["default"].createElement(TimeInput$1, __assign$6({}, commonProps, { name: "".concat(name, "_to"), onChange: onChangeTo, value: valueTo })),
2522
+ clearIcon !== null && (React__default["default"].createElement("button", { "aria-label": clearAriaLabel, className: "".concat(baseClassName$1, "__clear-button ").concat(baseClassName$1, "__button"), disabled: disabled, onClick: clear, onFocus: stopPropagation, type: "button" }, typeof clearIcon === 'function' ? React__default["default"].createElement(clearIcon) : clearIcon)),
2523
+ clockIcon !== null && !disableClock && (React__default["default"].createElement("button", { "aria-label": clockAriaLabel, className: "".concat(baseClassName$1, "__clock-button ").concat(baseClassName$1, "__button"), disabled: disabled, onClick: toggleClock, onFocus: stopPropagation, type: "button" }, typeof clockIcon === 'function' ? React__default["default"].createElement(clockIcon) : clockIcon))));
2524
+ }
2525
+ function renderClock() {
2526
+ if (isOpen === null || disableClock) {
2527
+ return null;
2528
+ }
2529
+ var clockClassName = props.clockClassName; props.className; // Unused, here to exclude it from clockProps
2530
+ props.onChange; // Unused, here to exclude it from clockProps
2531
+ var portalContainer = props.portalContainer, value = props.value, clockProps = __rest$5(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
2532
+ var className = "".concat(baseClassName$1, "__clock");
2533
+ var classNames = clsx(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
2534
+ var valueFrom = (Array.isArray(value) ? value : [value])[0];
2535
+ var clock = React__default["default"].createElement(Clock, __assign$6({ className: clockClassName, value: valueFrom }, clockProps));
2536
+ return portalContainer ? (ReactDOM.createPortal(React__default["default"].createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default["default"].createElement(Fit, null,
2537
+ React__default["default"].createElement("div", { ref: function (ref) {
2538
+ if (ref && !isOpen) {
2539
+ ref.removeAttribute('style');
2540
+ }
2541
+ }, className: classNames }, clock)));
2542
+ }
2543
+ var eventProps = React.useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
2544
+ return (React__default["default"].createElement("div", __assign$6({ className: clsx(baseClassName$1, "".concat(baseClassName$1, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName$1, "--").concat(disabled ? 'disabled' : 'enabled'), className), "data-testid": dataTestid, id: id }, eventProps, { onFocus: onFocus, ref: wrapper }),
2545
+ renderInputs(),
2546
+ renderClock()));
2547
+ };
2548
+ var isValue$1 = index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.instanceOf(Date)]);
2549
+ var isValueOrValueArray$1 = index.propTypes.exports.oneOfType([isValue$1, rangeOf$1(isValue$1)]);
2550
+ TimeRangePicker.propTypes = {
2551
+ amPmAriaLabel: index.propTypes.exports.string,
2552
+ autoFocus: index.propTypes.exports.bool,
2553
+ className: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.arrayOf(index.propTypes.exports.string)]),
2554
+ clearAriaLabel: index.propTypes.exports.string,
2555
+ clearIcon: index.propTypes.exports.oneOfType([index.propTypes.exports.node, index.propTypes.exports.func]),
2556
+ clockAriaLabel: index.propTypes.exports.string,
2557
+ clockClassName: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.arrayOf(index.propTypes.exports.string)]),
2558
+ clockIcon: index.propTypes.exports.oneOfType([index.propTypes.exports.node, index.propTypes.exports.func]),
2559
+ closeClock: index.propTypes.exports.bool,
2560
+ 'data-testid': index.propTypes.exports.string,
2561
+ disableClock: index.propTypes.exports.bool,
2562
+ disabled: index.propTypes.exports.bool,
2563
+ format: index.propTypes.exports.string,
2564
+ hourAriaLabel: index.propTypes.exports.string,
2565
+ hourPlaceholder: index.propTypes.exports.string,
2566
+ id: index.propTypes.exports.string,
2567
+ isOpen: index.propTypes.exports.bool,
2568
+ locale: index.propTypes.exports.string,
2569
+ maxDetail: index.propTypes.exports.oneOf(allViews$3),
2570
+ maxTime: isTime$1,
2571
+ minTime: isTime$1,
2572
+ minuteAriaLabel: index.propTypes.exports.string,
2573
+ minutePlaceholder: index.propTypes.exports.string,
2574
+ name: index.propTypes.exports.string,
2575
+ nativeInputAriaLabel: index.propTypes.exports.string,
2576
+ onChange: index.propTypes.exports.func,
2577
+ onClockClose: index.propTypes.exports.func,
2578
+ onClockOpen: index.propTypes.exports.func,
2579
+ onFocus: index.propTypes.exports.func,
2580
+ openClockOnFocus: index.propTypes.exports.bool,
2581
+ rangeDivider: index.propTypes.exports.node,
2582
+ required: index.propTypes.exports.bool,
2583
+ secondAriaLabel: index.propTypes.exports.string,
2584
+ secondPlaceholder: index.propTypes.exports.string,
2585
+ value: isValueOrValueArray$1,
2586
+ };
2587
+ if (isBrowser$2) {
2588
+ TimeRangePicker.propTypes.portalContainer = index.propTypes.exports.instanceOf(HTMLElement);
2589
+ }
2590
+
2591
+ function Divider(_a) {
2592
+ var children = _a.children;
2593
+ return React__default["default"].createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
2594
+ }
2595
+
2596
+ var isBrowser$1 = typeof document !== 'undefined';
2597
+ var useIsomorphicLayoutEffect = isBrowser$1 ? React.useLayoutEffect : React.useEffect;
2598
+ var isIEOrEdgeLegacy = isBrowser$1 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
2599
+ var isFirefox = isBrowser$1 && /Firefox/.test(navigator.userAgent);
2600
+ function onFocus(event) {
2601
+ var target = event.target;
2602
+ if (isIEOrEdgeLegacy) {
2603
+ requestAnimationFrame(function () { return target.select(); });
2604
+ }
2605
+ else {
2606
+ target.select();
2607
+ }
2608
+ }
2609
+ function updateInputWidthOnLoad(element) {
2610
+ if (document.readyState === 'complete') {
2611
+ return;
2612
+ }
2613
+ function onLoad() {
2614
+ updateInputWidth(element);
2615
+ }
2616
+ window.addEventListener('load', onLoad);
2617
+ }
2618
+ function updateInputWidthOnFontLoad(element) {
2619
+ if (!document.fonts) {
2620
+ return;
2621
+ }
2622
+ var font = getFontShorthand(element);
2623
+ if (!font) {
2624
+ return;
2625
+ }
2626
+ var isFontLoaded = document.fonts.check(font);
2627
+ if (isFontLoaded) {
2628
+ return;
2629
+ }
2630
+ function onLoadingDone() {
2631
+ updateInputWidth(element);
2632
+ }
2633
+ document.fonts.addEventListener('loadingdone', onLoadingDone);
2634
+ }
2635
+ function getSelectionString(input) {
2636
+ /**
2637
+ * window.getSelection().toString() returns empty string in IE11 and Firefox,
2638
+ * so alternatives come first.
2639
+ */
2640
+ if (input &&
2641
+ 'selectionStart' in input &&
2642
+ input.selectionStart !== null &&
2643
+ 'selectionEnd' in input &&
2644
+ input.selectionEnd !== null) {
2645
+ return input.value.slice(input.selectionStart, input.selectionEnd);
2646
+ }
2647
+ if ('getSelection' in window) {
2648
+ var selection = window.getSelection();
2649
+ return selection && selection.toString();
2650
+ }
2651
+ return null;
2652
+ }
2653
+ function makeOnKeyPress(maxLength) {
2654
+ if (maxLength === null) {
2655
+ return undefined;
2656
+ }
2657
+ /**
2658
+ * Prevents keystrokes that would not produce a number or when value after keystroke would
2659
+ * exceed maxLength.
2660
+ */
2661
+ return function onKeyPress(event) {
2662
+ if (isFirefox) {
2663
+ // See https://github.com/wojtekmaj/react-time-picker/issues/92
2664
+ return;
2665
+ }
2666
+ var key = event.key, input = event.target;
2667
+ var value = input.value;
2668
+ var isNumberKey = key.length === 1 && /\d/.test(key);
2669
+ var selection = getSelectionString(input);
2670
+ if (!isNumberKey || !(selection || value.length < maxLength)) {
2671
+ event.preventDefault();
2672
+ }
2673
+ };
2674
+ }
2675
+ function Input(_a) {
2676
+ var ariaLabel = _a.ariaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, inputRef = _a.inputRef, max = _a.max, min = _a.min, name = _a.name, nameForClass = _a.nameForClass, onChange = _a.onChange, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, _b = _a.placeholder, placeholder = _b === void 0 ? '--' : _b, required = _a.required, showLeadingZeros = _a.showLeadingZeros, step = _a.step, value = _a.value;
2677
+ useIsomorphicLayoutEffect(function () {
2678
+ if (!inputRef || !inputRef.current) {
2679
+ return;
2680
+ }
2681
+ updateInputWidth(inputRef.current);
2682
+ updateInputWidthOnLoad(inputRef.current);
2683
+ updateInputWidthOnFontLoad(inputRef.current);
2684
+ }, [inputRef, value]);
2685
+ var hasLeadingZero = showLeadingZeros &&
2686
+ value &&
2687
+ Number(value) < 10 &&
2688
+ (value === '0' || !value.toString().startsWith('0'));
2689
+ var maxLength = max ? max.toString().length : null;
2690
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2691
+ hasLeadingZero ? React__default["default"].createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
2692
+ React__default["default"].createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx("".concat(className, "__input"), "".concat(className, "__").concat(nameForClass || name), hasLeadingZero && "".concat(className, "__input--hasLeadingZero")), "data-input": "true", disabled: disabled, inputMode: "numeric", max: max, min: min, name: name, onChange: onChange, onFocus: onFocus, onKeyDown: onKeyDown, onKeyPress: makeOnKeyPress(maxLength), onKeyUp: function (event) {
2693
+ updateInputWidth(event.target);
2694
+ if (onKeyUp) {
2695
+ onKeyUp(event);
2696
+ }
2697
+ }, placeholder: placeholder, ref: inputRef, required: required, step: step, type: "number", value: value !== null ? value : '' })));
2698
+ }
2699
+
2700
+ function convert12to24(hour12, amPm) {
2701
+ var hour24 = Number(hour12);
2702
+ if (amPm === 'am' && hour24 === 12) {
2703
+ hour24 = 0;
2704
+ }
2705
+ else if (amPm === 'pm' && hour24 < 12) {
2706
+ hour24 += 12;
2707
+ }
2708
+ return hour24;
2709
+ }
2710
+ function convert24to12(hour24) {
2711
+ var hour12 = Number(hour24) % 12 || 12;
2712
+ return [hour12, Number(hour24) < 12 ? 'am' : 'pm'];
2713
+ }
2714
+
2715
+ var formatterCache = new Map();
2716
+ function getFormatter(options) {
2717
+ return function formatter(locale, date) {
2718
+ var localeWithDefault = locale || getUserLocale();
2719
+ if (!formatterCache.has(localeWithDefault)) {
2720
+ formatterCache.set(localeWithDefault, new Map());
2721
+ }
2722
+ var formatterCacheLocale = formatterCache.get(localeWithDefault);
2723
+ if (!formatterCacheLocale.has(options)) {
2724
+ formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault || undefined, options).format);
2725
+ }
2726
+ return formatterCacheLocale.get(options)(date);
2727
+ };
2728
+ }
2729
+ var numberFormatterCache = new Map();
2730
+ function getNumberFormatter(options) {
2731
+ return function (locale, number) {
2732
+ var localeWithDefault = locale || getUserLocale();
2733
+ if (!numberFormatterCache.has(localeWithDefault)) {
2734
+ numberFormatterCache.set(localeWithDefault, new Map());
2735
+ }
2736
+ var numberFormatterCacheLocale = numberFormatterCache.get(localeWithDefault);
2737
+ if (!numberFormatterCacheLocale.has(options)) {
2738
+ numberFormatterCacheLocale.set(options, new Intl.NumberFormat(localeWithDefault || undefined, options).format);
2739
+ }
2740
+ return numberFormatterCacheLocale.get(options)(number);
2741
+ };
2742
+ }
2743
+
2744
+ var nines = ['9', '٩'];
2745
+ var ninesRegExp = new RegExp("[".concat(nines.join(''), "]"));
2746
+ var amPmFormatter = getFormatter({ hour: 'numeric' });
2747
+ function getAmPmLabels(locale) {
2748
+ var amString = amPmFormatter(locale, new Date(2017, 0, 1, 9));
2749
+ var pmString = amPmFormatter(locale, new Date(2017, 0, 1, 21));
2750
+ var _a = amString.split(ninesRegExp), am1 = _a[0], am2 = _a[1];
2751
+ var _b = pmString.split(ninesRegExp), pm1 = _b[0], pm2 = _b[1];
2752
+ if (pm2 !== undefined) {
2753
+ // If pm2 is undefined, nine was not found in pmString - this locale is not using 12-hour time
2754
+ if (am1 !== pm1) {
2755
+ return [am1, pm1].map(function (el) { return el.trim(); });
2756
+ }
2757
+ if (am2 !== pm2) {
2758
+ return [am2, pm2].map(function (el) { return el.trim(); });
2759
+ }
2760
+ }
2761
+ // Fallback
2762
+ return ['AM', 'PM'];
2763
+ }
2764
+ function isValidNumber(num) {
2765
+ return num !== null && num !== false && !Number.isNaN(Number(num));
2766
+ }
2767
+ function safeMin() {
2768
+ var args = [];
2769
+ for (var _i = 0; _i < arguments.length; _i++) {
2770
+ args[_i] = arguments[_i];
2771
+ }
2772
+ return Math.min.apply(Math, args.filter(isValidNumber));
2773
+ }
2774
+ function safeMax() {
2775
+ var args = [];
2776
+ for (var _i = 0; _i < arguments.length; _i++) {
2777
+ args[_i] = arguments[_i];
2778
+ }
2779
+ return Math.max.apply(Math, args.filter(isValidNumber));
2780
+ }
2781
+
2782
+ var __assign$5 = (undefined && undefined.__assign) || function () {
2783
+ __assign$5 = Object.assign || function(t) {
2784
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2785
+ s = arguments[i];
2786
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2787
+ t[p] = s[p];
2788
+ }
2789
+ return t;
2790
+ };
2791
+ return __assign$5.apply(this, arguments);
2792
+ };
2793
+ var __rest$4 = (undefined && undefined.__rest) || function (s, e) {
2794
+ var t = {};
2795
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2796
+ t[p] = s[p];
2797
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2798
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2799
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2800
+ t[p[i]] = s[p[i]];
2801
+ }
2802
+ return t;
2803
+ };
2804
+ function Hour12Input(_a) {
2805
+ var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$4(_a, ["amPm", "maxTime", "minTime", "value"]);
2806
+ var maxHour = safeMin(12, maxTime &&
2807
+ (function () {
2808
+ var _a = convert24to12(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
2809
+ if (maxAmPm !== amPm) {
2810
+ // pm is always after am, so we should ignore validation
2811
+ return null;
2812
+ }
2813
+ return maxHourResult;
2814
+ })());
2815
+ var minHour = safeMax(1, minTime &&
2816
+ (function () {
2817
+ var _a = convert24to12(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
2818
+ if (
2819
+ // pm is always after am, so we should ignore validation
2820
+ minAmPm !== amPm ||
2821
+ // If minHour is 12 am/pm, user should be able to enter 12, 1, ..., 11.
2822
+ minHourResult === 12) {
2823
+ return null;
2824
+ }
2825
+ return minHourResult;
2826
+ })());
2827
+ var value12 = value ? convert24to12(value)[0].toString() : '';
2828
+ return (React__default["default"].createElement(Input, __assign$5({ max: maxHour, min: minHour, name: "hour12", nameForClass: "hour", value: value12 }, otherProps)));
2829
+ }
2830
+
2831
+ var __assign$4 = (undefined && undefined.__assign) || function () {
2832
+ __assign$4 = Object.assign || function(t) {
2833
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2834
+ s = arguments[i];
2835
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2836
+ t[p] = s[p];
2837
+ }
2838
+ return t;
2839
+ };
2840
+ return __assign$4.apply(this, arguments);
2841
+ };
2842
+ var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
2843
+ var t = {};
2844
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2845
+ t[p] = s[p];
2846
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2847
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2848
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2849
+ t[p[i]] = s[p[i]];
2850
+ }
2851
+ return t;
2852
+ };
2853
+ function Hour24Input(_a) {
2854
+ var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$3(_a, ["maxTime", "minTime"]);
2855
+ var maxHour = safeMin(23, maxTime && getHours(maxTime));
2856
+ var minHour = safeMax(0, minTime && getHours(minTime));
2857
+ return React__default["default"].createElement(Input, __assign$4({ max: maxHour, min: minHour, name: "hour24", nameForClass: "hour" }, otherProps));
2858
+ }
2859
+
2860
+ var __assign$3 = (undefined && undefined.__assign) || function () {
2861
+ __assign$3 = Object.assign || function(t) {
2862
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2863
+ s = arguments[i];
2864
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2865
+ t[p] = s[p];
2866
+ }
2867
+ return t;
2868
+ };
2869
+ return __assign$3.apply(this, arguments);
2870
+ };
2871
+ var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
2872
+ var t = {};
2873
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2874
+ t[p] = s[p];
2875
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2876
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2877
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2878
+ t[p[i]] = s[p[i]];
2879
+ }
2880
+ return t;
2881
+ };
2882
+ function MinuteInput(_a) {
2883
+ var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$2(_a, ["hour", "maxTime", "minTime", "showLeadingZeros"]);
2884
+ function isSameHour(date) {
2885
+ return hour === getHours(date).toString();
2886
+ }
2887
+ var maxMinute = safeMin(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
2888
+ var minMinute = safeMax(0, minTime && isSameHour(minTime) && getMinutes(minTime));
2889
+ return (React__default["default"].createElement(Input, __assign$3({ max: maxMinute, min: minMinute, name: "minute", showLeadingZeros: showLeadingZeros }, otherProps)));
2890
+ }
2891
+
2892
+ var __assign$2 = (undefined && undefined.__assign) || function () {
2893
+ __assign$2 = Object.assign || function(t) {
2894
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2895
+ s = arguments[i];
2896
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2897
+ t[p] = s[p];
2898
+ }
2899
+ return t;
2900
+ };
2901
+ return __assign$2.apply(this, arguments);
2902
+ };
2903
+ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
2904
+ var t = {};
2905
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2906
+ t[p] = s[p];
2907
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2908
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2909
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2910
+ t[p[i]] = s[p[i]];
2911
+ }
2912
+ return t;
2913
+ };
2914
+ function SecondInput(_a) {
2915
+ var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, minute = _a.minute, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$1(_a, ["hour", "maxTime", "minTime", "minute", "showLeadingZeros"]);
2916
+ function isSameMinute(date) {
2917
+ return hour === getHours(date).toString() && minute === getMinutes(date).toString();
2918
+ }
2919
+ var maxSecond = safeMin(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
2920
+ var minSecond = safeMax(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
2921
+ return (React__default["default"].createElement(Input, __assign$2({ max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros }, otherProps)));
2922
+ }
2923
+
2924
+ function NativeInput(_a) {
2925
+ var ariaLabel = _a.ariaLabel, disabled = _a.disabled, maxTime = _a.maxTime, minTime = _a.minTime, name = _a.name, onChange = _a.onChange, required = _a.required, value = _a.value, valueType = _a.valueType;
2926
+ var nativeValueParser = (function () {
2927
+ switch (valueType) {
2928
+ case 'hour':
2929
+ return function (receivedValue) { return "".concat(getHours(receivedValue), ":00"); };
2930
+ case 'minute':
2931
+ return getHoursMinutes;
2932
+ case 'second':
2933
+ return getHoursMinutesSeconds;
2934
+ default:
2935
+ throw new Error('Invalid valueType');
2936
+ }
2937
+ })();
2938
+ var step = (function () {
2939
+ switch (valueType) {
2940
+ case 'hour':
2941
+ return 3600;
2942
+ case 'minute':
2943
+ return 60;
2944
+ case 'second':
2945
+ return 1;
2946
+ default:
2947
+ throw new Error('Invalid valueType');
2948
+ }
2949
+ })();
2950
+ function stopPropagation(event) {
2951
+ event.stopPropagation();
2952
+ }
2953
+ return (React__default["default"].createElement("input", { "aria-label": ariaLabel, disabled: disabled, hidden: true, max: maxTime ? nativeValueParser(maxTime) : undefined, min: minTime ? nativeValueParser(minTime) : undefined, name: name, onChange: onChange, onFocus: stopPropagation, required: required, step: step, style: {
2954
+ visibility: 'hidden',
2955
+ position: 'absolute',
2956
+ zIndex: '-999',
2957
+ }, type: "time", value: value ? nativeValueParser(value) : '' }));
2958
+ }
2959
+
2960
+ function AmPm(_a) {
2961
+ var ariaLabel = _a.ariaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, inputRef = _a.inputRef, locale = _a.locale, maxTime = _a.maxTime, minTime = _a.minTime, onChange = _a.onChange, onKeyDown = _a.onKeyDown, required = _a.required, value = _a.value;
2962
+ var amDisabled = minTime ? convert24to12(getHours(minTime))[1] === 'pm' : false;
2963
+ var pmDisabled = maxTime ? convert24to12(getHours(maxTime))[1] === 'am' : false;
2964
+ var name = 'amPm';
2965
+ var _b = getAmPmLabels(locale), amLabel = _b[0], pmLabel = _b[1];
2966
+ return (React__default["default"].createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx("".concat(className, "__input"), "".concat(className, "__").concat(name)), "data-input": "true", "data-select": "true", disabled: disabled, name: name, onChange: onChange, onKeyDown: onKeyDown, ref: inputRef, required: required, value: value !== null ? value : '' },
2967
+ !value && React__default["default"].createElement("option", { value: "" }, "--"),
2968
+ React__default["default"].createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
2969
+ React__default["default"].createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
2970
+ }
2971
+
2972
+ var __assign$1 = (undefined && undefined.__assign) || function () {
2973
+ __assign$1 = Object.assign || function(t) {
2974
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2975
+ s = arguments[i];
2976
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2977
+ t[p] = s[p];
2978
+ }
2979
+ return t;
2980
+ };
2981
+ return __assign$1.apply(this, arguments);
2982
+ };
2983
+ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2984
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
2985
+ if (ar || !(i in from)) {
2986
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2987
+ ar[i] = from[i];
2988
+ }
2989
+ }
2990
+ return to.concat(ar || Array.prototype.slice.call(from));
2991
+ };
2992
+ var getFormatterOptionsCache = {};
2993
+ var allViews$2 = ['hour', 'minute', 'second'];
2994
+ function isInternalInput(element) {
2995
+ return element.dataset.input === 'true';
2996
+ }
2997
+ function findInput(element, property) {
2998
+ var nextElement = element;
2999
+ do {
3000
+ nextElement = nextElement[property];
3001
+ } while (nextElement && !isInternalInput(nextElement));
3002
+ return nextElement;
3003
+ }
3004
+ function focus(element) {
3005
+ if (element) {
3006
+ element.focus();
3007
+ }
3008
+ }
3009
+ function renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances) {
3010
+ var usedFunctions = [];
3011
+ var pattern = new RegExp(Object.keys(elementFunctions)
3012
+ .map(function (el) { return "".concat(el, "+"); })
3013
+ .join('|'), 'g');
3014
+ var matches = placeholder.match(pattern);
3015
+ return placeholder.split(pattern).reduce(function (arr, element, index) {
3016
+ var divider = element && (
3017
+ // eslint-disable-next-line react/no-array-index-key
3018
+ React__default["default"].createElement(Divider, { key: "separator_".concat(index) }, element));
3019
+ var res = __spreadArray$1(__spreadArray$1([], arr, true), [divider], false);
3020
+ var currentMatch = matches && matches[index];
3021
+ if (currentMatch) {
3022
+ var renderFunction = elementFunctions[currentMatch] ||
3023
+ elementFunctions[Object.keys(elementFunctions).find(function (elementFunction) {
3024
+ return currentMatch.match(elementFunction);
3025
+ })];
3026
+ if (!renderFunction) {
3027
+ return res;
3028
+ }
3029
+ if (!allowMultipleInstances && usedFunctions.includes(renderFunction)) {
3030
+ res.push(currentMatch);
3031
+ }
3032
+ else {
3033
+ res.push(renderFunction(currentMatch, index));
3034
+ usedFunctions.push(renderFunction);
3035
+ }
3036
+ }
3037
+ return res;
3038
+ }, []);
3039
+ }
3040
+ var formatNumber = getNumberFormatter({ useGrouping: false });
3041
+ function TimeInput(_a) {
3042
+ var amPmAriaLabel = _a.amPmAriaLabel, autoFocus = _a.autoFocus, className = _a.className, disabled = _a.disabled, format = _a.format, hourAriaLabel = _a.hourAriaLabel, hourPlaceholder = _a.hourPlaceholder, _b = _a.isClockOpen, isClockOpenProps = _b === void 0 ? null : _b, locale = _a.locale, _c = _a.maxDetail, maxDetail = _c === void 0 ? 'minute' : _c, maxTime = _a.maxTime, minTime = _a.minTime, minuteAriaLabel = _a.minuteAriaLabel, minutePlaceholder = _a.minutePlaceholder, _d = _a.name, name = _d === void 0 ? 'time' : _d, nativeInputAriaLabel = _a.nativeInputAriaLabel, onChangeProps = _a.onChange, onInvalidChange = _a.onInvalidChange, required = _a.required, secondAriaLabel = _a.secondAriaLabel, secondPlaceholder = _a.secondPlaceholder, valueProps = _a.value;
3043
+ var _e = React.useState(null), amPm = _e[0], setAmPm = _e[1];
3044
+ var _f = React.useState(null), hour = _f[0], setHour = _f[1];
3045
+ var _g = React.useState(null), minute = _g[0], setMinute = _g[1];
3046
+ var _h = React.useState(null), second = _h[0], setSecond = _h[1];
3047
+ var _j = React.useState(null), value = _j[0], setValue = _j[1];
3048
+ var amPmInput = React.useRef(null);
3049
+ var hour12Input = React.useRef(null);
3050
+ var hour24Input = React.useRef(null);
3051
+ var minuteInput = React.useRef(null);
3052
+ var secondInput = React.useRef(null);
3053
+ var _k = React.useState(isClockOpenProps), isClockOpen = _k[0], setIsClockOpen = _k[1];
3054
+ var lastPressedKey = React.useRef();
3055
+ React.useEffect(function () {
3056
+ setIsClockOpen(isClockOpenProps);
3057
+ }, [isClockOpenProps]);
3058
+ React.useEffect(function () {
3059
+ var nextValue = valueProps;
3060
+ if (nextValue) {
3061
+ setAmPm(convert24to12(getHours(nextValue))[1]);
3062
+ setHour(getHours(nextValue).toString());
3063
+ setMinute(getMinutes(nextValue).toString());
3064
+ setSecond(getSeconds(nextValue).toString());
3065
+ setValue(nextValue);
3066
+ }
3067
+ else {
3068
+ setAmPm(null);
3069
+ setHour(null);
3070
+ setMinute(null);
3071
+ setSecond(null);
3072
+ setValue(null);
3073
+ }
3074
+ }, [
3075
+ valueProps,
3076
+ minTime,
3077
+ maxTime,
3078
+ maxDetail,
3079
+ // Toggling clock visibility resets values
3080
+ isClockOpen,
3081
+ ]);
3082
+ var valueType = maxDetail;
3083
+ var formatTime = (function () {
3084
+ var level = allViews$2.indexOf(maxDetail);
3085
+ var formatterOptions = getFormatterOptionsCache[level] ||
3086
+ (function () {
3087
+ var options = { hour: 'numeric' };
3088
+ if (level >= 1) {
3089
+ options.minute = 'numeric';
3090
+ }
3091
+ if (level >= 2) {
3092
+ options.second = 'numeric';
3093
+ }
3094
+ getFormatterOptionsCache[level] = options;
3095
+ return options;
3096
+ })();
3097
+ return getFormatter(formatterOptions);
3098
+ })();
3099
+ /**
3100
+ * Gets current value in a desired format.
3101
+ */
3102
+ function getProcessedValue(value) {
3103
+ var processFunction = (function () {
3104
+ switch (valueType) {
3105
+ case 'hour':
3106
+ case 'minute':
3107
+ return getHoursMinutes;
3108
+ case 'second':
3109
+ return getHoursMinutesSeconds;
3110
+ default:
3111
+ throw new Error('Invalid valueType');
3112
+ }
3113
+ })();
3114
+ return processFunction(value);
3115
+ }
3116
+ var placeholder = format ||
3117
+ (function () {
3118
+ var hour24 = 21;
3119
+ var hour12 = 9;
3120
+ var minute = 13;
3121
+ var second = 14;
3122
+ var date = new Date(2017, 0, 1, hour24, minute, second);
3123
+ return formatTime(locale, date)
3124
+ .replace(formatNumber(locale, hour12), 'h')
3125
+ .replace(formatNumber(locale, hour24), 'H')
3126
+ .replace(formatNumber(locale, minute), 'mm')
3127
+ .replace(formatNumber(locale, second), 'ss')
3128
+ .replace(new RegExp(getAmPmLabels(locale).join('|')), 'a');
3129
+ })();
3130
+ var divider = (function () {
3131
+ var dividers = placeholder.match(/[^0-9a-z]/i);
3132
+ return dividers ? dividers[0] : null;
3133
+ })();
3134
+ function onClick(event) {
3135
+ if (event.target === event.currentTarget) {
3136
+ // Wrapper was directly clicked
3137
+ var firstInput = event.target.children[1];
3138
+ focus(firstInput);
3139
+ }
3140
+ }
3141
+ function onKeyDown(event) {
3142
+ lastPressedKey.current = event.key;
3143
+ switch (event.key) {
3144
+ case 'ArrowLeft':
3145
+ case 'ArrowRight':
3146
+ case divider: {
3147
+ event.preventDefault();
3148
+ var input = event.target;
3149
+ var property = event.key === 'ArrowLeft' ? 'previousElementSibling' : 'nextElementSibling';
3150
+ var nextInput = findInput(input, property);
3151
+ focus(nextInput);
3152
+ break;
3153
+ }
3154
+ }
3155
+ }
3156
+ function onKeyUp(event) {
3157
+ var key = event.key, input = event.target;
3158
+ var isLastPressedKey = lastPressedKey.current === key;
3159
+ if (!isLastPressedKey) {
3160
+ return;
3161
+ }
3162
+ var isNumberKey = !isNaN(Number(key));
3163
+ if (!isNumberKey) {
3164
+ return;
3165
+ }
3166
+ var max = input.getAttribute('max');
3167
+ if (!max) {
3168
+ return;
3169
+ }
3170
+ var value = input.value;
3171
+ /**
3172
+ * Given 1, the smallest possible number the user could type by adding another digit is 10.
3173
+ * 10 would be a valid value given max = 12, so we won't jump to the next input.
3174
+ * However, given 2, smallers possible number would be 20, and thus keeping the focus in
3175
+ * this field doesn't make sense.
3176
+ */
3177
+ if (Number(value) * 10 > Number(max) || value.length >= max.length) {
3178
+ var property = 'nextElementSibling';
3179
+ var nextInput = findInput(input, property);
3180
+ focus(nextInput);
3181
+ }
3182
+ }
3183
+ /**
3184
+ * Called after internal onChange. Checks input validity. If all fields are valid,
3185
+ * calls props.onChange.
3186
+ */
3187
+ function onChangeExternal() {
3188
+ if (!onChangeProps) {
3189
+ return;
3190
+ }
3191
+ function filterBoolean(value) {
3192
+ return Boolean(value);
3193
+ }
3194
+ var formElements = [
3195
+ amPmInput.current,
3196
+ hour12Input.current,
3197
+ hour24Input.current,
3198
+ minuteInput.current,
3199
+ secondInput.current,
3200
+ ].filter(filterBoolean);
3201
+ var formElementsWithoutSelect = formElements.slice(1);
3202
+ var values = {};
3203
+ formElements.forEach(function (formElement) {
3204
+ values[formElement.name] =
3205
+ formElement.type === 'number'
3206
+ ? 'valueAsNumber' in formElement
3207
+ ? formElement.valueAsNumber
3208
+ : Number(formElement.value)
3209
+ : formElement.value;
3210
+ });
3211
+ var isEveryValueEmpty = formElementsWithoutSelect.every(function (formElement) { return !formElement.value; });
3212
+ if (isEveryValueEmpty) {
3213
+ onChangeProps(null, false);
3214
+ return;
3215
+ }
3216
+ var isEveryValueFilled = formElements.every(function (formElement) { return formElement.value; });
3217
+ var isEveryValueValid = formElements.every(function (formElement) { return formElement.validity.valid; });
3218
+ if (isEveryValueFilled && isEveryValueValid) {
3219
+ var hour_1 = Number(values.hour24 ||
3220
+ (values.hour12 && values.amPm && convert12to24(values.hour12, values.amPm)) ||
3221
+ 0);
3222
+ var minute_1 = Number(values.minute || 0);
3223
+ var second_1 = Number(values.second || 0);
3224
+ var padStart = function (num) { return "0".concat(num).slice(-2); };
3225
+ var proposedValue = "".concat(padStart(hour_1), ":").concat(padStart(minute_1), ":").concat(padStart(second_1));
3226
+ var processedValue = getProcessedValue(proposedValue);
3227
+ onChangeProps(processedValue, false);
3228
+ return;
3229
+ }
3230
+ if (!onInvalidChange) {
3231
+ return;
3232
+ }
3233
+ onInvalidChange();
3234
+ }
3235
+ /**
3236
+ * Called when non-native date input is changed.
3237
+ */
3238
+ function onChange(event) {
3239
+ var _a = event.target, name = _a.name, value = _a.value;
3240
+ switch (name) {
3241
+ case 'amPm':
3242
+ setAmPm(value);
3243
+ break;
3244
+ case 'hour12':
3245
+ setHour(value ? convert12to24(value, amPm || 'am').toString() : '');
3246
+ break;
3247
+ case 'hour24':
3248
+ setHour(value);
3249
+ break;
3250
+ case 'minute':
3251
+ setMinute(value);
3252
+ break;
3253
+ case 'second':
3254
+ setSecond(value);
3255
+ break;
3256
+ }
3257
+ onChangeExternal();
3258
+ }
3259
+ /**
3260
+ * Called when native date input is changed.
3261
+ */
3262
+ function onChangeNative(event) {
3263
+ var value = event.target.value;
3264
+ if (!onChangeProps) {
3265
+ return;
3266
+ }
3267
+ var processedValue = value || null;
3268
+ onChangeProps(processedValue, false);
3269
+ }
3270
+ var commonInputProps = {
3271
+ className: className,
3272
+ disabled: disabled,
3273
+ maxTime: maxTime,
3274
+ minTime: minTime,
3275
+ onChange: onChange,
3276
+ onKeyDown: onKeyDown,
3277
+ onKeyUp: onKeyUp,
3278
+ // This is only for showing validity when editing
3279
+ required: Boolean(required || isClockOpen),
3280
+ };
3281
+ function renderHour12(currentMatch, index) {
3282
+ if (currentMatch && currentMatch.length > 2) {
3283
+ throw new Error("Unsupported token: ".concat(currentMatch));
3284
+ }
3285
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
3286
+ return (React__default["default"].createElement(Hour12Input, __assign$1({ key: "hour12" }, commonInputProps, { amPm: amPm, ariaLabel: hourAriaLabel,
3287
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3288
+ autoFocus: index === 0 && autoFocus, inputRef: hour12Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
3289
+ }
3290
+ function renderHour24(currentMatch, index) {
3291
+ if (currentMatch && currentMatch.length > 2) {
3292
+ throw new Error("Unsupported token: ".concat(currentMatch));
3293
+ }
3294
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
3295
+ return (React__default["default"].createElement(Hour24Input, __assign$1({ key: "hour24" }, commonInputProps, { ariaLabel: hourAriaLabel,
3296
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3297
+ autoFocus: index === 0 && autoFocus, inputRef: hour24Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
3298
+ }
3299
+ function renderHour(currentMatch, index) {
3300
+ if (/h/.test(currentMatch)) {
3301
+ return renderHour12(currentMatch, index);
3302
+ }
3303
+ return renderHour24(currentMatch, index);
3304
+ }
3305
+ function renderMinute(currentMatch, index) {
3306
+ if (currentMatch && currentMatch.length > 2) {
3307
+ throw new Error("Unsupported token: ".concat(currentMatch));
3308
+ }
3309
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
3310
+ return (React__default["default"].createElement(MinuteInput, __assign$1({ key: "minute" }, commonInputProps, { ariaLabel: minuteAriaLabel,
3311
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3312
+ autoFocus: index === 0 && autoFocus, hour: hour, inputRef: minuteInput, placeholder: minutePlaceholder, showLeadingZeros: showLeadingZeros, value: minute })));
3313
+ }
3314
+ function renderSecond(currentMatch, index) {
3315
+ if (currentMatch && currentMatch.length > 2) {
3316
+ throw new Error("Unsupported token: ".concat(currentMatch));
3317
+ }
3318
+ var showLeadingZeros = currentMatch ? currentMatch.length === 2 : true;
3319
+ return (React__default["default"].createElement(SecondInput, __assign$1({ key: "second" }, commonInputProps, { ariaLabel: secondAriaLabel,
3320
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3321
+ autoFocus: index === 0 && autoFocus, hour: hour, inputRef: secondInput, minute: minute, placeholder: secondPlaceholder, showLeadingZeros: showLeadingZeros, value: second })));
3322
+ }
3323
+ function renderAmPm(currentMatch, index) {
3324
+ return (React__default["default"].createElement(AmPm, __assign$1({ key: "ampm" }, commonInputProps, { ariaLabel: amPmAriaLabel,
3325
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3326
+ autoFocus: index === 0 && autoFocus, inputRef: amPmInput, locale: locale, onChange: onChange, value: amPm })));
3327
+ }
3328
+ function renderCustomInputsInternal() {
3329
+ var elementFunctions = {
3330
+ h: renderHour,
3331
+ H: renderHour,
3332
+ m: renderMinute,
3333
+ s: renderSecond,
3334
+ a: renderAmPm,
3335
+ };
3336
+ var allowMultipleInstances = typeof format !== 'undefined';
3337
+ return renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances);
3338
+ }
3339
+ function renderNativeInput() {
3340
+ return (React__default["default"].createElement(NativeInput, { key: "time", ariaLabel: nativeInputAriaLabel, disabled: disabled, maxTime: maxTime, minTime: minTime, name: name, onChange: onChangeNative, required: required, value: value, valueType: valueType }));
3341
+ }
3342
+ return (
3343
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
3344
+ React__default["default"].createElement("div", { className: className, onClick: onClick },
3345
+ renderNativeInput(),
3346
+ renderCustomInputsInternal()));
3347
+ }
3348
+
3349
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
3350
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3351
+ if (ar || !(i in from)) {
3352
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3353
+ ar[i] = from[i];
3354
+ }
3355
+ }
3356
+ return to.concat(ar || Array.prototype.slice.call(from));
3357
+ };
3358
+ var allViews$1 = ['hour', 'minute', 'second'];
3359
+ var allValueTypes = __spreadArray([], allViews$1, true);
3360
+ var hourOptionalSecondsRegExp = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
3361
+ var isTime = function isTime(props, propName, componentName) {
3362
+ var _a = props, _b = propName, time = _a[_b];
3363
+ if (time) {
3364
+ if (typeof time !== 'string' || !hourOptionalSecondsRegExp.test(time)) {
3365
+ return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof time, "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format."));
3366
+ }
3367
+ }
3368
+ // Everything is fine
3369
+ return null;
3370
+ };
3371
+ index.propTypes.exports.oneOf(allValueTypes);
3372
+ index.propTypes.exports.oneOfType([
3373
+ index.propTypes.exports.func,
3374
+ index.propTypes.exports.exact({
3375
+ current: index.propTypes.exports.any,
3376
+ }),
3377
+ ]);
3378
+ var rangeOf = function (type) {
3379
+ return index.propTypes.exports.arrayOf(type);
3380
+ };
3381
+
3382
+ var __assign = (undefined && undefined.__assign) || function () {
3383
+ __assign = Object.assign || function(t) {
3384
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3385
+ s = arguments[i];
3386
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3387
+ t[p] = s[p];
3388
+ }
3389
+ return t;
3390
+ };
3391
+ return __assign.apply(this, arguments);
3392
+ };
3393
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
3394
+ var t = {};
3395
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3396
+ t[p] = s[p];
3397
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3398
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3399
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3400
+ t[p[i]] = s[p[i]];
3401
+ }
3402
+ return t;
3403
+ };
3404
+ var isBrowser = typeof document !== 'undefined';
3405
+ var baseClassName = 'react-time-picker';
3406
+ var outsideActionEvents = ['mousedown', 'focusin', 'touchstart'];
3407
+ var allViews = ['hour', 'minute', 'second'];
3408
+ var iconProps = {
3409
+ xmlns: 'http://www.w3.org/2000/svg',
3410
+ width: 19,
3411
+ height: 19,
3412
+ viewBox: '0 0 19 19',
3413
+ stroke: 'black',
3414
+ strokeWidth: 2,
3415
+ };
3416
+ var ClockIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clock-button__icon ").concat(baseClassName, "__button__icon"), fill: "none" }),
3417
+ React__default["default"].createElement("circle", { cx: "9.5", cy: "9.5", r: "7.5" }),
3418
+ React__default["default"].createElement("path", { d: "M9.5 4.5 v5 h4" })));
3419
+ var ClearIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clear-button__icon ").concat(baseClassName, "__button__icon") }),
3420
+ React__default["default"].createElement("line", { x1: "4", x2: "15", y1: "4", y2: "15" }),
3421
+ React__default["default"].createElement("line", { x1: "15", x2: "4", y1: "4", y2: "15" })));
3422
+ var TimePicker = function TimePicker(props) {
3423
+ var amPmAriaLabel = props.amPmAriaLabel, autoFocus = props.autoFocus, className = props.className, clearAriaLabel = props.clearAriaLabel, _a = props.clearIcon, clearIcon = _a === void 0 ? ClearIcon : _a, clockAriaLabel = props.clockAriaLabel, _b = props.clockIcon, clockIcon = _b === void 0 ? ClockIcon : _b, _c = props.closeClock, shouldCloseClockOnSelect = _c === void 0 ? true : _c, dataTestid = props["data-testid"], hourAriaLabel = props.hourAriaLabel, hourPlaceholder = props.hourPlaceholder, disableClock = props.disableClock, disabled = props.disabled, format = props.format, id = props.id, _d = props.isOpen, isOpenProps = _d === void 0 ? null : _d, locale = props.locale, maxTime = props.maxTime, _e = props.maxDetail, maxDetail = _e === void 0 ? 'minute' : _e, minTime = props.minTime, minuteAriaLabel = props.minuteAriaLabel, minutePlaceholder = props.minutePlaceholder, _f = props.name, name = _f === void 0 ? 'time' : _f, nativeInputAriaLabel = props.nativeInputAriaLabel, onClockClose = props.onClockClose, onClockOpen = props.onClockOpen, onChangeProps = props.onChange, onFocusProps = props.onFocus, onInvalidChange = props.onInvalidChange, _g = props.openClockOnFocus, openClockOnFocus = _g === void 0 ? true : _g, required = props.required, value = props.value, secondAriaLabel = props.secondAriaLabel, secondPlaceholder = props.secondPlaceholder, shouldCloseClock = props.shouldCloseClock, shouldOpenClock = props.shouldOpenClock, otherProps = __rest(props, ["amPmAriaLabel", "autoFocus", "className", "clearAriaLabel", "clearIcon", "clockAriaLabel", "clockIcon", "closeClock", 'data-testid', "hourAriaLabel", "hourPlaceholder", "disableClock", "disabled", "format", "id", "isOpen", "locale", "maxTime", "maxDetail", "minTime", "minuteAriaLabel", "minutePlaceholder", "name", "nativeInputAriaLabel", "onClockClose", "onClockOpen", "onChange", "onFocus", "onInvalidChange", "openClockOnFocus", "required", "value", "secondAriaLabel", "secondPlaceholder", "shouldCloseClock", "shouldOpenClock"]);
3424
+ var _h = React.useState(isOpenProps), isOpen = _h[0], setIsOpen = _h[1];
3425
+ var wrapper = React.useRef(null);
3426
+ var clockWrapper = React.useRef(null);
3427
+ React.useEffect(function () {
3428
+ setIsOpen(isOpenProps);
3429
+ }, [isOpenProps]);
3430
+ function openClock(_a) {
3431
+ var reason = _a.reason;
3432
+ if (shouldOpenClock) {
3433
+ if (!shouldOpenClock({ reason: reason })) {
3434
+ return;
3435
+ }
3436
+ }
3437
+ setIsOpen(true);
3438
+ if (onClockOpen) {
3439
+ onClockOpen();
3440
+ }
3441
+ }
3442
+ var closeClock = React.useCallback(function (_a) {
3443
+ var reason = _a.reason;
3444
+ if (shouldCloseClock) {
3445
+ if (!shouldCloseClock({ reason: reason })) {
3446
+ return;
3447
+ }
3448
+ }
3449
+ setIsOpen(false);
3450
+ if (onClockClose) {
3451
+ onClockClose();
3452
+ }
3453
+ }, [onClockClose, shouldCloseClock]);
3454
+ function toggleClock() {
3455
+ if (isOpen) {
3456
+ closeClock({ reason: 'buttonClick' });
3457
+ }
3458
+ else {
3459
+ openClock({ reason: 'buttonClick' });
3460
+ }
3461
+ }
3462
+ function onChange(value, shouldCloseClock) {
3463
+ if (shouldCloseClock === void 0) { shouldCloseClock = shouldCloseClockOnSelect; }
3464
+ if (shouldCloseClock) {
3465
+ closeClock({ reason: 'select' });
3466
+ }
3467
+ if (onChangeProps) {
3468
+ onChangeProps(value);
3469
+ }
3470
+ }
3471
+ function onFocus(event) {
3472
+ if (onFocusProps) {
3473
+ onFocusProps(event);
3474
+ }
3475
+ if (
3476
+ // Internet Explorer still fires onFocus on disabled elements
3477
+ disabled ||
3478
+ isOpen ||
3479
+ !openClockOnFocus ||
3480
+ event.target.dataset.select === 'true') {
3481
+ return;
3482
+ }
3483
+ openClock({ reason: 'focus' });
3484
+ }
3485
+ var onKeyDown = React.useCallback(function (event) {
3486
+ if (event.key === 'Escape') {
3487
+ closeClock({ reason: 'escape' });
3488
+ }
3489
+ }, [closeClock]);
3490
+ function clear() {
3491
+ onChange(null);
3492
+ }
3493
+ function stopPropagation(event) {
3494
+ event.stopPropagation();
3495
+ }
3496
+ var onOutsideAction = React.useCallback(function (event) {
3497
+ var wrapperEl = wrapper.current;
3498
+ var clockWrapperEl = clockWrapper.current;
3499
+ // Try event.composedPath first to handle clicks inside a Shadow DOM.
3500
+ var target = ('composedPath' in event ? event.composedPath()[0] : event.target);
3501
+ if (target &&
3502
+ wrapperEl &&
3503
+ !wrapperEl.contains(target) &&
3504
+ (!clockWrapperEl || !clockWrapperEl.contains(target))) {
3505
+ closeClock({ reason: 'outsideAction' });
3506
+ }
3507
+ }, [clockWrapper, closeClock, wrapper]);
3508
+ var handleOutsideActionListeners = React.useCallback(function (shouldListen) {
3509
+ if (shouldListen === void 0) { shouldListen = isOpen; }
3510
+ outsideActionEvents.forEach(function (event) {
3511
+ if (shouldListen) {
3512
+ document.addEventListener(event, onOutsideAction);
3513
+ }
3514
+ else {
3515
+ document.removeEventListener(event, onOutsideAction);
3516
+ }
3517
+ });
3518
+ if (shouldListen) {
3519
+ document.addEventListener('keydown', onKeyDown);
3520
+ }
3521
+ else {
3522
+ document.removeEventListener('keydown', onKeyDown);
3523
+ }
3524
+ }, [isOpen, onOutsideAction, onKeyDown]);
3525
+ React.useEffect(function () {
3526
+ handleOutsideActionListeners();
3527
+ return function () {
3528
+ handleOutsideActionListeners(false);
3529
+ };
3530
+ }, [handleOutsideActionListeners]);
3531
+ function renderInputs() {
3532
+ var valueFrom = (Array.isArray(value) ? value : [value])[0];
3533
+ var ariaLabelProps = {
3534
+ amPmAriaLabel: amPmAriaLabel,
3535
+ hourAriaLabel: hourAriaLabel,
3536
+ minuteAriaLabel: minuteAriaLabel,
3537
+ nativeInputAriaLabel: nativeInputAriaLabel,
3538
+ secondAriaLabel: secondAriaLabel,
3539
+ };
3540
+ var placeholderProps = {
3541
+ hourPlaceholder: hourPlaceholder,
3542
+ minutePlaceholder: minutePlaceholder,
3543
+ secondPlaceholder: secondPlaceholder,
3544
+ };
3545
+ return (React__default["default"].createElement("div", { className: "".concat(baseClassName, "__wrapper") },
3546
+ React__default["default"].createElement(TimeInput, __assign({}, ariaLabelProps, placeholderProps, {
3547
+ // eslint-disable-next-line jsx-a11y/no-autofocus
3548
+ autoFocus: autoFocus, className: "".concat(baseClassName, "__inputGroup"), disabled: disabled, format: format, isClockOpen: isOpen, locale: locale, maxDetail: maxDetail, maxTime: maxTime, minTime: minTime, name: name, onChange: onChange, onInvalidChange: onInvalidChange, required: required, value: valueFrom })),
3549
+ clearIcon !== null && (React__default["default"].createElement("button", { "aria-label": clearAriaLabel, className: "".concat(baseClassName, "__clear-button ").concat(baseClassName, "__button"), disabled: disabled, onClick: clear, onFocus: stopPropagation, type: "button" }, typeof clearIcon === 'function' ? React__default["default"].createElement(clearIcon) : clearIcon)),
3550
+ clockIcon !== null && !disableClock && (React__default["default"].createElement("button", { "aria-label": clockAriaLabel, className: "".concat(baseClassName, "__clock-button ").concat(baseClassName, "__button"), disabled: disabled, onClick: toggleClock, onFocus: stopPropagation, type: "button" }, typeof clockIcon === 'function' ? React__default["default"].createElement(clockIcon) : clockIcon))));
3551
+ }
3552
+ function renderClock() {
3553
+ if (isOpen === null || disableClock) {
3554
+ return null;
3555
+ }
3556
+ var clockClassName = props.clockClassName; props.className; // Unused, here to exclude it from clockProps
3557
+ props.onChange; // Unused, here to exclude it from clockProps
3558
+ var portalContainer = props.portalContainer, value = props.value, clockProps = __rest(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
3559
+ var className = "".concat(baseClassName, "__clock");
3560
+ var classNames = clsx(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
3561
+ var valueFrom = (Array.isArray(value) ? value : [value])[0];
3562
+ var clock = React__default["default"].createElement(Clock, __assign({ className: clockClassName, value: valueFrom }, clockProps));
3563
+ return portalContainer ? (ReactDOM.createPortal(React__default["default"].createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default["default"].createElement(Fit, null,
3564
+ React__default["default"].createElement("div", { ref: function (ref) {
3565
+ if (ref && !isOpen) {
3566
+ ref.removeAttribute('style');
3567
+ }
3568
+ }, className: classNames }, clock)));
3569
+ }
3570
+ var eventProps = React.useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
3571
+ return (React__default["default"].createElement("div", __assign({ className: clsx(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className), "data-testid": dataTestid, id: id }, eventProps, { onFocus: onFocus, ref: wrapper }),
3572
+ renderInputs(),
3573
+ renderClock()));
3574
+ };
3575
+ var isValue = index.propTypes.exports.oneOfType([isTime, index.propTypes.exports.instanceOf(Date)]);
3576
+ var isValueOrValueArray = index.propTypes.exports.oneOfType([isValue, rangeOf(isValue)]);
3577
+ TimePicker.propTypes = {
3578
+ amPmAriaLabel: index.propTypes.exports.string,
3579
+ autoFocus: index.propTypes.exports.bool,
3580
+ className: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.arrayOf(index.propTypes.exports.string)]),
3581
+ clearAriaLabel: index.propTypes.exports.string,
3582
+ clearIcon: index.propTypes.exports.oneOfType([index.propTypes.exports.node, index.propTypes.exports.func]),
3583
+ clockAriaLabel: index.propTypes.exports.string,
3584
+ clockClassName: index.propTypes.exports.oneOfType([index.propTypes.exports.string, index.propTypes.exports.arrayOf(index.propTypes.exports.string)]),
3585
+ clockIcon: index.propTypes.exports.oneOfType([index.propTypes.exports.node, index.propTypes.exports.func]),
3586
+ closeClock: index.propTypes.exports.bool,
3587
+ 'data-testid': index.propTypes.exports.string,
3588
+ disableClock: index.propTypes.exports.bool,
3589
+ disabled: index.propTypes.exports.bool,
3590
+ format: index.propTypes.exports.string,
3591
+ hourAriaLabel: index.propTypes.exports.string,
3592
+ hourPlaceholder: index.propTypes.exports.string,
3593
+ id: index.propTypes.exports.string,
3594
+ isOpen: index.propTypes.exports.bool,
3595
+ locale: index.propTypes.exports.string,
3596
+ maxDetail: index.propTypes.exports.oneOf(allViews),
3597
+ maxTime: isTime,
3598
+ minTime: isTime,
3599
+ minuteAriaLabel: index.propTypes.exports.string,
3600
+ minutePlaceholder: index.propTypes.exports.string,
3601
+ name: index.propTypes.exports.string,
3602
+ nativeInputAriaLabel: index.propTypes.exports.string,
3603
+ onChange: index.propTypes.exports.func,
3604
+ onClockClose: index.propTypes.exports.func,
3605
+ onClockOpen: index.propTypes.exports.func,
3606
+ onFocus: index.propTypes.exports.func,
3607
+ openClockOnFocus: index.propTypes.exports.bool,
3608
+ required: index.propTypes.exports.bool,
3609
+ secondAriaLabel: index.propTypes.exports.string,
3610
+ secondPlaceholder: index.propTypes.exports.string,
3611
+ value: isValueOrValueArray,
3612
+ };
3613
+ if (isBrowser) {
3614
+ TimePicker.propTypes.portalContainer = index.propTypes.exports.instanceOf(HTMLElement);
3615
+ }
3616
+
3617
+ var HoverIcon = function HoverIcon(_ref) {
3618
+ var _ref$time = _ref.time,
3619
+ time = _ref$time === void 0 ? false : _ref$time;
3620
+ var _useState = React.useState(false),
3621
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
3622
+ hovered = _useState2[0],
3623
+ setHovered = _useState2[1];
3624
+ return /*#__PURE__*/React__default["default"].createElement("div", {
3625
+ onMouseLeave: function onMouseLeave() {
3626
+ return setHovered(false);
3627
+ },
3628
+ onMouseOver: function onMouseOver() {
3629
+ return setHovered(true);
3630
+ }
3631
+ }, hovered && time ? /*#__PURE__*/React__default["default"].createElement(neetoIcons.Close, {
3632
+ size: 16
3633
+ }) : /*#__PURE__*/React__default["default"].createElement(neetoIcons.Clock, {
3634
+ size: 16
3635
+ }));
3636
+ };
3637
+
3638
+ // A wrapper hook around useState, that updates a ref as well, useful when dealing directly with dom event listeners.
3639
+ var useRefState = function useRefState(val) {
3640
+ // eslint-disable-next-line react/hook-use-state
3641
+ var _useState = React.useState(val),
3642
+ _useState2 = slicedToArray._slicedToArray(_useState, 2),
3643
+ value = _useState2[0],
3644
+ _setValue = _useState2[1];
3645
+ var valueRef = React.useRef(value);
3646
+ var setValue = function setValue(val) {
3647
+ valueRef.current = val;
3648
+ _setValue(val);
3649
+ };
3650
+ return [value, valueRef, setValue];
3651
+ };
3652
+
3653
+ var FORMAT = "HH:mm";
3654
+ var getFormattedTime = function getFormattedTime(value) {
3655
+ if (index$1.dayjs.isDayjs(value)) {
3656
+ return value.toDate();
3657
+ } else if (value instanceof Date || index$1.dayjs(value, FORMAT).isValid()) {
3658
+ return value;
3659
+ }
3660
+ return null;
3661
+ };
3662
+ var getFormattedRange = function getFormattedRange(value) {
3663
+ if (!Array.isArray(value)) return null;
3664
+ return value.map(function (item) {
3665
+ return getFormattedTime(item);
3666
+ });
3667
+ };
3668
+ var toDayJs = function toDayJs(value) {
3669
+ if (Array.isArray(value)) return value.map(function (item) {
3670
+ return index$1.dayjs(item, FORMAT);
3671
+ });
3672
+ return index$1.dayjs(value, FORMAT);
3673
+ };
3674
+ var isValidTime = function isValidTime(minTime, maxTime, value) {
3675
+ if (neetoCist.isPresent(minTime) && toDayJs(value).isBefore(toDayJs(minTime))) {
3676
+ return false;
3677
+ }
3678
+ return !(neetoCist.isPresent(maxTime) && toDayJs(value).isAfter(toDayJs(maxTime)));
3679
+ };
3680
+ var isValidRange = function isValidRange(minTime, maxTime, value) {
3681
+ return value.every(function (item) {
3682
+ return isValid(minTime, maxTime, item);
3683
+ });
3684
+ };
3685
+ var isValid = function isValid(minTime, maxTime, value) {
3686
+ return (Array.isArray(value) ? isValidRange : isValidTime)(minTime, maxTime, value);
3687
+ };
3688
+ var getValidTime = function getValidTime(minTime, maxTime, value) {
3689
+ if (neetoCist.isPresent(minTime) && toDayJs(value).isBefore(toDayJs(minTime))) {
3690
+ return minTime;
3691
+ }
3692
+ if (neetoCist.isPresent(maxTime) && toDayJs(value).isAfter(toDayJs(maxTime))) {
3693
+ return maxTime;
3694
+ }
3695
+ return value;
3696
+ };
3697
+ var getValidRange = function getValidRange(minTime, maxTime, value) {
3698
+ return value.map(function (item) {
3699
+ return getValidTime(minTime, maxTime, item);
3700
+ });
3701
+ };
3702
+ var getValid = function getValid(minTime, maxTime, value) {
3703
+ return (Array.isArray(value) ? getValidRange : getValidTime)(minTime, maxTime, value);
3704
+ };
3705
+
3706
+ var _excluded = ["type", "className", "label", "labelProps", "size", "nakedInput", "required", "value", "defaultValue", "onChange", "error", "onBlur", "minTime", "maxTime"];
3707
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3708
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { defineProperty._defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3709
+ index$1.dayjs.extend(customParseFormat);
3710
+ var INPUT_SIZES = {
3711
+ small: "small",
3712
+ medium: "medium",
3713
+ large: "large"
3714
+ };
3715
+ var timeComponents = {
3716
+ range: TimeRangePicker,
3717
+ time: TimePicker
3718
+ };
3719
+ var TimePickerInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3720
+ var _ref$type = _ref.type,
3721
+ type = _ref$type === void 0 ? "time" : _ref$type,
3722
+ _ref$className = _ref.className,
3723
+ className = _ref$className === void 0 ? "" : _ref$className,
3724
+ label = _ref.label,
3725
+ labelProps = _ref.labelProps,
3726
+ _ref$size = _ref.size,
3727
+ size = _ref$size === void 0 ? INPUT_SIZES.medium : _ref$size,
3728
+ _ref$nakedInput = _ref.nakedInput,
3729
+ nakedInput = _ref$nakedInput === void 0 ? false : _ref$nakedInput,
3730
+ _ref$required = _ref.required,
3731
+ required = _ref$required === void 0 ? false : _ref$required,
3732
+ inputValue = _ref.value,
3733
+ defaultValue = _ref.defaultValue,
3734
+ _ref$onChange = _ref.onChange,
3735
+ onChange = _ref$onChange === void 0 ? index$1.noop : _ref$onChange,
3736
+ _ref$error = _ref.error,
3737
+ error = _ref$error === void 0 ? "" : _ref$error,
3738
+ _ref$onBlur = _ref.onBlur,
3739
+ onBlur = _ref$onBlur === void 0 ? index$1.noop : _ref$onBlur,
3740
+ minTime = _ref.minTime,
3741
+ maxTime = _ref.maxTime,
3742
+ otherProps = objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
3743
+ var _useRefState = useRefState(null),
3744
+ _useRefState2 = slicedToArray._slicedToArray(_useRefState, 3),
3745
+ value = _useRefState2[0],
3746
+ valueRef = _useRefState2[1],
3747
+ setValue = _useRefState2[2];
3748
+ var componentRef = React.useRef(null);
3749
+ var id = useId.useId(otherProps.id);
3750
+ var errorId = "error_".concat(id);
3751
+ React.useEffect(function () {
3752
+ if (neetoCist.isNotPresent(inputValue) && neetoCist.isNotPresent(defaultValue)) return;
3753
+ setValue((type === "range" ? getFormattedRange : getFormattedTime)(inputValue || defaultValue));
3754
+ }, [type, inputValue]);
3755
+ var handleChange = function handleChange(newValue) {
3756
+ setValue(newValue);
3757
+ if (isValid(minTime, maxTime, newValue)) {
3758
+ onChange(toDayJs(newValue), newValue);
3759
+ }
3760
+ };
3761
+ var onBlurHandle = function onBlurHandle() {
3762
+ if (isValid(minTime, maxTime, value)) {
3763
+ onBlur(toDayJs(value), value);
3764
+ } else {
3765
+ var validValue = getValid(minTime, maxTime, value);
3766
+ setValue(validValue);
3767
+ onChange(toDayJs(validValue), validValue);
3768
+ onBlur(toDayJs(validValue), validValue);
3769
+ }
3770
+ return true;
3771
+ };
3772
+ var onAmPmChange = function onAmPmChange() {
3773
+ var value = valueRef.current;
3774
+ if (!isValid(minTime, maxTime, value)) {
3775
+ var validValue = getValid(minTime, maxTime, value);
3776
+ setValue(validValue);
3777
+ onChange(toDayJs(validValue), validValue);
3778
+ }
3779
+ };
3780
+
3781
+ // If you just make amPm select change, onBlurHandle is not triggering. A work around
3782
+ React.useEffect(function () {
3783
+ var _document$getElementB;
3784
+ var amPmChange = function amPmChange() {
3785
+ return setTimeout(onAmPmChange);
3786
+ };
3787
+ var selectElements = (_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.querySelectorAll("[name='amPm']");
3788
+ selectElements === null || selectElements === void 0 || selectElements.forEach(function (element) {
3789
+ return element.addEventListener("change", amPmChange);
3790
+ });
3791
+ return function () {
3792
+ selectElements === null || selectElements === void 0 || selectElements.forEach(function (element) {
3793
+ return element.removeEventListener("change", amPmChange);
3794
+ });
3795
+ };
3796
+ }, [value]);
3797
+ var handleKeyDown = function handleKeyDown(_ref2) {
3798
+ var code = _ref2.code;
3799
+ if (code !== "Enter") return;
3800
+ onBlurHandle();
3801
+ };
3802
+ var Component = timeComponents[type];
3803
+ return /*#__PURE__*/React__default["default"].createElement("div", {
3804
+ ref: ref,
3805
+ className: "neeto-ui-input__wrapper"
3806
+ }, label && /*#__PURE__*/React__default["default"].createElement(Label, _objectSpread({
3807
+ required: required
3808
+ }, labelProps), label), /*#__PURE__*/React__default["default"].createElement(Component, _extends._extends({
3809
+ id: id,
3810
+ value: value,
3811
+ disableClock: true,
3812
+ clearIcon: /*#__PURE__*/React__default["default"].createElement(HoverIcon, {
3813
+ time: !!value
3814
+ }),
3815
+ format: "hh:mm a",
3816
+ hourPlaceholder: "HH",
3817
+ minutePlaceholder: "mm",
3818
+ ref: componentRef,
3819
+ secondAriaLabel: "ss",
3820
+ shouldCloseClock: onBlurHandle,
3821
+ className: index$2.classnames("neeto-ui-time-picker", [className], {
3822
+ "neeto-ui-time-picker--small": size === "small",
3823
+ "neeto-ui-time-picker--medium": size === "medium",
3824
+ "neeto-ui-time-picker--large": size === "large",
3825
+ "neeto-ui-time-picker--disabled": otherProps.disabled,
3826
+ "neeto-ui-time-picker--naked": nakedInput,
3827
+ "neeto-ui-time-picker--error": !!error
3828
+ }),
3829
+ onChange: handleChange,
3830
+ onKeyDown: handleKeyDown
3831
+ }, otherProps)), !!error && typeof error === "string" && /*#__PURE__*/React__default["default"].createElement("p", {
3832
+ className: "neeto-ui-input__error",
3833
+ "data-cy": "".concat(index$1.hyphenize(label), "-input-error"),
3834
+ id: errorId
3835
+ }, error));
3836
+ });
3837
+ TimePickerInput.displayName = "TimePicker";
3838
+
3839
+ exports.TimePickerInput = TimePickerInput;
3840
+ exports.customParseFormat = customParseFormat;
3841
+ //# sourceMappingURL=index-a780bb4a.js.map