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