You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
10 KiB
1 lines
10 KiB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).AnalogTimePicker=t(e.React)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e);function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw o}}return a}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e){var t=e.direction,n=e.onClick,o=e.disabled;return r.default.createElement("span",{className:"rmdp-arrow-container ".concat(t," ").concat(o?"disabled":""),onClick:n},r.default.createElement("i",{className:"rmdp-arrow"}))}function c(e){var t=e.name,n=e.value,o=e.onChange,a=e.digits;return r.default.createElement("input",{type:"text",name:t,value:n,onChange:function(e){var r=i(e.target.value);if(isNaN(r))return;o(t,r)},onKeyDown:function(e){var r;if("ArrowUp"===e.key)r=1;else{if("ArrowDown"!==e.key)return;r=-1}o(t,i(n)+r)}});function i(e){var t,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,d=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){d=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(d)throw a}}}}(a);try{for(r.s();!(t=r.n()).done;){var n=t.value;e=e.replace(n,a.indexOf(n))}}catch(e){r.e(e)}finally{r.f()}return Number(e)}}function u(e){return Array.isArray(e)}function m(t){var n=t.selectedDate,a=t.focused,i=t.handleFocusedDate,l=t.state,d=t.setState,p=t.format;return e.useEffect((function(){u(n)&&0!==n.length&&(a||c(n[0]))}),[a,n,c]),u(n)&&r.default.createElement("div",{style:{display:"flex",padding:"5px 0"}},r.default.createElement("select",{className:"rmdp-input",style:{height:"26px",width:"90%",margin:"auto"},value:(null==a?void 0:a.day)||"",onChange:function(e){return c(n.find((function(t){return t.day.toString()===e.target.value})))}},n.map((function(e){return r.default.createElement("option",{key:e.day,value:e.day},e.format(p))}))));function c(e){d(o(o({},l),{},{focused:e})),i(e)}}function f(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}f(".rmdp-analog-clock{background-color:#83cbe7;border:5px solid #09589e;border-radius:50%;height:130px;margin:auto 20px;position:relative;width:130px}.bottom .rmdp-analog-clock,.top .rmdp-analog-clock{margin:20px auto}.rmdp-analog-clock .dot{background-color:#ccc;border-radius:50%;bottom:0;box-shadow:0 2px 4px -1px #000;height:8px;left:0;margin:auto;position:absolute;right:0;top:0;width:8px;z-index:10}.rmdp-analog-clock .rmdp-hour{background-color:#333;height:30px;top:35px;transform-origin:50% 30px;z-index:5}.rmdp-analog-clock .rmdp-hour,.rmdp-analog-clock .rmdp-minute{border-top-left-radius:50%;border-top-right-radius:50%;left:50%;margin-left:-2px;position:absolute;width:4px}.rmdp-analog-clock .rmdp-minute{background-color:#666;height:55px;top:14px;transform-origin:50% 52px;z-index:6}.rmdp-analog-clock .rmdp-second{background-color:#0074d9;border-top-left-radius:50%;border-top-right-radius:50%;height:60px;left:50%;margin-left:-1px;position:absolute;top:10px;transform-origin:50% 55px;width:2px;z-index:7}.rmdp-analog-clock span{color:#333;display:inline-block;font-family:Arial;font-size:16px;font-weight:700;position:absolute;z-index:4}.rmdp-analog-clock .rmdp-h12{left:50%;margin-left:-9px;top:10px}.rmdp-analog-clock .rmdp-h3{right:10px;top:58px}.rmdp-analog-clock .rmdp-h6{bottom:7px;left:50%;margin-left:-4px}.rmdp-analog-clock .rmdp-h9{left:10px;top:58px}.rmdp-analog-clock .dial-lines{background-color:#4ca6f5;height:5px;left:50%;margin-left:-1px;position:absolute;transform-origin:50% 65px;width:2px;z-index:2}.rmdp-analog-clock .dial-lines:nth-of-type(5n){background-color:#0074d9;height:8px;width:3px}@media (max-height:400px),(max-width:400px){.rmdp-analog-clock{height:100px;margin:20px 10px;width:100px}.rmdp-analog-clock .dial-lines{height:3px;transform-origin:50% 50px;width:1px}.rmdp-analog-clock .dial-lines:nth-of-type(5n){background-color:#0074d9;height:5px;width:2px}.rmdp-analog-clock span{font-size:12px;font-weight:400}.rmdp-analog-clock .rmdp-h12{top:6px}.rmdp-analog-clock .rmdp-h3{right:7px;top:41px}.rmdp-analog-clock .rmdp-h6{bottom:6px}.rmdp-analog-clock .rmdp-h9{left:7px;top:41px}.rmdp-analog-clock .rmdp-hour{height:20px;top:30px;transform-origin:50% 20px}.rmdp-analog-clock .rmdp-minute{height:28px;top:19px;transform-origin:50% 31px}.rmdp-analog-clock .rmdp-second{height:33px;top:16px;transform-origin:50% 35px}.rmdp-analog-clock .dot{box-shadow:0 2px 4px -1px #000;height:7px;width:7px}}");f(".rmdp-time-picker.left div,.rmdp-time-picker.right div{margin:auto}.rmdp-time-picker{display:flex;padding:3px 0}.rmdp-time-picker.active{display:flex}.rmdp-time-picker div{align-items:center;display:flex;flex:1;flex-direction:column;margin-top:1px}.rmdp-time-picker div input{border:none;flex-grow:1;font-size:14px;padding:5px 2px;text-align:center;width:20px}.rmdp-time-picker div input::-webkit-inner-spin-button,.rmdp-time-picker div input::-webkit-outer-spin-button{-webkit-appearance:none}.rmdp-time-picker div input[type=number]{-moz-appearance:textfield}.rmdp-time-picker .dvdr{display:flex;flex-direction:column;justify-content:center;margin-top:-5px}.rmdp-time-picker div .rmdp-am{color:#000;font-size:13px;line-height:22px;margin-top:2px}.rmdp-only-time-picker{margin-bottom:0;width:220px}.rmdp-up i{margin-top:7px;transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}.rmdp-down i{margin-top:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}@media (max-height:400px),(max-width:400px){.rmdp-time-picker div input{font-size:12px}.rmdp-time-picker div .rmdp-am{font-size:12px;line-height:22px}}");var s=function(e){return"rotate(".concat(e,"deg)")},g=[["hour","HH"],["minute","mm"],["second","ss"]];function h(e){var t=e.name,n=i(e.values,2),o=n[0],a=n[1],l=e.update,d=e.digits,u=e.hideDivider;return r.default.createElement(r.default.Fragment,null,r.default.createElement("div",null,r.default.createElement(p,{direction:"rmdp-up",onClick:function(){return l(t,o+1)}}),r.default.createElement(c,{value:a,onChange:l,digits:d,name:t}),r.default.createElement(p,{direction:"rmdp-down",onClick:function(){return l(t,o-1)}})),!u&&r.default.createElement("span",{className:"dvdr"},":"))}return function(t){var n=t.state,a=t.setState,l=t.handleChange,d=t.handleFocusedDate,p=t.format,c=void 0===p?"YYYY/MM/DD":p,u=t.position,f=t.calendarProps.disableDayPicker,x=t.hideSeconds,y=n.date,b=n.selectedDate,v=n.multiple,k=n.range,w=n.focused,E=(v||k?w:b)||y,O=E.hour,j=E.minute,A=E.second,D={hour:30*O+.5*j,minute:6*j+.1*A,second:6*A},S=e.useMemo((function(){return Array.from(Array(60).keys()).map((function(e){return r.default.createElement("div",{key:e,className:"dial-lines",style:{transform:s(6*(e+1))}})}))}),[]),N=["3","6","9","12"].map((function(e,t){return r.default.createElement("span",{key:t,className:"rmdp-h"+e},e.replace(/[0-9]/g,(function(e){return y.digits[e]})))}));return r.default.createElement("div",{className:u,style:{display:"grid",minWidth:f?"180px":""}},r.default.createElement("div",{className:"rmdp-analog-clock"},r.default.createElement("div",{className:"dot"}),r.default.createElement("div",null,g.map((function(e,t){var n=i(e,1)[0];return"second"===n&&x?null:r.default.createElement("div",{key:t,style:{transform:s(D[n])},className:"rmdp-".concat(n)})}))),r.default.createElement("div",null,N),r.default.createElement("div",null,S)),Array.isArray(b)&&r.default.createElement(m,{selectedDate:b,focused:w,handleFocusedDate:d,state:n,setState:a,format:c}),r.default.createElement("div",{style:{margin:"auto 0"}},r.default.createElement("div",{className:"rmdp-time-picker"},g.map((function(e,t){var n=i(e,2),o=n[0],a=n[1];return"second"===o&&x?null:r.default.createElement(h,{key:t,name:o,values:C(o,a),update:z,digits:y.digits,hideDivider:"second"===o||"minute"===o&&x})})))));function C(e,t){return E[e]||(E[e]=0),[E[e],E.format(t)]}function z(e,t){E[e]=t,l(b,o(o({},n),{},{selectedDate:b,focused:w}))}}}));
|
|
|