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.cjs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var React$1 = require('react');
|
|
3
|
+
var React = require('react');
|
|
6
4
|
var reactDom = require('react-dom');
|
|
7
5
|
|
|
8
6
|
function _interopNamespaceDefault(e) {
|
|
@@ -22,7 +20,7 @@ function _interopNamespaceDefault(e) {
|
|
|
22
20
|
return Object.freeze(n);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React
|
|
23
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
24
|
|
|
27
25
|
function _typeof(o) {
|
|
28
26
|
"@babel/helpers - typeof";
|
|
@@ -173,38 +171,38 @@ function useStateManager(_ref) {
|
|
|
173
171
|
propsOnMenuOpen = _ref.onMenuOpen,
|
|
174
172
|
propsValue = _ref.value,
|
|
175
173
|
restSelectProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
176
|
-
var _useState = React
|
|
174
|
+
var _useState = React.useState(propsInputValue !== undefined ? propsInputValue : defaultInputValue),
|
|
177
175
|
_useState2 = _slicedToArray(_useState, 2),
|
|
178
176
|
stateInputValue = _useState2[0],
|
|
179
177
|
setStateInputValue = _useState2[1];
|
|
180
|
-
var _useState3 = React
|
|
178
|
+
var _useState3 = React.useState(propsMenuIsOpen !== undefined ? propsMenuIsOpen : defaultMenuIsOpen),
|
|
181
179
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
182
180
|
stateMenuIsOpen = _useState4[0],
|
|
183
181
|
setStateMenuIsOpen = _useState4[1];
|
|
184
|
-
var _useState5 = React
|
|
182
|
+
var _useState5 = React.useState(propsValue !== undefined ? propsValue : defaultValue),
|
|
185
183
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
186
184
|
stateValue = _useState6[0],
|
|
187
185
|
setStateValue = _useState6[1];
|
|
188
|
-
var onChange = React
|
|
186
|
+
var onChange = React.useCallback(function (value, actionMeta) {
|
|
189
187
|
if (typeof propsOnChange === 'function') {
|
|
190
188
|
propsOnChange(value, actionMeta);
|
|
191
189
|
}
|
|
192
190
|
setStateValue(value);
|
|
193
191
|
}, [propsOnChange]);
|
|
194
|
-
var onInputChange = React
|
|
192
|
+
var onInputChange = React.useCallback(function (value, actionMeta) {
|
|
195
193
|
var newValue;
|
|
196
194
|
if (typeof propsOnInputChange === 'function') {
|
|
197
195
|
newValue = propsOnInputChange(value, actionMeta);
|
|
198
196
|
}
|
|
199
197
|
setStateInputValue(newValue !== undefined ? newValue : value);
|
|
200
198
|
}, [propsOnInputChange]);
|
|
201
|
-
var onMenuOpen = React
|
|
199
|
+
var onMenuOpen = React.useCallback(function () {
|
|
202
200
|
if (typeof propsOnMenuOpen === 'function') {
|
|
203
201
|
propsOnMenuOpen();
|
|
204
202
|
}
|
|
205
203
|
setStateMenuIsOpen(true);
|
|
206
204
|
}, [propsOnMenuOpen]);
|
|
207
|
-
var onMenuClose = React
|
|
205
|
+
var onMenuClose = React.useCallback(function () {
|
|
208
206
|
if (typeof propsOnMenuClose === 'function') {
|
|
209
207
|
propsOnMenuClose();
|
|
210
208
|
}
|
|
@@ -224,14 +222,14 @@ function useStateManager(_ref) {
|
|
|
224
222
|
});
|
|
225
223
|
}
|
|
226
224
|
|
|
227
|
-
function _extends() {
|
|
228
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
225
|
+
function _extends$1() {
|
|
226
|
+
return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
|
|
229
227
|
for (var e = 1; e < arguments.length; e++) {
|
|
230
228
|
var t = arguments[e];
|
|
231
229
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
232
230
|
}
|
|
233
231
|
return n;
|
|
234
|
-
}, _extends.apply(null, arguments);
|
|
232
|
+
}, _extends$1.apply(null, arguments);
|
|
235
233
|
}
|
|
236
234
|
|
|
237
235
|
function _classCallCheck(a, n) {
|
|
@@ -1570,6 +1568,10 @@ var createCache = function createCache(options) {
|
|
|
1570
1568
|
return cache;
|
|
1571
1569
|
};
|
|
1572
1570
|
|
|
1571
|
+
function getDefaultExportFromCjs (x) {
|
|
1572
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1573
1575
|
var reactIs = {exports: {}};
|
|
1574
1576
|
|
|
1575
1577
|
var reactIs_production_min = {};
|
|
@@ -2314,9 +2316,9 @@ typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
|
|
|
2314
2316
|
EmotionCacheContext.Provider;
|
|
2315
2317
|
|
|
2316
2318
|
var withEmotionCache = function withEmotionCache(func) {
|
|
2317
|
-
return /*#__PURE__*/React
|
|
2319
|
+
return /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
2318
2320
|
// the cache will never be null in the browser
|
|
2319
|
-
var cache = React
|
|
2321
|
+
var cache = React.useContext(EmotionCacheContext);
|
|
2320
2322
|
return func(props, cache, ref);
|
|
2321
2323
|
});
|
|
2322
2324
|
};
|
|
@@ -2324,7 +2326,7 @@ var withEmotionCache = function withEmotionCache(func) {
|
|
|
2324
2326
|
if (!isBrowser) {
|
|
2325
2327
|
withEmotionCache = function withEmotionCache(func) {
|
|
2326
2328
|
return function (props) {
|
|
2327
|
-
var cache = React
|
|
2329
|
+
var cache = React.useContext(EmotionCacheContext);
|
|
2328
2330
|
|
|
2329
2331
|
if (cache === null) {
|
|
2330
2332
|
// yes, we're potentially creating this on every render
|
|
@@ -2926,7 +2928,7 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
2926
2928
|
var isClient = typeof document !== 'undefined';
|
|
2927
2929
|
|
|
2928
2930
|
var noop$1 = function noop() {};
|
|
2929
|
-
var index = isClient ? React
|
|
2931
|
+
var index = isClient ? React.useLayoutEffect : noop$1;
|
|
2930
2932
|
|
|
2931
2933
|
var _excluded$4 = ["className", "clearValue", "cx", "getStyles", "getClassNames", "getValue", "hasValue", "isMulti", "isRtl", "options", "selectOption", "selectProps", "setValue", "theme"];
|
|
2932
2934
|
// ==============================
|
|
@@ -3404,7 +3406,7 @@ var menuCSS = function menuCSS(_ref2, unstyled) {
|
|
|
3404
3406
|
marginTop: spacing.menuGutter
|
|
3405
3407
|
});
|
|
3406
3408
|
};
|
|
3407
|
-
var PortalPlacementContext = /*#__PURE__*/React
|
|
3409
|
+
var PortalPlacementContext = /*#__PURE__*/React.createContext(null);
|
|
3408
3410
|
|
|
3409
3411
|
// NOTE: internal only
|
|
3410
3412
|
var MenuPlacer = function MenuPlacer(props) {
|
|
@@ -3415,14 +3417,14 @@ var MenuPlacer = function MenuPlacer(props) {
|
|
|
3415
3417
|
menuPosition = props.menuPosition,
|
|
3416
3418
|
menuShouldScrollIntoView = props.menuShouldScrollIntoView,
|
|
3417
3419
|
theme = props.theme;
|
|
3418
|
-
var _ref3 = React
|
|
3420
|
+
var _ref3 = React.useContext(PortalPlacementContext) || {},
|
|
3419
3421
|
setPortalPlacement = _ref3.setPortalPlacement;
|
|
3420
|
-
var ref = React
|
|
3421
|
-
var _useState = React
|
|
3422
|
+
var ref = React.useRef(null);
|
|
3423
|
+
var _useState = React.useState(maxMenuHeight),
|
|
3422
3424
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3423
3425
|
maxHeight = _useState2[0],
|
|
3424
3426
|
setMaxHeight = _useState2[1];
|
|
3425
|
-
var _useState3 = React
|
|
3427
|
+
var _useState3 = React.useState(null),
|
|
3426
3428
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
3427
3429
|
placement = _useState4[0],
|
|
3428
3430
|
setPlacement = _useState4[1];
|
|
@@ -3459,7 +3461,7 @@ var Menu = function Menu(props) {
|
|
|
3459
3461
|
var children = props.children,
|
|
3460
3462
|
innerRef = props.innerRef,
|
|
3461
3463
|
innerProps = props.innerProps;
|
|
3462
|
-
return jsx("div", _extends({}, getStyleProps(props, 'menu', {
|
|
3464
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'menu', {
|
|
3463
3465
|
menu: true
|
|
3464
3466
|
}), {
|
|
3465
3467
|
ref: innerRef
|
|
@@ -3490,7 +3492,7 @@ var MenuList = function MenuList(props) {
|
|
|
3490
3492
|
innerProps = props.innerProps,
|
|
3491
3493
|
innerRef = props.innerRef,
|
|
3492
3494
|
isMulti = props.isMulti;
|
|
3493
|
-
return jsx("div", _extends({}, getStyleProps(props, 'menuList', {
|
|
3495
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'menuList', {
|
|
3494
3496
|
'menu-list': true,
|
|
3495
3497
|
'menu-list--is-multi': isMulti
|
|
3496
3498
|
}), {
|
|
@@ -3520,7 +3522,7 @@ var NoOptionsMessage = function NoOptionsMessage(_ref6) {
|
|
|
3520
3522
|
children = _ref6$children === void 0 ? 'No options' : _ref6$children,
|
|
3521
3523
|
innerProps = _ref6.innerProps,
|
|
3522
3524
|
restProps = _objectWithoutProperties(_ref6, _excluded$3);
|
|
3523
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3525
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3524
3526
|
children: children,
|
|
3525
3527
|
innerProps: innerProps
|
|
3526
3528
|
}), 'noOptionsMessage', {
|
|
@@ -3533,7 +3535,7 @@ var LoadingMessage = function LoadingMessage(_ref7) {
|
|
|
3533
3535
|
children = _ref7$children === void 0 ? 'Loading...' : _ref7$children,
|
|
3534
3536
|
innerProps = _ref7.innerProps,
|
|
3535
3537
|
restProps = _objectWithoutProperties(_ref7, _excluded2$1);
|
|
3536
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3538
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3537
3539
|
children: children,
|
|
3538
3540
|
innerProps: innerProps
|
|
3539
3541
|
}), 'loadingMessage', {
|
|
@@ -3565,22 +3567,22 @@ var MenuPortal = function MenuPortal(props) {
|
|
|
3565
3567
|
innerProps = props.innerProps,
|
|
3566
3568
|
menuPlacement = props.menuPlacement,
|
|
3567
3569
|
menuPosition = props.menuPosition;
|
|
3568
|
-
var menuPortalRef = React
|
|
3569
|
-
var cleanupRef = React
|
|
3570
|
-
var _useState5 = React
|
|
3570
|
+
var menuPortalRef = React.useRef(null);
|
|
3571
|
+
var cleanupRef = React.useRef(null);
|
|
3572
|
+
var _useState5 = React.useState(coercePlacement(menuPlacement)),
|
|
3571
3573
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
3572
3574
|
placement = _useState6[0],
|
|
3573
3575
|
setPortalPlacement = _useState6[1];
|
|
3574
|
-
var portalPlacementContext = React
|
|
3576
|
+
var portalPlacementContext = React.useMemo(function () {
|
|
3575
3577
|
return {
|
|
3576
3578
|
setPortalPlacement: setPortalPlacement
|
|
3577
3579
|
};
|
|
3578
3580
|
}, []);
|
|
3579
|
-
var _useState7 = React
|
|
3581
|
+
var _useState7 = React.useState(null),
|
|
3580
3582
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
3581
3583
|
computedPosition = _useState8[0],
|
|
3582
3584
|
setComputedPosition = _useState8[1];
|
|
3583
|
-
var updateComputedPosition = React
|
|
3585
|
+
var updateComputedPosition = React.useCallback(function () {
|
|
3584
3586
|
if (!controlElement) return;
|
|
3585
3587
|
var rect = getBoundingClientObj(controlElement);
|
|
3586
3588
|
var scrollDistance = menuPosition === 'fixed' ? 0 : window.pageYOffset;
|
|
@@ -3595,7 +3597,7 @@ var MenuPortal = function MenuPortal(props) {
|
|
|
3595
3597
|
index(function () {
|
|
3596
3598
|
updateComputedPosition();
|
|
3597
3599
|
}, [updateComputedPosition]);
|
|
3598
|
-
var runAutoUpdate = React
|
|
3600
|
+
var runAutoUpdate = React.useCallback(function () {
|
|
3599
3601
|
if (typeof cleanupRef.current === 'function') {
|
|
3600
3602
|
cleanupRef.current();
|
|
3601
3603
|
cleanupRef.current = null;
|
|
@@ -3609,7 +3611,7 @@ var MenuPortal = function MenuPortal(props) {
|
|
|
3609
3611
|
index(function () {
|
|
3610
3612
|
runAutoUpdate();
|
|
3611
3613
|
}, [runAutoUpdate]);
|
|
3612
|
-
var setMenuPortalElement = React
|
|
3614
|
+
var setMenuPortalElement = React.useCallback(function (menuPortalElement) {
|
|
3613
3615
|
menuPortalRef.current = menuPortalElement;
|
|
3614
3616
|
runAutoUpdate();
|
|
3615
3617
|
}, [runAutoUpdate]);
|
|
@@ -3618,7 +3620,7 @@ var MenuPortal = function MenuPortal(props) {
|
|
|
3618
3620
|
if (!appendTo && menuPosition !== 'fixed' || !computedPosition) return null;
|
|
3619
3621
|
|
|
3620
3622
|
// same wrapper element whether fixed or portalled
|
|
3621
|
-
var menuWrapper = jsx("div", _extends({
|
|
3623
|
+
var menuWrapper = jsx("div", _extends$1({
|
|
3622
3624
|
ref: setMenuPortalElement
|
|
3623
3625
|
}, getStyleProps(_objectSpread2(_objectSpread2({}, props), {}, {
|
|
3624
3626
|
offset: computedPosition.offset,
|
|
@@ -3652,7 +3654,7 @@ var SelectContainer = function SelectContainer(props) {
|
|
|
3652
3654
|
innerProps = props.innerProps,
|
|
3653
3655
|
isDisabled = props.isDisabled,
|
|
3654
3656
|
isRtl = props.isRtl;
|
|
3655
|
-
return jsx("div", _extends({}, getStyleProps(props, 'container', {
|
|
3657
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'container', {
|
|
3656
3658
|
'--is-disabled': isDisabled,
|
|
3657
3659
|
'--is-rtl': isRtl
|
|
3658
3660
|
}), innerProps), children);
|
|
@@ -3684,7 +3686,7 @@ var ValueContainer = function ValueContainer(props) {
|
|
|
3684
3686
|
innerProps = props.innerProps,
|
|
3685
3687
|
isMulti = props.isMulti,
|
|
3686
3688
|
hasValue = props.hasValue;
|
|
3687
|
-
return jsx("div", _extends({}, getStyleProps(props, 'valueContainer', {
|
|
3689
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'valueContainer', {
|
|
3688
3690
|
'value-container': true,
|
|
3689
3691
|
'value-container--is-multi': isMulti,
|
|
3690
3692
|
'value-container--has-value': hasValue
|
|
@@ -3706,7 +3708,7 @@ var indicatorsContainerCSS = function indicatorsContainerCSS() {
|
|
|
3706
3708
|
var IndicatorsContainer = function IndicatorsContainer(props) {
|
|
3707
3709
|
var children = props.children,
|
|
3708
3710
|
innerProps = props.innerProps;
|
|
3709
|
-
return jsx("div", _extends({}, getStyleProps(props, 'indicatorsContainer', {
|
|
3711
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'indicatorsContainer', {
|
|
3710
3712
|
indicators: true
|
|
3711
3713
|
}), innerProps), children);
|
|
3712
3714
|
};
|
|
@@ -3731,7 +3733,7 @@ var _ref2$2 = process.env.NODE_ENV === "production" ? {
|
|
|
3731
3733
|
var Svg = function Svg(_ref) {
|
|
3732
3734
|
var size = _ref.size,
|
|
3733
3735
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
3734
|
-
return jsx("svg", _extends({
|
|
3736
|
+
return jsx("svg", _extends$1({
|
|
3735
3737
|
height: size,
|
|
3736
3738
|
width: size,
|
|
3737
3739
|
viewBox: "0 0 20 20",
|
|
@@ -3741,14 +3743,14 @@ var Svg = function Svg(_ref) {
|
|
|
3741
3743
|
}, props));
|
|
3742
3744
|
};
|
|
3743
3745
|
var CrossIcon = function CrossIcon(props) {
|
|
3744
|
-
return jsx(Svg, _extends({
|
|
3746
|
+
return jsx(Svg, _extends$1({
|
|
3745
3747
|
size: 20
|
|
3746
3748
|
}, props), jsx("path", {
|
|
3747
3749
|
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"
|
|
3748
3750
|
}));
|
|
3749
3751
|
};
|
|
3750
3752
|
var DownChevron = function DownChevron(props) {
|
|
3751
|
-
return jsx(Svg, _extends({
|
|
3753
|
+
return jsx(Svg, _extends$1({
|
|
3752
3754
|
size: 20
|
|
3753
3755
|
}, props), jsx("path", {
|
|
3754
3756
|
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"
|
|
@@ -3780,7 +3782,7 @@ var dropdownIndicatorCSS = baseCSS;
|
|
|
3780
3782
|
var DropdownIndicator = function DropdownIndicator(props) {
|
|
3781
3783
|
var children = props.children,
|
|
3782
3784
|
innerProps = props.innerProps;
|
|
3783
|
-
return jsx("div", _extends({}, getStyleProps(props, 'dropdownIndicator', {
|
|
3785
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'dropdownIndicator', {
|
|
3784
3786
|
indicator: true,
|
|
3785
3787
|
'dropdown-indicator': true
|
|
3786
3788
|
}), innerProps), children || jsx(DownChevron, null));
|
|
@@ -3789,7 +3791,7 @@ var clearIndicatorCSS = baseCSS;
|
|
|
3789
3791
|
var ClearIndicator = function ClearIndicator(props) {
|
|
3790
3792
|
var children = props.children,
|
|
3791
3793
|
innerProps = props.innerProps;
|
|
3792
|
-
return jsx("div", _extends({}, getStyleProps(props, 'clearIndicator', {
|
|
3794
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'clearIndicator', {
|
|
3793
3795
|
indicator: true,
|
|
3794
3796
|
'clear-indicator': true
|
|
3795
3797
|
}), innerProps), children || jsx(CrossIcon, null));
|
|
@@ -3816,7 +3818,7 @@ var indicatorSeparatorCSS = function indicatorSeparatorCSS(_ref4, unstyled) {
|
|
|
3816
3818
|
};
|
|
3817
3819
|
var IndicatorSeparator = function IndicatorSeparator(props) {
|
|
3818
3820
|
var innerProps = props.innerProps;
|
|
3819
|
-
return jsx("span", _extends({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
3821
|
+
return jsx("span", _extends$1({}, innerProps, getStyleProps(props, 'indicatorSeparator', {
|
|
3820
3822
|
'indicator-separator': true
|
|
3821
3823
|
})));
|
|
3822
3824
|
};
|
|
@@ -3869,7 +3871,7 @@ var LoadingIndicator = function LoadingIndicator(_ref7) {
|
|
|
3869
3871
|
_ref7$size = _ref7.size,
|
|
3870
3872
|
size = _ref7$size === void 0 ? 4 : _ref7$size,
|
|
3871
3873
|
restProps = _objectWithoutProperties(_ref7, _excluded2);
|
|
3872
|
-
return jsx("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3874
|
+
return jsx("div", _extends$1({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, {
|
|
3873
3875
|
innerProps: innerProps,
|
|
3874
3876
|
isRtl: isRtl,
|
|
3875
3877
|
size: size
|
|
@@ -3925,7 +3927,7 @@ var Control = function Control(props) {
|
|
|
3925
3927
|
innerRef = props.innerRef,
|
|
3926
3928
|
innerProps = props.innerProps,
|
|
3927
3929
|
menuIsOpen = props.menuIsOpen;
|
|
3928
|
-
return jsx("div", _extends({
|
|
3930
|
+
return jsx("div", _extends$1({
|
|
3929
3931
|
ref: innerRef
|
|
3930
3932
|
}, getStyleProps(props, 'control', {
|
|
3931
3933
|
control: true,
|
|
@@ -3957,9 +3959,9 @@ var Group = function Group(props) {
|
|
|
3957
3959
|
label = props.label,
|
|
3958
3960
|
theme = props.theme,
|
|
3959
3961
|
selectProps = props.selectProps;
|
|
3960
|
-
return jsx("div", _extends({}, getStyleProps(props, 'group', {
|
|
3962
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'group', {
|
|
3961
3963
|
group: true
|
|
3962
|
-
}), innerProps), jsx(Heading, _extends({}, headingProps, {
|
|
3964
|
+
}), innerProps), jsx(Heading, _extends$1({}, headingProps, {
|
|
3963
3965
|
selectProps: selectProps,
|
|
3964
3966
|
theme: theme,
|
|
3965
3967
|
getStyles: getStyles,
|
|
@@ -3989,7 +3991,7 @@ var GroupHeading = function GroupHeading(props) {
|
|
|
3989
3991
|
var _cleanCommonProps = cleanCommonProps(props);
|
|
3990
3992
|
_cleanCommonProps.data;
|
|
3991
3993
|
var innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$1);
|
|
3992
|
-
return jsx("div", _extends({}, getStyleProps(props, 'groupHeading', {
|
|
3994
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'groupHeading', {
|
|
3993
3995
|
'group-heading': true
|
|
3994
3996
|
}), innerProps));
|
|
3995
3997
|
};
|
|
@@ -4052,11 +4054,11 @@ var Input = function Input(props) {
|
|
|
4052
4054
|
isHidden = _cleanCommonProps.isHidden,
|
|
4053
4055
|
inputClassName = _cleanCommonProps.inputClassName,
|
|
4054
4056
|
innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$5);
|
|
4055
|
-
return jsx("div", _extends({}, getStyleProps(props, 'input', {
|
|
4057
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'input', {
|
|
4056
4058
|
'input-container': true
|
|
4057
4059
|
}), {
|
|
4058
4060
|
"data-value": value || ''
|
|
4059
|
-
}), jsx("input", _extends({
|
|
4061
|
+
}), jsx("input", _extends$1({
|
|
4060
4062
|
className: cx({
|
|
4061
4063
|
input: true
|
|
4062
4064
|
}, inputClassName),
|
|
@@ -4129,7 +4131,7 @@ var MultiValueLabel = MultiValueGeneric;
|
|
|
4129
4131
|
function MultiValueRemove(_ref5) {
|
|
4130
4132
|
var children = _ref5.children,
|
|
4131
4133
|
innerProps = _ref5.innerProps;
|
|
4132
|
-
return jsx("div", _extends({
|
|
4134
|
+
return jsx("div", _extends$1({
|
|
4133
4135
|
role: "button"
|
|
4134
4136
|
}, innerProps), children || jsx(CrossIcon, {
|
|
4135
4137
|
size: 14
|
|
@@ -4203,7 +4205,7 @@ var Option = function Option(props) {
|
|
|
4203
4205
|
isSelected = props.isSelected,
|
|
4204
4206
|
innerRef = props.innerRef,
|
|
4205
4207
|
innerProps = props.innerProps;
|
|
4206
|
-
return jsx("div", _extends({}, getStyleProps(props, 'option', {
|
|
4208
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'option', {
|
|
4207
4209
|
option: true,
|
|
4208
4210
|
'option--is-disabled': isDisabled,
|
|
4209
4211
|
'option--is-focused': isFocused,
|
|
@@ -4231,7 +4233,7 @@ var placeholderCSS = function placeholderCSS(_ref, unstyled) {
|
|
|
4231
4233
|
var Placeholder = function Placeholder(props) {
|
|
4232
4234
|
var children = props.children,
|
|
4233
4235
|
innerProps = props.innerProps;
|
|
4234
|
-
return jsx("div", _extends({}, getStyleProps(props, 'placeholder', {
|
|
4236
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'placeholder', {
|
|
4235
4237
|
placeholder: true
|
|
4236
4238
|
}), innerProps), children);
|
|
4237
4239
|
};
|
|
@@ -4259,7 +4261,7 @@ var SingleValue = function SingleValue(props) {
|
|
|
4259
4261
|
var children = props.children,
|
|
4260
4262
|
isDisabled = props.isDisabled,
|
|
4261
4263
|
innerProps = props.innerProps;
|
|
4262
|
-
return jsx("div", _extends({}, getStyleProps(props, 'singleValue', {
|
|
4264
|
+
return jsx("div", _extends$1({}, getStyleProps(props, 'singleValue', {
|
|
4263
4265
|
'single-value': true,
|
|
4264
4266
|
'single-value--is-disabled': isDisabled
|
|
4265
4267
|
}), innerProps), children);
|
|
@@ -4360,7 +4362,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
|
|
|
4360
4362
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
|
|
4361
4363
|
};
|
|
4362
4364
|
var A11yText = function A11yText(props) {
|
|
4363
|
-
return jsx("span", _extends({
|
|
4365
|
+
return jsx("span", _extends$1({
|
|
4364
4366
|
css: _ref
|
|
4365
4367
|
}, props));
|
|
4366
4368
|
};
|
|
@@ -4460,12 +4462,12 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4460
4462
|
var ariaLive = selectProps['aria-live'];
|
|
4461
4463
|
|
|
4462
4464
|
// Update aria live message configuration when prop changes
|
|
4463
|
-
var messages = React
|
|
4465
|
+
var messages = React.useMemo(function () {
|
|
4464
4466
|
return _objectSpread2(_objectSpread2({}, defaultAriaLiveMessages), ariaLiveMessages || {});
|
|
4465
4467
|
}, [ariaLiveMessages]);
|
|
4466
4468
|
|
|
4467
4469
|
// Update aria live selected option when prop changes
|
|
4468
|
-
var ariaSelected = React
|
|
4470
|
+
var ariaSelected = React.useMemo(function () {
|
|
4469
4471
|
var message = '';
|
|
4470
4472
|
if (ariaSelection && messages.onChange) {
|
|
4471
4473
|
var option = ariaSelection.option,
|
|
@@ -4496,7 +4498,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4496
4498
|
}
|
|
4497
4499
|
return message;
|
|
4498
4500
|
}, [ariaSelection, messages, isOptionDisabled, selectValue, getOptionLabel]);
|
|
4499
|
-
var ariaFocused = React
|
|
4501
|
+
var ariaFocused = React.useMemo(function () {
|
|
4500
4502
|
var focusMsg = '';
|
|
4501
4503
|
var focused = focusedOption || focusedValue;
|
|
4502
4504
|
var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
|
|
@@ -4515,7 +4517,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4515
4517
|
}
|
|
4516
4518
|
return focusMsg;
|
|
4517
4519
|
}, [focusedOption, focusedValue, getOptionLabel, isOptionDisabled, messages, focusableOptions, selectValue, isAppleDevice]);
|
|
4518
|
-
var ariaResults = React
|
|
4520
|
+
var ariaResults = React.useMemo(function () {
|
|
4519
4521
|
var resultsMsg = '';
|
|
4520
4522
|
if (menuIsOpen && options.length && !isLoading && messages.onFilter) {
|
|
4521
4523
|
var resultsMessage = screenReaderStatus({
|
|
@@ -4529,7 +4531,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4529
4531
|
return resultsMsg;
|
|
4530
4532
|
}, [focusableOptions, inputValue, menuIsOpen, messages, options, screenReaderStatus, isLoading]);
|
|
4531
4533
|
var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === 'initial-input-focus';
|
|
4532
|
-
var ariaGuidance = React
|
|
4534
|
+
var ariaGuidance = React.useMemo(function () {
|
|
4533
4535
|
var guidanceMsg = '';
|
|
4534
4536
|
if (messages.guidance) {
|
|
4535
4537
|
var context = focusedValue ? 'value' : menuIsOpen ? 'menu' : 'input';
|
|
@@ -4545,7 +4547,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4545
4547
|
}
|
|
4546
4548
|
return guidanceMsg;
|
|
4547
4549
|
}, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]);
|
|
4548
|
-
var ScreenReaderText = jsx(React
|
|
4550
|
+
var ScreenReaderText = jsx(React.Fragment, null, jsx("span", {
|
|
4549
4551
|
id: "aria-selection"
|
|
4550
4552
|
}, ariaSelected), jsx("span", {
|
|
4551
4553
|
id: "aria-focused"
|
|
@@ -4554,7 +4556,7 @@ var LiveRegion = function LiveRegion(props) {
|
|
|
4554
4556
|
}, ariaResults), jsx("span", {
|
|
4555
4557
|
id: "aria-guidance"
|
|
4556
4558
|
}, ariaGuidance));
|
|
4557
|
-
return jsx(React
|
|
4559
|
+
return jsx(React.Fragment, null, jsx(A11yText$1, {
|
|
4558
4560
|
id: id
|
|
4559
4561
|
}, isInitialFocus && ScreenReaderText), jsx(A11yText$1, {
|
|
4560
4562
|
"aria-live": ariaLive,
|
|
@@ -4877,7 +4879,7 @@ function DummyInput(_ref) {
|
|
|
4877
4879
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
4878
4880
|
// Remove animation props not meant for HTML elements
|
|
4879
4881
|
var filteredProps = removeProps(props, 'onExited', 'in', 'enter', 'exit', 'appear');
|
|
4880
|
-
return jsx("input", _extends({
|
|
4882
|
+
return jsx("input", _extends$1({
|
|
4881
4883
|
ref: innerRef
|
|
4882
4884
|
}, filteredProps, {
|
|
4883
4885
|
css: /*#__PURE__*/css$2({
|
|
@@ -4914,11 +4916,11 @@ function useScrollCapture(_ref) {
|
|
|
4914
4916
|
onBottomLeave = _ref.onBottomLeave,
|
|
4915
4917
|
onTopArrive = _ref.onTopArrive,
|
|
4916
4918
|
onTopLeave = _ref.onTopLeave;
|
|
4917
|
-
var isBottom = React
|
|
4918
|
-
var isTop = React
|
|
4919
|
-
var touchStart = React
|
|
4920
|
-
var scrollTarget = React
|
|
4921
|
-
var handleEventDelta = React
|
|
4919
|
+
var isBottom = React.useRef(false);
|
|
4920
|
+
var isTop = React.useRef(false);
|
|
4921
|
+
var touchStart = React.useRef(0);
|
|
4922
|
+
var scrollTarget = React.useRef(null);
|
|
4923
|
+
var handleEventDelta = React.useCallback(function (event, delta) {
|
|
4922
4924
|
if (scrollTarget.current === null) return;
|
|
4923
4925
|
var _scrollTarget$current = scrollTarget.current,
|
|
4924
4926
|
scrollTop = _scrollTarget$current.scrollTop,
|
|
@@ -4963,18 +4965,18 @@ function useScrollCapture(_ref) {
|
|
|
4963
4965
|
cancelScroll(event);
|
|
4964
4966
|
}
|
|
4965
4967
|
}, [onBottomArrive, onBottomLeave, onTopArrive, onTopLeave]);
|
|
4966
|
-
var onWheel = React
|
|
4968
|
+
var onWheel = React.useCallback(function (event) {
|
|
4967
4969
|
handleEventDelta(event, event.deltaY);
|
|
4968
4970
|
}, [handleEventDelta]);
|
|
4969
|
-
var onTouchStart = React
|
|
4971
|
+
var onTouchStart = React.useCallback(function (event) {
|
|
4970
4972
|
// set touch start so we can calculate touchmove delta
|
|
4971
4973
|
touchStart.current = event.changedTouches[0].clientY;
|
|
4972
4974
|
}, []);
|
|
4973
|
-
var onTouchMove = React
|
|
4975
|
+
var onTouchMove = React.useCallback(function (event) {
|
|
4974
4976
|
var deltaY = touchStart.current - event.changedTouches[0].clientY;
|
|
4975
4977
|
handleEventDelta(event, deltaY);
|
|
4976
4978
|
}, [handleEventDelta]);
|
|
4977
|
-
var startListening = React
|
|
4979
|
+
var startListening = React.useCallback(function (el) {
|
|
4978
4980
|
// bail early if no element is available to attach to
|
|
4979
4981
|
if (!el) return;
|
|
4980
4982
|
var notPassive = supportsPassiveEvents ? {
|
|
@@ -4984,14 +4986,14 @@ function useScrollCapture(_ref) {
|
|
|
4984
4986
|
el.addEventListener('touchstart', onTouchStart, notPassive);
|
|
4985
4987
|
el.addEventListener('touchmove', onTouchMove, notPassive);
|
|
4986
4988
|
}, [onTouchMove, onTouchStart, onWheel]);
|
|
4987
|
-
var stopListening = React
|
|
4989
|
+
var stopListening = React.useCallback(function (el) {
|
|
4988
4990
|
// bail early if no element is available to detach from
|
|
4989
4991
|
if (!el) return;
|
|
4990
4992
|
el.removeEventListener('wheel', onWheel, false);
|
|
4991
4993
|
el.removeEventListener('touchstart', onTouchStart, false);
|
|
4992
4994
|
el.removeEventListener('touchmove', onTouchMove, false);
|
|
4993
4995
|
}, [onTouchMove, onTouchStart, onWheel]);
|
|
4994
|
-
React
|
|
4996
|
+
React.useEffect(function () {
|
|
4995
4997
|
if (!isEnabled) return;
|
|
4996
4998
|
var element = scrollTarget.current;
|
|
4997
4999
|
startListening(element);
|
|
@@ -5044,9 +5046,9 @@ function useScrollLock(_ref) {
|
|
|
5044
5046
|
var isEnabled = _ref.isEnabled,
|
|
5045
5047
|
_ref$accountForScroll = _ref.accountForScrollbars,
|
|
5046
5048
|
accountForScrollbars = _ref$accountForScroll === void 0 ? true : _ref$accountForScroll;
|
|
5047
|
-
var originalStyles = React
|
|
5048
|
-
var scrollTarget = React
|
|
5049
|
-
var addScrollLock = React
|
|
5049
|
+
var originalStyles = React.useRef({});
|
|
5050
|
+
var scrollTarget = React.useRef(null);
|
|
5051
|
+
var addScrollLock = React.useCallback(function (touchScrollTarget) {
|
|
5050
5052
|
if (!canUseDOM) return;
|
|
5051
5053
|
var target = document.body;
|
|
5052
5054
|
var targetStyle = target && target.style;
|
|
@@ -5089,7 +5091,7 @@ function useScrollLock(_ref) {
|
|
|
5089
5091
|
// increment active scroll locks
|
|
5090
5092
|
activeScrollLocks += 1;
|
|
5091
5093
|
}, [accountForScrollbars]);
|
|
5092
|
-
var removeScrollLock = React
|
|
5094
|
+
var removeScrollLock = React.useCallback(function (touchScrollTarget) {
|
|
5093
5095
|
if (!canUseDOM) return;
|
|
5094
5096
|
var target = document.body;
|
|
5095
5097
|
var targetStyle = target && target.style;
|
|
@@ -5116,7 +5118,7 @@ function useScrollLock(_ref) {
|
|
|
5116
5118
|
}
|
|
5117
5119
|
}
|
|
5118
5120
|
}, [accountForScrollbars]);
|
|
5119
|
-
React
|
|
5121
|
+
React.useEffect(function () {
|
|
5120
5122
|
if (!isEnabled) return;
|
|
5121
5123
|
var element = scrollTarget.current;
|
|
5122
5124
|
addScrollLock(element);
|
|
@@ -5166,7 +5168,7 @@ function ScrollManager(_ref) {
|
|
|
5166
5168
|
setScrollCaptureTarget(element);
|
|
5167
5169
|
setScrollLockTarget(element);
|
|
5168
5170
|
};
|
|
5169
|
-
return jsx(React
|
|
5171
|
+
return jsx(React.Fragment, null, lockEnabled && jsx("div", {
|
|
5170
5172
|
onClick: blurSelectInput,
|
|
5171
5173
|
css: _ref2$1
|
|
5172
5174
|
}), children(targetRef));
|
|
@@ -6459,7 +6461,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6459
6461
|
});
|
|
6460
6462
|
if (!isSearchable) {
|
|
6461
6463
|
// use a dummy input to maintain focus/blur functionality
|
|
6462
|
-
return /*#__PURE__*/React__namespace.createElement(DummyInput, _extends({
|
|
6464
|
+
return /*#__PURE__*/React__namespace.createElement(DummyInput, _extends$1({
|
|
6463
6465
|
id: id,
|
|
6464
6466
|
innerRef: this.getInputRef,
|
|
6465
6467
|
onBlur: this.onInputBlur,
|
|
@@ -6472,7 +6474,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6472
6474
|
value: ""
|
|
6473
6475
|
}, ariaAttributes));
|
|
6474
6476
|
}
|
|
6475
|
-
return /*#__PURE__*/React__namespace.createElement(Input, _extends({}, commonProps, {
|
|
6477
|
+
return /*#__PURE__*/React__namespace.createElement(Input, _extends$1({}, commonProps, {
|
|
6476
6478
|
autoCapitalize: "none",
|
|
6477
6479
|
autoComplete: "off",
|
|
6478
6480
|
autoCorrect: "off",
|
|
@@ -6513,7 +6515,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6513
6515
|
focusedValue = _this$state5.focusedValue,
|
|
6514
6516
|
isFocused = _this$state5.isFocused;
|
|
6515
6517
|
if (!this.hasValue() || !controlShouldRenderValue) {
|
|
6516
|
-
return inputValue ? null : /*#__PURE__*/React__namespace.createElement(Placeholder, _extends({}, commonProps, {
|
|
6518
|
+
return inputValue ? null : /*#__PURE__*/React__namespace.createElement(Placeholder, _extends$1({}, commonProps, {
|
|
6517
6519
|
key: "placeholder",
|
|
6518
6520
|
isDisabled: isDisabled,
|
|
6519
6521
|
isFocused: isFocused,
|
|
@@ -6526,7 +6528,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6526
6528
|
return selectValue.map(function (opt, index) {
|
|
6527
6529
|
var isOptionFocused = opt === focusedValue;
|
|
6528
6530
|
var key = "".concat(_this3.getOptionLabel(opt), "-").concat(_this3.getOptionValue(opt));
|
|
6529
|
-
return /*#__PURE__*/React__namespace.createElement(MultiValue, _extends({}, commonProps, {
|
|
6531
|
+
return /*#__PURE__*/React__namespace.createElement(MultiValue, _extends$1({}, commonProps, {
|
|
6530
6532
|
components: {
|
|
6531
6533
|
Container: MultiValueContainer,
|
|
6532
6534
|
Label: MultiValueLabel,
|
|
@@ -6555,7 +6557,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6555
6557
|
return null;
|
|
6556
6558
|
}
|
|
6557
6559
|
var singleValue = selectValue[0];
|
|
6558
|
-
return /*#__PURE__*/React__namespace.createElement(SingleValue, _extends({}, commonProps, {
|
|
6560
|
+
return /*#__PURE__*/React__namespace.createElement(SingleValue, _extends$1({}, commonProps, {
|
|
6559
6561
|
data: singleValue,
|
|
6560
6562
|
isDisabled: isDisabled
|
|
6561
6563
|
}), this.formatOptionLabel(singleValue, 'value'));
|
|
@@ -6578,7 +6580,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6578
6580
|
onTouchEnd: this.onClearIndicatorTouchEnd,
|
|
6579
6581
|
'aria-hidden': 'true'
|
|
6580
6582
|
};
|
|
6581
|
-
return /*#__PURE__*/React__namespace.createElement(ClearIndicator, _extends({}, commonProps, {
|
|
6583
|
+
return /*#__PURE__*/React__namespace.createElement(ClearIndicator, _extends$1({}, commonProps, {
|
|
6582
6584
|
innerProps: innerProps,
|
|
6583
6585
|
isFocused: isFocused
|
|
6584
6586
|
}));
|
|
@@ -6597,7 +6599,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6597
6599
|
var innerProps = {
|
|
6598
6600
|
'aria-hidden': 'true'
|
|
6599
6601
|
};
|
|
6600
|
-
return /*#__PURE__*/React__namespace.createElement(LoadingIndicator, _extends({}, commonProps, {
|
|
6602
|
+
return /*#__PURE__*/React__namespace.createElement(LoadingIndicator, _extends$1({}, commonProps, {
|
|
6601
6603
|
innerProps: innerProps,
|
|
6602
6604
|
isDisabled: isDisabled,
|
|
6603
6605
|
isFocused: isFocused
|
|
@@ -6615,7 +6617,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6615
6617
|
var commonProps = this.commonProps;
|
|
6616
6618
|
var isDisabled = this.props.isDisabled;
|
|
6617
6619
|
var isFocused = this.state.isFocused;
|
|
6618
|
-
return /*#__PURE__*/React__namespace.createElement(IndicatorSeparator, _extends({}, commonProps, {
|
|
6620
|
+
return /*#__PURE__*/React__namespace.createElement(IndicatorSeparator, _extends$1({}, commonProps, {
|
|
6619
6621
|
isDisabled: isDisabled,
|
|
6620
6622
|
isFocused: isFocused
|
|
6621
6623
|
}));
|
|
@@ -6634,7 +6636,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6634
6636
|
onTouchEnd: this.onDropdownIndicatorTouchEnd,
|
|
6635
6637
|
'aria-hidden': 'true'
|
|
6636
6638
|
};
|
|
6637
|
-
return /*#__PURE__*/React__namespace.createElement(DropdownIndicator, _extends({}, commonProps, {
|
|
6639
|
+
return /*#__PURE__*/React__namespace.createElement(DropdownIndicator, _extends$1({}, commonProps, {
|
|
6638
6640
|
innerProps: innerProps,
|
|
6639
6641
|
isDisabled: isDisabled,
|
|
6640
6642
|
isFocused: isFocused
|
|
@@ -6699,7 +6701,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6699
6701
|
'aria-selected': _this4.state.isAppleDevice ? undefined : isSelected // is not supported on Apple devices
|
|
6700
6702
|
};
|
|
6701
6703
|
|
|
6702
|
-
return /*#__PURE__*/React__namespace.createElement(Option, _extends({}, commonProps, {
|
|
6704
|
+
return /*#__PURE__*/React__namespace.createElement(Option, _extends$1({}, commonProps, {
|
|
6703
6705
|
innerProps: innerProps,
|
|
6704
6706
|
data: data,
|
|
6705
6707
|
isDisabled: isDisabled,
|
|
@@ -6721,7 +6723,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6721
6723
|
groupIndex = item.index;
|
|
6722
6724
|
var groupId = "".concat(_this4.getElementId('group'), "-").concat(groupIndex);
|
|
6723
6725
|
var headingId = "".concat(groupId, "-heading");
|
|
6724
|
-
return /*#__PURE__*/React__namespace.createElement(Group, _extends({}, commonProps, {
|
|
6726
|
+
return /*#__PURE__*/React__namespace.createElement(Group, _extends$1({}, commonProps, {
|
|
6725
6727
|
key: groupId,
|
|
6726
6728
|
data: _data,
|
|
6727
6729
|
options: options,
|
|
@@ -6758,12 +6760,12 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6758
6760
|
menuPosition: menuPosition,
|
|
6759
6761
|
menuShouldScrollIntoView: menuShouldScrollIntoView
|
|
6760
6762
|
};
|
|
6761
|
-
var menuElement = /*#__PURE__*/React__namespace.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), function (_ref4) {
|
|
6763
|
+
var menuElement = /*#__PURE__*/React__namespace.createElement(MenuPlacer, _extends$1({}, commonProps, menuPlacementProps), function (_ref4) {
|
|
6762
6764
|
var ref = _ref4.ref,
|
|
6763
6765
|
_ref4$placerProps = _ref4.placerProps,
|
|
6764
6766
|
placement = _ref4$placerProps.placement,
|
|
6765
6767
|
maxHeight = _ref4$placerProps.maxHeight;
|
|
6766
|
-
return /*#__PURE__*/React__namespace.createElement(Menu, _extends({}, commonProps, menuPlacementProps, {
|
|
6768
|
+
return /*#__PURE__*/React__namespace.createElement(Menu, _extends$1({}, commonProps, menuPlacementProps, {
|
|
6767
6769
|
innerRef: ref,
|
|
6768
6770
|
innerProps: {
|
|
6769
6771
|
onMouseDown: _this4.onMenuMouseDown,
|
|
@@ -6777,7 +6779,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6777
6779
|
onBottomArrive: onMenuScrollToBottom,
|
|
6778
6780
|
lockEnabled: menuShouldBlockScroll
|
|
6779
6781
|
}, function (scrollTargetRef) {
|
|
6780
|
-
return /*#__PURE__*/React__namespace.createElement(MenuList, _extends({}, commonProps, {
|
|
6782
|
+
return /*#__PURE__*/React__namespace.createElement(MenuList, _extends$1({}, commonProps, {
|
|
6781
6783
|
innerRef: function innerRef(instance) {
|
|
6782
6784
|
_this4.getMenuListRef(instance);
|
|
6783
6785
|
scrollTargetRef(instance);
|
|
@@ -6797,7 +6799,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6797
6799
|
// positioning behaviour is almost identical for portalled and fixed,
|
|
6798
6800
|
// so we use the same component. the actual portalling logic is forked
|
|
6799
6801
|
// within the component based on `menuPosition`
|
|
6800
|
-
return menuPortalTarget || menuPosition === 'fixed' ? /*#__PURE__*/React__namespace.createElement(MenuPortal, _extends({}, commonProps, {
|
|
6802
|
+
return menuPortalTarget || menuPosition === 'fixed' ? /*#__PURE__*/React__namespace.createElement(MenuPortal, _extends$1({}, commonProps, {
|
|
6801
6803
|
appendTo: menuPortalTarget,
|
|
6802
6804
|
controlElement: this.controlRef,
|
|
6803
6805
|
menuPlacement: menuPlacement,
|
|
@@ -6867,7 +6869,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6867
6869
|
isFocused = _this$state6.isFocused,
|
|
6868
6870
|
selectValue = _this$state6.selectValue;
|
|
6869
6871
|
var focusableOptions = this.getFocusableOptions();
|
|
6870
|
-
return /*#__PURE__*/React__namespace.createElement(LiveRegion$1, _extends({}, commonProps, {
|
|
6872
|
+
return /*#__PURE__*/React__namespace.createElement(LiveRegion$1, _extends$1({}, commonProps, {
|
|
6871
6873
|
id: this.getElementId('live-region'),
|
|
6872
6874
|
ariaSelection: ariaSelection,
|
|
6873
6875
|
focusedOption: focusedOption,
|
|
@@ -6893,7 +6895,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6893
6895
|
menuIsOpen = _this$props14.menuIsOpen;
|
|
6894
6896
|
var isFocused = this.state.isFocused;
|
|
6895
6897
|
var commonProps = this.commonProps = this.getCommonProps();
|
|
6896
|
-
return /*#__PURE__*/React__namespace.createElement(SelectContainer, _extends({}, commonProps, {
|
|
6898
|
+
return /*#__PURE__*/React__namespace.createElement(SelectContainer, _extends$1({}, commonProps, {
|
|
6897
6899
|
className: className,
|
|
6898
6900
|
innerProps: {
|
|
6899
6901
|
id: id,
|
|
@@ -6901,7 +6903,7 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6901
6903
|
},
|
|
6902
6904
|
isDisabled: isDisabled,
|
|
6903
6905
|
isFocused: isFocused
|
|
6904
|
-
}), this.renderLiveRegion(), /*#__PURE__*/React__namespace.createElement(Control, _extends({}, commonProps, {
|
|
6906
|
+
}), this.renderLiveRegion(), /*#__PURE__*/React__namespace.createElement(Control, _extends$1({}, commonProps, {
|
|
6905
6907
|
innerRef: this.getControlRef,
|
|
6906
6908
|
innerProps: {
|
|
6907
6909
|
onMouseDown: this.onControlMouseDown,
|
|
@@ -6910,9 +6912,9 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6910
6912
|
isDisabled: isDisabled,
|
|
6911
6913
|
isFocused: isFocused,
|
|
6912
6914
|
menuIsOpen: menuIsOpen
|
|
6913
|
-
}), /*#__PURE__*/React__namespace.createElement(ValueContainer, _extends({}, commonProps, {
|
|
6915
|
+
}), /*#__PURE__*/React__namespace.createElement(ValueContainer, _extends$1({}, commonProps, {
|
|
6914
6916
|
isDisabled: isDisabled
|
|
6915
|
-
}), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React__namespace.createElement(IndicatorsContainer, _extends({}, commonProps, {
|
|
6917
|
+
}), this.renderPlaceholderOrValue(), this.renderInput()), /*#__PURE__*/React__namespace.createElement(IndicatorsContainer, _extends$1({}, commonProps, {
|
|
6916
6918
|
isDisabled: isDisabled
|
|
6917
6919
|
}), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField());
|
|
6918
6920
|
}
|
|
@@ -6979,12 +6981,12 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
|
6979
6981
|
}
|
|
6980
6982
|
}]);
|
|
6981
6983
|
return Select;
|
|
6982
|
-
}(React
|
|
6984
|
+
}(React.Component);
|
|
6983
6985
|
Select.defaultProps = defaultProps;
|
|
6984
6986
|
|
|
6985
|
-
var StateManagedSelect = /*#__PURE__*/React
|
|
6987
|
+
var StateManagedSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
6986
6988
|
var baseSelectProps = useStateManager(props);
|
|
6987
|
-
return /*#__PURE__*/React__namespace.createElement(Select, _extends({
|
|
6989
|
+
return /*#__PURE__*/React__namespace.createElement(Select, _extends$1({
|
|
6988
6990
|
ref: ref
|
|
6989
6991
|
}, baseSelectProps));
|
|
6990
6992
|
});
|
|
@@ -6997,25 +6999,103 @@ const MultiSelectDropdown = ({
|
|
|
6997
6999
|
onChange,
|
|
6998
7000
|
theme = "light",
|
|
6999
7001
|
placeholder = "Select...",
|
|
7000
|
-
maxVisible = 1,
|
|
7001
7002
|
required = false,
|
|
7002
|
-
closeMenuOnSelect = false
|
|
7003
|
+
closeMenuOnSelect = false,
|
|
7004
|
+
pushUrlParamObj = false // pushUrlParamObj={"ids"}
|
|
7003
7005
|
}) => {
|
|
7004
|
-
const containerRef = React
|
|
7005
|
-
const
|
|
7006
|
+
const containerRef = React.useRef(null);
|
|
7007
|
+
const [maxVisible, setMaxVisible] = React.useState(1);
|
|
7008
|
+
React.useEffect(() => {
|
|
7009
|
+
if (!containerRef.current) return;
|
|
7010
|
+
const containerWidth = containerRef.current.offsetWidth || 200;
|
|
7011
|
+
// Estimate average tag width (adjust as needed for your style)
|
|
7012
|
+
const avgTagWidth = 90; // px, tweak for your font/size
|
|
7013
|
+
const calculated = Math.max(1, Math.floor((containerWidth - 40) / avgTagWidth));
|
|
7014
|
+
setMaxVisible(calculated);
|
|
7015
|
+
// Optionally, recalculate on window resize:
|
|
7016
|
+
const handleResize = () => {
|
|
7017
|
+
const w = containerRef.current.offsetWidth || 200;
|
|
7018
|
+
setMaxVisible(Math.max(1, Math.floor((w - 40) / avgTagWidth)));
|
|
7019
|
+
};
|
|
7020
|
+
window.addEventListener("resize", handleResize);
|
|
7021
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
7022
|
+
}, []);
|
|
7023
|
+
|
|
7024
|
+
// On mount, read from URL param if present and set values by matching with options
|
|
7025
|
+
React.useEffect(() => {
|
|
7026
|
+
if (!pushUrlParamObj || !options || options.length === 0) return;
|
|
7027
|
+
const readFromUrl = () => {
|
|
7028
|
+
const params = new URLSearchParams(window.location.search);
|
|
7029
|
+
const urlVal = params.get(pushUrlParamObj);
|
|
7030
|
+
if (urlVal) {
|
|
7031
|
+
if (isMulti) {
|
|
7032
|
+
const urlValues = urlVal.split(",").filter(Boolean);
|
|
7033
|
+
const matchedValues = urlValues.map(v => {
|
|
7034
|
+
const found = options.find(opt => String(opt.value) === String(v));
|
|
7035
|
+
return found ? found.value : null;
|
|
7036
|
+
}).filter(v => v !== null);
|
|
7037
|
+
if (matchedValues.length > 0 && JSON.stringify(matchedValues) !== JSON.stringify(selected)) {
|
|
7038
|
+
onChange?.(matchedValues);
|
|
7039
|
+
}
|
|
7040
|
+
} else {
|
|
7041
|
+
const found = options.find(opt => String(opt.value) === String(urlVal));
|
|
7042
|
+
if (found && (!selected || selected[0] !== found.value)) {
|
|
7043
|
+
onChange?.([found.value]);
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
}
|
|
7047
|
+
};
|
|
7048
|
+
readFromUrl();
|
|
7049
|
+
window.addEventListener("popstate", readFromUrl);
|
|
7050
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
7051
|
+
const patchHistory = type => {
|
|
7052
|
+
const orig = window.history[type];
|
|
7053
|
+
window.history[type] = function () {
|
|
7054
|
+
const rv = orig.apply(this, arguments);
|
|
7055
|
+
window.dispatchEvent(new Event(type));
|
|
7056
|
+
return rv;
|
|
7057
|
+
};
|
|
7058
|
+
};
|
|
7059
|
+
patchHistory('pushState');
|
|
7060
|
+
patchHistory('replaceState');
|
|
7061
|
+
window.addEventListener('pushState', readFromUrl);
|
|
7062
|
+
window.addEventListener('replaceState', readFromUrl);
|
|
7063
|
+
return () => {
|
|
7064
|
+
window.removeEventListener("popstate", readFromUrl);
|
|
7065
|
+
window.removeEventListener('pushState', readFromUrl);
|
|
7066
|
+
window.removeEventListener('replaceState', readFromUrl);
|
|
7067
|
+
};
|
|
7068
|
+
}, [pushUrlParamObj, isMulti, options, selected, onChange]);
|
|
7069
|
+
const selectedOptions = React.useMemo(() => {
|
|
7006
7070
|
if (isMulti) {
|
|
7007
7071
|
return options.filter(opt => selected.includes(opt.value));
|
|
7008
7072
|
} else {
|
|
7009
7073
|
return options.find(opt => opt.value === selected[0]) || null;
|
|
7010
7074
|
}
|
|
7011
7075
|
}, [selected, options, isMulti]);
|
|
7076
|
+
const setUrlParam = value => {
|
|
7077
|
+
if (!pushUrlParamObj) return;
|
|
7078
|
+
const url = new URL(window.location);
|
|
7079
|
+
if (!value) {
|
|
7080
|
+
url.searchParams.delete(pushUrlParamObj);
|
|
7081
|
+
} else {
|
|
7082
|
+
url.searchParams.set(pushUrlParamObj, value);
|
|
7083
|
+
}
|
|
7084
|
+
window.history.replaceState({}, "", url);
|
|
7085
|
+
};
|
|
7012
7086
|
const handleChange = selectedItems => {
|
|
7013
7087
|
if (isMulti) {
|
|
7014
7088
|
const values = selectedItems ? selectedItems.map(item => item.value) : [];
|
|
7015
7089
|
onChange(values);
|
|
7090
|
+
if (pushUrlParamObj) {
|
|
7091
|
+
setUrlParam(values.length ? values.join(",") : "");
|
|
7092
|
+
}
|
|
7016
7093
|
} else {
|
|
7017
7094
|
const value = selectedItems ? [selectedItems.value] : [];
|
|
7018
7095
|
onChange(value);
|
|
7096
|
+
if (pushUrlParamObj) {
|
|
7097
|
+
setUrlParam(value.length ? value[0] : "");
|
|
7098
|
+
}
|
|
7019
7099
|
}
|
|
7020
7100
|
};
|
|
7021
7101
|
const MultiValue = props => {
|
|
@@ -7025,9 +7105,13 @@ const MultiSelectDropdown = ({
|
|
|
7025
7105
|
} = props;
|
|
7026
7106
|
const allSelected = getValue();
|
|
7027
7107
|
const hiddenCount = allSelected.length - maxVisible;
|
|
7108
|
+
|
|
7109
|
+
// Only render visible tags
|
|
7028
7110
|
if (index < maxVisible) {
|
|
7029
7111
|
return /*#__PURE__*/React.createElement(components.MultiValue, props);
|
|
7030
7112
|
}
|
|
7113
|
+
|
|
7114
|
+
// Only render +N for the first hidden slot
|
|
7031
7115
|
if (index === maxVisible && hiddenCount > 0) {
|
|
7032
7116
|
const hiddenLabels = allSelected.slice(maxVisible).map(opt => opt.label).join(", ");
|
|
7033
7117
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -7037,13 +7121,17 @@ const MultiSelectDropdown = ({
|
|
|
7037
7121
|
backgroundColor: theme === "dark" ? "#333" : "#e0e0e0",
|
|
7038
7122
|
color: theme === "dark" ? "#eee" : "#333",
|
|
7039
7123
|
borderRadius: 4,
|
|
7040
|
-
padding: "
|
|
7041
|
-
fontSize: "0.
|
|
7042
|
-
|
|
7124
|
+
padding: "2px 8px",
|
|
7125
|
+
fontSize: "0.85em",
|
|
7126
|
+
display: "inline-flex",
|
|
7127
|
+
alignItems: "center",
|
|
7128
|
+
marginLeft: 4,
|
|
7043
7129
|
cursor: "default"
|
|
7044
7130
|
}
|
|
7045
7131
|
}, "+", hiddenCount);
|
|
7046
7132
|
}
|
|
7133
|
+
|
|
7134
|
+
// Don't render anything for other hidden tags
|
|
7047
7135
|
return null;
|
|
7048
7136
|
};
|
|
7049
7137
|
const selectStyle = {
|
|
@@ -7105,6 +7193,11 @@ const MultiSelectDropdown = ({
|
|
|
7105
7193
|
menuPortal: base => ({
|
|
7106
7194
|
...base,
|
|
7107
7195
|
zIndex: 999999
|
|
7196
|
+
}),
|
|
7197
|
+
valueContainer: base => ({
|
|
7198
|
+
...base,
|
|
7199
|
+
flexWrap: "nowrap",
|
|
7200
|
+
overflow: "hidden"
|
|
7108
7201
|
})
|
|
7109
7202
|
};
|
|
7110
7203
|
const showRequiredError = required && (!selected || selected.length === 0);
|
|
@@ -7126,407 +7219,2890 @@ const MultiSelectDropdown = ({
|
|
|
7126
7219
|
},
|
|
7127
7220
|
menuPortalTarget: document.body,
|
|
7128
7221
|
closeMenuOnSelect: closeMenuOnSelect,
|
|
7129
|
-
"aria-required": required
|
|
7222
|
+
"aria-required": required
|
|
7130
7223
|
}), showRequiredError && /*#__PURE__*/React.createElement("div", {
|
|
7131
7224
|
className: "error-text"
|
|
7132
7225
|
}, "This field is required."));
|
|
7133
7226
|
};
|
|
7134
7227
|
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7228
|
+
// import "src/style/DebounceSelect.css";
|
|
7229
|
+
|
|
7230
|
+
const DebounceSelect = ({
|
|
7231
|
+
label,
|
|
7232
|
+
fetchOptions,
|
|
7233
|
+
onSelect,
|
|
7234
|
+
placeholder = "Type to search...",
|
|
7235
|
+
debounceDelay = 300,
|
|
7236
|
+
required = false,
|
|
7237
|
+
disabled = false,
|
|
7238
|
+
objValue,
|
|
7239
|
+
style,
|
|
7240
|
+
isMulti = false,
|
|
7241
|
+
pushUrlParamObj = false
|
|
7147
7242
|
}) => {
|
|
7148
|
-
React
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7243
|
+
const [input, setInput] = React.useState("");
|
|
7244
|
+
const [options, setOptions] = React.useState([]);
|
|
7245
|
+
const [loading, setLoading] = React.useState(false);
|
|
7246
|
+
const [open, setOpen] = React.useState(false);
|
|
7247
|
+
const [selectedItems, setSelectedItems] = React.useState(isMulti ? objValue ?? [] : objValue ? [objValue] : []);
|
|
7248
|
+
|
|
7249
|
+
// Auto-update selectedItems when URL param changes
|
|
7250
|
+
// useEffect(() => {
|
|
7251
|
+
// if (!pushUrlParamObj) return;
|
|
7252
|
+
// const syncFromUrl = () => {
|
|
7253
|
+
// const params = new URLSearchParams(window.location.search);
|
|
7254
|
+
// const urlVal = params.get(pushUrlParamObj);
|
|
7255
|
+
// if (urlVal) {
|
|
7256
|
+
// if (isMulti) {
|
|
7257
|
+
// const urlValues = urlVal.split(",").filter(Boolean);
|
|
7258
|
+
// // Only update if different
|
|
7259
|
+
// if (JSON.stringify(urlValues) !== JSON.stringify(selectedItems.map(i => i.value))) {
|
|
7260
|
+
// // We don't have labels, so just update values
|
|
7261
|
+
// setSelectedItems(urlValues.map(v => ({ value: v, label: v })));
|
|
7262
|
+
// onSelect?.(urlValues.map(v => ({ value: v, label: v })));
|
|
7263
|
+
// }
|
|
7264
|
+
// } else {
|
|
7265
|
+
// if (!selectedItems[0] || selectedItems[0].value !== urlVal) {
|
|
7266
|
+
// setSelectedItems([{ value: urlVal, label: urlVal }]);
|
|
7267
|
+
// onSelect?.({ value: urlVal, label: urlVal });
|
|
7268
|
+
// }
|
|
7269
|
+
// }
|
|
7270
|
+
// } else {
|
|
7271
|
+
// if (selectedItems.length > 0) {
|
|
7272
|
+
// setSelectedItems([]);
|
|
7273
|
+
// onSelect?.(isMulti ? [] : null);
|
|
7274
|
+
// }
|
|
7275
|
+
// }
|
|
7276
|
+
// };
|
|
7277
|
+
// syncFromUrl();
|
|
7278
|
+
// window.addEventListener("popstate", syncFromUrl);
|
|
7279
|
+
// // Listen for pushState/replaceState (programmatic changes)
|
|
7280
|
+
// const patchHistory = (type) => {
|
|
7281
|
+
// const orig = window.history[type];
|
|
7282
|
+
// window.history[type] = function() {
|
|
7283
|
+
// const rv = orig.apply(this, arguments);
|
|
7284
|
+
// window.dispatchEvent(new Event(type));
|
|
7285
|
+
// return rv;
|
|
7286
|
+
// };
|
|
7287
|
+
// };
|
|
7288
|
+
// patchHistory('pushState');
|
|
7289
|
+
// patchHistory('replaceState');
|
|
7290
|
+
// window.addEventListener('pushState', syncFromUrl);
|
|
7291
|
+
// window.addEventListener('replaceState', syncFromUrl);
|
|
7292
|
+
// return () => {
|
|
7293
|
+
// window.removeEventListener("popstate", syncFromUrl);
|
|
7294
|
+
// window.removeEventListener('pushState', syncFromUrl);
|
|
7295
|
+
// window.removeEventListener('replaceState', syncFromUrl);
|
|
7296
|
+
// };
|
|
7297
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7298
|
+
// }, [pushUrlParamObj, isMulti, selectedItems, onSelect]);
|
|
7299
|
+
|
|
7300
|
+
const timeoutRef = React.useRef(null);
|
|
7301
|
+
React.useEffect(() => {
|
|
7302
|
+
if (!input) {
|
|
7303
|
+
setOptions([]);
|
|
7304
|
+
return;
|
|
7305
|
+
}
|
|
7306
|
+
setLoading(true);
|
|
7307
|
+
clearTimeout(timeoutRef.current);
|
|
7308
|
+
timeoutRef.current = setTimeout(async () => {
|
|
7309
|
+
try {
|
|
7310
|
+
// If input is '...', fetch all options
|
|
7311
|
+
const query = input === "..." ? "" : input;
|
|
7312
|
+
const results = await fetchOptions(query);
|
|
7313
|
+
setOptions(results);
|
|
7314
|
+
} catch (err) {
|
|
7315
|
+
console.error("Failed to fetch options", err);
|
|
7316
|
+
setOptions([]);
|
|
7317
|
+
} finally {
|
|
7318
|
+
setLoading(false);
|
|
7152
7319
|
}
|
|
7153
|
-
};
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
}
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7320
|
+
}, debounceDelay);
|
|
7321
|
+
return () => clearTimeout(timeoutRef.current);
|
|
7322
|
+
}, [input, fetchOptions, debounceDelay]);
|
|
7323
|
+
const setUrlParam = value => {
|
|
7324
|
+
const url = new URL(window.location);
|
|
7325
|
+
if (value === null || value === undefined || value === "") {
|
|
7326
|
+
url.searchParams.delete(pushUrlParamObj);
|
|
7327
|
+
} else {
|
|
7328
|
+
url.searchParams.set(pushUrlParamObj, value);
|
|
7329
|
+
}
|
|
7330
|
+
window.history.replaceState({}, "", url);
|
|
7331
|
+
};
|
|
7332
|
+
const handleSelect = (value, labelValue) => {
|
|
7333
|
+
if (isMulti) {
|
|
7334
|
+
const newItem = {
|
|
7335
|
+
value,
|
|
7336
|
+
label: labelValue
|
|
7337
|
+
};
|
|
7338
|
+
const updated = selectedItems.some(item => item.value === value) ? selectedItems : [...selectedItems, newItem];
|
|
7339
|
+
setSelectedItems(updated);
|
|
7340
|
+
onSelect(updated);
|
|
7341
|
+
setInput("");
|
|
7342
|
+
if (pushUrlParamObj) {
|
|
7343
|
+
setUrlParam(updated.map(item => item.value).join(","));
|
|
7344
|
+
}
|
|
7345
|
+
} else {
|
|
7346
|
+
const single = {
|
|
7347
|
+
value,
|
|
7348
|
+
label: labelValue
|
|
7349
|
+
};
|
|
7350
|
+
setSelectedItems([single]);
|
|
7351
|
+
onSelect(single);
|
|
7352
|
+
setInput(labelValue);
|
|
7353
|
+
if (pushUrlParamObj) {
|
|
7354
|
+
setUrlParam(value);
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
setOpen(false);
|
|
7358
|
+
};
|
|
7359
|
+
const removeItem = value => {
|
|
7360
|
+
const updated = selectedItems.filter(item => item.value !== value);
|
|
7361
|
+
setSelectedItems(updated);
|
|
7362
|
+
onSelect(updated);
|
|
7363
|
+
if (pushUrlParamObj) {
|
|
7364
|
+
setUrlParam(updated.length ? updated.map(item => item.value).join(",") : "");
|
|
7365
|
+
}
|
|
7366
|
+
};
|
|
7367
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
7368
|
+
style: {
|
|
7369
|
+
position: 'relative'
|
|
7370
|
+
}
|
|
7371
|
+
}, label && /*#__PURE__*/React.createElement("label", null, label, required && ' *'), isMulti && /*#__PURE__*/React.createElement("div", {
|
|
7372
|
+
className: "multi-selected-tags"
|
|
7373
|
+
}, selectedItems.map(({
|
|
7374
|
+
label,
|
|
7375
|
+
value
|
|
7376
|
+
}) => /*#__PURE__*/React.createElement("span", {
|
|
7377
|
+
key: value,
|
|
7378
|
+
className: "tag"
|
|
7379
|
+
}, label, /*#__PURE__*/React.createElement("button", {
|
|
7380
|
+
type: "button",
|
|
7381
|
+
onClick: () => removeItem(value)
|
|
7382
|
+
}, "\xD7")))), /*#__PURE__*/React.createElement("div", {
|
|
7383
|
+
style: {
|
|
7384
|
+
position: 'relative',
|
|
7385
|
+
display: 'flex',
|
|
7386
|
+
alignItems: 'center'
|
|
7387
|
+
}
|
|
7388
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
7389
|
+
className: "basic-input",
|
|
7390
|
+
type: "text",
|
|
7391
|
+
value: isMulti ? input : open ? input : selectedItems.length > 0 ? selectedItems[0].label : input,
|
|
7392
|
+
onChange: e => {
|
|
7393
|
+
setInput(e.target.value);
|
|
7394
|
+
setOpen(true);
|
|
7395
|
+
},
|
|
7396
|
+
placeholder: placeholder,
|
|
7397
|
+
onFocus: () => setOpen(true),
|
|
7398
|
+
onBlur: () => setTimeout(() => setOpen(false), 200),
|
|
7399
|
+
disabled: disabled,
|
|
7400
|
+
style: style
|
|
7401
|
+
}), (input || !isMulti && selectedItems.length > 0) && !disabled && /*#__PURE__*/React.createElement("button", {
|
|
7402
|
+
type: "button",
|
|
7403
|
+
"aria-label": "Clear",
|
|
7404
|
+
style: {
|
|
7405
|
+
position: 'absolute',
|
|
7406
|
+
right: 6,
|
|
7407
|
+
background: 'none',
|
|
7408
|
+
border: 'none',
|
|
7409
|
+
cursor: 'pointer',
|
|
7410
|
+
fontSize: '1.2em',
|
|
7411
|
+
color: '#888',
|
|
7412
|
+
padding: 0,
|
|
7413
|
+
lineHeight: 1
|
|
7414
|
+
},
|
|
7415
|
+
onMouseDown: e => {
|
|
7416
|
+
e.preventDefault();
|
|
7417
|
+
setInput("");
|
|
7418
|
+
if (isMulti) ; else {
|
|
7419
|
+
setSelectedItems([]);
|
|
7420
|
+
onSelect(null);
|
|
7421
|
+
if (pushUrlParamObj) setUrlParam("");
|
|
7422
|
+
}
|
|
7423
|
+
},
|
|
7424
|
+
tabIndex: -1
|
|
7425
|
+
}, "\xD7")), open && /*#__PURE__*/React.createElement("div", {
|
|
7426
|
+
className: "basic-input-dropdown-menu"
|
|
7427
|
+
}, loading ? /*#__PURE__*/React.createElement("div", {
|
|
7428
|
+
className: "loading-dropdown-item"
|
|
7429
|
+
}, "Loading...") : options?.length > 0 ? options.map(({
|
|
7430
|
+
label,
|
|
7431
|
+
value
|
|
7432
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
7433
|
+
key: value,
|
|
7434
|
+
className: "basic-input-dropdown-item",
|
|
7435
|
+
onMouseDown: () => handleSelect(value, label)
|
|
7436
|
+
}, label)) : /*#__PURE__*/React.createElement("div", {
|
|
7437
|
+
className: "no-results-dropdown-item"
|
|
7438
|
+
}, "No results")));
|
|
7177
7439
|
};
|
|
7178
7440
|
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
const _translations = {
|
|
7196
|
-
showFilters: 'showFilters',
|
|
7197
|
-
hideFilters: 'hideFilters',
|
|
7198
|
-
resetSorting: 'resetSorting',
|
|
7199
|
-
resetSearching: 'resetSearching',
|
|
7200
|
-
role: 'role',
|
|
7201
|
-
confirmTitle: 'confirmTitle',
|
|
7202
|
-
confirm: 'confirm',
|
|
7203
|
-
cancel: 'cancel',
|
|
7204
|
-
confirmUnknown: 'confirmUnknown'
|
|
7205
|
-
};
|
|
7441
|
+
function _extends() {
|
|
7442
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
7443
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
7444
|
+
var t = arguments[e];
|
|
7445
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
7446
|
+
}
|
|
7447
|
+
return n;
|
|
7448
|
+
}, _extends.apply(null, arguments);
|
|
7449
|
+
}
|
|
7450
|
+
|
|
7451
|
+
function SearchInput({
|
|
7452
|
+
pushUrlParamObj = null,
|
|
7453
|
+
...props
|
|
7454
|
+
}) {
|
|
7455
|
+
const key = pushUrlParamObj || "search";
|
|
7456
|
+
const [value, setValue] = React.useState("");
|
|
7206
7457
|
|
|
7207
|
-
//
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7458
|
+
// On mount, read the URL param and set value
|
|
7459
|
+
React.useEffect(() => {
|
|
7460
|
+
const params = new URLSearchParams(window.location.search);
|
|
7461
|
+
const urlValue = params.get(key) || "";
|
|
7462
|
+
setValue(urlValue);
|
|
7463
|
+
|
|
7464
|
+
// Listen for popstate (browser navigation)
|
|
7465
|
+
const onPopState = () => {
|
|
7466
|
+
const params = new URLSearchParams(window.location.search);
|
|
7467
|
+
setValue(params.get(key) || "");
|
|
7468
|
+
};
|
|
7469
|
+
window.addEventListener("popstate", onPopState);
|
|
7470
|
+
return () => window.removeEventListener("popstate", onPopState);
|
|
7471
|
+
}, [key]);
|
|
7472
|
+
const setUrlParam = val => {
|
|
7473
|
+
const params = new URLSearchParams(window.location.search);
|
|
7474
|
+
if (val && val.length > 0) {
|
|
7475
|
+
params.set(key, val);
|
|
7476
|
+
} else {
|
|
7477
|
+
params.delete(key);
|
|
7478
|
+
}
|
|
7479
|
+
const newUrl = window.location.pathname + (params.toString() ? "?" + params.toString() : "");
|
|
7480
|
+
window.history.replaceState({}, "", newUrl);
|
|
7212
7481
|
};
|
|
7213
|
-
const
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
}
|
|
7218
|
-
const
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7482
|
+
const handleChange = e => {
|
|
7483
|
+
const newValue = e.target.value;
|
|
7484
|
+
setValue(newValue);
|
|
7485
|
+
setUrlParam(newValue);
|
|
7486
|
+
};
|
|
7487
|
+
const handleClear = () => {
|
|
7488
|
+
setValue("");
|
|
7489
|
+
setUrlParam("");
|
|
7490
|
+
};
|
|
7491
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
7492
|
+
title: "tooltip",
|
|
7493
|
+
style: {
|
|
7494
|
+
position: "relative",
|
|
7495
|
+
display: "inline-block",
|
|
7496
|
+
height: "34px",
|
|
7497
|
+
verticalAlign: "middle"
|
|
7498
|
+
}
|
|
7499
|
+
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
7500
|
+
className: "basic-input",
|
|
7501
|
+
value: value,
|
|
7502
|
+
style: {
|
|
7503
|
+
marginBottom: "10px",
|
|
7504
|
+
padding: "5px",
|
|
7505
|
+
width: "200px",
|
|
7506
|
+
paddingRight: value ? "24px" : undefined,
|
|
7507
|
+
height: "100%",
|
|
7508
|
+
boxSizing: "border-box"
|
|
7509
|
+
},
|
|
7510
|
+
onChange: handleChange
|
|
7511
|
+
}, props)), value && /*#__PURE__*/React.createElement("span", {
|
|
7512
|
+
onClick: handleClear,
|
|
7513
|
+
title: "Clear search",
|
|
7514
|
+
style: {
|
|
7515
|
+
position: "absolute",
|
|
7516
|
+
right: "10px",
|
|
7517
|
+
top: "50%",
|
|
7518
|
+
transform: "translateY(-50%)",
|
|
7519
|
+
cursor: "pointer",
|
|
7520
|
+
fontSize: "14px",
|
|
7521
|
+
color: "#000000ff",
|
|
7522
|
+
lineHeight: "1"
|
|
7523
|
+
}
|
|
7524
|
+
}, "\u2716"));
|
|
7525
|
+
}
|
|
7526
|
+
|
|
7527
|
+
/*
|
|
7528
|
+
Reusable IconInput component
|
|
7529
|
+
Props:
|
|
7530
|
+
icon: ReactNode or string to render
|
|
7531
|
+
title: tooltip text
|
|
7532
|
+
ariaLabel: accessible label (falls back to title or stringified icon)
|
|
7533
|
+
onClick: callback fired after internal URL logic (receives event & active state)
|
|
7534
|
+
size: number (px) for square hit area
|
|
7535
|
+
disabled: boolean
|
|
7536
|
+
className, style: customization
|
|
7537
|
+
pushUrlParamObj: string | false -> if provided, component will write to that URL param
|
|
7538
|
+
pushValue: value written to param when activated (default '1')
|
|
7539
|
+
toggle: boolean -> if true acts like a toggle, else just sets param
|
|
7540
|
+
multiUrlList: boolean -> if true treats param as comma-separated list; clicking toggles pushValue in list
|
|
7541
|
+
activeColor: color when active
|
|
7542
|
+
inactiveColor: color when inactive
|
|
7543
|
+
*/
|
|
7227
7544
|
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7545
|
+
function IconInput({
|
|
7546
|
+
icon,
|
|
7547
|
+
title,
|
|
7548
|
+
ariaLabel,
|
|
7549
|
+
onClick,
|
|
7550
|
+
size = 32,
|
|
7551
|
+
disabled = false,
|
|
7552
|
+
className = "",
|
|
7553
|
+
style = {},
|
|
7554
|
+
pushUrlParamObj = false,
|
|
7555
|
+
pushValue = "1",
|
|
7556
|
+
toggle = true,
|
|
7557
|
+
multiUrlList = false,
|
|
7558
|
+
activeColor = "#1d4ed8",
|
|
7559
|
+
inactiveColor = "#555",
|
|
7560
|
+
onAction = null
|
|
7561
|
+
}) {
|
|
7562
|
+
const paramKey = pushUrlParamObj || null;
|
|
7563
|
+
const [active, setActive] = React.useState(() => {
|
|
7564
|
+
if (!paramKey) return false;
|
|
7565
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
7566
|
+
const raw = params.get(paramKey);
|
|
7567
|
+
if (!raw) return false;
|
|
7568
|
+
if (multiUrlList) {
|
|
7569
|
+
const arr = raw.split(',').filter(Boolean);
|
|
7570
|
+
return arr.includes(String(pushValue));
|
|
7571
|
+
}
|
|
7572
|
+
return raw === String(pushValue);
|
|
7573
|
+
});
|
|
7231
7574
|
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7575
|
+
// Auto-update active state when URL param changes
|
|
7576
|
+
React.useEffect(() => {
|
|
7577
|
+
if (!paramKey) return;
|
|
7578
|
+
const syncFromUrl = () => {
|
|
7579
|
+
const params = new URLSearchParams(window.location.search);
|
|
7580
|
+
const raw = params.get(paramKey);
|
|
7581
|
+
let nextActive = false;
|
|
7582
|
+
if (raw) {
|
|
7583
|
+
if (multiUrlList) {
|
|
7584
|
+
const arr = raw.split(',').filter(Boolean);
|
|
7585
|
+
nextActive = arr.includes(String(pushValue));
|
|
7586
|
+
} else {
|
|
7587
|
+
nextActive = raw === String(pushValue);
|
|
7588
|
+
}
|
|
7236
7589
|
}
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
const
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7590
|
+
setActive(nextActive);
|
|
7591
|
+
};
|
|
7592
|
+
syncFromUrl();
|
|
7593
|
+
window.addEventListener("popstate", syncFromUrl);
|
|
7594
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
7595
|
+
const patchHistory = type => {
|
|
7596
|
+
const orig = window.history[type];
|
|
7597
|
+
window.history[type] = function () {
|
|
7598
|
+
const rv = orig.apply(this, arguments);
|
|
7599
|
+
window.dispatchEvent(new Event(type));
|
|
7600
|
+
return rv;
|
|
7601
|
+
};
|
|
7602
|
+
};
|
|
7603
|
+
patchHistory('pushState');
|
|
7604
|
+
patchHistory('replaceState');
|
|
7605
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
7606
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
7607
|
+
return () => {
|
|
7608
|
+
window.removeEventListener("popstate", syncFromUrl);
|
|
7609
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
7610
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
7611
|
+
};
|
|
7612
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7613
|
+
}, [paramKey, multiUrlList, pushValue]);
|
|
7614
|
+
|
|
7615
|
+
// (Removed effect-based initialization; using lazy useState instead to satisfy lint rule.)
|
|
7616
|
+
|
|
7617
|
+
const updateUrl = React.useCallback(nextActive => {
|
|
7618
|
+
if (!paramKey) return;
|
|
7619
|
+
const params = new URLSearchParams(window.location.search);
|
|
7620
|
+
const current = params.get(paramKey);
|
|
7621
|
+
if (multiUrlList) {
|
|
7622
|
+
let list = current ? current.split(",").filter(Boolean) : [];
|
|
7623
|
+
const idx = list.indexOf(String(pushValue));
|
|
7624
|
+
if (nextActive) {
|
|
7625
|
+
if (idx === -1) list.push(String(pushValue));
|
|
7248
7626
|
} else {
|
|
7249
|
-
|
|
7250
|
-
}
|
|
7251
|
-
});
|
|
7252
|
-
Object.entries(initial).forEach(([key, value]) => {
|
|
7253
|
-
onChange?.(key, value);
|
|
7254
|
-
});
|
|
7255
|
-
}, []);
|
|
7256
|
-
React$1.useEffect(() => {
|
|
7257
|
-
const savedFilters = localStorage.getItem('adminFilters');
|
|
7258
|
-
if (savedFilters) {
|
|
7259
|
-
const parsed = JSON.parse(savedFilters);
|
|
7260
|
-
Object.entries(parsed).forEach(([key, value]) => {
|
|
7261
|
-
onChange?.(key, value);
|
|
7262
|
-
});
|
|
7263
|
-
}
|
|
7264
|
-
}, []);
|
|
7265
|
-
React$1.useEffect(() => {
|
|
7266
|
-
const currentValues = {};
|
|
7267
|
-
config.forEach(item => {
|
|
7268
|
-
if (item.type !== 'button' && item.type !== 'icon') {
|
|
7269
|
-
currentValues[item.key] = item.value;
|
|
7627
|
+
if (idx !== -1) list.splice(idx, 1);
|
|
7270
7628
|
}
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
setModalState({
|
|
7276
|
-
isOpen: true,
|
|
7277
|
-
label,
|
|
7278
|
-
key,
|
|
7279
|
-
onConfirm: () => {
|
|
7280
|
-
actionFn(key);
|
|
7281
|
-
setModalState({
|
|
7282
|
-
isOpen: false,
|
|
7283
|
-
label: '',
|
|
7284
|
-
key: '',
|
|
7285
|
-
onConfirm: null
|
|
7286
|
-
});
|
|
7629
|
+
if (list.length === 0) {
|
|
7630
|
+
params.delete(paramKey);
|
|
7631
|
+
} else {
|
|
7632
|
+
params.set(paramKey, list.join(","));
|
|
7287
7633
|
}
|
|
7288
|
-
}
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
setModalState({
|
|
7292
|
-
isOpen: false,
|
|
7293
|
-
label: '',
|
|
7294
|
-
key: '',
|
|
7295
|
-
onConfirm: null
|
|
7296
|
-
});
|
|
7297
|
-
};
|
|
7298
|
-
const sortingLocalStorage = localStorage.getItem("tableSort");
|
|
7299
|
-
|
|
7300
|
-
// When urSearchParams is enabled, keep the URL search param `search`
|
|
7301
|
-
// in sync with the extraSearchTerm prop without reloading the page.
|
|
7302
|
-
// When urSearchParams is enabled, keep the URL search param `search`
|
|
7303
|
-
// in sync with the extraSearchTerm prop without reloading the page.
|
|
7304
|
-
React$1.useEffect(() => {
|
|
7305
|
-
if (!urSearchParams) return;
|
|
7306
|
-
try {
|
|
7307
|
-
const url = new URL(window.location.href);
|
|
7308
|
-
if (extraSearchTerm && String(extraSearchTerm).length > 0) {
|
|
7309
|
-
url.searchParams.set('search', String(extraSearchTerm));
|
|
7634
|
+
} else {
|
|
7635
|
+
if (nextActive) {
|
|
7636
|
+
params.set(paramKey, String(pushValue));
|
|
7310
7637
|
} else {
|
|
7311
|
-
|
|
7638
|
+
if (toggle) {
|
|
7639
|
+
params.delete(paramKey);
|
|
7640
|
+
} else {
|
|
7641
|
+
// If not toggle, leave value as-is (or could clear)
|
|
7642
|
+
params.delete(paramKey);
|
|
7643
|
+
}
|
|
7312
7644
|
}
|
|
7313
|
-
window.history.replaceState({}, '', url.toString());
|
|
7314
|
-
} catch (e) {
|
|
7315
|
-
// fallback: do nothing if URL constructor fails (very unlikely in browsers)
|
|
7316
7645
|
}
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
if (
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
});
|
|
7328
|
-
}, [extraSearchTerm, urSearchParams]);
|
|
7329
|
-
return /*#__PURE__*/React$1.createElement(React$1.Fragment, null, /*#__PURE__*/React$1.createElement("div", {
|
|
7330
|
-
className: "filters-wrapper"
|
|
7331
|
-
}, /*#__PURE__*/React$1.createElement("div", {
|
|
7332
|
-
className: "filters-header"
|
|
7333
|
-
}, /*#__PURE__*/React$1.createElement("div", {
|
|
7334
|
-
className: "filters-title"
|
|
7335
|
-
}, title), /*#__PURE__*/React$1.createElement("button", {
|
|
7336
|
-
className: "basic-button",
|
|
7337
|
-
onClick: () => setCollapsed(prev => !prev)
|
|
7338
|
-
}, collapsed ? ' ' + t("showFilters") : ' ' + t("hideFilters")), sortingLocalStorage && /*#__PURE__*/React$1.createElement("button", {
|
|
7339
|
-
className: "basic-button confirm",
|
|
7340
|
-
onClick: () => {
|
|
7341
|
-
setSorting(false);
|
|
7342
|
-
context("resetSortingTrigger", true);
|
|
7343
|
-
localStorage.removeItem("tableSort");
|
|
7344
|
-
window.dispatchEvent(new Event("storageUpdated"));
|
|
7345
|
-
}
|
|
7346
|
-
}, t("resetSorting") + " " + (sorting || "")), !hideResetSearchButton && /*#__PURE__*/React$1.createElement("button", {
|
|
7347
|
-
className: "basic-button",
|
|
7348
|
-
onClick: handleReset
|
|
7349
|
-
}, t("resetSearching"))), !collapsed && /*#__PURE__*/React$1.createElement("div", {
|
|
7350
|
-
className: "filters-container"
|
|
7351
|
-
}, config.map((item, index) => {
|
|
7352
|
-
const tooltip = item.tooltip || '';
|
|
7353
|
-
const roleAllowed = !item.role || userRole.some(r => item.role.includes(r));
|
|
7354
|
-
if (!roleAllowed) return null;
|
|
7355
|
-
switch (item.type) {
|
|
7356
|
-
case 'group':
|
|
7357
|
-
return /*#__PURE__*/React$1.createElement("div", {
|
|
7358
|
-
key: index,
|
|
7359
|
-
className: "button-group",
|
|
7360
|
-
title: item.label
|
|
7361
|
-
}, item.buttons.map((btn, i) => {
|
|
7362
|
-
const actionFn = btn.onAction || onAction;
|
|
7363
|
-
if (!actionFn) return null;
|
|
7364
|
-
const handleClick = () => {
|
|
7365
|
-
if (btn.confirm) {
|
|
7366
|
-
openConfirmModal(btn.label, btn.key, actionFn);
|
|
7367
|
-
} else {
|
|
7368
|
-
actionFn(btn.key);
|
|
7369
|
-
}
|
|
7370
|
-
};
|
|
7371
|
-
return /*#__PURE__*/React$1.createElement("button", {
|
|
7372
|
-
className: "basic-button",
|
|
7373
|
-
key: i,
|
|
7374
|
-
onClick: handleClick,
|
|
7375
|
-
title: btn.tooltip || btn.label
|
|
7376
|
-
}, t(btn.label));
|
|
7377
|
-
}));
|
|
7378
|
-
case 'input':
|
|
7379
|
-
return /*#__PURE__*/React$1.createElement("div", {
|
|
7380
|
-
key: index,
|
|
7381
|
-
className: "filter-input-wrapper",
|
|
7382
|
-
title: tooltip
|
|
7383
|
-
}, /*#__PURE__*/React$1.createElement("input", {
|
|
7384
|
-
className: "basic-input",
|
|
7385
|
-
type: "search",
|
|
7386
|
-
placeholder: item.placeholder || '',
|
|
7387
|
-
value: item.value || '',
|
|
7388
|
-
onChange: e => {
|
|
7389
|
-
// If input search is used, clear all multiselects
|
|
7390
|
-
if (urSearchParams && e.target.value) {
|
|
7391
|
-
config.forEach(f => {
|
|
7392
|
-
if (f.type === 'multiselect' && f.value && f.value.length > 0) {
|
|
7393
|
-
onChange?.(f.key, f.isMulti ? [] : '');
|
|
7394
|
-
}
|
|
7395
|
-
});
|
|
7396
|
-
}
|
|
7397
|
-
onChange?.(item.key, e.target.value);
|
|
7398
|
-
}
|
|
7399
|
-
}));
|
|
7400
|
-
case 'select':
|
|
7401
|
-
return /*#__PURE__*/React$1.createElement("select", {
|
|
7402
|
-
key: index,
|
|
7403
|
-
value: item.value || '',
|
|
7404
|
-
onChange: e => onChange?.(item.key, e.target.value),
|
|
7405
|
-
className: "filter-select",
|
|
7406
|
-
title: tooltip
|
|
7407
|
-
}, item.options?.map((opt, i) => /*#__PURE__*/React$1.createElement("option", {
|
|
7408
|
-
key: i,
|
|
7409
|
-
value: opt.value
|
|
7410
|
-
}, opt.label)));
|
|
7411
|
-
case 'multiselect':
|
|
7412
|
-
return /*#__PURE__*/React$1.createElement("div", {
|
|
7413
|
-
key: index,
|
|
7414
|
-
className: "filter-multiselect",
|
|
7415
|
-
title: tooltip
|
|
7416
|
-
}, /*#__PURE__*/React$1.createElement(MultiSelectDropdown, {
|
|
7417
|
-
label: item.label || t("role"),
|
|
7418
|
-
selected: Array.isArray(item.value) ? item.value : item.value ? [item.value] : [],
|
|
7419
|
-
onChange: newValues => {
|
|
7420
|
-
// If multiselect is used, clear all input search fields
|
|
7421
|
-
if (urSearchParams && newValues && newValues.length > 0) {
|
|
7422
|
-
config.forEach(f => {
|
|
7423
|
-
if (f.type === 'input' && f.value && f.value.length > 0) {
|
|
7424
|
-
onChange?.(f.key, '');
|
|
7425
|
-
}
|
|
7426
|
-
});
|
|
7427
|
-
}
|
|
7428
|
-
onChange?.(item.key, item.isMulti ? newValues : newValues[0] || "");
|
|
7429
|
-
if (urSearchParams) {
|
|
7430
|
-
try {
|
|
7431
|
-
const url = new URL(window.location.href);
|
|
7432
|
-
// Combine all selected values from all MultiSelectDropdowns
|
|
7433
|
-
let allSelected = [];
|
|
7434
|
-
config.forEach(f => {
|
|
7435
|
-
if (f.type === 'multiselect') {
|
|
7436
|
-
// Skip the current item being changed, we'll use newValues for it
|
|
7437
|
-
if (f.key === item.key) {
|
|
7438
|
-
if (Array.isArray(newValues) && newValues.length > 0) {
|
|
7439
|
-
allSelected = allSelected.concat(newValues);
|
|
7440
|
-
} else if (newValues && !Array.isArray(newValues)) {
|
|
7441
|
-
allSelected.push(newValues);
|
|
7442
|
-
}
|
|
7443
|
-
} else if (f.value) {
|
|
7444
|
-
// For other multiselects, use their current value
|
|
7445
|
-
if (Array.isArray(f.value)) {
|
|
7446
|
-
allSelected = allSelected.concat(f.value);
|
|
7447
|
-
} else if (f.value) {
|
|
7448
|
-
allSelected.push(f.value);
|
|
7449
|
-
}
|
|
7450
|
-
}
|
|
7451
|
-
}
|
|
7452
|
-
});
|
|
7453
|
-
// Filter out empty/null/undefined values
|
|
7454
|
-
allSelected = allSelected.filter(v => v !== undefined && v !== null && v !== '');
|
|
7455
|
-
const joined = allSelected.join(",");
|
|
7456
|
-
if (joined && joined.length > 0) {
|
|
7457
|
-
url.searchParams.set('search', joined);
|
|
7458
|
-
} else {
|
|
7459
|
-
url.searchParams.delete('search');
|
|
7460
|
-
}
|
|
7461
|
-
window.history.replaceState({}, '', url.toString());
|
|
7462
|
-
} catch (e) {
|
|
7463
|
-
// ignore
|
|
7464
|
-
}
|
|
7465
|
-
}
|
|
7466
|
-
},
|
|
7467
|
-
required: item.required,
|
|
7468
|
-
isMulti: item.isMulti,
|
|
7469
|
-
theme: theme,
|
|
7470
|
-
fetchOptions: item.fetchOptions,
|
|
7471
|
-
options: item.options
|
|
7472
|
-
}));
|
|
7473
|
-
case 'date':
|
|
7474
|
-
return /*#__PURE__*/React$1.createElement("div", {
|
|
7475
|
-
key: index,
|
|
7476
|
-
className: "filter-date",
|
|
7477
|
-
title: tooltip
|
|
7478
|
-
}, /*#__PURE__*/React$1.createElement("input", {
|
|
7479
|
-
className: "basic-input",
|
|
7480
|
-
type: item.addTime ? 'datetime-local' : 'date',
|
|
7481
|
-
value: item.value || '',
|
|
7482
|
-
onChange: e => onChange?.(item.key, e.target.value)
|
|
7483
|
-
}), item.value && /*#__PURE__*/React$1.createElement("span", {
|
|
7484
|
-
className: "date-clear",
|
|
7485
|
-
onClick: () => onChange?.(item.key, ''),
|
|
7486
|
-
title: "Clear date"
|
|
7487
|
-
}, "\u2716\uFE0F"));
|
|
7488
|
-
case 'button':
|
|
7489
|
-
return /*#__PURE__*/React$1.createElement("button", {
|
|
7490
|
-
style: item?.style,
|
|
7491
|
-
className: "basic-button",
|
|
7492
|
-
key: index,
|
|
7493
|
-
onClick: () => {
|
|
7494
|
-
const actionFn = item.onAction || onAction;
|
|
7495
|
-
if (!actionFn) return;
|
|
7496
|
-
if (item.confirm) {
|
|
7497
|
-
openConfirmModal(item.label, item.key, actionFn);
|
|
7498
|
-
} else {
|
|
7499
|
-
actionFn(item.key);
|
|
7500
|
-
}
|
|
7501
|
-
},
|
|
7502
|
-
title: tooltip
|
|
7503
|
-
}, t(item.label));
|
|
7504
|
-
case 'icon':
|
|
7505
|
-
return /*#__PURE__*/React$1.createElement("span", {
|
|
7506
|
-
key: index,
|
|
7507
|
-
className: `filter-icon ${item.className || ''}`,
|
|
7508
|
-
style: item.style,
|
|
7509
|
-
onClick: () => onAction?.(item.key),
|
|
7510
|
-
title: tooltip
|
|
7511
|
-
}, item.icon);
|
|
7512
|
-
default:
|
|
7513
|
-
return null;
|
|
7646
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
7647
|
+
window.history.replaceState({}, "", newUrl);
|
|
7648
|
+
}, [paramKey, multiUrlList, pushValue, toggle]);
|
|
7649
|
+
const handleActivate = e => {
|
|
7650
|
+
if (disabled) return;
|
|
7651
|
+
let nextActive = active;
|
|
7652
|
+
if (toggle || multiUrlList) {
|
|
7653
|
+
nextActive = !active;
|
|
7654
|
+
} else {
|
|
7655
|
+
nextActive = true; // one-shot set
|
|
7514
7656
|
}
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7521
|
-
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
};
|
|
7657
|
+
setActive(nextActive);
|
|
7658
|
+
updateUrl(nextActive);
|
|
7659
|
+
onClick?.(e, nextActive);
|
|
7660
|
+
};
|
|
7661
|
+
const handleKey = e => {
|
|
7662
|
+
if (disabled) return;
|
|
7663
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
7664
|
+
e.preventDefault();
|
|
7665
|
+
handleActivate(e);
|
|
7666
|
+
}
|
|
7667
|
+
};
|
|
7668
|
+
const label = ariaLabel || title || (typeof icon === "string" ? icon : "icon button");
|
|
7669
|
+
const baseStyle = {
|
|
7670
|
+
display: "inline-flex",
|
|
7671
|
+
alignItems: "center",
|
|
7672
|
+
justifyContent: "center",
|
|
7673
|
+
width: size,
|
|
7674
|
+
height: size,
|
|
7675
|
+
fontSize: Math.floor(size * 0.6),
|
|
7676
|
+
lineHeight: 1,
|
|
7677
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
7678
|
+
userSelect: "none",
|
|
7679
|
+
borderRadius: 6,
|
|
7680
|
+
border: "1px solid #ccc",
|
|
7681
|
+
background: active ? "#e0f2fe" : "#f5f5f5",
|
|
7682
|
+
color: active ? activeColor : inactiveColor,
|
|
7683
|
+
transition: "background 120ms, color 120ms, box-shadow 120ms",
|
|
7684
|
+
boxShadow: active ? "0 0 0 2px rgba(29,78,216,0.3)" : "none",
|
|
7685
|
+
...style
|
|
7686
|
+
};
|
|
7687
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
7688
|
+
role: "button",
|
|
7689
|
+
"aria-label": label,
|
|
7690
|
+
"aria-pressed": toggle || multiUrlList ? active : undefined,
|
|
7691
|
+
tabIndex: disabled ? -1 : 0,
|
|
7692
|
+
title: title,
|
|
7693
|
+
onClick: onAction,
|
|
7694
|
+
onKeyDown: handleKey,
|
|
7695
|
+
className: `icon-input ${className}`.trim(),
|
|
7696
|
+
style: baseStyle,
|
|
7697
|
+
"data-active": active ? "true" : "false"
|
|
7698
|
+
}, icon);
|
|
7699
|
+
}
|
|
7700
|
+
|
|
7701
|
+
var propTypes = {exports: {}};
|
|
7702
|
+
|
|
7703
|
+
/*
|
|
7704
|
+
object-assign
|
|
7705
|
+
(c) Sindre Sorhus
|
|
7706
|
+
@license MIT
|
|
7707
|
+
*/
|
|
7708
|
+
|
|
7709
|
+
var objectAssign;
|
|
7710
|
+
var hasRequiredObjectAssign;
|
|
7711
|
+
|
|
7712
|
+
function requireObjectAssign () {
|
|
7713
|
+
if (hasRequiredObjectAssign) return objectAssign;
|
|
7714
|
+
hasRequiredObjectAssign = 1;
|
|
7715
|
+
/* eslint-disable no-unused-vars */
|
|
7716
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
7717
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
7718
|
+
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
7719
|
+
|
|
7720
|
+
function toObject(val) {
|
|
7721
|
+
if (val === null || val === undefined) {
|
|
7722
|
+
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
7723
|
+
}
|
|
7724
|
+
|
|
7725
|
+
return Object(val);
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7728
|
+
function shouldUseNative() {
|
|
7729
|
+
try {
|
|
7730
|
+
if (!Object.assign) {
|
|
7731
|
+
return false;
|
|
7732
|
+
}
|
|
7733
|
+
|
|
7734
|
+
// Detect buggy property enumeration order in older V8 versions.
|
|
7735
|
+
|
|
7736
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
7737
|
+
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
7738
|
+
test1[5] = 'de';
|
|
7739
|
+
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
7740
|
+
return false;
|
|
7741
|
+
}
|
|
7742
|
+
|
|
7743
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
7744
|
+
var test2 = {};
|
|
7745
|
+
for (var i = 0; i < 10; i++) {
|
|
7746
|
+
test2['_' + String.fromCharCode(i)] = i;
|
|
7747
|
+
}
|
|
7748
|
+
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
7749
|
+
return test2[n];
|
|
7750
|
+
});
|
|
7751
|
+
if (order2.join('') !== '0123456789') {
|
|
7752
|
+
return false;
|
|
7753
|
+
}
|
|
7754
|
+
|
|
7755
|
+
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
7756
|
+
var test3 = {};
|
|
7757
|
+
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
7758
|
+
test3[letter] = letter;
|
|
7759
|
+
});
|
|
7760
|
+
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
7761
|
+
'abcdefghijklmnopqrst') {
|
|
7762
|
+
return false;
|
|
7763
|
+
}
|
|
7764
|
+
|
|
7765
|
+
return true;
|
|
7766
|
+
} catch (err) {
|
|
7767
|
+
// We don't expect any of the above to throw, but better to be safe.
|
|
7768
|
+
return false;
|
|
7769
|
+
}
|
|
7770
|
+
}
|
|
7771
|
+
|
|
7772
|
+
objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
7773
|
+
var from;
|
|
7774
|
+
var to = toObject(target);
|
|
7775
|
+
var symbols;
|
|
7776
|
+
|
|
7777
|
+
for (var s = 1; s < arguments.length; s++) {
|
|
7778
|
+
from = Object(arguments[s]);
|
|
7779
|
+
|
|
7780
|
+
for (var key in from) {
|
|
7781
|
+
if (hasOwnProperty.call(from, key)) {
|
|
7782
|
+
to[key] = from[key];
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
|
|
7786
|
+
if (getOwnPropertySymbols) {
|
|
7787
|
+
symbols = getOwnPropertySymbols(from);
|
|
7788
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
7789
|
+
if (propIsEnumerable.call(from, symbols[i])) {
|
|
7790
|
+
to[symbols[i]] = from[symbols[i]];
|
|
7791
|
+
}
|
|
7792
|
+
}
|
|
7793
|
+
}
|
|
7794
|
+
}
|
|
7795
|
+
|
|
7796
|
+
return to;
|
|
7797
|
+
};
|
|
7798
|
+
return objectAssign;
|
|
7799
|
+
}
|
|
7800
|
+
|
|
7801
|
+
/**
|
|
7802
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7803
|
+
*
|
|
7804
|
+
* This source code is licensed under the MIT license found in the
|
|
7805
|
+
* LICENSE file in the root directory of this source tree.
|
|
7806
|
+
*/
|
|
7807
|
+
|
|
7808
|
+
var ReactPropTypesSecret_1;
|
|
7809
|
+
var hasRequiredReactPropTypesSecret;
|
|
7810
|
+
|
|
7811
|
+
function requireReactPropTypesSecret () {
|
|
7812
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
7813
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
7814
|
+
|
|
7815
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
7816
|
+
|
|
7817
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
7818
|
+
return ReactPropTypesSecret_1;
|
|
7819
|
+
}
|
|
7820
|
+
|
|
7821
|
+
var has;
|
|
7822
|
+
var hasRequiredHas;
|
|
7823
|
+
|
|
7824
|
+
function requireHas () {
|
|
7825
|
+
if (hasRequiredHas) return has;
|
|
7826
|
+
hasRequiredHas = 1;
|
|
7827
|
+
has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
7828
|
+
return has;
|
|
7829
|
+
}
|
|
7830
|
+
|
|
7831
|
+
/**
|
|
7832
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7833
|
+
*
|
|
7834
|
+
* This source code is licensed under the MIT license found in the
|
|
7835
|
+
* LICENSE file in the root directory of this source tree.
|
|
7836
|
+
*/
|
|
7837
|
+
|
|
7838
|
+
var checkPropTypes_1;
|
|
7839
|
+
var hasRequiredCheckPropTypes;
|
|
7840
|
+
|
|
7841
|
+
function requireCheckPropTypes () {
|
|
7842
|
+
if (hasRequiredCheckPropTypes) return checkPropTypes_1;
|
|
7843
|
+
hasRequiredCheckPropTypes = 1;
|
|
7844
|
+
|
|
7845
|
+
var printWarning = function() {};
|
|
7846
|
+
|
|
7847
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7848
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
7849
|
+
var loggedTypeFailures = {};
|
|
7850
|
+
var has = /*@__PURE__*/ requireHas();
|
|
7851
|
+
|
|
7852
|
+
printWarning = function(text) {
|
|
7853
|
+
var message = 'Warning: ' + text;
|
|
7854
|
+
if (typeof console !== 'undefined') {
|
|
7855
|
+
console.error(message);
|
|
7856
|
+
}
|
|
7857
|
+
try {
|
|
7858
|
+
// --- Welcome to debugging React ---
|
|
7859
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
7860
|
+
// to find the callsite that caused this warning to fire.
|
|
7861
|
+
throw new Error(message);
|
|
7862
|
+
} catch (x) { /**/ }
|
|
7863
|
+
};
|
|
7864
|
+
}
|
|
7865
|
+
|
|
7866
|
+
/**
|
|
7867
|
+
* Assert that the values match with the type specs.
|
|
7868
|
+
* Error messages are memorized and will only be shown once.
|
|
7869
|
+
*
|
|
7870
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
7871
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
7872
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
7873
|
+
* @param {string} componentName Name of the component for error messages.
|
|
7874
|
+
* @param {?Function} getStack Returns the component stack.
|
|
7875
|
+
* @private
|
|
7876
|
+
*/
|
|
7877
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
7878
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7879
|
+
for (var typeSpecName in typeSpecs) {
|
|
7880
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
7881
|
+
var error;
|
|
7882
|
+
// Prop type validation may throw. In case they do, we don't want to
|
|
7883
|
+
// fail the render phase where it didn't fail before. So we log it.
|
|
7884
|
+
// After these have been cleaned up, we'll let them throw.
|
|
7885
|
+
try {
|
|
7886
|
+
// This is intentionally an invariant that gets caught. It's the same
|
|
7887
|
+
// behavior as without this statement except with a better message.
|
|
7888
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
7889
|
+
var err = Error(
|
|
7890
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
7891
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
|
|
7892
|
+
'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
|
|
7893
|
+
);
|
|
7894
|
+
err.name = 'Invariant Violation';
|
|
7895
|
+
throw err;
|
|
7896
|
+
}
|
|
7897
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
7898
|
+
} catch (ex) {
|
|
7899
|
+
error = ex;
|
|
7900
|
+
}
|
|
7901
|
+
if (error && !(error instanceof Error)) {
|
|
7902
|
+
printWarning(
|
|
7903
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
7904
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
7905
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
7906
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
7907
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
7908
|
+
'shape all require an argument).'
|
|
7909
|
+
);
|
|
7910
|
+
}
|
|
7911
|
+
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
7912
|
+
// Only monitor this failure once because there tends to be a lot of the
|
|
7913
|
+
// same error.
|
|
7914
|
+
loggedTypeFailures[error.message] = true;
|
|
7915
|
+
|
|
7916
|
+
var stack = getStack ? getStack() : '';
|
|
7917
|
+
|
|
7918
|
+
printWarning(
|
|
7919
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
7920
|
+
);
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
}
|
|
7925
|
+
}
|
|
7926
|
+
|
|
7927
|
+
/**
|
|
7928
|
+
* Resets warning cache when testing.
|
|
7929
|
+
*
|
|
7930
|
+
* @private
|
|
7931
|
+
*/
|
|
7932
|
+
checkPropTypes.resetWarningCache = function() {
|
|
7933
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7934
|
+
loggedTypeFailures = {};
|
|
7935
|
+
}
|
|
7936
|
+
};
|
|
7937
|
+
|
|
7938
|
+
checkPropTypes_1 = checkPropTypes;
|
|
7939
|
+
return checkPropTypes_1;
|
|
7940
|
+
}
|
|
7941
|
+
|
|
7942
|
+
/**
|
|
7943
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
7944
|
+
*
|
|
7945
|
+
* This source code is licensed under the MIT license found in the
|
|
7946
|
+
* LICENSE file in the root directory of this source tree.
|
|
7947
|
+
*/
|
|
7948
|
+
|
|
7949
|
+
var factoryWithTypeCheckers;
|
|
7950
|
+
var hasRequiredFactoryWithTypeCheckers;
|
|
7951
|
+
|
|
7952
|
+
function requireFactoryWithTypeCheckers () {
|
|
7953
|
+
if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
|
|
7954
|
+
hasRequiredFactoryWithTypeCheckers = 1;
|
|
7955
|
+
|
|
7956
|
+
var ReactIs = requireReactIs();
|
|
7957
|
+
var assign = requireObjectAssign();
|
|
7958
|
+
|
|
7959
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
7960
|
+
var has = /*@__PURE__*/ requireHas();
|
|
7961
|
+
var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
|
|
7962
|
+
|
|
7963
|
+
var printWarning = function() {};
|
|
7964
|
+
|
|
7965
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7966
|
+
printWarning = function(text) {
|
|
7967
|
+
var message = 'Warning: ' + text;
|
|
7968
|
+
if (typeof console !== 'undefined') {
|
|
7969
|
+
console.error(message);
|
|
7970
|
+
}
|
|
7971
|
+
try {
|
|
7972
|
+
// --- Welcome to debugging React ---
|
|
7973
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
7974
|
+
// to find the callsite that caused this warning to fire.
|
|
7975
|
+
throw new Error(message);
|
|
7976
|
+
} catch (x) {}
|
|
7977
|
+
};
|
|
7978
|
+
}
|
|
7979
|
+
|
|
7980
|
+
function emptyFunctionThatReturnsNull() {
|
|
7981
|
+
return null;
|
|
7982
|
+
}
|
|
7983
|
+
|
|
7984
|
+
factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
|
|
7985
|
+
/* global Symbol */
|
|
7986
|
+
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
7987
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
|
|
7988
|
+
|
|
7989
|
+
/**
|
|
7990
|
+
* Returns the iterator method function contained on the iterable object.
|
|
7991
|
+
*
|
|
7992
|
+
* Be sure to invoke the function with the iterable as context:
|
|
7993
|
+
*
|
|
7994
|
+
* var iteratorFn = getIteratorFn(myIterable);
|
|
7995
|
+
* if (iteratorFn) {
|
|
7996
|
+
* var iterator = iteratorFn.call(myIterable);
|
|
7997
|
+
* ...
|
|
7998
|
+
* }
|
|
7999
|
+
*
|
|
8000
|
+
* @param {?object} maybeIterable
|
|
8001
|
+
* @return {?function}
|
|
8002
|
+
*/
|
|
8003
|
+
function getIteratorFn(maybeIterable) {
|
|
8004
|
+
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
|
8005
|
+
if (typeof iteratorFn === 'function') {
|
|
8006
|
+
return iteratorFn;
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
|
|
8010
|
+
/**
|
|
8011
|
+
* Collection of methods that allow declaration and validation of props that are
|
|
8012
|
+
* supplied to React components. Example usage:
|
|
8013
|
+
*
|
|
8014
|
+
* var Props = require('ReactPropTypes');
|
|
8015
|
+
* var MyArticle = React.createClass({
|
|
8016
|
+
* propTypes: {
|
|
8017
|
+
* // An optional string prop named "description".
|
|
8018
|
+
* description: Props.string,
|
|
8019
|
+
*
|
|
8020
|
+
* // A required enum prop named "category".
|
|
8021
|
+
* category: Props.oneOf(['News','Photos']).isRequired,
|
|
8022
|
+
*
|
|
8023
|
+
* // A prop named "dialog" that requires an instance of Dialog.
|
|
8024
|
+
* dialog: Props.instanceOf(Dialog).isRequired
|
|
8025
|
+
* },
|
|
8026
|
+
* render: function() { ... }
|
|
8027
|
+
* });
|
|
8028
|
+
*
|
|
8029
|
+
* A more formal specification of how these methods are used:
|
|
8030
|
+
*
|
|
8031
|
+
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
|
|
8032
|
+
* decl := ReactPropTypes.{type}(.isRequired)?
|
|
8033
|
+
*
|
|
8034
|
+
* Each and every declaration produces a function with the same signature. This
|
|
8035
|
+
* allows the creation of custom validation functions. For example:
|
|
8036
|
+
*
|
|
8037
|
+
* var MyLink = React.createClass({
|
|
8038
|
+
* propTypes: {
|
|
8039
|
+
* // An optional string or URI prop named "href".
|
|
8040
|
+
* href: function(props, propName, componentName) {
|
|
8041
|
+
* var propValue = props[propName];
|
|
8042
|
+
* if (propValue != null && typeof propValue !== 'string' &&
|
|
8043
|
+
* !(propValue instanceof URI)) {
|
|
8044
|
+
* return new Error(
|
|
8045
|
+
* 'Expected a string or an URI for ' + propName + ' in ' +
|
|
8046
|
+
* componentName
|
|
8047
|
+
* );
|
|
8048
|
+
* }
|
|
8049
|
+
* }
|
|
8050
|
+
* },
|
|
8051
|
+
* render: function() {...}
|
|
8052
|
+
* });
|
|
8053
|
+
*
|
|
8054
|
+
* @internal
|
|
8055
|
+
*/
|
|
8056
|
+
|
|
8057
|
+
var ANONYMOUS = '<<anonymous>>';
|
|
8058
|
+
|
|
8059
|
+
// Important!
|
|
8060
|
+
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
|
|
8061
|
+
var ReactPropTypes = {
|
|
8062
|
+
array: createPrimitiveTypeChecker('array'),
|
|
8063
|
+
bigint: createPrimitiveTypeChecker('bigint'),
|
|
8064
|
+
bool: createPrimitiveTypeChecker('boolean'),
|
|
8065
|
+
func: createPrimitiveTypeChecker('function'),
|
|
8066
|
+
number: createPrimitiveTypeChecker('number'),
|
|
8067
|
+
object: createPrimitiveTypeChecker('object'),
|
|
8068
|
+
string: createPrimitiveTypeChecker('string'),
|
|
8069
|
+
symbol: createPrimitiveTypeChecker('symbol'),
|
|
8070
|
+
|
|
8071
|
+
any: createAnyTypeChecker(),
|
|
8072
|
+
arrayOf: createArrayOfTypeChecker,
|
|
8073
|
+
element: createElementTypeChecker(),
|
|
8074
|
+
elementType: createElementTypeTypeChecker(),
|
|
8075
|
+
instanceOf: createInstanceTypeChecker,
|
|
8076
|
+
node: createNodeChecker(),
|
|
8077
|
+
objectOf: createObjectOfTypeChecker,
|
|
8078
|
+
oneOf: createEnumTypeChecker,
|
|
8079
|
+
oneOfType: createUnionTypeChecker,
|
|
8080
|
+
shape: createShapeTypeChecker,
|
|
8081
|
+
exact: createStrictShapeTypeChecker,
|
|
8082
|
+
};
|
|
8083
|
+
|
|
8084
|
+
/**
|
|
8085
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
8086
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
8087
|
+
*/
|
|
8088
|
+
/*eslint-disable no-self-compare*/
|
|
8089
|
+
function is(x, y) {
|
|
8090
|
+
// SameValue algorithm
|
|
8091
|
+
if (x === y) {
|
|
8092
|
+
// Steps 1-5, 7-10
|
|
8093
|
+
// Steps 6.b-6.e: +0 != -0
|
|
8094
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
8095
|
+
} else {
|
|
8096
|
+
// Step 6.a: NaN == NaN
|
|
8097
|
+
return x !== x && y !== y;
|
|
8098
|
+
}
|
|
8099
|
+
}
|
|
8100
|
+
/*eslint-enable no-self-compare*/
|
|
8101
|
+
|
|
8102
|
+
/**
|
|
8103
|
+
* We use an Error-like object for backward compatibility as people may call
|
|
8104
|
+
* PropTypes directly and inspect their output. However, we don't use real
|
|
8105
|
+
* Errors anymore. We don't inspect their stack anyway, and creating them
|
|
8106
|
+
* is prohibitively expensive if they are created too often, such as what
|
|
8107
|
+
* happens in oneOfType() for any type before the one that matched.
|
|
8108
|
+
*/
|
|
8109
|
+
function PropTypeError(message, data) {
|
|
8110
|
+
this.message = message;
|
|
8111
|
+
this.data = data && typeof data === 'object' ? data: {};
|
|
8112
|
+
this.stack = '';
|
|
8113
|
+
}
|
|
8114
|
+
// Make `instanceof Error` still work for returned errors.
|
|
8115
|
+
PropTypeError.prototype = Error.prototype;
|
|
8116
|
+
|
|
8117
|
+
function createChainableTypeChecker(validate) {
|
|
8118
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8119
|
+
var manualPropTypeCallCache = {};
|
|
8120
|
+
var manualPropTypeWarningCount = 0;
|
|
8121
|
+
}
|
|
8122
|
+
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
|
8123
|
+
componentName = componentName || ANONYMOUS;
|
|
8124
|
+
propFullName = propFullName || propName;
|
|
8125
|
+
|
|
8126
|
+
if (secret !== ReactPropTypesSecret) {
|
|
8127
|
+
if (throwOnDirectAccess) {
|
|
8128
|
+
// New behavior only for users of `prop-types` package
|
|
8129
|
+
var err = new Error(
|
|
8130
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
8131
|
+
'Use `PropTypes.checkPropTypes()` to call them. ' +
|
|
8132
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
8133
|
+
);
|
|
8134
|
+
err.name = 'Invariant Violation';
|
|
8135
|
+
throw err;
|
|
8136
|
+
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
8137
|
+
// Old behavior for people using React.PropTypes
|
|
8138
|
+
var cacheKey = componentName + ':' + propName;
|
|
8139
|
+
if (
|
|
8140
|
+
!manualPropTypeCallCache[cacheKey] &&
|
|
8141
|
+
// Avoid spamming the console because they are often not actionable except for lib authors
|
|
8142
|
+
manualPropTypeWarningCount < 3
|
|
8143
|
+
) {
|
|
8144
|
+
printWarning(
|
|
8145
|
+
'You are manually calling a React.PropTypes validation ' +
|
|
8146
|
+
'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
|
8147
|
+
'and will throw in the standalone `prop-types` package. ' +
|
|
8148
|
+
'You may be seeing this warning due to a third-party PropTypes ' +
|
|
8149
|
+
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
|
8150
|
+
);
|
|
8151
|
+
manualPropTypeCallCache[cacheKey] = true;
|
|
8152
|
+
manualPropTypeWarningCount++;
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
}
|
|
8156
|
+
if (props[propName] == null) {
|
|
8157
|
+
if (isRequired) {
|
|
8158
|
+
if (props[propName] === null) {
|
|
8159
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
|
8160
|
+
}
|
|
8161
|
+
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
|
8162
|
+
}
|
|
8163
|
+
return null;
|
|
8164
|
+
} else {
|
|
8165
|
+
return validate(props, propName, componentName, location, propFullName);
|
|
8166
|
+
}
|
|
8167
|
+
}
|
|
7526
8168
|
|
|
7527
|
-
|
|
7528
|
-
|
|
8169
|
+
var chainedCheckType = checkType.bind(null, false);
|
|
8170
|
+
chainedCheckType.isRequired = checkType.bind(null, true);
|
|
8171
|
+
|
|
8172
|
+
return chainedCheckType;
|
|
8173
|
+
}
|
|
8174
|
+
|
|
8175
|
+
function createPrimitiveTypeChecker(expectedType) {
|
|
8176
|
+
function validate(props, propName, componentName, location, propFullName, secret) {
|
|
8177
|
+
var propValue = props[propName];
|
|
8178
|
+
var propType = getPropType(propValue);
|
|
8179
|
+
if (propType !== expectedType) {
|
|
8180
|
+
// `propValue` being instance of, say, date/regexp, pass the 'object'
|
|
8181
|
+
// check, but we can offer a more precise error message here rather than
|
|
8182
|
+
// 'of type `object`'.
|
|
8183
|
+
var preciseType = getPreciseType(propValue);
|
|
8184
|
+
|
|
8185
|
+
return new PropTypeError(
|
|
8186
|
+
'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
|
|
8187
|
+
{expectedType: expectedType}
|
|
8188
|
+
);
|
|
8189
|
+
}
|
|
8190
|
+
return null;
|
|
8191
|
+
}
|
|
8192
|
+
return createChainableTypeChecker(validate);
|
|
8193
|
+
}
|
|
8194
|
+
|
|
8195
|
+
function createAnyTypeChecker() {
|
|
8196
|
+
return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
|
8197
|
+
}
|
|
8198
|
+
|
|
8199
|
+
function createArrayOfTypeChecker(typeChecker) {
|
|
8200
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8201
|
+
if (typeof typeChecker !== 'function') {
|
|
8202
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
|
8203
|
+
}
|
|
8204
|
+
var propValue = props[propName];
|
|
8205
|
+
if (!Array.isArray(propValue)) {
|
|
8206
|
+
var propType = getPropType(propValue);
|
|
8207
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
|
8208
|
+
}
|
|
8209
|
+
for (var i = 0; i < propValue.length; i++) {
|
|
8210
|
+
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
|
8211
|
+
if (error instanceof Error) {
|
|
8212
|
+
return error;
|
|
8213
|
+
}
|
|
8214
|
+
}
|
|
8215
|
+
return null;
|
|
8216
|
+
}
|
|
8217
|
+
return createChainableTypeChecker(validate);
|
|
8218
|
+
}
|
|
8219
|
+
|
|
8220
|
+
function createElementTypeChecker() {
|
|
8221
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8222
|
+
var propValue = props[propName];
|
|
8223
|
+
if (!isValidElement(propValue)) {
|
|
8224
|
+
var propType = getPropType(propValue);
|
|
8225
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
|
8226
|
+
}
|
|
8227
|
+
return null;
|
|
8228
|
+
}
|
|
8229
|
+
return createChainableTypeChecker(validate);
|
|
8230
|
+
}
|
|
8231
|
+
|
|
8232
|
+
function createElementTypeTypeChecker() {
|
|
8233
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8234
|
+
var propValue = props[propName];
|
|
8235
|
+
if (!ReactIs.isValidElementType(propValue)) {
|
|
8236
|
+
var propType = getPropType(propValue);
|
|
8237
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
|
8238
|
+
}
|
|
8239
|
+
return null;
|
|
8240
|
+
}
|
|
8241
|
+
return createChainableTypeChecker(validate);
|
|
8242
|
+
}
|
|
8243
|
+
|
|
8244
|
+
function createInstanceTypeChecker(expectedClass) {
|
|
8245
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8246
|
+
if (!(props[propName] instanceof expectedClass)) {
|
|
8247
|
+
var expectedClassName = expectedClass.name || ANONYMOUS;
|
|
8248
|
+
var actualClassName = getClassName(props[propName]);
|
|
8249
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
|
8250
|
+
}
|
|
8251
|
+
return null;
|
|
8252
|
+
}
|
|
8253
|
+
return createChainableTypeChecker(validate);
|
|
8254
|
+
}
|
|
8255
|
+
|
|
8256
|
+
function createEnumTypeChecker(expectedValues) {
|
|
8257
|
+
if (!Array.isArray(expectedValues)) {
|
|
8258
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8259
|
+
if (arguments.length > 1) {
|
|
8260
|
+
printWarning(
|
|
8261
|
+
'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
|
8262
|
+
'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
|
8263
|
+
);
|
|
8264
|
+
} else {
|
|
8265
|
+
printWarning('Invalid argument supplied to oneOf, expected an array.');
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8268
|
+
return emptyFunctionThatReturnsNull;
|
|
8269
|
+
}
|
|
8270
|
+
|
|
8271
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8272
|
+
var propValue = props[propName];
|
|
8273
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
8274
|
+
if (is(propValue, expectedValues[i])) {
|
|
8275
|
+
return null;
|
|
8276
|
+
}
|
|
8277
|
+
}
|
|
8278
|
+
|
|
8279
|
+
var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
|
8280
|
+
var type = getPreciseType(value);
|
|
8281
|
+
if (type === 'symbol') {
|
|
8282
|
+
return String(value);
|
|
8283
|
+
}
|
|
8284
|
+
return value;
|
|
8285
|
+
});
|
|
8286
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
|
8287
|
+
}
|
|
8288
|
+
return createChainableTypeChecker(validate);
|
|
8289
|
+
}
|
|
8290
|
+
|
|
8291
|
+
function createObjectOfTypeChecker(typeChecker) {
|
|
8292
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8293
|
+
if (typeof typeChecker !== 'function') {
|
|
8294
|
+
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
|
8295
|
+
}
|
|
8296
|
+
var propValue = props[propName];
|
|
8297
|
+
var propType = getPropType(propValue);
|
|
8298
|
+
if (propType !== 'object') {
|
|
8299
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
|
8300
|
+
}
|
|
8301
|
+
for (var key in propValue) {
|
|
8302
|
+
if (has(propValue, key)) {
|
|
8303
|
+
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8304
|
+
if (error instanceof Error) {
|
|
8305
|
+
return error;
|
|
8306
|
+
}
|
|
8307
|
+
}
|
|
8308
|
+
}
|
|
8309
|
+
return null;
|
|
8310
|
+
}
|
|
8311
|
+
return createChainableTypeChecker(validate);
|
|
8312
|
+
}
|
|
8313
|
+
|
|
8314
|
+
function createUnionTypeChecker(arrayOfTypeCheckers) {
|
|
8315
|
+
if (!Array.isArray(arrayOfTypeCheckers)) {
|
|
8316
|
+
process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
|
|
8317
|
+
return emptyFunctionThatReturnsNull;
|
|
8318
|
+
}
|
|
8319
|
+
|
|
8320
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
8321
|
+
var checker = arrayOfTypeCheckers[i];
|
|
8322
|
+
if (typeof checker !== 'function') {
|
|
8323
|
+
printWarning(
|
|
8324
|
+
'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
|
8325
|
+
'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
|
8326
|
+
);
|
|
8327
|
+
return emptyFunctionThatReturnsNull;
|
|
8328
|
+
}
|
|
8329
|
+
}
|
|
8330
|
+
|
|
8331
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8332
|
+
var expectedTypes = [];
|
|
8333
|
+
for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
|
8334
|
+
var checker = arrayOfTypeCheckers[i];
|
|
8335
|
+
var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
|
|
8336
|
+
if (checkerResult == null) {
|
|
8337
|
+
return null;
|
|
8338
|
+
}
|
|
8339
|
+
if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
|
|
8340
|
+
expectedTypes.push(checkerResult.data.expectedType);
|
|
8341
|
+
}
|
|
8342
|
+
}
|
|
8343
|
+
var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
|
|
8344
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
|
|
8345
|
+
}
|
|
8346
|
+
return createChainableTypeChecker(validate);
|
|
8347
|
+
}
|
|
8348
|
+
|
|
8349
|
+
function createNodeChecker() {
|
|
8350
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8351
|
+
if (!isNode(props[propName])) {
|
|
8352
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
|
8353
|
+
}
|
|
8354
|
+
return null;
|
|
8355
|
+
}
|
|
8356
|
+
return createChainableTypeChecker(validate);
|
|
8357
|
+
}
|
|
8358
|
+
|
|
8359
|
+
function invalidValidatorError(componentName, location, propFullName, key, type) {
|
|
8360
|
+
return new PropTypeError(
|
|
8361
|
+
(componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
|
|
8362
|
+
'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
|
|
8363
|
+
);
|
|
8364
|
+
}
|
|
8365
|
+
|
|
8366
|
+
function createShapeTypeChecker(shapeTypes) {
|
|
8367
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8368
|
+
var propValue = props[propName];
|
|
8369
|
+
var propType = getPropType(propValue);
|
|
8370
|
+
if (propType !== 'object') {
|
|
8371
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
8372
|
+
}
|
|
8373
|
+
for (var key in shapeTypes) {
|
|
8374
|
+
var checker = shapeTypes[key];
|
|
8375
|
+
if (typeof checker !== 'function') {
|
|
8376
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
8377
|
+
}
|
|
8378
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8379
|
+
if (error) {
|
|
8380
|
+
return error;
|
|
8381
|
+
}
|
|
8382
|
+
}
|
|
8383
|
+
return null;
|
|
8384
|
+
}
|
|
8385
|
+
return createChainableTypeChecker(validate);
|
|
8386
|
+
}
|
|
8387
|
+
|
|
8388
|
+
function createStrictShapeTypeChecker(shapeTypes) {
|
|
8389
|
+
function validate(props, propName, componentName, location, propFullName) {
|
|
8390
|
+
var propValue = props[propName];
|
|
8391
|
+
var propType = getPropType(propValue);
|
|
8392
|
+
if (propType !== 'object') {
|
|
8393
|
+
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
|
8394
|
+
}
|
|
8395
|
+
// We need to check all keys in case some are required but missing from props.
|
|
8396
|
+
var allKeys = assign({}, props[propName], shapeTypes);
|
|
8397
|
+
for (var key in allKeys) {
|
|
8398
|
+
var checker = shapeTypes[key];
|
|
8399
|
+
if (has(shapeTypes, key) && typeof checker !== 'function') {
|
|
8400
|
+
return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
|
|
8401
|
+
}
|
|
8402
|
+
if (!checker) {
|
|
8403
|
+
return new PropTypeError(
|
|
8404
|
+
'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
|
8405
|
+
'\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
|
8406
|
+
'\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
|
8407
|
+
);
|
|
8408
|
+
}
|
|
8409
|
+
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
|
8410
|
+
if (error) {
|
|
8411
|
+
return error;
|
|
8412
|
+
}
|
|
8413
|
+
}
|
|
8414
|
+
return null;
|
|
8415
|
+
}
|
|
8416
|
+
|
|
8417
|
+
return createChainableTypeChecker(validate);
|
|
8418
|
+
}
|
|
8419
|
+
|
|
8420
|
+
function isNode(propValue) {
|
|
8421
|
+
switch (typeof propValue) {
|
|
8422
|
+
case 'number':
|
|
8423
|
+
case 'string':
|
|
8424
|
+
case 'undefined':
|
|
8425
|
+
return true;
|
|
8426
|
+
case 'boolean':
|
|
8427
|
+
return !propValue;
|
|
8428
|
+
case 'object':
|
|
8429
|
+
if (Array.isArray(propValue)) {
|
|
8430
|
+
return propValue.every(isNode);
|
|
8431
|
+
}
|
|
8432
|
+
if (propValue === null || isValidElement(propValue)) {
|
|
8433
|
+
return true;
|
|
8434
|
+
}
|
|
8435
|
+
|
|
8436
|
+
var iteratorFn = getIteratorFn(propValue);
|
|
8437
|
+
if (iteratorFn) {
|
|
8438
|
+
var iterator = iteratorFn.call(propValue);
|
|
8439
|
+
var step;
|
|
8440
|
+
if (iteratorFn !== propValue.entries) {
|
|
8441
|
+
while (!(step = iterator.next()).done) {
|
|
8442
|
+
if (!isNode(step.value)) {
|
|
8443
|
+
return false;
|
|
8444
|
+
}
|
|
8445
|
+
}
|
|
8446
|
+
} else {
|
|
8447
|
+
// Iterator will provide entry [k,v] tuples rather than values.
|
|
8448
|
+
while (!(step = iterator.next()).done) {
|
|
8449
|
+
var entry = step.value;
|
|
8450
|
+
if (entry) {
|
|
8451
|
+
if (!isNode(entry[1])) {
|
|
8452
|
+
return false;
|
|
8453
|
+
}
|
|
8454
|
+
}
|
|
8455
|
+
}
|
|
8456
|
+
}
|
|
8457
|
+
} else {
|
|
8458
|
+
return false;
|
|
8459
|
+
}
|
|
8460
|
+
|
|
8461
|
+
return true;
|
|
8462
|
+
default:
|
|
8463
|
+
return false;
|
|
8464
|
+
}
|
|
8465
|
+
}
|
|
8466
|
+
|
|
8467
|
+
function isSymbol(propType, propValue) {
|
|
8468
|
+
// Native Symbol.
|
|
8469
|
+
if (propType === 'symbol') {
|
|
8470
|
+
return true;
|
|
8471
|
+
}
|
|
8472
|
+
|
|
8473
|
+
// falsy value can't be a Symbol
|
|
8474
|
+
if (!propValue) {
|
|
8475
|
+
return false;
|
|
8476
|
+
}
|
|
8477
|
+
|
|
8478
|
+
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
|
|
8479
|
+
if (propValue['@@toStringTag'] === 'Symbol') {
|
|
8480
|
+
return true;
|
|
8481
|
+
}
|
|
8482
|
+
|
|
8483
|
+
// Fallback for non-spec compliant Symbols which are polyfilled.
|
|
8484
|
+
if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
|
8485
|
+
return true;
|
|
8486
|
+
}
|
|
8487
|
+
|
|
8488
|
+
return false;
|
|
8489
|
+
}
|
|
8490
|
+
|
|
8491
|
+
// Equivalent of `typeof` but with special handling for array and regexp.
|
|
8492
|
+
function getPropType(propValue) {
|
|
8493
|
+
var propType = typeof propValue;
|
|
8494
|
+
if (Array.isArray(propValue)) {
|
|
8495
|
+
return 'array';
|
|
8496
|
+
}
|
|
8497
|
+
if (propValue instanceof RegExp) {
|
|
8498
|
+
// Old webkits (at least until Android 4.0) return 'function' rather than
|
|
8499
|
+
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/
|
|
8500
|
+
// passes PropTypes.object.
|
|
8501
|
+
return 'object';
|
|
8502
|
+
}
|
|
8503
|
+
if (isSymbol(propType, propValue)) {
|
|
8504
|
+
return 'symbol';
|
|
8505
|
+
}
|
|
8506
|
+
return propType;
|
|
8507
|
+
}
|
|
8508
|
+
|
|
8509
|
+
// This handles more types than `getPropType`. Only used for error messages.
|
|
8510
|
+
// See `createPrimitiveTypeChecker`.
|
|
8511
|
+
function getPreciseType(propValue) {
|
|
8512
|
+
if (typeof propValue === 'undefined' || propValue === null) {
|
|
8513
|
+
return '' + propValue;
|
|
8514
|
+
}
|
|
8515
|
+
var propType = getPropType(propValue);
|
|
8516
|
+
if (propType === 'object') {
|
|
8517
|
+
if (propValue instanceof Date) {
|
|
8518
|
+
return 'date';
|
|
8519
|
+
} else if (propValue instanceof RegExp) {
|
|
8520
|
+
return 'regexp';
|
|
8521
|
+
}
|
|
8522
|
+
}
|
|
8523
|
+
return propType;
|
|
8524
|
+
}
|
|
8525
|
+
|
|
8526
|
+
// Returns a string that is postfixed to a warning about an invalid type.
|
|
8527
|
+
// For example, "undefined" or "of type array"
|
|
8528
|
+
function getPostfixForTypeWarning(value) {
|
|
8529
|
+
var type = getPreciseType(value);
|
|
8530
|
+
switch (type) {
|
|
8531
|
+
case 'array':
|
|
8532
|
+
case 'object':
|
|
8533
|
+
return 'an ' + type;
|
|
8534
|
+
case 'boolean':
|
|
8535
|
+
case 'date':
|
|
8536
|
+
case 'regexp':
|
|
8537
|
+
return 'a ' + type;
|
|
8538
|
+
default:
|
|
8539
|
+
return type;
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
|
|
8543
|
+
// Returns class name of the object, if any.
|
|
8544
|
+
function getClassName(propValue) {
|
|
8545
|
+
if (!propValue.constructor || !propValue.constructor.name) {
|
|
8546
|
+
return ANONYMOUS;
|
|
8547
|
+
}
|
|
8548
|
+
return propValue.constructor.name;
|
|
8549
|
+
}
|
|
8550
|
+
|
|
8551
|
+
ReactPropTypes.checkPropTypes = checkPropTypes;
|
|
8552
|
+
ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
|
8553
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
8554
|
+
|
|
8555
|
+
return ReactPropTypes;
|
|
8556
|
+
};
|
|
8557
|
+
return factoryWithTypeCheckers;
|
|
8558
|
+
}
|
|
8559
|
+
|
|
8560
|
+
/**
|
|
8561
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
8562
|
+
*
|
|
8563
|
+
* This source code is licensed under the MIT license found in the
|
|
8564
|
+
* LICENSE file in the root directory of this source tree.
|
|
8565
|
+
*/
|
|
8566
|
+
|
|
8567
|
+
var factoryWithThrowingShims;
|
|
8568
|
+
var hasRequiredFactoryWithThrowingShims;
|
|
8569
|
+
|
|
8570
|
+
function requireFactoryWithThrowingShims () {
|
|
8571
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
|
8572
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
|
8573
|
+
|
|
8574
|
+
var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
|
|
8575
|
+
|
|
8576
|
+
function emptyFunction() {}
|
|
8577
|
+
function emptyFunctionWithReset() {}
|
|
8578
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
8579
|
+
|
|
8580
|
+
factoryWithThrowingShims = function() {
|
|
8581
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
8582
|
+
if (secret === ReactPropTypesSecret) {
|
|
8583
|
+
// It is still safe when called from React.
|
|
8584
|
+
return;
|
|
8585
|
+
}
|
|
8586
|
+
var err = new Error(
|
|
8587
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
8588
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
8589
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
8590
|
+
);
|
|
8591
|
+
err.name = 'Invariant Violation';
|
|
8592
|
+
throw err;
|
|
8593
|
+
} shim.isRequired = shim;
|
|
8594
|
+
function getShim() {
|
|
8595
|
+
return shim;
|
|
8596
|
+
} // Important!
|
|
8597
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
8598
|
+
var ReactPropTypes = {
|
|
8599
|
+
array: shim,
|
|
8600
|
+
bigint: shim,
|
|
8601
|
+
bool: shim,
|
|
8602
|
+
func: shim,
|
|
8603
|
+
number: shim,
|
|
8604
|
+
object: shim,
|
|
8605
|
+
string: shim,
|
|
8606
|
+
symbol: shim,
|
|
8607
|
+
|
|
8608
|
+
any: shim,
|
|
8609
|
+
arrayOf: getShim,
|
|
8610
|
+
element: shim,
|
|
8611
|
+
elementType: shim,
|
|
8612
|
+
instanceOf: getShim,
|
|
8613
|
+
node: shim,
|
|
8614
|
+
objectOf: getShim,
|
|
8615
|
+
oneOf: getShim,
|
|
8616
|
+
oneOfType: getShim,
|
|
8617
|
+
shape: getShim,
|
|
8618
|
+
exact: getShim,
|
|
8619
|
+
|
|
8620
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
8621
|
+
resetWarningCache: emptyFunction
|
|
8622
|
+
};
|
|
8623
|
+
|
|
8624
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
8625
|
+
|
|
8626
|
+
return ReactPropTypes;
|
|
8627
|
+
};
|
|
8628
|
+
return factoryWithThrowingShims;
|
|
8629
|
+
}
|
|
8630
|
+
|
|
8631
|
+
/**
|
|
8632
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
8633
|
+
*
|
|
8634
|
+
* This source code is licensed under the MIT license found in the
|
|
8635
|
+
* LICENSE file in the root directory of this source tree.
|
|
8636
|
+
*/
|
|
8637
|
+
|
|
8638
|
+
var hasRequiredPropTypes;
|
|
8639
|
+
|
|
8640
|
+
function requirePropTypes () {
|
|
8641
|
+
if (hasRequiredPropTypes) return propTypes.exports;
|
|
8642
|
+
hasRequiredPropTypes = 1;
|
|
8643
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8644
|
+
var ReactIs = requireReactIs();
|
|
8645
|
+
|
|
8646
|
+
// By explicitly using `prop-types` you are opting into new development behavior.
|
|
8647
|
+
// http://fb.me/prop-types-in-prod
|
|
8648
|
+
var throwOnDirectAccess = true;
|
|
8649
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
|
|
8650
|
+
} else {
|
|
8651
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
8652
|
+
// http://fb.me/prop-types-in-prod
|
|
8653
|
+
propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
|
|
8654
|
+
}
|
|
8655
|
+
return propTypes.exports;
|
|
8656
|
+
}
|
|
8657
|
+
|
|
8658
|
+
var propTypesExports = /*@__PURE__*/ requirePropTypes();
|
|
8659
|
+
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
8660
|
+
|
|
8661
|
+
/**
|
|
8662
|
+
* DateTimeInput (redesigned) - matches RangePicker visual style with dropdown panel.
|
|
8663
|
+
* Features:
|
|
8664
|
+
* - Single date (and optional time) selection via custom calendar popup
|
|
8665
|
+
* - URL param sync (stores timestamp) same as RangePicker
|
|
8666
|
+
* - Dynamic dropdown positioning (prevents overflow like RangePicker)
|
|
8667
|
+
* - Clear & OK footer actions
|
|
8668
|
+
*/
|
|
8669
|
+
function DateTimeInput({
|
|
8670
|
+
pushUrlParamObj = false,
|
|
8671
|
+
value: controlledValue,
|
|
8672
|
+
onChange,
|
|
8673
|
+
time = false,
|
|
8674
|
+
timeStart,
|
|
8675
|
+
timezone,
|
|
8676
|
+
timeFormat,
|
|
8677
|
+
dateFormat,
|
|
8678
|
+
placeholder = "Select date",
|
|
8679
|
+
disabled = false,
|
|
8680
|
+
className = "",
|
|
8681
|
+
style = {},
|
|
8682
|
+
predefinedRanges = ["today", "yesterday"],
|
|
8683
|
+
...rest
|
|
8684
|
+
}) {
|
|
8685
|
+
const paramKey = pushUrlParamObj || null;
|
|
8686
|
+
|
|
8687
|
+
// Helper: convert timestamp (number|string) to internal input string
|
|
8688
|
+
const toInputString = React.useCallback(ts => {
|
|
8689
|
+
if (!ts) return "";
|
|
8690
|
+
const d = new Date(Number(ts));
|
|
8691
|
+
if (isNaN(d.getTime())) return "";
|
|
8692
|
+
const yyyy = d.getFullYear();
|
|
8693
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
8694
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
8695
|
+
if (time) {
|
|
8696
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
8697
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
8698
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
8699
|
+
}
|
|
8700
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
8701
|
+
}, [time]);
|
|
8702
|
+
|
|
8703
|
+
// Initial value
|
|
8704
|
+
const [value, setValue] = React.useState(() => {
|
|
8705
|
+
if (typeof controlledValue !== "undefined") return controlledValue;
|
|
8706
|
+
if (!paramKey) {
|
|
8707
|
+
let d = new Date();
|
|
8708
|
+
if (time && timeStart) {
|
|
8709
|
+
const [h, m] = timeStart.split(":");
|
|
8710
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8711
|
+
}
|
|
8712
|
+
return toInputString(d.getTime());
|
|
8713
|
+
}
|
|
8714
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
8715
|
+
const urlVal = params.get(paramKey);
|
|
8716
|
+
if (urlVal) return toInputString(urlVal);
|
|
8717
|
+
let d = new Date();
|
|
8718
|
+
if (time && timeStart) {
|
|
8719
|
+
const [h, m] = timeStart.split(":");
|
|
8720
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8721
|
+
}
|
|
8722
|
+
return toInputString(d.getTime());
|
|
8723
|
+
});
|
|
8724
|
+
|
|
8725
|
+
// Dropdown state & positioning
|
|
8726
|
+
const [open, setOpen] = React.useState(false);
|
|
8727
|
+
const dropdownRef = React.useRef(null);
|
|
8728
|
+
const [dropdownPosition, setDropdownPosition] = React.useState({
|
|
8729
|
+
left: 0,
|
|
8730
|
+
top: "110%"
|
|
8731
|
+
});
|
|
8732
|
+
|
|
8733
|
+
// Predefined single-date shortcuts
|
|
8734
|
+
const normalizeLabel = lbl => String(lbl).toLowerCase();
|
|
8735
|
+
const createPredefinedItem = React.useCallback(item => {
|
|
8736
|
+
if (typeof item === 'number') {
|
|
8737
|
+
// number => N days ago
|
|
8738
|
+
return {
|
|
8739
|
+
key: `daysago_${item}`,
|
|
8740
|
+
label: `-${item}d`,
|
|
8741
|
+
getDate: () => {
|
|
8742
|
+
const d = new Date();
|
|
8743
|
+
d.setHours(0, 0, 0, 0);
|
|
8744
|
+
d.setDate(d.getDate() - item);
|
|
8745
|
+
return d;
|
|
8746
|
+
}
|
|
8747
|
+
};
|
|
8748
|
+
}
|
|
8749
|
+
const str = normalizeLabel(item);
|
|
8750
|
+
if (str === 'today') {
|
|
8751
|
+
return {
|
|
8752
|
+
key: 'today',
|
|
8753
|
+
label: 'Today',
|
|
8754
|
+
getDate: () => {
|
|
8755
|
+
const d = new Date();
|
|
8756
|
+
d.setHours(0, 0, 0, 0);
|
|
8757
|
+
return d;
|
|
8758
|
+
}
|
|
8759
|
+
};
|
|
8760
|
+
}
|
|
8761
|
+
if (str === 'yesterday') {
|
|
8762
|
+
return {
|
|
8763
|
+
key: 'yesterday',
|
|
8764
|
+
label: 'Yesterday',
|
|
8765
|
+
getDate: () => {
|
|
8766
|
+
const d = new Date();
|
|
8767
|
+
d.setHours(0, 0, 0, 0);
|
|
8768
|
+
d.setDate(d.getDate() - 1);
|
|
8769
|
+
return d;
|
|
8770
|
+
}
|
|
8771
|
+
};
|
|
8772
|
+
}
|
|
8773
|
+
if (str === 'lastweek') {
|
|
8774
|
+
return {
|
|
8775
|
+
key: 'lastweek',
|
|
8776
|
+
label: 'Last week (Mon)',
|
|
8777
|
+
getDate: () => {
|
|
8778
|
+
// Monday of previous week
|
|
8779
|
+
const d = new Date();
|
|
8780
|
+
d.setHours(0, 0, 0, 0);
|
|
8781
|
+
const day = d.getDay(); // 0 Sun..6 Sat
|
|
8782
|
+
const mondayOffset = day === 0 ? -6 : 1 - day; // days to monday this week
|
|
8783
|
+
d.setDate(d.getDate() + mondayOffset - 7); // previous week's Monday
|
|
8784
|
+
return d;
|
|
8785
|
+
}
|
|
8786
|
+
};
|
|
8787
|
+
}
|
|
8788
|
+
if (str === 'lastmonth') {
|
|
8789
|
+
return {
|
|
8790
|
+
key: 'lastmonth',
|
|
8791
|
+
label: 'First day last month',
|
|
8792
|
+
getDate: () => {
|
|
8793
|
+
const d = new Date();
|
|
8794
|
+
d.setHours(0, 0, 0, 0);
|
|
8795
|
+
d.setMonth(d.getMonth() - 1, 1);
|
|
8796
|
+
return d;
|
|
8797
|
+
}
|
|
8798
|
+
};
|
|
8799
|
+
}
|
|
8800
|
+
if (str === 'thismonth') {
|
|
8801
|
+
return {
|
|
8802
|
+
key: 'thismonth',
|
|
8803
|
+
label: 'First day this month',
|
|
8804
|
+
getDate: () => {
|
|
8805
|
+
const d = new Date();
|
|
8806
|
+
d.setHours(0, 0, 0, 0);
|
|
8807
|
+
d.setDate(1);
|
|
8808
|
+
return d;
|
|
8809
|
+
}
|
|
8810
|
+
};
|
|
8811
|
+
}
|
|
8812
|
+
if (str === 'lastyear') {
|
|
8813
|
+
return {
|
|
8814
|
+
key: 'lastyear',
|
|
8815
|
+
label: 'Jan 1 last year',
|
|
8816
|
+
getDate: () => {
|
|
8817
|
+
const d = new Date();
|
|
8818
|
+
d.setHours(0, 0, 0, 0);
|
|
8819
|
+
d.setFullYear(d.getFullYear() - 1, 0, 1);
|
|
8820
|
+
return d;
|
|
8821
|
+
}
|
|
8822
|
+
};
|
|
8823
|
+
}
|
|
8824
|
+
return {
|
|
8825
|
+
key: str,
|
|
8826
|
+
label: item,
|
|
8827
|
+
getDate: () => {
|
|
8828
|
+
const d = new Date();
|
|
8829
|
+
d.setHours(0, 0, 0, 0);
|
|
8830
|
+
return d;
|
|
8831
|
+
}
|
|
8832
|
+
};
|
|
8833
|
+
}, []);
|
|
8834
|
+
const PREDEFINED = React.useMemo(() => predefinedRanges.map(createPredefinedItem), [predefinedRanges, createPredefinedItem]);
|
|
8835
|
+
const [selectedPredefined, setSelectedPredefined] = React.useState("");
|
|
8836
|
+
React.useEffect(() => {
|
|
8837
|
+
if (open && dropdownRef.current) {
|
|
8838
|
+
const rect = dropdownRef.current.getBoundingClientRect();
|
|
8839
|
+
const viewportWidth = window.innerWidth;
|
|
8840
|
+
const viewportHeight = window.innerHeight;
|
|
8841
|
+
const newPosition = {
|
|
8842
|
+
left: '0',
|
|
8843
|
+
top: '110%'
|
|
8844
|
+
};
|
|
8845
|
+
if (rect.right > viewportWidth - 10) newPosition.right = 0, delete newPosition.left; // align right
|
|
8846
|
+
if (rect.bottom > viewportHeight - 10) newPosition.top = 'auto', newPosition.bottom = '110%';
|
|
8847
|
+
setDropdownPosition(newPosition);
|
|
8848
|
+
}
|
|
8849
|
+
}, [open]);
|
|
8850
|
+
|
|
8851
|
+
// Calendar month state (always show month of selected value; allow navigation)
|
|
8852
|
+
const selectedDate = React.useMemo(() => value ? new Date(value) : null, [value]);
|
|
8853
|
+
const [monthCursor, setMonthCursor] = React.useState(() => {
|
|
8854
|
+
const d = selectedDate || new Date();
|
|
8855
|
+
return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);
|
|
8856
|
+
});
|
|
8857
|
+
// Keep monthCursor in sync when selected date changes externally
|
|
8858
|
+
React.useEffect(() => {
|
|
8859
|
+
if (selectedDate) {
|
|
8860
|
+
setMonthCursor(new Date(selectedDate.getFullYear(), selectedDate.getMonth(), 1));
|
|
8861
|
+
}
|
|
8862
|
+
// Match predefined
|
|
8863
|
+
if (selectedDate) {
|
|
8864
|
+
const ts = selectedDate.getTime();
|
|
8865
|
+
for (let i = 0; i < PREDEFINED.length; i++) {
|
|
8866
|
+
const d = PREDEFINED[i].getDate();
|
|
8867
|
+
if (d.getTime() === ts) {
|
|
8868
|
+
setSelectedPredefined(String(i));
|
|
8869
|
+
return;
|
|
8870
|
+
}
|
|
8871
|
+
}
|
|
8872
|
+
setSelectedPredefined("");
|
|
8873
|
+
} else {
|
|
8874
|
+
setSelectedPredefined("");
|
|
8875
|
+
}
|
|
8876
|
+
}, [value, selectedDate, PREDEFINED]);
|
|
8877
|
+
|
|
8878
|
+
// Build calendar days (6 weeks grid)
|
|
8879
|
+
const buildDays = () => {
|
|
8880
|
+
const startOfMonth = new Date(monthCursor.getFullYear(), monthCursor.getMonth(), 1);
|
|
8881
|
+
const dayOfWeek = startOfMonth.getDay(); // 0 Sun ... 6 Sat
|
|
8882
|
+
// We start at Sunday of the week containing the 1st
|
|
8883
|
+
const firstGridDate = new Date(startOfMonth);
|
|
8884
|
+
firstGridDate.setDate(startOfMonth.getDate() - dayOfWeek);
|
|
8885
|
+
const days = [];
|
|
8886
|
+
for (let i = 0; i < 42; i++) {
|
|
8887
|
+
// 6 weeks
|
|
8888
|
+
const d = new Date(firstGridDate);
|
|
8889
|
+
d.setDate(firstGridDate.getDate() + i);
|
|
8890
|
+
days.push(d);
|
|
8891
|
+
}
|
|
8892
|
+
return days;
|
|
8893
|
+
};
|
|
8894
|
+
const days = buildDays();
|
|
8895
|
+
|
|
8896
|
+
// Update URL param
|
|
8897
|
+
const setUrlParam = React.useCallback(val => {
|
|
8898
|
+
if (!paramKey) return;
|
|
8899
|
+
const params = new URLSearchParams(window.location.search);
|
|
8900
|
+
let ts = val;
|
|
8901
|
+
if (val && typeof val === "string" && !/^[0-9]+$/.test(val)) {
|
|
8902
|
+
const d = new Date(val);
|
|
8903
|
+
ts = d.getTime();
|
|
8904
|
+
}
|
|
8905
|
+
if (ts && String(ts).length > 0 && !isNaN(Number(ts))) params.set(paramKey, String(ts));else params.delete(paramKey);
|
|
8906
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
8907
|
+
window.history.replaceState({}, "", newUrl);
|
|
8908
|
+
}, [paramKey]);
|
|
8909
|
+
|
|
8910
|
+
// Sync from URL
|
|
8911
|
+
React.useEffect(() => {
|
|
8912
|
+
if (!paramKey || typeof controlledValue !== 'undefined') return;
|
|
8913
|
+
const syncFromUrl = () => {
|
|
8914
|
+
const params = new URLSearchParams(window.location.search);
|
|
8915
|
+
const urlVal = params.get(paramKey);
|
|
8916
|
+
if (urlVal) {
|
|
8917
|
+
const str = toInputString(urlVal);
|
|
8918
|
+
setValue(prev => prev !== str ? str : prev);
|
|
8919
|
+
if (onChange && str !== controlledValue) onChange(urlVal);
|
|
8920
|
+
}
|
|
8921
|
+
};
|
|
8922
|
+
syncFromUrl();
|
|
8923
|
+
window.addEventListener('popstate', syncFromUrl);
|
|
8924
|
+
const patchHistory = type => {
|
|
8925
|
+
const orig = window.history[type];
|
|
8926
|
+
window.history[type] = function () {
|
|
8927
|
+
const rv = orig.apply(this, arguments);
|
|
8928
|
+
window.dispatchEvent(new Event(type));
|
|
8929
|
+
return rv;
|
|
8930
|
+
};
|
|
8931
|
+
};
|
|
8932
|
+
patchHistory('pushState');
|
|
8933
|
+
patchHistory('replaceState');
|
|
8934
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
8935
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
8936
|
+
return () => {
|
|
8937
|
+
window.removeEventListener('popstate', syncFromUrl);
|
|
8938
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
8939
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
8940
|
+
};
|
|
8941
|
+
}, [paramKey, controlledValue, onChange, toInputString]);
|
|
8942
|
+
|
|
8943
|
+
// Controlled value sync
|
|
8944
|
+
React.useEffect(() => {
|
|
8945
|
+
if (typeof controlledValue !== 'undefined') setValue(controlledValue);
|
|
8946
|
+
}, [controlledValue]);
|
|
8947
|
+
|
|
8948
|
+
// Formatting display (similar to RangePicker)
|
|
8949
|
+
const formatDisplay = () => {
|
|
8950
|
+
if (!value) return "";
|
|
8951
|
+
const d = new Date(value);
|
|
8952
|
+
if (isNaN(d.getTime())) return "";
|
|
8953
|
+
const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
|
|
8954
|
+
const yyyy = d.getFullYear();
|
|
8955
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
8956
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
8957
|
+
let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
|
|
8958
|
+
if (time) {
|
|
8959
|
+
const actualTimeFormat = timeFormat || 'HH:mm';
|
|
8960
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
8961
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
8962
|
+
const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
|
|
8963
|
+
return `${dateStr} ${timeStr}`;
|
|
8964
|
+
}
|
|
8965
|
+
return dateStr;
|
|
8966
|
+
};
|
|
8967
|
+
const applySelection = d => {
|
|
8968
|
+
const dt = new Date(d);
|
|
8969
|
+
if (time && timeStart && !value) {
|
|
8970
|
+
// apply timeStart if initial selection
|
|
8971
|
+
const [h, m] = timeStart.split(":");
|
|
8972
|
+
dt.setHours(Number(h), Number(m), 0, 0);
|
|
8973
|
+
}
|
|
8974
|
+
const str = toInputString(dt.getTime());
|
|
8975
|
+
if (typeof controlledValue === 'undefined') setValue(str);
|
|
8976
|
+
setUrlParam(str);
|
|
8977
|
+
onChange?.(str);
|
|
8978
|
+
};
|
|
8979
|
+
const handlePredefinedClick = idx => {
|
|
8980
|
+
const item = PREDEFINED[idx];
|
|
8981
|
+
const d = item.getDate();
|
|
8982
|
+
if (time && timeStart) {
|
|
8983
|
+
const [h, m] = (timeStart || "00:00").split(":");
|
|
8984
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8985
|
+
}
|
|
8986
|
+
applySelection(d);
|
|
8987
|
+
setSelectedPredefined(String(idx));
|
|
8988
|
+
};
|
|
8989
|
+
const handleDayClick = day => {
|
|
8990
|
+
applySelection(day);
|
|
8991
|
+
};
|
|
8992
|
+
const handleTimeChange = e => {
|
|
8993
|
+
const t = e.target.value; // HH:mm
|
|
8994
|
+
if (!value) return;
|
|
8995
|
+
const d = new Date(value);
|
|
8996
|
+
const [h, m] = t.split(":");
|
|
8997
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
8998
|
+
const str = toInputString(d.getTime());
|
|
8999
|
+
if (typeof controlledValue === 'undefined') setValue(str);
|
|
9000
|
+
setUrlParam(str);
|
|
9001
|
+
onChange?.(str);
|
|
9002
|
+
};
|
|
9003
|
+
const handleClear = () => {
|
|
9004
|
+
if (typeof controlledValue === 'undefined') setValue("");
|
|
9005
|
+
setUrlParam("");
|
|
9006
|
+
onChange?.("");
|
|
9007
|
+
};
|
|
9008
|
+
|
|
9009
|
+
// Outside click close
|
|
9010
|
+
React.useEffect(() => {
|
|
9011
|
+
if (!open) return;
|
|
9012
|
+
const onClick = e => {
|
|
9013
|
+
if (!e.target.closest('.datetime-input-dropdown')) setOpen(false);
|
|
9014
|
+
};
|
|
9015
|
+
window.addEventListener('mousedown', onClick);
|
|
9016
|
+
return () => window.removeEventListener('mousedown', onClick);
|
|
9017
|
+
}, [open]);
|
|
9018
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
9019
|
+
className: `datetime-input-wrapper ${className}`,
|
|
9020
|
+
style: {
|
|
9021
|
+
position: 'relative',
|
|
9022
|
+
display: 'inline-block',
|
|
9023
|
+
...style
|
|
9024
|
+
}
|
|
9025
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
9026
|
+
className: "basic-input",
|
|
9027
|
+
onClick: () => !disabled && setOpen(o => !o),
|
|
9028
|
+
style: {
|
|
9029
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
9030
|
+
padding: '6px 8px',
|
|
9031
|
+
minWidth: 180,
|
|
9032
|
+
userSelect: 'none',
|
|
9033
|
+
position: 'relative'
|
|
9034
|
+
},
|
|
9035
|
+
"data-timestart": timeStart || undefined,
|
|
9036
|
+
"data-timezone": timezone || undefined,
|
|
9037
|
+
"data-timeformat": timeFormat || undefined,
|
|
9038
|
+
"data-dateformat": dateFormat || undefined
|
|
9039
|
+
}, formatDisplay() || placeholder, value && /*#__PURE__*/React.createElement("span", {
|
|
9040
|
+
onClick: e => {
|
|
9041
|
+
e.stopPropagation();
|
|
9042
|
+
handleClear();
|
|
9043
|
+
},
|
|
9044
|
+
title: "Clear date",
|
|
9045
|
+
style: {
|
|
9046
|
+
position: 'absolute',
|
|
9047
|
+
right: 8,
|
|
9048
|
+
top: '50%',
|
|
9049
|
+
transform: 'translateY(-50%)',
|
|
9050
|
+
fontSize: 12,
|
|
9051
|
+
cursor: 'pointer'
|
|
9052
|
+
}
|
|
9053
|
+
}, "\u2716")), open && /*#__PURE__*/React.createElement("div", {
|
|
9054
|
+
ref: dropdownRef,
|
|
9055
|
+
className: "datetime-input-dropdown range-picker-dropdown" // reuse class for styling consistency
|
|
9056
|
+
,
|
|
9057
|
+
style: {
|
|
9058
|
+
position: 'absolute',
|
|
9059
|
+
zIndex: 50,
|
|
9060
|
+
background: '#fff',
|
|
9061
|
+
border: '1px solid #d9d9d9',
|
|
9062
|
+
borderRadius: 4,
|
|
9063
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
|
|
9064
|
+
padding: 12,
|
|
9065
|
+
width: 320,
|
|
9066
|
+
...dropdownPosition
|
|
9067
|
+
}
|
|
9068
|
+
}, PREDEFINED.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
9069
|
+
style: {
|
|
9070
|
+
display: 'flex',
|
|
9071
|
+
flexWrap: 'wrap',
|
|
9072
|
+
gap: 6,
|
|
9073
|
+
marginBottom: 8
|
|
9074
|
+
}
|
|
9075
|
+
}, PREDEFINED.map((p, i) => {
|
|
9076
|
+
const active = selectedPredefined === String(i);
|
|
9077
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
9078
|
+
key: p.key,
|
|
9079
|
+
type: "button",
|
|
9080
|
+
onClick: () => handlePredefinedClick(i),
|
|
9081
|
+
className: "basic-btn",
|
|
9082
|
+
style: {
|
|
9083
|
+
padding: '4px 8px',
|
|
9084
|
+
fontSize: 12,
|
|
9085
|
+
background: active ? '#1677ff' : '#fff',
|
|
9086
|
+
color: active ? '#fff' : '#000',
|
|
9087
|
+
border: active ? '1px solid #1677ff' : '1px solid #d9d9d9'
|
|
9088
|
+
}
|
|
9089
|
+
}, p.label);
|
|
9090
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
9091
|
+
style: {
|
|
9092
|
+
display: 'flex',
|
|
9093
|
+
justifyContent: 'space-between',
|
|
9094
|
+
alignItems: 'center',
|
|
9095
|
+
marginBottom: 8
|
|
9096
|
+
}
|
|
9097
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
9098
|
+
type: "button",
|
|
9099
|
+
className: "basic-btn",
|
|
9100
|
+
onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() - 1, 1))
|
|
9101
|
+
}, "\u2039"), /*#__PURE__*/React.createElement("div", {
|
|
9102
|
+
style: {
|
|
9103
|
+
fontWeight: 600
|
|
9104
|
+
}
|
|
9105
|
+
}, monthCursor.toLocaleString(undefined, {
|
|
9106
|
+
month: 'long'
|
|
9107
|
+
}), " ", monthCursor.getFullYear()), /*#__PURE__*/React.createElement("button", {
|
|
9108
|
+
type: "button",
|
|
9109
|
+
className: "basic-btn",
|
|
9110
|
+
onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() + 1, 1))
|
|
9111
|
+
}, "\u203A")), /*#__PURE__*/React.createElement("div", {
|
|
9112
|
+
style: {
|
|
9113
|
+
display: 'grid',
|
|
9114
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
9115
|
+
fontSize: 12,
|
|
9116
|
+
marginBottom: 4,
|
|
9117
|
+
opacity: 0.8
|
|
9118
|
+
}
|
|
9119
|
+
}, ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(d => /*#__PURE__*/React.createElement("div", {
|
|
9120
|
+
key: d,
|
|
9121
|
+
style: {
|
|
9122
|
+
textAlign: 'center'
|
|
9123
|
+
}
|
|
9124
|
+
}, d))), /*#__PURE__*/React.createElement("div", {
|
|
9125
|
+
style: {
|
|
9126
|
+
display: 'grid',
|
|
9127
|
+
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
9128
|
+
gap: 2
|
|
9129
|
+
}
|
|
9130
|
+
}, days.map(d => {
|
|
9131
|
+
const isCurrentMonth = d.getMonth() === monthCursor.getMonth();
|
|
9132
|
+
const isSelected = selectedDate && d.getFullYear() === selectedDate.getFullYear() && d.getMonth() === selectedDate.getMonth() && d.getDate() === selectedDate.getDate();
|
|
9133
|
+
const isToday = (() => {
|
|
9134
|
+
const t = new Date();
|
|
9135
|
+
return t.getFullYear() === d.getFullYear() && t.getMonth() === d.getMonth() && t.getDate() === d.getDate();
|
|
9136
|
+
})();
|
|
9137
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9138
|
+
key: d.toISOString(),
|
|
9139
|
+
onClick: () => handleDayClick(d),
|
|
9140
|
+
style: {
|
|
9141
|
+
textAlign: 'center',
|
|
9142
|
+
padding: '6px 0',
|
|
9143
|
+
cursor: 'pointer',
|
|
9144
|
+
fontSize: 12,
|
|
9145
|
+
borderRadius: 4,
|
|
9146
|
+
background: isSelected ? '#1677ff' : isToday ? '#e6f4ff' : 'transparent',
|
|
9147
|
+
color: isSelected ? '#fff' : isCurrentMonth ? '#000' : '#aaa',
|
|
9148
|
+
border: isSelected ? '1px solid #1677ff' : '1px solid transparent'
|
|
9149
|
+
}
|
|
9150
|
+
}, d.getDate());
|
|
9151
|
+
})), time && /*#__PURE__*/React.createElement("div", {
|
|
9152
|
+
style: {
|
|
9153
|
+
marginTop: 10
|
|
9154
|
+
}
|
|
9155
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
9156
|
+
style: {
|
|
9157
|
+
fontSize: 12,
|
|
9158
|
+
display: 'block',
|
|
9159
|
+
marginBottom: 4
|
|
9160
|
+
}
|
|
9161
|
+
}, "Time:"), /*#__PURE__*/React.createElement("input", {
|
|
9162
|
+
type: "time",
|
|
9163
|
+
value: (() => {
|
|
9164
|
+
if (!value) return '';
|
|
9165
|
+
const d = new Date(value);
|
|
9166
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9167
|
+
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
9168
|
+
return `${hh}:${mm}`;
|
|
9169
|
+
})(),
|
|
9170
|
+
onChange: handleTimeChange,
|
|
9171
|
+
className: "basic-input",
|
|
9172
|
+
style: {
|
|
9173
|
+
width: '100%'
|
|
9174
|
+
}
|
|
9175
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
9176
|
+
style: {
|
|
9177
|
+
display: 'flex',
|
|
9178
|
+
justifyContent: 'space-between',
|
|
9179
|
+
alignItems: 'center',
|
|
9180
|
+
marginTop: 12
|
|
9181
|
+
}
|
|
9182
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9183
|
+
style: {
|
|
9184
|
+
display: 'flex',
|
|
9185
|
+
gap: 8
|
|
9186
|
+
}
|
|
9187
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
9188
|
+
type: "button",
|
|
9189
|
+
className: "basic-btn",
|
|
9190
|
+
onClick: () => {
|
|
9191
|
+
handleClear();
|
|
9192
|
+
}
|
|
9193
|
+
}, "Clear"), /*#__PURE__*/React.createElement("button", {
|
|
9194
|
+
type: "button",
|
|
9195
|
+
className: "basic-btn",
|
|
9196
|
+
onClick: () => {
|
|
9197
|
+
setOpen(false);
|
|
9198
|
+
}
|
|
9199
|
+
}, "OK")), /*#__PURE__*/React.createElement("button", {
|
|
9200
|
+
type: "button",
|
|
9201
|
+
className: "basic-btn",
|
|
9202
|
+
onClick: () => {
|
|
9203
|
+
handlePredefinedClick(PREDEFINED.findIndex(p => p.key === 'today'));
|
|
9204
|
+
}
|
|
9205
|
+
}, "Today"))));
|
|
9206
|
+
}
|
|
9207
|
+
DateTimeInput.propTypes = {
|
|
9208
|
+
pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
9209
|
+
value: PropTypes.string,
|
|
9210
|
+
onChange: PropTypes.func,
|
|
9211
|
+
time: PropTypes.bool,
|
|
9212
|
+
timeStart: PropTypes.string,
|
|
9213
|
+
timezone: PropTypes.string,
|
|
9214
|
+
timeFormat: PropTypes.string,
|
|
9215
|
+
dateFormat: PropTypes.string,
|
|
9216
|
+
placeholder: PropTypes.string,
|
|
9217
|
+
disabled: PropTypes.bool,
|
|
9218
|
+
className: PropTypes.string,
|
|
9219
|
+
style: PropTypes.object,
|
|
9220
|
+
predefinedRanges: PropTypes.array
|
|
9221
|
+
};
|
|
9222
|
+
|
|
9223
|
+
/**
|
|
9224
|
+
* CalendarRangePicker - Custom calendar UI for selecting date ranges
|
|
9225
|
+
* Props:
|
|
9226
|
+
* startDate: Date | null
|
|
9227
|
+
* endDate: Date | null
|
|
9228
|
+
* onChange: (startDate, endDate) => void
|
|
9229
|
+
* time: boolean - if true, show time selectors
|
|
9230
|
+
* timeStart, timeEnd: default times for start/end
|
|
9231
|
+
*/
|
|
9232
|
+
function CalendarRangePicker({
|
|
9233
|
+
startDate,
|
|
9234
|
+
endDate,
|
|
9235
|
+
onChange,
|
|
9236
|
+
time = false,
|
|
9237
|
+
timeStart = "00:00",
|
|
9238
|
+
timeEnd = "23:59"
|
|
9239
|
+
}) {
|
|
9240
|
+
// Current view months (show 2 months)
|
|
9241
|
+
const [leftMonth, setLeftMonth] = React.useState(() => {
|
|
9242
|
+
const d = startDate ? new Date(startDate) : new Date();
|
|
9243
|
+
return new Date(d.getFullYear(), d.getMonth(), 1);
|
|
9244
|
+
});
|
|
9245
|
+
const rightMonth = new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1);
|
|
9246
|
+
|
|
9247
|
+
// Update leftMonth when startDate changes (e.g., when selecting predefined ranges)
|
|
9248
|
+
React.useEffect(() => {
|
|
9249
|
+
if (startDate) {
|
|
9250
|
+
const d = new Date(startDate);
|
|
9251
|
+
setLeftMonth(new Date(d.getFullYear(), d.getMonth(), 1));
|
|
9252
|
+
}
|
|
9253
|
+
}, [startDate]);
|
|
9254
|
+
|
|
9255
|
+
// Hover state for preview
|
|
9256
|
+
const [hoverDate, setHoverDate] = React.useState(null);
|
|
9257
|
+
|
|
9258
|
+
// Navigate months
|
|
9259
|
+
const prevMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() - 1, 1));
|
|
9260
|
+
const nextMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1));
|
|
9261
|
+
|
|
9262
|
+
// Handle date click
|
|
9263
|
+
const handleDateClick = date => {
|
|
9264
|
+
const d = new Date(date);
|
|
9265
|
+
if (time && startDate && timeStart) {
|
|
9266
|
+
const [h, m] = timeStart.split(":");
|
|
9267
|
+
d.setHours(Number(h), Number(m), 0, 0);
|
|
9268
|
+
}
|
|
9269
|
+
if (!startDate || startDate && endDate) {
|
|
9270
|
+
// Start new range
|
|
9271
|
+
onChange(d, null);
|
|
9272
|
+
} else {
|
|
9273
|
+
// Complete range
|
|
9274
|
+
if (d < startDate) {
|
|
9275
|
+
onChange(d, startDate);
|
|
9276
|
+
} else {
|
|
9277
|
+
const endD = new Date(d);
|
|
9278
|
+
if (time && timeEnd) {
|
|
9279
|
+
const [h, m] = timeEnd.split(":");
|
|
9280
|
+
endD.setHours(Number(h), Number(m), 59, 999);
|
|
9281
|
+
}
|
|
9282
|
+
onChange(startDate, endD);
|
|
9283
|
+
}
|
|
9284
|
+
}
|
|
9285
|
+
};
|
|
9286
|
+
|
|
9287
|
+
// Check if date is in range
|
|
9288
|
+
const isInRange = date => {
|
|
9289
|
+
if (!startDate) return false;
|
|
9290
|
+
const check = endDate || hoverDate;
|
|
9291
|
+
if (!check) return false;
|
|
9292
|
+
const d = new Date(date).setHours(0, 0, 0, 0);
|
|
9293
|
+
const s = new Date(startDate).setHours(0, 0, 0, 0);
|
|
9294
|
+
const e = new Date(check).setHours(0, 0, 0, 0);
|
|
9295
|
+
return d >= Math.min(s, e) && d <= Math.max(s, e);
|
|
9296
|
+
};
|
|
9297
|
+
const isStartDate = date => {
|
|
9298
|
+
if (!startDate) return false;
|
|
9299
|
+
return new Date(date).setHours(0, 0, 0, 0) === new Date(startDate).setHours(0, 0, 0, 0);
|
|
9300
|
+
};
|
|
9301
|
+
const isEndDate = date => {
|
|
9302
|
+
if (!endDate) return false;
|
|
9303
|
+
return new Date(date).setHours(0, 0, 0, 0) === new Date(endDate).setHours(0, 0, 0, 0);
|
|
9304
|
+
};
|
|
9305
|
+
const isToday = date => {
|
|
9306
|
+
const today = new Date();
|
|
9307
|
+
return date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
|
|
9308
|
+
};
|
|
9309
|
+
|
|
9310
|
+
// Render a single month
|
|
9311
|
+
const renderMonth = month => {
|
|
9312
|
+
const year = month.getFullYear();
|
|
9313
|
+
const monthIdx = month.getMonth();
|
|
9314
|
+
const firstDay = new Date(year, monthIdx, 1);
|
|
9315
|
+
const lastDay = new Date(year, monthIdx + 1, 0);
|
|
9316
|
+
const startWeekday = firstDay.getDay(); // 0 = Sunday
|
|
9317
|
+
const daysInMonth = lastDay.getDate();
|
|
9318
|
+
const days = [];
|
|
9319
|
+
// Padding days from previous month
|
|
9320
|
+
const prevMonthLastDay = new Date(year, monthIdx, 0).getDate();
|
|
9321
|
+
for (let i = startWeekday - 1; i >= 0; i--) {
|
|
9322
|
+
days.push({
|
|
9323
|
+
date: new Date(year, monthIdx - 1, prevMonthLastDay - i),
|
|
9324
|
+
otherMonth: true
|
|
9325
|
+
});
|
|
9326
|
+
}
|
|
9327
|
+
// Current month days
|
|
9328
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
9329
|
+
days.push({
|
|
9330
|
+
date: new Date(year, monthIdx, d),
|
|
9331
|
+
otherMonth: false
|
|
9332
|
+
});
|
|
9333
|
+
}
|
|
9334
|
+
// Padding days from next month
|
|
9335
|
+
const remaining = 42 - days.length; // 6 rows * 7 days
|
|
9336
|
+
for (let d = 1; d <= remaining; d++) {
|
|
9337
|
+
days.push({
|
|
9338
|
+
date: new Date(year, monthIdx + 1, d),
|
|
9339
|
+
otherMonth: true
|
|
9340
|
+
});
|
|
9341
|
+
}
|
|
9342
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9343
|
+
style: {
|
|
9344
|
+
flex: 1,
|
|
9345
|
+
padding: "0 8px"
|
|
9346
|
+
}
|
|
9347
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9348
|
+
style: {
|
|
9349
|
+
textAlign: "center",
|
|
9350
|
+
fontWeight: "bold",
|
|
9351
|
+
marginBottom: 12,
|
|
9352
|
+
fontSize: 14
|
|
9353
|
+
}
|
|
9354
|
+
}, month.toLocaleDateString("en-US", {
|
|
9355
|
+
month: "short",
|
|
9356
|
+
year: "numeric"
|
|
9357
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
9358
|
+
style: {
|
|
9359
|
+
display: "grid",
|
|
9360
|
+
gridTemplateColumns: "repeat(7, 1fr)",
|
|
9361
|
+
gap: 2
|
|
9362
|
+
}
|
|
9363
|
+
}, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(day => /*#__PURE__*/React.createElement("div", {
|
|
9364
|
+
key: day,
|
|
9365
|
+
style: {
|
|
9366
|
+
textAlign: "center",
|
|
9367
|
+
fontSize: 11,
|
|
9368
|
+
color: "#666",
|
|
9369
|
+
fontWeight: 600,
|
|
9370
|
+
padding: "4px 0"
|
|
9371
|
+
}
|
|
9372
|
+
}, day)), days.map(({
|
|
9373
|
+
date,
|
|
9374
|
+
otherMonth
|
|
9375
|
+
}, idx) => {
|
|
9376
|
+
const inRange = isInRange(date);
|
|
9377
|
+
const isStart = isStartDate(date);
|
|
9378
|
+
const isEnd = isEndDate(date);
|
|
9379
|
+
const isCurrentDay = isToday(date);
|
|
9380
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9381
|
+
key: idx,
|
|
9382
|
+
onClick: () => !otherMonth && handleDateClick(date),
|
|
9383
|
+
onMouseEnter: () => !otherMonth && setHoverDate(date),
|
|
9384
|
+
style: {
|
|
9385
|
+
textAlign: "center",
|
|
9386
|
+
padding: "8px 4px",
|
|
9387
|
+
fontSize: 13,
|
|
9388
|
+
cursor: otherMonth ? "default" : "pointer",
|
|
9389
|
+
color: otherMonth ? "#ccc" : isStart || isEnd ? "#fff" : isCurrentDay ? "#1d4ed8" : "#333",
|
|
9390
|
+
fontWeight: isStart || isEnd || isCurrentDay ? "600" : "normal",
|
|
9391
|
+
background: isStart || isEnd ? "#1d4ed8" : inRange ? "#e0f2fe" : "transparent",
|
|
9392
|
+
borderRadius: isStart || isEnd ? "50%" : inRange ? 0 : 4,
|
|
9393
|
+
border: isCurrentDay && !isStart && !isEnd ? "1px solid #1d4ed8" : "none",
|
|
9394
|
+
userSelect: "none",
|
|
9395
|
+
transition: "all 0.15s ease"
|
|
9396
|
+
},
|
|
9397
|
+
onMouseOver: e => {
|
|
9398
|
+
if (!otherMonth && !isStart && !isEnd) {
|
|
9399
|
+
e.currentTarget.style.background = inRange ? "#bfdbfe" : "#f3f4f6";
|
|
9400
|
+
}
|
|
9401
|
+
},
|
|
9402
|
+
onMouseOut: e => {
|
|
9403
|
+
if (!otherMonth && !isStart && !isEnd) {
|
|
9404
|
+
e.currentTarget.style.background = inRange ? "#e0f2fe" : "transparent";
|
|
9405
|
+
}
|
|
9406
|
+
}
|
|
9407
|
+
}, date.getDate());
|
|
9408
|
+
})));
|
|
9409
|
+
};
|
|
9410
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9411
|
+
style: {
|
|
9412
|
+
minWidth: 560
|
|
9413
|
+
}
|
|
9414
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9415
|
+
style: {
|
|
9416
|
+
display: "flex",
|
|
9417
|
+
justifyContent: "space-between",
|
|
9418
|
+
alignItems: "center",
|
|
9419
|
+
marginBottom: 16
|
|
9420
|
+
}
|
|
9421
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
9422
|
+
onClick: prevMonth,
|
|
9423
|
+
style: {
|
|
9424
|
+
background: "none",
|
|
9425
|
+
border: "none",
|
|
9426
|
+
fontSize: 20,
|
|
9427
|
+
cursor: "pointer",
|
|
9428
|
+
padding: "4px 8px",
|
|
9429
|
+
color: "#333"
|
|
9430
|
+
}
|
|
9431
|
+
}, "\u2039\u2039"), /*#__PURE__*/React.createElement("div", {
|
|
9432
|
+
style: {
|
|
9433
|
+
fontWeight: "600",
|
|
9434
|
+
fontSize: 14,
|
|
9435
|
+
color: "#333"
|
|
9436
|
+
}
|
|
9437
|
+
}, leftMonth.toLocaleDateString("en-US", {
|
|
9438
|
+
month: "long",
|
|
9439
|
+
year: "numeric"
|
|
9440
|
+
}), " \u2013 ", rightMonth.toLocaleDateString("en-US", {
|
|
9441
|
+
month: "long",
|
|
9442
|
+
year: "numeric"
|
|
9443
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
9444
|
+
onClick: nextMonth,
|
|
9445
|
+
style: {
|
|
9446
|
+
background: "none",
|
|
9447
|
+
border: "none",
|
|
9448
|
+
fontSize: 20,
|
|
9449
|
+
cursor: "pointer",
|
|
9450
|
+
padding: "4px 8px",
|
|
9451
|
+
color: "#333"
|
|
9452
|
+
}
|
|
9453
|
+
}, "\u203A\u203A")), /*#__PURE__*/React.createElement("div", {
|
|
9454
|
+
style: {
|
|
9455
|
+
display: "flex",
|
|
9456
|
+
gap: 16
|
|
9457
|
+
},
|
|
9458
|
+
onMouseLeave: () => setHoverDate(null)
|
|
9459
|
+
}, renderMonth(leftMonth), renderMonth(rightMonth)));
|
|
9460
|
+
}
|
|
9461
|
+
CalendarRangePicker.propTypes = {
|
|
9462
|
+
startDate: PropTypes.instanceOf(Date),
|
|
9463
|
+
endDate: PropTypes.instanceOf(Date),
|
|
9464
|
+
onChange: PropTypes.func.isRequired,
|
|
9465
|
+
time: PropTypes.bool,
|
|
9466
|
+
timeStart: PropTypes.string,
|
|
9467
|
+
timeEnd: PropTypes.string
|
|
9468
|
+
};
|
|
9469
|
+
|
|
9470
|
+
/**
|
|
9471
|
+
* RangePicker - a reusable date or datetime-local range picker with URL param sync
|
|
9472
|
+
* Props:
|
|
9473
|
+
* pushUrlParamObj: string | false - URL param key to sync value (will store as start~end)
|
|
9474
|
+
* value: [start, end] controlled value (optional)
|
|
9475
|
+
* onChange: ([start, end]) => void (optional)
|
|
9476
|
+
* time: boolean - if true, use datetime-local, else date
|
|
9477
|
+
* timeStart: string (for default start time, e.g. "00:00")
|
|
9478
|
+
* timeEnd: string (for default end time, e.g. "23:59")
|
|
9479
|
+
* timezone, timeFormat, dateFormat, placeholder, required, disabled, className, style, min, max, ...rest
|
|
9480
|
+
*/
|
|
9481
|
+
// Helper to get date string in yyyy-MM-dd or yyyy-MM-ddTHH:mm
|
|
9482
|
+
function formatDate(date, time = false) {
|
|
9483
|
+
const yyyy = date.getFullYear();
|
|
9484
|
+
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
9485
|
+
const dd = String(date.getDate()).padStart(2, '0');
|
|
9486
|
+
if (time) {
|
|
9487
|
+
const hh = String(date.getHours()).padStart(2, '0');
|
|
9488
|
+
const min = String(date.getMinutes()).padStart(2, '0');
|
|
9489
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9490
|
+
}
|
|
9491
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9492
|
+
}
|
|
9493
|
+
const PREDEFINED_RANGES = [{
|
|
9494
|
+
label: 'Today',
|
|
9495
|
+
getRange: time => {
|
|
9496
|
+
const now = new Date();
|
|
9497
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
9498
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9499
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9500
|
+
}
|
|
9501
|
+
}, {
|
|
9502
|
+
label: 'This week',
|
|
9503
|
+
getRange: time => {
|
|
9504
|
+
const now = new Date();
|
|
9505
|
+
const day = now.getDay() || 7;
|
|
9506
|
+
const start = new Date(now);
|
|
9507
|
+
start.setDate(now.getDate() - day + 1);
|
|
9508
|
+
start.setHours(0, 0, 0, 0);
|
|
9509
|
+
const end = new Date(start);
|
|
9510
|
+
end.setDate(start.getDate() + 6);
|
|
9511
|
+
end.setHours(23, 59, 59, 999);
|
|
9512
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9513
|
+
}
|
|
9514
|
+
}, {
|
|
9515
|
+
label: 'Last 7 days',
|
|
9516
|
+
getRange: time => {
|
|
9517
|
+
const now = new Date();
|
|
9518
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9519
|
+
const start = new Date(end);
|
|
9520
|
+
start.setDate(end.getDate() - 6);
|
|
9521
|
+
start.setHours(0, 0, 0, 0);
|
|
9522
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9523
|
+
}
|
|
9524
|
+
}, {
|
|
9525
|
+
label: 'This month',
|
|
9526
|
+
getRange: time => {
|
|
9527
|
+
const now = new Date();
|
|
9528
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
|
|
9529
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
9530
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9531
|
+
}
|
|
9532
|
+
}, {
|
|
9533
|
+
label: 'Last 30 days',
|
|
9534
|
+
getRange: time => {
|
|
9535
|
+
const now = new Date();
|
|
9536
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9537
|
+
const start = new Date(end);
|
|
9538
|
+
start.setDate(end.getDate() - 29);
|
|
9539
|
+
start.setHours(0, 0, 0, 0);
|
|
9540
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9541
|
+
}
|
|
9542
|
+
}];
|
|
9543
|
+
|
|
9544
|
+
// Helper to create predefined range from simple format
|
|
9545
|
+
const createRangeFromSimple = (item, time) => {
|
|
9546
|
+
// If it's a number, treat as "last N days"
|
|
9547
|
+
if (typeof item === 'number') {
|
|
9548
|
+
return {
|
|
9549
|
+
label: `Last ${item} days`,
|
|
9550
|
+
getRange: time => {
|
|
9551
|
+
const now = new Date();
|
|
9552
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9553
|
+
const start = new Date(end);
|
|
9554
|
+
start.setDate(end.getDate() - (item - 1));
|
|
9555
|
+
start.setHours(0, 0, 0, 0);
|
|
9556
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9557
|
+
}
|
|
9558
|
+
};
|
|
9559
|
+
}
|
|
9560
|
+
|
|
9561
|
+
// If it's a string, map to predefined functions
|
|
9562
|
+
const lowerItem = item.toLowerCase();
|
|
9563
|
+
const rangeMap = {
|
|
9564
|
+
'today': {
|
|
9565
|
+
label: 'Today',
|
|
9566
|
+
getRange: time => {
|
|
9567
|
+
const now = new Date();
|
|
9568
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
|
|
9569
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
|
|
9570
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9571
|
+
}
|
|
9572
|
+
},
|
|
9573
|
+
'yesterday': {
|
|
9574
|
+
label: 'Yesterday',
|
|
9575
|
+
getRange: time => {
|
|
9576
|
+
const now = new Date();
|
|
9577
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0, 0);
|
|
9578
|
+
const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 23, 59, 59, 999);
|
|
9579
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9580
|
+
}
|
|
9581
|
+
},
|
|
9582
|
+
'thisweek': {
|
|
9583
|
+
label: 'This week',
|
|
9584
|
+
getRange: time => {
|
|
9585
|
+
const now = new Date();
|
|
9586
|
+
const day = now.getDay() || 7;
|
|
9587
|
+
const start = new Date(now);
|
|
9588
|
+
start.setDate(now.getDate() - day + 1);
|
|
9589
|
+
start.setHours(0, 0, 0, 0);
|
|
9590
|
+
const end = new Date(start);
|
|
9591
|
+
end.setDate(start.getDate() + 6);
|
|
9592
|
+
end.setHours(23, 59, 59, 999);
|
|
9593
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9594
|
+
}
|
|
9595
|
+
},
|
|
9596
|
+
'lastweek': {
|
|
9597
|
+
label: 'Last week',
|
|
9598
|
+
getRange: time => {
|
|
9599
|
+
const now = new Date();
|
|
9600
|
+
const day = now.getDay() || 7;
|
|
9601
|
+
const start = new Date(now);
|
|
9602
|
+
start.setDate(now.getDate() - day - 6);
|
|
9603
|
+
start.setHours(0, 0, 0, 0);
|
|
9604
|
+
const end = new Date(start);
|
|
9605
|
+
end.setDate(start.getDate() + 6);
|
|
9606
|
+
end.setHours(23, 59, 59, 999);
|
|
9607
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9608
|
+
}
|
|
9609
|
+
},
|
|
9610
|
+
'thismonth': {
|
|
9611
|
+
label: 'This month',
|
|
9612
|
+
getRange: time => {
|
|
9613
|
+
const now = new Date();
|
|
9614
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
|
|
9615
|
+
const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
9616
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9617
|
+
}
|
|
9618
|
+
},
|
|
9619
|
+
'lastmonth': {
|
|
9620
|
+
label: 'Last month',
|
|
9621
|
+
getRange: time => {
|
|
9622
|
+
const now = new Date();
|
|
9623
|
+
const start = new Date(now.getFullYear(), now.getMonth() - 1, 1, 0, 0, 0, 0);
|
|
9624
|
+
const end = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
|
|
9625
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9626
|
+
}
|
|
9627
|
+
},
|
|
9628
|
+
'thisyear': {
|
|
9629
|
+
label: 'This year',
|
|
9630
|
+
getRange: time => {
|
|
9631
|
+
const now = new Date();
|
|
9632
|
+
const start = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0);
|
|
9633
|
+
const end = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
9634
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9635
|
+
}
|
|
9636
|
+
},
|
|
9637
|
+
'lastyear': {
|
|
9638
|
+
label: 'Last year',
|
|
9639
|
+
getRange: time => {
|
|
9640
|
+
const now = new Date();
|
|
9641
|
+
const start = new Date(now.getFullYear() - 1, 0, 1, 0, 0, 0, 0);
|
|
9642
|
+
const end = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999);
|
|
9643
|
+
return [formatDate(start, time), formatDate(end, time)];
|
|
9644
|
+
}
|
|
9645
|
+
}
|
|
9646
|
+
};
|
|
9647
|
+
return rangeMap[lowerItem] || null;
|
|
9648
|
+
};
|
|
9649
|
+
function RangePicker({
|
|
9650
|
+
pushUrlParamObj = false,
|
|
9651
|
+
value: controlledValue,
|
|
9652
|
+
onChange,
|
|
9653
|
+
time = false,
|
|
9654
|
+
timeStart,
|
|
9655
|
+
timeEnd,
|
|
9656
|
+
timezone,
|
|
9657
|
+
timeFormat,
|
|
9658
|
+
dateFormat,
|
|
9659
|
+
placeholder = "",
|
|
9660
|
+
required = false,
|
|
9661
|
+
disabled = false,
|
|
9662
|
+
className = "",
|
|
9663
|
+
style = {},
|
|
9664
|
+
min,
|
|
9665
|
+
max,
|
|
9666
|
+
predefinedRanges = PREDEFINED_RANGES,
|
|
9667
|
+
...rest
|
|
9668
|
+
}) {
|
|
9669
|
+
const paramKey = pushUrlParamObj || null;
|
|
9670
|
+
|
|
9671
|
+
// Convert simple predefinedRanges to full format
|
|
9672
|
+
const processedRanges = Array.isArray(predefinedRanges) ? predefinedRanges.map(item => {
|
|
9673
|
+
// If it's already an object with label and getRange, use it as-is
|
|
9674
|
+
if (typeof item === 'object' && item.label && item.getRange) {
|
|
9675
|
+
return item;
|
|
9676
|
+
}
|
|
9677
|
+
// Otherwise, convert from simple format
|
|
9678
|
+
return createRangeFromSimple(item);
|
|
9679
|
+
}).filter(Boolean) : [];
|
|
9680
|
+
|
|
9681
|
+
// Helper to format default value
|
|
9682
|
+
const getDefault = which => {
|
|
9683
|
+
if (time) {
|
|
9684
|
+
const today = new Date();
|
|
9685
|
+
const yyyy = today.getFullYear();
|
|
9686
|
+
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
|
9687
|
+
const dd = String(today.getDate()).padStart(2, '0');
|
|
9688
|
+
if (which === 'start' && timeStart) return `${yyyy}-${mm}-${dd}T${timeStart}`;
|
|
9689
|
+
if (which === 'end' && timeEnd) return `${yyyy}-${mm}-${dd}T${timeEnd}`;
|
|
9690
|
+
// fallback to now
|
|
9691
|
+
const now = new Date();
|
|
9692
|
+
const hh = String(now.getHours()).padStart(2, '0');
|
|
9693
|
+
const min = String(now.getMinutes()).padStart(2, '0');
|
|
9694
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9695
|
+
}
|
|
9696
|
+
return "";
|
|
9697
|
+
};
|
|
9698
|
+
// Initial state
|
|
9699
|
+
const toInputString = ts => {
|
|
9700
|
+
if (!ts) return "";
|
|
9701
|
+
const d = new Date(Number(ts));
|
|
9702
|
+
if (isNaN(d.getTime())) return "";
|
|
9703
|
+
if (time) {
|
|
9704
|
+
const yyyy = d.getFullYear();
|
|
9705
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9706
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9707
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9708
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9709
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9710
|
+
} else {
|
|
9711
|
+
const yyyy = d.getFullYear();
|
|
9712
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9713
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9714
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9715
|
+
}
|
|
9716
|
+
};
|
|
9717
|
+
const [range, setRange] = React.useState(() => {
|
|
9718
|
+
if (controlledValue && Array.isArray(controlledValue)) return controlledValue;
|
|
9719
|
+
if (!paramKey) return [getDefault('start'), getDefault('end')];
|
|
9720
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
9721
|
+
const urlVal = params.get(paramKey);
|
|
9722
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9723
|
+
const [start, end] = urlVal.split('~');
|
|
9724
|
+
return [toInputString(start), toInputString(end)];
|
|
9725
|
+
}
|
|
9726
|
+
return [getDefault('start'), getDefault('end')];
|
|
9727
|
+
});
|
|
9728
|
+
// Track selected predefined range
|
|
9729
|
+
const [selectedRange, setSelectedRange] = React.useState(() => {
|
|
9730
|
+
// Initialize with matching predefined range if any
|
|
9731
|
+
if (!paramKey) return "";
|
|
9732
|
+
const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
|
|
9733
|
+
const urlVal = params.get(paramKey);
|
|
9734
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9735
|
+
const [start, end] = urlVal.split('~');
|
|
9736
|
+
// Check if this matches any predefined range
|
|
9737
|
+
for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
|
|
9738
|
+
const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
|
|
9739
|
+
if (new Date(pStart).getTime() === Number(start) && new Date(pEnd).getTime() === Number(end)) {
|
|
9740
|
+
return String(i);
|
|
9741
|
+
}
|
|
9742
|
+
}
|
|
9743
|
+
}
|
|
9744
|
+
return "";
|
|
9745
|
+
});
|
|
9746
|
+
|
|
9747
|
+
// Helper to check if a range matches a predefined range
|
|
9748
|
+
const findMatchingPredefined = (start, end) => {
|
|
9749
|
+
for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
|
|
9750
|
+
const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
|
|
9751
|
+
// Compare as timestamps for precision
|
|
9752
|
+
if (new Date(pStart).getTime() === new Date(start).getTime() && new Date(pEnd).getTime() === new Date(end).getTime()) {
|
|
9753
|
+
return String(i);
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
return "";
|
|
9757
|
+
};
|
|
9758
|
+
|
|
9759
|
+
// Sync with URL param on mount and popstate
|
|
9760
|
+
React.useEffect(() => {
|
|
9761
|
+
if (!paramKey || controlledValue && Array.isArray(controlledValue)) return;
|
|
9762
|
+
const syncFromUrl = () => {
|
|
9763
|
+
const params = new URLSearchParams(window.location.search);
|
|
9764
|
+
const urlVal = params.get(paramKey);
|
|
9765
|
+
if (urlVal && urlVal.includes('~')) {
|
|
9766
|
+
const [start, end] = urlVal.split('~');
|
|
9767
|
+
setRange(prev => prev[0] !== toInputString(start) || prev[1] !== toInputString(end) ? [toInputString(start), toInputString(end)] : prev);
|
|
9768
|
+
if (onChange && (range[0] !== toInputString(start) || range[1] !== toInputString(end))) onChange([start, end]);
|
|
9769
|
+
// Set dropdown if matches predefined
|
|
9770
|
+
const matchIdx = findMatchingPredefined(Number(start), Number(end));
|
|
9771
|
+
setSelectedRange(matchIdx);
|
|
9772
|
+
} else {
|
|
9773
|
+
setSelectedRange("");
|
|
9774
|
+
}
|
|
9775
|
+
};
|
|
9776
|
+
syncFromUrl();
|
|
9777
|
+
window.addEventListener("popstate", syncFromUrl);
|
|
9778
|
+
// Listen for pushState/replaceState (programmatic changes)
|
|
9779
|
+
const patchHistory = type => {
|
|
9780
|
+
const orig = window.history[type];
|
|
9781
|
+
window.history[type] = function () {
|
|
9782
|
+
const rv = orig.apply(this, arguments);
|
|
9783
|
+
window.dispatchEvent(new Event(type));
|
|
9784
|
+
return rv;
|
|
9785
|
+
};
|
|
9786
|
+
};
|
|
9787
|
+
patchHistory('pushState');
|
|
9788
|
+
patchHistory('replaceState');
|
|
9789
|
+
window.addEventListener('pushState', syncFromUrl);
|
|
9790
|
+
window.addEventListener('replaceState', syncFromUrl);
|
|
9791
|
+
return () => {
|
|
9792
|
+
window.removeEventListener("popstate", syncFromUrl);
|
|
9793
|
+
window.removeEventListener('pushState', syncFromUrl);
|
|
9794
|
+
window.removeEventListener('replaceState', syncFromUrl);
|
|
9795
|
+
};
|
|
9796
|
+
}, [paramKey, onChange]);
|
|
9797
|
+
|
|
9798
|
+
// If controlled, update local value when prop changes
|
|
9799
|
+
React.useEffect(() => {
|
|
9800
|
+
if (controlledValue && Array.isArray(controlledValue)) setRange(controlledValue);
|
|
9801
|
+
}, [controlledValue]);
|
|
9802
|
+
|
|
9803
|
+
// Update URL param
|
|
9804
|
+
const setUrlParam = React.useCallback(vals => {
|
|
9805
|
+
if (!paramKey) return;
|
|
9806
|
+
const params = new URLSearchParams(window.location.search);
|
|
9807
|
+
// Convert input strings to timestamps
|
|
9808
|
+
const toTs = v => {
|
|
9809
|
+
if (!v) return "";
|
|
9810
|
+
if (/^[0-9]+$/.test(v)) return v;
|
|
9811
|
+
const d = new Date(v);
|
|
9812
|
+
return d.getTime();
|
|
9813
|
+
};
|
|
9814
|
+
if (vals[0] && vals[1]) {
|
|
9815
|
+
params.set(paramKey, `${toTs(vals[0])}~${toTs(vals[1])}`);
|
|
9816
|
+
} else {
|
|
9817
|
+
params.delete(paramKey);
|
|
9818
|
+
}
|
|
9819
|
+
const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
|
|
9820
|
+
window.history.replaceState({}, "", newUrl);
|
|
9821
|
+
}, [paramKey]);
|
|
9822
|
+
const handleClear = () => {
|
|
9823
|
+
if (!controlledValue) setRange(["", ""]);
|
|
9824
|
+
setUrlParam(["", ""]);
|
|
9825
|
+
onChange?.(["", ""]);
|
|
9826
|
+
};
|
|
9827
|
+
|
|
9828
|
+
// Show/hide dropdown for range selection
|
|
9829
|
+
const [dropdownOpen, setDropdownOpen] = React.useState(false);
|
|
9830
|
+
const [dropdownPosition, setDropdownPosition] = React.useState({
|
|
9831
|
+
top: "110%",
|
|
9832
|
+
left: 0,
|
|
9833
|
+
right: 'auto'
|
|
9834
|
+
});
|
|
9835
|
+
|
|
9836
|
+
// Calculate dropdown position to prevent overflow
|
|
9837
|
+
const dropdownRef = React.useRef(null);
|
|
9838
|
+
React.useEffect(() => {
|
|
9839
|
+
if (!dropdownOpen || !dropdownRef.current) return;
|
|
9840
|
+
const dropdown = dropdownRef.current;
|
|
9841
|
+
const rect = dropdown.getBoundingClientRect();
|
|
9842
|
+
const viewportWidth = window.innerWidth;
|
|
9843
|
+
const viewportHeight = window.innerHeight;
|
|
9844
|
+
let newPosition = {
|
|
9845
|
+
top: "110%",
|
|
9846
|
+
left: 0,
|
|
9847
|
+
right: 'auto'
|
|
9848
|
+
};
|
|
9849
|
+
|
|
9850
|
+
// Check if dropdown goes beyond right edge
|
|
9851
|
+
if (rect.right > viewportWidth - 10) {
|
|
9852
|
+
newPosition.right = 0;
|
|
9853
|
+
newPosition.left = 'auto';
|
|
9854
|
+
}
|
|
9855
|
+
|
|
9856
|
+
// Check if dropdown goes beyond bottom edge
|
|
9857
|
+
if (rect.bottom > viewportHeight - 10) {
|
|
9858
|
+
newPosition.top = 'auto';
|
|
9859
|
+
newPosition.bottom = "110%";
|
|
9860
|
+
}
|
|
9861
|
+
setDropdownPosition(newPosition);
|
|
9862
|
+
}, [dropdownOpen]);
|
|
9863
|
+
|
|
9864
|
+
// Format range for display using dateFormat and timeFormat props
|
|
9865
|
+
const formatDisplay = () => {
|
|
9866
|
+
if (!range[0] && !range[1]) return {
|
|
9867
|
+
start: "",
|
|
9868
|
+
end: ""
|
|
9869
|
+
};
|
|
9870
|
+
const fmt = v => {
|
|
9871
|
+
if (!v) return "";
|
|
9872
|
+
const d = new Date(v);
|
|
9873
|
+
if (isNaN(d.getTime())) return "";
|
|
9874
|
+
|
|
9875
|
+
// Parse dateFormat (default: DD-MM-YYYY)
|
|
9876
|
+
const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
|
|
9877
|
+
const yyyy = d.getFullYear();
|
|
9878
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9879
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9880
|
+
let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
|
|
9881
|
+
if (time) {
|
|
9882
|
+
// Parse timeFormat (default: HH:mm)
|
|
9883
|
+
const actualTimeFormat = timeFormat || "HH:mm";
|
|
9884
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9885
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9886
|
+
const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
|
|
9887
|
+
return `${dateStr} ${timeStr}`;
|
|
9888
|
+
}
|
|
9889
|
+
return dateStr;
|
|
9890
|
+
};
|
|
9891
|
+
return {
|
|
9892
|
+
start: fmt(range[0]),
|
|
9893
|
+
end: fmt(range[1])
|
|
9894
|
+
};
|
|
9895
|
+
};
|
|
9896
|
+
// Close dropdown on outside click
|
|
9897
|
+
React.useEffect(() => {
|
|
9898
|
+
if (!dropdownOpen) return;
|
|
9899
|
+
const onClick = e => {
|
|
9900
|
+
if (!e.target.closest('.range-picker-dropdown')) setDropdownOpen(false);
|
|
9901
|
+
};
|
|
9902
|
+
window.addEventListener('mousedown', onClick);
|
|
9903
|
+
return () => window.removeEventListener('mousedown', onClick);
|
|
9904
|
+
}, [dropdownOpen]);
|
|
9905
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9906
|
+
style: {
|
|
9907
|
+
position: "relative",
|
|
9908
|
+
display: "inline-flex",
|
|
9909
|
+
gap: 4,
|
|
9910
|
+
...style
|
|
9911
|
+
},
|
|
9912
|
+
className: className
|
|
9913
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9914
|
+
style: {
|
|
9915
|
+
position: "relative",
|
|
9916
|
+
flex: 1
|
|
9917
|
+
}
|
|
9918
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
9919
|
+
className: "basic-input",
|
|
9920
|
+
onClick: () => setDropdownOpen(!dropdownOpen),
|
|
9921
|
+
style: {
|
|
9922
|
+
cursor: "pointer",
|
|
9923
|
+
background: dropdownOpen ? "#f0f8ff" : "#fff",
|
|
9924
|
+
height: 34,
|
|
9925
|
+
minHeight: 34,
|
|
9926
|
+
width: 280,
|
|
9927
|
+
border: '1px solid #ccc',
|
|
9928
|
+
borderRadius: 2,
|
|
9929
|
+
display: 'flex',
|
|
9930
|
+
alignItems: 'center',
|
|
9931
|
+
padding: '0 32px 0 8px',
|
|
9932
|
+
position: 'relative',
|
|
9933
|
+
fontSize: 14
|
|
9934
|
+
}
|
|
9935
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
9936
|
+
style: {
|
|
9937
|
+
color: formatDisplay().start ? '#333' : '#999',
|
|
9938
|
+
flex: 1
|
|
9939
|
+
}
|
|
9940
|
+
}, formatDisplay().start || 'Start date'), /*#__PURE__*/React.createElement("span", {
|
|
9941
|
+
style: {
|
|
9942
|
+
padding: '0 8px',
|
|
9943
|
+
color: '#999'
|
|
9944
|
+
}
|
|
9945
|
+
}, "\u2192"), /*#__PURE__*/React.createElement("span", {
|
|
9946
|
+
style: {
|
|
9947
|
+
color: formatDisplay().end ? '#333' : '#999',
|
|
9948
|
+
flex: 1
|
|
9949
|
+
}
|
|
9950
|
+
}, formatDisplay().end || 'End date'), /*#__PURE__*/React.createElement("span", {
|
|
9951
|
+
style: {
|
|
9952
|
+
position: 'absolute',
|
|
9953
|
+
right: 8,
|
|
9954
|
+
top: '50%',
|
|
9955
|
+
transform: 'translateY(-51%)',
|
|
9956
|
+
fontSize: 16,
|
|
9957
|
+
color: '#666'
|
|
9958
|
+
}
|
|
9959
|
+
}, "\uD83D\uDCC5")), dropdownOpen && /*#__PURE__*/React.createElement("div", {
|
|
9960
|
+
ref: dropdownRef,
|
|
9961
|
+
className: "range-picker-dropdown",
|
|
9962
|
+
style: {
|
|
9963
|
+
position: "absolute",
|
|
9964
|
+
...dropdownPosition,
|
|
9965
|
+
background: "#fff",
|
|
9966
|
+
border: "1px solid #ccc",
|
|
9967
|
+
borderRadius: 4,
|
|
9968
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
|
|
9969
|
+
padding: 12,
|
|
9970
|
+
zIndex: 1000,
|
|
9971
|
+
minWidth: 260
|
|
9972
|
+
}
|
|
9973
|
+
}, /*#__PURE__*/React.createElement(CalendarRangePicker, {
|
|
9974
|
+
startDate: range[0] ? new Date(range[0]) : null,
|
|
9975
|
+
endDate: range[1] ? new Date(range[1]) : null,
|
|
9976
|
+
onChange: (start, end) => {
|
|
9977
|
+
const toStr = d => {
|
|
9978
|
+
if (!d) return "";
|
|
9979
|
+
if (time) {
|
|
9980
|
+
const yyyy = d.getFullYear();
|
|
9981
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9982
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9983
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
9984
|
+
const min = String(d.getMinutes()).padStart(2, '0');
|
|
9985
|
+
return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
|
|
9986
|
+
} else {
|
|
9987
|
+
const yyyy = d.getFullYear();
|
|
9988
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
9989
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
9990
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
9991
|
+
}
|
|
9992
|
+
};
|
|
9993
|
+
const newRange = [toStr(start), toStr(end)];
|
|
9994
|
+
if (!controlledValue) setRange(newRange);
|
|
9995
|
+
setUrlParam(newRange);
|
|
9996
|
+
onChange?.(newRange);
|
|
9997
|
+
},
|
|
9998
|
+
time: time,
|
|
9999
|
+
timeStart: timeStart,
|
|
10000
|
+
timeEnd: timeEnd
|
|
10001
|
+
}), processedRanges && processedRanges.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
10002
|
+
style: {
|
|
10003
|
+
marginTop: 12,
|
|
10004
|
+
paddingTop: 12,
|
|
10005
|
+
borderTop: '1px solid #e5e7eb',
|
|
10006
|
+
display: 'flex',
|
|
10007
|
+
gap: 6,
|
|
10008
|
+
flexWrap: 'wrap'
|
|
10009
|
+
}
|
|
10010
|
+
}, processedRanges.map((r, i) => {
|
|
10011
|
+
const isActive = selectedRange === String(i);
|
|
10012
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
10013
|
+
key: r.label,
|
|
10014
|
+
type: "button",
|
|
10015
|
+
onClick: () => {
|
|
10016
|
+
const {
|
|
10017
|
+
getRange
|
|
10018
|
+
} = r;
|
|
10019
|
+
const newRange = getRange(time);
|
|
10020
|
+
if (!controlledValue) setRange(newRange);
|
|
10021
|
+
setUrlParam(newRange);
|
|
10022
|
+
setSelectedRange(String(i));
|
|
10023
|
+
onChange?.(newRange);
|
|
10024
|
+
},
|
|
10025
|
+
style: {
|
|
10026
|
+
padding: '4px 12px',
|
|
10027
|
+
border: isActive ? '1px solid #1d4ed8' : '1px solid #d1d5db',
|
|
10028
|
+
background: isActive ? '#e0f2fe' : '#fff',
|
|
10029
|
+
color: isActive ? '#1d4ed8' : '#333',
|
|
10030
|
+
borderRadius: 4,
|
|
10031
|
+
cursor: 'pointer',
|
|
10032
|
+
fontSize: 12,
|
|
10033
|
+
fontWeight: isActive ? 500 : 400,
|
|
10034
|
+
transition: 'all 0.15s ease'
|
|
10035
|
+
}
|
|
10036
|
+
}, r.label);
|
|
10037
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
10038
|
+
style: {
|
|
10039
|
+
marginTop: 12,
|
|
10040
|
+
textAlign: 'right',
|
|
10041
|
+
borderTop: '1px solid #e5e7eb',
|
|
10042
|
+
paddingTop: 12
|
|
10043
|
+
}
|
|
10044
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
10045
|
+
type: "button",
|
|
10046
|
+
onClick: handleClear,
|
|
10047
|
+
style: {
|
|
10048
|
+
marginRight: 8,
|
|
10049
|
+
padding: '6px 16px',
|
|
10050
|
+
border: '1px solid #d1d5db',
|
|
10051
|
+
background: '#fff',
|
|
10052
|
+
borderRadius: 4,
|
|
10053
|
+
cursor: 'pointer',
|
|
10054
|
+
fontSize: 13
|
|
10055
|
+
}
|
|
10056
|
+
}, "Clear"), /*#__PURE__*/React.createElement("button", {
|
|
10057
|
+
type: "button",
|
|
10058
|
+
onClick: () => setDropdownOpen(false),
|
|
10059
|
+
style: {
|
|
10060
|
+
padding: '6px 16px',
|
|
10061
|
+
border: 'none',
|
|
10062
|
+
background: '#1d4ed8',
|
|
10063
|
+
color: '#fff',
|
|
10064
|
+
borderRadius: 4,
|
|
10065
|
+
cursor: 'pointer',
|
|
10066
|
+
fontSize: 13,
|
|
10067
|
+
fontWeight: 500
|
|
10068
|
+
}
|
|
10069
|
+
}, "OK")))));
|
|
10070
|
+
}
|
|
10071
|
+
RangePicker.propTypes = {
|
|
10072
|
+
pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
10073
|
+
value: PropTypes.arrayOf(PropTypes.string),
|
|
10074
|
+
onChange: PropTypes.func,
|
|
10075
|
+
time: PropTypes.bool,
|
|
10076
|
+
timeStart: PropTypes.string,
|
|
10077
|
+
timeEnd: PropTypes.string,
|
|
10078
|
+
timezone: PropTypes.string,
|
|
10079
|
+
timeFormat: PropTypes.string,
|
|
10080
|
+
dateFormat: PropTypes.string,
|
|
10081
|
+
placeholder: PropTypes.string,
|
|
10082
|
+
required: PropTypes.bool,
|
|
10083
|
+
disabled: PropTypes.bool,
|
|
10084
|
+
className: PropTypes.string,
|
|
10085
|
+
style: PropTypes.object,
|
|
10086
|
+
min: PropTypes.string,
|
|
10087
|
+
max: PropTypes.string,
|
|
10088
|
+
predefinedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,
|
|
10089
|
+
// e.g., "today", "yesterday", "lastweek"
|
|
10090
|
+
PropTypes.number,
|
|
10091
|
+
// e.g., 7, 30 (last N days)
|
|
10092
|
+
PropTypes.shape({
|
|
10093
|
+
label: PropTypes.string.isRequired,
|
|
10094
|
+
getRange: PropTypes.func.isRequired
|
|
10095
|
+
})])), PropTypes.arrayOf(PropTypes.shape({
|
|
10096
|
+
label: PropTypes.string.isRequired,
|
|
10097
|
+
getRange: PropTypes.func.isRequired
|
|
10098
|
+
}))])
|
|
10099
|
+
};
|
|
7529
10100
|
|
|
7530
|
-
exports.
|
|
7531
|
-
exports.
|
|
10101
|
+
exports.CalendarRangePicker = CalendarRangePicker;
|
|
10102
|
+
exports.DateTimeInput = DateTimeInput;
|
|
10103
|
+
exports.DebounceSelect = DebounceSelect;
|
|
10104
|
+
exports.IconInput = IconInput;
|
|
10105
|
+
exports.MultiSelectDropdown = MultiSelectDropdown;
|
|
10106
|
+
exports.RangePicker = RangePicker;
|
|
10107
|
+
exports.SearchInput = SearchInput;
|
|
7532
10108
|
//# sourceMappingURL=index.cjs.js.map
|