@bigbinary/neetoui 6.2.5 → 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 +1147 -83
- package/index.cjs.js.map +1 -1
- package/index.css +4 -1
- package/index.d.ts +8 -4
- package/index.js +1147 -83
- package/index.js.map +1 -1
- package/package.json +3 -1
package/index.js
CHANGED
|
@@ -223,9 +223,9 @@ const MotionContext = createContext({});
|
|
|
223
223
|
*/
|
|
224
224
|
const PresenceContext = createContext(null);
|
|
225
225
|
|
|
226
|
-
const isBrowser$
|
|
226
|
+
const isBrowser$b = typeof document !== "undefined";
|
|
227
227
|
|
|
228
|
-
const useIsomorphicLayoutEffect$
|
|
228
|
+
const useIsomorphicLayoutEffect$3 = isBrowser$b ? useLayoutEffect : useEffect;
|
|
229
229
|
|
|
230
230
|
const LazyContext = createContext({ strict: false });
|
|
231
231
|
|
|
@@ -260,7 +260,7 @@ function useVisualElement(Component, visualState, props, createVisualElement) {
|
|
|
260
260
|
* was present on initial render - it will be deleted after this.
|
|
261
261
|
*/
|
|
262
262
|
const canHandoff = useRef(Boolean(window.HandoffAppearAnimations));
|
|
263
|
-
useIsomorphicLayoutEffect$
|
|
263
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
264
264
|
if (!visualElement)
|
|
265
265
|
return;
|
|
266
266
|
visualElement.render();
|
|
@@ -451,7 +451,7 @@ function createMotionComponent({ preloadedFeatures, createVisualElement, useRend
|
|
|
451
451
|
const { isStatic } = configAndProps;
|
|
452
452
|
const context = useCreateMotionContext(props);
|
|
453
453
|
const visualState = useVisualState(props, isStatic);
|
|
454
|
-
if (!isStatic && isBrowser$
|
|
454
|
+
if (!isStatic && isBrowser$b) {
|
|
455
455
|
/**
|
|
456
456
|
* Create a VisualElement for this component. A VisualElement provides a common
|
|
457
457
|
* interface to renderer-specific APIs (ie DOM/Three.js etc) as well as
|
|
@@ -2773,7 +2773,7 @@ function calcGeneratorVelocity(resolveValue, t, current) {
|
|
|
2773
2773
|
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
2774
2774
|
}
|
|
2775
2775
|
|
|
2776
|
-
const safeMin$
|
|
2776
|
+
const safeMin$2 = 0.001;
|
|
2777
2777
|
const minDuration = 0.01;
|
|
2778
2778
|
const maxDuration$1 = 10.0;
|
|
2779
2779
|
const minDamping = 0.05;
|
|
@@ -2798,7 +2798,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2798
2798
|
const a = exponentialDecay - velocity;
|
|
2799
2799
|
const b = calcAngularFreq(undampedFreq, dampingRatio);
|
|
2800
2800
|
const c = Math.exp(-delta);
|
|
2801
|
-
return safeMin$
|
|
2801
|
+
return safeMin$2 - (a / b) * c;
|
|
2802
2802
|
};
|
|
2803
2803
|
derivative = (undampedFreq) => {
|
|
2804
2804
|
const exponentialDecay = undampedFreq * dampingRatio;
|
|
@@ -2807,7 +2807,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2807
2807
|
const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq, 2) * duration;
|
|
2808
2808
|
const f = Math.exp(-delta);
|
|
2809
2809
|
const g = calcAngularFreq(Math.pow(undampedFreq, 2), dampingRatio);
|
|
2810
|
-
const factor = -envelope(undampedFreq) + safeMin$
|
|
2810
|
+
const factor = -envelope(undampedFreq) + safeMin$2 > 0 ? -1 : 1;
|
|
2811
2811
|
return (factor * ((d - e) * f)) / g;
|
|
2812
2812
|
};
|
|
2813
2813
|
}
|
|
@@ -2818,7 +2818,7 @@ function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, })
|
|
|
2818
2818
|
envelope = (undampedFreq) => {
|
|
2819
2819
|
const a = Math.exp(-undampedFreq * duration);
|
|
2820
2820
|
const b = (undampedFreq - velocity) * duration + 1;
|
|
2821
|
-
return -safeMin$
|
|
2821
|
+
return -safeMin$2 + a * b;
|
|
2822
2822
|
};
|
|
2823
2823
|
derivative = (undampedFreq) => {
|
|
2824
2824
|
const a = Math.exp(-undampedFreq * duration);
|
|
@@ -8343,7 +8343,7 @@ const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, tr
|
|
|
8343
8343
|
// Reapply original values
|
|
8344
8344
|
visualElement.render();
|
|
8345
8345
|
// Restore scroll position
|
|
8346
|
-
if (isBrowser$
|
|
8346
|
+
if (isBrowser$b && scrollY !== null) {
|
|
8347
8347
|
window.scrollTo({ top: scrollY });
|
|
8348
8348
|
}
|
|
8349
8349
|
return { target: convertedTarget, transitionEnd };
|
|
@@ -8382,7 +8382,7 @@ const hasReducedMotionListener = { current: false };
|
|
|
8382
8382
|
|
|
8383
8383
|
function initPrefersReducedMotion() {
|
|
8384
8384
|
hasReducedMotionListener.current = true;
|
|
8385
|
-
if (!isBrowser$
|
|
8385
|
+
if (!isBrowser$b)
|
|
8386
8386
|
return;
|
|
8387
8387
|
if (window.matchMedia) {
|
|
8388
8388
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
@@ -9068,7 +9068,7 @@ const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomM
|
|
|
9068
9068
|
|
|
9069
9069
|
function useIsMounted() {
|
|
9070
9070
|
const isMounted = useRef(false);
|
|
9071
|
-
useIsomorphicLayoutEffect$
|
|
9071
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
9072
9072
|
isMounted.current = true;
|
|
9073
9073
|
return () => {
|
|
9074
9074
|
isMounted.current = false;
|
|
@@ -9278,7 +9278,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
9278
9278
|
// If this is the initial component render, just deal with logic surrounding whether
|
|
9279
9279
|
// we play onMount animations or not.
|
|
9280
9280
|
const isInitialRender = useRef(true);
|
|
9281
|
-
useIsomorphicLayoutEffect$
|
|
9281
|
+
useIsomorphicLayoutEffect$3(() => {
|
|
9282
9282
|
isInitialRender.current = false;
|
|
9283
9283
|
updateChildLookup(filteredChildren, allChildren);
|
|
9284
9284
|
presentChildren.current = childrenToRender;
|
|
@@ -13876,8 +13876,8 @@ function bindGlobalEventListeners() {
|
|
|
13876
13876
|
window.addEventListener('blur', onWindowBlur);
|
|
13877
13877
|
}
|
|
13878
13878
|
|
|
13879
|
-
var isBrowser$
|
|
13880
|
-
var isIE11 = isBrowser$
|
|
13879
|
+
var isBrowser$a = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
13880
|
+
var isIE11 = isBrowser$a ? // @ts-ignore
|
|
13881
13881
|
!!window.msCrypto : false;
|
|
13882
13882
|
|
|
13883
13883
|
var pluginProps = {
|
|
@@ -15327,7 +15327,7 @@ function _objectWithoutPropertiesLoose$4(source, excluded) {
|
|
|
15327
15327
|
return target;
|
|
15328
15328
|
}
|
|
15329
15329
|
|
|
15330
|
-
var isBrowser$
|
|
15330
|
+
var isBrowser$9 = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
15331
15331
|
function preserveRef(ref, node) {
|
|
15332
15332
|
if (ref) {
|
|
15333
15333
|
if (typeof ref === 'function') {
|
|
@@ -15340,7 +15340,7 @@ function preserveRef(ref, node) {
|
|
|
15340
15340
|
}
|
|
15341
15341
|
}
|
|
15342
15342
|
function ssrSafeCreateDiv() {
|
|
15343
|
-
return isBrowser$
|
|
15343
|
+
return isBrowser$9 && document.createElement('div');
|
|
15344
15344
|
}
|
|
15345
15345
|
function toDataAttributes(attrs) {
|
|
15346
15346
|
var dataAttrs = {
|
|
@@ -15403,7 +15403,7 @@ function deepPreserveProps(instanceProps, componentProps) {
|
|
|
15403
15403
|
});
|
|
15404
15404
|
}
|
|
15405
15405
|
|
|
15406
|
-
var useIsomorphicLayoutEffect$
|
|
15406
|
+
var useIsomorphicLayoutEffect$2 = isBrowser$9 ? useLayoutEffect : useEffect;
|
|
15407
15407
|
function useMutableBox(initialValue) {
|
|
15408
15408
|
// Using refs instead of state as it's recommended to not store imperative
|
|
15409
15409
|
// values in state due to memory problems in React(?)
|
|
@@ -15542,7 +15542,7 @@ function TippyGenerator(tippy) {
|
|
|
15542
15542
|
|
|
15543
15543
|
var deps = [reference].concat(children ? [children.type] : []); // CREATE
|
|
15544
15544
|
|
|
15545
|
-
useIsomorphicLayoutEffect$
|
|
15545
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15546
15546
|
var element = reference;
|
|
15547
15547
|
|
|
15548
15548
|
if (reference && reference.hasOwnProperty('current')) {
|
|
@@ -15577,7 +15577,7 @@ function TippyGenerator(tippy) {
|
|
|
15577
15577
|
};
|
|
15578
15578
|
}, deps); // UPDATE
|
|
15579
15579
|
|
|
15580
|
-
useIsomorphicLayoutEffect$
|
|
15580
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15581
15581
|
var _instance$popperInsta;
|
|
15582
15582
|
|
|
15583
15583
|
// Prevent this effect from running on 1st render
|
|
@@ -15613,7 +15613,7 @@ function TippyGenerator(tippy) {
|
|
|
15613
15613
|
});
|
|
15614
15614
|
}
|
|
15615
15615
|
});
|
|
15616
|
-
useIsomorphicLayoutEffect$
|
|
15616
|
+
useIsomorphicLayoutEffect$2(function () {
|
|
15617
15617
|
var _instance$props$poppe;
|
|
15618
15618
|
|
|
15619
15619
|
if (!render) {
|
|
@@ -15889,7 +15889,7 @@ var Button = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
15889
15889
|
});
|
|
15890
15890
|
Button.displayName = "Button";
|
|
15891
15891
|
|
|
15892
|
-
var Divider$
|
|
15892
|
+
var Divider$2 = function Divider(props) {
|
|
15893
15893
|
return /*#__PURE__*/React__default.createElement("li", _extends$4({
|
|
15894
15894
|
className: "neeto-ui-dropdown__popup-divider"
|
|
15895
15895
|
}, props));
|
|
@@ -16162,7 +16162,7 @@ var Dropdown = function Dropdown(_ref2) {
|
|
|
16162
16162
|
};
|
|
16163
16163
|
Dropdown.Menu = Menu$3;
|
|
16164
16164
|
Dropdown.MenuItem = MenuItem$1;
|
|
16165
|
-
Dropdown.Divider = Divider$
|
|
16165
|
+
Dropdown.Divider = Divider$2;
|
|
16166
16166
|
|
|
16167
16167
|
var _excluded$D = ["style", "size"];
|
|
16168
16168
|
var BTN_STYLES = {
|
|
@@ -22833,7 +22833,7 @@ var customParseFormat$1 = {exports: {}};
|
|
|
22833
22833
|
|
|
22834
22834
|
var customParseFormat = customParseFormat$1.exports;
|
|
22835
22835
|
|
|
22836
|
-
var __spreadArray$
|
|
22836
|
+
var __spreadArray$3 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
22837
22837
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
22838
22838
|
if (ar || !(i in from)) {
|
|
22839
22839
|
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
@@ -22924,7 +22924,7 @@ var animationEvents = [
|
|
|
22924
22924
|
var transitionEvents = ['onTransitionEnd'];
|
|
22925
22925
|
var otherEvents = ['onToggle'];
|
|
22926
22926
|
var changeEvents = ['onChange'];
|
|
22927
|
-
var allEvents = __spreadArray$
|
|
22927
|
+
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);
|
|
22928
22928
|
/**
|
|
22929
22929
|
* Returns an object with on-event callback props curried with provided args.
|
|
22930
22930
|
* @param {Object} props Props passed to a component.
|
|
@@ -22950,8 +22950,6 @@ function makeEventProps(props, getArgs) {
|
|
|
22950
22950
|
return eventProps;
|
|
22951
22951
|
}
|
|
22952
22952
|
|
|
22953
|
-
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}
|
|
22954
|
-
|
|
22955
22953
|
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}
|
|
22956
22954
|
|
|
22957
22955
|
/**
|
|
@@ -23108,8 +23106,8 @@ function Mark(_a) {
|
|
|
23108
23106
|
} }, number)) : null));
|
|
23109
23107
|
}
|
|
23110
23108
|
|
|
23111
|
-
var __assign$
|
|
23112
|
-
__assign$
|
|
23109
|
+
var __assign$e = (undefined && undefined.__assign) || function () {
|
|
23110
|
+
__assign$e = Object.assign || function(t) {
|
|
23113
23111
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23114
23112
|
s = arguments[i];
|
|
23115
23113
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -23117,10 +23115,10 @@ var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
|
23117
23115
|
}
|
|
23118
23116
|
return t;
|
|
23119
23117
|
};
|
|
23120
|
-
return __assign$
|
|
23118
|
+
return __assign$e.apply(this, arguments);
|
|
23121
23119
|
};
|
|
23122
23120
|
var MinuteMark = memo$1(function MinuteMark(props) {
|
|
23123
|
-
return React__default.createElement(Mark, __assign$
|
|
23121
|
+
return React__default.createElement(Mark, __assign$e({}, props));
|
|
23124
23122
|
});
|
|
23125
23123
|
|
|
23126
23124
|
/**
|
|
@@ -23868,8 +23866,8 @@ function formatHour(locale, hour) {
|
|
|
23868
23866
|
return hour.toLocaleString(locale || getUserLocale() || undefined);
|
|
23869
23867
|
}
|
|
23870
23868
|
|
|
23871
|
-
var __assign$
|
|
23872
|
-
__assign$
|
|
23869
|
+
var __assign$d = (undefined && undefined.__assign) || function () {
|
|
23870
|
+
__assign$d = Object.assign || function(t) {
|
|
23873
23871
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23874
23872
|
s = arguments[i];
|
|
23875
23873
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -23877,9 +23875,9 @@ var __assign$7 = (undefined && undefined.__assign) || function () {
|
|
|
23877
23875
|
}
|
|
23878
23876
|
return t;
|
|
23879
23877
|
};
|
|
23880
|
-
return __assign$
|
|
23878
|
+
return __assign$d.apply(this, arguments);
|
|
23881
23879
|
};
|
|
23882
|
-
var __rest$
|
|
23880
|
+
var __rest$b = (undefined && undefined.__rest) || function (s, e) {
|
|
23883
23881
|
var t = {};
|
|
23884
23882
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23885
23883
|
t[p] = s[p];
|
|
@@ -23891,8 +23889,8 @@ var __rest$6 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
23891
23889
|
return t;
|
|
23892
23890
|
};
|
|
23893
23891
|
var HourMark = memo$1(function HourMark(_a) {
|
|
23894
|
-
var _b = _a.formatHour, formatHour$1 = _b === void 0 ? formatHour : _b, locale = _a.locale, number = _a.number, otherProps = __rest$
|
|
23895
|
-
return React__default.createElement(Mark, __assign$
|
|
23892
|
+
var _b = _a.formatHour, formatHour$1 = _b === void 0 ? formatHour : _b, locale = _a.locale, number = _a.number, otherProps = __rest$b(_a, ["formatHour", "locale", "number"]);
|
|
23893
|
+
return React__default.createElement(Mark, __assign$d({ number: number ? formatHour$1(locale, number) : null }, otherProps));
|
|
23896
23894
|
});
|
|
23897
23895
|
|
|
23898
23896
|
function isNumberBetween(min, max) {
|
|
@@ -24072,8 +24070,8 @@ var __extends = (undefined && undefined.__extends) || (function () {
|
|
|
24072
24070
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
24073
24071
|
};
|
|
24074
24072
|
})();
|
|
24075
|
-
var __assign$
|
|
24076
|
-
__assign$
|
|
24073
|
+
var __assign$c = (undefined && undefined.__assign) || function () {
|
|
24074
|
+
__assign$c = Object.assign || function(t) {
|
|
24077
24075
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24078
24076
|
s = arguments[i];
|
|
24079
24077
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
@@ -24081,9 +24079,9 @@ var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
|
24081
24079
|
}
|
|
24082
24080
|
return t;
|
|
24083
24081
|
};
|
|
24084
|
-
return __assign$
|
|
24082
|
+
return __assign$c.apply(this, arguments);
|
|
24085
24083
|
};
|
|
24086
|
-
var __rest$
|
|
24084
|
+
var __rest$a = (undefined && undefined.__rest) || function (s, e) {
|
|
24087
24085
|
var t = {};
|
|
24088
24086
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24089
24087
|
t[p] = s[p];
|
|
@@ -24094,9 +24092,9 @@ var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
|
24094
24092
|
}
|
|
24095
24093
|
return t;
|
|
24096
24094
|
};
|
|
24097
|
-
var isBrowser$
|
|
24098
|
-
var isDisplayContentsSupported = isBrowser$
|
|
24099
|
-
var isMutationObserverSupported = isBrowser$
|
|
24095
|
+
var isBrowser$8 = typeof document !== 'undefined';
|
|
24096
|
+
var isDisplayContentsSupported = isBrowser$8 && 'CSS' in window && 'supports' in window.CSS && CSS.supports('display', 'contents');
|
|
24097
|
+
var isMutationObserverSupported = isBrowser$8 && 'MutationObserver' in window;
|
|
24100
24098
|
function capitalize(string) {
|
|
24101
24099
|
return (string.charAt(0).toUpperCase() + string.slice(1));
|
|
24102
24100
|
}
|
|
@@ -24196,12 +24194,12 @@ function alignMainAxis(args) {
|
|
|
24196
24194
|
alignAxis(args);
|
|
24197
24195
|
}
|
|
24198
24196
|
function alignSecondaryAxis(args) {
|
|
24199
|
-
alignAxis(__assign$
|
|
24197
|
+
alignAxis(__assign$c(__assign$c({}, args), { axis: args.axis === 'x' ? 'y' : 'x', secondary: true }));
|
|
24200
24198
|
}
|
|
24201
24199
|
function alignBothAxis(args) {
|
|
24202
|
-
var invertAxis = args.invertAxis, invertSecondaryAxis = args.invertSecondaryAxis, commonArgs = __rest$
|
|
24203
|
-
alignMainAxis(__assign$
|
|
24204
|
-
alignSecondaryAxis(__assign$
|
|
24200
|
+
var invertAxis = args.invertAxis, invertSecondaryAxis = args.invertSecondaryAxis, commonArgs = __rest$a(args, ["invertAxis", "invertSecondaryAxis"]);
|
|
24201
|
+
alignMainAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertAxis }));
|
|
24202
|
+
alignSecondaryAxis(__assign$c(__assign$c({}, commonArgs), { invertAxis: invertSecondaryAxis }));
|
|
24205
24203
|
}
|
|
24206
24204
|
var Fit = /** @class */ (function (_super) {
|
|
24207
24205
|
__extends(Fit, _super);
|
|
@@ -24316,7 +24314,7 @@ var Fit = /** @class */ (function (_super) {
|
|
|
24316
24314
|
return Fit;
|
|
24317
24315
|
}(Component));
|
|
24318
24316
|
|
|
24319
|
-
function Divider(_a) {
|
|
24317
|
+
function Divider$1(_a) {
|
|
24320
24318
|
var children = _a.children;
|
|
24321
24319
|
return React__default.createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
|
|
24322
24320
|
}
|
|
@@ -24378,6 +24376,1026 @@ function updateInputWidth(element) {
|
|
|
24378
24376
|
return width;
|
|
24379
24377
|
}
|
|
24380
24378
|
|
|
24379
|
+
var isBrowser$7 = typeof document !== 'undefined';
|
|
24380
|
+
var useIsomorphicLayoutEffect$1 = isBrowser$7 ? useLayoutEffect : useEffect;
|
|
24381
|
+
var isIEOrEdgeLegacy$1 = isBrowser$7 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
|
|
24382
|
+
var isFirefox$1 = isBrowser$7 && /Firefox/.test(navigator.userAgent);
|
|
24383
|
+
function onFocus$1(event) {
|
|
24384
|
+
var target = event.target;
|
|
24385
|
+
if (isIEOrEdgeLegacy$1) {
|
|
24386
|
+
requestAnimationFrame(function () { return target.select(); });
|
|
24387
|
+
}
|
|
24388
|
+
else {
|
|
24389
|
+
target.select();
|
|
24390
|
+
}
|
|
24391
|
+
}
|
|
24392
|
+
function updateInputWidthOnLoad$1(element) {
|
|
24393
|
+
if (document.readyState === 'complete') {
|
|
24394
|
+
return;
|
|
24395
|
+
}
|
|
24396
|
+
function onLoad() {
|
|
24397
|
+
updateInputWidth(element);
|
|
24398
|
+
}
|
|
24399
|
+
window.addEventListener('load', onLoad);
|
|
24400
|
+
}
|
|
24401
|
+
function updateInputWidthOnFontLoad$1(element) {
|
|
24402
|
+
if (!document.fonts) {
|
|
24403
|
+
return;
|
|
24404
|
+
}
|
|
24405
|
+
var font = getFontShorthand(element);
|
|
24406
|
+
if (!font) {
|
|
24407
|
+
return;
|
|
24408
|
+
}
|
|
24409
|
+
var isFontLoaded = document.fonts.check(font);
|
|
24410
|
+
if (isFontLoaded) {
|
|
24411
|
+
return;
|
|
24412
|
+
}
|
|
24413
|
+
function onLoadingDone() {
|
|
24414
|
+
updateInputWidth(element);
|
|
24415
|
+
}
|
|
24416
|
+
document.fonts.addEventListener('loadingdone', onLoadingDone);
|
|
24417
|
+
}
|
|
24418
|
+
function getSelectionString$1(input) {
|
|
24419
|
+
/**
|
|
24420
|
+
* window.getSelection().toString() returns empty string in IE11 and Firefox,
|
|
24421
|
+
* so alternatives come first.
|
|
24422
|
+
*/
|
|
24423
|
+
if (input &&
|
|
24424
|
+
'selectionStart' in input &&
|
|
24425
|
+
input.selectionStart !== null &&
|
|
24426
|
+
'selectionEnd' in input &&
|
|
24427
|
+
input.selectionEnd !== null) {
|
|
24428
|
+
return input.value.slice(input.selectionStart, input.selectionEnd);
|
|
24429
|
+
}
|
|
24430
|
+
if ('getSelection' in window) {
|
|
24431
|
+
var selection = window.getSelection();
|
|
24432
|
+
return selection && selection.toString();
|
|
24433
|
+
}
|
|
24434
|
+
return null;
|
|
24435
|
+
}
|
|
24436
|
+
function makeOnKeyPress$1(maxLength) {
|
|
24437
|
+
if (maxLength === null) {
|
|
24438
|
+
return undefined;
|
|
24439
|
+
}
|
|
24440
|
+
/**
|
|
24441
|
+
* Prevents keystrokes that would not produce a number or when value after keystroke would
|
|
24442
|
+
* exceed maxLength.
|
|
24443
|
+
*/
|
|
24444
|
+
return function onKeyPress(event) {
|
|
24445
|
+
if (isFirefox$1) {
|
|
24446
|
+
// See https://github.com/wojtekmaj/react-time-picker/issues/92
|
|
24447
|
+
return;
|
|
24448
|
+
}
|
|
24449
|
+
var key = event.key, input = event.target;
|
|
24450
|
+
var value = input.value;
|
|
24451
|
+
var isNumberKey = key.length === 1 && /\d/.test(key);
|
|
24452
|
+
var selection = getSelectionString$1(input);
|
|
24453
|
+
if (!isNumberKey || !(selection || value.length < maxLength)) {
|
|
24454
|
+
event.preventDefault();
|
|
24455
|
+
}
|
|
24456
|
+
};
|
|
24457
|
+
}
|
|
24458
|
+
function Input$4(_a) {
|
|
24459
|
+
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;
|
|
24460
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
24461
|
+
if (!inputRef || !inputRef.current) {
|
|
24462
|
+
return;
|
|
24463
|
+
}
|
|
24464
|
+
updateInputWidth(inputRef.current);
|
|
24465
|
+
updateInputWidthOnLoad$1(inputRef.current);
|
|
24466
|
+
updateInputWidthOnFontLoad$1(inputRef.current);
|
|
24467
|
+
}, [inputRef, value]);
|
|
24468
|
+
var hasLeadingZero = showLeadingZeros &&
|
|
24469
|
+
value &&
|
|
24470
|
+
Number(value) < 10 &&
|
|
24471
|
+
(value === '0' || !value.toString().startsWith('0'));
|
|
24472
|
+
var maxLength = max ? max.toString().length : null;
|
|
24473
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
24474
|
+
hasLeadingZero ? React__default.createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
|
|
24475
|
+
React__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) {
|
|
24476
|
+
updateInputWidth(event.target);
|
|
24477
|
+
if (onKeyUp) {
|
|
24478
|
+
onKeyUp(event);
|
|
24479
|
+
}
|
|
24480
|
+
}, placeholder: placeholder, ref: inputRef, required: required, step: step, type: "number", value: value !== null ? value : '' })));
|
|
24481
|
+
}
|
|
24482
|
+
|
|
24483
|
+
function convert12to24$1(hour12, amPm) {
|
|
24484
|
+
var hour24 = Number(hour12);
|
|
24485
|
+
if (amPm === 'am' && hour24 === 12) {
|
|
24486
|
+
hour24 = 0;
|
|
24487
|
+
}
|
|
24488
|
+
else if (amPm === 'pm' && hour24 < 12) {
|
|
24489
|
+
hour24 += 12;
|
|
24490
|
+
}
|
|
24491
|
+
return hour24;
|
|
24492
|
+
}
|
|
24493
|
+
function convert24to12$1(hour24) {
|
|
24494
|
+
var hour12 = Number(hour24) % 12 || 12;
|
|
24495
|
+
return [hour12, Number(hour24) < 12 ? 'am' : 'pm'];
|
|
24496
|
+
}
|
|
24497
|
+
|
|
24498
|
+
var formatterCache$1 = new Map();
|
|
24499
|
+
function getFormatter$1(options) {
|
|
24500
|
+
return function formatter(locale, date) {
|
|
24501
|
+
var localeWithDefault = locale || getUserLocale();
|
|
24502
|
+
if (!formatterCache$1.has(localeWithDefault)) {
|
|
24503
|
+
formatterCache$1.set(localeWithDefault, new Map());
|
|
24504
|
+
}
|
|
24505
|
+
var formatterCacheLocale = formatterCache$1.get(localeWithDefault);
|
|
24506
|
+
if (!formatterCacheLocale.has(options)) {
|
|
24507
|
+
formatterCacheLocale.set(options, new Intl.DateTimeFormat(localeWithDefault || undefined, options).format);
|
|
24508
|
+
}
|
|
24509
|
+
return formatterCacheLocale.get(options)(date);
|
|
24510
|
+
};
|
|
24511
|
+
}
|
|
24512
|
+
var numberFormatterCache$1 = new Map();
|
|
24513
|
+
function getNumberFormatter$1(options) {
|
|
24514
|
+
return function (locale, number) {
|
|
24515
|
+
var localeWithDefault = locale || getUserLocale();
|
|
24516
|
+
if (!numberFormatterCache$1.has(localeWithDefault)) {
|
|
24517
|
+
numberFormatterCache$1.set(localeWithDefault, new Map());
|
|
24518
|
+
}
|
|
24519
|
+
var numberFormatterCacheLocale = numberFormatterCache$1.get(localeWithDefault);
|
|
24520
|
+
if (!numberFormatterCacheLocale.has(options)) {
|
|
24521
|
+
numberFormatterCacheLocale.set(options, new Intl.NumberFormat(localeWithDefault || undefined, options).format);
|
|
24522
|
+
}
|
|
24523
|
+
return numberFormatterCacheLocale.get(options)(number);
|
|
24524
|
+
};
|
|
24525
|
+
}
|
|
24526
|
+
|
|
24527
|
+
var nines$1 = ['9', '٩'];
|
|
24528
|
+
var ninesRegExp$1 = new RegExp("[".concat(nines$1.join(''), "]"));
|
|
24529
|
+
var amPmFormatter$1 = getFormatter$1({ hour: 'numeric' });
|
|
24530
|
+
function getAmPmLabels$1(locale) {
|
|
24531
|
+
var amString = amPmFormatter$1(locale, new Date(2017, 0, 1, 9));
|
|
24532
|
+
var pmString = amPmFormatter$1(locale, new Date(2017, 0, 1, 21));
|
|
24533
|
+
var _a = amString.split(ninesRegExp$1), am1 = _a[0], am2 = _a[1];
|
|
24534
|
+
var _b = pmString.split(ninesRegExp$1), pm1 = _b[0], pm2 = _b[1];
|
|
24535
|
+
if (pm2 !== undefined) {
|
|
24536
|
+
// If pm2 is undefined, nine was not found in pmString - this locale is not using 12-hour time
|
|
24537
|
+
if (am1 !== pm1) {
|
|
24538
|
+
return [am1, pm1].map(function (el) { return el.trim(); });
|
|
24539
|
+
}
|
|
24540
|
+
if (am2 !== pm2) {
|
|
24541
|
+
return [am2, pm2].map(function (el) { return el.trim(); });
|
|
24542
|
+
}
|
|
24543
|
+
}
|
|
24544
|
+
// Fallback
|
|
24545
|
+
return ['AM', 'PM'];
|
|
24546
|
+
}
|
|
24547
|
+
function isValidNumber$1(num) {
|
|
24548
|
+
return num !== null && num !== false && !Number.isNaN(Number(num));
|
|
24549
|
+
}
|
|
24550
|
+
function safeMin$1() {
|
|
24551
|
+
var args = [];
|
|
24552
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24553
|
+
args[_i] = arguments[_i];
|
|
24554
|
+
}
|
|
24555
|
+
return Math.min.apply(Math, args.filter(isValidNumber$1));
|
|
24556
|
+
}
|
|
24557
|
+
function safeMax$1() {
|
|
24558
|
+
var args = [];
|
|
24559
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
24560
|
+
args[_i] = arguments[_i];
|
|
24561
|
+
}
|
|
24562
|
+
return Math.max.apply(Math, args.filter(isValidNumber$1));
|
|
24563
|
+
}
|
|
24564
|
+
|
|
24565
|
+
var __assign$b = (undefined && undefined.__assign) || function () {
|
|
24566
|
+
__assign$b = Object.assign || function(t) {
|
|
24567
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24568
|
+
s = arguments[i];
|
|
24569
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24570
|
+
t[p] = s[p];
|
|
24571
|
+
}
|
|
24572
|
+
return t;
|
|
24573
|
+
};
|
|
24574
|
+
return __assign$b.apply(this, arguments);
|
|
24575
|
+
};
|
|
24576
|
+
var __rest$9 = (undefined && undefined.__rest) || function (s, e) {
|
|
24577
|
+
var t = {};
|
|
24578
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24579
|
+
t[p] = s[p];
|
|
24580
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
24581
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24582
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24583
|
+
t[p[i]] = s[p[i]];
|
|
24584
|
+
}
|
|
24585
|
+
return t;
|
|
24586
|
+
};
|
|
24587
|
+
function Hour12Input$1(_a) {
|
|
24588
|
+
var amPm = _a.amPm, maxTime = _a.maxTime, minTime = _a.minTime, value = _a.value, otherProps = __rest$9(_a, ["amPm", "maxTime", "minTime", "value"]);
|
|
24589
|
+
var maxHour = safeMin$1(12, maxTime &&
|
|
24590
|
+
(function () {
|
|
24591
|
+
var _a = convert24to12$1(getHours(maxTime)), maxHourResult = _a[0], maxAmPm = _a[1];
|
|
24592
|
+
if (maxAmPm !== amPm) {
|
|
24593
|
+
// pm is always after am, so we should ignore validation
|
|
24594
|
+
return null;
|
|
24595
|
+
}
|
|
24596
|
+
return maxHourResult;
|
|
24597
|
+
})());
|
|
24598
|
+
var minHour = safeMax$1(1, minTime &&
|
|
24599
|
+
(function () {
|
|
24600
|
+
var _a = convert24to12$1(getHours(minTime)), minHourResult = _a[0], minAmPm = _a[1];
|
|
24601
|
+
if (
|
|
24602
|
+
// pm is always after am, so we should ignore validation
|
|
24603
|
+
minAmPm !== amPm ||
|
|
24604
|
+
// If minHour is 12 am/pm, user should be able to enter 12, 1, ..., 11.
|
|
24605
|
+
minHourResult === 12) {
|
|
24606
|
+
return null;
|
|
24607
|
+
}
|
|
24608
|
+
return minHourResult;
|
|
24609
|
+
})());
|
|
24610
|
+
var value12 = value ? convert24to12$1(value)[0].toString() : '';
|
|
24611
|
+
return (React__default.createElement(Input$4, __assign$b({ max: maxHour, min: minHour, name: "hour12", nameForClass: "hour", value: value12 }, otherProps)));
|
|
24612
|
+
}
|
|
24613
|
+
|
|
24614
|
+
var __assign$a = (undefined && undefined.__assign) || function () {
|
|
24615
|
+
__assign$a = Object.assign || function(t) {
|
|
24616
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24617
|
+
s = arguments[i];
|
|
24618
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24619
|
+
t[p] = s[p];
|
|
24620
|
+
}
|
|
24621
|
+
return t;
|
|
24622
|
+
};
|
|
24623
|
+
return __assign$a.apply(this, arguments);
|
|
24624
|
+
};
|
|
24625
|
+
var __rest$8 = (undefined && undefined.__rest) || function (s, e) {
|
|
24626
|
+
var t = {};
|
|
24627
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24628
|
+
t[p] = s[p];
|
|
24629
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
24630
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24631
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24632
|
+
t[p[i]] = s[p[i]];
|
|
24633
|
+
}
|
|
24634
|
+
return t;
|
|
24635
|
+
};
|
|
24636
|
+
function Hour24Input$1(_a) {
|
|
24637
|
+
var maxTime = _a.maxTime, minTime = _a.minTime, otherProps = __rest$8(_a, ["maxTime", "minTime"]);
|
|
24638
|
+
var maxHour = safeMin$1(23, maxTime && getHours(maxTime));
|
|
24639
|
+
var minHour = safeMax$1(0, minTime && getHours(minTime));
|
|
24640
|
+
return React__default.createElement(Input$4, __assign$a({ max: maxHour, min: minHour, name: "hour24", nameForClass: "hour" }, otherProps));
|
|
24641
|
+
}
|
|
24642
|
+
|
|
24643
|
+
var __assign$9 = (undefined && undefined.__assign) || function () {
|
|
24644
|
+
__assign$9 = Object.assign || function(t) {
|
|
24645
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24646
|
+
s = arguments[i];
|
|
24647
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24648
|
+
t[p] = s[p];
|
|
24649
|
+
}
|
|
24650
|
+
return t;
|
|
24651
|
+
};
|
|
24652
|
+
return __assign$9.apply(this, arguments);
|
|
24653
|
+
};
|
|
24654
|
+
var __rest$7 = (undefined && undefined.__rest) || function (s, e) {
|
|
24655
|
+
var t = {};
|
|
24656
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24657
|
+
t[p] = s[p];
|
|
24658
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
24659
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24660
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24661
|
+
t[p[i]] = s[p[i]];
|
|
24662
|
+
}
|
|
24663
|
+
return t;
|
|
24664
|
+
};
|
|
24665
|
+
function MinuteInput$1(_a) {
|
|
24666
|
+
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"]);
|
|
24667
|
+
function isSameHour(date) {
|
|
24668
|
+
return hour === getHours(date).toString();
|
|
24669
|
+
}
|
|
24670
|
+
var maxMinute = safeMin$1(59, maxTime && isSameHour(maxTime) && getMinutes(maxTime));
|
|
24671
|
+
var minMinute = safeMax$1(0, minTime && isSameHour(minTime) && getMinutes(minTime));
|
|
24672
|
+
return (React__default.createElement(Input$4, __assign$9({ max: maxMinute, min: minMinute, name: "minute", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
24673
|
+
}
|
|
24674
|
+
|
|
24675
|
+
var __assign$8 = (undefined && undefined.__assign) || function () {
|
|
24676
|
+
__assign$8 = Object.assign || function(t) {
|
|
24677
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24678
|
+
s = arguments[i];
|
|
24679
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24680
|
+
t[p] = s[p];
|
|
24681
|
+
}
|
|
24682
|
+
return t;
|
|
24683
|
+
};
|
|
24684
|
+
return __assign$8.apply(this, arguments);
|
|
24685
|
+
};
|
|
24686
|
+
var __rest$6 = (undefined && undefined.__rest) || function (s, e) {
|
|
24687
|
+
var t = {};
|
|
24688
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24689
|
+
t[p] = s[p];
|
|
24690
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
24691
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24692
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24693
|
+
t[p[i]] = s[p[i]];
|
|
24694
|
+
}
|
|
24695
|
+
return t;
|
|
24696
|
+
};
|
|
24697
|
+
function SecondInput$1(_a) {
|
|
24698
|
+
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"]);
|
|
24699
|
+
function isSameMinute(date) {
|
|
24700
|
+
return hour === getHours(date).toString() && minute === getMinutes(date).toString();
|
|
24701
|
+
}
|
|
24702
|
+
var maxSecond = safeMin$1(59, maxTime && isSameMinute(maxTime) && getSeconds(maxTime));
|
|
24703
|
+
var minSecond = safeMax$1(0, minTime && isSameMinute(minTime) && getSeconds(minTime));
|
|
24704
|
+
return (React__default.createElement(Input$4, __assign$8({ max: maxSecond, min: minSecond, name: "second", showLeadingZeros: showLeadingZeros }, otherProps)));
|
|
24705
|
+
}
|
|
24706
|
+
|
|
24707
|
+
function NativeInput$1(_a) {
|
|
24708
|
+
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;
|
|
24709
|
+
var nativeValueParser = (function () {
|
|
24710
|
+
switch (valueType) {
|
|
24711
|
+
case 'hour':
|
|
24712
|
+
return function (receivedValue) { return "".concat(getHours(receivedValue), ":00"); };
|
|
24713
|
+
case 'minute':
|
|
24714
|
+
return getHoursMinutes;
|
|
24715
|
+
case 'second':
|
|
24716
|
+
return getHoursMinutesSeconds;
|
|
24717
|
+
default:
|
|
24718
|
+
throw new Error('Invalid valueType');
|
|
24719
|
+
}
|
|
24720
|
+
})();
|
|
24721
|
+
var step = (function () {
|
|
24722
|
+
switch (valueType) {
|
|
24723
|
+
case 'hour':
|
|
24724
|
+
return 3600;
|
|
24725
|
+
case 'minute':
|
|
24726
|
+
return 60;
|
|
24727
|
+
case 'second':
|
|
24728
|
+
return 1;
|
|
24729
|
+
default:
|
|
24730
|
+
throw new Error('Invalid valueType');
|
|
24731
|
+
}
|
|
24732
|
+
})();
|
|
24733
|
+
function stopPropagation(event) {
|
|
24734
|
+
event.stopPropagation();
|
|
24735
|
+
}
|
|
24736
|
+
return (React__default.createElement("input", { "aria-label": ariaLabel, disabled: disabled, hidden: true, max: maxTime ? nativeValueParser(maxTime) : undefined, min: minTime ? nativeValueParser(minTime) : undefined, name: name, onChange: onChange, onFocus: stopPropagation, required: required, step: step, style: {
|
|
24737
|
+
visibility: 'hidden',
|
|
24738
|
+
position: 'absolute',
|
|
24739
|
+
zIndex: '-999',
|
|
24740
|
+
}, type: "time", value: value ? nativeValueParser(value) : '' }));
|
|
24741
|
+
}
|
|
24742
|
+
|
|
24743
|
+
function AmPm$1(_a) {
|
|
24744
|
+
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;
|
|
24745
|
+
var amDisabled = minTime ? convert24to12$1(getHours(minTime))[1] === 'pm' : false;
|
|
24746
|
+
var pmDisabled = maxTime ? convert24to12$1(getHours(maxTime))[1] === 'am' : false;
|
|
24747
|
+
var name = 'amPm';
|
|
24748
|
+
var _b = getAmPmLabels$1(locale), amLabel = _b[0], pmLabel = _b[1];
|
|
24749
|
+
return (React__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 : '' },
|
|
24750
|
+
!value && React__default.createElement("option", { value: "" }, "--"),
|
|
24751
|
+
React__default.createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
|
|
24752
|
+
React__default.createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
|
|
24753
|
+
}
|
|
24754
|
+
|
|
24755
|
+
var __assign$7 = (undefined && undefined.__assign) || function () {
|
|
24756
|
+
__assign$7 = Object.assign || function(t) {
|
|
24757
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24758
|
+
s = arguments[i];
|
|
24759
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24760
|
+
t[p] = s[p];
|
|
24761
|
+
}
|
|
24762
|
+
return t;
|
|
24763
|
+
};
|
|
24764
|
+
return __assign$7.apply(this, arguments);
|
|
24765
|
+
};
|
|
24766
|
+
var __spreadArray$2 = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
24767
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
24768
|
+
if (ar || !(i in from)) {
|
|
24769
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
24770
|
+
ar[i] = from[i];
|
|
24771
|
+
}
|
|
24772
|
+
}
|
|
24773
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24774
|
+
};
|
|
24775
|
+
var getFormatterOptionsCache$1 = {};
|
|
24776
|
+
var allViews$4 = ['hour', 'minute', 'second'];
|
|
24777
|
+
function isInternalInput$1(element) {
|
|
24778
|
+
return element.dataset.input === 'true';
|
|
24779
|
+
}
|
|
24780
|
+
function findInput$1(element, property) {
|
|
24781
|
+
var nextElement = element;
|
|
24782
|
+
do {
|
|
24783
|
+
nextElement = nextElement[property];
|
|
24784
|
+
} while (nextElement && !isInternalInput$1(nextElement));
|
|
24785
|
+
return nextElement;
|
|
24786
|
+
}
|
|
24787
|
+
function focus$1(element) {
|
|
24788
|
+
if (element) {
|
|
24789
|
+
element.focus();
|
|
24790
|
+
}
|
|
24791
|
+
}
|
|
24792
|
+
function renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances) {
|
|
24793
|
+
var usedFunctions = [];
|
|
24794
|
+
var pattern = new RegExp(Object.keys(elementFunctions)
|
|
24795
|
+
.map(function (el) { return "".concat(el, "+"); })
|
|
24796
|
+
.join('|'), 'g');
|
|
24797
|
+
var matches = placeholder.match(pattern);
|
|
24798
|
+
return placeholder.split(pattern).reduce(function (arr, element, index) {
|
|
24799
|
+
var divider = element && (
|
|
24800
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
24801
|
+
React__default.createElement(Divider$1, { key: "separator_".concat(index) }, element));
|
|
24802
|
+
var res = __spreadArray$2(__spreadArray$2([], arr, true), [divider], false);
|
|
24803
|
+
var currentMatch = matches && matches[index];
|
|
24804
|
+
if (currentMatch) {
|
|
24805
|
+
var renderFunction = elementFunctions[currentMatch] ||
|
|
24806
|
+
elementFunctions[Object.keys(elementFunctions).find(function (elementFunction) {
|
|
24807
|
+
return currentMatch.match(elementFunction);
|
|
24808
|
+
})];
|
|
24809
|
+
if (!renderFunction) {
|
|
24810
|
+
return res;
|
|
24811
|
+
}
|
|
24812
|
+
if (!allowMultipleInstances && usedFunctions.includes(renderFunction)) {
|
|
24813
|
+
res.push(currentMatch);
|
|
24814
|
+
}
|
|
24815
|
+
else {
|
|
24816
|
+
res.push(renderFunction(currentMatch, index));
|
|
24817
|
+
usedFunctions.push(renderFunction);
|
|
24818
|
+
}
|
|
24819
|
+
}
|
|
24820
|
+
return res;
|
|
24821
|
+
}, []);
|
|
24822
|
+
}
|
|
24823
|
+
var formatNumber$1 = getNumberFormatter$1({ useGrouping: false });
|
|
24824
|
+
function TimeInput$1(_a) {
|
|
24825
|
+
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;
|
|
24826
|
+
var _e = useState(null), amPm = _e[0], setAmPm = _e[1];
|
|
24827
|
+
var _f = useState(null), hour = _f[0], setHour = _f[1];
|
|
24828
|
+
var _g = useState(null), minute = _g[0], setMinute = _g[1];
|
|
24829
|
+
var _h = useState(null), second = _h[0], setSecond = _h[1];
|
|
24830
|
+
var _j = useState(null), value = _j[0], setValue = _j[1];
|
|
24831
|
+
var amPmInput = useRef(null);
|
|
24832
|
+
var hour12Input = useRef(null);
|
|
24833
|
+
var hour24Input = useRef(null);
|
|
24834
|
+
var minuteInput = useRef(null);
|
|
24835
|
+
var secondInput = useRef(null);
|
|
24836
|
+
var _k = useState(isClockOpenProps), isClockOpen = _k[0], setIsClockOpen = _k[1];
|
|
24837
|
+
var lastPressedKey = useRef();
|
|
24838
|
+
useEffect(function () {
|
|
24839
|
+
setIsClockOpen(isClockOpenProps);
|
|
24840
|
+
}, [isClockOpenProps]);
|
|
24841
|
+
useEffect(function () {
|
|
24842
|
+
var nextValue = valueProps;
|
|
24843
|
+
if (nextValue) {
|
|
24844
|
+
setAmPm(convert24to12$1(getHours(nextValue))[1]);
|
|
24845
|
+
setHour(getHours(nextValue).toString());
|
|
24846
|
+
setMinute(getMinutes(nextValue).toString());
|
|
24847
|
+
setSecond(getSeconds(nextValue).toString());
|
|
24848
|
+
setValue(nextValue);
|
|
24849
|
+
}
|
|
24850
|
+
else {
|
|
24851
|
+
setAmPm(null);
|
|
24852
|
+
setHour(null);
|
|
24853
|
+
setMinute(null);
|
|
24854
|
+
setSecond(null);
|
|
24855
|
+
setValue(null);
|
|
24856
|
+
}
|
|
24857
|
+
}, [
|
|
24858
|
+
valueProps,
|
|
24859
|
+
minTime,
|
|
24860
|
+
maxTime,
|
|
24861
|
+
maxDetail,
|
|
24862
|
+
// Toggling clock visibility resets values
|
|
24863
|
+
isClockOpen,
|
|
24864
|
+
]);
|
|
24865
|
+
var valueType = maxDetail;
|
|
24866
|
+
var formatTime = (function () {
|
|
24867
|
+
var level = allViews$4.indexOf(maxDetail);
|
|
24868
|
+
var formatterOptions = getFormatterOptionsCache$1[level] ||
|
|
24869
|
+
(function () {
|
|
24870
|
+
var options = { hour: 'numeric' };
|
|
24871
|
+
if (level >= 1) {
|
|
24872
|
+
options.minute = 'numeric';
|
|
24873
|
+
}
|
|
24874
|
+
if (level >= 2) {
|
|
24875
|
+
options.second = 'numeric';
|
|
24876
|
+
}
|
|
24877
|
+
getFormatterOptionsCache$1[level] = options;
|
|
24878
|
+
return options;
|
|
24879
|
+
})();
|
|
24880
|
+
return getFormatter$1(formatterOptions);
|
|
24881
|
+
})();
|
|
24882
|
+
/**
|
|
24883
|
+
* Gets current value in a desired format.
|
|
24884
|
+
*/
|
|
24885
|
+
function getProcessedValue(value) {
|
|
24886
|
+
var processFunction = (function () {
|
|
24887
|
+
switch (valueType) {
|
|
24888
|
+
case 'hour':
|
|
24889
|
+
case 'minute':
|
|
24890
|
+
return getHoursMinutes;
|
|
24891
|
+
case 'second':
|
|
24892
|
+
return getHoursMinutesSeconds;
|
|
24893
|
+
default:
|
|
24894
|
+
throw new Error('Invalid valueType');
|
|
24895
|
+
}
|
|
24896
|
+
})();
|
|
24897
|
+
return processFunction(value);
|
|
24898
|
+
}
|
|
24899
|
+
var placeholder = format ||
|
|
24900
|
+
(function () {
|
|
24901
|
+
var hour24 = 21;
|
|
24902
|
+
var hour12 = 9;
|
|
24903
|
+
var minute = 13;
|
|
24904
|
+
var second = 14;
|
|
24905
|
+
var date = new Date(2017, 0, 1, hour24, minute, second);
|
|
24906
|
+
return formatTime(locale, date)
|
|
24907
|
+
.replace(formatNumber$1(locale, hour12), 'h')
|
|
24908
|
+
.replace(formatNumber$1(locale, hour24), 'H')
|
|
24909
|
+
.replace(formatNumber$1(locale, minute), 'mm')
|
|
24910
|
+
.replace(formatNumber$1(locale, second), 'ss')
|
|
24911
|
+
.replace(new RegExp(getAmPmLabels$1(locale).join('|')), 'a');
|
|
24912
|
+
})();
|
|
24913
|
+
var divider = (function () {
|
|
24914
|
+
var dividers = placeholder.match(/[^0-9a-z]/i);
|
|
24915
|
+
return dividers ? dividers[0] : null;
|
|
24916
|
+
})();
|
|
24917
|
+
function onClick(event) {
|
|
24918
|
+
if (event.target === event.currentTarget) {
|
|
24919
|
+
// Wrapper was directly clicked
|
|
24920
|
+
var firstInput = event.target.children[1];
|
|
24921
|
+
focus$1(firstInput);
|
|
24922
|
+
}
|
|
24923
|
+
}
|
|
24924
|
+
function onKeyDown(event) {
|
|
24925
|
+
lastPressedKey.current = event.key;
|
|
24926
|
+
switch (event.key) {
|
|
24927
|
+
case 'ArrowLeft':
|
|
24928
|
+
case 'ArrowRight':
|
|
24929
|
+
case divider: {
|
|
24930
|
+
event.preventDefault();
|
|
24931
|
+
var input = event.target;
|
|
24932
|
+
var property = event.key === 'ArrowLeft' ? 'previousElementSibling' : 'nextElementSibling';
|
|
24933
|
+
var nextInput = findInput$1(input, property);
|
|
24934
|
+
focus$1(nextInput);
|
|
24935
|
+
break;
|
|
24936
|
+
}
|
|
24937
|
+
}
|
|
24938
|
+
}
|
|
24939
|
+
function onKeyUp(event) {
|
|
24940
|
+
var key = event.key, input = event.target;
|
|
24941
|
+
var isLastPressedKey = lastPressedKey.current === key;
|
|
24942
|
+
if (!isLastPressedKey) {
|
|
24943
|
+
return;
|
|
24944
|
+
}
|
|
24945
|
+
var isNumberKey = !isNaN(Number(key));
|
|
24946
|
+
if (!isNumberKey) {
|
|
24947
|
+
return;
|
|
24948
|
+
}
|
|
24949
|
+
var max = input.getAttribute('max');
|
|
24950
|
+
if (!max) {
|
|
24951
|
+
return;
|
|
24952
|
+
}
|
|
24953
|
+
var value = input.value;
|
|
24954
|
+
/**
|
|
24955
|
+
* Given 1, the smallest possible number the user could type by adding another digit is 10.
|
|
24956
|
+
* 10 would be a valid value given max = 12, so we won't jump to the next input.
|
|
24957
|
+
* However, given 2, smallers possible number would be 20, and thus keeping the focus in
|
|
24958
|
+
* this field doesn't make sense.
|
|
24959
|
+
*/
|
|
24960
|
+
if (Number(value) * 10 > Number(max) || value.length >= max.length) {
|
|
24961
|
+
var property = 'nextElementSibling';
|
|
24962
|
+
var nextInput = findInput$1(input, property);
|
|
24963
|
+
focus$1(nextInput);
|
|
24964
|
+
}
|
|
24965
|
+
}
|
|
24966
|
+
/**
|
|
24967
|
+
* Called after internal onChange. Checks input validity. If all fields are valid,
|
|
24968
|
+
* calls props.onChange.
|
|
24969
|
+
*/
|
|
24970
|
+
function onChangeExternal() {
|
|
24971
|
+
if (!onChangeProps) {
|
|
24972
|
+
return;
|
|
24973
|
+
}
|
|
24974
|
+
function filterBoolean(value) {
|
|
24975
|
+
return Boolean(value);
|
|
24976
|
+
}
|
|
24977
|
+
var formElements = [
|
|
24978
|
+
amPmInput.current,
|
|
24979
|
+
hour12Input.current,
|
|
24980
|
+
hour24Input.current,
|
|
24981
|
+
minuteInput.current,
|
|
24982
|
+
secondInput.current,
|
|
24983
|
+
].filter(filterBoolean);
|
|
24984
|
+
var formElementsWithoutSelect = formElements.slice(1);
|
|
24985
|
+
var values = {};
|
|
24986
|
+
formElements.forEach(function (formElement) {
|
|
24987
|
+
values[formElement.name] =
|
|
24988
|
+
formElement.type === 'number'
|
|
24989
|
+
? 'valueAsNumber' in formElement
|
|
24990
|
+
? formElement.valueAsNumber
|
|
24991
|
+
: Number(formElement.value)
|
|
24992
|
+
: formElement.value;
|
|
24993
|
+
});
|
|
24994
|
+
var isEveryValueEmpty = formElementsWithoutSelect.every(function (formElement) { return !formElement.value; });
|
|
24995
|
+
if (isEveryValueEmpty) {
|
|
24996
|
+
onChangeProps(null, false);
|
|
24997
|
+
return;
|
|
24998
|
+
}
|
|
24999
|
+
var isEveryValueFilled = formElements.every(function (formElement) { return formElement.value; });
|
|
25000
|
+
var isEveryValueValid = formElements.every(function (formElement) { return formElement.validity.valid; });
|
|
25001
|
+
if (isEveryValueFilled && isEveryValueValid) {
|
|
25002
|
+
var hour_1 = Number(values.hour24 ||
|
|
25003
|
+
(values.hour12 && values.amPm && convert12to24$1(values.hour12, values.amPm)) ||
|
|
25004
|
+
0);
|
|
25005
|
+
var minute_1 = Number(values.minute || 0);
|
|
25006
|
+
var second_1 = Number(values.second || 0);
|
|
25007
|
+
var padStart = function (num) { return "0".concat(num).slice(-2); };
|
|
25008
|
+
var proposedValue = "".concat(padStart(hour_1), ":").concat(padStart(minute_1), ":").concat(padStart(second_1));
|
|
25009
|
+
var processedValue = getProcessedValue(proposedValue);
|
|
25010
|
+
onChangeProps(processedValue, false);
|
|
25011
|
+
return;
|
|
25012
|
+
}
|
|
25013
|
+
if (!onInvalidChange) {
|
|
25014
|
+
return;
|
|
25015
|
+
}
|
|
25016
|
+
onInvalidChange();
|
|
25017
|
+
}
|
|
25018
|
+
/**
|
|
25019
|
+
* Called when non-native date input is changed.
|
|
25020
|
+
*/
|
|
25021
|
+
function onChange(event) {
|
|
25022
|
+
var _a = event.target, name = _a.name, value = _a.value;
|
|
25023
|
+
switch (name) {
|
|
25024
|
+
case 'amPm':
|
|
25025
|
+
setAmPm(value);
|
|
25026
|
+
break;
|
|
25027
|
+
case 'hour12':
|
|
25028
|
+
setHour(value ? convert12to24$1(value, amPm || 'am').toString() : '');
|
|
25029
|
+
break;
|
|
25030
|
+
case 'hour24':
|
|
25031
|
+
setHour(value);
|
|
25032
|
+
break;
|
|
25033
|
+
case 'minute':
|
|
25034
|
+
setMinute(value);
|
|
25035
|
+
break;
|
|
25036
|
+
case 'second':
|
|
25037
|
+
setSecond(value);
|
|
25038
|
+
break;
|
|
25039
|
+
}
|
|
25040
|
+
onChangeExternal();
|
|
25041
|
+
}
|
|
25042
|
+
/**
|
|
25043
|
+
* Called when native date input is changed.
|
|
25044
|
+
*/
|
|
25045
|
+
function onChangeNative(event) {
|
|
25046
|
+
var value = event.target.value;
|
|
25047
|
+
if (!onChangeProps) {
|
|
25048
|
+
return;
|
|
25049
|
+
}
|
|
25050
|
+
var processedValue = value || null;
|
|
25051
|
+
onChangeProps(processedValue, false);
|
|
25052
|
+
}
|
|
25053
|
+
var commonInputProps = {
|
|
25054
|
+
className: className,
|
|
25055
|
+
disabled: disabled,
|
|
25056
|
+
maxTime: maxTime,
|
|
25057
|
+
minTime: minTime,
|
|
25058
|
+
onChange: onChange,
|
|
25059
|
+
onKeyDown: onKeyDown,
|
|
25060
|
+
onKeyUp: onKeyUp,
|
|
25061
|
+
// This is only for showing validity when editing
|
|
25062
|
+
required: Boolean(required || isClockOpen),
|
|
25063
|
+
};
|
|
25064
|
+
function renderHour12(currentMatch, index) {
|
|
25065
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
25066
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25067
|
+
}
|
|
25068
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25069
|
+
return (React__default.createElement(Hour12Input$1, __assign$7({ key: "hour12" }, commonInputProps, { amPm: amPm, ariaLabel: hourAriaLabel,
|
|
25070
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25071
|
+
autoFocus: index === 0 && autoFocus, inputRef: hour12Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
25072
|
+
}
|
|
25073
|
+
function renderHour24(currentMatch, index) {
|
|
25074
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
25075
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25076
|
+
}
|
|
25077
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25078
|
+
return (React__default.createElement(Hour24Input$1, __assign$7({ key: "hour24" }, commonInputProps, { ariaLabel: hourAriaLabel,
|
|
25079
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25080
|
+
autoFocus: index === 0 && autoFocus, inputRef: hour24Input, placeholder: hourPlaceholder, showLeadingZeros: showLeadingZeros, value: hour })));
|
|
25081
|
+
}
|
|
25082
|
+
function renderHour(currentMatch, index) {
|
|
25083
|
+
if (/h/.test(currentMatch)) {
|
|
25084
|
+
return renderHour12(currentMatch, index);
|
|
25085
|
+
}
|
|
25086
|
+
return renderHour24(currentMatch, index);
|
|
25087
|
+
}
|
|
25088
|
+
function renderMinute(currentMatch, index) {
|
|
25089
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
25090
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25091
|
+
}
|
|
25092
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : false;
|
|
25093
|
+
return (React__default.createElement(MinuteInput$1, __assign$7({ key: "minute" }, commonInputProps, { ariaLabel: minuteAriaLabel,
|
|
25094
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25095
|
+
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: minuteInput, placeholder: minutePlaceholder, showLeadingZeros: showLeadingZeros, value: minute })));
|
|
25096
|
+
}
|
|
25097
|
+
function renderSecond(currentMatch, index) {
|
|
25098
|
+
if (currentMatch && currentMatch.length > 2) {
|
|
25099
|
+
throw new Error("Unsupported token: ".concat(currentMatch));
|
|
25100
|
+
}
|
|
25101
|
+
var showLeadingZeros = currentMatch ? currentMatch.length === 2 : true;
|
|
25102
|
+
return (React__default.createElement(SecondInput$1, __assign$7({ key: "second" }, commonInputProps, { ariaLabel: secondAriaLabel,
|
|
25103
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25104
|
+
autoFocus: index === 0 && autoFocus, hour: hour, inputRef: secondInput, minute: minute, placeholder: secondPlaceholder, showLeadingZeros: showLeadingZeros, value: second })));
|
|
25105
|
+
}
|
|
25106
|
+
function renderAmPm(currentMatch, index) {
|
|
25107
|
+
return (React__default.createElement(AmPm$1, __assign$7({ key: "ampm" }, commonInputProps, { ariaLabel: amPmAriaLabel,
|
|
25108
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25109
|
+
autoFocus: index === 0 && autoFocus, inputRef: amPmInput, locale: locale, onChange: onChange, value: amPm })));
|
|
25110
|
+
}
|
|
25111
|
+
function renderCustomInputsInternal() {
|
|
25112
|
+
var elementFunctions = {
|
|
25113
|
+
h: renderHour,
|
|
25114
|
+
H: renderHour,
|
|
25115
|
+
m: renderMinute,
|
|
25116
|
+
s: renderSecond,
|
|
25117
|
+
a: renderAmPm,
|
|
25118
|
+
};
|
|
25119
|
+
var allowMultipleInstances = typeof format !== 'undefined';
|
|
25120
|
+
return renderCustomInputs$1(placeholder, elementFunctions, allowMultipleInstances);
|
|
25121
|
+
}
|
|
25122
|
+
function renderNativeInput() {
|
|
25123
|
+
return (React__default.createElement(NativeInput$1, { key: "time", ariaLabel: nativeInputAriaLabel, disabled: disabled, maxTime: maxTime, minTime: minTime, name: name, onChange: onChangeNative, required: required, value: value, valueType: valueType }));
|
|
25124
|
+
}
|
|
25125
|
+
return (
|
|
25126
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
25127
|
+
React__default.createElement("div", { className: className, onClick: onClick },
|
|
25128
|
+
renderNativeInput(),
|
|
25129
|
+
renderCustomInputsInternal()));
|
|
25130
|
+
}
|
|
25131
|
+
|
|
25132
|
+
var hourOptionalSecondsRegExp$1 = /^(([0-1])?[0-9]|2[0-3]):[0-5][0-9](:([0-5][0-9]))?$/;
|
|
25133
|
+
var isTime$1 = function isTime(props, propName, componentName) {
|
|
25134
|
+
var _a = props, _b = propName, time = _a[_b];
|
|
25135
|
+
if (time) {
|
|
25136
|
+
if (typeof time !== 'string' || !hourOptionalSecondsRegExp$1.test(time)) {
|
|
25137
|
+
return new Error("Invalid prop `".concat(propName, "` of type `").concat(typeof time, "` supplied to `").concat(componentName, "`, expected time in HH:mm(:ss) format."));
|
|
25138
|
+
}
|
|
25139
|
+
}
|
|
25140
|
+
// Everything is fine
|
|
25141
|
+
return null;
|
|
25142
|
+
};
|
|
25143
|
+
var rangeOf$1 = function (type) {
|
|
25144
|
+
return propTypes$1.exports.arrayOf(type);
|
|
25145
|
+
};
|
|
25146
|
+
|
|
25147
|
+
var __assign$6 = (undefined && undefined.__assign) || function () {
|
|
25148
|
+
__assign$6 = Object.assign || function(t) {
|
|
25149
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25150
|
+
s = arguments[i];
|
|
25151
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
25152
|
+
t[p] = s[p];
|
|
25153
|
+
}
|
|
25154
|
+
return t;
|
|
25155
|
+
};
|
|
25156
|
+
return __assign$6.apply(this, arguments);
|
|
25157
|
+
};
|
|
25158
|
+
var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
25159
|
+
var t = {};
|
|
25160
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25161
|
+
t[p] = s[p];
|
|
25162
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25163
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
25164
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25165
|
+
t[p[i]] = s[p[i]];
|
|
25166
|
+
}
|
|
25167
|
+
return t;
|
|
25168
|
+
};
|
|
25169
|
+
var isBrowser$6 = typeof document !== 'undefined';
|
|
25170
|
+
var baseClassName$1 = 'react-timerange-picker';
|
|
25171
|
+
var outsideActionEvents$1 = ['mousedown', 'focusin', 'touchstart'];
|
|
25172
|
+
var allViews$3 = ['hour', 'minute', 'second'];
|
|
25173
|
+
var iconProps$1 = {
|
|
25174
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
25175
|
+
width: 19,
|
|
25176
|
+
height: 19,
|
|
25177
|
+
viewBox: '0 0 19 19',
|
|
25178
|
+
stroke: 'black',
|
|
25179
|
+
strokeWidth: 2,
|
|
25180
|
+
};
|
|
25181
|
+
var ClockIcon$1 = (React__default.createElement("svg", __assign$6({}, iconProps$1, { className: "".concat(baseClassName$1, "__clock-button__icon ").concat(baseClassName$1, "__button__icon"), fill: "none" }),
|
|
25182
|
+
React__default.createElement("circle", { cx: "9.5", cy: "9.5", r: "7.5" }),
|
|
25183
|
+
React__default.createElement("path", { d: "M9.5 4.5 v5 h4" })));
|
|
25184
|
+
var ClearIcon$1 = (React__default.createElement("svg", __assign$6({}, iconProps$1, { className: "".concat(baseClassName$1, "__clear-button__icon ").concat(baseClassName$1, "__button__icon") }),
|
|
25185
|
+
React__default.createElement("line", { x1: "4", x2: "15", y1: "4", y2: "15" }),
|
|
25186
|
+
React__default.createElement("line", { x1: "15", x2: "4", y1: "4", y2: "15" })));
|
|
25187
|
+
var TimeRangePicker = function TimeRangePicker(props) {
|
|
25188
|
+
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"]);
|
|
25189
|
+
var _j = useState(isOpenProps), isOpen = _j[0], setIsOpen = _j[1];
|
|
25190
|
+
var wrapper = useRef(null);
|
|
25191
|
+
var clockWrapper = useRef(null);
|
|
25192
|
+
useEffect(function () {
|
|
25193
|
+
setIsOpen(isOpenProps);
|
|
25194
|
+
}, [isOpenProps]);
|
|
25195
|
+
function openClock(_a) {
|
|
25196
|
+
var reason = _a.reason;
|
|
25197
|
+
if (shouldOpenClock) {
|
|
25198
|
+
if (!shouldOpenClock({ reason: reason })) {
|
|
25199
|
+
return;
|
|
25200
|
+
}
|
|
25201
|
+
}
|
|
25202
|
+
setIsOpen(true);
|
|
25203
|
+
if (onClockOpen) {
|
|
25204
|
+
onClockOpen();
|
|
25205
|
+
}
|
|
25206
|
+
}
|
|
25207
|
+
var closeClock = useCallback(function (_a) {
|
|
25208
|
+
var reason = _a.reason;
|
|
25209
|
+
if (shouldCloseClock) {
|
|
25210
|
+
if (!shouldCloseClock({ reason: reason })) {
|
|
25211
|
+
return;
|
|
25212
|
+
}
|
|
25213
|
+
}
|
|
25214
|
+
setIsOpen(false);
|
|
25215
|
+
if (onClockClose) {
|
|
25216
|
+
onClockClose();
|
|
25217
|
+
}
|
|
25218
|
+
}, [onClockClose, shouldCloseClock]);
|
|
25219
|
+
function toggleClock() {
|
|
25220
|
+
if (isOpen) {
|
|
25221
|
+
closeClock({ reason: 'buttonClick' });
|
|
25222
|
+
}
|
|
25223
|
+
else {
|
|
25224
|
+
openClock({ reason: 'buttonClick' });
|
|
25225
|
+
}
|
|
25226
|
+
}
|
|
25227
|
+
function onChange(value, shouldCloseClock) {
|
|
25228
|
+
if (shouldCloseClock === void 0) { shouldCloseClock = shouldCloseClockOnSelect; }
|
|
25229
|
+
if (shouldCloseClock) {
|
|
25230
|
+
closeClock({ reason: 'select' });
|
|
25231
|
+
}
|
|
25232
|
+
if (onChangeProps) {
|
|
25233
|
+
onChangeProps(value);
|
|
25234
|
+
}
|
|
25235
|
+
}
|
|
25236
|
+
function onChangeFrom(valueFrom, closeClock) {
|
|
25237
|
+
var _a = Array.isArray(value) ? value : [value], valueTo = _a[1];
|
|
25238
|
+
onChange([valueFrom, valueTo || null], closeClock);
|
|
25239
|
+
}
|
|
25240
|
+
function onChangeTo(valueTo, closeClock) {
|
|
25241
|
+
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
25242
|
+
onChange([valueFrom || null, valueTo], closeClock);
|
|
25243
|
+
}
|
|
25244
|
+
function onFocus(event) {
|
|
25245
|
+
if (onFocusProps) {
|
|
25246
|
+
onFocusProps(event);
|
|
25247
|
+
}
|
|
25248
|
+
if (
|
|
25249
|
+
// Internet Explorer still fires onFocus on disabled elements
|
|
25250
|
+
disabled ||
|
|
25251
|
+
isOpen ||
|
|
25252
|
+
!openClockOnFocus ||
|
|
25253
|
+
event.target.dataset.select === 'true') {
|
|
25254
|
+
return;
|
|
25255
|
+
}
|
|
25256
|
+
openClock({ reason: 'focus' });
|
|
25257
|
+
}
|
|
25258
|
+
var onKeyDown = useCallback(function (event) {
|
|
25259
|
+
if (event.key === 'Escape') {
|
|
25260
|
+
closeClock({ reason: 'escape' });
|
|
25261
|
+
}
|
|
25262
|
+
}, [closeClock]);
|
|
25263
|
+
function clear() {
|
|
25264
|
+
onChange(null);
|
|
25265
|
+
}
|
|
25266
|
+
function stopPropagation(event) {
|
|
25267
|
+
event.stopPropagation();
|
|
25268
|
+
}
|
|
25269
|
+
var onOutsideAction = useCallback(function (event) {
|
|
25270
|
+
var wrapperEl = wrapper.current;
|
|
25271
|
+
var clockWrapperEl = clockWrapper.current;
|
|
25272
|
+
// Try event.composedPath first to handle clicks inside a Shadow DOM.
|
|
25273
|
+
var target = ('composedPath' in event ? event.composedPath()[0] : event.target);
|
|
25274
|
+
if (target &&
|
|
25275
|
+
wrapperEl &&
|
|
25276
|
+
!wrapperEl.contains(target) &&
|
|
25277
|
+
(!clockWrapperEl || !clockWrapperEl.contains(target))) {
|
|
25278
|
+
closeClock({ reason: 'outsideAction' });
|
|
25279
|
+
}
|
|
25280
|
+
}, [clockWrapper, closeClock, wrapper]);
|
|
25281
|
+
var handleOutsideActionListeners = useCallback(function (shouldListen) {
|
|
25282
|
+
if (shouldListen === void 0) { shouldListen = isOpen; }
|
|
25283
|
+
outsideActionEvents$1.forEach(function (event) {
|
|
25284
|
+
if (shouldListen) {
|
|
25285
|
+
document.addEventListener(event, onOutsideAction);
|
|
25286
|
+
}
|
|
25287
|
+
else {
|
|
25288
|
+
document.removeEventListener(event, onOutsideAction);
|
|
25289
|
+
}
|
|
25290
|
+
});
|
|
25291
|
+
if (shouldListen) {
|
|
25292
|
+
document.addEventListener('keydown', onKeyDown);
|
|
25293
|
+
}
|
|
25294
|
+
else {
|
|
25295
|
+
document.removeEventListener('keydown', onKeyDown);
|
|
25296
|
+
}
|
|
25297
|
+
}, [isOpen, onOutsideAction, onKeyDown]);
|
|
25298
|
+
useEffect(function () {
|
|
25299
|
+
handleOutsideActionListeners();
|
|
25300
|
+
return function () {
|
|
25301
|
+
handleOutsideActionListeners(false);
|
|
25302
|
+
};
|
|
25303
|
+
}, [handleOutsideActionListeners, isOpen]);
|
|
25304
|
+
function renderInputs() {
|
|
25305
|
+
var _a = Array.isArray(value) ? value : [value], valueFrom = _a[0], valueTo = _a[1];
|
|
25306
|
+
var ariaLabelProps = {
|
|
25307
|
+
amPmAriaLabel: amPmAriaLabel,
|
|
25308
|
+
hourAriaLabel: hourAriaLabel,
|
|
25309
|
+
minuteAriaLabel: minuteAriaLabel,
|
|
25310
|
+
nativeInputAriaLabel: nativeInputAriaLabel,
|
|
25311
|
+
secondAriaLabel: secondAriaLabel,
|
|
25312
|
+
};
|
|
25313
|
+
var placeholderProps = {
|
|
25314
|
+
hourPlaceholder: hourPlaceholder,
|
|
25315
|
+
minutePlaceholder: minutePlaceholder,
|
|
25316
|
+
secondPlaceholder: secondPlaceholder,
|
|
25317
|
+
};
|
|
25318
|
+
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 });
|
|
25319
|
+
return (React__default.createElement("div", { className: "".concat(baseClassName$1, "__wrapper") },
|
|
25320
|
+
React__default.createElement(TimeInput$1, __assign$6({}, commonProps, {
|
|
25321
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
25322
|
+
autoFocus: autoFocus, name: "".concat(name, "_from"), onChange: onChangeFrom, value: valueFrom })),
|
|
25323
|
+
React__default.createElement("span", { className: "".concat(baseClassName$1, "__range-divider") }, rangeDivider),
|
|
25324
|
+
React__default.createElement(TimeInput$1, __assign$6({}, commonProps, { name: "".concat(name, "_to"), onChange: onChangeTo, value: valueTo })),
|
|
25325
|
+
clearIcon !== null && (React__default.createElement("button", { "aria-label": clearAriaLabel, className: "".concat(baseClassName$1, "__clear-button ").concat(baseClassName$1, "__button"), disabled: disabled, onClick: clear, onFocus: stopPropagation, type: "button" }, typeof clearIcon === 'function' ? React__default.createElement(clearIcon) : clearIcon)),
|
|
25326
|
+
clockIcon !== null && !disableClock && (React__default.createElement("button", { "aria-label": clockAriaLabel, className: "".concat(baseClassName$1, "__clock-button ").concat(baseClassName$1, "__button"), disabled: disabled, onClick: toggleClock, onFocus: stopPropagation, type: "button" }, typeof clockIcon === 'function' ? React__default.createElement(clockIcon) : clockIcon))));
|
|
25327
|
+
}
|
|
25328
|
+
function renderClock() {
|
|
25329
|
+
if (isOpen === null || disableClock) {
|
|
25330
|
+
return null;
|
|
25331
|
+
}
|
|
25332
|
+
var clockClassName = props.clockClassName; props.className; // Unused, here to exclude it from clockProps
|
|
25333
|
+
props.onChange; // Unused, here to exclude it from clockProps
|
|
25334
|
+
var portalContainer = props.portalContainer, value = props.value, clockProps = __rest$5(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
|
|
25335
|
+
var className = "".concat(baseClassName$1, "__clock");
|
|
25336
|
+
var classNames = clsx$1(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
|
|
25337
|
+
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
25338
|
+
var clock = React__default.createElement(Clock, __assign$6({ className: clockClassName, value: valueFrom }, clockProps));
|
|
25339
|
+
return portalContainer ? (createPortal(React__default.createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default.createElement(Fit, null,
|
|
25340
|
+
React__default.createElement("div", { ref: function (ref) {
|
|
25341
|
+
if (ref && !isOpen) {
|
|
25342
|
+
ref.removeAttribute('style');
|
|
25343
|
+
}
|
|
25344
|
+
}, className: classNames }, clock)));
|
|
25345
|
+
}
|
|
25346
|
+
var eventProps = useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
|
|
25347
|
+
return (React__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 }),
|
|
25348
|
+
renderInputs(),
|
|
25349
|
+
renderClock()));
|
|
25350
|
+
};
|
|
25351
|
+
var isValue$1 = propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.instanceOf(Date)]);
|
|
25352
|
+
var isValueOrValueArray$1 = propTypes$1.exports.oneOfType([isValue$1, rangeOf$1(isValue$1)]);
|
|
25353
|
+
TimeRangePicker.propTypes = {
|
|
25354
|
+
amPmAriaLabel: propTypes$1.exports.string,
|
|
25355
|
+
autoFocus: propTypes$1.exports.bool,
|
|
25356
|
+
className: propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.arrayOf(propTypes$1.exports.string)]),
|
|
25357
|
+
clearAriaLabel: propTypes$1.exports.string,
|
|
25358
|
+
clearIcon: propTypes$1.exports.oneOfType([propTypes$1.exports.node, propTypes$1.exports.func]),
|
|
25359
|
+
clockAriaLabel: propTypes$1.exports.string,
|
|
25360
|
+
clockClassName: propTypes$1.exports.oneOfType([propTypes$1.exports.string, propTypes$1.exports.arrayOf(propTypes$1.exports.string)]),
|
|
25361
|
+
clockIcon: propTypes$1.exports.oneOfType([propTypes$1.exports.node, propTypes$1.exports.func]),
|
|
25362
|
+
closeClock: propTypes$1.exports.bool,
|
|
25363
|
+
'data-testid': propTypes$1.exports.string,
|
|
25364
|
+
disableClock: propTypes$1.exports.bool,
|
|
25365
|
+
disabled: propTypes$1.exports.bool,
|
|
25366
|
+
format: propTypes$1.exports.string,
|
|
25367
|
+
hourAriaLabel: propTypes$1.exports.string,
|
|
25368
|
+
hourPlaceholder: propTypes$1.exports.string,
|
|
25369
|
+
id: propTypes$1.exports.string,
|
|
25370
|
+
isOpen: propTypes$1.exports.bool,
|
|
25371
|
+
locale: propTypes$1.exports.string,
|
|
25372
|
+
maxDetail: propTypes$1.exports.oneOf(allViews$3),
|
|
25373
|
+
maxTime: isTime$1,
|
|
25374
|
+
minTime: isTime$1,
|
|
25375
|
+
minuteAriaLabel: propTypes$1.exports.string,
|
|
25376
|
+
minutePlaceholder: propTypes$1.exports.string,
|
|
25377
|
+
name: propTypes$1.exports.string,
|
|
25378
|
+
nativeInputAriaLabel: propTypes$1.exports.string,
|
|
25379
|
+
onChange: propTypes$1.exports.func,
|
|
25380
|
+
onClockClose: propTypes$1.exports.func,
|
|
25381
|
+
onClockOpen: propTypes$1.exports.func,
|
|
25382
|
+
onFocus: propTypes$1.exports.func,
|
|
25383
|
+
openClockOnFocus: propTypes$1.exports.bool,
|
|
25384
|
+
rangeDivider: propTypes$1.exports.node,
|
|
25385
|
+
required: propTypes$1.exports.bool,
|
|
25386
|
+
secondAriaLabel: propTypes$1.exports.string,
|
|
25387
|
+
secondPlaceholder: propTypes$1.exports.string,
|
|
25388
|
+
value: isValueOrValueArray$1,
|
|
25389
|
+
};
|
|
25390
|
+
if (isBrowser$6) {
|
|
25391
|
+
TimeRangePicker.propTypes.portalContainer = propTypes$1.exports.instanceOf(HTMLElement);
|
|
25392
|
+
}
|
|
25393
|
+
|
|
25394
|
+
function Divider(_a) {
|
|
25395
|
+
var children = _a.children;
|
|
25396
|
+
return React__default.createElement("span", { className: "react-time-picker__inputGroup__divider" }, children);
|
|
25397
|
+
}
|
|
25398
|
+
|
|
24381
25399
|
var isBrowser$5 = typeof document !== 'undefined';
|
|
24382
25400
|
var useIsomorphicLayoutEffect = isBrowser$5 ? useLayoutEffect : useEffect;
|
|
24383
25401
|
var isIEOrEdgeLegacy = isBrowser$5 && /(MSIE|Trident\/|Edge\/)/.test(navigator.userAgent);
|
|
@@ -24474,7 +25492,7 @@ function Input$3(_a) {
|
|
|
24474
25492
|
var maxLength = max ? max.toString().length : null;
|
|
24475
25493
|
return (React__default.createElement(React__default.Fragment, null,
|
|
24476
25494
|
hasLeadingZero ? React__default.createElement("span", { className: "".concat(className, "__leadingZero") }, "0") : null,
|
|
24477
|
-
React__default.createElement("input", { "aria-label": ariaLabel, autoComplete: "off", autoFocus: autoFocus, className: clsx$
|
|
25495
|
+
React__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) {
|
|
24478
25496
|
updateInputWidth(event.target);
|
|
24479
25497
|
if (onKeyUp) {
|
|
24480
25498
|
onKeyUp(event);
|
|
@@ -24748,7 +25766,7 @@ function AmPm(_a) {
|
|
|
24748
25766
|
var pmDisabled = maxTime ? convert24to12(getHours(maxTime))[1] === 'am' : false;
|
|
24749
25767
|
var name = 'amPm';
|
|
24750
25768
|
var _b = getAmPmLabels(locale), amLabel = _b[0], pmLabel = _b[1];
|
|
24751
|
-
return (React__default.createElement("select", { "aria-label": ariaLabel, autoFocus: autoFocus, className: clsx$
|
|
25769
|
+
return (React__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 : '' },
|
|
24752
25770
|
!value && React__default.createElement("option", { value: "" }, "--"),
|
|
24753
25771
|
React__default.createElement("option", { disabled: amDisabled, value: "am" }, amLabel),
|
|
24754
25772
|
React__default.createElement("option", { disabled: pmDisabled, value: "pm" }, pmLabel)));
|
|
@@ -25342,7 +26360,7 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25342
26360
|
props.onChange; // Unused, here to exclude it from clockProps
|
|
25343
26361
|
var portalContainer = props.portalContainer, value = props.value, clockProps = __rest(props, ["clockClassName", "className", "onChange", "portalContainer", "value"]);
|
|
25344
26362
|
var className = "".concat(baseClassName, "__clock");
|
|
25345
|
-
var classNames = clsx$
|
|
26363
|
+
var classNames = clsx$1(className, "".concat(className, "--").concat(isOpen ? 'open' : 'closed'));
|
|
25346
26364
|
var valueFrom = (Array.isArray(value) ? value : [value])[0];
|
|
25347
26365
|
var clock = React__default.createElement(Clock, __assign({ className: clockClassName, value: valueFrom }, clockProps));
|
|
25348
26366
|
return portalContainer ? (createPortal(React__default.createElement("div", { ref: clockWrapper, className: classNames }, clock), portalContainer)) : (React__default.createElement(Fit, null,
|
|
@@ -25353,7 +26371,7 @@ var TimePicker$1 = function TimePicker(props) {
|
|
|
25353
26371
|
}, className: classNames }, clock)));
|
|
25354
26372
|
}
|
|
25355
26373
|
var eventProps = useMemo(function () { return makeEventProps(otherProps); }, [otherProps]);
|
|
25356
|
-
return (React__default.createElement("div", __assign({ className: clsx$
|
|
26374
|
+
return (React__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 }),
|
|
25357
26375
|
renderInputs(),
|
|
25358
26376
|
renderClock()));
|
|
25359
26377
|
};
|
|
@@ -25420,7 +26438,29 @@ var HoverIcon = function HoverIcon(_ref) {
|
|
|
25420
26438
|
}));
|
|
25421
26439
|
};
|
|
25422
26440
|
|
|
25423
|
-
var
|
|
26441
|
+
var FORMAT = "HH:mm";
|
|
26442
|
+
var getFormattedTime = function getFormattedTime(value) {
|
|
26443
|
+
if (dayjs.isDayjs(value)) {
|
|
26444
|
+
return value.toDate();
|
|
26445
|
+
} else if (value instanceof Date || dayjs(value, FORMAT).isValid()) {
|
|
26446
|
+
return value;
|
|
26447
|
+
}
|
|
26448
|
+
return null;
|
|
26449
|
+
};
|
|
26450
|
+
var getFormattedRange = function getFormattedRange(value) {
|
|
26451
|
+
if (!Array.isArray(value)) return null;
|
|
26452
|
+
return value.map(function (item) {
|
|
26453
|
+
return getFormattedTime(item);
|
|
26454
|
+
});
|
|
26455
|
+
};
|
|
26456
|
+
var toDayJs = function toDayJs(value) {
|
|
26457
|
+
if (Array.isArray(value)) return value.map(function (item) {
|
|
26458
|
+
return dayjs(item, FORMAT);
|
|
26459
|
+
});
|
|
26460
|
+
return dayjs(value, FORMAT);
|
|
26461
|
+
};
|
|
26462
|
+
|
|
26463
|
+
var _excluded$v = ["type", "className", "label", "labelProps", "size", "nakedInput", "required", "value", "defaultValue", "onChange", "error", "onBlur"];
|
|
25424
26464
|
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; }
|
|
25425
26465
|
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; }
|
|
25426
26466
|
dayjs.extend(customParseFormat);
|
|
@@ -25429,9 +26469,14 @@ var INPUT_SIZES$1 = {
|
|
|
25429
26469
|
medium: "medium",
|
|
25430
26470
|
large: "large"
|
|
25431
26471
|
};
|
|
25432
|
-
var
|
|
26472
|
+
var timeComponents = {
|
|
26473
|
+
range: TimeRangePicker,
|
|
26474
|
+
time: TimePicker$1
|
|
26475
|
+
};
|
|
25433
26476
|
var TimePickerInput = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
|
|
25434
|
-
var _ref$
|
|
26477
|
+
var _ref$type = _ref.type,
|
|
26478
|
+
type = _ref$type === void 0 ? "time" : _ref$type,
|
|
26479
|
+
_ref$className = _ref.className,
|
|
25435
26480
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
25436
26481
|
label = _ref.label,
|
|
25437
26482
|
labelProps = _ref.labelProps,
|
|
@@ -25442,30 +26487,44 @@ var TimePickerInput = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
|
|
|
25442
26487
|
_ref$required = _ref.required,
|
|
25443
26488
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
25444
26489
|
inputValue = _ref.value,
|
|
25445
|
-
|
|
26490
|
+
defaultValue = _ref.defaultValue,
|
|
26491
|
+
_ref$onChange = _ref.onChange,
|
|
26492
|
+
onChange = _ref$onChange === void 0 ? noop$3 : _ref$onChange,
|
|
25446
26493
|
_ref$error = _ref.error,
|
|
25447
26494
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
25448
26495
|
_ref$onBlur = _ref.onBlur,
|
|
25449
26496
|
onBlur = _ref$onBlur === void 0 ? noop$3 : _ref$onBlur,
|
|
25450
26497
|
otherProps = _objectWithoutProperties$1(_ref, _excluded$v);
|
|
25451
|
-
var
|
|
25452
|
-
|
|
25453
|
-
|
|
25454
|
-
|
|
25455
|
-
return null;
|
|
25456
|
-
}, [inputValue]);
|
|
26498
|
+
var _useState = useState(null),
|
|
26499
|
+
_useState2 = _slicedToArray$3(_useState, 2),
|
|
26500
|
+
value = _useState2[0],
|
|
26501
|
+
setValue = _useState2[1];
|
|
25457
26502
|
var id = useId(otherProps.id);
|
|
25458
26503
|
var errorId = "error_".concat(id);
|
|
26504
|
+
useEffect(function () {
|
|
26505
|
+
if (isNotPresent(inputValue) && isNotPresent(defaultValue)) return;
|
|
26506
|
+
setValue((type === "range" ? getFormattedRange : getFormattedTime)(inputValue || defaultValue));
|
|
26507
|
+
}, [type, inputValue]);
|
|
25459
26508
|
var handleChange = function handleChange(newValue) {
|
|
25460
|
-
|
|
25461
|
-
onChange(
|
|
26509
|
+
setValue(newValue);
|
|
26510
|
+
onChange(toDayJs(newValue), newValue);
|
|
26511
|
+
};
|
|
26512
|
+
var handleShouldCloseClock = function handleShouldCloseClock() {
|
|
26513
|
+
onBlur(toDayJs(value), value);
|
|
26514
|
+
return true;
|
|
26515
|
+
};
|
|
26516
|
+
var handleKeyDown = function handleKeyDown(_ref2) {
|
|
26517
|
+
var code = _ref2.code;
|
|
26518
|
+
if (code !== "Enter") return;
|
|
26519
|
+
onBlur(toDayJs(value), value);
|
|
25462
26520
|
};
|
|
26521
|
+
var Component = timeComponents[type];
|
|
25463
26522
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
25464
26523
|
ref: ref,
|
|
25465
26524
|
className: "neeto-ui-input__wrapper"
|
|
25466
26525
|
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$k({
|
|
25467
26526
|
required: required
|
|
25468
|
-
}, labelProps), label), /*#__PURE__*/React__default.createElement(
|
|
26527
|
+
}, labelProps), label), /*#__PURE__*/React__default.createElement(Component, _extends$4({
|
|
25469
26528
|
id: id,
|
|
25470
26529
|
value: value,
|
|
25471
26530
|
disableClock: true,
|
|
@@ -25476,6 +26535,7 @@ var TimePickerInput = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
|
|
|
25476
26535
|
hourPlaceholder: "HH",
|
|
25477
26536
|
minutePlaceholder: "mm",
|
|
25478
26537
|
secondAriaLabel: "ss",
|
|
26538
|
+
shouldCloseClock: handleShouldCloseClock,
|
|
25479
26539
|
className: classnames$1("neeto-ui-time-picker", [className], {
|
|
25480
26540
|
"neeto-ui-time-picker--small": size === "small",
|
|
25481
26541
|
"neeto-ui-time-picker--medium": size === "medium",
|
|
@@ -25484,13 +26544,8 @@ var TimePickerInput = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
|
|
|
25484
26544
|
"neeto-ui-time-picker--naked": nakedInput,
|
|
25485
26545
|
"neeto-ui-time-picker--error": !!error
|
|
25486
26546
|
}),
|
|
25487
|
-
|
|
25488
|
-
|
|
25489
|
-
if (reason !== "outsideAction") return true;
|
|
25490
|
-
onBlur();
|
|
25491
|
-
return true;
|
|
25492
|
-
},
|
|
25493
|
-
onChange: handleChange
|
|
26547
|
+
onChange: handleChange,
|
|
26548
|
+
onKeyDown: handleKeyDown
|
|
25494
26549
|
}, otherProps)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
|
|
25495
26550
|
className: "neeto-ui-input__error",
|
|
25496
26551
|
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
@@ -25499,11 +26554,18 @@ var TimePickerInput = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
|
|
|
25499
26554
|
});
|
|
25500
26555
|
TimePickerInput.displayName = "TimePicker";
|
|
25501
26556
|
|
|
26557
|
+
var DATE_FORMAT = "YYYY-MM-DD";
|
|
26558
|
+
var TIME_FORMAT = "HH:mm";
|
|
26559
|
+
var getDateTime = function getDateTime(date, time) {
|
|
26560
|
+
if (isPresent(date) && isPresent(time)) {
|
|
26561
|
+
return dayjs("".concat(date.format(DATE_FORMAT), " ").concat(time.format(TIME_FORMAT)));
|
|
26562
|
+
}
|
|
26563
|
+
return null;
|
|
26564
|
+
};
|
|
26565
|
+
|
|
25502
26566
|
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; }
|
|
25503
26567
|
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; }
|
|
25504
26568
|
dayjs.extend(customParseFormat);
|
|
25505
|
-
var DATE_FORMAT = "YYYY-MM-DD";
|
|
25506
|
-
var TIME_FORMAT = "HH:mm";
|
|
25507
26569
|
var DateTimePicker = function DateTimePicker(_ref) {
|
|
25508
26570
|
var _ref$className = _ref.className,
|
|
25509
26571
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
@@ -25525,10 +26587,12 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25525
26587
|
_ref$required = _ref.required,
|
|
25526
26588
|
required = _ref$required === void 0 ? false : _ref$required,
|
|
25527
26589
|
id = _ref.id,
|
|
26590
|
+
datePickerProps = _ref.datePickerProps,
|
|
26591
|
+
timePickerProps = _ref.timePickerProps,
|
|
25528
26592
|
_ref$onTimeInputBlur = _ref.onTimeInputBlur,
|
|
25529
26593
|
onTimeInputBlur = _ref$onTimeInputBlur === void 0 ? noop$3 : _ref$onTimeInputBlur,
|
|
25530
|
-
|
|
25531
|
-
|
|
26594
|
+
_ref$onBlur = _ref.onBlur,
|
|
26595
|
+
onBlur = _ref$onBlur === void 0 ? noop$3 : _ref$onBlur;
|
|
25532
26596
|
var _useState = useState(datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.open),
|
|
25533
26597
|
_useState2 = _slicedToArray$3(_useState, 2),
|
|
25534
26598
|
open = _useState2[0],
|
|
@@ -25558,11 +26622,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25558
26622
|
}, [value, defaultValue]);
|
|
25559
26623
|
useEffect(function () {
|
|
25560
26624
|
if (isNotPresent(changedField)) return;
|
|
25561
|
-
|
|
25562
|
-
onChange(dayjs("".concat(date.format(DATE_FORMAT), " ").concat(time.format(TIME_FORMAT))), changedField);
|
|
25563
|
-
} else {
|
|
25564
|
-
onChange(null, changedField);
|
|
25565
|
-
}
|
|
26625
|
+
onChange(getDateTime(date, time), changedField);
|
|
25566
26626
|
setChangedField(); // reset to avoid unnecessary trigger on rerender
|
|
25567
26627
|
}, [date, time, changedField]);
|
|
25568
26628
|
var handleDateChange = function handleDateChange(newDate) {
|
|
@@ -25578,6 +26638,10 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25578
26638
|
if (newTime.isValid() && !date) setDate(newTime);
|
|
25579
26639
|
setChangedField("time");
|
|
25580
26640
|
};
|
|
26641
|
+
var handleTimeBlur = function handleTimeBlur() {
|
|
26642
|
+
onTimeInputBlur(getDateTime(date, time));
|
|
26643
|
+
onBlur(getDateTime(date, time));
|
|
26644
|
+
};
|
|
25581
26645
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
25582
26646
|
className: "neeto-ui-input__wrapper"
|
|
25583
26647
|
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$j({
|
|
@@ -25607,7 +26671,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
25607
26671
|
error: error,
|
|
25608
26672
|
nakedInput: nakedInput,
|
|
25609
26673
|
size: size
|
|
25610
|
-
}, "error", !!error), "ref", timeRef), "value", time), "onBlur",
|
|
26674
|
+
}, "error", !!error), "ref", timeRef), "value", time), "onBlur", handleTimeBlur), "onChange", handleTimeChange), timePickerProps))), !!error && /*#__PURE__*/React__default.createElement("p", {
|
|
25611
26675
|
className: "neeto-ui-input__error",
|
|
25612
26676
|
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
25613
26677
|
id: errorId
|
|
@@ -35899,7 +36963,7 @@ var useTableSort = function useTableSort() {
|
|
|
35899
36963
|
var history = useHistory();
|
|
35900
36964
|
var handleTableChange = function handleTableChange(pagination, sorter) {
|
|
35901
36965
|
var params = {
|
|
35902
|
-
sort_by: sorter.order
|
|
36966
|
+
sort_by: sorter.order ? camelToSnakeCase(sorter.field) : undefined,
|
|
35903
36967
|
order_by: URL_SORT_ORDERS[sorter.order],
|
|
35904
36968
|
page: pagination.current
|
|
35905
36969
|
};
|