@bigbinary/neetoui 6.6.0 → 6.7.0

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