@bigbinary/neetoui 6.2.6 → 6.3.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.
- package/index.cjs.js +1359 -295
- package/index.cjs.js.map +1 -1
- package/index.css +4 -1
- package/index.d.ts +8 -4
- package/index.js +1359 -295
- package/index.js.map +1 -1
- package/package.json +3 -1
package/index.cjs.js
CHANGED
|
@@ -257,9 +257,9 @@ const MotionContext = React$3.createContext({});
|
|
|
257
257
|
*/
|
|
258
258
|
const PresenceContext = React$3.createContext(null);
|
|
259
259
|
|
|
260
|
-
const isBrowser$
|
|
260
|
+
const isBrowser$b = typeof document !== "undefined";
|
|
261
261
|
|
|
262
|
-
const useIsomorphicLayoutEffect$
|
|
262
|
+
const useIsomorphicLayoutEffect$3 = isBrowser$b ? React$3.useLayoutEffect : React$3.useEffect;
|
|
263
263
|
|
|
264
264
|
const LazyContext = React$3.createContext({ strict: false });
|
|
265
265
|
|
|
@@ -294,7 +294,7 @@ function useVisualElement(Component, visualState, props, createVisualElement) {
|
|
|
294
294
|
* was present on initial render - it will be deleted after this.
|
|
295
295
|
*/
|
|
296
296
|
const canHandoff = React$3.useRef(Boolean(window.HandoffAppearAnimations));
|
|
297
|
-
useIsomorphicLayoutEffect$
|
|
297
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
298
298
|
if (!visualElement)
|
|
299
299
|
return;
|
|
300
300
|
visualElement.render();
|
|
@@ -485,7 +485,7 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, useRend
|
|
|
485
485
|
const { isStatic } = configAndProps;
|
|
486
486
|
const context = useCreateMotionContext(props);
|
|
487
487
|
const visualState = useVisualState(props, isStatic);
|
|
488
|
-
if (!isStatic && isBrowser$
|
|
488
|
+
if (!isStatic && isBrowser$b) {
|
|
489
489
|
/**
|
|
490
490
|
* Create a VisualElement for this component. A VisualElement provides a common
|
|
491
491
|
* interface to renderer-specific APIs (ie DOM/Three.js etc) as well as
|
|
@@ -2807,7 +2807,7 @@ function calcGeneratorVelocity(resolveValue, t, current) {
|
|
|
2807
2807
|
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
2808
2808
|
}
|
|
2809
2809
|
|
|
2810
|
-
const safeMin$
|
|
2810
|
+
const safeMin$2 = 0.001;
|
|
2811
2811
|
const minDuration = 0.01;
|
|
2812
2812
|
const maxDuration$1 = 10.0;
|
|
2813
2813
|
const minDamping = 0.05;
|
|
@@ -2832,7 +2832,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2832
2832
|
const a = exponentialDecay - velocity;
|
|
2833
2833
|
const b = calcAngularFreq(undampedFreq, dampingRatio);
|
|
2834
2834
|
const c = Math.exp(-delta);
|
|
2835
|
-
return safeMin$
|
|
2835
|
+
return safeMin$2 - (a / b) * c;
|
|
2836
2836
|
};
|
|
2837
2837
|
derivative = (undampedFreq) => {
|
|
2838
2838
|
const exponentialDecay = undampedFreq * dampingRatio;
|
|
@@ -2841,7 +2841,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2841
2841
|
const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq, 2) * duration;
|
|
2842
2842
|
const f = Math.exp(-delta);
|
|
2843
2843
|
const g = calcAngularFreq(Math.pow(undampedFreq, 2), dampingRatio);
|
|
2844
|
-
const factor = -envelope(undampedFreq) + safeMin$
|
|
2844
|
+
const factor = -envelope(undampedFreq) + safeMin$2 > 0 ? -1 : 1;
|
|
2845
2845
|
return (factor * ((d - e) * f)) / g;
|
|
2846
2846
|
};
|
|
2847
2847
|
}
|
|
@@ -2852,7 +2852,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2852
2852
|
envelope = (undampedFreq) => {
|
|
2853
2853
|
const a = Math.exp(-undampedFreq * duration);
|
|
2854
2854
|
const b = (undampedFreq - velocity) * duration + 1;
|
|
2855
|
-
return -safeMin$
|
|
2855
|
+
return -safeMin$2 + a * b;
|
|
2856
2856
|
};
|
|
2857
2857
|
derivative = (undampedFreq) => {
|
|
2858
2858
|
const a = Math.exp(-undampedFreq * duration);
|
|
@@ -8377,7 +8377,7 @@ const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, tr
|
|
|
8377
8377
|
// Reapply original values
|
|
8378
8378
|
visualElement.render();
|
|
8379
8379
|
// Restore scroll position
|
|
8380
|
-
if (isBrowser$
|
|
8380
|
+
if (isBrowser$b && scrollY !== null) {
|
|
8381
8381
|
window.scrollTo({ top: scrollY });
|
|
8382
8382
|
}
|
|
8383
8383
|
return { target: convertedTarget, transitionEnd };
|
|
@@ -8416,7 +8416,7 @@ const hasReducedMotionListener = { current: false };
|
|
|
8416
8416
|
|
|
8417
8417
|
function initPrefersReducedMotion() {
|
|
8418
8418
|
hasReducedMotionListener.current = true;
|
|
8419
|
-
if (!isBrowser$
|
|
8419
|
+
if (!isBrowser$b)
|
|
8420
8420
|
return;
|
|
8421
8421
|
if (window.matchMedia) {
|
|
8422
8422
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
@@ -9102,7 +9102,7 @@ const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomM
|
|
|
9102
9102
|
|
|
9103
9103
|
function useIsMounted() {
|
|
9104
9104
|
const isMounted = React$3.useRef(false);
|
|
9105
|
-
useIsomorphicLayoutEffect$
|
|
9105
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
9106
9106
|
isMounted.current = true;
|
|
9107
9107
|
return () => {
|
|
9108
9108
|
isMounted.current = false;
|
|
@@ -9312,7 +9312,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
9312
9312
|
// If this is the initial component render, just deal with logic surrounding whether
|
|
9313
9313
|
// we play onMount animations or not.
|
|
9314
9314
|
const isInitialRender = React$3.useRef(true);
|
|
9315
|
-
useIsomorphicLayoutEffect$
|
|
9315
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
9316
9316
|
isInitialRender.current = false;
|
|
9317
9317
|
updateChildLookup(filteredChildren, allChildren);
|
|
9318
9318
|
presentChildren.current = childrenToRender;
|
|
@@ -13910,8 +13910,8 @@ function bindGlobalEventListeners() {
|
|
|
13910
13910
|
window.addEventListener('blur', onWindowBlur);
|
|
13911
13911
|
}
|
|
13912
13912
|
|
|
13913
|
-
var isBrowser$
|
|
13914
|
-
var isIE11 = isBrowser$
|
|
13913
|
+
var isBrowser$a = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
13914
|
+
var isIE11 = isBrowser$a ? // @ts-ignore
|
|
13915
13915
|
!!window.msCrypto : false;
|
|
13916
13916
|
|
|
13917
13917
|
var pluginProps = {
|
|
@@ -15361,7 +15361,7 @@ function _objectWithoutPropertiesLoose$4(source, excluded) {
|
|
|
15361
15361
|
return target;
|
|
15362
15362
|
}
|
|
15363
15363
|
|
|
15364
|
-
var isBrowser$
|
|
15364
|
+
var isBrowser$9 = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
15365
15365
|
function preserveRef(ref, node) {
|
|
15366
15366
|
if (ref) {
|
|
15367
15367
|
if (typeof ref === 'function') {
|
|
@@ -15374,7 +15374,7 @@ function preserveRef(ref, node) {
|
|
|
15374
15374
|
}
|
|
15375
15375
|
}
|
|
15376
15376
|
function ssrSafeCreateDiv() {
|
|
15377
|
-
return isBrowser$
|
|
15377
|
+
return isBrowser$9 && document.createElement('div');
|
|
15378
15378
|
}
|
|
15379
15379
|
function toDataAttributes(attrs) {
|
|
15380
15380
|
var dataAttrs = {
|
|
@@ -15437,7 +15437,7 @@ function deepPreserveProps(instanceProps, componentProps) {
|
|
|
15437
15437
|
});
|
|
15438
15438
|
}
|
|
15439
15439
|
|
|
15440
|
-
var useIsomorphicLayoutEffect$
|
|
15440
|
+
var useIsomorphicLayoutEffect$2 = isBrowser$9 ? React$3.useLayoutEffect : React$3.useEffect;
|
|
15441
15441
|
function useMutableBox(initialValue) {
|
|
15442
15442
|
// Using refs instead of state as it's recommended to not store imperative
|
|
15443
15443
|
// values in state due to memory problems in React(?)
|
|
@@ -15576,7 +15576,7 @@ function TippyGenerator(tippy) {
|
|
|
15576
15576
|
|
|
15577
15577
|
var deps = [reference].concat(children ? [children.type] : []); // CREATE
|
|
15578
15578
|
|
|
15579
|
-
useIsomorphicLayoutEffect$
|
|
15579
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15580
15580
|
var element = reference;
|
|
15581
15581
|
|
|
15582
15582
|
if (reference && reference.hasOwnProperty('current')) {
|
|
@@ -15611,7 +15611,7 @@ function TippyGenerator(tippy) {
|
|
|
15611
15611
|
};
|
|
15612
15612
|
}, deps); // UPDATE
|
|
15613
15613
|
|
|
15614
|
-
useIsomorphicLayoutEffect$
|
|
15614
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15615
15615
|
var _instance$popperInsta;
|
|
15616
15616
|
|
|
15617
15617
|
// Prevent this effect from running on 1st render
|
|
@@ -15647,7 +15647,7 @@ function TippyGenerator(tippy) {
|
|
|
15647
15647
|
});
|
|
15648
15648
|
}
|
|
15649
15649
|
});
|
|
15650
|
-
useIsomorphicLayoutEffect$
|
|
15650
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15651
15651
|
var _instance$props$poppe;
|
|
15652
15652
|
|
|
15653
15653
|
if (!render) {
|
|
@@ -15923,7 +15923,7 @@ var Button = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, r
|
|
|
15923
15923
|
});
|
|
15924
15924
|
Button.displayName = "Button";
|
|
15925
15925
|
|
|
15926
|
-
var Divider$
|
|
15926
|
+
var Divider$2 = function Divider(props) {
|
|
15927
15927
|
return /*#__PURE__*/React__default["default"].createElement("li", _extends$4({
|
|
15928
15928
|
className: "neeto-ui-dropdown__popup-divider"
|
|
15929
15929
|
}, props));
|
|
@@ -16196,7 +16196,7 @@ var Dropdown = function Dropdown(_ref2) {
|
|
|
16196
16196
|
};
|
|
16197
16197
|
Dropdown.Menu = Menu$3;
|
|
16198
16198
|
Dropdown.MenuItem = MenuItem$1;
|
|
16199
|
-
Dropdown.Divider = Divider$
|
|
16199
|
+
Dropdown.Divider = Divider$2;
|
|
16200
16200
|
|
|
16201
16201
|
var _excluded$D = ["style", "size"];
|
|
16202
16202
|
var BTN_STYLES = {
|
|
@@ -22867,7 +22867,7 @@ var customParseFormat$1 = {exports: {}};
|
|
|
22867
22867
|
|
|
22868
22868
|
var customParseFormat = customParseFormat$1.exports;
|
|
22869
22869
|
|
|
22870
|
-
var __spreadArray$
|
|
22870
|
+
var __spreadArray$3 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
22871
22871
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
22872
22872
|
if (ar || !(i in from)) {
|
|
22873
22873
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -22958,7 +22958,7 @@ var animationEvents = [
|
|
|
22958
22958
|
var transitionEvents = ['onTransitionEnd'];
|
|
22959
22959
|
var otherEvents = ['onToggle'];
|
|
22960
22960
|
var changeEvents = ['onChange'];
|
|
22961
|
-
var allEvents = __spreadArray$
|
|
22961
|
+
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);
|
|
22962
22962
|
/**
|
|
22963
22963
|
* Returns an object with on-event callback props curried with provided args.
|
|
22964
22964
|
* @param {Object} props Props passed to a component.
|
|
@@ -22984,8 +22984,6 @@ function makeEventProps(props, getArgs) {
|
|
|
22984
22984
|
return eventProps;
|
|
22985
22985
|
}
|
|
22986
22986
|
|
|
22987
|
-
function r$3(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$3(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx$2(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r$3(e))&&(n&&(n+=" "),n+=t);return n}
|
|
22988
|
-
|
|
22989
22987
|
function r$2(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$2(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx$1(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r$2(e))&&(n&&(n+=" "),n+=t);return n}
|
|
22990
22988
|
|
|
22991
22989
|
/**
|
|
@@ -23142,8 +23140,8 @@ function Mark(_a) {
|
|
|
23142
23140
|
} }, number)) : null));
|
|
23143
23141
|
}
|
|
23144
23142
|
|
|
23145
|
-
var __assign$
|
|
23146
|
-
__assign$
|
|
23143
|
+
var __assign$e = (undefined && undefined.__assign) || function () {
|
|
23144
|
+
__assign$e = Object.assign || function(t) {
|
|
23147
23145
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23148
23146
|
s = arguments[i];
|
|
23149
23147
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -23151,10 +23149,10 @@ var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
|
23151
23149
|
}
|
|
23152
23150
|
return t;
|
|
23153
23151
|
};
|
|
23154
|
-
return __assign$
|
|
23152
|
+
return __assign$e.apply(this, arguments);
|
|
23155
23153
|
};
|
|
23156
23154
|
var MinuteMark = React$3.memo(function MinuteMark(props) {
|
|
23157
|
-
return React__default["default"].createElement(Mark, __assign$
|
|
23155
|
+
return React__default["default"].createElement(Mark, __assign$e({}, props));
|
|
23158
23156
|
});
|
|
23159
23157
|
|
|
23160
23158
|
/**
|
|
@@ -23902,8 +23900,8 @@ function formatHour(locale, hour) {
|
|
|
23902
23900
|
return hour.toLocaleString(locale || getUserLocale() || undefined);
|
|
23903
23901
|
}
|
|
23904
23902
|
|
|
23905
|
-
var __assign$
|
|
23906
|
-
__assign$
|
|
23903
|
+
var __assign$d = (undefined && undefined.__assign) || function () {
|
|
23904
|
+
__assign$d = Object.assign || function(t) {
|
|
23907
23905
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23908
23906
|
s = arguments[i];
|
|
23909
23907
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -23911,9 +23909,9 @@ var __assign$7 = (undefined && undefined.__assign) || function () {
|
|
|
23911
23909
|
}
|
|
23912
23910
|
return t;
|
|
23913
23911
|
};
|
|
23914
|
-
return __assign$
|
|
23912
|
+
return __assign$d.apply(this, arguments);
|
|
23915
23913
|
};
|
|
23916
|
-
var __rest$
|
|
23914
|
+
var __rest$b = (undefined && undefined.__rest) || function (s, e) {
|
|
23917
23915
|
var t = {};
|
|
23918
23916
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23919
23917
|
t[p] = s[p];
|
|
@@ -23925,8 +23923,8 @@ var __rest$6 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
23925
23923
|
return t;
|
|
23926
23924
|
};
|
|
23927
23925
|
var HourMark = React$3.memo(function HourMark(_a) {
|
|
23928
|
-
var _b = _a.formatHour, formatHour$1 = _b === void 0 ? formatHour : _b, locale = _a.locale, number = _a.number, otherProps = __rest$
|
|
23929
|
-
return React__default["default"].createElement(Mark, __assign$
|
|
23926
|
+
var _b = _a.formatHour, formatHour$1 = _b === void 0 ? formatHour : _b, locale = _a.locale, number = _a.number, otherProps = __rest$b(_a, ["formatHour", "locale", "number"]);
|
|
23927
|
+
return React__default["default"].createElement(Mark, __assign$d({ number: number ? formatHour$1(locale, number) : null }, otherProps));
|
|
23930
23928
|
});
|
|
23931
23929
|
|
|
23932
23930
|
function isNumberBetween(min, max) {
|
|
@@ -24106,8 +24104,8 @@ var __extends = (undefined && undefined.__extends) || (function () {
|
|
|
24106
24104
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
24107
24105
|
};
|
|
24108
24106
|
})();
|
|
24109
|
-
var __assign$
|
|
24110
|
-
__assign$
|
|
24107
|
+
var __assign$c = (undefined && undefined.__assign) || function () {
|
|
24108
|
+
__assign$c = Object.assign || function(t) {
|
|
24111
24109
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24112
24110
|
s = arguments[i];
|
|
24113
24111
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24115,9 +24113,9 @@ var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
|
24115
24113
|
}
|
|
24116
24114
|
return t;
|
|
24117
24115
|
};
|
|
24118
|
-
return __assign$
|
|
24116
|
+
return __assign$c.apply(this, arguments);
|
|
24119
24117
|
};
|
|
24120
|
-
var __rest$
|
|
24118
|
+
var __rest$a = (undefined && undefined.__rest) || function (s, e) {
|
|
24121
24119
|
var t = {};
|
|
24122
24120
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24123
24121
|
t[p] = s[p];
|
|
@@ -24128,9 +24126,9 @@ var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24128
24126
|
}
|
|
24129
24127
|
return t;
|
|
24130
24128
|
};
|
|
24131
|
-
var isBrowser$
|
|
24132
|
-
var isDisplayContentsSupported = isBrowser$
|
|
24133
|
-
var isMutationObserverSupported = isBrowser$
|
|
24129
|
+
var isBrowser$8 = typeof document !== 'undefined';
|
|
24130
|
+
var isDisplayContentsSupported = isBrowser$8 && 'CSS' in window && 'supports' in window.CSS && CSS.supports('display', 'contents');
|
|
24131
|
+
var isMutationObserverSupported = isBrowser$8 && 'MutationObserver' in window;
|
|
24134
24132
|
function capitalize(string) {
|
|
24135
24133
|
return (string.charAt(0).toUpperCase() + string.slice(1));
|
|
24136
24134
|
}
|
|
@@ -24230,12 +24228,12 @@ function alignMainAxis(args) {
|
|
|
24230
24228
|
alignAxis(args);
|
|
24231
24229
|
}
|
|
24232
24230
|
function alignSecondaryAxis(args) {
|
|
24233
|
-
alignAxis(__assign$
|
|
24231
|
+
alignAxis(__assign$c(__assign$c({}, args), { axis: args.axis === 'x' ? 'y' : 'x', secondary: true }));
|
|
24234
24232
|
}
|
|
24235
24233
|
function alignBothAxis(args) {
|
|
24236
|
-
var invertAxis = args.invertAxis, invertSecondaryAxis = args.invertSecondaryAxis, commonArgs = __rest$
|
|
24237
|
-
alignMainAxis(__assign$
|
|
24238
|
-
alignSecondaryAxis(__assign$
|
|
24234
|
+
var invertAxis = args.invertAxis, invertSecondaryAxis = args.invertSecondaryAxis, commonArgs = __rest$a(args, ["invertAxis", "invertSecondaryAxis"]);
|
|
24235
|
+
alignMainAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertAxis }));
|
|
24236
|
+
alignSecondaryAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertSecondaryAxis }));
|
|
24239
24237
|
}
|
|
24240
24238
|
var Fit = /** @class */ (function (_super) {
|
|
24241
24239
|
__extends(Fit, _super);
|
|
@@ -24350,7 +24348,7 @@ var Fit = /** @class */ (function (_super) {
|
|
|
24350
24348
|
return Fit;
|
|
24351
24349
|
}(React$3.Component));
|
|
24352
24350
|
|
|
24353
|
-
function Divider(_a) {
|
|
24351
|
+
function Divider$1(_a) {
|
|
24354
24352
|
var children = _a.children;
|
|
24355
24353
|
return React__default["default"].createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
|
|
24356
24354
|
}
|
|
@@ -24412,20 +24410,20 @@ function updateInputWidth(element) {
|
|
|
24412
24410
|
return width;
|
|
24413
24411
|
}
|
|
24414
24412
|
|
|
24415
|
-
var isBrowser$
|
|
24416
|
-
var useIsomorphicLayoutEffect = isBrowser$
|
|
24417
|
-
var isIEOrEdgeLegacy = isBrowser$
|
|
24418
|
-
var isFirefox = isBrowser$
|
|
24419
|
-
function onFocus(event) {
|
|
24413
|
+
var isBrowser$7 = typeof document !== 'undefined';
|
|
24414
|
+
var useIsomorphicLayoutEffect$1 = isBrowser$7 ? React$3.useLayoutEffect : React$3.useEffect;
|
|
24415
|
+
var isIEOrEdgeLegacy$1 = isBrowser$7 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
|
|
24416
|
+
var isFirefox$1 = isBrowser$7 && /Firefox/.test(navigator.userAgent);
|
|
24417
|
+
function onFocus$1(event) {
|
|
24420
24418
|
var target = event.target;
|
|
24421
|
-
if (isIEOrEdgeLegacy) {
|
|
24419
|
+
if (isIEOrEdgeLegacy$1) {
|
|
24422
24420
|
requestAnimationFrame(function () { return target.select(); });
|
|
24423
24421
|
}
|
|
24424
24422
|
else {
|
|
24425
24423
|
target.select();
|
|
24426
24424
|
}
|
|
24427
24425
|
}
|
|
24428
|
-
function updateInputWidthOnLoad(element) {
|
|
24426
|
+
function updateInputWidthOnLoad$1(element) {
|
|
24429
24427
|
if (document.readyState === 'complete') {
|
|
24430
24428
|
return;
|
|
24431
24429
|
}
|
|
@@ -24434,7 +24432,7 @@ function updateInputWidthOnLoad(element) {
|
|
|
24434
24432
|
}
|
|
24435
24433
|
window.addEventListener('load', onLoad);
|
|
24436
24434
|
}
|
|
24437
|
-
function updateInputWidthOnFontLoad(element) {
|
|
24435
|
+
function updateInputWidthOnFontLoad$1(element) {
|
|
24438
24436
|
if (!document.fonts) {
|
|
24439
24437
|
return;
|
|
24440
24438
|
}
|
|
@@ -24451,7 +24449,7 @@ function updateInputWidthOnFontLoad(element) {
|
|
|
24451
24449
|
}
|
|
24452
24450
|
document.fonts.addEventListener('loadingdone', onLoadingDone);
|
|
24453
24451
|
}
|
|
24454
|
-
function getSelectionString(input) {
|
|
24452
|
+
function getSelectionString$1(input) {
|
|
24455
24453
|
/**
|
|
24456
24454
|
* window.getSelection().toString() returns empty string in IE11 and Firefox,
|
|
24457
24455
|
* so alternatives come first.
|
|
@@ -24469,7 +24467,7 @@ function getSelectionString(input) {
|
|
|
24469
24467
|
}
|
|
24470
24468
|
return null;
|
|
24471
24469
|
}
|
|
24472
|
-
function makeOnKeyPress(maxLength) {
|
|
24470
|
+
function makeOnKeyPress$1(maxLength) {
|
|
24473
24471
|
if (maxLength === null) {
|
|
24474
24472
|
return undefined;
|
|
24475
24473
|
}
|
|
@@ -24478,28 +24476,28 @@ function makeOnKeyPress(maxLength) {
|
|
|
24478
24476
|
* exceed maxLength.
|
|
24479
24477
|
*/
|
|
24480
24478
|
return function onKeyPress(event) {
|
|
24481
|
-
if (isFirefox) {
|
|
24479
|
+
if (isFirefox$1) {
|
|
24482
24480
|
// See https://github.com/wojtekmaj/react-time-picker/issues/92
|
|
24483
24481
|
return;
|
|
24484
24482
|
}
|
|
24485
24483
|
var key = event.key, input = event.target;
|
|
24486
24484
|
var value = input.value;
|
|
24487
24485
|
var isNumberKey = key.length === 1 && /\d/.test(key);
|
|
24488
|
-
var selection = getSelectionString(input);
|
|
24486
|
+
var selection = getSelectionString$1(input);
|
|
24489
24487
|
if (!isNumberKey || !(selection || value.length < maxLength)) {
|
|
24490
24488
|
event.preventDefault();
|
|
24491
24489
|
}
|
|
24492
24490
|
};
|
|
24493
24491
|
}
|
|
24494
|
-
function Input$
|
|
24492
|
+
function Input$4(_a) {
|
|
24495
24493
|
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;
|
|
24496
|
-
useIsomorphicLayoutEffect(function () {
|
|
24494
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
24497
24495
|
if (!inputRef || !inputRef.current) {
|
|
24498
24496
|
return;
|
|
24499
24497
|
}
|
|
24500
24498
|
updateInputWidth(inputRef.current);
|
|
24501
|
-
updateInputWidthOnLoad(inputRef.current);
|
|
24502
|
-
updateInputWidthOnFontLoad(inputRef.current);
|
|
24499
|
+
updateInputWidthOnLoad$1(inputRef.current);
|
|
24500
|
+
updateInputWidthOnFontLoad$1(inputRef.current);
|
|
24503
24501
|
}, [inputRef, value]);
|
|
24504
24502
|
var hasLeadingZero = showLeadingZeros &&
|
|
24505
24503
|
value &&
|
|
@@ -24508,7 +24506,7 @@ function Input$3(_a) {
|
|
|
24508
24506
|
var maxLength = max ? max.toString().length : null;
|
|
24509
24507
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
24510
24508
|
hasLeadingZero ? React__default["default"].createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
|
|
24511
|
-
React__default["default"].createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx$
|
|
24509
|
+
React__default["default"].createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx$1("".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) {
|
|
24512
24510
|
updateInputWidth(event.target);
|
|
24513
24511
|
if (onKeyUp) {
|
|
24514
24512
|
onKeyUp(event);
|
|
@@ -24516,7 +24514,7 @@ function Input$3(_a) {
|
|
|
24516
24514
|
}, placeholder: placeholder, ref: inputRef, required: required, step: step, type: "number", value: value !== null ? value : '' })));
|
|
24517
24515
|
}
|
|
24518
24516
|
|
|
24519
|
-
function convert12to24(hour12, amPm) {
|
|
24517
|
+
function convert12to24$1(hour12, amPm) {
|
|
24520
24518
|
var hour24 = Number(hour12);
|
|
24521
24519
|
if (amPm === 'am' && hour24 === 12) {
|
|
24522
24520
|
hour24 = 0;
|
|
@@ -24526,33 +24524,33 @@ function convert12to24(hour12, amPm) {
|
|
|
24526
24524
|
}
|
|
24527
24525
|
return hour24;
|
|
24528
24526
|
}
|
|
24529
|
-
function convert24to12(hour24) {
|
|
24527
|
+
function convert24to12$1(hour24) {
|
|
24530
24528
|
var hour12 = Number(hour24) % 12 || 12;
|
|
24531
24529
|
return [hour12, Number(hour24) < 12 ? 'am' : 'pm'];
|
|
24532
24530
|
}
|
|
24533
24531
|
|
|
24534
|
-
var formatterCache = new Map();
|
|
24535
|
-
function getFormatter(options) {
|
|
24532
|
+
var formatterCache$1 = new Map();
|
|
24533
|
+
function getFormatter$1(options) {
|
|
24536
24534
|
return function formatter(locale, date) {
|
|
24537
24535
|
var localeWithDefault = locale || getUserLocale();
|
|
24538
|
-
if (!formatterCache.has(localeWithDefault)) {
|
|
24539
|
-
formatterCache.set(localeWithDefault, new Map());
|
|
24536
|
+
if (!formatterCache$1.has(localeWithDefault)) {
|
|
24537
|
+
formatterCache$1.set(localeWithDefault, new Map());
|
|
24540
24538
|
}
|
|
24541
|
-
var formatterCacheLocale = formatterCache.get(localeWithDefault);
|
|
24539
|
+
var formatterCacheLocale = formatterCache$1.get(localeWithDefault);
|
|
24542
24540
|
if (!formatterCacheLocale.has(options)) {
|
|
24543
24541
|
formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault || undefined, options).format);
|
|
24544
24542
|
}
|
|
24545
24543
|
return formatterCacheLocale.get(options)(date);
|
|
24546
24544
|
};
|
|
24547
24545
|
}
|
|
24548
|
-
var numberFormatterCache = new Map();
|
|
24549
|
-
function getNumberFormatter(options) {
|
|
24546
|
+
var numberFormatterCache$1 = new Map();
|
|
24547
|
+
function getNumberFormatter$1(options) {
|
|
24550
24548
|
return function (locale, number) {
|
|
24551
24549
|
var localeWithDefault = locale || getUserLocale();
|
|
24552
|
-
if (!numberFormatterCache.has(localeWithDefault)) {
|
|
24553
|
-
numberFormatterCache.set(localeWithDefault, new Map());
|
|
24550
|
+
if (!numberFormatterCache$1.has(localeWithDefault)) {
|
|
24551
|
+
numberFormatterCache$1.set(localeWithDefault, new Map());
|
|
24554
24552
|
}
|
|
24555
|
-
var numberFormatterCacheLocale = numberFormatterCache.get(localeWithDefault);
|
|
24553
|
+
var numberFormatterCacheLocale = numberFormatterCache$1.get(localeWithDefault);
|
|
24556
24554
|
if (!numberFormatterCacheLocale.has(options)) {
|
|
24557
24555
|
numberFormatterCacheLocale.set(options, new Intl.NumberFormat(localeWithDefault || undefined, options).format);
|
|
24558
24556
|
}
|
|
@@ -24560,14 +24558,14 @@ function getNumberFormatter(options) {
|
|
|
24560
24558
|
};
|
|
24561
24559
|
}
|
|
24562
24560
|
|
|
24563
|
-
var nines = ['9', '٩'];
|
|
24564
|
-
var ninesRegExp = new RegExp("[".concat(nines.join(''), "]"));
|
|
24565
|
-
var amPmFormatter = getFormatter({ hour: 'numeric' });
|
|
24566
|
-
function getAmPmLabels(locale) {
|
|
24567
|
-
var amString = amPmFormatter(locale, new Date(2017, 0, 1, 9));
|
|
24568
|
-
var pmString = amPmFormatter(locale, new Date(2017, 0, 1, 21));
|
|
24569
|
-
var _a = amString.split(ninesRegExp), am1 = _a[0], am2 = _a[1];
|
|
24570
|
-
var _b = pmString.split(ninesRegExp), pm1 = _b[0], pm2 = _b[1];
|
|
24561
|
+
var nines$1 = ['9', '٩'];
|
|
24562
|
+
var ninesRegExp$1 = new RegExp("[".concat(nines$1.join(''), "]"));
|
|
24563
|
+
var amPmFormatter$1 = getFormatter$1({ hour: 'numeric' });
|
|
24564
|
+
function getAmPmLabels$1(locale) {
|
|
24565
|
+
var amString = amPmFormatter$1(locale, new Date(2017, 0, 1, 9));
|
|
24566
|
+
var pmString = amPmFormatter$1(locale, new Date(2017, 0, 1, 21));
|
|
24567
|
+
var _a = amString.split(ninesRegExp$1), am1 = _a[0], am2 = _a[1];
|
|
24568
|
+
var _b = pmString.split(ninesRegExp$1), pm1 = _b[0], pm2 = _b[1];
|
|
24571
24569
|
if (pm2 !== undefined) {
|
|
24572
24570
|
// If pm2 is undefined, nine was not found in pmString - this locale is not using 12-hour time
|
|
24573
24571
|
if (am1 !== pm1) {
|
|
@@ -24580,26 +24578,26 @@ function getAmPmLabels(locale) {
|
|
|
24580
24578
|
// Fallback
|
|
24581
24579
|
return ['AM', 'PM'];
|
|
24582
24580
|
}
|
|
24583
|
-
function isValidNumber(num) {
|
|
24581
|
+
function isValidNumber$1(num) {
|
|
24584
24582
|
return num !== null && num !== false && !Number.isNaN(Number(num));
|
|
24585
24583
|
}
|
|
24586
|
-
function safeMin() {
|
|
24584
|
+
function safeMin$1() {
|
|
24587
24585
|
var args = [];
|
|
24588
24586
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24589
24587
|
args[_i] = arguments[_i];
|
|
24590
24588
|
}
|
|
24591
|
-
return Math.min.apply(Math, args.filter(isValidNumber));
|
|
24589
|
+
return Math.min.apply(Math, args.filter(isValidNumber$1));
|
|
24592
24590
|
}
|
|
24593
|
-
function safeMax() {
|
|
24591
|
+
function safeMax$1() {
|
|
24594
24592
|
var args = [];
|
|
24595
24593
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24596
24594
|
args[_i] = arguments[_i];
|
|
24597
24595
|
}
|
|
24598
|
-
return Math.max.apply(Math, args.filter(isValidNumber));
|
|
24596
|
+
return Math.max.apply(Math, args.filter(isValidNumber$1));
|
|
24599
24597
|
}
|
|
24600
24598
|
|
|
24601
|
-
var __assign$
|
|
24602
|
-
__assign$
|
|
24599
|
+
var __assign$b = (undefined && undefined.__assign) || function () {
|
|
24600
|
+
__assign$b = Object.assign || function(t) {
|
|
24603
24601
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24604
24602
|
s = arguments[i];
|
|
24605
24603
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24607,9 +24605,9 @@ var __assign$5 = (undefined && undefined.__assign) || function () {
|
|
|
24607
24605
|
}
|
|
24608
24606
|
return t;
|
|
24609
24607
|
};
|
|
24610
|
-
return __assign$
|
|
24608
|
+
return __assign$b.apply(this, arguments);
|
|
24611
24609
|
};
|
|
24612
|
-
var __rest$
|
|
24610
|
+
var __rest$9 = (undefined && undefined.__rest) || function (s, e) {
|
|
24613
24611
|
var t = {};
|
|
24614
24612
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24615
24613
|
t[p] = s[p];
|
|
@@ -24620,20 +24618,20 @@ var __rest$4 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24620
24618
|
}
|
|
24621
24619
|
return t;
|
|
24622
24620
|
};
|
|
24623
|
-
function Hour12Input(_a) {
|
|
24624
|
-
var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$
|
|
24625
|
-
var maxHour = safeMin(12, maxTime &&
|
|
24621
|
+
function Hour12Input$1(_a) {
|
|
24622
|
+
var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$9(_a, ["amPm", "maxTime", "minTime", "value"]);
|
|
24623
|
+
var maxHour = safeMin$1(12, maxTime &&
|
|
24626
24624
|
(function () {
|
|
24627
|
-
var _a = convert24to12(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
|
|
24625
|
+
var _a = convert24to12$1(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
|
|
24628
24626
|
if (maxAmPm !== amPm) {
|
|
24629
24627
|
// pm is always after am, so we should ignore validation
|
|
24630
24628
|
return null;
|
|
24631
24629
|
}
|
|
24632
24630
|
return maxHourResult;
|
|
24633
24631
|
})());
|
|
24634
|
-
var minHour = safeMax(1, minTime &&
|
|
24632
|
+
var minHour = safeMax$1(1, minTime &&
|
|
24635
24633
|
(function () {
|
|
24636
|
-
var _a = convert24to12(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
|
|
24634
|
+
var _a = convert24to12$1(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
|
|
24637
24635
|
if (
|
|
24638
24636
|
// pm is always after am, so we should ignore validation
|
|
24639
24637
|
minAmPm !== amPm ||
|
|
@@ -24643,12 +24641,12 @@ function Hour12Input(_a) {
|
|
|
24643
24641
|
}
|
|
24644
24642
|
return minHourResult;
|
|
24645
24643
|
})());
|
|
24646
|
-
var value12 = value ? convert24to12(value)[0].toString() : '';
|
|
24647
|
-
return (React__default["default"].createElement(Input$
|
|
24644
|
+
var value12 = value ? convert24to12$1(value)[0].toString() : '';
|
|
24645
|
+
return (React__default["default"].createElement(Input$4, __assign$b({ max: maxHour, min: minHour, name: "hour12", nameForClass: "hour", value: value12 }, otherProps)));
|
|
24648
24646
|
}
|
|
24649
24647
|
|
|
24650
|
-
var __assign$
|
|
24651
|
-
__assign$
|
|
24648
|
+
var __assign$a = (undefined && undefined.__assign) || function () {
|
|
24649
|
+
__assign$a = Object.assign || function(t) {
|
|
24652
24650
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24653
24651
|
s = arguments[i];
|
|
24654
24652
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24656,9 +24654,9 @@ var __assign$4 = (undefined && undefined.__assign) || function () {
|
|
|
24656
24654
|
}
|
|
24657
24655
|
return t;
|
|
24658
24656
|
};
|
|
24659
|
-
return __assign$
|
|
24657
|
+
return __assign$a.apply(this, arguments);
|
|
24660
24658
|
};
|
|
24661
|
-
var __rest$
|
|
24659
|
+
var __rest$8 = (undefined && undefined.__rest) || function (s, e) {
|
|
24662
24660
|
var t = {};
|
|
24663
24661
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24664
24662
|
t[p] = s[p];
|
|
@@ -24669,15 +24667,15 @@ var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24669
24667
|
}
|
|
24670
24668
|
return t;
|
|
24671
24669
|
};
|
|
24672
|
-
function Hour24Input(_a) {
|
|
24673
|
-
var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$
|
|
24674
|
-
var maxHour = safeMin(23, maxTime && getHours(maxTime));
|
|
24675
|
-
var minHour = safeMax(0, minTime && getHours(minTime));
|
|
24676
|
-
return React__default["default"].createElement(Input$
|
|
24670
|
+
function Hour24Input$1(_a) {
|
|
24671
|
+
var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$8(_a, ["maxTime", "minTime"]);
|
|
24672
|
+
var maxHour = safeMin$1(23, maxTime && getHours(maxTime));
|
|
24673
|
+
var minHour = safeMax$1(0, minTime && getHours(minTime));
|
|
24674
|
+
return React__default["default"].createElement(Input$4, __assign$a({ max: maxHour, min: minHour, name: "hour24", nameForClass: "hour" }, otherProps));
|
|
24677
24675
|
}
|
|
24678
24676
|
|
|
24679
|
-
var __assign$
|
|
24680
|
-
__assign$
|
|
24677
|
+
var __assign$9 = (undefined && undefined.__assign) || function () {
|
|
24678
|
+
__assign$9 = Object.assign || function(t) {
|
|
24681
24679
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24682
24680
|
s = arguments[i];
|
|
24683
24681
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24685,9 +24683,9 @@ var __assign$3 = (undefined && undefined.__assign) || function () {
|
|
|
24685
24683
|
}
|
|
24686
24684
|
return t;
|
|
24687
24685
|
};
|
|
24688
|
-
return __assign$
|
|
24686
|
+
return __assign$9.apply(this, arguments);
|
|
24689
24687
|
};
|
|
24690
|
-
var __rest$
|
|
24688
|
+
var __rest$7 = (undefined && undefined.__rest) || function (s, e) {
|
|
24691
24689
|
var t = {};
|
|
24692
24690
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24693
24691
|
t[p] = s[p];
|
|
@@ -24698,18 +24696,18 @@ var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24698
24696
|
}
|
|
24699
24697
|
return t;
|
|
24700
24698
|
};
|
|
24701
|
-
function MinuteInput(_a) {
|
|
24702
|
-
var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$
|
|
24699
|
+
function MinuteInput$1(_a) {
|
|
24700
|
+
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"]);
|
|
24703
24701
|
function isSameHour(date) {
|
|
24704
24702
|
return hour === getHours(date).toString();
|
|
24705
24703
|
}
|
|
24706
|
-
var maxMinute = safeMin(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
|
|
24707
|
-
var minMinute = safeMax(0, minTime && isSameHour(minTime) && getMinutes(minTime));
|
|
24708
|
-
return (React__default["default"].createElement(Input$
|
|
24704
|
+
var maxMinute = safeMin$1(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
|
|
24705
|
+
var minMinute = safeMax$1(0, minTime && isSameHour(minTime) && getMinutes(minTime));
|
|
24706
|
+
return (React__default["default"].createElement(Input$4, __assign$9({ max: maxMinute, min: minMinute, name: "minute", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
24709
24707
|
}
|
|
24710
24708
|
|
|
24711
|
-
var __assign$
|
|
24712
|
-
__assign$
|
|
24709
|
+
var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
24710
|
+
__assign$8 = Object.assign || function(t) {
|
|
24713
24711
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24714
24712
|
s = arguments[i];
|
|
24715
24713
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24717,9 +24715,9 @@ var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
|
24717
24715
|
}
|
|
24718
24716
|
return t;
|
|
24719
24717
|
};
|
|
24720
|
-
return __assign$
|
|
24718
|
+
return __assign$8.apply(this, arguments);
|
|
24721
24719
|
};
|
|
24722
|
-
var __rest$
|
|
24720
|
+
var __rest$6 = (undefined && undefined.__rest) || function (s, e) {
|
|
24723
24721
|
var t = {};
|
|
24724
24722
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24725
24723
|
t[p] = s[p];
|
|
@@ -24730,17 +24728,17 @@ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24730
24728
|
}
|
|
24731
24729
|
return t;
|
|
24732
24730
|
};
|
|
24733
|
-
function SecondInput(_a) {
|
|
24734
|
-
var hour = _a.hour, maxTime = _a.maxTime, minTime = _a.minTime, minute = _a.minute, _b = _a.showLeadingZeros, showLeadingZeros = _b === void 0 ? true : _b, otherProps = __rest$
|
|
24731
|
+
function SecondInput$1(_a) {
|
|
24732
|
+
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"]);
|
|
24735
24733
|
function isSameMinute(date) {
|
|
24736
24734
|
return hour === getHours(date).toString() && minute === getMinutes(date).toString();
|
|
24737
24735
|
}
|
|
24738
|
-
var maxSecond = safeMin(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
|
|
24739
|
-
var minSecond = safeMax(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
|
|
24740
|
-
return (React__default["default"].createElement(Input$
|
|
24736
|
+
var maxSecond = safeMin$1(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
|
|
24737
|
+
var minSecond = safeMax$1(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
|
|
24738
|
+
return (React__default["default"].createElement(Input$4, __assign$8({ max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
24741
24739
|
}
|
|
24742
24740
|
|
|
24743
|
-
function NativeInput(_a) {
|
|
24741
|
+
function NativeInput$1(_a) {
|
|
24744
24742
|
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;
|
|
24745
24743
|
var nativeValueParser = (function () {
|
|
24746
24744
|
switch (valueType) {
|
|
@@ -24776,20 +24774,20 @@ function NativeInput(_a) {
|
|
|
24776
24774
|
}, type: "time", value: value ? nativeValueParser(value) : '' }));
|
|
24777
24775
|
}
|
|
24778
24776
|
|
|
24779
|
-
function AmPm(_a) {
|
|
24777
|
+
function AmPm$1(_a) {
|
|
24780
24778
|
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;
|
|
24781
|
-
var amDisabled = minTime ? convert24to12(getHours(minTime))[1] === 'pm' : false;
|
|
24782
|
-
var pmDisabled = maxTime ? convert24to12(getHours(maxTime))[1] === 'am' : false;
|
|
24779
|
+
var amDisabled = minTime ? convert24to12$1(getHours(minTime))[1] === 'pm' : false;
|
|
24780
|
+
var pmDisabled = maxTime ? convert24to12$1(getHours(maxTime))[1] === 'am' : false;
|
|
24783
24781
|
var name = 'amPm';
|
|
24784
|
-
var _b = getAmPmLabels(locale), amLabel = _b[0], pmLabel = _b[1];
|
|
24785
|
-
return (React__default["default"].createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx$
|
|
24782
|
+
var _b = getAmPmLabels$1(locale), amLabel = _b[0], pmLabel = _b[1];
|
|
24783
|
+
return (React__default["default"].createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx$1("".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 : '' },
|
|
24786
24784
|
!value && React__default["default"].createElement("option", { value: "" }, "--"),
|
|
24787
24785
|
React__default["default"].createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
|
|
24788
24786
|
React__default["default"].createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
|
|
24789
24787
|
}
|
|
24790
24788
|
|
|
24791
|
-
var __assign$
|
|
24792
|
-
__assign$
|
|
24789
|
+
var __assign$7 = (undefined && undefined.__assign) || function () {
|
|
24790
|
+
__assign$7 = Object.assign || function(t) {
|
|
24793
24791
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24794
24792
|
s = arguments[i];
|
|
24795
24793
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24797,9 +24795,9 @@ var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
|
24797
24795
|
}
|
|
24798
24796
|
return t;
|
|
24799
24797
|
};
|
|
24800
|
-
return __assign$
|
|
24798
|
+
return __assign$7.apply(this, arguments);
|
|
24801
24799
|
};
|
|
24802
|
-
var __spreadArray$
|
|
24800
|
+
var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
24803
24801
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
24804
24802
|
if (ar || !(i in from)) {
|
|
24805
24803
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -24808,24 +24806,24 @@ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, fr
|
|
|
24808
24806
|
}
|
|
24809
24807
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24810
24808
|
};
|
|
24811
|
-
var getFormatterOptionsCache = {};
|
|
24812
|
-
var allViews$
|
|
24813
|
-
function isInternalInput(element) {
|
|
24809
|
+
var getFormatterOptionsCache$1 = {};
|
|
24810
|
+
var allViews$4 = ['hour', 'minute', 'second'];
|
|
24811
|
+
function isInternalInput$1(element) {
|
|
24814
24812
|
return element.dataset.input === 'true';
|
|
24815
24813
|
}
|
|
24816
|
-
function findInput(element, property) {
|
|
24814
|
+
function findInput$1(element, property) {
|
|
24817
24815
|
var nextElement = element;
|
|
24818
24816
|
do {
|
|
24819
24817
|
nextElement = nextElement[property];
|
|
24820
|
-
} while (nextElement && !isInternalInput(nextElement));
|
|
24818
|
+
} while (nextElement && !isInternalInput$1(nextElement));
|
|
24821
24819
|
return nextElement;
|
|
24822
24820
|
}
|
|
24823
|
-
function focus(element) {
|
|
24821
|
+
function focus$1(element) {
|
|
24824
24822
|
if (element) {
|
|
24825
24823
|
element.focus();
|
|
24826
24824
|
}
|
|
24827
24825
|
}
|
|
24828
|
-
function renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances) {
|
|
24826
|
+
function renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances) {
|
|
24829
24827
|
var usedFunctions = [];
|
|
24830
24828
|
var pattern = new RegExp(Object.keys(elementFunctions)
|
|
24831
24829
|
.map(function (el) { return "".concat(el, "+"); })
|
|
@@ -24834,8 +24832,8 @@ function renderCustomInputs(placeholder, elementFunctions, allowMultipleInstance
|
|
|
24834
24832
|
return placeholder.split(pattern).reduce(function (arr, element, index) {
|
|
24835
24833
|
var divider = element && (
|
|
24836
24834
|
// eslint-disable-next-line react/no-array-index-key
|
|
24837
|
-
React__default["default"].createElement(Divider, { key: "separator_".concat(index) }, element));
|
|
24838
|
-
var res = __spreadArray$
|
|
24835
|
+
React__default["default"].createElement(Divider$1, { key: "separator_".concat(index) }, element));
|
|
24836
|
+
var res = __spreadArray$2(__spreadArray$2([], arr, true), [divider], false);
|
|
24839
24837
|
var currentMatch = matches && matches[index];
|
|
24840
24838
|
if (currentMatch) {
|
|
24841
24839
|
var renderFunction = elementFunctions[currentMatch] ||
|
|
@@ -24856,8 +24854,8 @@ function renderCustomInputs(placeholder, elementFunctions, allowMultipleInstance
|
|
|
24856
24854
|
return res;
|
|
24857
24855
|
}, []);
|
|
24858
24856
|
}
|
|
24859
|
-
var formatNumber = getNumberFormatter({ useGrouping: false });
|
|
24860
|
-
function TimeInput(_a) {
|
|
24857
|
+
var formatNumber$1 = getNumberFormatter$1({ useGrouping: false });
|
|
24858
|
+
function TimeInput$1(_a) {
|
|
24861
24859
|
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;
|
|
24862
24860
|
var _e = React$3.useState(null), amPm = _e[0], setAmPm = _e[1];
|
|
24863
24861
|
var _f = React$3.useState(null), hour = _f[0], setHour = _f[1];
|
|
@@ -24877,7 +24875,7 @@ function TimeInput(_a) {
|
|
|
24877
24875
|
React$3.useEffect(function () {
|
|
24878
24876
|
var nextValue = valueProps;
|
|
24879
24877
|
if (nextValue) {
|
|
24880
|
-
setAmPm(convert24to12(getHours(nextValue))[1]);
|
|
24878
|
+
setAmPm(convert24to12$1(getHours(nextValue))[1]);
|
|
24881
24879
|
setHour(getHours(nextValue).toString());
|
|
24882
24880
|
setMinute(getMinutes(nextValue).toString());
|
|
24883
24881
|
setSecond(getSeconds(nextValue).toString());
|
|
@@ -24900,8 +24898,8 @@ function TimeInput(_a) {
|
|
|
24900
24898
|
]);
|
|
24901
24899
|
var valueType = maxDetail;
|
|
24902
24900
|
var formatTime = (function () {
|
|
24903
|
-
var level = allViews$
|
|
24904
|
-
var formatterOptions = getFormatterOptionsCache[level] ||
|
|
24901
|
+
var level = allViews$4.indexOf(maxDetail);
|
|
24902
|
+
var formatterOptions = getFormatterOptionsCache$1[level] ||
|
|
24905
24903
|
(function () {
|
|
24906
24904
|
var options = { hour: 'numeric' };
|
|
24907
24905
|
if (level >= 1) {
|
|
@@ -24910,10 +24908,10 @@ function TimeInput(_a) {
|
|
|
24910
24908
|
if (level >= 2) {
|
|
24911
24909
|
options.second = 'numeric';
|
|
24912
24910
|
}
|
|
24913
|
-
getFormatterOptionsCache[level] = options;
|
|
24911
|
+
getFormatterOptionsCache$1[level] = options;
|
|
24914
24912
|
return options;
|
|
24915
24913
|
})();
|
|
24916
|
-
return getFormatter(formatterOptions);
|
|
24914
|
+
return getFormatter$1(formatterOptions);
|
|
24917
24915
|
})();
|
|
24918
24916
|
/**
|
|
24919
24917
|
* Gets current value in a desired format.
|
|
@@ -24940,11 +24938,11 @@ function TimeInput(_a) {
|
|
|
24940
24938
|
var second = 14;
|
|
24941
24939
|
var date = new Date(2017, 0, 1, hour24, minute, second);
|
|
24942
24940
|
return formatTime(locale, date)
|
|
24943
|
-
.replace(formatNumber(locale, hour12), 'h')
|
|
24944
|
-
.replace(formatNumber(locale, hour24), 'H')
|
|
24945
|
-
.replace(formatNumber(locale, minute), 'mm')
|
|
24946
|
-
.replace(formatNumber(locale, second), 'ss')
|
|
24947
|
-
.replace(new RegExp(getAmPmLabels(locale).join('|')), 'a');
|
|
24941
|
+
.replace(formatNumber$1(locale, hour12), 'h')
|
|
24942
|
+
.replace(formatNumber$1(locale, hour24), 'H')
|
|
24943
|
+
.replace(formatNumber$1(locale, minute), 'mm')
|
|
24944
|
+
.replace(formatNumber$1(locale, second), 'ss')
|
|
24945
|
+
.replace(new RegExp(getAmPmLabels$1(locale).join('|')), 'a');
|
|
24948
24946
|
})();
|
|
24949
24947
|
var divider = (function () {
|
|
24950
24948
|
var dividers = placeholder.match(/[^0-9a-z]/i);
|
|
@@ -24954,7 +24952,7 @@ function TimeInput(_a) {
|
|
|
24954
24952
|
if (event.target === event.currentTarget) {
|
|
24955
24953
|
// Wrapper was directly clicked
|
|
24956
24954
|
var firstInput = event.target.children[1];
|
|
24957
|
-
focus(firstInput);
|
|
24955
|
+
focus$1(firstInput);
|
|
24958
24956
|
}
|
|
24959
24957
|
}
|
|
24960
24958
|
function onKeyDown(event) {
|
|
@@ -24966,8 +24964,8 @@ function TimeInput(_a) {
|
|
|
24966
24964
|
event.preventDefault();
|
|
24967
24965
|
var input = event.target;
|
|
24968
24966
|
var property = event.key === 'ArrowLeft' ? 'previousElementSibling' : 'nextElementSibling';
|
|
24969
|
-
var nextInput = findInput(input, property);
|
|
24970
|
-
focus(nextInput);
|
|
24967
|
+
var nextInput = findInput$1(input, property);
|
|
24968
|
+
focus$1(nextInput);
|
|
24971
24969
|
break;
|
|
24972
24970
|
}
|
|
24973
24971
|
}
|
|
@@ -24995,8 +24993,8 @@ function TimeInput(_a) {
|
|
|
24995
24993
|
*/
|
|
24996
24994
|
if (Number(value) * 10 > Number(max) || value.length >= max.length) {
|
|
24997
24995
|
var property = 'nextElementSibling';
|
|
24998
|
-
var nextInput = findInput(input, property);
|
|
24999
|
-
focus(nextInput);
|
|
24996
|
+
var nextInput = findInput$1(input, property);
|
|
24997
|
+
focus$1(nextInput);
|
|
25000
24998
|
}
|
|
25001
24999
|
}
|
|
25002
25000
|
/**
|
|
@@ -25036,7 +25034,7 @@ function TimeInput(_a) {
|
|
|
25036
25034
|
var isEveryValueValid = formElements.every(function (formElement) { return formElement.validity.valid; });
|
|
25037
25035
|
if (isEveryValueFilled && isEveryValueValid) {
|
|
25038
25036
|
var hour_1 = Number(values.hour24 ||
|
|
25039
|
-
(values.hour12 && values.amPm && convert12to24(values.hour12, values.amPm)) ||
|
|
25037
|
+
(values.hour12 && values.amPm && convert12to24$1(values.hour12, values.amPm)) ||
|
|
25040
25038
|
0);
|
|
25041
25039
|
var minute_1 = Number(values.minute || 0);
|
|
25042
25040
|
var second_1 = Number(values.second || 0);
|
|
@@ -25061,7 +25059,7 @@ function TimeInput(_a) {
|
|
|
25061
25059
|
setAmPm(value);
|
|
25062
25060
|
break;
|
|
25063
25061
|
case 'hour12':
|
|
25064
|
-
setHour(value ? convert12to24(value, amPm || 'am').toString() : '');
|
|
25062
|
+
setHour(value ? convert12to24$1(value, amPm || 'am').toString() : '');
|
|
25065
25063
|
break;
|
|
25066
25064
|
case 'hour24':
|
|
25067
25065
|
setHour(value);
|
|
@@ -25102,7 +25100,7 @@ function TimeInput(_a) {
|
|
|
25102
25100
|
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25103
25101
|
}
|
|
25104
25102
|
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25105
|
-
return (React__default["default"].createElement(Hour12Input, __assign$
|
|
25103
|
+
return (React__default["default"].createElement(Hour12Input$1, __assign$7({ key: "hour12" }, commonInputProps, { amPm: amPm, ariaLabel: hourAriaLabel,
|
|
25106
25104
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25107
25105
|
autoFocus: index === 0 && autoFocus, inputRef: hour12Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
25108
25106
|
}
|
|
@@ -25111,7 +25109,7 @@ function TimeInput(_a) {
|
|
|
25111
25109
|
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25112
25110
|
}
|
|
25113
25111
|
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25114
|
-
return (React__default["default"].createElement(Hour24Input, __assign$
|
|
25112
|
+
return (React__default["default"].createElement(Hour24Input$1, __assign$7({ key: "hour24" }, commonInputProps, { ariaLabel: hourAriaLabel,
|
|
25115
25113
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25116
25114
|
autoFocus: index === 0 && autoFocus, inputRef: hour24Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
25117
25115
|
}
|
|
@@ -25126,7 +25124,7 @@ function TimeInput(_a) {
|
|
|
25126
25124
|
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25127
25125
|
}
|
|
25128
25126
|
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25129
|
-
return (React__default["default"].createElement(MinuteInput, __assign$
|
|
25127
|
+
return (React__default["default"].createElement(MinuteInput$1, __assign$7({ key: "minute" }, commonInputProps, { ariaLabel: minuteAriaLabel,
|
|
25130
25128
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25131
25129
|
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: minuteInput, placeholder: minutePlaceholder, showLeadingZeros: showLeadingZeros, value: minute })));
|
|
25132
25130
|
}
|
|
@@ -25135,12 +25133,12 @@ function TimeInput(_a) {
|
|
|
25135
25133
|
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25136
25134
|
}
|
|
25137
25135
|
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : true;
|
|
25138
|
-
return (React__default["default"].createElement(SecondInput, __assign$
|
|
25136
|
+
return (React__default["default"].createElement(SecondInput$1, __assign$7({ key: "second" }, commonInputProps, { ariaLabel: secondAriaLabel,
|
|
25139
25137
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25140
25138
|
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: secondInput, minute: minute, placeholder: secondPlaceholder, showLeadingZeros: showLeadingZeros, value: second })));
|
|
25141
25139
|
}
|
|
25142
25140
|
function renderAmPm(currentMatch, index) {
|
|
25143
|
-
return (React__default["default"].createElement(AmPm, __assign$
|
|
25141
|
+
return (React__default["default"].createElement(AmPm$1, __assign$7({ key: "ampm" }, commonInputProps, { ariaLabel: amPmAriaLabel,
|
|
25144
25142
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25145
25143
|
autoFocus: index === 0 && autoFocus, inputRef: amPmInput, locale: locale, onChange: onChange, value: amPm })));
|
|
25146
25144
|
}
|
|
@@ -25153,10 +25151,10 @@ function TimeInput(_a) {
|
|
|
25153
25151
|
a: renderAmPm,
|
|
25154
25152
|
};
|
|
25155
25153
|
var allowMultipleInstances = typeof format !== 'undefined';
|
|
25156
|
-
return renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances);
|
|
25154
|
+
return renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances);
|
|
25157
25155
|
}
|
|
25158
25156
|
function renderNativeInput() {
|
|
25159
|
-
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 }));
|
|
25157
|
+
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 }));
|
|
25160
25158
|
}
|
|
25161
25159
|
return (
|
|
25162
25160
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
@@ -25165,41 +25163,23 @@ function TimeInput(_a) {
|
|
|
25165
25163
|
renderCustomInputsInternal()));
|
|
25166
25164
|
}
|
|
25167
25165
|
|
|
25168
|
-
var
|
|
25169
|
-
|
|
25170
|
-
if (ar || !(i in from)) {
|
|
25171
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
25172
|
-
ar[i] = from[i];
|
|
25173
|
-
}
|
|
25174
|
-
}
|
|
25175
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25176
|
-
};
|
|
25177
|
-
var allViews$1 = ['hour', 'minute', 'second'];
|
|
25178
|
-
var allValueTypes = __spreadArray([], allViews$1, true);
|
|
25179
|
-
var hourOptionalSecondsRegExp = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
|
|
25180
|
-
var isTime = function isTime(props, propName, componentName) {
|
|
25166
|
+
var hourOptionalSecondsRegExp$1 = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
|
|
25167
|
+
var isTime$1 = function isTime(props, propName, componentName) {
|
|
25181
25168
|
var _a = props, _b = propName, time = _a[_b];
|
|
25182
25169
|
if (time) {
|
|
25183
|
-
if (typeof time !== 'string' || !hourOptionalSecondsRegExp.test(time)) {
|
|
25170
|
+
if (typeof time !== 'string' || !hourOptionalSecondsRegExp$1.test(time)) {
|
|
25184
25171
|
return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof time, "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format."));
|
|
25185
25172
|
}
|
|
25186
25173
|
}
|
|
25187
25174
|
// Everything is fine
|
|
25188
25175
|
return null;
|
|
25189
25176
|
};
|
|
25190
|
-
|
|
25191
|
-
propTypes$1.exports.oneOfType([
|
|
25192
|
-
propTypes$1.exports.func,
|
|
25193
|
-
propTypes$1.exports.exact({
|
|
25194
|
-
current: propTypes$1.exports.any,
|
|
25195
|
-
}),
|
|
25196
|
-
]);
|
|
25197
|
-
var rangeOf = function (type) {
|
|
25177
|
+
var rangeOf$1 = function (type) {
|
|
25198
25178
|
return propTypes$1.exports.arrayOf(type);
|
|
25199
25179
|
};
|
|
25200
25180
|
|
|
25201
|
-
var __assign = (undefined && undefined.__assign) || function () {
|
|
25202
|
-
__assign = Object.assign || function(t) {
|
|
25181
|
+
var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
25182
|
+
__assign$6 = Object.assign || function(t) {
|
|
25203
25183
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25204
25184
|
s = arguments[i];
|
|
25205
25185
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -25207,9 +25187,9 @@ var __assign = (undefined && undefined.__assign) || function () {
|
|
|
25207
25187
|
}
|
|
25208
25188
|
return t;
|
|
25209
25189
|
};
|
|
25210
|
-
return __assign.apply(this, arguments);
|
|
25190
|
+
return __assign$6.apply(this, arguments);
|
|
25211
25191
|
};
|
|
25212
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
25192
|
+
var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
25213
25193
|
var t = {};
|
|
25214
25194
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25215
25195
|
t[p] = s[p];
|
|
@@ -25220,11 +25200,11 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
25220
25200
|
}
|
|
25221
25201
|
return t;
|
|
25222
25202
|
};
|
|
25223
|
-
var isBrowser$
|
|
25224
|
-
var baseClassName = 'react-
|
|
25225
|
-
var outsideActionEvents = ['mousedown', 'focusin', 'touchstart'];
|
|
25226
|
-
var allViews = ['hour', 'minute', 'second'];
|
|
25227
|
-
var iconProps = {
|
|
25203
|
+
var isBrowser$6 = typeof document !== 'undefined';
|
|
25204
|
+
var baseClassName$1 = 'react-timerange-picker';
|
|
25205
|
+
var outsideActionEvents$1 = ['mousedown', 'focusin', 'touchstart'];
|
|
25206
|
+
var allViews$3 = ['hour', 'minute', 'second'];
|
|
25207
|
+
var iconProps$1 = {
|
|
25228
25208
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
25229
25209
|
width: 19,
|
|
25230
25210
|
height: 19,
|
|
@@ -25232,15 +25212,15 @@ var iconProps = {
|
|
|
25232
25212
|
stroke: 'black',
|
|
25233
25213
|
strokeWidth: 2,
|
|
25234
25214
|
};
|
|
25235
|
-
var ClockIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clock-button__icon ").concat(baseClassName, "__button__icon"), fill: "none" }),
|
|
25215
|
+
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" }),
|
|
25236
25216
|
React__default["default"].createElement("circle", { cx: "9.5", cy: "9.5", r: "7.5" }),
|
|
25237
25217
|
React__default["default"].createElement("path", { d: "M9.5 4.5 v5 h4" })));
|
|
25238
|
-
var ClearIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clear-button__icon ").concat(baseClassName, "__button__icon") }),
|
|
25218
|
+
var ClearIcon$1 = (React__default["default"].createElement("svg", __assign$6({}, iconProps$1, { className: "".concat(baseClassName$1, "__clear-button__icon ").concat(baseClassName$1, "__button__icon") }),
|
|
25239
25219
|
React__default["default"].createElement("line", { x1: "4", x2: "15", y1: "4", y2: "15" }),
|
|
25240
25220
|
React__default["default"].createElement("line", { x1: "15", x2: "4", y1: "4", y2: "15" })));
|
|
25241
|
-
var
|
|
25242
|
-
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"],
|
|
25243
|
-
var
|
|
25221
|
+
var TimeRangePicker = function TimeRangePicker(props) {
|
|
25222
|
+
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"]);
|
|
25223
|
+
var _j = React$3.useState(isOpenProps), isOpen = _j[0], setIsOpen = _j[1];
|
|
25244
25224
|
var wrapper = React$3.useRef(null);
|
|
25245
25225
|
var clockWrapper = React$3.useRef(null);
|
|
25246
25226
|
React$3.useEffect(function () {
|
|
@@ -25287,6 +25267,14 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25287
25267
|
onChangeProps(value);
|
|
25288
25268
|
}
|
|
25289
25269
|
}
|
|
25270
|
+
function onChangeFrom(valueFrom, closeClock) {
|
|
25271
|
+
var _a = Array.isArray(value) ? value : [value], valueTo = _a[1];
|
|
25272
|
+
onChange([valueFrom, valueTo || null], closeClock);
|
|
25273
|
+
}
|
|
25274
|
+
function onChangeTo(valueTo, closeClock) {
|
|
25275
|
+
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
25276
|
+
onChange([valueFrom || null, valueTo], closeClock);
|
|
25277
|
+
}
|
|
25290
25278
|
function onFocus(event) {
|
|
25291
25279
|
if (onFocusProps) {
|
|
25292
25280
|
onFocusProps(event);
|
|
@@ -25326,7 +25314,7 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25326
25314
|
}, [clockWrapper, closeClock, wrapper]);
|
|
25327
25315
|
var handleOutsideActionListeners = React$3.useCallback(function (shouldListen) {
|
|
25328
25316
|
if (shouldListen === void 0) { shouldListen = isOpen; }
|
|
25329
|
-
outsideActionEvents.forEach(function (event) {
|
|
25317
|
+
outsideActionEvents$1.forEach(function (event) {
|
|
25330
25318
|
if (shouldListen) {
|
|
25331
25319
|
document.addEventListener(event, onOutsideAction);
|
|
25332
25320
|
}
|
|
@@ -25346,9 +25334,9 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25346
25334
|
return function () {
|
|
25347
25335
|
handleOutsideActionListeners(false);
|
|
25348
25336
|
};
|
|
25349
|
-
}, [handleOutsideActionListeners]);
|
|
25337
|
+
}, [handleOutsideActionListeners, isOpen]);
|
|
25350
25338
|
function renderInputs() {
|
|
25351
|
-
var
|
|
25339
|
+
var _a = Array.isArray(value) ? value : [value], valueFrom = _a[0], valueTo = _a[1];
|
|
25352
25340
|
var ariaLabelProps = {
|
|
25353
25341
|
amPmAriaLabel: amPmAriaLabel,
|
|
25354
25342
|
hourAriaLabel: hourAriaLabel,
|
|
@@ -25361,12 +25349,15 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25361
25349
|
minutePlaceholder: minutePlaceholder,
|
|
25362
25350
|
secondPlaceholder: secondPlaceholder,
|
|
25363
25351
|
};
|
|
25364
|
-
|
|
25365
|
-
|
|
25352
|
+
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 });
|
|
25353
|
+
return (React__default["default"].createElement("div", { className: "".concat(baseClassName$1, "__wrapper") },
|
|
25354
|
+
React__default["default"].createElement(TimeInput$1, __assign$6({}, commonProps, {
|
|
25366
25355
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25367
|
-
autoFocus: autoFocus,
|
|
25368
|
-
|
|
25369
|
-
|
|
25356
|
+
autoFocus: autoFocus, name: "".concat(name, "_from"), onChange: onChangeFrom, value: valueFrom })),
|
|
25357
|
+
React__default["default"].createElement("span", { className: "".concat(baseClassName$1, "__range-divider") }, rangeDivider),
|
|
25358
|
+
React__default["default"].createElement(TimeInput$1, __assign$6({}, commonProps, { name: "".concat(name, "_to"), onChange: onChangeTo, value: valueTo })),
|
|
25359
|
+
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)),
|
|
25360
|
+
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))));
|
|
25370
25361
|
}
|
|
25371
25362
|
function renderClock() {
|
|
25372
25363
|
if (isOpen === null || disableClock) {
|
|
@@ -25374,11 +25365,11 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25374
25365
|
}
|
|
25375
25366
|
var clockClassName = props.clockClassName; props.className; // Unused, here to exclude it from clockProps
|
|
25376
25367
|
props.onChange; // Unused, here to exclude it from clockProps
|
|
25377
|
-
var portalContainer = props.portalContainer, value = props.value, clockProps = __rest(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
|
|
25378
|
-
var className = "".concat(baseClassName, "__clock");
|
|
25379
|
-
var classNames = clsx$
|
|
25368
|
+
var portalContainer = props.portalContainer, value = props.value, clockProps = __rest$5(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
|
|
25369
|
+
var className = "".concat(baseClassName$1, "__clock");
|
|
25370
|
+
var classNames = clsx$1(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
|
|
25380
25371
|
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
25381
|
-
var clock = React__default["default"].createElement(Clock, __assign({ className: clockClassName, value: valueFrom }, clockProps));
|
|
25372
|
+
var clock = React__default["default"].createElement(Clock, __assign$6({ className: clockClassName, value: valueFrom }, clockProps));
|
|
25382
25373
|
return portalContainer ? (ReactDOM.createPortal(React__default["default"].createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default["default"].createElement(Fit, null,
|
|
25383
25374
|
React__default["default"].createElement("div", { ref: function (ref) {
|
|
25384
25375
|
if (ref && !isOpen) {
|
|
@@ -25387,13 +25378,13 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25387
25378
|
}, className: classNames }, clock)));
|
|
25388
25379
|
}
|
|
25389
25380
|
var eventProps = React$3.useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
|
|
25390
|
-
return (React__default["default"].createElement("div", __assign({ className: clsx$
|
|
25381
|
+
return (React__default["default"].createElement("div", __assign$6({ className: clsx$1(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 }),
|
|
25391
25382
|
renderInputs(),
|
|
25392
25383
|
renderClock()));
|
|
25393
25384
|
};
|
|
25394
|
-
var isValue = propTypes$1.exports.oneOfType([
|
|
25395
|
-
var isValueOrValueArray = propTypes$1.exports.oneOfType([isValue, rangeOf(isValue)]);
|
|
25396
|
-
|
|
25385
|
+
var isValue$1 = propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.instanceOf(Date)]);
|
|
25386
|
+
var isValueOrValueArray$1 = propTypes$1.exports.oneOfType([isValue$1, rangeOf$1(isValue$1)]);
|
|
25387
|
+
TimeRangePicker.propTypes = {
|
|
25397
25388
|
amPmAriaLabel: propTypes$1.exports.string,
|
|
25398
25389
|
autoFocus: propTypes$1.exports.bool,
|
|
25399
25390
|
className: propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.arrayOf(propTypes$1.exports.string)]),
|
|
@@ -25412,9 +25403,9 @@ TimePicker$1.propTypes = {
|
|
|
25412
25403
|
id: propTypes$1.exports.string,
|
|
25413
25404
|
isOpen: propTypes$1.exports.bool,
|
|
25414
25405
|
locale: propTypes$1.exports.string,
|
|
25415
|
-
maxDetail: propTypes$1.exports.oneOf(allViews),
|
|
25416
|
-
maxTime: isTime,
|
|
25417
|
-
minTime: isTime,
|
|
25406
|
+
maxDetail: propTypes$1.exports.oneOf(allViews$3),
|
|
25407
|
+
maxTime: isTime$1,
|
|
25408
|
+
minTime: isTime$1,
|
|
25418
25409
|
minuteAriaLabel: propTypes$1.exports.string,
|
|
25419
25410
|
minutePlaceholder: propTypes$1.exports.string,
|
|
25420
25411
|
name: propTypes$1.exports.string,
|
|
@@ -25424,82 +25415,1150 @@ TimePicker$1.propTypes = {
|
|
|
25424
25415
|
onClockOpen: propTypes$1.exports.func,
|
|
25425
25416
|
onFocus: propTypes$1.exports.func,
|
|
25426
25417
|
openClockOnFocus: propTypes$1.exports.bool,
|
|
25418
|
+
rangeDivider: propTypes$1.exports.node,
|
|
25427
25419
|
required: propTypes$1.exports.bool,
|
|
25428
25420
|
secondAriaLabel: propTypes$1.exports.string,
|
|
25429
25421
|
secondPlaceholder: propTypes$1.exports.string,
|
|
25430
|
-
value: isValueOrValueArray,
|
|
25422
|
+
value: isValueOrValueArray$1,
|
|
25431
25423
|
};
|
|
25432
|
-
if (isBrowser$
|
|
25433
|
-
|
|
25424
|
+
if (isBrowser$6) {
|
|
25425
|
+
TimeRangePicker.propTypes.portalContainer = propTypes$1.exports.instanceOf(HTMLElement);
|
|
25434
25426
|
}
|
|
25435
25427
|
|
|
25436
|
-
|
|
25437
|
-
|
|
25438
|
-
|
|
25439
|
-
|
|
25440
|
-
_useState2 = _slicedToArray$3(_useState, 2),
|
|
25441
|
-
hovered = _useState2[0],
|
|
25442
|
-
setHovered = _useState2[1];
|
|
25443
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
25444
|
-
onMouseLeave: function onMouseLeave() {
|
|
25445
|
-
return setHovered(false);
|
|
25446
|
-
},
|
|
25447
|
-
onMouseOver: function onMouseOver() {
|
|
25448
|
-
return setHovered(true);
|
|
25449
|
-
}
|
|
25450
|
-
}, hovered && time ? /*#__PURE__*/React__default["default"].createElement(neetoIcons.Close, {
|
|
25451
|
-
size: 16
|
|
25452
|
-
}) : /*#__PURE__*/React__default["default"].createElement(neetoIcons.Clock, {
|
|
25453
|
-
size: 16
|
|
25454
|
-
}));
|
|
25455
|
-
};
|
|
25428
|
+
function Divider(_a) {
|
|
25429
|
+
var children = _a.children;
|
|
25430
|
+
return React__default["default"].createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
|
|
25431
|
+
}
|
|
25456
25432
|
|
|
25457
|
-
var
|
|
25458
|
-
|
|
25459
|
-
|
|
25460
|
-
|
|
25461
|
-
|
|
25462
|
-
|
|
25463
|
-
|
|
25464
|
-
|
|
25465
|
-
}
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25433
|
+
var isBrowser$5 = typeof document !== 'undefined';
|
|
25434
|
+
var useIsomorphicLayoutEffect = isBrowser$5 ? React$3.useLayoutEffect : React$3.useEffect;
|
|
25435
|
+
var isIEOrEdgeLegacy = isBrowser$5 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
|
|
25436
|
+
var isFirefox = isBrowser$5 && /Firefox/.test(navigator.userAgent);
|
|
25437
|
+
function onFocus(event) {
|
|
25438
|
+
var target = event.target;
|
|
25439
|
+
if (isIEOrEdgeLegacy) {
|
|
25440
|
+
requestAnimationFrame(function () { return target.select(); });
|
|
25441
|
+
}
|
|
25442
|
+
else {
|
|
25443
|
+
target.select();
|
|
25444
|
+
}
|
|
25445
|
+
}
|
|
25446
|
+
function updateInputWidthOnLoad(element) {
|
|
25447
|
+
if (document.readyState === 'complete') {
|
|
25448
|
+
return;
|
|
25449
|
+
}
|
|
25450
|
+
function onLoad() {
|
|
25451
|
+
updateInputWidth(element);
|
|
25452
|
+
}
|
|
25453
|
+
window.addEventListener('load', onLoad);
|
|
25454
|
+
}
|
|
25455
|
+
function updateInputWidthOnFontLoad(element) {
|
|
25456
|
+
if (!document.fonts) {
|
|
25457
|
+
return;
|
|
25458
|
+
}
|
|
25459
|
+
var font = getFontShorthand(element);
|
|
25460
|
+
if (!font) {
|
|
25461
|
+
return;
|
|
25462
|
+
}
|
|
25463
|
+
var isFontLoaded = document.fonts.check(font);
|
|
25464
|
+
if (isFontLoaded) {
|
|
25465
|
+
return;
|
|
25466
|
+
}
|
|
25467
|
+
function onLoadingDone() {
|
|
25468
|
+
updateInputWidth(element);
|
|
25469
|
+
}
|
|
25470
|
+
document.fonts.addEventListener('loadingdone', onLoadingDone);
|
|
25471
|
+
}
|
|
25472
|
+
function getSelectionString(input) {
|
|
25473
|
+
/**
|
|
25474
|
+
* window.getSelection().toString() returns empty string in IE11 and Firefox,
|
|
25475
|
+
* so alternatives come first.
|
|
25476
|
+
*/
|
|
25477
|
+
if (input &&
|
|
25478
|
+
'selectionStart' in input &&
|
|
25479
|
+
input.selectionStart !== null &&
|
|
25480
|
+
'selectionEnd' in input &&
|
|
25481
|
+
input.selectionEnd !== null) {
|
|
25482
|
+
return input.value.slice(input.selectionStart, input.selectionEnd);
|
|
25483
|
+
}
|
|
25484
|
+
if ('getSelection' in window) {
|
|
25485
|
+
var selection = window.getSelection();
|
|
25486
|
+
return selection && selection.toString();
|
|
25487
|
+
}
|
|
25488
|
+
return null;
|
|
25489
|
+
}
|
|
25490
|
+
function makeOnKeyPress(maxLength) {
|
|
25491
|
+
if (maxLength === null) {
|
|
25492
|
+
return undefined;
|
|
25493
|
+
}
|
|
25494
|
+
/**
|
|
25495
|
+
* Prevents keystrokes that would not produce a number or when value after keystroke would
|
|
25496
|
+
* exceed maxLength.
|
|
25497
|
+
*/
|
|
25498
|
+
return function onKeyPress(event) {
|
|
25499
|
+
if (isFirefox) {
|
|
25500
|
+
// See https://github.com/wojtekmaj/react-time-picker/issues/92
|
|
25501
|
+
return;
|
|
25502
|
+
}
|
|
25503
|
+
var key = event.key, input = event.target;
|
|
25504
|
+
var value = input.value;
|
|
25505
|
+
var isNumberKey = key.length === 1 && /\d/.test(key);
|
|
25506
|
+
var selection = getSelectionString(input);
|
|
25507
|
+
if (!isNumberKey || !(selection || value.length < maxLength)) {
|
|
25508
|
+
event.preventDefault();
|
|
25509
|
+
}
|
|
25510
|
+
};
|
|
25511
|
+
}
|
|
25512
|
+
function Input$3(_a) {
|
|
25513
|
+
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;
|
|
25514
|
+
useIsomorphicLayoutEffect(function () {
|
|
25515
|
+
if (!inputRef || !inputRef.current) {
|
|
25516
|
+
return;
|
|
25517
|
+
}
|
|
25518
|
+
updateInputWidth(inputRef.current);
|
|
25519
|
+
updateInputWidthOnLoad(inputRef.current);
|
|
25520
|
+
updateInputWidthOnFontLoad(inputRef.current);
|
|
25521
|
+
}, [inputRef, value]);
|
|
25522
|
+
var hasLeadingZero = showLeadingZeros &&
|
|
25523
|
+
value &&
|
|
25524
|
+
Number(value) < 10 &&
|
|
25525
|
+
(value === '0' || !value.toString().startsWith('0'));
|
|
25526
|
+
var maxLength = max ? max.toString().length : null;
|
|
25527
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
25528
|
+
hasLeadingZero ? React__default["default"].createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
|
|
25529
|
+
React__default["default"].createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx$1("".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) {
|
|
25530
|
+
updateInputWidth(event.target);
|
|
25531
|
+
if (onKeyUp) {
|
|
25532
|
+
onKeyUp(event);
|
|
25533
|
+
}
|
|
25534
|
+
}, placeholder: placeholder, ref: inputRef, required: required, step: step, type: "number", value: value !== null ? value : '' })));
|
|
25535
|
+
}
|
|
25536
|
+
|
|
25537
|
+
function convert12to24(hour12, amPm) {
|
|
25538
|
+
var hour24 = Number(hour12);
|
|
25539
|
+
if (amPm === 'am' && hour24 === 12) {
|
|
25540
|
+
hour24 = 0;
|
|
25541
|
+
}
|
|
25542
|
+
else if (amPm === 'pm' && hour24 < 12) {
|
|
25543
|
+
hour24 += 12;
|
|
25544
|
+
}
|
|
25545
|
+
return hour24;
|
|
25546
|
+
}
|
|
25547
|
+
function convert24to12(hour24) {
|
|
25548
|
+
var hour12 = Number(hour24) % 12 || 12;
|
|
25549
|
+
return [hour12, Number(hour24) < 12 ? 'am' : 'pm'];
|
|
25550
|
+
}
|
|
25551
|
+
|
|
25552
|
+
var formatterCache = new Map();
|
|
25553
|
+
function getFormatter(options) {
|
|
25554
|
+
return function formatter(locale, date) {
|
|
25555
|
+
var localeWithDefault = locale || getUserLocale();
|
|
25556
|
+
if (!formatterCache.has(localeWithDefault)) {
|
|
25557
|
+
formatterCache.set(localeWithDefault, new Map());
|
|
25558
|
+
}
|
|
25559
|
+
var formatterCacheLocale = formatterCache.get(localeWithDefault);
|
|
25560
|
+
if (!formatterCacheLocale.has(options)) {
|
|
25561
|
+
formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault || undefined, options).format);
|
|
25562
|
+
}
|
|
25563
|
+
return formatterCacheLocale.get(options)(date);
|
|
25564
|
+
};
|
|
25565
|
+
}
|
|
25566
|
+
var numberFormatterCache = new Map();
|
|
25567
|
+
function getNumberFormatter(options) {
|
|
25568
|
+
return function (locale, number) {
|
|
25569
|
+
var localeWithDefault = locale || getUserLocale();
|
|
25570
|
+
if (!numberFormatterCache.has(localeWithDefault)) {
|
|
25571
|
+
numberFormatterCache.set(localeWithDefault, new Map());
|
|
25572
|
+
}
|
|
25573
|
+
var numberFormatterCacheLocale = numberFormatterCache.get(localeWithDefault);
|
|
25574
|
+
if (!numberFormatterCacheLocale.has(options)) {
|
|
25575
|
+
numberFormatterCacheLocale.set(options, new Intl.NumberFormat(localeWithDefault || undefined, options).format);
|
|
25576
|
+
}
|
|
25577
|
+
return numberFormatterCacheLocale.get(options)(number);
|
|
25578
|
+
};
|
|
25579
|
+
}
|
|
25580
|
+
|
|
25581
|
+
var nines = ['9', '٩'];
|
|
25582
|
+
var ninesRegExp = new RegExp("[".concat(nines.join(''), "]"));
|
|
25583
|
+
var amPmFormatter = getFormatter({ hour: 'numeric' });
|
|
25584
|
+
function getAmPmLabels(locale) {
|
|
25585
|
+
var amString = amPmFormatter(locale, new Date(2017, 0, 1, 9));
|
|
25586
|
+
var pmString = amPmFormatter(locale, new Date(2017, 0, 1, 21));
|
|
25587
|
+
var _a = amString.split(ninesRegExp), am1 = _a[0], am2 = _a[1];
|
|
25588
|
+
var _b = pmString.split(ninesRegExp), pm1 = _b[0], pm2 = _b[1];
|
|
25589
|
+
if (pm2 !== undefined) {
|
|
25590
|
+
// If pm2 is undefined, nine was not found in pmString - this locale is not using 12-hour time
|
|
25591
|
+
if (am1 !== pm1) {
|
|
25592
|
+
return [am1, pm1].map(function (el) { return el.trim(); });
|
|
25593
|
+
}
|
|
25594
|
+
if (am2 !== pm2) {
|
|
25595
|
+
return [am2, pm2].map(function (el) { return el.trim(); });
|
|
25596
|
+
}
|
|
25597
|
+
}
|
|
25598
|
+
// Fallback
|
|
25599
|
+
return ['AM', 'PM'];
|
|
25600
|
+
}
|
|
25601
|
+
function isValidNumber(num) {
|
|
25602
|
+
return num !== null && num !== false && !Number.isNaN(Number(num));
|
|
25603
|
+
}
|
|
25604
|
+
function safeMin() {
|
|
25605
|
+
var args = [];
|
|
25606
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25607
|
+
args[_i] = arguments[_i];
|
|
25608
|
+
}
|
|
25609
|
+
return Math.min.apply(Math, args.filter(isValidNumber));
|
|
25610
|
+
}
|
|
25611
|
+
function safeMax() {
|
|
25612
|
+
var args = [];
|
|
25613
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25614
|
+
args[_i] = arguments[_i];
|
|
25615
|
+
}
|
|
25616
|
+
return Math.max.apply(Math, args.filter(isValidNumber));
|
|
25617
|
+
}
|
|
25618
|
+
|
|
25619
|
+
var __assign$5 = (undefined && undefined.__assign) || function () {
|
|
25620
|
+
__assign$5 = Object.assign || function(t) {
|
|
25621
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25622
|
+
s = arguments[i];
|
|
25623
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25624
|
+
t[p] = s[p];
|
|
25625
|
+
}
|
|
25626
|
+
return t;
|
|
25627
|
+
};
|
|
25628
|
+
return __assign$5.apply(this, arguments);
|
|
25629
|
+
};
|
|
25630
|
+
var __rest$4 = (undefined && undefined.__rest) || function (s, e) {
|
|
25631
|
+
var t = {};
|
|
25632
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25633
|
+
t[p] = s[p];
|
|
25634
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25635
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25636
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25637
|
+
t[p[i]] = s[p[i]];
|
|
25638
|
+
}
|
|
25639
|
+
return t;
|
|
25640
|
+
};
|
|
25641
|
+
function Hour12Input(_a) {
|
|
25642
|
+
var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$4(_a, ["amPm", "maxTime", "minTime", "value"]);
|
|
25643
|
+
var maxHour = safeMin(12, maxTime &&
|
|
25644
|
+
(function () {
|
|
25645
|
+
var _a = convert24to12(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
|
|
25646
|
+
if (maxAmPm !== amPm) {
|
|
25647
|
+
// pm is always after am, so we should ignore validation
|
|
25648
|
+
return null;
|
|
25649
|
+
}
|
|
25650
|
+
return maxHourResult;
|
|
25651
|
+
})());
|
|
25652
|
+
var minHour = safeMax(1, minTime &&
|
|
25653
|
+
(function () {
|
|
25654
|
+
var _a = convert24to12(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
|
|
25655
|
+
if (
|
|
25656
|
+
// pm is always after am, so we should ignore validation
|
|
25657
|
+
minAmPm !== amPm ||
|
|
25658
|
+
// If minHour is 12 am/pm, user should be able to enter 12, 1, ..., 11.
|
|
25659
|
+
minHourResult === 12) {
|
|
25660
|
+
return null;
|
|
25661
|
+
}
|
|
25662
|
+
return minHourResult;
|
|
25663
|
+
})());
|
|
25664
|
+
var value12 = value ? convert24to12(value)[0].toString() : '';
|
|
25665
|
+
return (React__default["default"].createElement(Input$3, __assign$5({ max: maxHour, min: minHour, name: "hour12", nameForClass: "hour", value: value12 }, otherProps)));
|
|
25666
|
+
}
|
|
25667
|
+
|
|
25668
|
+
var __assign$4 = (undefined && undefined.__assign) || function () {
|
|
25669
|
+
__assign$4 = Object.assign || function(t) {
|
|
25670
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25671
|
+
s = arguments[i];
|
|
25672
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25673
|
+
t[p] = s[p];
|
|
25674
|
+
}
|
|
25675
|
+
return t;
|
|
25676
|
+
};
|
|
25677
|
+
return __assign$4.apply(this, arguments);
|
|
25678
|
+
};
|
|
25679
|
+
var __rest$3 = (undefined && undefined.__rest) || function (s, e) {
|
|
25680
|
+
var t = {};
|
|
25681
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25682
|
+
t[p] = s[p];
|
|
25683
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25684
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25685
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25686
|
+
t[p[i]] = s[p[i]];
|
|
25687
|
+
}
|
|
25688
|
+
return t;
|
|
25689
|
+
};
|
|
25690
|
+
function Hour24Input(_a) {
|
|
25691
|
+
var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$3(_a, ["maxTime", "minTime"]);
|
|
25692
|
+
var maxHour = safeMin(23, maxTime && getHours(maxTime));
|
|
25693
|
+
var minHour = safeMax(0, minTime && getHours(minTime));
|
|
25694
|
+
return React__default["default"].createElement(Input$3, __assign$4({ max: maxHour, min: minHour, name: "hour24", nameForClass: "hour" }, otherProps));
|
|
25695
|
+
}
|
|
25696
|
+
|
|
25697
|
+
var __assign$3 = (undefined && undefined.__assign) || function () {
|
|
25698
|
+
__assign$3 = Object.assign || function(t) {
|
|
25699
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25700
|
+
s = arguments[i];
|
|
25701
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25702
|
+
t[p] = s[p];
|
|
25703
|
+
}
|
|
25704
|
+
return t;
|
|
25705
|
+
};
|
|
25706
|
+
return __assign$3.apply(this, arguments);
|
|
25707
|
+
};
|
|
25708
|
+
var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
|
|
25709
|
+
var t = {};
|
|
25710
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25711
|
+
t[p] = s[p];
|
|
25712
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25713
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25714
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25715
|
+
t[p[i]] = s[p[i]];
|
|
25716
|
+
}
|
|
25717
|
+
return t;
|
|
25718
|
+
};
|
|
25719
|
+
function MinuteInput(_a) {
|
|
25720
|
+
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"]);
|
|
25721
|
+
function isSameHour(date) {
|
|
25722
|
+
return hour === getHours(date).toString();
|
|
25723
|
+
}
|
|
25724
|
+
var maxMinute = safeMin(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
|
|
25725
|
+
var minMinute = safeMax(0, minTime && isSameHour(minTime) && getMinutes(minTime));
|
|
25726
|
+
return (React__default["default"].createElement(Input$3, __assign$3({ max: maxMinute, min: minMinute, name: "minute", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
25727
|
+
}
|
|
25728
|
+
|
|
25729
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
25730
|
+
__assign$2 = Object.assign || function(t) {
|
|
25731
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25732
|
+
s = arguments[i];
|
|
25733
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25734
|
+
t[p] = s[p];
|
|
25735
|
+
}
|
|
25736
|
+
return t;
|
|
25737
|
+
};
|
|
25738
|
+
return __assign$2.apply(this, arguments);
|
|
25739
|
+
};
|
|
25740
|
+
var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
|
|
25741
|
+
var t = {};
|
|
25742
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25743
|
+
t[p] = s[p];
|
|
25744
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25745
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25746
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25747
|
+
t[p[i]] = s[p[i]];
|
|
25748
|
+
}
|
|
25749
|
+
return t;
|
|
25750
|
+
};
|
|
25751
|
+
function SecondInput(_a) {
|
|
25752
|
+
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"]);
|
|
25753
|
+
function isSameMinute(date) {
|
|
25754
|
+
return hour === getHours(date).toString() && minute === getMinutes(date).toString();
|
|
25755
|
+
}
|
|
25756
|
+
var maxSecond = safeMin(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
|
|
25757
|
+
var minSecond = safeMax(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
|
|
25758
|
+
return (React__default["default"].createElement(Input$3, __assign$2({ max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
25759
|
+
}
|
|
25760
|
+
|
|
25761
|
+
function NativeInput(_a) {
|
|
25762
|
+
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;
|
|
25763
|
+
var nativeValueParser = (function () {
|
|
25764
|
+
switch (valueType) {
|
|
25765
|
+
case 'hour':
|
|
25766
|
+
return function (receivedValue) { return "".concat(getHours(receivedValue), ":00"); };
|
|
25767
|
+
case 'minute':
|
|
25768
|
+
return getHoursMinutes;
|
|
25769
|
+
case 'second':
|
|
25770
|
+
return getHoursMinutesSeconds;
|
|
25771
|
+
default:
|
|
25772
|
+
throw new Error('Invalid valueType');
|
|
25773
|
+
}
|
|
25774
|
+
})();
|
|
25775
|
+
var step = (function () {
|
|
25776
|
+
switch (valueType) {
|
|
25777
|
+
case 'hour':
|
|
25778
|
+
return 3600;
|
|
25779
|
+
case 'minute':
|
|
25780
|
+
return 60;
|
|
25781
|
+
case 'second':
|
|
25782
|
+
return 1;
|
|
25783
|
+
default:
|
|
25784
|
+
throw new Error('Invalid valueType');
|
|
25785
|
+
}
|
|
25786
|
+
})();
|
|
25787
|
+
function stopPropagation(event) {
|
|
25788
|
+
event.stopPropagation();
|
|
25789
|
+
}
|
|
25790
|
+
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: {
|
|
25791
|
+
visibility: 'hidden',
|
|
25792
|
+
position: 'absolute',
|
|
25793
|
+
zIndex: '-999',
|
|
25794
|
+
}, type: "time", value: value ? nativeValueParser(value) : '' }));
|
|
25795
|
+
}
|
|
25796
|
+
|
|
25797
|
+
function AmPm(_a) {
|
|
25798
|
+
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;
|
|
25799
|
+
var amDisabled = minTime ? convert24to12(getHours(minTime))[1] === 'pm' : false;
|
|
25800
|
+
var pmDisabled = maxTime ? convert24to12(getHours(maxTime))[1] === 'am' : false;
|
|
25801
|
+
var name = 'amPm';
|
|
25802
|
+
var _b = getAmPmLabels(locale), amLabel = _b[0], pmLabel = _b[1];
|
|
25803
|
+
return (React__default["default"].createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx$1("".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 : '' },
|
|
25804
|
+
!value && React__default["default"].createElement("option", { value: "" }, "--"),
|
|
25805
|
+
React__default["default"].createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
|
|
25806
|
+
React__default["default"].createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
|
|
25807
|
+
}
|
|
25808
|
+
|
|
25809
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
25810
|
+
__assign$1 = Object.assign || function(t) {
|
|
25811
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25812
|
+
s = arguments[i];
|
|
25813
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25814
|
+
t[p] = s[p];
|
|
25815
|
+
}
|
|
25816
|
+
return t;
|
|
25817
|
+
};
|
|
25818
|
+
return __assign$1.apply(this, arguments);
|
|
25819
|
+
};
|
|
25820
|
+
var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
25821
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25822
|
+
if (ar || !(i in from)) {
|
|
25823
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
25824
|
+
ar[i] = from[i];
|
|
25825
|
+
}
|
|
25826
|
+
}
|
|
25827
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25828
|
+
};
|
|
25829
|
+
var getFormatterOptionsCache = {};
|
|
25830
|
+
var allViews$2 = ['hour', 'minute', 'second'];
|
|
25831
|
+
function isInternalInput(element) {
|
|
25832
|
+
return element.dataset.input === 'true';
|
|
25833
|
+
}
|
|
25834
|
+
function findInput(element, property) {
|
|
25835
|
+
var nextElement = element;
|
|
25836
|
+
do {
|
|
25837
|
+
nextElement = nextElement[property];
|
|
25838
|
+
} while (nextElement && !isInternalInput(nextElement));
|
|
25839
|
+
return nextElement;
|
|
25840
|
+
}
|
|
25841
|
+
function focus(element) {
|
|
25842
|
+
if (element) {
|
|
25843
|
+
element.focus();
|
|
25844
|
+
}
|
|
25845
|
+
}
|
|
25846
|
+
function renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances) {
|
|
25847
|
+
var usedFunctions = [];
|
|
25848
|
+
var pattern = new RegExp(Object.keys(elementFunctions)
|
|
25849
|
+
.map(function (el) { return "".concat(el, "+"); })
|
|
25850
|
+
.join('|'), 'g');
|
|
25851
|
+
var matches = placeholder.match(pattern);
|
|
25852
|
+
return placeholder.split(pattern).reduce(function (arr, element, index) {
|
|
25853
|
+
var divider = element && (
|
|
25854
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
25855
|
+
React__default["default"].createElement(Divider, { key: "separator_".concat(index) }, element));
|
|
25856
|
+
var res = __spreadArray$1(__spreadArray$1([], arr, true), [divider], false);
|
|
25857
|
+
var currentMatch = matches && matches[index];
|
|
25858
|
+
if (currentMatch) {
|
|
25859
|
+
var renderFunction = elementFunctions[currentMatch] ||
|
|
25860
|
+
elementFunctions[Object.keys(elementFunctions).find(function (elementFunction) {
|
|
25861
|
+
return currentMatch.match(elementFunction);
|
|
25862
|
+
})];
|
|
25863
|
+
if (!renderFunction) {
|
|
25864
|
+
return res;
|
|
25865
|
+
}
|
|
25866
|
+
if (!allowMultipleInstances && usedFunctions.includes(renderFunction)) {
|
|
25867
|
+
res.push(currentMatch);
|
|
25868
|
+
}
|
|
25869
|
+
else {
|
|
25870
|
+
res.push(renderFunction(currentMatch, index));
|
|
25871
|
+
usedFunctions.push(renderFunction);
|
|
25872
|
+
}
|
|
25873
|
+
}
|
|
25874
|
+
return res;
|
|
25875
|
+
}, []);
|
|
25876
|
+
}
|
|
25877
|
+
var formatNumber = getNumberFormatter({ useGrouping: false });
|
|
25878
|
+
function TimeInput(_a) {
|
|
25879
|
+
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;
|
|
25880
|
+
var _e = React$3.useState(null), amPm = _e[0], setAmPm = _e[1];
|
|
25881
|
+
var _f = React$3.useState(null), hour = _f[0], setHour = _f[1];
|
|
25882
|
+
var _g = React$3.useState(null), minute = _g[0], setMinute = _g[1];
|
|
25883
|
+
var _h = React$3.useState(null), second = _h[0], setSecond = _h[1];
|
|
25884
|
+
var _j = React$3.useState(null), value = _j[0], setValue = _j[1];
|
|
25885
|
+
var amPmInput = React$3.useRef(null);
|
|
25886
|
+
var hour12Input = React$3.useRef(null);
|
|
25887
|
+
var hour24Input = React$3.useRef(null);
|
|
25888
|
+
var minuteInput = React$3.useRef(null);
|
|
25889
|
+
var secondInput = React$3.useRef(null);
|
|
25890
|
+
var _k = React$3.useState(isClockOpenProps), isClockOpen = _k[0], setIsClockOpen = _k[1];
|
|
25891
|
+
var lastPressedKey = React$3.useRef();
|
|
25892
|
+
React$3.useEffect(function () {
|
|
25893
|
+
setIsClockOpen(isClockOpenProps);
|
|
25894
|
+
}, [isClockOpenProps]);
|
|
25895
|
+
React$3.useEffect(function () {
|
|
25896
|
+
var nextValue = valueProps;
|
|
25897
|
+
if (nextValue) {
|
|
25898
|
+
setAmPm(convert24to12(getHours(nextValue))[1]);
|
|
25899
|
+
setHour(getHours(nextValue).toString());
|
|
25900
|
+
setMinute(getMinutes(nextValue).toString());
|
|
25901
|
+
setSecond(getSeconds(nextValue).toString());
|
|
25902
|
+
setValue(nextValue);
|
|
25903
|
+
}
|
|
25904
|
+
else {
|
|
25905
|
+
setAmPm(null);
|
|
25906
|
+
setHour(null);
|
|
25907
|
+
setMinute(null);
|
|
25908
|
+
setSecond(null);
|
|
25909
|
+
setValue(null);
|
|
25910
|
+
}
|
|
25911
|
+
}, [
|
|
25912
|
+
valueProps,
|
|
25913
|
+
minTime,
|
|
25914
|
+
maxTime,
|
|
25915
|
+
maxDetail,
|
|
25916
|
+
// Toggling clock visibility resets values
|
|
25917
|
+
isClockOpen,
|
|
25918
|
+
]);
|
|
25919
|
+
var valueType = maxDetail;
|
|
25920
|
+
var formatTime = (function () {
|
|
25921
|
+
var level = allViews$2.indexOf(maxDetail);
|
|
25922
|
+
var formatterOptions = getFormatterOptionsCache[level] ||
|
|
25923
|
+
(function () {
|
|
25924
|
+
var options = { hour: 'numeric' };
|
|
25925
|
+
if (level >= 1) {
|
|
25926
|
+
options.minute = 'numeric';
|
|
25927
|
+
}
|
|
25928
|
+
if (level >= 2) {
|
|
25929
|
+
options.second = 'numeric';
|
|
25930
|
+
}
|
|
25931
|
+
getFormatterOptionsCache[level] = options;
|
|
25932
|
+
return options;
|
|
25933
|
+
})();
|
|
25934
|
+
return getFormatter(formatterOptions);
|
|
25935
|
+
})();
|
|
25936
|
+
/**
|
|
25937
|
+
* Gets current value in a desired format.
|
|
25938
|
+
*/
|
|
25939
|
+
function getProcessedValue(value) {
|
|
25940
|
+
var processFunction = (function () {
|
|
25941
|
+
switch (valueType) {
|
|
25942
|
+
case 'hour':
|
|
25943
|
+
case 'minute':
|
|
25944
|
+
return getHoursMinutes;
|
|
25945
|
+
case 'second':
|
|
25946
|
+
return getHoursMinutesSeconds;
|
|
25947
|
+
default:
|
|
25948
|
+
throw new Error('Invalid valueType');
|
|
25949
|
+
}
|
|
25950
|
+
})();
|
|
25951
|
+
return processFunction(value);
|
|
25952
|
+
}
|
|
25953
|
+
var placeholder = format ||
|
|
25954
|
+
(function () {
|
|
25955
|
+
var hour24 = 21;
|
|
25956
|
+
var hour12 = 9;
|
|
25957
|
+
var minute = 13;
|
|
25958
|
+
var second = 14;
|
|
25959
|
+
var date = new Date(2017, 0, 1, hour24, minute, second);
|
|
25960
|
+
return formatTime(locale, date)
|
|
25961
|
+
.replace(formatNumber(locale, hour12), 'h')
|
|
25962
|
+
.replace(formatNumber(locale, hour24), 'H')
|
|
25963
|
+
.replace(formatNumber(locale, minute), 'mm')
|
|
25964
|
+
.replace(formatNumber(locale, second), 'ss')
|
|
25965
|
+
.replace(new RegExp(getAmPmLabels(locale).join('|')), 'a');
|
|
25966
|
+
})();
|
|
25967
|
+
var divider = (function () {
|
|
25968
|
+
var dividers = placeholder.match(/[^0-9a-z]/i);
|
|
25969
|
+
return dividers ? dividers[0] : null;
|
|
25970
|
+
})();
|
|
25971
|
+
function onClick(event) {
|
|
25972
|
+
if (event.target === event.currentTarget) {
|
|
25973
|
+
// Wrapper was directly clicked
|
|
25974
|
+
var firstInput = event.target.children[1];
|
|
25975
|
+
focus(firstInput);
|
|
25976
|
+
}
|
|
25977
|
+
}
|
|
25978
|
+
function onKeyDown(event) {
|
|
25979
|
+
lastPressedKey.current = event.key;
|
|
25980
|
+
switch (event.key) {
|
|
25981
|
+
case 'ArrowLeft':
|
|
25982
|
+
case 'ArrowRight':
|
|
25983
|
+
case divider: {
|
|
25984
|
+
event.preventDefault();
|
|
25985
|
+
var input = event.target;
|
|
25986
|
+
var property = event.key === 'ArrowLeft' ? 'previousElementSibling' : 'nextElementSibling';
|
|
25987
|
+
var nextInput = findInput(input, property);
|
|
25988
|
+
focus(nextInput);
|
|
25989
|
+
break;
|
|
25990
|
+
}
|
|
25991
|
+
}
|
|
25992
|
+
}
|
|
25993
|
+
function onKeyUp(event) {
|
|
25994
|
+
var key = event.key, input = event.target;
|
|
25995
|
+
var isLastPressedKey = lastPressedKey.current === key;
|
|
25996
|
+
if (!isLastPressedKey) {
|
|
25997
|
+
return;
|
|
25998
|
+
}
|
|
25999
|
+
var isNumberKey = !isNaN(Number(key));
|
|
26000
|
+
if (!isNumberKey) {
|
|
26001
|
+
return;
|
|
26002
|
+
}
|
|
26003
|
+
var max = input.getAttribute('max');
|
|
26004
|
+
if (!max) {
|
|
26005
|
+
return;
|
|
26006
|
+
}
|
|
26007
|
+
var value = input.value;
|
|
26008
|
+
/**
|
|
26009
|
+
* Given 1, the smallest possible number the user could type by adding another digit is 10.
|
|
26010
|
+
* 10 would be a valid value given max = 12, so we won't jump to the next input.
|
|
26011
|
+
* However, given 2, smallers possible number would be 20, and thus keeping the focus in
|
|
26012
|
+
* this field doesn't make sense.
|
|
26013
|
+
*/
|
|
26014
|
+
if (Number(value) * 10 > Number(max) || value.length >= max.length) {
|
|
26015
|
+
var property = 'nextElementSibling';
|
|
26016
|
+
var nextInput = findInput(input, property);
|
|
26017
|
+
focus(nextInput);
|
|
26018
|
+
}
|
|
26019
|
+
}
|
|
26020
|
+
/**
|
|
26021
|
+
* Called after internal onChange. Checks input validity. If all fields are valid,
|
|
26022
|
+
* calls props.onChange.
|
|
26023
|
+
*/
|
|
26024
|
+
function onChangeExternal() {
|
|
26025
|
+
if (!onChangeProps) {
|
|
26026
|
+
return;
|
|
26027
|
+
}
|
|
26028
|
+
function filterBoolean(value) {
|
|
26029
|
+
return Boolean(value);
|
|
26030
|
+
}
|
|
26031
|
+
var formElements = [
|
|
26032
|
+
amPmInput.current,
|
|
26033
|
+
hour12Input.current,
|
|
26034
|
+
hour24Input.current,
|
|
26035
|
+
minuteInput.current,
|
|
26036
|
+
secondInput.current,
|
|
26037
|
+
].filter(filterBoolean);
|
|
26038
|
+
var formElementsWithoutSelect = formElements.slice(1);
|
|
26039
|
+
var values = {};
|
|
26040
|
+
formElements.forEach(function (formElement) {
|
|
26041
|
+
values[formElement.name] =
|
|
26042
|
+
formElement.type === 'number'
|
|
26043
|
+
? 'valueAsNumber' in formElement
|
|
26044
|
+
? formElement.valueAsNumber
|
|
26045
|
+
: Number(formElement.value)
|
|
26046
|
+
: formElement.value;
|
|
26047
|
+
});
|
|
26048
|
+
var isEveryValueEmpty = formElementsWithoutSelect.every(function (formElement) { return !formElement.value; });
|
|
26049
|
+
if (isEveryValueEmpty) {
|
|
26050
|
+
onChangeProps(null, false);
|
|
26051
|
+
return;
|
|
26052
|
+
}
|
|
26053
|
+
var isEveryValueFilled = formElements.every(function (formElement) { return formElement.value; });
|
|
26054
|
+
var isEveryValueValid = formElements.every(function (formElement) { return formElement.validity.valid; });
|
|
26055
|
+
if (isEveryValueFilled && isEveryValueValid) {
|
|
26056
|
+
var hour_1 = Number(values.hour24 ||
|
|
26057
|
+
(values.hour12 && values.amPm && convert12to24(values.hour12, values.amPm)) ||
|
|
26058
|
+
0);
|
|
26059
|
+
var minute_1 = Number(values.minute || 0);
|
|
26060
|
+
var second_1 = Number(values.second || 0);
|
|
26061
|
+
var padStart = function (num) { return "0".concat(num).slice(-2); };
|
|
26062
|
+
var proposedValue = "".concat(padStart(hour_1), ":").concat(padStart(minute_1), ":").concat(padStart(second_1));
|
|
26063
|
+
var processedValue = getProcessedValue(proposedValue);
|
|
26064
|
+
onChangeProps(processedValue, false);
|
|
26065
|
+
return;
|
|
26066
|
+
}
|
|
26067
|
+
if (!onInvalidChange) {
|
|
26068
|
+
return;
|
|
26069
|
+
}
|
|
26070
|
+
onInvalidChange();
|
|
26071
|
+
}
|
|
26072
|
+
/**
|
|
26073
|
+
* Called when non-native date input is changed.
|
|
26074
|
+
*/
|
|
26075
|
+
function onChange(event) {
|
|
26076
|
+
var _a = event.target, name = _a.name, value = _a.value;
|
|
26077
|
+
switch (name) {
|
|
26078
|
+
case 'amPm':
|
|
26079
|
+
setAmPm(value);
|
|
26080
|
+
break;
|
|
26081
|
+
case 'hour12':
|
|
26082
|
+
setHour(value ? convert12to24(value, amPm || 'am').toString() : '');
|
|
26083
|
+
break;
|
|
26084
|
+
case 'hour24':
|
|
26085
|
+
setHour(value);
|
|
26086
|
+
break;
|
|
26087
|
+
case 'minute':
|
|
26088
|
+
setMinute(value);
|
|
26089
|
+
break;
|
|
26090
|
+
case 'second':
|
|
26091
|
+
setSecond(value);
|
|
26092
|
+
break;
|
|
26093
|
+
}
|
|
26094
|
+
onChangeExternal();
|
|
26095
|
+
}
|
|
26096
|
+
/**
|
|
26097
|
+
* Called when native date input is changed.
|
|
26098
|
+
*/
|
|
26099
|
+
function onChangeNative(event) {
|
|
26100
|
+
var value = event.target.value;
|
|
26101
|
+
if (!onChangeProps) {
|
|
26102
|
+
return;
|
|
26103
|
+
}
|
|
26104
|
+
var processedValue = value || null;
|
|
26105
|
+
onChangeProps(processedValue, false);
|
|
26106
|
+
}
|
|
26107
|
+
var commonInputProps = {
|
|
26108
|
+
className: className,
|
|
26109
|
+
disabled: disabled,
|
|
26110
|
+
maxTime: maxTime,
|
|
26111
|
+
minTime: minTime,
|
|
26112
|
+
onChange: onChange,
|
|
26113
|
+
onKeyDown: onKeyDown,
|
|
26114
|
+
onKeyUp: onKeyUp,
|
|
26115
|
+
// This is only for showing validity when editing
|
|
26116
|
+
required: Boolean(required || isClockOpen),
|
|
26117
|
+
};
|
|
26118
|
+
function renderHour12(currentMatch, index) {
|
|
26119
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
26120
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
26121
|
+
}
|
|
26122
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
26123
|
+
return (React__default["default"].createElement(Hour12Input, __assign$1({ key: "hour12" }, commonInputProps, { amPm: amPm, ariaLabel: hourAriaLabel,
|
|
26124
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26125
|
+
autoFocus: index === 0 && autoFocus, inputRef: hour12Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
26126
|
+
}
|
|
26127
|
+
function renderHour24(currentMatch, index) {
|
|
26128
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
26129
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
26130
|
+
}
|
|
26131
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
26132
|
+
return (React__default["default"].createElement(Hour24Input, __assign$1({ key: "hour24" }, commonInputProps, { ariaLabel: hourAriaLabel,
|
|
26133
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26134
|
+
autoFocus: index === 0 && autoFocus, inputRef: hour24Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
26135
|
+
}
|
|
26136
|
+
function renderHour(currentMatch, index) {
|
|
26137
|
+
if (/h/.test(currentMatch)) {
|
|
26138
|
+
return renderHour12(currentMatch, index);
|
|
26139
|
+
}
|
|
26140
|
+
return renderHour24(currentMatch, index);
|
|
26141
|
+
}
|
|
26142
|
+
function renderMinute(currentMatch, index) {
|
|
26143
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
26144
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
26145
|
+
}
|
|
26146
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
26147
|
+
return (React__default["default"].createElement(MinuteInput, __assign$1({ key: "minute" }, commonInputProps, { ariaLabel: minuteAriaLabel,
|
|
26148
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26149
|
+
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: minuteInput, placeholder: minutePlaceholder, showLeadingZeros: showLeadingZeros, value: minute })));
|
|
26150
|
+
}
|
|
26151
|
+
function renderSecond(currentMatch, index) {
|
|
26152
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
26153
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
26154
|
+
}
|
|
26155
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : true;
|
|
26156
|
+
return (React__default["default"].createElement(SecondInput, __assign$1({ key: "second" }, commonInputProps, { ariaLabel: secondAriaLabel,
|
|
26157
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26158
|
+
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: secondInput, minute: minute, placeholder: secondPlaceholder, showLeadingZeros: showLeadingZeros, value: second })));
|
|
26159
|
+
}
|
|
26160
|
+
function renderAmPm(currentMatch, index) {
|
|
26161
|
+
return (React__default["default"].createElement(AmPm, __assign$1({ key: "ampm" }, commonInputProps, { ariaLabel: amPmAriaLabel,
|
|
26162
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26163
|
+
autoFocus: index === 0 && autoFocus, inputRef: amPmInput, locale: locale, onChange: onChange, value: amPm })));
|
|
26164
|
+
}
|
|
26165
|
+
function renderCustomInputsInternal() {
|
|
26166
|
+
var elementFunctions = {
|
|
26167
|
+
h: renderHour,
|
|
26168
|
+
H: renderHour,
|
|
26169
|
+
m: renderMinute,
|
|
26170
|
+
s: renderSecond,
|
|
26171
|
+
a: renderAmPm,
|
|
26172
|
+
};
|
|
26173
|
+
var allowMultipleInstances = typeof format !== 'undefined';
|
|
26174
|
+
return renderCustomInputs(placeholder, elementFunctions, allowMultipleInstances);
|
|
26175
|
+
}
|
|
26176
|
+
function renderNativeInput() {
|
|
26177
|
+
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 }));
|
|
26178
|
+
}
|
|
26179
|
+
return (
|
|
26180
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
26181
|
+
React__default["default"].createElement("div", { className: className, onClick: onClick },
|
|
26182
|
+
renderNativeInput(),
|
|
26183
|
+
renderCustomInputsInternal()));
|
|
26184
|
+
}
|
|
26185
|
+
|
|
26186
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
26187
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
26188
|
+
if (ar || !(i in from)) {
|
|
26189
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
26190
|
+
ar[i] = from[i];
|
|
26191
|
+
}
|
|
26192
|
+
}
|
|
26193
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26194
|
+
};
|
|
26195
|
+
var allViews$1 = ['hour', 'minute', 'second'];
|
|
26196
|
+
var allValueTypes = __spreadArray([], allViews$1, true);
|
|
26197
|
+
var hourOptionalSecondsRegExp = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
|
|
26198
|
+
var isTime = function isTime(props, propName, componentName) {
|
|
26199
|
+
var _a = props, _b = propName, time = _a[_b];
|
|
26200
|
+
if (time) {
|
|
26201
|
+
if (typeof time !== 'string' || !hourOptionalSecondsRegExp.test(time)) {
|
|
26202
|
+
return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof time, "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format."));
|
|
26203
|
+
}
|
|
26204
|
+
}
|
|
26205
|
+
// Everything is fine
|
|
26206
|
+
return null;
|
|
26207
|
+
};
|
|
26208
|
+
propTypes$1.exports.oneOf(allValueTypes);
|
|
26209
|
+
propTypes$1.exports.oneOfType([
|
|
26210
|
+
propTypes$1.exports.func,
|
|
26211
|
+
propTypes$1.exports.exact({
|
|
26212
|
+
current: propTypes$1.exports.any,
|
|
26213
|
+
}),
|
|
26214
|
+
]);
|
|
26215
|
+
var rangeOf = function (type) {
|
|
26216
|
+
return propTypes$1.exports.arrayOf(type);
|
|
26217
|
+
};
|
|
26218
|
+
|
|
26219
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
26220
|
+
__assign = Object.assign || function(t) {
|
|
26221
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26222
|
+
s = arguments[i];
|
|
26223
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
26224
|
+
t[p] = s[p];
|
|
26225
|
+
}
|
|
26226
|
+
return t;
|
|
26227
|
+
};
|
|
26228
|
+
return __assign.apply(this, arguments);
|
|
26229
|
+
};
|
|
26230
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
26231
|
+
var t = {};
|
|
26232
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
26233
|
+
t[p] = s[p];
|
|
26234
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26235
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26236
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
26237
|
+
t[p[i]] = s[p[i]];
|
|
26238
|
+
}
|
|
26239
|
+
return t;
|
|
26240
|
+
};
|
|
26241
|
+
var isBrowser$4 = typeof document !== 'undefined';
|
|
26242
|
+
var baseClassName = 'react-time-picker';
|
|
26243
|
+
var outsideActionEvents = ['mousedown', 'focusin', 'touchstart'];
|
|
26244
|
+
var allViews = ['hour', 'minute', 'second'];
|
|
26245
|
+
var iconProps = {
|
|
26246
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
26247
|
+
width: 19,
|
|
26248
|
+
height: 19,
|
|
26249
|
+
viewBox: '0 0 19 19',
|
|
26250
|
+
stroke: 'black',
|
|
26251
|
+
strokeWidth: 2,
|
|
26252
|
+
};
|
|
26253
|
+
var ClockIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clock-button__icon ").concat(baseClassName, "__button__icon"), fill: "none" }),
|
|
26254
|
+
React__default["default"].createElement("circle", { cx: "9.5", cy: "9.5", r: "7.5" }),
|
|
26255
|
+
React__default["default"].createElement("path", { d: "M9.5 4.5 v5 h4" })));
|
|
26256
|
+
var ClearIcon = (React__default["default"].createElement("svg", __assign({}, iconProps, { className: "".concat(baseClassName, "__clear-button__icon ").concat(baseClassName, "__button__icon") }),
|
|
26257
|
+
React__default["default"].createElement("line", { x1: "4", x2: "15", y1: "4", y2: "15" }),
|
|
26258
|
+
React__default["default"].createElement("line", { x1: "15", x2: "4", y1: "4", y2: "15" })));
|
|
26259
|
+
var TimePicker$1 = function TimePicker(props) {
|
|
26260
|
+
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"]);
|
|
26261
|
+
var _h = React$3.useState(isOpenProps), isOpen = _h[0], setIsOpen = _h[1];
|
|
26262
|
+
var wrapper = React$3.useRef(null);
|
|
26263
|
+
var clockWrapper = React$3.useRef(null);
|
|
26264
|
+
React$3.useEffect(function () {
|
|
26265
|
+
setIsOpen(isOpenProps);
|
|
26266
|
+
}, [isOpenProps]);
|
|
26267
|
+
function openClock(_a) {
|
|
26268
|
+
var reason = _a.reason;
|
|
26269
|
+
if (shouldOpenClock) {
|
|
26270
|
+
if (!shouldOpenClock({ reason: reason })) {
|
|
26271
|
+
return;
|
|
26272
|
+
}
|
|
26273
|
+
}
|
|
26274
|
+
setIsOpen(true);
|
|
26275
|
+
if (onClockOpen) {
|
|
26276
|
+
onClockOpen();
|
|
26277
|
+
}
|
|
26278
|
+
}
|
|
26279
|
+
var closeClock = React$3.useCallback(function (_a) {
|
|
26280
|
+
var reason = _a.reason;
|
|
26281
|
+
if (shouldCloseClock) {
|
|
26282
|
+
if (!shouldCloseClock({ reason: reason })) {
|
|
26283
|
+
return;
|
|
26284
|
+
}
|
|
26285
|
+
}
|
|
26286
|
+
setIsOpen(false);
|
|
26287
|
+
if (onClockClose) {
|
|
26288
|
+
onClockClose();
|
|
26289
|
+
}
|
|
26290
|
+
}, [onClockClose, shouldCloseClock]);
|
|
26291
|
+
function toggleClock() {
|
|
26292
|
+
if (isOpen) {
|
|
26293
|
+
closeClock({ reason: 'buttonClick' });
|
|
26294
|
+
}
|
|
26295
|
+
else {
|
|
26296
|
+
openClock({ reason: 'buttonClick' });
|
|
26297
|
+
}
|
|
26298
|
+
}
|
|
26299
|
+
function onChange(value, shouldCloseClock) {
|
|
26300
|
+
if (shouldCloseClock === void 0) { shouldCloseClock = shouldCloseClockOnSelect; }
|
|
26301
|
+
if (shouldCloseClock) {
|
|
26302
|
+
closeClock({ reason: 'select' });
|
|
26303
|
+
}
|
|
26304
|
+
if (onChangeProps) {
|
|
26305
|
+
onChangeProps(value);
|
|
26306
|
+
}
|
|
26307
|
+
}
|
|
26308
|
+
function onFocus(event) {
|
|
26309
|
+
if (onFocusProps) {
|
|
26310
|
+
onFocusProps(event);
|
|
26311
|
+
}
|
|
26312
|
+
if (
|
|
26313
|
+
// Internet Explorer still fires onFocus on disabled elements
|
|
26314
|
+
disabled ||
|
|
26315
|
+
isOpen ||
|
|
26316
|
+
!openClockOnFocus ||
|
|
26317
|
+
event.target.dataset.select === 'true') {
|
|
26318
|
+
return;
|
|
26319
|
+
}
|
|
26320
|
+
openClock({ reason: 'focus' });
|
|
26321
|
+
}
|
|
26322
|
+
var onKeyDown = React$3.useCallback(function (event) {
|
|
26323
|
+
if (event.key === 'Escape') {
|
|
26324
|
+
closeClock({ reason: 'escape' });
|
|
26325
|
+
}
|
|
26326
|
+
}, [closeClock]);
|
|
26327
|
+
function clear() {
|
|
26328
|
+
onChange(null);
|
|
26329
|
+
}
|
|
26330
|
+
function stopPropagation(event) {
|
|
26331
|
+
event.stopPropagation();
|
|
26332
|
+
}
|
|
26333
|
+
var onOutsideAction = React$3.useCallback(function (event) {
|
|
26334
|
+
var wrapperEl = wrapper.current;
|
|
26335
|
+
var clockWrapperEl = clockWrapper.current;
|
|
26336
|
+
// Try event.composedPath first to handle clicks inside a Shadow DOM.
|
|
26337
|
+
var target = ('composedPath' in event ? event.composedPath()[0] : event.target);
|
|
26338
|
+
if (target &&
|
|
26339
|
+
wrapperEl &&
|
|
26340
|
+
!wrapperEl.contains(target) &&
|
|
26341
|
+
(!clockWrapperEl || !clockWrapperEl.contains(target))) {
|
|
26342
|
+
closeClock({ reason: 'outsideAction' });
|
|
26343
|
+
}
|
|
26344
|
+
}, [clockWrapper, closeClock, wrapper]);
|
|
26345
|
+
var handleOutsideActionListeners = React$3.useCallback(function (shouldListen) {
|
|
26346
|
+
if (shouldListen === void 0) { shouldListen = isOpen; }
|
|
26347
|
+
outsideActionEvents.forEach(function (event) {
|
|
26348
|
+
if (shouldListen) {
|
|
26349
|
+
document.addEventListener(event, onOutsideAction);
|
|
26350
|
+
}
|
|
26351
|
+
else {
|
|
26352
|
+
document.removeEventListener(event, onOutsideAction);
|
|
26353
|
+
}
|
|
26354
|
+
});
|
|
26355
|
+
if (shouldListen) {
|
|
26356
|
+
document.addEventListener('keydown', onKeyDown);
|
|
26357
|
+
}
|
|
26358
|
+
else {
|
|
26359
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
26360
|
+
}
|
|
26361
|
+
}, [isOpen, onOutsideAction, onKeyDown]);
|
|
26362
|
+
React$3.useEffect(function () {
|
|
26363
|
+
handleOutsideActionListeners();
|
|
26364
|
+
return function () {
|
|
26365
|
+
handleOutsideActionListeners(false);
|
|
26366
|
+
};
|
|
26367
|
+
}, [handleOutsideActionListeners]);
|
|
26368
|
+
function renderInputs() {
|
|
26369
|
+
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
26370
|
+
var ariaLabelProps = {
|
|
26371
|
+
amPmAriaLabel: amPmAriaLabel,
|
|
26372
|
+
hourAriaLabel: hourAriaLabel,
|
|
26373
|
+
minuteAriaLabel: minuteAriaLabel,
|
|
26374
|
+
nativeInputAriaLabel: nativeInputAriaLabel,
|
|
26375
|
+
secondAriaLabel: secondAriaLabel,
|
|
26376
|
+
};
|
|
26377
|
+
var placeholderProps = {
|
|
26378
|
+
hourPlaceholder: hourPlaceholder,
|
|
26379
|
+
minutePlaceholder: minutePlaceholder,
|
|
26380
|
+
secondPlaceholder: secondPlaceholder,
|
|
26381
|
+
};
|
|
26382
|
+
return (React__default["default"].createElement("div", { className: "".concat(baseClassName, "__wrapper") },
|
|
26383
|
+
React__default["default"].createElement(TimeInput, __assign({}, ariaLabelProps, placeholderProps, {
|
|
26384
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
26385
|
+
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 })),
|
|
26386
|
+
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)),
|
|
26387
|
+
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))));
|
|
26388
|
+
}
|
|
26389
|
+
function renderClock() {
|
|
26390
|
+
if (isOpen === null || disableClock) {
|
|
26391
|
+
return null;
|
|
26392
|
+
}
|
|
26393
|
+
var clockClassName = props.clockClassName; props.className; // Unused, here to exclude it from clockProps
|
|
26394
|
+
props.onChange; // Unused, here to exclude it from clockProps
|
|
26395
|
+
var portalContainer = props.portalContainer, value = props.value, clockProps = __rest(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
|
|
26396
|
+
var className = "".concat(baseClassName, "__clock");
|
|
26397
|
+
var classNames = clsx$1(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
|
|
26398
|
+
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
26399
|
+
var clock = React__default["default"].createElement(Clock, __assign({ className: clockClassName, value: valueFrom }, clockProps));
|
|
26400
|
+
return portalContainer ? (ReactDOM.createPortal(React__default["default"].createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default["default"].createElement(Fit, null,
|
|
26401
|
+
React__default["default"].createElement("div", { ref: function (ref) {
|
|
26402
|
+
if (ref && !isOpen) {
|
|
26403
|
+
ref.removeAttribute('style');
|
|
26404
|
+
}
|
|
26405
|
+
}, className: classNames }, clock)));
|
|
26406
|
+
}
|
|
26407
|
+
var eventProps = React$3.useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
|
|
26408
|
+
return (React__default["default"].createElement("div", __assign({ className: clsx$1(baseClassName, "".concat(baseClassName, "--").concat(isOpen ? 'open' : 'closed'), "".concat(baseClassName, "--").concat(disabled ? 'disabled' : 'enabled'), className), "data-testid": dataTestid, id: id }, eventProps, { onFocus: onFocus, ref: wrapper }),
|
|
26409
|
+
renderInputs(),
|
|
26410
|
+
renderClock()));
|
|
26411
|
+
};
|
|
26412
|
+
var isValue = propTypes$1.exports.oneOfType([isTime, propTypes$1.exports.instanceOf(Date)]);
|
|
26413
|
+
var isValueOrValueArray = propTypes$1.exports.oneOfType([isValue, rangeOf(isValue)]);
|
|
26414
|
+
TimePicker$1.propTypes = {
|
|
26415
|
+
amPmAriaLabel: propTypes$1.exports.string,
|
|
26416
|
+
autoFocus: propTypes$1.exports.bool,
|
|
26417
|
+
className: propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.arrayOf(propTypes$1.exports.string)]),
|
|
26418
|
+
clearAriaLabel: propTypes$1.exports.string,
|
|
26419
|
+
clearIcon: propTypes$1.exports.oneOfType([propTypes$1.exports.node, propTypes$1.exports.func]),
|
|
26420
|
+
clockAriaLabel: propTypes$1.exports.string,
|
|
26421
|
+
clockClassName: propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.arrayOf(propTypes$1.exports.string)]),
|
|
26422
|
+
clockIcon: propTypes$1.exports.oneOfType([propTypes$1.exports.node, propTypes$1.exports.func]),
|
|
26423
|
+
closeClock: propTypes$1.exports.bool,
|
|
26424
|
+
'data-testid': propTypes$1.exports.string,
|
|
26425
|
+
disableClock: propTypes$1.exports.bool,
|
|
26426
|
+
disabled: propTypes$1.exports.bool,
|
|
26427
|
+
format: propTypes$1.exports.string,
|
|
26428
|
+
hourAriaLabel: propTypes$1.exports.string,
|
|
26429
|
+
hourPlaceholder: propTypes$1.exports.string,
|
|
26430
|
+
id: propTypes$1.exports.string,
|
|
26431
|
+
isOpen: propTypes$1.exports.bool,
|
|
26432
|
+
locale: propTypes$1.exports.string,
|
|
26433
|
+
maxDetail: propTypes$1.exports.oneOf(allViews),
|
|
26434
|
+
maxTime: isTime,
|
|
26435
|
+
minTime: isTime,
|
|
26436
|
+
minuteAriaLabel: propTypes$1.exports.string,
|
|
26437
|
+
minutePlaceholder: propTypes$1.exports.string,
|
|
26438
|
+
name: propTypes$1.exports.string,
|
|
26439
|
+
nativeInputAriaLabel: propTypes$1.exports.string,
|
|
26440
|
+
onChange: propTypes$1.exports.func,
|
|
26441
|
+
onClockClose: propTypes$1.exports.func,
|
|
26442
|
+
onClockOpen: propTypes$1.exports.func,
|
|
26443
|
+
onFocus: propTypes$1.exports.func,
|
|
26444
|
+
openClockOnFocus: propTypes$1.exports.bool,
|
|
26445
|
+
required: propTypes$1.exports.bool,
|
|
26446
|
+
secondAriaLabel: propTypes$1.exports.string,
|
|
26447
|
+
secondPlaceholder: propTypes$1.exports.string,
|
|
26448
|
+
value: isValueOrValueArray,
|
|
26449
|
+
};
|
|
26450
|
+
if (isBrowser$4) {
|
|
26451
|
+
TimePicker$1.propTypes.portalContainer = propTypes$1.exports.instanceOf(HTMLElement);
|
|
26452
|
+
}
|
|
26453
|
+
|
|
26454
|
+
var HoverIcon = function HoverIcon(_ref) {
|
|
26455
|
+
var _ref$time = _ref.time,
|
|
26456
|
+
time = _ref$time === void 0 ? false : _ref$time;
|
|
26457
|
+
var _useState = React$3.useState(false),
|
|
26458
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
26459
|
+
hovered = _useState2[0],
|
|
26460
|
+
setHovered = _useState2[1];
|
|
26461
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26462
|
+
onMouseLeave: function onMouseLeave() {
|
|
26463
|
+
return setHovered(false);
|
|
26464
|
+
},
|
|
26465
|
+
onMouseOver: function onMouseOver() {
|
|
26466
|
+
return setHovered(true);
|
|
26467
|
+
}
|
|
26468
|
+
}, hovered && time ? /*#__PURE__*/React__default["default"].createElement(neetoIcons.Close, {
|
|
26469
|
+
size: 16
|
|
26470
|
+
}) : /*#__PURE__*/React__default["default"].createElement(neetoIcons.Clock, {
|
|
26471
|
+
size: 16
|
|
26472
|
+
}));
|
|
26473
|
+
};
|
|
26474
|
+
|
|
26475
|
+
var FORMAT = "HH:mm";
|
|
26476
|
+
var getFormattedTime = function getFormattedTime(value) {
|
|
26477
|
+
if (dayjs.isDayjs(value)) {
|
|
26478
|
+
return value.toDate();
|
|
26479
|
+
} else if (value instanceof Date || dayjs(value, FORMAT).isValid()) {
|
|
26480
|
+
return value;
|
|
26481
|
+
}
|
|
26482
|
+
return null;
|
|
26483
|
+
};
|
|
26484
|
+
var getFormattedRange = function getFormattedRange(value) {
|
|
26485
|
+
if (!Array.isArray(value)) return null;
|
|
26486
|
+
return value.map(function (item) {
|
|
26487
|
+
return getFormattedTime(item);
|
|
26488
|
+
});
|
|
26489
|
+
};
|
|
26490
|
+
var toDayJs = function toDayJs(value) {
|
|
26491
|
+
if (Array.isArray(value)) return value.map(function (item) {
|
|
26492
|
+
return dayjs(item, FORMAT);
|
|
26493
|
+
});
|
|
26494
|
+
return dayjs(value, FORMAT);
|
|
26495
|
+
};
|
|
26496
|
+
|
|
26497
|
+
var _excluded$v = ["type", "className", "label", "labelProps", "size", "nakedInput", "required", "value", "defaultValue", "onChange", "error", "onBlur"];
|
|
26498
|
+
function ownKeys$l(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; }
|
|
26499
|
+
function _objectSpread$k(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$l(Object(source), !0).forEach(function (key) { _defineProperty$7(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$l(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26500
|
+
dayjs.extend(customParseFormat);
|
|
26501
|
+
var INPUT_SIZES$1 = {
|
|
26502
|
+
small: "small",
|
|
26503
|
+
medium: "medium",
|
|
26504
|
+
large: "large"
|
|
26505
|
+
};
|
|
26506
|
+
var timeComponents = {
|
|
26507
|
+
range: TimeRangePicker,
|
|
26508
|
+
time: TimePicker$1
|
|
26509
|
+
};
|
|
26510
|
+
var TimePickerInput = /*#__PURE__*/React$3.forwardRef(function (_ref, ref) {
|
|
26511
|
+
var _ref$type = _ref.type,
|
|
26512
|
+
type = _ref$type === void 0 ? "time" : _ref$type,
|
|
26513
|
+
_ref$className = _ref.className,
|
|
26514
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
26515
|
+
label = _ref.label,
|
|
26516
|
+
labelProps = _ref.labelProps,
|
|
26517
|
+
_ref$size = _ref.size,
|
|
25473
26518
|
size = _ref$size === void 0 ? INPUT_SIZES$1.medium : _ref$size,
|
|
25474
26519
|
_ref$nakedInput = _ref.nakedInput,
|
|
25475
26520
|
nakedInput = _ref$nakedInput === void 0 ? false : _ref$nakedInput,
|
|
25476
26521
|
_ref$required = _ref.required,
|
|
25477
26522
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
25478
26523
|
inputValue = _ref.value,
|
|
25479
|
-
|
|
26524
|
+
defaultValue = _ref.defaultValue,
|
|
26525
|
+
_ref$onChange = _ref.onChange,
|
|
26526
|
+
onChange = _ref$onChange === void 0 ? noop$3 : _ref$onChange,
|
|
25480
26527
|
_ref$error = _ref.error,
|
|
25481
26528
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
25482
26529
|
_ref$onBlur = _ref.onBlur,
|
|
25483
26530
|
onBlur = _ref$onBlur === void 0 ? noop$3 : _ref$onBlur,
|
|
25484
26531
|
otherProps = _objectWithoutProperties$1(_ref, _excluded$v);
|
|
25485
|
-
var
|
|
25486
|
-
|
|
25487
|
-
|
|
25488
|
-
|
|
25489
|
-
return null;
|
|
25490
|
-
}, [inputValue]);
|
|
26532
|
+
var _useState = React$3.useState(null),
|
|
26533
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
26534
|
+
value = _useState2[0],
|
|
26535
|
+
setValue = _useState2[1];
|
|
25491
26536
|
var id = useId(otherProps.id);
|
|
25492
26537
|
var errorId = "error_".concat(id);
|
|
26538
|
+
React$3.useEffect(function () {
|
|
26539
|
+
if (neetoCist.isNotPresent(inputValue) && neetoCist.isNotPresent(defaultValue)) return;
|
|
26540
|
+
setValue((type === "range" ? getFormattedRange : getFormattedTime)(inputValue || defaultValue));
|
|
26541
|
+
}, [type, inputValue]);
|
|
25493
26542
|
var handleChange = function handleChange(newValue) {
|
|
25494
|
-
|
|
25495
|
-
onChange(
|
|
26543
|
+
setValue(newValue);
|
|
26544
|
+
onChange(toDayJs(newValue), newValue);
|
|
26545
|
+
};
|
|
26546
|
+
var handleShouldCloseClock = function handleShouldCloseClock() {
|
|
26547
|
+
onBlur(toDayJs(value), value);
|
|
26548
|
+
return true;
|
|
25496
26549
|
};
|
|
26550
|
+
var handleKeyDown = function handleKeyDown(_ref2) {
|
|
26551
|
+
var code = _ref2.code;
|
|
26552
|
+
if (code !== "Enter") return;
|
|
26553
|
+
onBlur(toDayJs(value), value);
|
|
26554
|
+
};
|
|
26555
|
+
var Component = timeComponents[type];
|
|
25497
26556
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
25498
26557
|
ref: ref,
|
|
25499
26558
|
className: "neeto-ui-input__wrapper"
|
|
25500
26559
|
}, label && /*#__PURE__*/React__default["default"].createElement(Label, _objectSpread$k({
|
|
25501
26560
|
required: required
|
|
25502
|
-
}, labelProps), label), /*#__PURE__*/React__default["default"].createElement(
|
|
26561
|
+
}, labelProps), label), /*#__PURE__*/React__default["default"].createElement(Component, _extends$4({
|
|
25503
26562
|
id: id,
|
|
25504
26563
|
value: value,
|
|
25505
26564
|
disableClock: true,
|
|
@@ -25510,6 +26569,7 @@ var TimePickerInput = /*#__PURE__*/React$3.forwardRef(function (_ref, ref) {
|
|
|
25510
26569
|
hourPlaceholder: "HH",
|
|
25511
26570
|
minutePlaceholder: "mm",
|
|
25512
26571
|
secondAriaLabel: "ss",
|
|
26572
|
+
shouldCloseClock: handleShouldCloseClock,
|
|
25513
26573
|
className: classnames$1("neeto-ui-time-picker", [className], {
|
|
25514
26574
|
"neeto-ui-time-picker--small": size === "small",
|
|
25515
26575
|
"neeto-ui-time-picker--medium": size === "medium",
|
|
@@ -25518,13 +26578,8 @@ var TimePickerInput = /*#__PURE__*/React$3.forwardRef(function (_ref, ref) {
|
|
|
25518
26578
|
"neeto-ui-time-picker--naked": nakedInput,
|
|
25519
26579
|
"neeto-ui-time-picker--error": !!error
|
|
25520
26580
|
}),
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
if (reason !== "outsideAction") return true;
|
|
25524
|
-
onBlur();
|
|
25525
|
-
return true;
|
|
25526
|
-
},
|
|
25527
|
-
onChange: handleChange
|
|
26581
|
+
onChange: handleChange,
|
|
26582
|
+
onKeyDown: handleKeyDown
|
|
25528
26583
|
}, otherProps)), !!error && typeof error === "string" && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
25529
26584
|
className: "neeto-ui-input__error",
|
|
25530
26585
|
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
@@ -25533,11 +26588,18 @@ var TimePickerInput = /*#__PURE__*/React$3.forwardRef(function (_ref, ref) {
|
|
|
25533
26588
|
});
|
|
25534
26589
|
TimePickerInput.displayName = "TimePicker";
|
|
25535
26590
|
|
|
26591
|
+
var DATE_FORMAT = "YYYY-MM-DD";
|
|
26592
|
+
var TIME_FORMAT = "HH:mm";
|
|
26593
|
+
var getDateTime = function getDateTime(date, time) {
|
|
26594
|
+
if (neetoCist.isPresent(date) && neetoCist.isPresent(time)) {
|
|
26595
|
+
return dayjs("".concat(date.format(DATE_FORMAT), " ").concat(time.format(TIME_FORMAT)));
|
|
26596
|
+
}
|
|
26597
|
+
return null;
|
|
26598
|
+
};
|
|
26599
|
+
|
|
25536
26600
|
function ownKeys$k(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; }
|
|
25537
26601
|
function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$k(Object(source), !0).forEach(function (key) { _defineProperty$7(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$k(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25538
26602
|
dayjs.extend(customParseFormat);
|
|
25539
|
-
var DATE_FORMAT = "YYYY-MM-DD";
|
|
25540
|
-
var TIME_FORMAT = "HH:mm";
|
|
25541
26603
|
var DateTimePicker = function DateTimePicker(_ref) {
|
|
25542
26604
|
var _ref$className = _ref.className,
|
|
25543
26605
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
@@ -25559,10 +26621,12 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25559
26621
|
_ref$required = _ref.required,
|
|
25560
26622
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
25561
26623
|
id = _ref.id,
|
|
26624
|
+
datePickerProps = _ref.datePickerProps,
|
|
26625
|
+
timePickerProps = _ref.timePickerProps,
|
|
25562
26626
|
_ref$onTimeInputBlur = _ref.onTimeInputBlur,
|
|
25563
26627
|
onTimeInputBlur = _ref$onTimeInputBlur === void 0 ? noop$3 : _ref$onTimeInputBlur,
|
|
25564
|
-
|
|
25565
|
-
|
|
26628
|
+
_ref$onBlur = _ref.onBlur,
|
|
26629
|
+
onBlur = _ref$onBlur === void 0 ? noop$3 : _ref$onBlur;
|
|
25566
26630
|
var _useState = React$3.useState(datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.open),
|
|
25567
26631
|
_useState2 = _slicedToArray$3(_useState, 2),
|
|
25568
26632
|
open = _useState2[0],
|
|
@@ -25592,11 +26656,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25592
26656
|
}, [value, defaultValue]);
|
|
25593
26657
|
React$3.useEffect(function () {
|
|
25594
26658
|
if (neetoCist.isNotPresent(changedField)) return;
|
|
25595
|
-
|
|
25596
|
-
onChange(dayjs("".concat(date.format(DATE_FORMAT), " ").concat(time.format(TIME_FORMAT))), changedField);
|
|
25597
|
-
} else {
|
|
25598
|
-
onChange(null, changedField);
|
|
25599
|
-
}
|
|
26659
|
+
onChange(getDateTime(date, time), changedField);
|
|
25600
26660
|
setChangedField(); // reset to avoid unnecessary trigger on rerender
|
|
25601
26661
|
}, [date, time, changedField]);
|
|
25602
26662
|
var handleDateChange = function handleDateChange(newDate) {
|
|
@@ -25612,6 +26672,10 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25612
26672
|
if (newTime.isValid() && !date) setDate(newTime);
|
|
25613
26673
|
setChangedField("time");
|
|
25614
26674
|
};
|
|
26675
|
+
var handleTimeBlur = function handleTimeBlur() {
|
|
26676
|
+
onTimeInputBlur(getDateTime(date, time));
|
|
26677
|
+
onBlur(getDateTime(date, time));
|
|
26678
|
+
};
|
|
25615
26679
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
25616
26680
|
className: "neeto-ui-input__wrapper"
|
|
25617
26681
|
}, label && /*#__PURE__*/React__default["default"].createElement(Label, _objectSpread$j({
|
|
@@ -25641,7 +26705,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25641
26705
|
error: error,
|
|
25642
26706
|
nakedInput: nakedInput,
|
|
25643
26707
|
size: size
|
|
25644
|
-
}, "error", !!error), "ref", timeRef), "value", time), "onBlur",
|
|
26708
|
+
}, "error", !!error), "ref", timeRef), "value", time), "onBlur", handleTimeBlur), "onChange", handleTimeChange), timePickerProps))), !!error && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
25645
26709
|
className: "neeto-ui-input__error",
|
|
25646
26710
|
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
25647
26711
|
id: errorId
|