trotl-filter 1.0.3 → 1.0.5
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/dist/index.cjs.js +3068 -492
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +3030 -457
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import React__default, { useState, useCallback, forwardRef, useContext, useLayoutEffect, useRef, useMemo, createContext, Component, Fragment, useEffect } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
|
|
@@ -202,14 +202,14 @@ function useStateManager(_ref) {
|
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function _extends() {
|
|
206
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
205
|
+
function _extends$1() {
|
|
206
|
+
return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
|
|
207
207
|
for (var e = 1; e < arguments.length; e++) {
|
|
208
208
|
var t = arguments[e];
|
|
209
209
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
210
210
|
}
|
|
211
211
|
return n;
|
|
212
|
-
}, _extends.apply(null, arguments);
|
|
212
|
+
}, _extends$1.apply(null, arguments);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
function _classCallCheck(a, n) {
|
|
@@ -1548,6 +1548,10 @@ var createCache = function createCache(options) {
|
|
|
1548
1548
|
return cache;
|
|
1549
1549
|
};
|
|
1550
1550
|
|
|
1551
|
+
function getDefaultExportFromCjs (x) {
|
|
1552
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1551
1555
|
var reactIs = {exports: {}};
|
|
1552
1556
|
|
|
1553
1557
|
var reactIs_production_min = {};
|
|
@@ -2274,12 +2278,12 @@ var syncFallback = function syncFallback(create) {
|
|
|
2274
2278
|
return create();
|
|
2275
2279
|
};
|
|
2276
2280
|
|
|
2277
|
-
var useInsertionEffect = React
|
|
2281
|
+
var useInsertionEffect = React['useInsertion' + 'Effect'] ? React['useInsertion' + 'Effect'] : false;
|
|
2278
2282
|
var useInsertionEffectAlwaysWithSyncFallback = !isBrowser$1 ? syncFallback : useInsertionEffect || syncFallback;
|
|
2279
2283
|
|
|
2280
2284
|
var isBrowser = typeof document !== 'undefined';
|
|
2281
2285
|
|
|
2282
|
-
var EmotionCacheContext = /* #__PURE__ */React
|
|
2286
|
+
var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
|
|
2283
2287
|
// because this module is primarily intended for the browser and node
|
|
2284
2288
|
// but it's also required in react native and similar environments sometimes
|
|
2285
2289
|
// and we could have a special build just for that
|
|
@@ -2313,7 +2317,7 @@ if (!isBrowser) {
|
|
|
2313
2317
|
cache = createCache({
|
|
2314
2318
|
key: 'css'
|
|
2315
2319
|
});
|
|
2316
|
-
return /*#__PURE__*/React
|
|
2320
|
+
return /*#__PURE__*/React.createElement(EmotionCacheContext.Provider, {
|
|
2317
2321
|
value: cache
|
|
2318
2322
|
}, func(props, cache));
|
|
2319
2323
|
} else {
|
|
@@ -2323,7 +2327,7 @@ if (!isBrowser) {
|
|
|
2323
2327
|
};
|
|
2324
2328
|
}
|
|
2325
2329
|
|
|
2326
|
-
var ThemeContext = /* #__PURE__ */React
|
|
2330
|
+
var ThemeContext = /* #__PURE__ */React.createContext({});
|
|
2327
2331
|
|
|
2328
2332
|
var hasOwn = {}.hasOwnProperty;
|
|
2329
2333
|
|
|
@@ -2363,7 +2367,7 @@ var Insertion = function Insertion(_ref) {
|
|
|
2363
2367
|
next = next.next;
|
|
2364
2368
|
}
|
|
2365
2369
|
|
|
2366
|
-
return /*#__PURE__*/React
|
|
2370
|
+
return /*#__PURE__*/React.createElement("style", (_ref2 = {}, _ref2["data-emotion"] = cache.key + " " + serializedNames, _ref2.dangerouslySetInnerHTML = {
|
|
2367
2371
|
__html: rules
|
|
2368
2372
|
}, _ref2.nonce = cache.sheet.nonce, _ref2));
|
|
2369
2373
|
}
|
|
@@ -2390,7 +2394,7 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2390
2394
|
className = props.className + " ";
|
|
2391
2395
|
}
|
|
2392
2396
|
|
|
2393
|
-
var serialized = serializeStyles(registeredStyles, undefined, React
|
|
2397
|
+
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
|
2394
2398
|
|
|
2395
2399
|
className += cache.key + "-" + serialized.name;
|
|
2396
2400
|
var newProps = {};
|
|
@@ -2407,11 +2411,11 @@ var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
|
|
2407
2411
|
newProps.ref = ref;
|
|
2408
2412
|
}
|
|
2409
2413
|
|
|
2410
|
-
return /*#__PURE__*/React
|
|
2414
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
|
2411
2415
|
cache: cache,
|
|
2412
2416
|
serialized: serialized,
|
|
2413
2417
|
isStringTag: typeof WrappedComponent === 'string'
|
|
2414
|
-
}), /*#__PURE__*/React
|
|
2418
|
+
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
|
2415
2419
|
});
|
|
2416
2420
|
|
|
2417
2421
|
var Emotion$1 = Emotion;
|
|
@@ -2421,7 +2425,7 @@ var jsx = function jsx(type, props) {
|
|
|
2421
2425
|
var args = arguments;
|
|
2422
2426
|
|
|
2423
2427
|
if (props == null || !hasOwn.call(props, 'css')) {
|
|
2424
|
-
return React
|
|
2428
|
+
return React.createElement.apply(undefined, args);
|
|
2425
2429
|
}
|
|
2426
2430
|
|
|
2427
2431
|
var argsLength = args.length;
|
|
@@ -2433,7 +2437,7 @@ var jsx = function jsx(type, props) {
|
|
|
2433
2437
|
createElementArgArray[i] = args[i];
|
|
2434
2438
|
}
|
|
2435
2439
|
|
|
2436
|
-
return React
|
|
2440
|
+
return React.createElement.apply(null, createElementArgArray);
|
|
2437
2441
|
};
|
|
2438
2442
|
|
|
2439
2443
|
(function (_jsx) {
|
|
@@ -3437,7 +3441,7 @@ var Menu = function Menu(props) {
|
|
|
3437
3441
|
var children = props.children,
|
|
3438
3442
|
innerRef = props.innerRef,
|
|
3439
3443
|
innerProps = props.innerProps;
|
|
3440
|
-
return jsx("div", _extends({}, getStyleProps(props, 'menu', {
|
|
3444
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'menu', {
|
|
3441
3445
|
menu: true
|
|
3442
3446
|
}), {
|
|
3443
3447
|
ref: innerRef
|
|
@@ -3468,7 +3472,7 @@ var MenuList = function MenuList(props) {
|
|
|
3468
3472
|
innerProps = props.innerProps,
|
|
3469
3473
|
innerRef = props.innerRef,
|
|
3470
3474
|
isMulti = props.isMulti;
|
|
3471
|
-
return jsx("div", _extends({}, getStyleProps(props, 'menuList', {
|
|
3475
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'menuList', {
|
|
3472
3476
|
'menu-list': true,
|
|
3473
3477
|
'menu-list--is-multi': isMulti
|
|
3474
3478
|
}), {
|
|
@@ -3498,7 +3502,7 @@ var NoOptionsMessage = function NoOptionsMessage(_ref6) {
|
|
|
3498
3502
|
children = _ref6$children === void 0 ? 'No options' : _ref6$children,
|
|
3499
3503
|
innerProps = _ref6.innerProps,
|
|
3500
3504
|
restProps = _objectWithoutProperties(_ref6, _excluded$3);
|
|
3501
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3505
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3502
3506
|
children: children,
|
|
3503
3507
|
innerProps: innerProps
|
|
3504
3508
|
}), 'noOptionsMessage', {
|
|
@@ -3511,7 +3515,7 @@ var LoadingMessage = function LoadingMessage(_ref7) {
|
|
|
3511
3515
|
children = _ref7$children === void 0 ? 'Loading...' : _ref7$children,
|
|
3512
3516
|
innerProps = _ref7.innerProps,
|
|
3513
3517
|
restProps = _objectWithoutProperties(_ref7, _excluded2$1);
|
|
3514
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3518
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3515
3519
|
children: children,
|
|
3516
3520
|
innerProps: innerProps
|
|
3517
3521
|
}), 'loadingMessage', {
|
|
@@ -3596,7 +3600,7 @@ var MenuPortal = function MenuPortal(props) {
|
|
|
3596
3600
|
if (!appendTo && menuPosition !== 'fixed' || !computedPosition) return null;
|
|
3597
3601
|
|
|
3598
3602
|
// same wrapper element whether fixed or portalled
|
|
3599
|
-
var menuWrapper = jsx("div", _extends({
|
|
3603
|
+
var menuWrapper = jsx("div", _extends$1({
|
|
3600
3604
|
ref: setMenuPortalElement
|
|
3601
3605
|
}, getStyleProps(_objectSpread2(_objectSpread2({}, props), {}, {
|
|
3602
3606
|
offset: computedPosition.offset,
|
|
@@ -3630,7 +3634,7 @@ var SelectContainer = function SelectContainer(props) {
|
|
|
3630
3634
|
innerProps = props.innerProps,
|
|
3631
3635
|
isDisabled = props.isDisabled,
|
|
3632
3636
|
isRtl = props.isRtl;
|
|
3633
|
-
return jsx("div", _extends({}, getStyleProps(props, 'container', {
|
|
3637
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'container', {
|
|
3634
3638
|
'--is-disabled': isDisabled,
|
|
3635
3639
|
'--is-rtl': isRtl
|
|
3636
3640
|
}), innerProps), children);
|
|
@@ -3662,7 +3666,7 @@ var ValueContainer = function ValueContainer(props) {
|
|
|
3662
3666
|
innerProps = props.innerProps,
|
|
3663
3667
|
isMulti = props.isMulti,
|
|
3664
3668
|
hasValue = props.hasValue;
|
|
3665
|
-
return jsx("div", _extends({}, getStyleProps(props, 'valueContainer', {
|
|
3669
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'valueContainer', {
|
|
3666
3670
|
'value-container': true,
|
|
3667
3671
|
'value-container--is-multi': isMulti,
|
|
3668
3672
|
'value-container--has-value': hasValue
|
|
@@ -3684,7 +3688,7 @@ var indicatorsContainerCSS = function indicatorsContainerCSS() {
|
|
|
3684
3688
|
var IndicatorsContainer = function IndicatorsContainer(props) {
|
|
3685
3689
|
var children = props.children,
|
|
3686
3690
|
innerProps = props.innerProps;
|
|
3687
|
-
return jsx("div", _extends({}, getStyleProps(props, 'indicatorsContainer', {
|
|
3691
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'indicatorsContainer', {
|
|
3688
3692
|
indicators: true
|
|
3689
3693
|
}), innerProps), children);
|
|
3690
3694
|
};
|
|
@@ -3709,7 +3713,7 @@ var _ref2$2 = process.env.NODE_ENV === "production" ? {
|
|
|
3709
3713
|
var Svg = function Svg(_ref) {
|
|
3710
3714
|
var size = _ref.size,
|
|
3711
3715
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
3712
|
-
return jsx("svg", _extends({
|
|
3716
|
+
return jsx("svg", _extends$1({
|
|
3713
3717
|
height: size,
|
|
3714
3718
|
width: size,
|
|
3715
3719
|
viewBox: "0 0 20 20",
|
|
@@ -3719,14 +3723,14 @@ var Svg = function Svg(_ref) {
|
|
|
3719
3723
|
}, props));
|
|
3720
3724
|
};
|
|
3721
3725
|
var CrossIcon = function CrossIcon(props) {
|
|
3722
|
-
return jsx(Svg, _extends({
|
|
3726
|
+
return jsx(Svg, _extends$1({
|
|
3723
3727
|
size: 20
|
|
3724
3728
|
}, props), jsx("path", {
|
|
3725
3729
|
d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"
|
|
3726
3730
|
}));
|
|
3727
3731
|
};
|
|
3728
3732
|
var DownChevron = function DownChevron(props) {
|
|
3729
|
-
return jsx(Svg, _extends({
|
|
3733
|
+
return jsx(Svg, _extends$1({
|
|
3730
3734
|
size: 20
|
|
3731
3735
|
}, props), jsx("path", {
|
|
3732
3736
|
d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
|
|
@@ -3758,7 +3762,7 @@ var dropdownIndicatorCSS = baseCSS;
|
|
|
3758
3762
|
var DropdownIndicator = function DropdownIndicator(props) {
|
|
3759
3763
|
var children = props.children,
|
|
3760
3764
|
innerProps = props.innerProps;
|
|
3761
|
-
return jsx("div", _extends({}, getStyleProps(props, 'dropdownIndicator', {
|
|
3765
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'dropdownIndicator', {
|
|
3762
3766
|
indicator: true,
|
|
3763
3767
|
'dropdown-indicator': true
|
|
3764
3768
|
}), innerProps), children || jsx(DownChevron, null));
|
|
@@ -3767,7 +3771,7 @@ var clearIndicatorCSS = baseCSS;
|
|
|
3767
3771
|
var ClearIndicator = function ClearIndicator(props) {
|
|
3768
3772
|
var children = props.children,
|
|
3769
3773
|
innerProps = props.innerProps;
|
|
3770
|
-
return jsx("div", _extends({}, getStyleProps(props, 'clearIndicator', {
|
|
3774
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'clearIndicator', {
|
|
3771
3775
|
indicator: true,
|
|
3772
3776
|
'clear-indicator': true
|
|
3773
3777
|
}), innerProps), children || jsx(CrossIcon, null));
|
|
@@ -3794,7 +3798,7 @@ var indicatorSeparatorCSS = function indicatorSeparatorCSS(_ref4, unstyled) {
|
|
|
3794
3798
|
};
|
|
3795
3799
|
var IndicatorSeparator = function IndicatorSeparator(props) {
|
|
3796
3800
|
var innerProps = props.innerProps;
|
|
3797
|
-
return jsx("span", _extends({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
3801
|
+
return jsx("span", _extends$1({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
3798
3802
|
'indicator-separator': true
|
|
3799
3803
|
})));
|
|
3800
3804
|
};
|
|
@@ -3847,7 +3851,7 @@ var LoadingIndicator = function LoadingIndicator(_ref7) {
|
|
|
3847
3851
|
_ref7$size = _ref7.size,
|
|
3848
3852
|
size = _ref7$size === void 0 ? 4 : _ref7$size,
|
|
3849
3853
|
restProps = _objectWithoutProperties(_ref7, _excluded2);
|
|
3850
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3854
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3851
3855
|
innerProps: innerProps,
|
|
3852
3856
|
isRtl: isRtl,
|
|
3853
3857
|
size: size
|
|
@@ -3903,7 +3907,7 @@ var Control = function Control(props) {
|
|
|
3903
3907
|
innerRef = props.innerRef,
|
|
3904
3908
|
innerProps = props.innerProps,
|
|
3905
3909
|
menuIsOpen = props.menuIsOpen;
|
|
3906
|
-
return jsx("div", _extends({
|
|
3910
|
+
return jsx("div", _extends$1({
|
|
3907
3911
|
ref: innerRef
|
|
3908
3912
|
}, getStyleProps(props, 'control', {
|
|
3909
3913
|
control: true,
|
|
@@ -3935,9 +3939,9 @@ var Group = function Group(props) {
|
|
|
3935
3939
|
label = props.label,
|
|
3936
3940
|
theme = props.theme,
|
|
3937
3941
|
selectProps = props.selectProps;
|
|
3938
|
-
return jsx("div", _extends({}, getStyleProps(props, 'group', {
|
|
3942
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'group', {
|
|
3939
3943
|
group: true
|
|
3940
|
-
}), innerProps), jsx(Heading, _extends({}, headingProps, {
|
|
3944
|
+
}), innerProps), jsx(Heading, _extends$1({}, headingProps, {
|
|
3941
3945
|
selectProps: selectProps,
|
|
3942
3946
|
theme: theme,
|
|
3943
3947
|
getStyles: getStyles,
|
|
@@ -3967,7 +3971,7 @@ var GroupHeading = function GroupHeading(props) {
|
|
|
3967
3971
|
var _cleanCommonProps = cleanCommonProps(props);
|
|
3968
3972
|
_cleanCommonProps.data;
|
|
3969
3973
|
var innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$1);
|
|
3970
|
-
return jsx("div", _extends({}, getStyleProps(props, 'groupHeading', {
|
|
3974
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'groupHeading', {
|
|
3971
3975
|
'group-heading': true
|
|
3972
3976
|
}), innerProps));
|
|
3973
3977
|
};
|
|
@@ -4030,11 +4034,11 @@ var Input = function Input(props) {
|
|
|
4030
4034
|
isHidden = _cleanCommonProps.isHidden,
|
|
4031
4035
|
inputClassName = _cleanCommonProps.inputClassName,
|
|
4032
4036
|
innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$5);
|
|
4033
|
-
return jsx("div", _extends({}, getStyleProps(props, 'input', {
|
|
4037
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'input', {
|
|
4034
4038
|
'input-container': true
|
|
4035
4039
|
}), {
|
|
4036
4040
|
"data-value": value || ''
|
|
4037
|
-
}), jsx("input", _extends({
|
|
4041
|
+
}), jsx("input", _extends$1({
|
|
4038
4042
|
className: cx({
|
|
4039
4043
|
input: true
|
|
4040
4044
|
}, inputClassName),
|
|
@@ -4107,7 +4111,7 @@ var MultiValueLabel = MultiValueGeneric;
|
|
|
4107
4111
|
function MultiValueRemove(_ref5) {
|
|
4108
4112
|
var children = _ref5.children,
|
|
4109
4113
|
innerProps = _ref5.innerProps;
|
|
4110
|
-
return jsx("div", _extends({
|
|
4114
|
+
return jsx("div", _extends$1({
|
|
4111
4115
|
role: "button"
|
|
4112
4116
|
}, innerProps), children || jsx(CrossIcon, {
|
|
4113
4117
|
size: 14
|
|
@@ -4181,7 +4185,7 @@ var Option = function Option(props) {
|
|
|
4181
4185
|
isSelected = props.isSelected,
|
|
4182
4186
|
innerRef = props.innerRef,
|
|
4183
4187
|
innerProps = props.innerProps;
|
|
4184
|
-
return jsx("div", _extends({}, getStyleProps(props, 'option', {
|
|
4188
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'option', {
|
|
4185
4189
|
option: true,
|
|
4186
4190
|
'option--is-disabled': isDisabled,
|
|
4187
4191
|
'option--is-focused': isFocused,
|
|
@@ -4209,7 +4213,7 @@ var placeholderCSS = function placeholderCSS(_ref, unstyled) {
|
|
|
4209
4213
|
var Placeholder = function Placeholder(props) {
|
|
4210
4214
|
var children = props.children,
|
|
4211
4215
|
innerProps = props.innerProps;
|
|
4212
|
-
return jsx("div", _extends({}, getStyleProps(props, 'placeholder', {
|
|
4216
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'placeholder', {
|
|
4213
4217
|
placeholder: true
|
|
4214
4218
|
}), innerProps), children);
|
|
4215
4219
|
};
|
|
@@ -4237,7 +4241,7 @@ var SingleValue = function SingleValue(props) {
|
|
|
4237
4241
|
var children = props.children,
|
|
4238
4242
|
isDisabled = props.isDisabled,
|
|
4239
4243
|
innerProps = props.innerProps;
|
|
4240
|
-
return jsx("div", _extends({}, getStyleProps(props, 'singleValue', {
|
|
4244
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'singleValue', {
|
|
4241
4245
|
'single-value': true,
|
|
4242
4246
|
'single-value--is-disabled': isDisabled
|
|
4243
4247
|
}), innerProps), children);
|
|
@@ -4338,7 +4342,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
|
4338
4342
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
|
|
4339
4343
|
};
|
|
4340
4344
|
var A11yText = function A11yText(props) {
|
|
4341
|
-
return jsx("span", _extends({
|
|
4345
|
+
return jsx("span", _extends$1({
|
|
4342
4346
|
css: _ref
|
|
4343
4347
|
}, props));
|
|
4344
4348
|
};
|
|
@@ -4855,7 +4859,7 @@ function DummyInput(_ref) {
|
|
|
4855
4859
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
4856
4860
|
// Remove animation props not meant for HTML elements
|
|
4857
4861
|
var filteredProps = removeProps(props, 'onExited', 'in', 'enter', 'exit', 'appear');
|
|
4858
|
-
return jsx("input", _extends({
|
|
4862
|
+
return jsx("input", _extends$1({
|
|
4859
4863
|
ref: innerRef
|
|
4860
4864
|
}, filteredProps, {
|
|
4861
4865
|
css: /*#__PURE__*/css$2({
|
|
@@ -6437,7 +6441,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6437
6441
|
});
|
|
6438
6442
|
if (!isSearchable) {
|
|
6439
6443
|
// use a dummy input to maintain focus/blur functionality
|
|
6440
|
-
return /*#__PURE__*/React
|
|
6444
|
+
return /*#__PURE__*/React.createElement(DummyInput, _extends$1({
|
|
6441
6445
|
id: id,
|
|
6442
6446
|
innerRef: this.getInputRef,
|
|
6443
6447
|
onBlur: this.onInputBlur,
|
|
@@ -6450,7 +6454,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6450
6454
|
value: ""
|
|
6451
6455
|
}, ariaAttributes));
|
|
6452
6456
|
}
|
|
6453
|
-
return /*#__PURE__*/React
|
|
6457
|
+
return /*#__PURE__*/React.createElement(Input, _extends$1({}, commonProps, {
|
|
6454
6458
|
autoCapitalize: "none",
|
|
6455
6459
|
autoComplete: "off",
|
|
6456
6460
|
autoCorrect: "off",
|
|
@@ -6491,7 +6495,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6491
6495
|
focusedValue = _this$state5.focusedValue,
|
|
6492
6496
|
isFocused = _this$state5.isFocused;
|
|
6493
6497
|
if (!this.hasValue() || !controlShouldRenderValue) {
|
|
6494
|
-
return inputValue ? null : /*#__PURE__*/React
|
|
6498
|
+
return inputValue ? null : /*#__PURE__*/React.createElement(Placeholder, _extends$1({}, commonProps, {
|
|
6495
6499
|
key: "placeholder",
|
|
6496
6500
|
isDisabled: isDisabled,
|
|
6497
6501
|
isFocused: isFocused,
|
|
@@ -6504,7 +6508,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6504
6508
|
return selectValue.map(function (opt, index) {
|
|
6505
6509
|
var isOptionFocused = opt === focusedValue;
|
|
6506
6510
|
var key = "".concat(_this3.getOptionLabel(opt), "-").concat(_this3.getOptionValue(opt));
|
|
6507
|
-
return /*#__PURE__*/React
|
|
6511
|
+
return /*#__PURE__*/React.createElement(MultiValue, _extends$1({}, commonProps, {
|
|
6508
6512
|
components: {
|
|
6509
6513
|
Container: MultiValueContainer,
|
|
6510
6514
|
Label: MultiValueLabel,
|
|
@@ -6533,7 +6537,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6533
6537
|
return null;
|
|
6534
6538
|
}
|
|
6535
6539
|
var singleValue = selectValue[0];
|
|
6536
|
-
return /*#__PURE__*/React
|
|
6540
|
+
return /*#__PURE__*/React.createElement(SingleValue, _extends$1({}, commonProps, {
|
|
6537
6541
|
data: singleValue,
|
|
6538
6542
|
isDisabled: isDisabled
|
|
6539
6543
|
}), this.formatOptionLabel(singleValue, 'value'));
|
|
@@ -6556,7 +6560,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6556
6560
|
onTouchEnd: this.onClearIndicatorTouchEnd,
|
|
6557
6561
|
'aria-hidden': 'true'
|
|
6558
6562
|
};
|
|
6559
|
-
return /*#__PURE__*/React
|
|
6563
|
+
return /*#__PURE__*/React.createElement(ClearIndicator, _extends$1({}, commonProps, {
|
|
6560
6564
|
innerProps: innerProps,
|
|
6561
6565
|
isFocused: isFocused
|
|
6562
6566
|
}));
|
|
@@ -6575,7 +6579,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6575
6579
|
var innerProps = {
|
|
6576
6580
|
'aria-hidden': 'true'
|
|
6577
6581
|
};
|
|
6578
|
-
return /*#__PURE__*/React
|
|
6582
|
+
return /*#__PURE__*/React.createElement(LoadingIndicator, _extends$1({}, commonProps, {
|
|
6579
6583
|
innerProps: innerProps,
|
|
6580
6584
|
isDisabled: isDisabled,
|
|
6581
6585
|
isFocused: isFocused
|
|
@@ -6593,7 +6597,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6593
6597
|
var commonProps = this.commonProps;
|
|
6594
6598
|
var isDisabled = this.props.isDisabled;
|
|
6595
6599
|
var isFocused = this.state.isFocused;
|
|
6596
|
-
return /*#__PURE__*/React
|
|
6600
|
+
return /*#__PURE__*/React.createElement(IndicatorSeparator, _extends$1({}, commonProps, {
|
|
6597
6601
|
isDisabled: isDisabled,
|
|
6598
6602
|
isFocused: isFocused
|
|
6599
6603
|
}));
|
|
@@ -6612,7 +6616,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6612
6616
|
onTouchEnd: this.onDropdownIndicatorTouchEnd,
|
|
6613
6617
|
'aria-hidden': 'true'
|
|
6614
6618
|
};
|
|
6615
|
-
return /*#__PURE__*/React
|
|
6619
|
+
return /*#__PURE__*/React.createElement(DropdownIndicator, _extends$1({}, commonProps, {
|
|
6616
6620
|
innerProps: innerProps,
|
|
6617
6621
|
isDisabled: isDisabled,
|
|
6618
6622
|
isFocused: isFocused
|
|
@@ -6677,7 +6681,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6677
6681
|
'aria-selected': _this4.state.isAppleDevice ? undefined : isSelected // is not supported on Apple devices
|
|
6678
6682
|
};
|
|
6679
6683
|
|
|
6680
|
-
return /*#__PURE__*/React
|
|
6684
|
+
return /*#__PURE__*/React.createElement(Option, _extends$1({}, commonProps, {
|
|
6681
6685
|
innerProps: innerProps,
|
|
6682
6686
|
data: data,
|
|
6683
6687
|
isDisabled: isDisabled,
|
|
@@ -6699,7 +6703,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6699
6703
|
groupIndex = item.index;
|
|
6700
6704
|
var groupId = "".concat(_this4.getElementId('group'), "-").concat(groupIndex);
|
|
6701
6705
|
var headingId = "".concat(groupId, "-heading");
|
|
6702
|
-
return /*#__PURE__*/React
|
|
6706
|
+
return /*#__PURE__*/React.createElement(Group, _extends$1({}, commonProps, {
|
|
6703
6707
|
key: groupId,
|
|
6704
6708
|
data: _data,
|
|
6705
6709
|
options: options,
|
|
@@ -6721,13 +6725,13 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6721
6725
|
inputValue: inputValue
|
|
6722
6726
|
});
|
|
6723
6727
|
if (message === null) return null;
|
|
6724
|
-
menuUI = /*#__PURE__*/React
|
|
6728
|
+
menuUI = /*#__PURE__*/React.createElement(LoadingMessage, commonProps, message);
|
|
6725
6729
|
} else {
|
|
6726
6730
|
var _message = noOptionsMessage({
|
|
6727
6731
|
inputValue: inputValue
|
|
6728
6732
|
});
|
|
6729
6733
|
if (_message === null) return null;
|
|
6730
|
-
menuUI = /*#__PURE__*/React
|
|
6734
|
+
menuUI = /*#__PURE__*/React.createElement(NoOptionsMessage, commonProps, _message);
|
|
6731
6735
|
}
|
|
6732
6736
|
var menuPlacementProps = {
|
|
6733
6737
|
minMenuHeight: minMenuHeight,
|
|
@@ -6736,12 +6740,12 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6736
6740
|
menuPosition: menuPosition,
|
|
6737
6741
|
menuShouldScrollIntoView: menuShouldScrollIntoView
|
|
6738
6742
|
};
|
|
6739
|
-
var menuElement = /*#__PURE__*/React
|
|
6743
|
+
var menuElement = /*#__PURE__*/React.createElement(MenuPlacer, _extends$1({}, commonProps, menuPlacementProps), function (_ref4) {
|
|
6740
6744
|
var ref = _ref4.ref,
|
|
6741
6745
|
_ref4$placerProps = _ref4.placerProps,
|
|
6742
6746
|
placement = _ref4$placerProps.placement,
|
|
6743
6747
|
maxHeight = _ref4$placerProps.maxHeight;
|
|
6744
|
-
return /*#__PURE__*/React
|
|
6748
|
+
return /*#__PURE__*/React.createElement(Menu, _extends$1({}, commonProps, menuPlacementProps, {
|
|
6745
6749
|
innerRef: ref,
|
|
6746
6750
|
innerProps: {
|
|
6747
6751
|
onMouseDown: _this4.onMenuMouseDown,
|
|
@@ -6749,13 +6753,13 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6749
6753
|
},
|
|
6750
6754
|
isLoading: isLoading,
|
|
6751
6755
|
placement: placement
|
|
6752
|
-
}), /*#__PURE__*/React
|
|
6756
|
+
}), /*#__PURE__*/React.createElement(ScrollManager, {
|
|
6753
6757
|
captureEnabled: captureMenuScroll,
|
|
6754
6758
|
onTopArrive: onMenuScrollToTop,
|
|
6755
6759
|
onBottomArrive: onMenuScrollToBottom,
|
|
6756
6760
|
lockEnabled: menuShouldBlockScroll
|
|
6757
6761
|
}, function (scrollTargetRef) {
|
|
6758
|
-
return /*#__PURE__*/React
|
|
6762
|
+
return /*#__PURE__*/React.createElement(MenuList, _extends$1({}, commonProps, {
|
|
6759
6763
|
innerRef: function innerRef(instance) {
|
|
6760
6764
|
_this4.getMenuListRef(instance);
|
|
6761
6765
|
scrollTargetRef(instance);
|
|
@@ -6775,7 +6779,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6775
6779
|
// positioning behaviour is almost identical for portalled and fixed,
|
|
6776
6780
|
// so we use the same component. the actual portalling logic is forked
|
|
6777
6781
|
// within the component based on `menuPosition`
|
|
6778
|
-
return menuPortalTarget || menuPosition === 'fixed' ? /*#__PURE__*/React
|
|
6782
|
+
return menuPortalTarget || menuPosition === 'fixed' ? /*#__PURE__*/React.createElement(MenuPortal, _extends$1({}, commonProps, {
|
|
6779
6783
|
appendTo: menuPortalTarget,
|
|
6780
6784
|
controlElement: this.controlRef,
|
|
6781
6785
|
menuPlacement: menuPlacement,
|
|
@@ -6794,7 +6798,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6794
6798
|
required = _this$props13.required;
|
|
6795
6799
|
var selectValue = this.state.selectValue;
|
|
6796
6800
|
if (required && !this.hasValue() && !isDisabled) {
|
|
6797
|
-
return /*#__PURE__*/React
|
|
6801
|
+
return /*#__PURE__*/React.createElement(RequiredInput$1, {
|
|
6798
6802
|
name: name,
|
|
6799
6803
|
onFocus: this.onValueInputFocus
|
|
6800
6804
|
});
|
|
@@ -6805,29 +6809,29 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6805
6809
|
var value = selectValue.map(function (opt) {
|
|
6806
6810
|
return _this5.getOptionValue(opt);
|
|
6807
6811
|
}).join(delimiter);
|
|
6808
|
-
return /*#__PURE__*/React
|
|
6812
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
6809
6813
|
name: name,
|
|
6810
6814
|
type: "hidden",
|
|
6811
6815
|
value: value
|
|
6812
6816
|
});
|
|
6813
6817
|
} else {
|
|
6814
6818
|
var input = selectValue.length > 0 ? selectValue.map(function (opt, i) {
|
|
6815
|
-
return /*#__PURE__*/React
|
|
6819
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
6816
6820
|
key: "i-".concat(i),
|
|
6817
6821
|
name: name,
|
|
6818
6822
|
type: "hidden",
|
|
6819
6823
|
value: _this5.getOptionValue(opt)
|
|
6820
6824
|
});
|
|
6821
|
-
}) : /*#__PURE__*/React
|
|
6825
|
+
}) : /*#__PURE__*/React.createElement("input", {
|
|
6822
6826
|
name: name,
|
|
6823
6827
|
type: "hidden",
|
|
6824
6828
|
value: ""
|
|
6825
6829
|
});
|
|
6826
|
-
return /*#__PURE__*/React
|
|
6830
|
+
return /*#__PURE__*/React.createElement("div", null, input);
|
|
6827
6831
|
}
|
|
6828
6832
|
} else {
|
|
6829
6833
|
var _value = selectValue[0] ? this.getOptionValue(selectValue[0]) : '';
|
|
6830
|
-
return /*#__PURE__*/React
|
|
6834
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
6831
6835
|
name: name,
|
|
6832
6836
|
type: "hidden",
|
|
6833
6837
|
value: _value
|
|
@@ -6845,7 +6849,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6845
6849
|
isFocused = _this$state6.isFocused,
|
|
6846
6850
|
selectValue = _this$state6.selectValue;
|
|
6847
6851
|
var focusableOptions = this.getFocusableOptions();
|
|
6848
|
-
return /*#__PURE__*/React
|
|
6852
|
+
return /*#__PURE__*/React.createElement(LiveRegion$1, _extends$1({}, commonProps, {
|
|
6849
6853
|
id: this.getElementId('live-region'),
|
|
6850
6854
|
ariaSelection: ariaSelection,
|
|
6851
6855
|
focusedOption: focusedOption,
|
|
@@ -6871,7 +6875,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6871
6875
|
menuIsOpen = _this$props14.menuIsOpen;
|
|
6872
6876
|
var isFocused = this.state.isFocused;
|
|
6873
6877
|
var commonProps = this.commonProps = this.getCommonProps();
|
|
6874
|
-
return /*#__PURE__*/React
|
|
6878
|
+
return /*#__PURE__*/React.createElement(SelectContainer, _extends$1({}, commonProps, {
|
|
6875
6879
|
className: className,
|
|
6876
6880
|
innerProps: {
|
|
6877
6881
|
id: id,
|
|
@@ -6879,7 +6883,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6879
6883
|
},
|
|
6880
6884
|
isDisabled: isDisabled,
|
|
6881
6885
|
isFocused: isFocused
|
|
6882
|
-
}), this.renderLiveRegion(), /*#__PURE__*/React
|
|
6886
|
+
}), this.renderLiveRegion(), /*#__PURE__*/React.createElement(Control, _extends$1({}, commonProps, {
|
|
6883
6887
|
innerRef: this.getControlRef,
|
|
6884
6888
|
innerProps: {
|
|
6885
6889
|
onMouseDown: this.onControlMouseDown,
|
|
@@ -6888,9 +6892,9 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6888
6892
|
isDisabled: isDisabled,
|
|
6889
6893
|
isFocused: isFocused,
|
|
6890
6894
|
menuIsOpen: menuIsOpen
|
|
6891
|
-
}), /*#__PURE__*/React
|
|
6895
|
+
}), /*#__PURE__*/React.createElement(ValueContainer, _extends$1({}, commonProps, {
|
|
6892
6896
|
isDisabled: isDisabled
|
|
6893
|
-
}), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React
|
|
6897
|
+
}), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React.createElement(IndicatorsContainer, _extends$1({}, commonProps, {
|
|
6894
6898
|
isDisabled: isDisabled
|
|
6895
6899
|
}), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
|
|
6896
6900
|
}
|
|
@@ -6962,7 +6966,7 @@ Select.defaultProps = defaultProps;
|
|
|
6962
6966
|
|
|
6963
6967
|
var StateManagedSelect = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
6964
6968
|
var baseSelectProps = useStateManager(props);
|
|
6965
|
-
return /*#__PURE__*/React
|
|
6969
|
+
return /*#__PURE__*/React.createElement(Select, _extends$1({
|
|
6966
6970
|
ref: ref
|
|
6967
6971
|
}, baseSelectProps));
|
|
6968
6972
|
});
|
|
@@ -6975,11 +6979,73 @@ const MultiSelectDropdown = ({
|
|
|
6975
6979
|
onChange,
|
|
6976
6980
|
theme = "light",
|
|
6977
6981
|
placeholder = "Select...",
|
|
6978
|
-
maxVisible = 1,
|
|
6979
6982
|
required = false,
|
|
6980
|
-
closeMenuOnSelect = false
|
|
6983
|
+
closeMenuOnSelect = false,
|
|
6984
|
+
pushUrlParamObj = false // pushUrlParamObj={"ids"}
|
|
6981
6985
|
}) => {
|
|
6982
6986
|
const containerRef = useRef(null);
|
|
6987
|
+
const [maxVisible, setMaxVisible] = useState(1);
|
|
6988
|
+
useEffect(() => {
|
|
6989
|
+
if (!containerRef.current) return;
|
|
6990
|
+
const containerWidth = containerRef.current.offsetWidth || 200;
|
|
6991
|
+
// Estimate average tag width (adjust as needed for your style)
|
|
6992
|
+
const avgTagWidth = 90; // px, tweak for your font/size
|
|
6993
|
+
const calculated = Math.max(1, Math.floor((containerWidth - 40) / avgTagWidth));
|
|
6994
|
+
setMaxVisible(calculated);
|
|
6995
|
+
// Optionally, recalculate on window resize:
|
|
6996
|
+
const handleResize = () => {
|
|
6997
|
+
const w = containerRef.current.offsetWidth || 200;
|
|
6998
|
+
setMaxVisible(Math.max(1, Math.floor((w - 40) / avgTagWidth)));
|
|
6999
|
+
};
|
|
7000
|
+
window.addEventListener("resize", handleResize);
|
|
7001
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
7002
|
+
}, []);
|
|
7003
|
+
|
|
7004
|
+
// On mount, read from URL param if present and set values by matching with options
|
|
7005
|
+
useEffect(() => {
|
|
7006
|
+
if (!pushUrlParamObj || !options || options.length === 0) return;
|
|
7007
|
+
const readFromUrl = () => {
|
|
7008
|
+
const params = new URLSearchParams(window.location.search);
|
|
7009
|
+
const urlVal = params.get(pushUrlParamObj);
|
|
7010
|
+
if (urlVal) {
|
|
7011
|
+
if (isMulti) {
|
|
7012
|
+
const urlValues = urlVal.split(",").filter(Boolean);
|
|
7013
|
+
const matchedValues = urlValues.map(v => {
|
|
7014
|
+
const found = options.find(opt => String(opt.value) === String(v));
|
|
7015
|
+
return found ? found.value : null;
|
|
7016
|
+
}).filter(v => v !== null);
|
|
7017
|
+
if (matchedValues.length > 0 && JSON.stringify(matchedValues) !== JSON.stringify(selected)) {
|
|
7018
|
+
onChange?.(matchedValues);
|
|
7019
|
+
}
|
|
7020
|
+
} else {
|
|
7021
|
+
const found = options.find(opt => String(opt.value) === String(urlVal));
|
|
7022
|
+
if (found && (!selected || selected[0] !== found.value)) {
|
|
7023
|
+
onChange?.([found.value]);
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
7027
|
+
};
|
|
7028
|
+
readFromUrl();
|
|
7029
|
+
window.addEventListener("popstate", readFromUrl);
|
|
7030
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
7031
|
+
const patchHistory = type => {
|
|
7032
|
+
const orig = window.history[type];
|
|
7033
|
+
window.history[type] = function () {
|
|
7034
|
+
const rv = orig.apply(this, arguments);
|
|
7035
|
+
window.dispatchEvent(new Event(type));
|
|
7036
|
+
return rv;
|
|
7037
|
+
};
|
|
7038
|
+
};
|
|
7039
|
+
patchHistory('pushState');
|
|
7040
|
+
patchHistory('replaceState');
|
|
7041
|
+
window.addEventListener('pushState', readFromUrl);
|
|
7042
|
+
window.addEventListener('replaceState', readFromUrl);
|
|
7043
|
+
return () => {
|
|
7044
|
+
window.removeEventListener("popstate", readFromUrl);
|
|
7045
|
+
window.removeEventListener('pushState', readFromUrl);
|
|
7046
|
+
window.removeEventListener('replaceState', readFromUrl);
|
|
7047
|
+
};
|
|
7048
|
+
}, [pushUrlParamObj, isMulti, options, selected, onChange]);
|
|
6983
7049
|
const selectedOptions = useMemo(() => {
|
|
6984
7050
|
if (isMulti) {
|
|
6985
7051
|
return options.filter(opt => selected.includes(opt.value));
|
|
@@ -6987,13 +7053,29 @@ const MultiSelectDropdown = ({
|
|
|
6987
7053
|
return options.find(opt => opt.value === selected[0]) || null;
|
|
6988
7054
|
}
|
|
6989
7055
|
}, [selected, options, isMulti]);
|
|
7056
|
+
const setUrlParam = value => {
|
|
7057
|
+
if (!pushUrlParamObj) return;
|
|
7058
|
+
const url = new URL(window.location);
|
|
7059
|
+
if (!value) {
|
|
7060
|
+
url.searchParams.delete(pushUrlParamObj);
|
|
7061
|
+
} else {
|
|
7062
|
+
url.searchParams.set(pushUrlParamObj, value);
|
|
7063
|
+
}
|
|
7064
|
+
window.history.replaceState({}, "", url);
|
|
7065
|
+
};
|
|
6990
7066
|
const handleChange = selectedItems => {
|
|
6991
7067
|
if (isMulti) {
|
|
6992
7068
|
const values = selectedItems ? selectedItems.map(item => item.value) : [];
|
|
6993
7069
|
onChange(values);
|
|
7070
|
+
if (pushUrlParamObj) {
|
|
7071
|
+
setUrlParam(values.length ? values.join(",") : "");
|
|
7072
|
+
}
|
|
6994
7073
|
} else {
|
|
6995
7074
|
const value = selectedItems ? [selectedItems.value] : [];
|
|
6996
7075
|
onChange(value);
|
|
7076
|
+
if (pushUrlParamObj) {
|
|
7077
|
+
setUrlParam(value.length ? value[0] : "");
|
|
7078
|
+
}
|
|
6997
7079
|
}
|
|
6998
7080
|
};
|
|
6999
7081
|
const MultiValue = props => {
|
|
@@ -7003,25 +7085,33 @@ const MultiSelectDropdown = ({
|
|
|
7003
7085
|
} = props;
|
|
7004
7086
|
const allSelected = getValue();
|
|
7005
7087
|
const hiddenCount = allSelected.length - maxVisible;
|
|
7088
|
+
|
|
7089
|
+
// Only render visible tags
|
|
7006
7090
|
if (index < maxVisible) {
|
|
7007
|
-
return /*#__PURE__*/
|
|
7091
|
+
return /*#__PURE__*/React__default.createElement(components.MultiValue, props);
|
|
7008
7092
|
}
|
|
7093
|
+
|
|
7094
|
+
// Only render +N for the first hidden slot
|
|
7009
7095
|
if (index === maxVisible && hiddenCount > 0) {
|
|
7010
7096
|
const hiddenLabels = allSelected.slice(maxVisible).map(opt => opt.label).join(", ");
|
|
7011
|
-
return /*#__PURE__*/
|
|
7097
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
7012
7098
|
className: "multi-value-extra",
|
|
7013
7099
|
title: hiddenLabels,
|
|
7014
7100
|
style: {
|
|
7015
7101
|
backgroundColor: theme === "dark" ? "#333" : "#e0e0e0",
|
|
7016
7102
|
color: theme === "dark" ? "#eee" : "#333",
|
|
7017
7103
|
borderRadius: 4,
|
|
7018
|
-
padding: "
|
|
7019
|
-
fontSize: "0.
|
|
7020
|
-
|
|
7104
|
+
padding: "2px 8px",
|
|
7105
|
+
fontSize: "0.85em",
|
|
7106
|
+
display: "inline-flex",
|
|
7107
|
+
alignItems: "center",
|
|
7108
|
+
marginLeft: 4,
|
|
7021
7109
|
cursor: "default"
|
|
7022
7110
|
}
|
|
7023
7111
|
}, "+", hiddenCount);
|
|
7024
7112
|
}
|
|
7113
|
+
|
|
7114
|
+
// Don't render anything for other hidden tags
|
|
7025
7115
|
return null;
|
|
7026
7116
|
};
|
|
7027
7117
|
const selectStyle = {
|
|
@@ -7083,16 +7173,21 @@ const MultiSelectDropdown = ({
|
|
|
7083
7173
|
menuPortal: base => ({
|
|
7084
7174
|
...base,
|
|
7085
7175
|
zIndex: 999999
|
|
7176
|
+
}),
|
|
7177
|
+
valueContainer: base => ({
|
|
7178
|
+
...base,
|
|
7179
|
+
flexWrap: "nowrap",
|
|
7180
|
+
overflow: "hidden"
|
|
7086
7181
|
})
|
|
7087
7182
|
};
|
|
7088
7183
|
const showRequiredError = required && (!selected || selected.length === 0);
|
|
7089
|
-
return /*#__PURE__*/
|
|
7184
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
7090
7185
|
style: {
|
|
7091
7186
|
width: "100%"
|
|
7092
7187
|
},
|
|
7093
7188
|
ref: containerRef,
|
|
7094
7189
|
className: showRequiredError ? "select-required-error" : ""
|
|
7095
|
-
}, /*#__PURE__*/
|
|
7190
|
+
}, /*#__PURE__*/React__default.createElement(StateManagedSelect$1, {
|
|
7096
7191
|
isMulti: isMulti,
|
|
7097
7192
|
options: options,
|
|
7098
7193
|
value: selectedOptions,
|
|
@@ -7104,406 +7199,2884 @@ const MultiSelectDropdown = ({
|
|
|
7104
7199
|
},
|
|
7105
7200
|
menuPortalTarget: document.body,
|
|
7106
7201
|
closeMenuOnSelect: closeMenuOnSelect,
|
|
7107
|
-
"aria-required": required
|
|
7108
|
-
}), showRequiredError && /*#__PURE__*/
|
|
7202
|
+
"aria-required": required
|
|
7203
|
+
}), showRequiredError && /*#__PURE__*/React__default.createElement("div", {
|
|
7109
7204
|
className: "error-text"
|
|
7110
7205
|
}, "This field is required."));
|
|
7111
7206
|
};
|
|
7112
7207
|
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7208
|
+
// import "src/style/DebounceSelect.css";
|
|
7209
|
+
|
|
7210
|
+
const DebounceSelect = ({
|
|
7211
|
+
label,
|
|
7212
|
+
fetchOptions,
|
|
7213
|
+
onSelect,
|
|
7214
|
+
placeholder = "Type to search...",
|
|
7215
|
+
debounceDelay = 300,
|
|
7216
|
+
required = false,
|
|
7217
|
+
disabled = false,
|
|
7218
|
+
objValue,
|
|
7219
|
+
style,
|
|
7220
|
+
isMulti = false,
|
|
7221
|
+
pushUrlParamObj = false
|
|
7125
7222
|
}) => {
|
|
7223
|
+
const [input, setInput] = useState("");
|
|
7224
|
+
const [options, setOptions] = useState([]);
|
|
7225
|
+
const [loading, setLoading] = useState(false);
|
|
7226
|
+
const [open, setOpen] = useState(false);
|
|
7227
|
+
const [selectedItems, setSelectedItems] = useState(isMulti ? objValue ?? [] : objValue ? [objValue] : []);
|
|
7228
|
+
|
|
7229
|
+
// Auto-update selectedItems when URL param changes
|
|
7230
|
+
// useEffect(() => {
|
|
7231
|
+
// if (!pushUrlParamObj) return;
|
|
7232
|
+
// const syncFromUrl = () => {
|
|
7233
|
+
// const params = new URLSearchParams(window.location.search);
|
|
7234
|
+
// const urlVal = params.get(pushUrlParamObj);
|
|
7235
|
+
// if (urlVal) {
|
|
7236
|
+
// if (isMulti) {
|
|
7237
|
+
// const urlValues = urlVal.split(",").filter(Boolean);
|
|
7238
|
+
// // Only update if different
|
|
7239
|
+
// if (JSON.stringify(urlValues) !== JSON.stringify(selectedItems.map(i => i.value))) {
|
|
7240
|
+
// // We don't have labels, so just update values
|
|
7241
|
+
// setSelectedItems(urlValues.map(v => ({ value: v, label: v })));
|
|
7242
|
+
// onSelect?.(urlValues.map(v => ({ value: v, label: v })));
|
|
7243
|
+
// }
|
|
7244
|
+
// } else {
|
|
7245
|
+
// if (!selectedItems[0] || selectedItems[0].value !== urlVal) {
|
|
7246
|
+
// setSelectedItems([{ value: urlVal, label: urlVal }]);
|
|
7247
|
+
// onSelect?.({ value: urlVal, label: urlVal });
|
|
7248
|
+
// }
|
|
7249
|
+
// }
|
|
7250
|
+
// } else {
|
|
7251
|
+
// if (selectedItems.length > 0) {
|
|
7252
|
+
// setSelectedItems([]);
|
|
7253
|
+
// onSelect?.(isMulti ? [] : null);
|
|
7254
|
+
// }
|
|
7255
|
+
// }
|
|
7256
|
+
// };
|
|
7257
|
+
// syncFromUrl();
|
|
7258
|
+
// window.addEventListener("popstate", syncFromUrl);
|
|
7259
|
+
// // Listen for pushState/replaceState (programmatic changes)
|
|
7260
|
+
// const patchHistory = (type) => {
|
|
7261
|
+
// const orig = window.history[type];
|
|
7262
|
+
// window.history[type] = function() {
|
|
7263
|
+
// const rv = orig.apply(this, arguments);
|
|
7264
|
+
// window.dispatchEvent(new Event(type));
|
|
7265
|
+
// return rv;
|
|
7266
|
+
// };
|
|
7267
|
+
// };
|
|
7268
|
+
// patchHistory('pushState');
|
|
7269
|
+
// patchHistory('replaceState');
|
|
7270
|
+
// window.addEventListener('pushState', syncFromUrl);
|
|
7271
|
+
// window.addEventListener('replaceState', syncFromUrl);
|
|
7272
|
+
// return () => {
|
|
7273
|
+
// window.removeEventListener("popstate", syncFromUrl);
|
|
7274
|
+
// window.removeEventListener('pushState', syncFromUrl);
|
|
7275
|
+
// window.removeEventListener('replaceState', syncFromUrl);
|
|
7276
|
+
// };
|
|
7277
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7278
|
+
// }, [pushUrlParamObj, isMulti, selectedItems, onSelect]);
|
|
7279
|
+
|
|
7280
|
+
const timeoutRef = useRef(null);
|
|
7126
7281
|
useEffect(() => {
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7282
|
+
if (!input) {
|
|
7283
|
+
setOptions([]);
|
|
7284
|
+
return;
|
|
7285
|
+
}
|
|
7286
|
+
setLoading(true);
|
|
7287
|
+
clearTimeout(timeoutRef.current);
|
|
7288
|
+
timeoutRef.current = setTimeout(async () => {
|
|
7289
|
+
try {
|
|
7290
|
+
// If input is '...', fetch all options
|
|
7291
|
+
const query = input === "..." ? "" : input;
|
|
7292
|
+
const results = await fetchOptions(query);
|
|
7293
|
+
setOptions(results);
|
|
7294
|
+
} catch (err) {
|
|
7295
|
+
console.error("Failed to fetch options", err);
|
|
7296
|
+
setOptions([]);
|
|
7297
|
+
} finally {
|
|
7298
|
+
setLoading(false);
|
|
7130
7299
|
}
|
|
7131
|
-
};
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7300
|
+
}, debounceDelay);
|
|
7301
|
+
return () => clearTimeout(timeoutRef.current);
|
|
7302
|
+
}, [input, fetchOptions, debounceDelay]);
|
|
7303
|
+
const setUrlParam = value => {
|
|
7304
|
+
const url = new URL(window.location);
|
|
7305
|
+
if (value === null || value === undefined || value === "") {
|
|
7306
|
+
url.searchParams.delete(pushUrlParamObj);
|
|
7307
|
+
} else {
|
|
7308
|
+
url.searchParams.set(pushUrlParamObj, value);
|
|
7309
|
+
}
|
|
7310
|
+
window.history.replaceState({}, "", url);
|
|
7311
|
+
};
|
|
7312
|
+
const handleSelect = (value, labelValue) => {
|
|
7313
|
+
if (isMulti) {
|
|
7314
|
+
const newItem = {
|
|
7315
|
+
value,
|
|
7316
|
+
label: labelValue
|
|
7317
|
+
};
|
|
7318
|
+
const updated = selectedItems.some(item => item.value === value) ? selectedItems : [...selectedItems, newItem];
|
|
7319
|
+
setSelectedItems(updated);
|
|
7320
|
+
onSelect(updated);
|
|
7321
|
+
setInput("");
|
|
7322
|
+
if (pushUrlParamObj) {
|
|
7323
|
+
setUrlParam(updated.map(item => item.value).join(","));
|
|
7324
|
+
}
|
|
7325
|
+
} else {
|
|
7326
|
+
const single = {
|
|
7327
|
+
value,
|
|
7328
|
+
label: labelValue
|
|
7329
|
+
};
|
|
7330
|
+
setSelectedItems([single]);
|
|
7331
|
+
onSelect(single);
|
|
7332
|
+
setInput(labelValue);
|
|
7333
|
+
if (pushUrlParamObj) {
|
|
7334
|
+
setUrlParam(value);
|
|
7335
|
+
}
|
|
7336
|
+
}
|
|
7337
|
+
setOpen(false);
|
|
7338
|
+
};
|
|
7339
|
+
const removeItem = value => {
|
|
7340
|
+
const updated = selectedItems.filter(item => item.value !== value);
|
|
7341
|
+
setSelectedItems(updated);
|
|
7342
|
+
onSelect(updated);
|
|
7343
|
+
if (pushUrlParamObj) {
|
|
7344
|
+
setUrlParam(updated.length ? updated.map(item => item.value).join(",") : "");
|
|
7345
|
+
}
|
|
7346
|
+
};
|
|
7136
7347
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
},
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
className: "
|
|
7148
|
-
},
|
|
7149
|
-
|
|
7150
|
-
onClick:
|
|
7151
|
-
},
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7348
|
+
style: {
|
|
7349
|
+
position: 'relative'
|
|
7350
|
+
}
|
|
7351
|
+
}, label && /*#__PURE__*/React__default.createElement("label", null, label, required && ' *'), isMulti && /*#__PURE__*/React__default.createElement("div", {
|
|
7352
|
+
className: "multi-selected-tags"
|
|
7353
|
+
}, selectedItems.map(({
|
|
7354
|
+
label,
|
|
7355
|
+
value
|
|
7356
|
+
}) => /*#__PURE__*/React__default.createElement("span", {
|
|
7357
|
+
key: value,
|
|
7358
|
+
className: "tag"
|
|
7359
|
+
}, label, /*#__PURE__*/React__default.createElement("button", {
|
|
7360
|
+
type: "button",
|
|
7361
|
+
onClick: () => removeItem(value)
|
|
7362
|
+
}, "\xD7")))), /*#__PURE__*/React__default.createElement("div", {
|
|
7363
|
+
style: {
|
|
7364
|
+
position: 'relative',
|
|
7365
|
+
display: 'flex',
|
|
7366
|
+
alignItems: 'center'
|
|
7367
|
+
}
|
|
7368
|
+
}, /*#__PURE__*/React__default.createElement("input", {
|
|
7369
|
+
className: "basic-input",
|
|
7370
|
+
type: "text",
|
|
7371
|
+
value: isMulti ? input : open ? input : selectedItems.length > 0 ? selectedItems[0].label : input,
|
|
7372
|
+
onChange: e => {
|
|
7373
|
+
setInput(e.target.value);
|
|
7374
|
+
setOpen(true);
|
|
7375
|
+
},
|
|
7376
|
+
placeholder: placeholder,
|
|
7377
|
+
onFocus: () => setOpen(true),
|
|
7378
|
+
onBlur: () => setTimeout(() => setOpen(false), 200),
|
|
7379
|
+
disabled: disabled,
|
|
7380
|
+
style: style
|
|
7381
|
+
}), (input || !isMulti && selectedItems.length > 0) && !disabled && /*#__PURE__*/React__default.createElement("button", {
|
|
7382
|
+
type: "button",
|
|
7383
|
+
"aria-label": "Clear",
|
|
7384
|
+
style: {
|
|
7385
|
+
position: 'absolute',
|
|
7386
|
+
right: 6,
|
|
7387
|
+
background: 'none',
|
|
7388
|
+
border: 'none',
|
|
7389
|
+
cursor: 'pointer',
|
|
7390
|
+
fontSize: '1.2em',
|
|
7391
|
+
color: '#888',
|
|
7392
|
+
padding: 0,
|
|
7393
|
+
lineHeight: 1
|
|
7394
|
+
},
|
|
7395
|
+
onMouseDown: e => {
|
|
7396
|
+
e.preventDefault();
|
|
7397
|
+
setInput("");
|
|
7398
|
+
if (isMulti) ; else {
|
|
7399
|
+
setSelectedItems([]);
|
|
7400
|
+
onSelect(null);
|
|
7401
|
+
if (pushUrlParamObj) setUrlParam("");
|
|
7402
|
+
}
|
|
7403
|
+
},
|
|
7404
|
+
tabIndex: -1
|
|
7405
|
+
}, "\xD7")), open && /*#__PURE__*/React__default.createElement("div", {
|
|
7406
|
+
className: "basic-input-dropdown-menu"
|
|
7407
|
+
}, loading ? /*#__PURE__*/React__default.createElement("div", {
|
|
7408
|
+
className: "loading-dropdown-item"
|
|
7409
|
+
}, "Loading...") : options?.length > 0 ? options.map(({
|
|
7410
|
+
label,
|
|
7411
|
+
value
|
|
7412
|
+
}) => /*#__PURE__*/React__default.createElement("div", {
|
|
7413
|
+
key: value,
|
|
7414
|
+
className: "basic-input-dropdown-item",
|
|
7415
|
+
onMouseDown: () => handleSelect(value, label)
|
|
7416
|
+
}, label)) : /*#__PURE__*/React__default.createElement("div", {
|
|
7417
|
+
className: "no-results-dropdown-item"
|
|
7418
|
+
}, "No results")));
|
|
7155
7419
|
};
|
|
7156
7420
|
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
extraSearchTerm,
|
|
7167
|
-
theme = "light"
|
|
7168
|
-
}) => {
|
|
7169
|
-
// const { theme, internalSort, context } = useAuth();
|
|
7170
|
-
|
|
7171
|
-
// console.log(extraSearchTerm)
|
|
7172
|
-
// Simple translation stub: return mapped key or the key itself.
|
|
7173
|
-
const _translations = {
|
|
7174
|
-
showFilters: 'showFilters',
|
|
7175
|
-
hideFilters: 'hideFilters',
|
|
7176
|
-
resetSorting: 'resetSorting',
|
|
7177
|
-
resetSearching: 'resetSearching',
|
|
7178
|
-
role: 'role',
|
|
7179
|
-
confirmTitle: 'confirmTitle',
|
|
7180
|
-
confirm: 'confirm',
|
|
7181
|
-
cancel: 'cancel',
|
|
7182
|
-
confirmUnknown: 'confirmUnknown'
|
|
7183
|
-
};
|
|
7421
|
+
function _extends() {
|
|
7422
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
7423
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
7424
|
+
var t = arguments[e];
|
|
7425
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
7426
|
+
}
|
|
7427
|
+
return n;
|
|
7428
|
+
}, _extends.apply(null, arguments);
|
|
7429
|
+
}
|
|
7184
7430
|
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
const [sorting, setSorting] = useState(null);
|
|
7192
|
-
const [collapsed, setCollapsed] = useState(() => {
|
|
7193
|
-
const stored = localStorage.getItem('filtersCollapsed');
|
|
7194
|
-
return stored === 'true';
|
|
7195
|
-
});
|
|
7196
|
-
const [modalState, setModalState] = useState({
|
|
7197
|
-
isOpen: false,
|
|
7198
|
-
label: '',
|
|
7199
|
-
key: '',
|
|
7200
|
-
onConfirm: null
|
|
7201
|
-
});
|
|
7202
|
-
useEffect(() => {
|
|
7203
|
-
localStorage.setItem('filtersCollapsed', collapsed);
|
|
7204
|
-
}, [collapsed]);
|
|
7431
|
+
function SearchInput({
|
|
7432
|
+
pushUrlParamObj = null,
|
|
7433
|
+
...props
|
|
7434
|
+
}) {
|
|
7435
|
+
const key = pushUrlParamObj || "search";
|
|
7436
|
+
const [value, setValue] = React__default.useState("");
|
|
7205
7437
|
|
|
7206
|
-
//
|
|
7207
|
-
|
|
7208
|
-
|
|
7438
|
+
// On mount, read the URL param and set value
|
|
7439
|
+
React__default.useEffect(() => {
|
|
7440
|
+
const params = new URLSearchParams(window.location.search);
|
|
7441
|
+
const urlValue = params.get(key) || "";
|
|
7442
|
+
setValue(urlValue);
|
|
7209
7443
|
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7444
|
+
// Listen for popstate (browser navigation)
|
|
7445
|
+
const onPopState = () => {
|
|
7446
|
+
const params = new URLSearchParams(window.location.search);
|
|
7447
|
+
setValue(params.get(key) || "");
|
|
7448
|
+
};
|
|
7449
|
+
window.addEventListener("popstate", onPopState);
|
|
7450
|
+
return () => window.removeEventListener("popstate", onPopState);
|
|
7451
|
+
}, [key]);
|
|
7452
|
+
const setUrlParam = val => {
|
|
7453
|
+
const params = new URLSearchParams(window.location.search);
|
|
7454
|
+
if (val && val.length > 0) {
|
|
7455
|
+
params.set(key, val);
|
|
7456
|
+
} else {
|
|
7457
|
+
params.delete(key);
|
|
7458
|
+
}
|
|
7459
|
+
const newUrl = window.location.pathname + (params.toString() ? "?" + params.toString() : "");
|
|
7460
|
+
window.history.replaceState({}, "", newUrl);
|
|
7461
|
+
};
|
|
7462
|
+
const handleChange = e => {
|
|
7463
|
+
const newValue = e.target.value;
|
|
7464
|
+
setValue(newValue);
|
|
7465
|
+
setUrlParam(newValue);
|
|
7218
7466
|
};
|
|
7467
|
+
const handleClear = () => {
|
|
7468
|
+
setValue("");
|
|
7469
|
+
setUrlParam("");
|
|
7470
|
+
};
|
|
7471
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
7472
|
+
title: "tooltip",
|
|
7473
|
+
style: {
|
|
7474
|
+
position: "relative",
|
|
7475
|
+
display: "inline-block",
|
|
7476
|
+
height: "34px",
|
|
7477
|
+
verticalAlign: "middle"
|
|
7478
|
+
}
|
|
7479
|
+
}, /*#__PURE__*/React__default.createElement("input", _extends({
|
|
7480
|
+
className: "basic-input",
|
|
7481
|
+
value: value,
|
|
7482
|
+
style: {
|
|
7483
|
+
marginBottom: "10px",
|
|
7484
|
+
padding: "5px",
|
|
7485
|
+
width: "200px",
|
|
7486
|
+
paddingRight: value ? "24px" : undefined,
|
|
7487
|
+
height: "100%",
|
|
7488
|
+
boxSizing: "border-box"
|
|
7489
|
+
},
|
|
7490
|
+
onChange: handleChange
|
|
7491
|
+
}, props)), value && /*#__PURE__*/React__default.createElement("span", {
|
|
7492
|
+
onClick: handleClear,
|
|
7493
|
+
title: "Clear search",
|
|
7494
|
+
style: {
|
|
7495
|
+
position: "absolute",
|
|
7496
|
+
right: "10px",
|
|
7497
|
+
top: "50%",
|
|
7498
|
+
transform: "translateY(-50%)",
|
|
7499
|
+
cursor: "pointer",
|
|
7500
|
+
fontSize: "14px",
|
|
7501
|
+
color: "#000000ff",
|
|
7502
|
+
lineHeight: "1"
|
|
7503
|
+
}
|
|
7504
|
+
}, "\u2716"));
|
|
7505
|
+
}
|
|
7506
|
+
|
|
7507
|
+
/*
|
|
7508
|
+
Reusable IconInput component
|
|
7509
|
+
Props:
|
|
7510
|
+
icon: ReactNode or string to render
|
|
7511
|
+
title: tooltip text
|
|
7512
|
+
ariaLabel: accessible label (falls back to title or stringified icon)
|
|
7513
|
+
onClick: callback fired after internal URL logic (receives event & active state)
|
|
7514
|
+
size: number (px) for square hit area
|
|
7515
|
+
disabled: boolean
|
|
7516
|
+
className, style: customization
|
|
7517
|
+
pushUrlParamObj: string | false -> if provided, component will write to that URL param
|
|
7518
|
+
pushValue: value written to param when activated (default '1')
|
|
7519
|
+
toggle: boolean -> if true acts like a toggle, else just sets param
|
|
7520
|
+
multiUrlList: boolean -> if true treats param as comma-separated list; clicking toggles pushValue in list
|
|
7521
|
+
activeColor: color when active
|
|
7522
|
+
inactiveColor: color when inactive
|
|
7523
|
+
*/
|
|
7524
|
+
|
|
7525
|
+
function IconInput({
|
|
7526
|
+
icon,
|
|
7527
|
+
title,
|
|
7528
|
+
ariaLabel,
|
|
7529
|
+
onClick,
|
|
7530
|
+
size = 32,
|
|
7531
|
+
disabled = false,
|
|
7532
|
+
className = "",
|
|
7533
|
+
style = {},
|
|
7534
|
+
pushUrlParamObj = false,
|
|
7535
|
+
pushValue = "1",
|
|
7536
|
+
toggle = true,
|
|
7537
|
+
multiUrlList = false,
|
|
7538
|
+
activeColor = "#1d4ed8",
|
|
7539
|
+
inactiveColor = "#555",
|
|
7540
|
+
onAction = null
|
|
7541
|
+
}) {
|
|
7542
|
+
const paramKey = pushUrlParamObj || null;
|
|
7543
|
+
const [active, setActive] = useState(() => {
|
|
7544
|
+
if (!paramKey) return false;
|
|
7545
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
7546
|
+
const raw = params.get(paramKey);
|
|
7547
|
+
if (!raw) return false;
|
|
7548
|
+
if (multiUrlList) {
|
|
7549
|
+
const arr = raw.split(',').filter(Boolean);
|
|
7550
|
+
return arr.includes(String(pushValue));
|
|
7551
|
+
}
|
|
7552
|
+
return raw === String(pushValue);
|
|
7553
|
+
});
|
|
7554
|
+
|
|
7555
|
+
// Auto-update active state when URL param changes
|
|
7219
7556
|
useEffect(() => {
|
|
7220
|
-
|
|
7221
|
-
const
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7557
|
+
if (!paramKey) return;
|
|
7558
|
+
const syncFromUrl = () => {
|
|
7559
|
+
const params = new URLSearchParams(window.location.search);
|
|
7560
|
+
const raw = params.get(paramKey);
|
|
7561
|
+
let nextActive = false;
|
|
7562
|
+
if (raw) {
|
|
7563
|
+
if (multiUrlList) {
|
|
7564
|
+
const arr = raw.split(',').filter(Boolean);
|
|
7565
|
+
nextActive = arr.includes(String(pushValue));
|
|
7566
|
+
} else {
|
|
7567
|
+
nextActive = raw === String(pushValue);
|
|
7568
|
+
}
|
|
7569
|
+
}
|
|
7570
|
+
setActive(nextActive);
|
|
7571
|
+
};
|
|
7572
|
+
syncFromUrl();
|
|
7573
|
+
window.addEventListener("popstate", syncFromUrl);
|
|
7574
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
7575
|
+
const patchHistory = type => {
|
|
7576
|
+
const orig = window.history[type];
|
|
7577
|
+
window.history[type] = function () {
|
|
7578
|
+
const rv = orig.apply(this, arguments);
|
|
7579
|
+
window.dispatchEvent(new Event(type));
|
|
7580
|
+
return rv;
|
|
7581
|
+
};
|
|
7582
|
+
};
|
|
7583
|
+
patchHistory('pushState');
|
|
7584
|
+
patchHistory('replaceState');
|
|
7585
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
7586
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
7587
|
+
return () => {
|
|
7588
|
+
window.removeEventListener("popstate", syncFromUrl);
|
|
7589
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
7590
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
7591
|
+
};
|
|
7592
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7593
|
+
}, [paramKey, multiUrlList, pushValue]);
|
|
7594
|
+
|
|
7595
|
+
// (Removed effect-based initialization; using lazy useState instead to satisfy lint rule.)
|
|
7596
|
+
|
|
7597
|
+
const updateUrl = useCallback(nextActive => {
|
|
7598
|
+
if (!paramKey) return;
|
|
7599
|
+
const params = new URLSearchParams(window.location.search);
|
|
7600
|
+
const current = params.get(paramKey);
|
|
7601
|
+
if (multiUrlList) {
|
|
7602
|
+
let list = current ? current.split(",").filter(Boolean) : [];
|
|
7603
|
+
const idx = list.indexOf(String(pushValue));
|
|
7604
|
+
if (nextActive) {
|
|
7605
|
+
if (idx === -1) list.push(String(pushValue));
|
|
7226
7606
|
} else {
|
|
7227
|
-
|
|
7607
|
+
if (idx !== -1) list.splice(idx, 1);
|
|
7228
7608
|
}
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
}, []);
|
|
7234
|
-
useEffect(() => {
|
|
7235
|
-
const savedFilters = localStorage.getItem('adminFilters');
|
|
7236
|
-
if (savedFilters) {
|
|
7237
|
-
const parsed = JSON.parse(savedFilters);
|
|
7238
|
-
Object.entries(parsed).forEach(([key, value]) => {
|
|
7239
|
-
onChange?.(key, value);
|
|
7240
|
-
});
|
|
7241
|
-
}
|
|
7242
|
-
}, []);
|
|
7243
|
-
useEffect(() => {
|
|
7244
|
-
const currentValues = {};
|
|
7245
|
-
config.forEach(item => {
|
|
7246
|
-
if (item.type !== 'button' && item.type !== 'icon') {
|
|
7247
|
-
currentValues[item.key] = item.value;
|
|
7609
|
+
if (list.length === 0) {
|
|
7610
|
+
params.delete(paramKey);
|
|
7611
|
+
} else {
|
|
7612
|
+
params.set(paramKey, list.join(","));
|
|
7248
7613
|
}
|
|
7249
|
-
}
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
setModalState({
|
|
7260
|
-
isOpen: false,
|
|
7261
|
-
label: '',
|
|
7262
|
-
key: '',
|
|
7263
|
-
onConfirm: null
|
|
7264
|
-
});
|
|
7614
|
+
} else {
|
|
7615
|
+
if (nextActive) {
|
|
7616
|
+
params.set(paramKey, String(pushValue));
|
|
7617
|
+
} else {
|
|
7618
|
+
if (toggle) {
|
|
7619
|
+
params.delete(paramKey);
|
|
7620
|
+
} else {
|
|
7621
|
+
// If not toggle, leave value as-is (or could clear)
|
|
7622
|
+
params.delete(paramKey);
|
|
7623
|
+
}
|
|
7265
7624
|
}
|
|
7266
|
-
}
|
|
7625
|
+
}
|
|
7626
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
7627
|
+
window.history.replaceState({}, "", newUrl);
|
|
7628
|
+
}, [paramKey, multiUrlList, pushValue, toggle]);
|
|
7629
|
+
const handleActivate = e => {
|
|
7630
|
+
if (disabled) return;
|
|
7631
|
+
let nextActive = active;
|
|
7632
|
+
if (toggle || multiUrlList) {
|
|
7633
|
+
nextActive = !active;
|
|
7634
|
+
} else {
|
|
7635
|
+
nextActive = true; // one-shot set
|
|
7636
|
+
}
|
|
7637
|
+
setActive(nextActive);
|
|
7638
|
+
updateUrl(nextActive);
|
|
7639
|
+
onClick?.(e, nextActive);
|
|
7267
7640
|
};
|
|
7268
|
-
const
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
});
|
|
7641
|
+
const handleKey = e => {
|
|
7642
|
+
if (disabled) return;
|
|
7643
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
7644
|
+
e.preventDefault();
|
|
7645
|
+
handleActivate(e);
|
|
7646
|
+
}
|
|
7275
7647
|
};
|
|
7276
|
-
const
|
|
7648
|
+
const label = ariaLabel || title || (typeof icon === "string" ? icon : "icon button");
|
|
7649
|
+
const baseStyle = {
|
|
7650
|
+
display: "inline-flex",
|
|
7651
|
+
alignItems: "center",
|
|
7652
|
+
justifyContent: "center",
|
|
7653
|
+
width: size,
|
|
7654
|
+
height: size,
|
|
7655
|
+
fontSize: Math.floor(size * 0.6),
|
|
7656
|
+
lineHeight: 1,
|
|
7657
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
7658
|
+
userSelect: "none",
|
|
7659
|
+
borderRadius: 6,
|
|
7660
|
+
border: "1px solid #ccc",
|
|
7661
|
+
background: active ? "#e0f2fe" : "#f5f5f5",
|
|
7662
|
+
color: active ? activeColor : inactiveColor,
|
|
7663
|
+
transition: "background 120ms, color 120ms, box-shadow 120ms",
|
|
7664
|
+
boxShadow: active ? "0 0 0 2px rgba(29,78,216,0.3)" : "none",
|
|
7665
|
+
...style
|
|
7666
|
+
};
|
|
7667
|
+
return /*#__PURE__*/React__default.createElement("span", {
|
|
7668
|
+
role: "button",
|
|
7669
|
+
"aria-label": label,
|
|
7670
|
+
"aria-pressed": toggle || multiUrlList ? active : undefined,
|
|
7671
|
+
tabIndex: disabled ? -1 : 0,
|
|
7672
|
+
title: title,
|
|
7673
|
+
onClick: onAction,
|
|
7674
|
+
onKeyDown: handleKey,
|
|
7675
|
+
className: `icon-input ${className}`.trim(),
|
|
7676
|
+
style: baseStyle,
|
|
7677
|
+
"data-active": active ? "true" : "false"
|
|
7678
|
+
}, icon);
|
|
7679
|
+
}
|
|
7680
|
+
|
|
7681
|
+
var propTypes = {exports: {}};
|
|
7277
7682
|
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
if (!urSearchParams) return;
|
|
7284
|
-
try {
|
|
7285
|
-
const url = new URL(window.location.href);
|
|
7286
|
-
if (extraSearchTerm && String(extraSearchTerm).length > 0) {
|
|
7287
|
-
url.searchParams.set('search', String(extraSearchTerm));
|
|
7288
|
-
} else {
|
|
7289
|
-
url.searchParams.delete('search');
|
|
7290
|
-
}
|
|
7291
|
-
window.history.replaceState({}, '', url.toString());
|
|
7292
|
-
} catch (e) {
|
|
7293
|
-
// fallback: do nothing if URL constructor fails (very unlikely in browsers)
|
|
7294
|
-
}
|
|
7295
|
-
}, [urSearchParams, extraSearchTerm]);
|
|
7683
|
+
/*
|
|
7684
|
+
object-assign
|
|
7685
|
+
(c) Sindre Sorhus
|
|
7686
|
+
@license MIT
|
|
7687
|
+
*/
|
|
7296
7688
|
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7312
|
-
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7689
|
+
var objectAssign;
|
|
7690
|
+
var hasRequiredObjectAssign;
|
|
7691
|
+
|
|
7692
|
+
function requireObjectAssign () {
|
|
7693
|
+
if (hasRequiredObjectAssign) return objectAssign;
|
|
7694
|
+
hasRequiredObjectAssign = 1;
|
|
7695
|
+
/* eslint-disable no-unused-vars */
|
|
7696
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
7697
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
7698
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
7699
|
+
|
|
7700
|
+
function toObject(val) {
|
|
7701
|
+
if (val === null || val === undefined) {
|
|
7702
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
7703
|
+
}
|
|
7704
|
+
|
|
7705
|
+
return Object(val);
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7708
|
+
function shouldUseNative() {
|
|
7709
|
+
try {
|
|
7710
|
+
if (!Object.assign) {
|
|
7711
|
+
return false;
|
|
7712
|
+
}
|
|
7713
|
+
|
|
7714
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
7715
|
+
|
|
7716
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
7717
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
7718
|
+
test1[5] = 'de';
|
|
7719
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
7720
|
+
return false;
|
|
7721
|
+
}
|
|
7722
|
+
|
|
7723
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
7724
|
+
var test2 = {};
|
|
7725
|
+
for (var i = 0; i < 10; i++) {
|
|
7726
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
7727
|
+
}
|
|
7728
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
7729
|
+
return test2[n];
|
|
7730
|
+
});
|
|
7731
|
+
if (order2.join('') !== '0123456789') {
|
|
7732
|
+
return false;
|
|
7733
|
+
}
|
|
7734
|
+
|
|
7735
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
7736
|
+
var test3 = {};
|
|
7737
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
7738
|
+
test3[letter] = letter;
|
|
7739
|
+
});
|
|
7740
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
7741
|
+
'abcdefghijklmnopqrst') {
|
|
7742
|
+
return false;
|
|
7743
|
+
}
|
|
7744
|
+
|
|
7745
|
+
return true;
|
|
7746
|
+
} catch (err) {
|
|
7747
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
7748
|
+
return false;
|
|
7749
|
+
}
|
|
7750
|
+
}
|
|
7751
|
+
|
|
7752
|
+
objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
7753
|
+
var from;
|
|
7754
|
+
var to = toObject(target);
|
|
7755
|
+
var symbols;
|
|
7756
|
+
|
|
7757
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
7758
|
+
from = Object(arguments[s]);
|
|
7759
|
+
|
|
7760
|
+
for (var key in from) {
|
|
7761
|
+
if (hasOwnProperty.call(from, key)) {
|
|
7762
|
+
to[key] = from[key];
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7765
|
+
|
|
7766
|
+
if (getOwnPropertySymbols) {
|
|
7767
|
+
symbols = getOwnPropertySymbols(from);
|
|
7768
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
7769
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
7770
|
+
to[symbols[i]] = from[symbols[i]];
|
|
7771
|
+
}
|
|
7772
|
+
}
|
|
7773
|
+
}
|
|
7774
|
+
}
|
|
7775
|
+
|
|
7776
|
+
return to;
|
|
7777
|
+
};
|
|
7778
|
+
return objectAssign;
|
|
7779
|
+
}
|
|
7780
|
+
|
|
7781
|
+
/**
|
|
7782
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7783
|
+
*
|
|
7784
|
+
* This source code is licensed under the MIT license found in the
|
|
7785
|
+
* LICENSE file in the root directory of this source tree.
|
|
7786
|
+
*/
|
|
7787
|
+
|
|
7788
|
+
var ReactPropTypesSecret_1;
|
|
7789
|
+
var hasRequiredReactPropTypesSecret;
|
|
7790
|
+
|
|
7791
|
+
function requireReactPropTypesSecret () {
|
|
7792
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
7793
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
7794
|
+
|
|
7795
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
7796
|
+
|
|
7797
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
7798
|
+
return ReactPropTypesSecret_1;
|
|
7799
|
+
}
|
|
7800
|
+
|
|
7801
|
+
var has;
|
|
7802
|
+
var hasRequiredHas;
|
|
7803
|
+
|
|
7804
|
+
function requireHas () {
|
|
7805
|
+
if (hasRequiredHas) return has;
|
|
7806
|
+
hasRequiredHas = 1;
|
|
7807
|
+
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
7808
|
+
return has;
|
|
7809
|
+
}
|
|
7810
|
+
|
|
7811
|
+
/**
|
|
7812
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7813
|
+
*
|
|
7814
|
+
* This source code is licensed under the MIT license found in the
|
|
7815
|
+
* LICENSE file in the root directory of this source tree.
|
|
7816
|
+
*/
|
|
7817
|
+
|
|
7818
|
+
var checkPropTypes_1;
|
|
7819
|
+
var hasRequiredCheckPropTypes;
|
|
7820
|
+
|
|
7821
|
+
function requireCheckPropTypes () {
|
|
7822
|
+
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
7823
|
+
hasRequiredCheckPropTypes = 1;
|
|
7824
|
+
|
|
7825
|
+
var printWarning = function() {};
|
|
7826
|
+
|
|
7827
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7828
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
7829
|
+
var loggedTypeFailures = {};
|
|
7830
|
+
var has = /*@__PURE__*/ requireHas();
|
|
7831
|
+
|
|
7832
|
+
printWarning = function(text) {
|
|
7833
|
+
var message = 'Warning: ' + text;
|
|
7834
|
+
if (typeof console !== 'undefined') {
|
|
7835
|
+
console.error(message);
|
|
7836
|
+
}
|
|
7837
|
+
try {
|
|
7838
|
+
// --- Welcome to debugging React ---
|
|
7839
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
7840
|
+
// to find the callsite that caused this warning to fire.
|
|
7841
|
+
throw new Error(message);
|
|
7842
|
+
} catch (x) { /**/ }
|
|
7843
|
+
};
|
|
7844
|
+
}
|
|
7845
|
+
|
|
7846
|
+
/**
|
|
7847
|
+
* Assert that the values match with the type specs.
|
|
7848
|
+
* Error messages are memorized and will only be shown once.
|
|
7849
|
+
*
|
|
7850
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
7851
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
7852
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
7853
|
+
* @param {string} componentName Name of the component for error messages.
|
|
7854
|
+
* @param {?Function} getStack Returns the component stack.
|
|
7855
|
+
* @private
|
|
7856
|
+
*/
|
|
7857
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
7858
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7859
|
+
for (var typeSpecName in typeSpecs) {
|
|
7860
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
7861
|
+
var error;
|
|
7862
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
7863
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
7864
|
+
// After these have been cleaned up, we'll let them throw.
|
|
7865
|
+
try {
|
|
7866
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
7867
|
+
// behavior as without this statement except with a better message.
|
|
7868
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
7869
|
+
var err = Error(
|
|
7870
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
7871
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
|
7872
|
+
'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
|
7873
|
+
);
|
|
7874
|
+
err.name = 'Invariant Violation';
|
|
7875
|
+
throw err;
|
|
7876
|
+
}
|
|
7877
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
7878
|
+
} catch (ex) {
|
|
7879
|
+
error = ex;
|
|
7880
|
+
}
|
|
7881
|
+
if (error && !(error instanceof Error)) {
|
|
7882
|
+
printWarning(
|
|
7883
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
7884
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
7885
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
7886
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
7887
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
7888
|
+
'shape all require an argument).'
|
|
7889
|
+
);
|
|
7890
|
+
}
|
|
7891
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
7892
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
7893
|
+
// same error.
|
|
7894
|
+
loggedTypeFailures[error.message] = true;
|
|
7895
|
+
|
|
7896
|
+
var stack = getStack ? getStack() : '';
|
|
7897
|
+
|
|
7898
|
+
printWarning(
|
|
7899
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
7900
|
+
);
|
|
7901
|
+
}
|
|
7902
|
+
}
|
|
7903
|
+
}
|
|
7904
|
+
}
|
|
7905
|
+
}
|
|
7906
|
+
|
|
7907
|
+
/**
|
|
7908
|
+
* Resets warning cache when testing.
|
|
7909
|
+
*
|
|
7910
|
+
* @private
|
|
7911
|
+
*/
|
|
7912
|
+
checkPropTypes.resetWarningCache = function() {
|
|
7913
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7914
|
+
loggedTypeFailures = {};
|
|
7915
|
+
}
|
|
7916
|
+
};
|
|
7917
|
+
|
|
7918
|
+
checkPropTypes_1 = checkPropTypes;
|
|
7919
|
+
return checkPropTypes_1;
|
|
7920
|
+
}
|
|
7921
|
+
|
|
7922
|
+
/**
|
|
7923
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7924
|
+
*
|
|
7925
|
+
* This source code is licensed under the MIT license found in the
|
|
7926
|
+
* LICENSE file in the root directory of this source tree.
|
|
7927
|
+
*/
|
|
7928
|
+
|
|
7929
|
+
var factoryWithTypeCheckers;
|
|
7930
|
+
var hasRequiredFactoryWithTypeCheckers;
|
|
7931
|
+
|
|
7932
|
+
function requireFactoryWithTypeCheckers () {
|
|
7933
|
+
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
7934
|
+
hasRequiredFactoryWithTypeCheckers = 1;
|
|
7935
|
+
|
|
7936
|
+
var ReactIs = requireReactIs();
|
|
7937
|
+
var assign = requireObjectAssign();
|
|
7938
|
+
|
|
7939
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
7940
|
+
var has = /*@__PURE__*/ requireHas();
|
|
7941
|
+
var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
|
|
7942
|
+
|
|
7943
|
+
var printWarning = function() {};
|
|
7944
|
+
|
|
7945
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7946
|
+
printWarning = function(text) {
|
|
7947
|
+
var message = 'Warning: ' + text;
|
|
7948
|
+
if (typeof console !== 'undefined') {
|
|
7949
|
+
console.error(message);
|
|
7950
|
+
}
|
|
7951
|
+
try {
|
|
7952
|
+
// --- Welcome to debugging React ---
|
|
7953
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
7954
|
+
// to find the callsite that caused this warning to fire.
|
|
7955
|
+
throw new Error(message);
|
|
7956
|
+
} catch (x) {}
|
|
7957
|
+
};
|
|
7958
|
+
}
|
|
7959
|
+
|
|
7960
|
+
function emptyFunctionThatReturnsNull() {
|
|
7961
|
+
return null;
|
|
7962
|
+
}
|
|
7504
7963
|
|
|
7505
|
-
|
|
7506
|
-
|
|
7964
|
+
factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
7965
|
+
/* global Symbol */
|
|
7966
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
7967
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
7968
|
+
|
|
7969
|
+
/**
|
|
7970
|
+
* Returns the iterator method function contained on the iterable object.
|
|
7971
|
+
*
|
|
7972
|
+
* Be sure to invoke the function with the iterable as context:
|
|
7973
|
+
*
|
|
7974
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
7975
|
+
* if (iteratorFn) {
|
|
7976
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
7977
|
+
* ...
|
|
7978
|
+
* }
|
|
7979
|
+
*
|
|
7980
|
+
* @param {?object} maybeIterable
|
|
7981
|
+
* @return {?function}
|
|
7982
|
+
*/
|
|
7983
|
+
function getIteratorFn(maybeIterable) {
|
|
7984
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
7985
|
+
if (typeof iteratorFn === 'function') {
|
|
7986
|
+
return iteratorFn;
|
|
7987
|
+
}
|
|
7988
|
+
}
|
|
7989
|
+
|
|
7990
|
+
/**
|
|
7991
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
7992
|
+
* supplied to React components. Example usage:
|
|
7993
|
+
*
|
|
7994
|
+
* var Props = require('ReactPropTypes');
|
|
7995
|
+
* var MyArticle = React.createClass({
|
|
7996
|
+
* propTypes: {
|
|
7997
|
+
* // An optional string prop named "description".
|
|
7998
|
+
* description: Props.string,
|
|
7999
|
+
*
|
|
8000
|
+
* // A required enum prop named "category".
|
|
8001
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
8002
|
+
*
|
|
8003
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
8004
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
8005
|
+
* },
|
|
8006
|
+
* render: function() { ... }
|
|
8007
|
+
* });
|
|
8008
|
+
*
|
|
8009
|
+
* A more formal specification of how these methods are used:
|
|
8010
|
+
*
|
|
8011
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
8012
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
8013
|
+
*
|
|
8014
|
+
* Each and every declaration produces a function with the same signature. This
|
|
8015
|
+
* allows the creation of custom validation functions. For example:
|
|
8016
|
+
*
|
|
8017
|
+
* var MyLink = React.createClass({
|
|
8018
|
+
* propTypes: {
|
|
8019
|
+
* // An optional string or URI prop named "href".
|
|
8020
|
+
* href: function(props, propName, componentName) {
|
|
8021
|
+
* var propValue = props[propName];
|
|
8022
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
8023
|
+
* !(propValue instanceof URI)) {
|
|
8024
|
+
* return new Error(
|
|
8025
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
8026
|
+
* componentName
|
|
8027
|
+
* );
|
|
8028
|
+
* }
|
|
8029
|
+
* }
|
|
8030
|
+
* },
|
|
8031
|
+
* render: function() {...}
|
|
8032
|
+
* });
|
|
8033
|
+
*
|
|
8034
|
+
* @internal
|
|
8035
|
+
*/
|
|
8036
|
+
|
|
8037
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
8038
|
+
|
|
8039
|
+
// Important!
|
|
8040
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
8041
|
+
var ReactPropTypes = {
|
|
8042
|
+
array: createPrimitiveTypeChecker('array'),
|
|
8043
|
+
bigint: createPrimitiveTypeChecker('bigint'),
|
|
8044
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
8045
|
+
func: createPrimitiveTypeChecker('function'),
|
|
8046
|
+
number: createPrimitiveTypeChecker('number'),
|
|
8047
|
+
object: createPrimitiveTypeChecker('object'),
|
|
8048
|
+
string: createPrimitiveTypeChecker('string'),
|
|
8049
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
8050
|
+
|
|
8051
|
+
any: createAnyTypeChecker(),
|
|
8052
|
+
arrayOf: createArrayOfTypeChecker,
|
|
8053
|
+
element: createElementTypeChecker(),
|
|
8054
|
+
elementType: createElementTypeTypeChecker(),
|
|
8055
|
+
instanceOf: createInstanceTypeChecker,
|
|
8056
|
+
node: createNodeChecker(),
|
|
8057
|
+
objectOf: createObjectOfTypeChecker,
|
|
8058
|
+
oneOf: createEnumTypeChecker,
|
|
8059
|
+
oneOfType: createUnionTypeChecker,
|
|
8060
|
+
shape: createShapeTypeChecker,
|
|
8061
|
+
exact: createStrictShapeTypeChecker,
|
|
8062
|
+
};
|
|
8063
|
+
|
|
8064
|
+
/**
|
|
8065
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
8066
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
8067
|
+
*/
|
|
8068
|
+
/*eslint-disable no-self-compare*/
|
|
8069
|
+
function is(x, y) {
|
|
8070
|
+
// SameValue algorithm
|
|
8071
|
+
if (x === y) {
|
|
8072
|
+
// Steps 1-5, 7-10
|
|
8073
|
+
// Steps 6.b-6.e: +0 != -0
|
|
8074
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
8075
|
+
} else {
|
|
8076
|
+
// Step 6.a: NaN == NaN
|
|
8077
|
+
return x !== x && y !== y;
|
|
8078
|
+
}
|
|
8079
|
+
}
|
|
8080
|
+
/*eslint-enable no-self-compare*/
|
|
8081
|
+
|
|
8082
|
+
/**
|
|
8083
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
8084
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
8085
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
8086
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
8087
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
8088
|
+
*/
|
|
8089
|
+
function PropTypeError(message, data) {
|
|
8090
|
+
this.message = message;
|
|
8091
|
+
this.data = data && typeof data === 'object' ? data: {};
|
|
8092
|
+
this.stack = '';
|
|
8093
|
+
}
|
|
8094
|
+
// Make `instanceof Error` still work for returned errors.
|
|
8095
|
+
PropTypeError.prototype = Error.prototype;
|
|
8096
|
+
|
|
8097
|
+
function createChainableTypeChecker(validate) {
|
|
8098
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8099
|
+
var manualPropTypeCallCache = {};
|
|
8100
|
+
var manualPropTypeWarningCount = 0;
|
|
8101
|
+
}
|
|
8102
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
8103
|
+
componentName = componentName || ANONYMOUS;
|
|
8104
|
+
propFullName = propFullName || propName;
|
|
8105
|
+
|
|
8106
|
+
if (secret !== ReactPropTypesSecret) {
|
|
8107
|
+
if (throwOnDirectAccess) {
|
|
8108
|
+
// New behavior only for users of `prop-types` package
|
|
8109
|
+
var err = new Error(
|
|
8110
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
8111
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
8112
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
8113
|
+
);
|
|
8114
|
+
err.name = 'Invariant Violation';
|
|
8115
|
+
throw err;
|
|
8116
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
8117
|
+
// Old behavior for people using React.PropTypes
|
|
8118
|
+
var cacheKey = componentName + ':' + propName;
|
|
8119
|
+
if (
|
|
8120
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
8121
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
8122
|
+
manualPropTypeWarningCount < 3
|
|
8123
|
+
) {
|
|
8124
|
+
printWarning(
|
|
8125
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
8126
|
+
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
8127
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
8128
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
8129
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
8130
|
+
);
|
|
8131
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
8132
|
+
manualPropTypeWarningCount++;
|
|
8133
|
+
}
|
|
8134
|
+
}
|
|
8135
|
+
}
|
|
8136
|
+
if (props[propName] == null) {
|
|
8137
|
+
if (isRequired) {
|
|
8138
|
+
if (props[propName] === null) {
|
|
8139
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
8140
|
+
}
|
|
8141
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
8142
|
+
}
|
|
8143
|
+
return null;
|
|
8144
|
+
} else {
|
|
8145
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
8146
|
+
}
|
|
8147
|
+
}
|
|
8148
|
+
|
|
8149
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
8150
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
8151
|
+
|
|
8152
|
+
return chainedCheckType;
|
|
8153
|
+
}
|
|
8154
|
+
|
|
8155
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
8156
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
8157
|
+
var propValue = props[propName];
|
|
8158
|
+
var propType = getPropType(propValue);
|
|
8159
|
+
if (propType !== expectedType) {
|
|
8160
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
8161
|
+
// check, but we can offer a more precise error message here rather than
|
|
8162
|
+
// 'of type `object`'.
|
|
8163
|
+
var preciseType = getPreciseType(propValue);
|
|
8164
|
+
|
|
8165
|
+
return new PropTypeError(
|
|
8166
|
+
'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
|
8167
|
+
{expectedType: expectedType}
|
|
8168
|
+
);
|
|
8169
|
+
}
|
|
8170
|
+
return null;
|
|
8171
|
+
}
|
|
8172
|
+
return createChainableTypeChecker(validate);
|
|
8173
|
+
}
|
|
8174
|
+
|
|
8175
|
+
function createAnyTypeChecker() {
|
|
8176
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
8177
|
+
}
|
|
8178
|
+
|
|
8179
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
8180
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8181
|
+
if (typeof typeChecker !== 'function') {
|
|
8182
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
8183
|
+
}
|
|
8184
|
+
var propValue = props[propName];
|
|
8185
|
+
if (!Array.isArray(propValue)) {
|
|
8186
|
+
var propType = getPropType(propValue);
|
|
8187
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
8188
|
+
}
|
|
8189
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
8190
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
8191
|
+
if (error instanceof Error) {
|
|
8192
|
+
return error;
|
|
8193
|
+
}
|
|
8194
|
+
}
|
|
8195
|
+
return null;
|
|
8196
|
+
}
|
|
8197
|
+
return createChainableTypeChecker(validate);
|
|
8198
|
+
}
|
|
8199
|
+
|
|
8200
|
+
function createElementTypeChecker() {
|
|
8201
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8202
|
+
var propValue = props[propName];
|
|
8203
|
+
if (!isValidElement(propValue)) {
|
|
8204
|
+
var propType = getPropType(propValue);
|
|
8205
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
8206
|
+
}
|
|
8207
|
+
return null;
|
|
8208
|
+
}
|
|
8209
|
+
return createChainableTypeChecker(validate);
|
|
8210
|
+
}
|
|
8211
|
+
|
|
8212
|
+
function createElementTypeTypeChecker() {
|
|
8213
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8214
|
+
var propValue = props[propName];
|
|
8215
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
8216
|
+
var propType = getPropType(propValue);
|
|
8217
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
8218
|
+
}
|
|
8219
|
+
return null;
|
|
8220
|
+
}
|
|
8221
|
+
return createChainableTypeChecker(validate);
|
|
8222
|
+
}
|
|
8223
|
+
|
|
8224
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
8225
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8226
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
8227
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
8228
|
+
var actualClassName = getClassName(props[propName]);
|
|
8229
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
8230
|
+
}
|
|
8231
|
+
return null;
|
|
8232
|
+
}
|
|
8233
|
+
return createChainableTypeChecker(validate);
|
|
8234
|
+
}
|
|
8235
|
+
|
|
8236
|
+
function createEnumTypeChecker(expectedValues) {
|
|
8237
|
+
if (!Array.isArray(expectedValues)) {
|
|
8238
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8239
|
+
if (arguments.length > 1) {
|
|
8240
|
+
printWarning(
|
|
8241
|
+
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
8242
|
+
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
8243
|
+
);
|
|
8244
|
+
} else {
|
|
8245
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8248
|
+
return emptyFunctionThatReturnsNull;
|
|
8249
|
+
}
|
|
8250
|
+
|
|
8251
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8252
|
+
var propValue = props[propName];
|
|
8253
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
8254
|
+
if (is(propValue, expectedValues[i])) {
|
|
8255
|
+
return null;
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
|
|
8259
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
8260
|
+
var type = getPreciseType(value);
|
|
8261
|
+
if (type === 'symbol') {
|
|
8262
|
+
return String(value);
|
|
8263
|
+
}
|
|
8264
|
+
return value;
|
|
8265
|
+
});
|
|
8266
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
8267
|
+
}
|
|
8268
|
+
return createChainableTypeChecker(validate);
|
|
8269
|
+
}
|
|
8270
|
+
|
|
8271
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
8272
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8273
|
+
if (typeof typeChecker !== 'function') {
|
|
8274
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
8275
|
+
}
|
|
8276
|
+
var propValue = props[propName];
|
|
8277
|
+
var propType = getPropType(propValue);
|
|
8278
|
+
if (propType !== 'object') {
|
|
8279
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
8280
|
+
}
|
|
8281
|
+
for (var key in propValue) {
|
|
8282
|
+
if (has(propValue, key)) {
|
|
8283
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8284
|
+
if (error instanceof Error) {
|
|
8285
|
+
return error;
|
|
8286
|
+
}
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
return null;
|
|
8290
|
+
}
|
|
8291
|
+
return createChainableTypeChecker(validate);
|
|
8292
|
+
}
|
|
8293
|
+
|
|
8294
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
8295
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
8296
|
+
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
8297
|
+
return emptyFunctionThatReturnsNull;
|
|
8298
|
+
}
|
|
8299
|
+
|
|
8300
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
8301
|
+
var checker = arrayOfTypeCheckers[i];
|
|
8302
|
+
if (typeof checker !== 'function') {
|
|
8303
|
+
printWarning(
|
|
8304
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
8305
|
+
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
8306
|
+
);
|
|
8307
|
+
return emptyFunctionThatReturnsNull;
|
|
8308
|
+
}
|
|
8309
|
+
}
|
|
8310
|
+
|
|
8311
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8312
|
+
var expectedTypes = [];
|
|
8313
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
8314
|
+
var checker = arrayOfTypeCheckers[i];
|
|
8315
|
+
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
8316
|
+
if (checkerResult == null) {
|
|
8317
|
+
return null;
|
|
8318
|
+
}
|
|
8319
|
+
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
8320
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
8321
|
+
}
|
|
8322
|
+
}
|
|
8323
|
+
var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
|
8324
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
8325
|
+
}
|
|
8326
|
+
return createChainableTypeChecker(validate);
|
|
8327
|
+
}
|
|
8328
|
+
|
|
8329
|
+
function createNodeChecker() {
|
|
8330
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8331
|
+
if (!isNode(props[propName])) {
|
|
8332
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
8333
|
+
}
|
|
8334
|
+
return null;
|
|
8335
|
+
}
|
|
8336
|
+
return createChainableTypeChecker(validate);
|
|
8337
|
+
}
|
|
8338
|
+
|
|
8339
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
8340
|
+
return new PropTypeError(
|
|
8341
|
+
(componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
|
8342
|
+
'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
|
8343
|
+
);
|
|
8344
|
+
}
|
|
8345
|
+
|
|
8346
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
8347
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8348
|
+
var propValue = props[propName];
|
|
8349
|
+
var propType = getPropType(propValue);
|
|
8350
|
+
if (propType !== 'object') {
|
|
8351
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
8352
|
+
}
|
|
8353
|
+
for (var key in shapeTypes) {
|
|
8354
|
+
var checker = shapeTypes[key];
|
|
8355
|
+
if (typeof checker !== 'function') {
|
|
8356
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
8357
|
+
}
|
|
8358
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8359
|
+
if (error) {
|
|
8360
|
+
return error;
|
|
8361
|
+
}
|
|
8362
|
+
}
|
|
8363
|
+
return null;
|
|
8364
|
+
}
|
|
8365
|
+
return createChainableTypeChecker(validate);
|
|
8366
|
+
}
|
|
8367
|
+
|
|
8368
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
8369
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8370
|
+
var propValue = props[propName];
|
|
8371
|
+
var propType = getPropType(propValue);
|
|
8372
|
+
if (propType !== 'object') {
|
|
8373
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
8374
|
+
}
|
|
8375
|
+
// We need to check all keys in case some are required but missing from props.
|
|
8376
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
8377
|
+
for (var key in allKeys) {
|
|
8378
|
+
var checker = shapeTypes[key];
|
|
8379
|
+
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
8380
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
8381
|
+
}
|
|
8382
|
+
if (!checker) {
|
|
8383
|
+
return new PropTypeError(
|
|
8384
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
8385
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
8386
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
8387
|
+
);
|
|
8388
|
+
}
|
|
8389
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8390
|
+
if (error) {
|
|
8391
|
+
return error;
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
return null;
|
|
8395
|
+
}
|
|
8396
|
+
|
|
8397
|
+
return createChainableTypeChecker(validate);
|
|
8398
|
+
}
|
|
8399
|
+
|
|
8400
|
+
function isNode(propValue) {
|
|
8401
|
+
switch (typeof propValue) {
|
|
8402
|
+
case 'number':
|
|
8403
|
+
case 'string':
|
|
8404
|
+
case 'undefined':
|
|
8405
|
+
return true;
|
|
8406
|
+
case 'boolean':
|
|
8407
|
+
return !propValue;
|
|
8408
|
+
case 'object':
|
|
8409
|
+
if (Array.isArray(propValue)) {
|
|
8410
|
+
return propValue.every(isNode);
|
|
8411
|
+
}
|
|
8412
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
8413
|
+
return true;
|
|
8414
|
+
}
|
|
8415
|
+
|
|
8416
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
8417
|
+
if (iteratorFn) {
|
|
8418
|
+
var iterator = iteratorFn.call(propValue);
|
|
8419
|
+
var step;
|
|
8420
|
+
if (iteratorFn !== propValue.entries) {
|
|
8421
|
+
while (!(step = iterator.next()).done) {
|
|
8422
|
+
if (!isNode(step.value)) {
|
|
8423
|
+
return false;
|
|
8424
|
+
}
|
|
8425
|
+
}
|
|
8426
|
+
} else {
|
|
8427
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
8428
|
+
while (!(step = iterator.next()).done) {
|
|
8429
|
+
var entry = step.value;
|
|
8430
|
+
if (entry) {
|
|
8431
|
+
if (!isNode(entry[1])) {
|
|
8432
|
+
return false;
|
|
8433
|
+
}
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
}
|
|
8437
|
+
} else {
|
|
8438
|
+
return false;
|
|
8439
|
+
}
|
|
8440
|
+
|
|
8441
|
+
return true;
|
|
8442
|
+
default:
|
|
8443
|
+
return false;
|
|
8444
|
+
}
|
|
8445
|
+
}
|
|
8446
|
+
|
|
8447
|
+
function isSymbol(propType, propValue) {
|
|
8448
|
+
// Native Symbol.
|
|
8449
|
+
if (propType === 'symbol') {
|
|
8450
|
+
return true;
|
|
8451
|
+
}
|
|
8452
|
+
|
|
8453
|
+
// falsy value can't be a Symbol
|
|
8454
|
+
if (!propValue) {
|
|
8455
|
+
return false;
|
|
8456
|
+
}
|
|
8457
|
+
|
|
8458
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
8459
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
8460
|
+
return true;
|
|
8461
|
+
}
|
|
8462
|
+
|
|
8463
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
8464
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
8465
|
+
return true;
|
|
8466
|
+
}
|
|
8467
|
+
|
|
8468
|
+
return false;
|
|
8469
|
+
}
|
|
8470
|
+
|
|
8471
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
8472
|
+
function getPropType(propValue) {
|
|
8473
|
+
var propType = typeof propValue;
|
|
8474
|
+
if (Array.isArray(propValue)) {
|
|
8475
|
+
return 'array';
|
|
8476
|
+
}
|
|
8477
|
+
if (propValue instanceof RegExp) {
|
|
8478
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
8479
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
8480
|
+
// passes PropTypes.object.
|
|
8481
|
+
return 'object';
|
|
8482
|
+
}
|
|
8483
|
+
if (isSymbol(propType, propValue)) {
|
|
8484
|
+
return 'symbol';
|
|
8485
|
+
}
|
|
8486
|
+
return propType;
|
|
8487
|
+
}
|
|
8488
|
+
|
|
8489
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
8490
|
+
// See `createPrimitiveTypeChecker`.
|
|
8491
|
+
function getPreciseType(propValue) {
|
|
8492
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
8493
|
+
return '' + propValue;
|
|
8494
|
+
}
|
|
8495
|
+
var propType = getPropType(propValue);
|
|
8496
|
+
if (propType === 'object') {
|
|
8497
|
+
if (propValue instanceof Date) {
|
|
8498
|
+
return 'date';
|
|
8499
|
+
} else if (propValue instanceof RegExp) {
|
|
8500
|
+
return 'regexp';
|
|
8501
|
+
}
|
|
8502
|
+
}
|
|
8503
|
+
return propType;
|
|
8504
|
+
}
|
|
8505
|
+
|
|
8506
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
8507
|
+
// For example, "undefined" or "of type array"
|
|
8508
|
+
function getPostfixForTypeWarning(value) {
|
|
8509
|
+
var type = getPreciseType(value);
|
|
8510
|
+
switch (type) {
|
|
8511
|
+
case 'array':
|
|
8512
|
+
case 'object':
|
|
8513
|
+
return 'an ' + type;
|
|
8514
|
+
case 'boolean':
|
|
8515
|
+
case 'date':
|
|
8516
|
+
case 'regexp':
|
|
8517
|
+
return 'a ' + type;
|
|
8518
|
+
default:
|
|
8519
|
+
return type;
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8522
|
+
|
|
8523
|
+
// Returns class name of the object, if any.
|
|
8524
|
+
function getClassName(propValue) {
|
|
8525
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
8526
|
+
return ANONYMOUS;
|
|
8527
|
+
}
|
|
8528
|
+
return propValue.constructor.name;
|
|
8529
|
+
}
|
|
8530
|
+
|
|
8531
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
8532
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
8533
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
8534
|
+
|
|
8535
|
+
return ReactPropTypes;
|
|
8536
|
+
};
|
|
8537
|
+
return factoryWithTypeCheckers;
|
|
8538
|
+
}
|
|
8539
|
+
|
|
8540
|
+
/**
|
|
8541
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
8542
|
+
*
|
|
8543
|
+
* This source code is licensed under the MIT license found in the
|
|
8544
|
+
* LICENSE file in the root directory of this source tree.
|
|
8545
|
+
*/
|
|
8546
|
+
|
|
8547
|
+
var factoryWithThrowingShims;
|
|
8548
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
8549
|
+
|
|
8550
|
+
function requireFactoryWithThrowingShims () {
|
|
8551
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
8552
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
8553
|
+
|
|
8554
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
8555
|
+
|
|
8556
|
+
function emptyFunction() {}
|
|
8557
|
+
function emptyFunctionWithReset() {}
|
|
8558
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
8559
|
+
|
|
8560
|
+
factoryWithThrowingShims = function() {
|
|
8561
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
8562
|
+
if (secret === ReactPropTypesSecret) {
|
|
8563
|
+
// It is still safe when called from React.
|
|
8564
|
+
return;
|
|
8565
|
+
}
|
|
8566
|
+
var err = new Error(
|
|
8567
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
8568
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
8569
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
8570
|
+
);
|
|
8571
|
+
err.name = 'Invariant Violation';
|
|
8572
|
+
throw err;
|
|
8573
|
+
} shim.isRequired = shim;
|
|
8574
|
+
function getShim() {
|
|
8575
|
+
return shim;
|
|
8576
|
+
} // Important!
|
|
8577
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
8578
|
+
var ReactPropTypes = {
|
|
8579
|
+
array: shim,
|
|
8580
|
+
bigint: shim,
|
|
8581
|
+
bool: shim,
|
|
8582
|
+
func: shim,
|
|
8583
|
+
number: shim,
|
|
8584
|
+
object: shim,
|
|
8585
|
+
string: shim,
|
|
8586
|
+
symbol: shim,
|
|
8587
|
+
|
|
8588
|
+
any: shim,
|
|
8589
|
+
arrayOf: getShim,
|
|
8590
|
+
element: shim,
|
|
8591
|
+
elementType: shim,
|
|
8592
|
+
instanceOf: getShim,
|
|
8593
|
+
node: shim,
|
|
8594
|
+
objectOf: getShim,
|
|
8595
|
+
oneOf: getShim,
|
|
8596
|
+
oneOfType: getShim,
|
|
8597
|
+
shape: getShim,
|
|
8598
|
+
exact: getShim,
|
|
8599
|
+
|
|
8600
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
8601
|
+
resetWarningCache: emptyFunction
|
|
8602
|
+
};
|
|
8603
|
+
|
|
8604
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
8605
|
+
|
|
8606
|
+
return ReactPropTypes;
|
|
8607
|
+
};
|
|
8608
|
+
return factoryWithThrowingShims;
|
|
8609
|
+
}
|
|
8610
|
+
|
|
8611
|
+
/**
|
|
8612
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
8613
|
+
*
|
|
8614
|
+
* This source code is licensed under the MIT license found in the
|
|
8615
|
+
* LICENSE file in the root directory of this source tree.
|
|
8616
|
+
*/
|
|
8617
|
+
|
|
8618
|
+
var hasRequiredPropTypes;
|
|
8619
|
+
|
|
8620
|
+
function requirePropTypes () {
|
|
8621
|
+
if (hasRequiredPropTypes) return propTypes.exports;
|
|
8622
|
+
hasRequiredPropTypes = 1;
|
|
8623
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8624
|
+
var ReactIs = requireReactIs();
|
|
8625
|
+
|
|
8626
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
8627
|
+
// http://fb.me/prop-types-in-prod
|
|
8628
|
+
var throwOnDirectAccess = true;
|
|
8629
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
8630
|
+
} else {
|
|
8631
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
8632
|
+
// http://fb.me/prop-types-in-prod
|
|
8633
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
|
|
8634
|
+
}
|
|
8635
|
+
return propTypes.exports;
|
|
8636
|
+
}
|
|
8637
|
+
|
|
8638
|
+
var propTypesExports = /*@__PURE__*/ requirePropTypes();
|
|
8639
|
+
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
8640
|
+
|
|
8641
|
+
/**
|
|
8642
|
+
* DateTimeInput (redesigned) - matches RangePicker visual style with dropdown panel.
|
|
8643
|
+
* Features:
|
|
8644
|
+
* - Single date (and optional time) selection via custom calendar popup
|
|
8645
|
+
* - URL param sync (stores timestamp) same as RangePicker
|
|
8646
|
+
* - Dynamic dropdown positioning (prevents overflow like RangePicker)
|
|
8647
|
+
* - Clear & OK footer actions
|
|
8648
|
+
*/
|
|
8649
|
+
function DateTimeInput({
|
|
8650
|
+
pushUrlParamObj = false,
|
|
8651
|
+
value: controlledValue,
|
|
8652
|
+
onChange,
|
|
8653
|
+
time = false,
|
|
8654
|
+
timeStart,
|
|
8655
|
+
timezone,
|
|
8656
|
+
timeFormat,
|
|
8657
|
+
dateFormat,
|
|
8658
|
+
placeholder = "Select date",
|
|
8659
|
+
disabled = false,
|
|
8660
|
+
className = "",
|
|
8661
|
+
style = {},
|
|
8662
|
+
predefinedRanges = ["today", "yesterday"],
|
|
8663
|
+
...rest
|
|
8664
|
+
}) {
|
|
8665
|
+
const paramKey = pushUrlParamObj || null;
|
|
8666
|
+
|
|
8667
|
+
// Helper: convert timestamp (number|string) to internal input string
|
|
8668
|
+
const toInputString = useCallback(ts => {
|
|
8669
|
+
if (!ts) return "";
|
|
8670
|
+
const d = new Date(Number(ts));
|
|
8671
|
+
if (isNaN(d.getTime())) return "";
|
|
8672
|
+
const yyyy = d.getFullYear();
|
|
8673
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
8674
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
8675
|
+
if (time) {
|
|
8676
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
8677
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
8678
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
8679
|
+
}
|
|
8680
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
8681
|
+
}, [time]);
|
|
8682
|
+
|
|
8683
|
+
// Initial value
|
|
8684
|
+
const [value, setValue] = useState(() => {
|
|
8685
|
+
if (typeof controlledValue !== "undefined") return controlledValue;
|
|
8686
|
+
if (!paramKey) {
|
|
8687
|
+
let d = new Date();
|
|
8688
|
+
if (time && timeStart) {
|
|
8689
|
+
const [h, m] = timeStart.split(":");
|
|
8690
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8691
|
+
}
|
|
8692
|
+
return toInputString(d.getTime());
|
|
8693
|
+
}
|
|
8694
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
8695
|
+
const urlVal = params.get(paramKey);
|
|
8696
|
+
if (urlVal) return toInputString(urlVal);
|
|
8697
|
+
let d = new Date();
|
|
8698
|
+
if (time && timeStart) {
|
|
8699
|
+
const [h, m] = timeStart.split(":");
|
|
8700
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8701
|
+
}
|
|
8702
|
+
return toInputString(d.getTime());
|
|
8703
|
+
});
|
|
8704
|
+
|
|
8705
|
+
// Dropdown state & positioning
|
|
8706
|
+
const [open, setOpen] = useState(false);
|
|
8707
|
+
const dropdownRef = useRef(null);
|
|
8708
|
+
const [dropdownPosition, setDropdownPosition] = useState({
|
|
8709
|
+
left: 0,
|
|
8710
|
+
top: "110%"
|
|
8711
|
+
});
|
|
8712
|
+
|
|
8713
|
+
// Predefined single-date shortcuts
|
|
8714
|
+
const normalizeLabel = lbl => String(lbl).toLowerCase();
|
|
8715
|
+
const createPredefinedItem = useCallback(item => {
|
|
8716
|
+
if (typeof item === 'number') {
|
|
8717
|
+
// number => N days ago
|
|
8718
|
+
return {
|
|
8719
|
+
key: `daysago_${item}`,
|
|
8720
|
+
label: `-${item}d`,
|
|
8721
|
+
getDate: () => {
|
|
8722
|
+
const d = new Date();
|
|
8723
|
+
d.setHours(0, 0, 0, 0);
|
|
8724
|
+
d.setDate(d.getDate() - item);
|
|
8725
|
+
return d;
|
|
8726
|
+
}
|
|
8727
|
+
};
|
|
8728
|
+
}
|
|
8729
|
+
const str = normalizeLabel(item);
|
|
8730
|
+
if (str === 'today') {
|
|
8731
|
+
return {
|
|
8732
|
+
key: 'today',
|
|
8733
|
+
label: 'Today',
|
|
8734
|
+
getDate: () => {
|
|
8735
|
+
const d = new Date();
|
|
8736
|
+
d.setHours(0, 0, 0, 0);
|
|
8737
|
+
return d;
|
|
8738
|
+
}
|
|
8739
|
+
};
|
|
8740
|
+
}
|
|
8741
|
+
if (str === 'yesterday') {
|
|
8742
|
+
return {
|
|
8743
|
+
key: 'yesterday',
|
|
8744
|
+
label: 'Yesterday',
|
|
8745
|
+
getDate: () => {
|
|
8746
|
+
const d = new Date();
|
|
8747
|
+
d.setHours(0, 0, 0, 0);
|
|
8748
|
+
d.setDate(d.getDate() - 1);
|
|
8749
|
+
return d;
|
|
8750
|
+
}
|
|
8751
|
+
};
|
|
8752
|
+
}
|
|
8753
|
+
if (str === 'lastweek') {
|
|
8754
|
+
return {
|
|
8755
|
+
key: 'lastweek',
|
|
8756
|
+
label: 'Last week (Mon)',
|
|
8757
|
+
getDate: () => {
|
|
8758
|
+
// Monday of previous week
|
|
8759
|
+
const d = new Date();
|
|
8760
|
+
d.setHours(0, 0, 0, 0);
|
|
8761
|
+
const day = d.getDay(); // 0 Sun..6 Sat
|
|
8762
|
+
const mondayOffset = day === 0 ? -6 : 1 - day; // days to monday this week
|
|
8763
|
+
d.setDate(d.getDate() + mondayOffset - 7); // previous week's Monday
|
|
8764
|
+
return d;
|
|
8765
|
+
}
|
|
8766
|
+
};
|
|
8767
|
+
}
|
|
8768
|
+
if (str === 'lastmonth') {
|
|
8769
|
+
return {
|
|
8770
|
+
key: 'lastmonth',
|
|
8771
|
+
label: 'First day last month',
|
|
8772
|
+
getDate: () => {
|
|
8773
|
+
const d = new Date();
|
|
8774
|
+
d.setHours(0, 0, 0, 0);
|
|
8775
|
+
d.setMonth(d.getMonth() - 1, 1);
|
|
8776
|
+
return d;
|
|
8777
|
+
}
|
|
8778
|
+
};
|
|
8779
|
+
}
|
|
8780
|
+
if (str === 'thismonth') {
|
|
8781
|
+
return {
|
|
8782
|
+
key: 'thismonth',
|
|
8783
|
+
label: 'First day this month',
|
|
8784
|
+
getDate: () => {
|
|
8785
|
+
const d = new Date();
|
|
8786
|
+
d.setHours(0, 0, 0, 0);
|
|
8787
|
+
d.setDate(1);
|
|
8788
|
+
return d;
|
|
8789
|
+
}
|
|
8790
|
+
};
|
|
8791
|
+
}
|
|
8792
|
+
if (str === 'lastyear') {
|
|
8793
|
+
return {
|
|
8794
|
+
key: 'lastyear',
|
|
8795
|
+
label: 'Jan 1 last year',
|
|
8796
|
+
getDate: () => {
|
|
8797
|
+
const d = new Date();
|
|
8798
|
+
d.setHours(0, 0, 0, 0);
|
|
8799
|
+
d.setFullYear(d.getFullYear() - 1, 0, 1);
|
|
8800
|
+
return d;
|
|
8801
|
+
}
|
|
8802
|
+
};
|
|
8803
|
+
}
|
|
8804
|
+
return {
|
|
8805
|
+
key: str,
|
|
8806
|
+
label: item,
|
|
8807
|
+
getDate: () => {
|
|
8808
|
+
const d = new Date();
|
|
8809
|
+
d.setHours(0, 0, 0, 0);
|
|
8810
|
+
return d;
|
|
8811
|
+
}
|
|
8812
|
+
};
|
|
8813
|
+
}, []);
|
|
8814
|
+
const PREDEFINED = useMemo(() => predefinedRanges.map(createPredefinedItem), [predefinedRanges, createPredefinedItem]);
|
|
8815
|
+
const [selectedPredefined, setSelectedPredefined] = useState("");
|
|
8816
|
+
useEffect(() => {
|
|
8817
|
+
if (open && dropdownRef.current) {
|
|
8818
|
+
const rect = dropdownRef.current.getBoundingClientRect();
|
|
8819
|
+
const viewportWidth = window.innerWidth;
|
|
8820
|
+
const viewportHeight = window.innerHeight;
|
|
8821
|
+
const newPosition = {
|
|
8822
|
+
left: '0',
|
|
8823
|
+
top: '110%'
|
|
8824
|
+
};
|
|
8825
|
+
if (rect.right > viewportWidth - 10) newPosition.right = 0, delete newPosition.left; // align right
|
|
8826
|
+
if (rect.bottom > viewportHeight - 10) newPosition.top = 'auto', newPosition.bottom = '110%';
|
|
8827
|
+
setDropdownPosition(newPosition);
|
|
8828
|
+
}
|
|
8829
|
+
}, [open]);
|
|
8830
|
+
|
|
8831
|
+
// Calendar month state (always show month of selected value; allow navigation)
|
|
8832
|
+
const selectedDate = useMemo(() => value ? new Date(value) : null, [value]);
|
|
8833
|
+
const [monthCursor, setMonthCursor] = useState(() => {
|
|
8834
|
+
const d = selectedDate || new Date();
|
|
8835
|
+
return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);
|
|
8836
|
+
});
|
|
8837
|
+
// Keep monthCursor in sync when selected date changes externally
|
|
8838
|
+
useEffect(() => {
|
|
8839
|
+
if (selectedDate) {
|
|
8840
|
+
setMonthCursor(new Date(selectedDate.getFullYear(), selectedDate.getMonth(), 1));
|
|
8841
|
+
}
|
|
8842
|
+
// Match predefined
|
|
8843
|
+
if (selectedDate) {
|
|
8844
|
+
const ts = selectedDate.getTime();
|
|
8845
|
+
for (let i = 0; i < PREDEFINED.length; i++) {
|
|
8846
|
+
const d = PREDEFINED[i].getDate();
|
|
8847
|
+
if (d.getTime() === ts) {
|
|
8848
|
+
setSelectedPredefined(String(i));
|
|
8849
|
+
return;
|
|
8850
|
+
}
|
|
8851
|
+
}
|
|
8852
|
+
setSelectedPredefined("");
|
|
8853
|
+
} else {
|
|
8854
|
+
setSelectedPredefined("");
|
|
8855
|
+
}
|
|
8856
|
+
}, [value, selectedDate, PREDEFINED]);
|
|
8857
|
+
|
|
8858
|
+
// Build calendar days (6 weeks grid)
|
|
8859
|
+
const buildDays = () => {
|
|
8860
|
+
const startOfMonth = new Date(monthCursor.getFullYear(), monthCursor.getMonth(), 1);
|
|
8861
|
+
const dayOfWeek = startOfMonth.getDay(); // 0 Sun ... 6 Sat
|
|
8862
|
+
// We start at Sunday of the week containing the 1st
|
|
8863
|
+
const firstGridDate = new Date(startOfMonth);
|
|
8864
|
+
firstGridDate.setDate(startOfMonth.getDate() - dayOfWeek);
|
|
8865
|
+
const days = [];
|
|
8866
|
+
for (let i = 0; i < 42; i++) {
|
|
8867
|
+
// 6 weeks
|
|
8868
|
+
const d = new Date(firstGridDate);
|
|
8869
|
+
d.setDate(firstGridDate.getDate() + i);
|
|
8870
|
+
days.push(d);
|
|
8871
|
+
}
|
|
8872
|
+
return days;
|
|
8873
|
+
};
|
|
8874
|
+
const days = buildDays();
|
|
8875
|
+
|
|
8876
|
+
// Update URL param
|
|
8877
|
+
const setUrlParam = useCallback(val => {
|
|
8878
|
+
if (!paramKey) return;
|
|
8879
|
+
const params = new URLSearchParams(window.location.search);
|
|
8880
|
+
let ts = val;
|
|
8881
|
+
if (val && typeof val === "string" && !/^[0-9]+$/.test(val)) {
|
|
8882
|
+
const d = new Date(val);
|
|
8883
|
+
ts = d.getTime();
|
|
8884
|
+
}
|
|
8885
|
+
if (ts && String(ts).length > 0 && !isNaN(Number(ts))) params.set(paramKey, String(ts));else params.delete(paramKey);
|
|
8886
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
8887
|
+
window.history.replaceState({}, "", newUrl);
|
|
8888
|
+
}, [paramKey]);
|
|
8889
|
+
|
|
8890
|
+
// Sync from URL
|
|
8891
|
+
useEffect(() => {
|
|
8892
|
+
if (!paramKey || typeof controlledValue !== 'undefined') return;
|
|
8893
|
+
const syncFromUrl = () => {
|
|
8894
|
+
const params = new URLSearchParams(window.location.search);
|
|
8895
|
+
const urlVal = params.get(paramKey);
|
|
8896
|
+
if (urlVal) {
|
|
8897
|
+
const str = toInputString(urlVal);
|
|
8898
|
+
setValue(prev => prev !== str ? str : prev);
|
|
8899
|
+
if (onChange && str !== controlledValue) onChange(urlVal);
|
|
8900
|
+
}
|
|
8901
|
+
};
|
|
8902
|
+
syncFromUrl();
|
|
8903
|
+
window.addEventListener('popstate', syncFromUrl);
|
|
8904
|
+
const patchHistory = type => {
|
|
8905
|
+
const orig = window.history[type];
|
|
8906
|
+
window.history[type] = function () {
|
|
8907
|
+
const rv = orig.apply(this, arguments);
|
|
8908
|
+
window.dispatchEvent(new Event(type));
|
|
8909
|
+
return rv;
|
|
8910
|
+
};
|
|
8911
|
+
};
|
|
8912
|
+
patchHistory('pushState');
|
|
8913
|
+
patchHistory('replaceState');
|
|
8914
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
8915
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
8916
|
+
return () => {
|
|
8917
|
+
window.removeEventListener('popstate', syncFromUrl);
|
|
8918
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
8919
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
8920
|
+
};
|
|
8921
|
+
}, [paramKey, controlledValue, onChange, toInputString]);
|
|
8922
|
+
|
|
8923
|
+
// Controlled value sync
|
|
8924
|
+
useEffect(() => {
|
|
8925
|
+
if (typeof controlledValue !== 'undefined') setValue(controlledValue);
|
|
8926
|
+
}, [controlledValue]);
|
|
8927
|
+
|
|
8928
|
+
// Formatting display (similar to RangePicker)
|
|
8929
|
+
const formatDisplay = () => {
|
|
8930
|
+
if (!value) return "";
|
|
8931
|
+
const d = new Date(value);
|
|
8932
|
+
if (isNaN(d.getTime())) return "";
|
|
8933
|
+
const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
|
|
8934
|
+
const yyyy = d.getFullYear();
|
|
8935
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
8936
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
8937
|
+
let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
|
|
8938
|
+
if (time) {
|
|
8939
|
+
const actualTimeFormat = timeFormat || 'HH:mm';
|
|
8940
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
8941
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
8942
|
+
const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
|
|
8943
|
+
return `${dateStr} ${timeStr}`;
|
|
8944
|
+
}
|
|
8945
|
+
return dateStr;
|
|
8946
|
+
};
|
|
8947
|
+
const applySelection = d => {
|
|
8948
|
+
const dt = new Date(d);
|
|
8949
|
+
if (time && timeStart && !value) {
|
|
8950
|
+
// apply timeStart if initial selection
|
|
8951
|
+
const [h, m] = timeStart.split(":");
|
|
8952
|
+
dt.setHours(Number(h), Number(m), 0, 0);
|
|
8953
|
+
}
|
|
8954
|
+
const str = toInputString(dt.getTime());
|
|
8955
|
+
if (typeof controlledValue === 'undefined') setValue(str);
|
|
8956
|
+
setUrlParam(str);
|
|
8957
|
+
onChange?.(str);
|
|
8958
|
+
};
|
|
8959
|
+
const handlePredefinedClick = idx => {
|
|
8960
|
+
const item = PREDEFINED[idx];
|
|
8961
|
+
const d = item.getDate();
|
|
8962
|
+
if (time && timeStart) {
|
|
8963
|
+
const [h, m] = (timeStart || "00:00").split(":");
|
|
8964
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8965
|
+
}
|
|
8966
|
+
applySelection(d);
|
|
8967
|
+
setSelectedPredefined(String(idx));
|
|
8968
|
+
};
|
|
8969
|
+
const handleDayClick = day => {
|
|
8970
|
+
applySelection(day);
|
|
8971
|
+
};
|
|
8972
|
+
const handleTimeChange = e => {
|
|
8973
|
+
const t = e.target.value; // HH:mm
|
|
8974
|
+
if (!value) return;
|
|
8975
|
+
const d = new Date(value);
|
|
8976
|
+
const [h, m] = t.split(":");
|
|
8977
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8978
|
+
const str = toInputString(d.getTime());
|
|
8979
|
+
if (typeof controlledValue === 'undefined') setValue(str);
|
|
8980
|
+
setUrlParam(str);
|
|
8981
|
+
onChange?.(str);
|
|
8982
|
+
};
|
|
8983
|
+
const handleClear = () => {
|
|
8984
|
+
if (typeof controlledValue === 'undefined') setValue("");
|
|
8985
|
+
setUrlParam("");
|
|
8986
|
+
onChange?.("");
|
|
8987
|
+
};
|
|
8988
|
+
|
|
8989
|
+
// Outside click close
|
|
8990
|
+
useEffect(() => {
|
|
8991
|
+
if (!open) return;
|
|
8992
|
+
const onClick = e => {
|
|
8993
|
+
if (!e.target.closest('.datetime-input-dropdown')) setOpen(false);
|
|
8994
|
+
};
|
|
8995
|
+
window.addEventListener('mousedown', onClick);
|
|
8996
|
+
return () => window.removeEventListener('mousedown', onClick);
|
|
8997
|
+
}, [open]);
|
|
8998
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
8999
|
+
className: `datetime-input-wrapper ${className}`,
|
|
9000
|
+
style: {
|
|
9001
|
+
position: 'relative',
|
|
9002
|
+
display: 'inline-block',
|
|
9003
|
+
...style
|
|
9004
|
+
}
|
|
9005
|
+
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
9006
|
+
className: "basic-input",
|
|
9007
|
+
onClick: () => !disabled && setOpen(o => !o),
|
|
9008
|
+
style: {
|
|
9009
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
9010
|
+
padding: '6px 8px',
|
|
9011
|
+
minWidth: 180,
|
|
9012
|
+
userSelect: 'none',
|
|
9013
|
+
position: 'relative'
|
|
9014
|
+
},
|
|
9015
|
+
"data-timestart": timeStart || undefined,
|
|
9016
|
+
"data-timezone": timezone || undefined,
|
|
9017
|
+
"data-timeformat": timeFormat || undefined,
|
|
9018
|
+
"data-dateformat": dateFormat || undefined
|
|
9019
|
+
}, formatDisplay() || placeholder, value && /*#__PURE__*/React__default.createElement("span", {
|
|
9020
|
+
onClick: e => {
|
|
9021
|
+
e.stopPropagation();
|
|
9022
|
+
handleClear();
|
|
9023
|
+
},
|
|
9024
|
+
title: "Clear date",
|
|
9025
|
+
style: {
|
|
9026
|
+
position: 'absolute',
|
|
9027
|
+
right: 8,
|
|
9028
|
+
top: '50%',
|
|
9029
|
+
transform: 'translateY(-50%)',
|
|
9030
|
+
fontSize: 12,
|
|
9031
|
+
cursor: 'pointer'
|
|
9032
|
+
}
|
|
9033
|
+
}, "\u2716")), open && /*#__PURE__*/React__default.createElement("div", {
|
|
9034
|
+
ref: dropdownRef,
|
|
9035
|
+
className: "datetime-input-dropdown range-picker-dropdown" // reuse class for styling consistency
|
|
9036
|
+
,
|
|
9037
|
+
style: {
|
|
9038
|
+
position: 'absolute',
|
|
9039
|
+
zIndex: 50,
|
|
9040
|
+
background: '#fff',
|
|
9041
|
+
border: '1px solid #d9d9d9',
|
|
9042
|
+
borderRadius: 4,
|
|
9043
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
9044
|
+
padding: 12,
|
|
9045
|
+
width: 320,
|
|
9046
|
+
...dropdownPosition
|
|
9047
|
+
}
|
|
9048
|
+
}, PREDEFINED.length > 0 && /*#__PURE__*/React__default.createElement("div", {
|
|
9049
|
+
style: {
|
|
9050
|
+
display: 'flex',
|
|
9051
|
+
flexWrap: 'wrap',
|
|
9052
|
+
gap: 6,
|
|
9053
|
+
marginBottom: 8
|
|
9054
|
+
}
|
|
9055
|
+
}, PREDEFINED.map((p, i) => {
|
|
9056
|
+
const active = selectedPredefined === String(i);
|
|
9057
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
9058
|
+
key: p.key,
|
|
9059
|
+
type: "button",
|
|
9060
|
+
onClick: () => handlePredefinedClick(i),
|
|
9061
|
+
className: "basic-btn",
|
|
9062
|
+
style: {
|
|
9063
|
+
padding: '4px 8px',
|
|
9064
|
+
fontSize: 12,
|
|
9065
|
+
background: active ? '#1677ff' : '#fff',
|
|
9066
|
+
color: active ? '#fff' : '#000',
|
|
9067
|
+
border: active ? '1px solid #1677ff' : '1px solid #d9d9d9'
|
|
9068
|
+
}
|
|
9069
|
+
}, p.label);
|
|
9070
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
9071
|
+
style: {
|
|
9072
|
+
display: 'flex',
|
|
9073
|
+
justifyContent: 'space-between',
|
|
9074
|
+
alignItems: 'center',
|
|
9075
|
+
marginBottom: 8
|
|
9076
|
+
}
|
|
9077
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
9078
|
+
type: "button",
|
|
9079
|
+
className: "basic-btn",
|
|
9080
|
+
onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() - 1, 1))
|
|
9081
|
+
}, "\u2039"), /*#__PURE__*/React__default.createElement("div", {
|
|
9082
|
+
style: {
|
|
9083
|
+
fontWeight: 600
|
|
9084
|
+
}
|
|
9085
|
+
}, monthCursor.toLocaleString(undefined, {
|
|
9086
|
+
month: 'long'
|
|
9087
|
+
}), " ", monthCursor.getFullYear()), /*#__PURE__*/React__default.createElement("button", {
|
|
9088
|
+
type: "button",
|
|
9089
|
+
className: "basic-btn",
|
|
9090
|
+
onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() + 1, 1))
|
|
9091
|
+
}, "\u203A")), /*#__PURE__*/React__default.createElement("div", {
|
|
9092
|
+
style: {
|
|
9093
|
+
display: 'grid',
|
|
9094
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
9095
|
+
fontSize: 12,
|
|
9096
|
+
marginBottom: 4,
|
|
9097
|
+
opacity: 0.8
|
|
9098
|
+
}
|
|
9099
|
+
}, ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(d => /*#__PURE__*/React__default.createElement("div", {
|
|
9100
|
+
key: d,
|
|
9101
|
+
style: {
|
|
9102
|
+
textAlign: 'center'
|
|
9103
|
+
}
|
|
9104
|
+
}, d))), /*#__PURE__*/React__default.createElement("div", {
|
|
9105
|
+
style: {
|
|
9106
|
+
display: 'grid',
|
|
9107
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
9108
|
+
gap: 2
|
|
9109
|
+
}
|
|
9110
|
+
}, days.map(d => {
|
|
9111
|
+
const isCurrentMonth = d.getMonth() === monthCursor.getMonth();
|
|
9112
|
+
const isSelected = selectedDate && d.getFullYear() === selectedDate.getFullYear() && d.getMonth() === selectedDate.getMonth() && d.getDate() === selectedDate.getDate();
|
|
9113
|
+
const isToday = (() => {
|
|
9114
|
+
const t = new Date();
|
|
9115
|
+
return t.getFullYear() === d.getFullYear() && t.getMonth() === d.getMonth() && t.getDate() === d.getDate();
|
|
9116
|
+
})();
|
|
9117
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
9118
|
+
key: d.toISOString(),
|
|
9119
|
+
onClick: () => handleDayClick(d),
|
|
9120
|
+
style: {
|
|
9121
|
+
textAlign: 'center',
|
|
9122
|
+
padding: '6px 0',
|
|
9123
|
+
cursor: 'pointer',
|
|
9124
|
+
fontSize: 12,
|
|
9125
|
+
borderRadius: 4,
|
|
9126
|
+
background: isSelected ? '#1677ff' : isToday ? '#e6f4ff' : 'transparent',
|
|
9127
|
+
color: isSelected ? '#fff' : isCurrentMonth ? '#000' : '#aaa',
|
|
9128
|
+
border: isSelected ? '1px solid #1677ff' : '1px solid transparent'
|
|
9129
|
+
}
|
|
9130
|
+
}, d.getDate());
|
|
9131
|
+
})), time && /*#__PURE__*/React__default.createElement("div", {
|
|
9132
|
+
style: {
|
|
9133
|
+
marginTop: 10
|
|
9134
|
+
}
|
|
9135
|
+
}, /*#__PURE__*/React__default.createElement("label", {
|
|
9136
|
+
style: {
|
|
9137
|
+
fontSize: 12,
|
|
9138
|
+
display: 'block',
|
|
9139
|
+
marginBottom: 4
|
|
9140
|
+
}
|
|
9141
|
+
}, "Time:"), /*#__PURE__*/React__default.createElement("input", {
|
|
9142
|
+
type: "time",
|
|
9143
|
+
value: (() => {
|
|
9144
|
+
if (!value) return '';
|
|
9145
|
+
const d = new Date(value);
|
|
9146
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9147
|
+
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
9148
|
+
return `${hh}:${mm}`;
|
|
9149
|
+
})(),
|
|
9150
|
+
onChange: handleTimeChange,
|
|
9151
|
+
className: "basic-input",
|
|
9152
|
+
style: {
|
|
9153
|
+
width: '100%'
|
|
9154
|
+
}
|
|
9155
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
9156
|
+
style: {
|
|
9157
|
+
display: 'flex',
|
|
9158
|
+
justifyContent: 'space-between',
|
|
9159
|
+
alignItems: 'center',
|
|
9160
|
+
marginTop: 12
|
|
9161
|
+
}
|
|
9162
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9163
|
+
style: {
|
|
9164
|
+
display: 'flex',
|
|
9165
|
+
gap: 8
|
|
9166
|
+
}
|
|
9167
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
9168
|
+
type: "button",
|
|
9169
|
+
className: "basic-btn",
|
|
9170
|
+
onClick: () => {
|
|
9171
|
+
handleClear();
|
|
9172
|
+
}
|
|
9173
|
+
}, "Clear"), /*#__PURE__*/React__default.createElement("button", {
|
|
9174
|
+
type: "button",
|
|
9175
|
+
className: "basic-btn",
|
|
9176
|
+
onClick: () => {
|
|
9177
|
+
setOpen(false);
|
|
9178
|
+
}
|
|
9179
|
+
}, "OK")), /*#__PURE__*/React__default.createElement("button", {
|
|
9180
|
+
type: "button",
|
|
9181
|
+
className: "basic-btn",
|
|
9182
|
+
onClick: () => {
|
|
9183
|
+
handlePredefinedClick(PREDEFINED.findIndex(p => p.key === 'today'));
|
|
9184
|
+
}
|
|
9185
|
+
}, "Today"))));
|
|
9186
|
+
}
|
|
9187
|
+
DateTimeInput.propTypes = {
|
|
9188
|
+
pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
9189
|
+
value: PropTypes.string,
|
|
9190
|
+
onChange: PropTypes.func,
|
|
9191
|
+
time: PropTypes.bool,
|
|
9192
|
+
timeStart: PropTypes.string,
|
|
9193
|
+
timezone: PropTypes.string,
|
|
9194
|
+
timeFormat: PropTypes.string,
|
|
9195
|
+
dateFormat: PropTypes.string,
|
|
9196
|
+
placeholder: PropTypes.string,
|
|
9197
|
+
disabled: PropTypes.bool,
|
|
9198
|
+
className: PropTypes.string,
|
|
9199
|
+
style: PropTypes.object,
|
|
9200
|
+
predefinedRanges: PropTypes.array
|
|
9201
|
+
};
|
|
9202
|
+
|
|
9203
|
+
/**
|
|
9204
|
+
* CalendarRangePicker - Custom calendar UI for selecting date ranges
|
|
9205
|
+
* Props:
|
|
9206
|
+
* startDate: Date | null
|
|
9207
|
+
* endDate: Date | null
|
|
9208
|
+
* onChange: (startDate, endDate) => void
|
|
9209
|
+
* time: boolean - if true, show time selectors
|
|
9210
|
+
* timeStart, timeEnd: default times for start/end
|
|
9211
|
+
*/
|
|
9212
|
+
function CalendarRangePicker({
|
|
9213
|
+
startDate,
|
|
9214
|
+
endDate,
|
|
9215
|
+
onChange,
|
|
9216
|
+
time = false,
|
|
9217
|
+
timeStart = "00:00",
|
|
9218
|
+
timeEnd = "23:59"
|
|
9219
|
+
}) {
|
|
9220
|
+
// Current view months (show 2 months)
|
|
9221
|
+
const [leftMonth, setLeftMonth] = useState(() => {
|
|
9222
|
+
const d = startDate ? new Date(startDate) : new Date();
|
|
9223
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
9224
|
+
});
|
|
9225
|
+
const rightMonth = new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1);
|
|
9226
|
+
|
|
9227
|
+
// Update leftMonth when startDate changes (e.g., when selecting predefined ranges)
|
|
9228
|
+
React__default.useEffect(() => {
|
|
9229
|
+
if (startDate) {
|
|
9230
|
+
const d = new Date(startDate);
|
|
9231
|
+
setLeftMonth(new Date(d.getFullYear(), d.getMonth(), 1));
|
|
9232
|
+
}
|
|
9233
|
+
}, [startDate]);
|
|
9234
|
+
|
|
9235
|
+
// Hover state for preview
|
|
9236
|
+
const [hoverDate, setHoverDate] = useState(null);
|
|
9237
|
+
|
|
9238
|
+
// Navigate months
|
|
9239
|
+
const prevMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() - 1, 1));
|
|
9240
|
+
const nextMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1));
|
|
9241
|
+
|
|
9242
|
+
// Handle date click
|
|
9243
|
+
const handleDateClick = date => {
|
|
9244
|
+
const d = new Date(date);
|
|
9245
|
+
if (time && startDate && timeStart) {
|
|
9246
|
+
const [h, m] = timeStart.split(":");
|
|
9247
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
9248
|
+
}
|
|
9249
|
+
if (!startDate || startDate && endDate) {
|
|
9250
|
+
// Start new range
|
|
9251
|
+
onChange(d, null);
|
|
9252
|
+
} else {
|
|
9253
|
+
// Complete range
|
|
9254
|
+
if (d < startDate) {
|
|
9255
|
+
onChange(d, startDate);
|
|
9256
|
+
} else {
|
|
9257
|
+
const endD = new Date(d);
|
|
9258
|
+
if (time && timeEnd) {
|
|
9259
|
+
const [h, m] = timeEnd.split(":");
|
|
9260
|
+
endD.setHours(Number(h), Number(m), 59, 999);
|
|
9261
|
+
}
|
|
9262
|
+
onChange(startDate, endD);
|
|
9263
|
+
}
|
|
9264
|
+
}
|
|
9265
|
+
};
|
|
9266
|
+
|
|
9267
|
+
// Check if date is in range
|
|
9268
|
+
const isInRange = date => {
|
|
9269
|
+
if (!startDate) return false;
|
|
9270
|
+
const check = endDate || hoverDate;
|
|
9271
|
+
if (!check) return false;
|
|
9272
|
+
const d = new Date(date).setHours(0, 0, 0, 0);
|
|
9273
|
+
const s = new Date(startDate).setHours(0, 0, 0, 0);
|
|
9274
|
+
const e = new Date(check).setHours(0, 0, 0, 0);
|
|
9275
|
+
return d >= Math.min(s, e) && d <= Math.max(s, e);
|
|
9276
|
+
};
|
|
9277
|
+
const isStartDate = date => {
|
|
9278
|
+
if (!startDate) return false;
|
|
9279
|
+
return new Date(date).setHours(0, 0, 0, 0) === new Date(startDate).setHours(0, 0, 0, 0);
|
|
9280
|
+
};
|
|
9281
|
+
const isEndDate = date => {
|
|
9282
|
+
if (!endDate) return false;
|
|
9283
|
+
return new Date(date).setHours(0, 0, 0, 0) === new Date(endDate).setHours(0, 0, 0, 0);
|
|
9284
|
+
};
|
|
9285
|
+
const isToday = date => {
|
|
9286
|
+
const today = new Date();
|
|
9287
|
+
return date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
|
|
9288
|
+
};
|
|
9289
|
+
|
|
9290
|
+
// Render a single month
|
|
9291
|
+
const renderMonth = month => {
|
|
9292
|
+
const year = month.getFullYear();
|
|
9293
|
+
const monthIdx = month.getMonth();
|
|
9294
|
+
const firstDay = new Date(year, monthIdx, 1);
|
|
9295
|
+
const lastDay = new Date(year, monthIdx + 1, 0);
|
|
9296
|
+
const startWeekday = firstDay.getDay(); // 0 = Sunday
|
|
9297
|
+
const daysInMonth = lastDay.getDate();
|
|
9298
|
+
const days = [];
|
|
9299
|
+
// Padding days from previous month
|
|
9300
|
+
const prevMonthLastDay = new Date(year, monthIdx, 0).getDate();
|
|
9301
|
+
for (let i = startWeekday - 1; i >= 0; i--) {
|
|
9302
|
+
days.push({
|
|
9303
|
+
date: new Date(year, monthIdx - 1, prevMonthLastDay - i),
|
|
9304
|
+
otherMonth: true
|
|
9305
|
+
});
|
|
9306
|
+
}
|
|
9307
|
+
// Current month days
|
|
9308
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
9309
|
+
days.push({
|
|
9310
|
+
date: new Date(year, monthIdx, d),
|
|
9311
|
+
otherMonth: false
|
|
9312
|
+
});
|
|
9313
|
+
}
|
|
9314
|
+
// Padding days from next month
|
|
9315
|
+
const remaining = 42 - days.length; // 6 rows * 7 days
|
|
9316
|
+
for (let d = 1; d <= remaining; d++) {
|
|
9317
|
+
days.push({
|
|
9318
|
+
date: new Date(year, monthIdx + 1, d),
|
|
9319
|
+
otherMonth: true
|
|
9320
|
+
});
|
|
9321
|
+
}
|
|
9322
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
9323
|
+
style: {
|
|
9324
|
+
flex: 1,
|
|
9325
|
+
padding: "0 8px"
|
|
9326
|
+
}
|
|
9327
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9328
|
+
style: {
|
|
9329
|
+
textAlign: "center",
|
|
9330
|
+
fontWeight: "bold",
|
|
9331
|
+
marginBottom: 12,
|
|
9332
|
+
fontSize: 14
|
|
9333
|
+
}
|
|
9334
|
+
}, month.toLocaleDateString("en-US", {
|
|
9335
|
+
month: "short",
|
|
9336
|
+
year: "numeric"
|
|
9337
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
9338
|
+
style: {
|
|
9339
|
+
display: "grid",
|
|
9340
|
+
gridTemplateColumns: "repeat(7, 1fr)",
|
|
9341
|
+
gap: 2
|
|
9342
|
+
}
|
|
9343
|
+
}, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(day => /*#__PURE__*/React__default.createElement("div", {
|
|
9344
|
+
key: day,
|
|
9345
|
+
style: {
|
|
9346
|
+
textAlign: "center",
|
|
9347
|
+
fontSize: 11,
|
|
9348
|
+
color: "#666",
|
|
9349
|
+
fontWeight: 600,
|
|
9350
|
+
padding: "4px 0"
|
|
9351
|
+
}
|
|
9352
|
+
}, day)), days.map(({
|
|
9353
|
+
date,
|
|
9354
|
+
otherMonth
|
|
9355
|
+
}, idx) => {
|
|
9356
|
+
const inRange = isInRange(date);
|
|
9357
|
+
const isStart = isStartDate(date);
|
|
9358
|
+
const isEnd = isEndDate(date);
|
|
9359
|
+
const isCurrentDay = isToday(date);
|
|
9360
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
9361
|
+
key: idx,
|
|
9362
|
+
onClick: () => !otherMonth && handleDateClick(date),
|
|
9363
|
+
onMouseEnter: () => !otherMonth && setHoverDate(date),
|
|
9364
|
+
style: {
|
|
9365
|
+
textAlign: "center",
|
|
9366
|
+
padding: "8px 4px",
|
|
9367
|
+
fontSize: 13,
|
|
9368
|
+
cursor: otherMonth ? "default" : "pointer",
|
|
9369
|
+
color: otherMonth ? "#ccc" : isStart || isEnd ? "#fff" : isCurrentDay ? "#1d4ed8" : "#333",
|
|
9370
|
+
fontWeight: isStart || isEnd || isCurrentDay ? "600" : "normal",
|
|
9371
|
+
background: isStart || isEnd ? "#1d4ed8" : inRange ? "#e0f2fe" : "transparent",
|
|
9372
|
+
borderRadius: isStart || isEnd ? "50%" : inRange ? 0 : 4,
|
|
9373
|
+
border: isCurrentDay && !isStart && !isEnd ? "1px solid #1d4ed8" : "none",
|
|
9374
|
+
userSelect: "none",
|
|
9375
|
+
transition: "all 0.15s ease"
|
|
9376
|
+
},
|
|
9377
|
+
onMouseOver: e => {
|
|
9378
|
+
if (!otherMonth && !isStart && !isEnd) {
|
|
9379
|
+
e.currentTarget.style.background = inRange ? "#bfdbfe" : "#f3f4f6";
|
|
9380
|
+
}
|
|
9381
|
+
},
|
|
9382
|
+
onMouseOut: e => {
|
|
9383
|
+
if (!otherMonth && !isStart && !isEnd) {
|
|
9384
|
+
e.currentTarget.style.background = inRange ? "#e0f2fe" : "transparent";
|
|
9385
|
+
}
|
|
9386
|
+
}
|
|
9387
|
+
}, date.getDate());
|
|
9388
|
+
})));
|
|
9389
|
+
};
|
|
9390
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
9391
|
+
style: {
|
|
9392
|
+
minWidth: 560
|
|
9393
|
+
}
|
|
9394
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9395
|
+
style: {
|
|
9396
|
+
display: "flex",
|
|
9397
|
+
justifyContent: "space-between",
|
|
9398
|
+
alignItems: "center",
|
|
9399
|
+
marginBottom: 16
|
|
9400
|
+
}
|
|
9401
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
9402
|
+
onClick: prevMonth,
|
|
9403
|
+
style: {
|
|
9404
|
+
background: "none",
|
|
9405
|
+
border: "none",
|
|
9406
|
+
fontSize: 20,
|
|
9407
|
+
cursor: "pointer",
|
|
9408
|
+
padding: "4px 8px",
|
|
9409
|
+
color: "#333"
|
|
9410
|
+
}
|
|
9411
|
+
}, "\u2039\u2039"), /*#__PURE__*/React__default.createElement("div", {
|
|
9412
|
+
style: {
|
|
9413
|
+
fontWeight: "600",
|
|
9414
|
+
fontSize: 14,
|
|
9415
|
+
color: "#333"
|
|
9416
|
+
}
|
|
9417
|
+
}, leftMonth.toLocaleDateString("en-US", {
|
|
9418
|
+
month: "long",
|
|
9419
|
+
year: "numeric"
|
|
9420
|
+
}), " \u2013 ", rightMonth.toLocaleDateString("en-US", {
|
|
9421
|
+
month: "long",
|
|
9422
|
+
year: "numeric"
|
|
9423
|
+
})), /*#__PURE__*/React__default.createElement("button", {
|
|
9424
|
+
onClick: nextMonth,
|
|
9425
|
+
style: {
|
|
9426
|
+
background: "none",
|
|
9427
|
+
border: "none",
|
|
9428
|
+
fontSize: 20,
|
|
9429
|
+
cursor: "pointer",
|
|
9430
|
+
padding: "4px 8px",
|
|
9431
|
+
color: "#333"
|
|
9432
|
+
}
|
|
9433
|
+
}, "\u203A\u203A")), /*#__PURE__*/React__default.createElement("div", {
|
|
9434
|
+
style: {
|
|
9435
|
+
display: "flex",
|
|
9436
|
+
gap: 16
|
|
9437
|
+
},
|
|
9438
|
+
onMouseLeave: () => setHoverDate(null)
|
|
9439
|
+
}, renderMonth(leftMonth), renderMonth(rightMonth)));
|
|
9440
|
+
}
|
|
9441
|
+
CalendarRangePicker.propTypes = {
|
|
9442
|
+
startDate: PropTypes.instanceOf(Date),
|
|
9443
|
+
endDate: PropTypes.instanceOf(Date),
|
|
9444
|
+
onChange: PropTypes.func.isRequired,
|
|
9445
|
+
time: PropTypes.bool,
|
|
9446
|
+
timeStart: PropTypes.string,
|
|
9447
|
+
timeEnd: PropTypes.string
|
|
9448
|
+
};
|
|
9449
|
+
|
|
9450
|
+
/**
|
|
9451
|
+
* RangePicker - a reusable date or datetime-local range picker with URL param sync
|
|
9452
|
+
* Props:
|
|
9453
|
+
* pushUrlParamObj: string | false - URL param key to sync value (will store as start~end)
|
|
9454
|
+
* value: [start, end] controlled value (optional)
|
|
9455
|
+
* onChange: ([start, end]) => void (optional)
|
|
9456
|
+
* time: boolean - if true, use datetime-local, else date
|
|
9457
|
+
* timeStart: string (for default start time, e.g. "00:00")
|
|
9458
|
+
* timeEnd: string (for default end time, e.g. "23:59")
|
|
9459
|
+
* timezone, timeFormat, dateFormat, placeholder, required, disabled, className, style, min, max, ...rest
|
|
9460
|
+
*/
|
|
9461
|
+
// Helper to get date string in yyyy-MM-dd or yyyy-MM-ddTHH:mm
|
|
9462
|
+
function formatDate(date, time = false) {
|
|
9463
|
+
const yyyy = date.getFullYear();
|
|
9464
|
+
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
9465
|
+
const dd = String(date.getDate()).padStart(2, '0');
|
|
9466
|
+
if (time) {
|
|
9467
|
+
const hh = String(date.getHours()).padStart(2, '0');
|
|
9468
|
+
const min = String(date.getMinutes()).padStart(2, '0');
|
|
9469
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9470
|
+
}
|
|
9471
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9472
|
+
}
|
|
9473
|
+
const PREDEFINED_RANGES = [{
|
|
9474
|
+
label: 'Today',
|
|
9475
|
+
getRange: time => {
|
|
9476
|
+
const now = new Date();
|
|
9477
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
9478
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9479
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9480
|
+
}
|
|
9481
|
+
}, {
|
|
9482
|
+
label: 'This week',
|
|
9483
|
+
getRange: time => {
|
|
9484
|
+
const now = new Date();
|
|
9485
|
+
const day = now.getDay() || 7;
|
|
9486
|
+
const start = new Date(now);
|
|
9487
|
+
start.setDate(now.getDate() - day + 1);
|
|
9488
|
+
start.setHours(0, 0, 0, 0);
|
|
9489
|
+
const end = new Date(start);
|
|
9490
|
+
end.setDate(start.getDate() + 6);
|
|
9491
|
+
end.setHours(23, 59, 59, 999);
|
|
9492
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9493
|
+
}
|
|
9494
|
+
}, {
|
|
9495
|
+
label: 'Last 7 days',
|
|
9496
|
+
getRange: time => {
|
|
9497
|
+
const now = new Date();
|
|
9498
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9499
|
+
const start = new Date(end);
|
|
9500
|
+
start.setDate(end.getDate() - 6);
|
|
9501
|
+
start.setHours(0, 0, 0, 0);
|
|
9502
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9503
|
+
}
|
|
9504
|
+
}, {
|
|
9505
|
+
label: 'This month',
|
|
9506
|
+
getRange: time => {
|
|
9507
|
+
const now = new Date();
|
|
9508
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
|
|
9509
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
9510
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9511
|
+
}
|
|
9512
|
+
}, {
|
|
9513
|
+
label: 'Last 30 days',
|
|
9514
|
+
getRange: time => {
|
|
9515
|
+
const now = new Date();
|
|
9516
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9517
|
+
const start = new Date(end);
|
|
9518
|
+
start.setDate(end.getDate() - 29);
|
|
9519
|
+
start.setHours(0, 0, 0, 0);
|
|
9520
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9521
|
+
}
|
|
9522
|
+
}];
|
|
9523
|
+
|
|
9524
|
+
// Helper to create predefined range from simple format
|
|
9525
|
+
const createRangeFromSimple = (item, time) => {
|
|
9526
|
+
// If it's a number, treat as "last N days"
|
|
9527
|
+
if (typeof item === 'number') {
|
|
9528
|
+
return {
|
|
9529
|
+
label: `Last ${item} days`,
|
|
9530
|
+
getRange: time => {
|
|
9531
|
+
const now = new Date();
|
|
9532
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9533
|
+
const start = new Date(end);
|
|
9534
|
+
start.setDate(end.getDate() - (item - 1));
|
|
9535
|
+
start.setHours(0, 0, 0, 0);
|
|
9536
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9537
|
+
}
|
|
9538
|
+
};
|
|
9539
|
+
}
|
|
9540
|
+
|
|
9541
|
+
// If it's a string, map to predefined functions
|
|
9542
|
+
const lowerItem = item.toLowerCase();
|
|
9543
|
+
const rangeMap = {
|
|
9544
|
+
'today': {
|
|
9545
|
+
label: 'Today',
|
|
9546
|
+
getRange: time => {
|
|
9547
|
+
const now = new Date();
|
|
9548
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
9549
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9550
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9551
|
+
}
|
|
9552
|
+
},
|
|
9553
|
+
'yesterday': {
|
|
9554
|
+
label: 'Yesterday',
|
|
9555
|
+
getRange: time => {
|
|
9556
|
+
const now = new Date();
|
|
9557
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0, 0);
|
|
9558
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 23, 59, 59, 999);
|
|
9559
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9560
|
+
}
|
|
9561
|
+
},
|
|
9562
|
+
'thisweek': {
|
|
9563
|
+
label: 'This week',
|
|
9564
|
+
getRange: time => {
|
|
9565
|
+
const now = new Date();
|
|
9566
|
+
const day = now.getDay() || 7;
|
|
9567
|
+
const start = new Date(now);
|
|
9568
|
+
start.setDate(now.getDate() - day + 1);
|
|
9569
|
+
start.setHours(0, 0, 0, 0);
|
|
9570
|
+
const end = new Date(start);
|
|
9571
|
+
end.setDate(start.getDate() + 6);
|
|
9572
|
+
end.setHours(23, 59, 59, 999);
|
|
9573
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9574
|
+
}
|
|
9575
|
+
},
|
|
9576
|
+
'lastweek': {
|
|
9577
|
+
label: 'Last week',
|
|
9578
|
+
getRange: time => {
|
|
9579
|
+
const now = new Date();
|
|
9580
|
+
const day = now.getDay() || 7;
|
|
9581
|
+
const start = new Date(now);
|
|
9582
|
+
start.setDate(now.getDate() - day - 6);
|
|
9583
|
+
start.setHours(0, 0, 0, 0);
|
|
9584
|
+
const end = new Date(start);
|
|
9585
|
+
end.setDate(start.getDate() + 6);
|
|
9586
|
+
end.setHours(23, 59, 59, 999);
|
|
9587
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9588
|
+
}
|
|
9589
|
+
},
|
|
9590
|
+
'thismonth': {
|
|
9591
|
+
label: 'This month',
|
|
9592
|
+
getRange: time => {
|
|
9593
|
+
const now = new Date();
|
|
9594
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
|
|
9595
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
9596
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9597
|
+
}
|
|
9598
|
+
},
|
|
9599
|
+
'lastmonth': {
|
|
9600
|
+
label: 'Last month',
|
|
9601
|
+
getRange: time => {
|
|
9602
|
+
const now = new Date();
|
|
9603
|
+
const start = new Date(now.getFullYear(), now.getMonth() - 1, 1, 0, 0, 0, 0);
|
|
9604
|
+
const end = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
|
|
9605
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9606
|
+
}
|
|
9607
|
+
},
|
|
9608
|
+
'thisyear': {
|
|
9609
|
+
label: 'This year',
|
|
9610
|
+
getRange: time => {
|
|
9611
|
+
const now = new Date();
|
|
9612
|
+
const start = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0);
|
|
9613
|
+
const end = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
9614
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9615
|
+
}
|
|
9616
|
+
},
|
|
9617
|
+
'lastyear': {
|
|
9618
|
+
label: 'Last year',
|
|
9619
|
+
getRange: time => {
|
|
9620
|
+
const now = new Date();
|
|
9621
|
+
const start = new Date(now.getFullYear() - 1, 0, 1, 0, 0, 0, 0);
|
|
9622
|
+
const end = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999);
|
|
9623
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9624
|
+
}
|
|
9625
|
+
}
|
|
9626
|
+
};
|
|
9627
|
+
return rangeMap[lowerItem] || null;
|
|
9628
|
+
};
|
|
9629
|
+
function RangePicker({
|
|
9630
|
+
pushUrlParamObj = false,
|
|
9631
|
+
value: controlledValue,
|
|
9632
|
+
onChange,
|
|
9633
|
+
time = false,
|
|
9634
|
+
timeStart,
|
|
9635
|
+
timeEnd,
|
|
9636
|
+
timezone,
|
|
9637
|
+
timeFormat,
|
|
9638
|
+
dateFormat,
|
|
9639
|
+
placeholder = "",
|
|
9640
|
+
required = false,
|
|
9641
|
+
disabled = false,
|
|
9642
|
+
className = "",
|
|
9643
|
+
style = {},
|
|
9644
|
+
min,
|
|
9645
|
+
max,
|
|
9646
|
+
predefinedRanges = PREDEFINED_RANGES,
|
|
9647
|
+
...rest
|
|
9648
|
+
}) {
|
|
9649
|
+
const paramKey = pushUrlParamObj || null;
|
|
9650
|
+
|
|
9651
|
+
// Convert simple predefinedRanges to full format
|
|
9652
|
+
const processedRanges = Array.isArray(predefinedRanges) ? predefinedRanges.map(item => {
|
|
9653
|
+
// If it's already an object with label and getRange, use it as-is
|
|
9654
|
+
if (typeof item === 'object' && item.label && item.getRange) {
|
|
9655
|
+
return item;
|
|
9656
|
+
}
|
|
9657
|
+
// Otherwise, convert from simple format
|
|
9658
|
+
return createRangeFromSimple(item);
|
|
9659
|
+
}).filter(Boolean) : [];
|
|
9660
|
+
|
|
9661
|
+
// Helper to format default value
|
|
9662
|
+
const getDefault = which => {
|
|
9663
|
+
if (time) {
|
|
9664
|
+
const today = new Date();
|
|
9665
|
+
const yyyy = today.getFullYear();
|
|
9666
|
+
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
|
9667
|
+
const dd = String(today.getDate()).padStart(2, '0');
|
|
9668
|
+
if (which === 'start' && timeStart) return `${yyyy}-${mm}-${dd}T${timeStart}`;
|
|
9669
|
+
if (which === 'end' && timeEnd) return `${yyyy}-${mm}-${dd}T${timeEnd}`;
|
|
9670
|
+
// fallback to now
|
|
9671
|
+
const now = new Date();
|
|
9672
|
+
const hh = String(now.getHours()).padStart(2, '0');
|
|
9673
|
+
const min = String(now.getMinutes()).padStart(2, '0');
|
|
9674
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9675
|
+
}
|
|
9676
|
+
return "";
|
|
9677
|
+
};
|
|
9678
|
+
// Initial state
|
|
9679
|
+
const toInputString = ts => {
|
|
9680
|
+
if (!ts) return "";
|
|
9681
|
+
const d = new Date(Number(ts));
|
|
9682
|
+
if (isNaN(d.getTime())) return "";
|
|
9683
|
+
if (time) {
|
|
9684
|
+
const yyyy = d.getFullYear();
|
|
9685
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9686
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9687
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9688
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9689
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9690
|
+
} else {
|
|
9691
|
+
const yyyy = d.getFullYear();
|
|
9692
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9693
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9694
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9695
|
+
}
|
|
9696
|
+
};
|
|
9697
|
+
const [range, setRange] = useState(() => {
|
|
9698
|
+
if (controlledValue && Array.isArray(controlledValue)) return controlledValue;
|
|
9699
|
+
if (!paramKey) return [getDefault('start'), getDefault('end')];
|
|
9700
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
9701
|
+
const urlVal = params.get(paramKey);
|
|
9702
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9703
|
+
const [start, end] = urlVal.split('~');
|
|
9704
|
+
return [toInputString(start), toInputString(end)];
|
|
9705
|
+
}
|
|
9706
|
+
return [getDefault('start'), getDefault('end')];
|
|
9707
|
+
});
|
|
9708
|
+
// Track selected predefined range
|
|
9709
|
+
const [selectedRange, setSelectedRange] = useState(() => {
|
|
9710
|
+
// Initialize with matching predefined range if any
|
|
9711
|
+
if (!paramKey) return "";
|
|
9712
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
9713
|
+
const urlVal = params.get(paramKey);
|
|
9714
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9715
|
+
const [start, end] = urlVal.split('~');
|
|
9716
|
+
// Check if this matches any predefined range
|
|
9717
|
+
for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
|
|
9718
|
+
const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
|
|
9719
|
+
if (new Date(pStart).getTime() === Number(start) && new Date(pEnd).getTime() === Number(end)) {
|
|
9720
|
+
return String(i);
|
|
9721
|
+
}
|
|
9722
|
+
}
|
|
9723
|
+
}
|
|
9724
|
+
return "";
|
|
9725
|
+
});
|
|
9726
|
+
|
|
9727
|
+
// Helper to check if a range matches a predefined range
|
|
9728
|
+
const findMatchingPredefined = (start, end) => {
|
|
9729
|
+
for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
|
|
9730
|
+
const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
|
|
9731
|
+
// Compare as timestamps for precision
|
|
9732
|
+
if (new Date(pStart).getTime() === new Date(start).getTime() && new Date(pEnd).getTime() === new Date(end).getTime()) {
|
|
9733
|
+
return String(i);
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
return "";
|
|
9737
|
+
};
|
|
9738
|
+
|
|
9739
|
+
// Sync with URL param on mount and popstate
|
|
9740
|
+
useEffect(() => {
|
|
9741
|
+
if (!paramKey || controlledValue && Array.isArray(controlledValue)) return;
|
|
9742
|
+
const syncFromUrl = () => {
|
|
9743
|
+
const params = new URLSearchParams(window.location.search);
|
|
9744
|
+
const urlVal = params.get(paramKey);
|
|
9745
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9746
|
+
const [start, end] = urlVal.split('~');
|
|
9747
|
+
setRange(prev => prev[0] !== toInputString(start) || prev[1] !== toInputString(end) ? [toInputString(start), toInputString(end)] : prev);
|
|
9748
|
+
if (onChange && (range[0] !== toInputString(start) || range[1] !== toInputString(end))) onChange([start, end]);
|
|
9749
|
+
// Set dropdown if matches predefined
|
|
9750
|
+
const matchIdx = findMatchingPredefined(Number(start), Number(end));
|
|
9751
|
+
setSelectedRange(matchIdx);
|
|
9752
|
+
} else {
|
|
9753
|
+
setSelectedRange("");
|
|
9754
|
+
}
|
|
9755
|
+
};
|
|
9756
|
+
syncFromUrl();
|
|
9757
|
+
window.addEventListener("popstate", syncFromUrl);
|
|
9758
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
9759
|
+
const patchHistory = type => {
|
|
9760
|
+
const orig = window.history[type];
|
|
9761
|
+
window.history[type] = function () {
|
|
9762
|
+
const rv = orig.apply(this, arguments);
|
|
9763
|
+
window.dispatchEvent(new Event(type));
|
|
9764
|
+
return rv;
|
|
9765
|
+
};
|
|
9766
|
+
};
|
|
9767
|
+
patchHistory('pushState');
|
|
9768
|
+
patchHistory('replaceState');
|
|
9769
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
9770
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
9771
|
+
return () => {
|
|
9772
|
+
window.removeEventListener("popstate", syncFromUrl);
|
|
9773
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
9774
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
9775
|
+
};
|
|
9776
|
+
}, [paramKey, onChange]);
|
|
9777
|
+
|
|
9778
|
+
// If controlled, update local value when prop changes
|
|
9779
|
+
useEffect(() => {
|
|
9780
|
+
if (controlledValue && Array.isArray(controlledValue)) setRange(controlledValue);
|
|
9781
|
+
}, [controlledValue]);
|
|
9782
|
+
|
|
9783
|
+
// Update URL param
|
|
9784
|
+
const setUrlParam = useCallback(vals => {
|
|
9785
|
+
if (!paramKey) return;
|
|
9786
|
+
const params = new URLSearchParams(window.location.search);
|
|
9787
|
+
// Convert input strings to timestamps
|
|
9788
|
+
const toTs = v => {
|
|
9789
|
+
if (!v) return "";
|
|
9790
|
+
if (/^[0-9]+$/.test(v)) return v;
|
|
9791
|
+
const d = new Date(v);
|
|
9792
|
+
return d.getTime();
|
|
9793
|
+
};
|
|
9794
|
+
if (vals[0] && vals[1]) {
|
|
9795
|
+
params.set(paramKey, `${toTs(vals[0])}~${toTs(vals[1])}`);
|
|
9796
|
+
} else {
|
|
9797
|
+
params.delete(paramKey);
|
|
9798
|
+
}
|
|
9799
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
9800
|
+
window.history.replaceState({}, "", newUrl);
|
|
9801
|
+
}, [paramKey]);
|
|
9802
|
+
const handleClear = () => {
|
|
9803
|
+
if (!controlledValue) setRange(["", ""]);
|
|
9804
|
+
setUrlParam(["", ""]);
|
|
9805
|
+
onChange?.(["", ""]);
|
|
9806
|
+
};
|
|
9807
|
+
|
|
9808
|
+
// Show/hide dropdown for range selection
|
|
9809
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
9810
|
+
const [dropdownPosition, setDropdownPosition] = useState({
|
|
9811
|
+
top: "110%",
|
|
9812
|
+
left: 0,
|
|
9813
|
+
right: 'auto'
|
|
9814
|
+
});
|
|
9815
|
+
|
|
9816
|
+
// Calculate dropdown position to prevent overflow
|
|
9817
|
+
const dropdownRef = React__default.useRef(null);
|
|
9818
|
+
React__default.useEffect(() => {
|
|
9819
|
+
if (!dropdownOpen || !dropdownRef.current) return;
|
|
9820
|
+
const dropdown = dropdownRef.current;
|
|
9821
|
+
const rect = dropdown.getBoundingClientRect();
|
|
9822
|
+
const viewportWidth = window.innerWidth;
|
|
9823
|
+
const viewportHeight = window.innerHeight;
|
|
9824
|
+
let newPosition = {
|
|
9825
|
+
top: "110%",
|
|
9826
|
+
left: 0,
|
|
9827
|
+
right: 'auto'
|
|
9828
|
+
};
|
|
9829
|
+
|
|
9830
|
+
// Check if dropdown goes beyond right edge
|
|
9831
|
+
if (rect.right > viewportWidth - 10) {
|
|
9832
|
+
newPosition.right = 0;
|
|
9833
|
+
newPosition.left = 'auto';
|
|
9834
|
+
}
|
|
9835
|
+
|
|
9836
|
+
// Check if dropdown goes beyond bottom edge
|
|
9837
|
+
if (rect.bottom > viewportHeight - 10) {
|
|
9838
|
+
newPosition.top = 'auto';
|
|
9839
|
+
newPosition.bottom = "110%";
|
|
9840
|
+
}
|
|
9841
|
+
setDropdownPosition(newPosition);
|
|
9842
|
+
}, [dropdownOpen]);
|
|
9843
|
+
|
|
9844
|
+
// Format range for display using dateFormat and timeFormat props
|
|
9845
|
+
const formatDisplay = () => {
|
|
9846
|
+
if (!range[0] && !range[1]) return {
|
|
9847
|
+
start: "",
|
|
9848
|
+
end: ""
|
|
9849
|
+
};
|
|
9850
|
+
const fmt = v => {
|
|
9851
|
+
if (!v) return "";
|
|
9852
|
+
const d = new Date(v);
|
|
9853
|
+
if (isNaN(d.getTime())) return "";
|
|
9854
|
+
|
|
9855
|
+
// Parse dateFormat (default: DD-MM-YYYY)
|
|
9856
|
+
const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
|
|
9857
|
+
const yyyy = d.getFullYear();
|
|
9858
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9859
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9860
|
+
let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
|
|
9861
|
+
if (time) {
|
|
9862
|
+
// Parse timeFormat (default: HH:mm)
|
|
9863
|
+
const actualTimeFormat = timeFormat || "HH:mm";
|
|
9864
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9865
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9866
|
+
const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
|
|
9867
|
+
return `${dateStr} ${timeStr}`;
|
|
9868
|
+
}
|
|
9869
|
+
return dateStr;
|
|
9870
|
+
};
|
|
9871
|
+
return {
|
|
9872
|
+
start: fmt(range[0]),
|
|
9873
|
+
end: fmt(range[1])
|
|
9874
|
+
};
|
|
9875
|
+
};
|
|
9876
|
+
// Close dropdown on outside click
|
|
9877
|
+
useEffect(() => {
|
|
9878
|
+
if (!dropdownOpen) return;
|
|
9879
|
+
const onClick = e => {
|
|
9880
|
+
if (!e.target.closest('.range-picker-dropdown')) setDropdownOpen(false);
|
|
9881
|
+
};
|
|
9882
|
+
window.addEventListener('mousedown', onClick);
|
|
9883
|
+
return () => window.removeEventListener('mousedown', onClick);
|
|
9884
|
+
}, [dropdownOpen]);
|
|
9885
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
9886
|
+
style: {
|
|
9887
|
+
position: "relative",
|
|
9888
|
+
display: "inline-flex",
|
|
9889
|
+
gap: 4,
|
|
9890
|
+
...style
|
|
9891
|
+
},
|
|
9892
|
+
className: className
|
|
9893
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9894
|
+
style: {
|
|
9895
|
+
position: "relative",
|
|
9896
|
+
flex: 1
|
|
9897
|
+
}
|
|
9898
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
9899
|
+
className: "basic-input",
|
|
9900
|
+
onClick: () => setDropdownOpen(!dropdownOpen),
|
|
9901
|
+
style: {
|
|
9902
|
+
cursor: "pointer",
|
|
9903
|
+
background: dropdownOpen ? "#f0f8ff" : "#fff",
|
|
9904
|
+
height: 34,
|
|
9905
|
+
minHeight: 34,
|
|
9906
|
+
width: 280,
|
|
9907
|
+
border: '1px solid #ccc',
|
|
9908
|
+
borderRadius: 2,
|
|
9909
|
+
display: 'flex',
|
|
9910
|
+
alignItems: 'center',
|
|
9911
|
+
padding: '0 32px 0 8px',
|
|
9912
|
+
position: 'relative',
|
|
9913
|
+
fontSize: 14
|
|
9914
|
+
}
|
|
9915
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
9916
|
+
style: {
|
|
9917
|
+
color: formatDisplay().start ? '#333' : '#999',
|
|
9918
|
+
flex: 1
|
|
9919
|
+
}
|
|
9920
|
+
}, formatDisplay().start || 'Start date'), /*#__PURE__*/React__default.createElement("span", {
|
|
9921
|
+
style: {
|
|
9922
|
+
padding: '0 8px',
|
|
9923
|
+
color: '#999'
|
|
9924
|
+
}
|
|
9925
|
+
}, "\u2192"), /*#__PURE__*/React__default.createElement("span", {
|
|
9926
|
+
style: {
|
|
9927
|
+
color: formatDisplay().end ? '#333' : '#999',
|
|
9928
|
+
flex: 1
|
|
9929
|
+
}
|
|
9930
|
+
}, formatDisplay().end || 'End date'), /*#__PURE__*/React__default.createElement("span", {
|
|
9931
|
+
style: {
|
|
9932
|
+
position: 'absolute',
|
|
9933
|
+
right: 8,
|
|
9934
|
+
top: '50%',
|
|
9935
|
+
transform: 'translateY(-51%)',
|
|
9936
|
+
fontSize: 16,
|
|
9937
|
+
color: '#666'
|
|
9938
|
+
}
|
|
9939
|
+
}, "\uD83D\uDCC5")), dropdownOpen && /*#__PURE__*/React__default.createElement("div", {
|
|
9940
|
+
ref: dropdownRef,
|
|
9941
|
+
className: "range-picker-dropdown",
|
|
9942
|
+
style: {
|
|
9943
|
+
position: "absolute",
|
|
9944
|
+
...dropdownPosition,
|
|
9945
|
+
background: "#fff",
|
|
9946
|
+
border: "1px solid #ccc",
|
|
9947
|
+
borderRadius: 4,
|
|
9948
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
|
|
9949
|
+
padding: 12,
|
|
9950
|
+
zIndex: 1000,
|
|
9951
|
+
minWidth: 260
|
|
9952
|
+
}
|
|
9953
|
+
}, /*#__PURE__*/React__default.createElement(CalendarRangePicker, {
|
|
9954
|
+
startDate: range[0] ? new Date(range[0]) : null,
|
|
9955
|
+
endDate: range[1] ? new Date(range[1]) : null,
|
|
9956
|
+
onChange: (start, end) => {
|
|
9957
|
+
const toStr = d => {
|
|
9958
|
+
if (!d) return "";
|
|
9959
|
+
if (time) {
|
|
9960
|
+
const yyyy = d.getFullYear();
|
|
9961
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9962
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9963
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9964
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9965
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9966
|
+
} else {
|
|
9967
|
+
const yyyy = d.getFullYear();
|
|
9968
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9969
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9970
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9971
|
+
}
|
|
9972
|
+
};
|
|
9973
|
+
const newRange = [toStr(start), toStr(end)];
|
|
9974
|
+
if (!controlledValue) setRange(newRange);
|
|
9975
|
+
setUrlParam(newRange);
|
|
9976
|
+
onChange?.(newRange);
|
|
9977
|
+
},
|
|
9978
|
+
time: time,
|
|
9979
|
+
timeStart: timeStart,
|
|
9980
|
+
timeEnd: timeEnd
|
|
9981
|
+
}), processedRanges && processedRanges.length > 0 && /*#__PURE__*/React__default.createElement("div", {
|
|
9982
|
+
style: {
|
|
9983
|
+
marginTop: 12,
|
|
9984
|
+
paddingTop: 12,
|
|
9985
|
+
borderTop: '1px solid #e5e7eb',
|
|
9986
|
+
display: 'flex',
|
|
9987
|
+
gap: 6,
|
|
9988
|
+
flexWrap: 'wrap'
|
|
9989
|
+
}
|
|
9990
|
+
}, processedRanges.map((r, i) => {
|
|
9991
|
+
const isActive = selectedRange === String(i);
|
|
9992
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
9993
|
+
key: r.label,
|
|
9994
|
+
type: "button",
|
|
9995
|
+
onClick: () => {
|
|
9996
|
+
const {
|
|
9997
|
+
getRange
|
|
9998
|
+
} = r;
|
|
9999
|
+
const newRange = getRange(time);
|
|
10000
|
+
if (!controlledValue) setRange(newRange);
|
|
10001
|
+
setUrlParam(newRange);
|
|
10002
|
+
setSelectedRange(String(i));
|
|
10003
|
+
onChange?.(newRange);
|
|
10004
|
+
},
|
|
10005
|
+
style: {
|
|
10006
|
+
padding: '4px 12px',
|
|
10007
|
+
border: isActive ? '1px solid #1d4ed8' : '1px solid #d1d5db',
|
|
10008
|
+
background: isActive ? '#e0f2fe' : '#fff',
|
|
10009
|
+
color: isActive ? '#1d4ed8' : '#333',
|
|
10010
|
+
borderRadius: 4,
|
|
10011
|
+
cursor: 'pointer',
|
|
10012
|
+
fontSize: 12,
|
|
10013
|
+
fontWeight: isActive ? 500 : 400,
|
|
10014
|
+
transition: 'all 0.15s ease'
|
|
10015
|
+
}
|
|
10016
|
+
}, r.label);
|
|
10017
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
10018
|
+
style: {
|
|
10019
|
+
marginTop: 12,
|
|
10020
|
+
textAlign: 'right',
|
|
10021
|
+
borderTop: '1px solid #e5e7eb',
|
|
10022
|
+
paddingTop: 12
|
|
10023
|
+
}
|
|
10024
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
10025
|
+
type: "button",
|
|
10026
|
+
onClick: handleClear,
|
|
10027
|
+
style: {
|
|
10028
|
+
marginRight: 8,
|
|
10029
|
+
padding: '6px 16px',
|
|
10030
|
+
border: '1px solid #d1d5db',
|
|
10031
|
+
background: '#fff',
|
|
10032
|
+
borderRadius: 4,
|
|
10033
|
+
cursor: 'pointer',
|
|
10034
|
+
fontSize: 13
|
|
10035
|
+
}
|
|
10036
|
+
}, "Clear"), /*#__PURE__*/React__default.createElement("button", {
|
|
10037
|
+
type: "button",
|
|
10038
|
+
onClick: () => setDropdownOpen(false),
|
|
10039
|
+
style: {
|
|
10040
|
+
padding: '6px 16px',
|
|
10041
|
+
border: 'none',
|
|
10042
|
+
background: '#1d4ed8',
|
|
10043
|
+
color: '#fff',
|
|
10044
|
+
borderRadius: 4,
|
|
10045
|
+
cursor: 'pointer',
|
|
10046
|
+
fontSize: 13,
|
|
10047
|
+
fontWeight: 500
|
|
10048
|
+
}
|
|
10049
|
+
}, "OK")))));
|
|
10050
|
+
}
|
|
10051
|
+
RangePicker.propTypes = {
|
|
10052
|
+
pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
10053
|
+
value: PropTypes.arrayOf(PropTypes.string),
|
|
10054
|
+
onChange: PropTypes.func,
|
|
10055
|
+
time: PropTypes.bool,
|
|
10056
|
+
timeStart: PropTypes.string,
|
|
10057
|
+
timeEnd: PropTypes.string,
|
|
10058
|
+
timezone: PropTypes.string,
|
|
10059
|
+
timeFormat: PropTypes.string,
|
|
10060
|
+
dateFormat: PropTypes.string,
|
|
10061
|
+
placeholder: PropTypes.string,
|
|
10062
|
+
required: PropTypes.bool,
|
|
10063
|
+
disabled: PropTypes.bool,
|
|
10064
|
+
className: PropTypes.string,
|
|
10065
|
+
style: PropTypes.object,
|
|
10066
|
+
min: PropTypes.string,
|
|
10067
|
+
max: PropTypes.string,
|
|
10068
|
+
predefinedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,
|
|
10069
|
+
// e.g., "today", "yesterday", "lastweek"
|
|
10070
|
+
PropTypes.number,
|
|
10071
|
+
// e.g., 7, 30 (last N days)
|
|
10072
|
+
PropTypes.shape({
|
|
10073
|
+
label: PropTypes.string.isRequired,
|
|
10074
|
+
getRange: PropTypes.func.isRequired
|
|
10075
|
+
})])), PropTypes.arrayOf(PropTypes.shape({
|
|
10076
|
+
label: PropTypes.string.isRequired,
|
|
10077
|
+
getRange: PropTypes.func.isRequired
|
|
10078
|
+
}))])
|
|
10079
|
+
};
|
|
7507
10080
|
|
|
7508
|
-
export {
|
|
10081
|
+
export { CalendarRangePicker, DateTimeInput, DebounceSelect, IconInput, MultiSelectDropdown, RangePicker, SearchInput };
|
|
7509
10082
|
//# sourceMappingURL=index.esm.js.map
|