trotl-filter 1.0.4 → 1.0.6

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.esm.js CHANGED
@@ -2,6 +2,16 @@ import * as React from 'react';
2
2
  import React__default, { useState, useCallback, forwardRef, useContext, useLayoutEffect, useRef, useMemo, createContext, Component, Fragment, useEffect } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
 
5
+ function _extends$1() {
6
+ return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
7
+ for (var e = 1; e < arguments.length; e++) {
8
+ var t = arguments[e];
9
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
10
+ }
11
+ return n;
12
+ }, _extends$1.apply(null, arguments);
13
+ }
14
+
5
15
  function _typeof(o) {
6
16
  "@babel/helpers - typeof";
7
17
 
@@ -1548,6 +1558,10 @@ var createCache = function createCache(options) {
1548
1558
  return cache;
1549
1559
  };
1550
1560
 
1561
+ function getDefaultExportFromCjs (x) {
1562
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1563
+ }
1564
+
1551
1565
  var reactIs = {exports: {}};
1552
1566
 
1553
1567
  var reactIs_production_min = {};
@@ -6975,11 +6989,75 @@ const MultiSelectDropdown = ({
6975
6989
  onChange,
6976
6990
  theme = "light",
6977
6991
  placeholder = "Select...",
6978
- maxVisible = 1,
6979
6992
  required = false,
6980
- closeMenuOnSelect = false
6993
+ closeMenuOnSelect = false,
6994
+ pushUrlParamObj = false,
6995
+ // pushUrlParamObj={"ids"}
6996
+ addItem = undefined
6981
6997
  }) => {
6982
6998
  const containerRef = useRef(null);
6999
+ const [maxVisible, setMaxVisible] = useState(1);
7000
+ useEffect(() => {
7001
+ if (!containerRef.current) return;
7002
+ const containerWidth = containerRef.current.offsetWidth || 200;
7003
+ // Estimate average tag width (adjust as needed for your style)
7004
+ const avgTagWidth = 90; // px, tweak for your font/size
7005
+ const calculated = Math.max(1, Math.floor((containerWidth - 40) / avgTagWidth));
7006
+ setMaxVisible(calculated);
7007
+ // Optionally, recalculate on window resize:
7008
+ const handleResize = () => {
7009
+ const w = containerRef.current.offsetWidth || 200;
7010
+ setMaxVisible(Math.max(1, Math.floor((w - 40) / avgTagWidth)));
7011
+ };
7012
+ window.addEventListener("resize", handleResize);
7013
+ return () => window.removeEventListener("resize", handleResize);
7014
+ }, []);
7015
+
7016
+ // On mount, read from URL param if present and set values by matching with options
7017
+ useEffect(() => {
7018
+ if (!pushUrlParamObj || !options || options.length === 0) return;
7019
+ const readFromUrl = () => {
7020
+ const params = new URLSearchParams(window.location.search);
7021
+ const urlVal = params.get(pushUrlParamObj);
7022
+ if (urlVal) {
7023
+ if (isMulti) {
7024
+ const urlValues = urlVal.split(",").filter(Boolean);
7025
+ const matchedValues = urlValues.map(v => {
7026
+ const found = options.find(opt => String(opt.value) === String(v));
7027
+ return found ? found.value : null;
7028
+ }).filter(v => v !== null);
7029
+ if (matchedValues.length > 0 && JSON.stringify(matchedValues) !== JSON.stringify(selected)) {
7030
+ onChange?.(matchedValues);
7031
+ }
7032
+ } else {
7033
+ const found = options.find(opt => String(opt.value) === String(urlVal));
7034
+ if (found && (!selected || selected[0] !== found.value)) {
7035
+ onChange?.([found.value]);
7036
+ }
7037
+ }
7038
+ }
7039
+ };
7040
+ readFromUrl();
7041
+ window.addEventListener("popstate", readFromUrl);
7042
+ // Listen for pushState/replaceState (programmatic changes)
7043
+ const patchHistory = type => {
7044
+ const orig = window.history[type];
7045
+ window.history[type] = function () {
7046
+ const rv = orig.apply(this, arguments);
7047
+ window.dispatchEvent(new Event(type));
7048
+ return rv;
7049
+ };
7050
+ };
7051
+ patchHistory('pushState');
7052
+ patchHistory('replaceState');
7053
+ window.addEventListener('pushState', readFromUrl);
7054
+ window.addEventListener('replaceState', readFromUrl);
7055
+ return () => {
7056
+ window.removeEventListener("popstate", readFromUrl);
7057
+ window.removeEventListener('pushState', readFromUrl);
7058
+ window.removeEventListener('replaceState', readFromUrl);
7059
+ };
7060
+ }, [pushUrlParamObj, isMulti, options, selected, onChange]);
6983
7061
  const selectedOptions = useMemo(() => {
6984
7062
  if (isMulti) {
6985
7063
  return options.filter(opt => selected.includes(opt.value));
@@ -6987,13 +7065,94 @@ const MultiSelectDropdown = ({
6987
7065
  return options.find(opt => opt.value === selected[0]) || null;
6988
7066
  }
6989
7067
  }, [selected, options, isMulti]);
7068
+ const setUrlParam = value => {
7069
+ if (!pushUrlParamObj) return;
7070
+ const url = new URL(window.location);
7071
+ if (!value) {
7072
+ url.searchParams.delete(pushUrlParamObj);
7073
+ } else {
7074
+ url.searchParams.set(pushUrlParamObj, value);
7075
+ }
7076
+ window.history.replaceState({}, "", url);
7077
+ };
7078
+
7079
+ // For custom input: track input value and show add button as inline option
7080
+ const [inputValue, setInputValue] = useState("");
7081
+ const inputExists = useMemo(() => {
7082
+ return options.some(opt => String(opt.label).toLowerCase() === inputValue.trim().toLowerCase());
7083
+ }, [inputValue, options]);
7084
+
7085
+ // Add special option for +Add if inputValue is non-empty and not in options
7086
+ const menuOptions = useMemo(() => {
7087
+ if (inputValue && !inputExists && typeof addItem === 'function') {
7088
+ return [...options, {
7089
+ label: `+ Add "${inputValue.trim()}"`,
7090
+ value: '__add_new__',
7091
+ __isAddNew: true
7092
+ }];
7093
+ }
7094
+ return options;
7095
+ }, [options, inputValue, inputExists, addItem]);
7096
+ const handleAddNew = () => {
7097
+ if (!inputValue.trim()) return;
7098
+ const newLabel = inputValue.trim();
7099
+ // Prevent duplicate by value or label (case-insensitive)
7100
+ const exists = options.some(opt => String(opt.value).toLowerCase() === newLabel.toLowerCase() || String(opt.label).toLowerCase() === newLabel.toLowerCase());
7101
+ if (exists) {
7102
+ setInputValue("");
7103
+ return;
7104
+ }
7105
+ const newOption = {
7106
+ label: newLabel,
7107
+ value: newLabel
7108
+ };
7109
+ if (typeof addItem === 'function') {
7110
+ addItem(newOption);
7111
+ // return;
7112
+ }
7113
+ if (isMulti) {
7114
+ onChange([...(selected || []), newOption.value]);
7115
+ if (pushUrlParamObj) setUrlParam([...(selected || []), newOption.value].join(","));
7116
+ } else {
7117
+ onChange([newOption.value]);
7118
+ if (pushUrlParamObj) setUrlParam(newOption.value);
7119
+ }
7120
+ setInputValue("");
7121
+ };
7122
+
7123
+ // Custom Option to handle +Add
7124
+ const Option = props => {
7125
+ if (props.data.__isAddNew) {
7126
+ return /*#__PURE__*/React__default.createElement("div", _extends$1({}, props.innerProps, {
7127
+ style: {
7128
+ padding: '8px 12px',
7129
+ cursor: 'pointer',
7130
+ color: '#1677ff',
7131
+ fontWeight: 500,
7132
+ background: props.isFocused ? '#e6f4ff' : '#fff'
7133
+ },
7134
+ onMouseDown: e => {
7135
+ e.preventDefault();
7136
+ handleAddNew();
7137
+ props.selectOption(props.data);
7138
+ }
7139
+ }), props.data.label);
7140
+ }
7141
+ return /*#__PURE__*/React__default.createElement(components.Option, props);
7142
+ };
6990
7143
  const handleChange = selectedItems => {
6991
7144
  if (isMulti) {
6992
7145
  const values = selectedItems ? selectedItems.map(item => item.value) : [];
6993
7146
  onChange(values);
7147
+ if (pushUrlParamObj) {
7148
+ setUrlParam(values.length ? values.join(",") : "");
7149
+ }
6994
7150
  } else {
6995
7151
  const value = selectedItems ? [selectedItems.value] : [];
6996
7152
  onChange(value);
7153
+ if (pushUrlParamObj) {
7154
+ setUrlParam(value.length ? value[0] : "");
7155
+ }
6997
7156
  }
6998
7157
  };
6999
7158
  const MultiValue = props => {
@@ -7003,9 +7162,13 @@ const MultiSelectDropdown = ({
7003
7162
  } = props;
7004
7163
  const allSelected = getValue();
7005
7164
  const hiddenCount = allSelected.length - maxVisible;
7165
+
7166
+ // Only render visible tags
7006
7167
  if (index < maxVisible) {
7007
7168
  return /*#__PURE__*/React__default.createElement(components.MultiValue, props);
7008
7169
  }
7170
+
7171
+ // Only render +N for the first hidden slot
7009
7172
  if (index === maxVisible && hiddenCount > 0) {
7010
7173
  const hiddenLabels = allSelected.slice(maxVisible).map(opt => opt.label).join(", ");
7011
7174
  return /*#__PURE__*/React__default.createElement("div", {
@@ -7015,13 +7178,17 @@ const MultiSelectDropdown = ({
7015
7178
  backgroundColor: theme === "dark" ? "#333" : "#e0e0e0",
7016
7179
  color: theme === "dark" ? "#eee" : "#333",
7017
7180
  borderRadius: 4,
7018
- padding: "0 6px",
7019
- fontSize: "0.8em",
7020
- alignSelf: "center",
7181
+ padding: "2px 8px",
7182
+ fontSize: "0.85em",
7183
+ display: "inline-flex",
7184
+ alignItems: "center",
7185
+ marginLeft: 4,
7021
7186
  cursor: "default"
7022
7187
  }
7023
7188
  }, "+", hiddenCount);
7024
7189
  }
7190
+
7191
+ // Don't render anything for other hidden tags
7025
7192
  return null;
7026
7193
  };
7027
7194
  const selectStyle = {
@@ -7083,6 +7250,11 @@ const MultiSelectDropdown = ({
7083
7250
  menuPortal: base => ({
7084
7251
  ...base,
7085
7252
  zIndex: 999999
7253
+ }),
7254
+ valueContainer: base => ({
7255
+ ...base,
7256
+ flexWrap: "nowrap",
7257
+ overflow: "hidden"
7086
7258
  })
7087
7259
  };
7088
7260
  const showRequiredError = required && (!selected || selected.length === 0);
@@ -7094,416 +7266,2945 @@ const MultiSelectDropdown = ({
7094
7266
  className: showRequiredError ? "select-required-error" : ""
7095
7267
  }, /*#__PURE__*/React__default.createElement(StateManagedSelect$1, {
7096
7268
  isMulti: isMulti,
7097
- options: options,
7269
+ options: menuOptions,
7098
7270
  value: selectedOptions,
7099
- onChange: handleChange,
7271
+ onChange: (val, action) => {
7272
+ // If user selects the +Add option, handle it
7273
+ if (action && action.action === 'select-option' && val && val.length && val[val.length - 1]?.__isAddNew) {
7274
+ handleAddNew();
7275
+ return;
7276
+ }
7277
+ handleChange(val);
7278
+ },
7100
7279
  placeholder: placeholder,
7101
7280
  styles: selectStyle,
7102
7281
  components: {
7103
- MultiValue
7282
+ MultiValue,
7283
+ Option
7104
7284
  },
7105
7285
  menuPortalTarget: document.body,
7106
7286
  closeMenuOnSelect: closeMenuOnSelect,
7107
- "aria-required": required // ✅ Accessibility hint
7287
+ "aria-required": required,
7288
+ inputValue: inputValue,
7289
+ onInputChange: (val, action) => {
7290
+ if (action.action === "input-change") setInputValue(val);
7291
+ }
7108
7292
  }), showRequiredError && /*#__PURE__*/React__default.createElement("div", {
7109
7293
  className: "error-text"
7110
7294
  }, "This field is required."));
7111
7295
  };
7112
7296
 
7113
- const Modal = ({
7114
- isOpen,
7115
- title = 'Confirm',
7116
- children,
7117
- onConfirm,
7118
- onCancel,
7119
- confirmLabel = 'Confirm',
7120
- cancelLabel = 'Cancel',
7121
- showCancel = false,
7122
- showConfirm = false,
7123
- closeOnEscape = true,
7124
- closeOnOutsideClick = true
7297
+ // import "src/style/DebounceSelect.css";
7298
+
7299
+ const DebounceSelect = ({
7300
+ label,
7301
+ fetchOptions,
7302
+ onSelect,
7303
+ placeholder = "Type to search...",
7304
+ debounceDelay = 300,
7305
+ required = false,
7306
+ disabled = false,
7307
+ objValue,
7308
+ style,
7309
+ isMulti = false,
7310
+ pushUrlParamObj = false,
7311
+ addItem = undefined,
7312
+ fetchAll = true
7125
7313
  }) => {
7314
+ const [input, setInput] = useState("");
7315
+ const [options, setOptions] = useState([]);
7316
+ const [loading, setLoading] = useState(false);
7317
+ const [open, setOpen] = useState(false);
7318
+ const [selectedItems, setSelectedItems] = useState(isMulti ? objValue ?? [] : objValue ? [objValue] : []);
7319
+
7320
+ // Auto-update selectedItems when URL param changes
7321
+ // useEffect(() => {
7322
+ // if (!pushUrlParamObj) return;
7323
+ // const syncFromUrl = () => {
7324
+ // const params = new URLSearchParams(window.location.search);
7325
+ // const urlVal = params.get(pushUrlParamObj);
7326
+ // if (urlVal) {
7327
+ // if (isMulti) {
7328
+ // const urlValues = urlVal.split(",").filter(Boolean);
7329
+ // // Only update if different
7330
+ // if (JSON.stringify(urlValues) !== JSON.stringify(selectedItems.map(i => i.value))) {
7331
+ // // We don't have labels, so just update values
7332
+ // setSelectedItems(urlValues.map(v => ({ value: v, label: v })));
7333
+ // onSelect?.(urlValues.map(v => ({ value: v, label: v })));
7334
+ // }
7335
+ // } else {
7336
+ // if (!selectedItems[0] || selectedItems[0].value !== urlVal) {
7337
+ // setSelectedItems([{ value: urlVal, label: urlVal }]);
7338
+ // onSelect?.({ value: urlVal, label: urlVal });
7339
+ // }
7340
+ // }
7341
+ // } else {
7342
+ // if (selectedItems.length > 0) {
7343
+ // setSelectedItems([]);
7344
+ // onSelect?.(isMulti ? [] : null);
7345
+ // }
7346
+ // }
7347
+ // };
7348
+ // syncFromUrl();
7349
+ // window.addEventListener("popstate", syncFromUrl);
7350
+ // // Listen for pushState/replaceState (programmatic changes)
7351
+ // const patchHistory = (type) => {
7352
+ // const orig = window.history[type];
7353
+ // window.history[type] = function() {
7354
+ // const rv = orig.apply(this, arguments);
7355
+ // window.dispatchEvent(new Event(type));
7356
+ // return rv;
7357
+ // };
7358
+ // };
7359
+ // patchHistory('pushState');
7360
+ // patchHistory('replaceState');
7361
+ // window.addEventListener('pushState', syncFromUrl);
7362
+ // window.addEventListener('replaceState', syncFromUrl);
7363
+ // return () => {
7364
+ // window.removeEventListener("popstate", syncFromUrl);
7365
+ // window.removeEventListener('pushState', syncFromUrl);
7366
+ // window.removeEventListener('replaceState', syncFromUrl);
7367
+ // };
7368
+ // // eslint-disable-next-line react-hooks/exhaustive-deps
7369
+ // }, [pushUrlParamObj, isMulti, selectedItems, onSelect]);
7370
+
7371
+ const timeoutRef = useRef(null);
7126
7372
  useEffect(() => {
7127
- const handleKey = e => {
7128
- if (e.key === 'Escape' && closeOnEscape) {
7129
- onCancel?.();
7373
+ if (!input) {
7374
+ setOptions([]);
7375
+ return;
7376
+ }
7377
+ setLoading(true);
7378
+ clearTimeout(timeoutRef.current);
7379
+ timeoutRef.current = setTimeout(async () => {
7380
+ try {
7381
+ // If fetchAll is true and input is '...', fetch all options
7382
+ // If fetchAll is false, '...' will be treated as regular search
7383
+ const query = fetchAll && input === "..." ? "" : input;
7384
+ const results = await fetchOptions(query);
7385
+ setOptions(results);
7386
+ } catch (err) {
7387
+ console.error("Failed to fetch options", err);
7388
+ setOptions([]);
7389
+ } finally {
7390
+ setLoading(false);
7130
7391
  }
7392
+ }, debounceDelay);
7393
+ return () => clearTimeout(timeoutRef.current);
7394
+ }, [input, fetchOptions, debounceDelay, fetchAll]);
7395
+ const setUrlParam = value => {
7396
+ const url = new URL(window.location);
7397
+ if (value === null || value === undefined || value === "") {
7398
+ url.searchParams.delete(pushUrlParamObj);
7399
+ } else {
7400
+ url.searchParams.set(pushUrlParamObj, value);
7401
+ }
7402
+ window.history.replaceState({}, "", url);
7403
+ };
7404
+ const handleSelect = (value, labelValue) => {
7405
+ if (isMulti) {
7406
+ const newItem = {
7407
+ value,
7408
+ label: labelValue
7409
+ };
7410
+ const updated = selectedItems.some(item => item.value === value) ? selectedItems : [...selectedItems, newItem];
7411
+ setSelectedItems(updated);
7412
+ onSelect(updated);
7413
+ setInput("");
7414
+ if (pushUrlParamObj) {
7415
+ setUrlParam(updated.map(item => item.value).join(","));
7416
+ }
7417
+ } else {
7418
+ const single = {
7419
+ value,
7420
+ label: labelValue
7421
+ };
7422
+ setSelectedItems([single]);
7423
+ onSelect(single);
7424
+ setInput(labelValue);
7425
+ if (pushUrlParamObj) {
7426
+ setUrlParam(value);
7427
+ }
7428
+ }
7429
+ setOpen(false);
7430
+ };
7431
+ const removeItem = value => {
7432
+ const updated = selectedItems.filter(item => item.value !== value);
7433
+ setSelectedItems(updated);
7434
+ onSelect(updated);
7435
+ if (pushUrlParamObj) {
7436
+ setUrlParam(updated.length ? updated.map(item => item.value).join(",") : "");
7437
+ }
7438
+ };
7439
+
7440
+ // Check if input value exists in options
7441
+ const inputExists = input.trim() && options.some(opt => String(opt.label).toLowerCase() === input.trim().toLowerCase() || String(opt.value).toLowerCase() === input.trim().toLowerCase());
7442
+ const handleAddNew = () => {
7443
+ if (!input.trim()) return;
7444
+ const newOption = {
7445
+ label: input.trim(),
7446
+ value: input.trim()
7131
7447
  };
7132
- document.addEventListener('keydown', handleKey);
7133
- return () => document.removeEventListener('keydown', handleKey);
7134
- }, [closeOnEscape, onCancel]);
7135
- if (!isOpen) return null;
7448
+ if (typeof addItem === 'function') {
7449
+ addItem(newOption);
7450
+ }
7451
+ handleSelect(newOption.value, newOption.label);
7452
+ };
7453
+
7454
+ // Handle double-click to fetch all when fetchAll is false
7455
+ const handleDoubleClick = async () => {
7456
+ if (!fetchAll && !disabled) {
7457
+ setLoading(true);
7458
+ setOpen(true);
7459
+ try {
7460
+ const results = await fetchOptions("");
7461
+ setOptions(results);
7462
+ } catch (err) {
7463
+ console.error("Failed to fetch options", err);
7464
+ setOptions([]);
7465
+ } finally {
7466
+ setLoading(false);
7467
+ }
7468
+ }
7469
+ };
7136
7470
  return /*#__PURE__*/React__default.createElement("div", {
7137
- className: "modal-overlay",
7138
- onClick: closeOnOutsideClick ? onCancel : undefined
7139
- }, /*#__PURE__*/React__default.createElement("div", {
7140
- className: "modal-box",
7141
- onClick: e => e.stopPropagation()
7142
- }, /*#__PURE__*/React__default.createElement("h3", {
7143
- className: "modal-title"
7144
- }, title), /*#__PURE__*/React__default.createElement("div", {
7145
- className: "modal-content"
7146
- }, children), /*#__PURE__*/React__default.createElement("div", {
7147
- className: "modal-actions"
7148
- }, showCancel && /*#__PURE__*/React__default.createElement("button", {
7149
- className: "basic-button cancel",
7150
- onClick: onCancel
7151
- }, cancelLabel), showConfirm && /*#__PURE__*/React__default.createElement("button", {
7152
- className: "basic-button confirm",
7153
- onClick: onConfirm
7154
- }, confirmLabel))));
7471
+ style: {
7472
+ position: 'relative'
7473
+ }
7474
+ }, label && /*#__PURE__*/React__default.createElement("label", null, label, required && ' *'), isMulti && /*#__PURE__*/React__default.createElement("div", {
7475
+ className: "multi-selected-tags"
7476
+ }, selectedItems.map(({
7477
+ label,
7478
+ value
7479
+ }) => /*#__PURE__*/React__default.createElement("span", {
7480
+ key: value,
7481
+ className: "tag"
7482
+ }, label, /*#__PURE__*/React__default.createElement("button", {
7483
+ type: "button",
7484
+ onClick: () => removeItem(value)
7485
+ }, "\xD7")))), /*#__PURE__*/React__default.createElement("div", {
7486
+ style: {
7487
+ position: 'relative',
7488
+ display: 'flex',
7489
+ alignItems: 'center'
7490
+ }
7491
+ }, /*#__PURE__*/React__default.createElement("input", {
7492
+ className: "basic-input",
7493
+ type: "text",
7494
+ value: isMulti ? input : open ? input : selectedItems.length > 0 ? selectedItems[0].label : input,
7495
+ onChange: e => {
7496
+ setInput(e.target.value);
7497
+ setOpen(true);
7498
+ },
7499
+ placeholder: placeholder,
7500
+ onFocus: () => setOpen(true),
7501
+ onBlur: () => setTimeout(() => setOpen(false), 200),
7502
+ onDoubleClick: handleDoubleClick,
7503
+ disabled: disabled,
7504
+ style: style
7505
+ }), (input || !isMulti && selectedItems.length > 0) && !disabled && /*#__PURE__*/React__default.createElement("button", {
7506
+ type: "button",
7507
+ "aria-label": "Clear",
7508
+ style: {
7509
+ position: 'absolute',
7510
+ right: 6,
7511
+ background: 'none',
7512
+ border: 'none',
7513
+ cursor: 'pointer',
7514
+ fontSize: '1.2em',
7515
+ color: '#888',
7516
+ padding: 0,
7517
+ lineHeight: 1
7518
+ },
7519
+ onMouseDown: e => {
7520
+ e.preventDefault();
7521
+ setInput("");
7522
+ if (isMulti) ; else {
7523
+ setSelectedItems([]);
7524
+ onSelect(null);
7525
+ if (pushUrlParamObj) setUrlParam("");
7526
+ }
7527
+ },
7528
+ tabIndex: -1
7529
+ }, "\xD7")), open && /*#__PURE__*/React__default.createElement("div", {
7530
+ className: "basic-input-dropdown-menu"
7531
+ }, loading ? /*#__PURE__*/React__default.createElement("div", {
7532
+ className: "loading-dropdown-item"
7533
+ }, "Loading...") : options?.length > 0 ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, options.map(({
7534
+ label,
7535
+ value
7536
+ }) => /*#__PURE__*/React__default.createElement("div", {
7537
+ key: value,
7538
+ className: "basic-input-dropdown-item",
7539
+ onMouseDown: () => handleSelect(value, label)
7540
+ }, label)), input.trim() && !inputExists && typeof addItem === 'function' && /*#__PURE__*/React__default.createElement("div", {
7541
+ className: "basic-input-dropdown-item",
7542
+ style: {
7543
+ color: '#1677ff',
7544
+ fontWeight: 500
7545
+ },
7546
+ onMouseDown: handleAddNew
7547
+ }, "+ Add \"", input.trim(), "\"")) : input.trim() && !loading && typeof addItem === 'function' ? /*#__PURE__*/React__default.createElement("div", {
7548
+ className: "basic-input-dropdown-item",
7549
+ style: {
7550
+ color: '#1677ff',
7551
+ fontWeight: 500
7552
+ },
7553
+ onMouseDown: handleAddNew
7554
+ }, "+ Add \"", input.trim(), "\"") : /*#__PURE__*/React__default.createElement("div", {
7555
+ className: "no-results-dropdown-item"
7556
+ }, "No results")));
7155
7557
  };
7156
7558
 
7157
- const Filters = ({
7158
- title,
7159
- config = [],
7160
- onChange,
7161
- onAction,
7162
- userRole = [],
7163
- onExport,
7164
- hideResetSearchButton,
7165
- urSearchParams = false,
7166
- extraSearchTerm,
7167
- theme = "light"
7168
- }) => {
7169
- // const { theme, internalSort, context } = useAuth();
7170
-
7171
- // console.log(extraSearchTerm)
7172
- // Simple translation stub: return mapped key or the key itself.
7173
- const _translations = {
7174
- showFilters: 'showFilters',
7175
- hideFilters: 'hideFilters',
7176
- resetSorting: 'resetSorting',
7177
- resetSearching: 'resetSearching',
7178
- role: 'role',
7179
- confirmTitle: 'confirmTitle',
7180
- confirm: 'confirm',
7181
- cancel: 'cancel',
7182
- confirmUnknown: 'confirmUnknown'
7559
+ function SearchInput({
7560
+ pushUrlParamObj = null,
7561
+ ...props
7562
+ }) {
7563
+ const key = pushUrlParamObj || "search";
7564
+ const [value, setValue] = React__default.useState("");
7565
+
7566
+ // On mount, read the URL param and set value
7567
+ React__default.useEffect(() => {
7568
+ const params = new URLSearchParams(window.location.search);
7569
+ const urlValue = params.get(key) || "";
7570
+ setValue(urlValue);
7571
+
7572
+ // Listen for popstate (browser navigation)
7573
+ const onPopState = () => {
7574
+ const params = new URLSearchParams(window.location.search);
7575
+ setValue(params.get(key) || "");
7576
+ };
7577
+ window.addEventListener("popstate", onPopState);
7578
+ return () => window.removeEventListener("popstate", onPopState);
7579
+ }, [key]);
7580
+ const setUrlParam = val => {
7581
+ const params = new URLSearchParams(window.location.search);
7582
+ if (val && val.length > 0) {
7583
+ params.set(key, val);
7584
+ } else {
7585
+ params.delete(key);
7586
+ }
7587
+ const newUrl = window.location.pathname + (params.toString() ? "?" + params.toString() : "");
7588
+ window.history.replaceState({}, "", newUrl);
7183
7589
  };
7184
-
7185
- // t(key) returns the translation (here same as key). Calling t() with no args
7186
- // returns an empty string to avoid accidentally rendering the translations object.
7187
- const t = key => {
7188
- if (typeof key === 'undefined' || key === null) return '';
7189
- return _translations[key] ?? key;
7590
+ const handleChange = e => {
7591
+ const newValue = e.target.value;
7592
+ setValue(newValue);
7593
+ setUrlParam(newValue);
7190
7594
  };
7191
- const [sorting, setSorting] = useState(null);
7192
- const [collapsed, setCollapsed] = useState(() => {
7193
- const stored = localStorage.getItem('filtersCollapsed');
7194
- return stored === 'true';
7195
- });
7196
- const [modalState, setModalState] = useState({
7197
- isOpen: false,
7198
- label: '',
7199
- key: '',
7200
- onConfirm: null
7201
- });
7202
- useEffect(() => {
7203
- localStorage.setItem('filtersCollapsed', collapsed);
7204
- }, [collapsed]);
7595
+ const handleClear = () => {
7596
+ setValue("");
7597
+ setUrlParam("");
7598
+ };
7599
+ return /*#__PURE__*/React__default.createElement("div", {
7600
+ title: "tooltip",
7601
+ style: {
7602
+ position: "relative",
7603
+ display: "inline-block",
7604
+ height: "34px",
7605
+ verticalAlign: "middle"
7606
+ }
7607
+ }, /*#__PURE__*/React__default.createElement("input", _extends$1({
7608
+ className: "basic-input",
7609
+ value: value,
7610
+ style: {
7611
+ marginBottom: "10px",
7612
+ padding: "5px",
7613
+ width: "200px",
7614
+ paddingRight: value ? "24px" : undefined,
7615
+ height: "100%",
7616
+ boxSizing: "border-box"
7617
+ },
7618
+ onChange: handleChange
7619
+ }, props)), value && /*#__PURE__*/React__default.createElement("span", {
7620
+ onClick: handleClear,
7621
+ title: "Clear search",
7622
+ style: {
7623
+ position: "absolute",
7624
+ right: "10px",
7625
+ top: "50%",
7626
+ transform: "translateY(-50%)",
7627
+ cursor: "pointer",
7628
+ fontSize: "14px",
7629
+ color: "#000000ff",
7630
+ lineHeight: "1"
7631
+ }
7632
+ }, "\u2716"));
7633
+ }
7634
+
7635
+ /*
7636
+ Reusable IconInput component
7637
+ Props:
7638
+ icon: ReactNode or string to render
7639
+ title: tooltip text
7640
+ ariaLabel: accessible label (falls back to title or stringified icon)
7641
+ onClick: callback fired after internal URL logic (receives event & active state)
7642
+ size: number (px) for square hit area
7643
+ disabled: boolean
7644
+ className, style: customization
7645
+ pushUrlParamObj: string | false -> if provided, component will write to that URL param
7646
+ pushValue: value written to param when activated (default '1')
7647
+ toggle: boolean -> if true acts like a toggle, else just sets param
7648
+ multiUrlList: boolean -> if true treats param as comma-separated list; clicking toggles pushValue in list
7649
+ activeColor: color when active
7650
+ inactiveColor: color when inactive
7651
+ */
7205
7652
 
7206
- // useEffect(() => {
7207
- // setSorting(internalSort)
7208
- // }, [internalSort]);
7653
+ function IconInput({
7654
+ icon,
7655
+ title,
7656
+ ariaLabel,
7657
+ onClick,
7658
+ size = 32,
7659
+ disabled = false,
7660
+ className = "",
7661
+ style = {},
7662
+ pushUrlParamObj = false,
7663
+ pushValue = "1",
7664
+ toggle = true,
7665
+ multiUrlList = false,
7666
+ activeColor = "#1d4ed8",
7667
+ inactiveColor = "#555",
7668
+ onAction = null
7669
+ }) {
7670
+ const paramKey = pushUrlParamObj || null;
7671
+ const [active, setActive] = useState(() => {
7672
+ if (!paramKey) return false;
7673
+ const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
7674
+ const raw = params.get(paramKey);
7675
+ if (!raw) return false;
7676
+ if (multiUrlList) {
7677
+ const arr = raw.split(',').filter(Boolean);
7678
+ return arr.includes(String(pushValue));
7679
+ }
7680
+ return raw === String(pushValue);
7681
+ });
7209
7682
 
7210
- const handleReset = () => {
7211
- config.forEach(item => {
7212
- if (item.type !== 'button' && item.type !== 'icon') {
7213
- onChange?.(item.key, item.defaultValue || '');
7214
- }
7215
- });
7216
- localStorage.removeItem('adminFilters');
7217
- window.history.replaceState({}, '', window.location.pathname);
7218
- };
7683
+ // Auto-update active state when URL param changes
7219
7684
  useEffect(() => {
7220
- const urlParams = new URLSearchParams(window.location.search);
7221
- const savedFilters = localStorage.getItem('adminFilters');
7222
- const initial = savedFilters ? JSON.parse(savedFilters) : {};
7223
- urlParams.forEach((value, key) => {
7224
- if (key === 'roles') {
7225
- initial[key] = urlParams.getAll('roles');
7685
+ if (!paramKey) return;
7686
+ const syncFromUrl = () => {
7687
+ const params = new URLSearchParams(window.location.search);
7688
+ const raw = params.get(paramKey);
7689
+ let nextActive = false;
7690
+ if (raw) {
7691
+ if (multiUrlList) {
7692
+ const arr = raw.split(',').filter(Boolean);
7693
+ nextActive = arr.includes(String(pushValue));
7694
+ } else {
7695
+ nextActive = raw === String(pushValue);
7696
+ }
7697
+ }
7698
+ setActive(nextActive);
7699
+ };
7700
+ syncFromUrl();
7701
+ window.addEventListener("popstate", syncFromUrl);
7702
+ // Listen for pushState/replaceState (programmatic changes)
7703
+ const patchHistory = type => {
7704
+ const orig = window.history[type];
7705
+ window.history[type] = function () {
7706
+ const rv = orig.apply(this, arguments);
7707
+ window.dispatchEvent(new Event(type));
7708
+ return rv;
7709
+ };
7710
+ };
7711
+ patchHistory('pushState');
7712
+ patchHistory('replaceState');
7713
+ window.addEventListener('pushState', syncFromUrl);
7714
+ window.addEventListener('replaceState', syncFromUrl);
7715
+ return () => {
7716
+ window.removeEventListener("popstate", syncFromUrl);
7717
+ window.removeEventListener('pushState', syncFromUrl);
7718
+ window.removeEventListener('replaceState', syncFromUrl);
7719
+ };
7720
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7721
+ }, [paramKey, multiUrlList, pushValue]);
7722
+
7723
+ // (Removed effect-based initialization; using lazy useState instead to satisfy lint rule.)
7724
+
7725
+ const updateUrl = useCallback(nextActive => {
7726
+ if (!paramKey) return;
7727
+ const params = new URLSearchParams(window.location.search);
7728
+ const current = params.get(paramKey);
7729
+ if (multiUrlList) {
7730
+ let list = current ? current.split(",").filter(Boolean) : [];
7731
+ const idx = list.indexOf(String(pushValue));
7732
+ if (nextActive) {
7733
+ if (idx === -1) list.push(String(pushValue));
7226
7734
  } else {
7227
- initial[key] = value;
7735
+ if (idx !== -1) list.splice(idx, 1);
7228
7736
  }
7229
- });
7230
- Object.entries(initial).forEach(([key, value]) => {
7231
- onChange?.(key, value);
7232
- });
7233
- }, []);
7234
- useEffect(() => {
7235
- const savedFilters = localStorage.getItem('adminFilters');
7236
- if (savedFilters) {
7237
- const parsed = JSON.parse(savedFilters);
7238
- Object.entries(parsed).forEach(([key, value]) => {
7239
- onChange?.(key, value);
7240
- });
7241
- }
7242
- }, []);
7243
- useEffect(() => {
7244
- const currentValues = {};
7245
- config.forEach(item => {
7246
- if (item.type !== 'button' && item.type !== 'icon') {
7247
- currentValues[item.key] = item.value;
7737
+ if (list.length === 0) {
7738
+ params.delete(paramKey);
7739
+ } else {
7740
+ params.set(paramKey, list.join(","));
7248
7741
  }
7249
- });
7250
- localStorage.setItem('adminFilters', JSON.stringify(currentValues));
7251
- }, [config]);
7252
- const openConfirmModal = (label, key, actionFn) => {
7253
- setModalState({
7254
- isOpen: true,
7255
- label,
7256
- key,
7257
- onConfirm: () => {
7258
- actionFn(key);
7259
- setModalState({
7260
- isOpen: false,
7261
- label: '',
7262
- key: '',
7263
- onConfirm: null
7264
- });
7742
+ } else {
7743
+ if (nextActive) {
7744
+ params.set(paramKey, String(pushValue));
7745
+ } else {
7746
+ if (toggle) {
7747
+ params.delete(paramKey);
7748
+ } else {
7749
+ // If not toggle, leave value as-is (or could clear)
7750
+ params.delete(paramKey);
7751
+ }
7265
7752
  }
7266
- });
7753
+ }
7754
+ const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
7755
+ window.history.replaceState({}, "", newUrl);
7756
+ }, [paramKey, multiUrlList, pushValue, toggle]);
7757
+ const handleActivate = e => {
7758
+ if (disabled) return;
7759
+ let nextActive = active;
7760
+ if (toggle || multiUrlList) {
7761
+ nextActive = !active;
7762
+ } else {
7763
+ nextActive = true; // one-shot set
7764
+ }
7765
+ setActive(nextActive);
7766
+ updateUrl(nextActive);
7767
+ onClick?.(e, nextActive);
7267
7768
  };
7268
- const closeModal = () => {
7269
- setModalState({
7270
- isOpen: false,
7271
- label: '',
7272
- key: '',
7273
- onConfirm: null
7274
- });
7769
+ const handleKey = e => {
7770
+ if (disabled) return;
7771
+ if (e.key === "Enter" || e.key === " ") {
7772
+ e.preventDefault();
7773
+ handleActivate(e);
7774
+ }
7275
7775
  };
7276
- const sortingLocalStorage = localStorage.getItem("tableSort");
7776
+ const label = ariaLabel || title || (typeof icon === "string" ? icon : "icon button");
7777
+ const baseStyle = {
7778
+ display: "inline-flex",
7779
+ alignItems: "center",
7780
+ justifyContent: "center",
7781
+ width: size,
7782
+ height: size,
7783
+ fontSize: Math.floor(size * 0.6),
7784
+ lineHeight: 1,
7785
+ cursor: disabled ? "not-allowed" : "pointer",
7786
+ userSelect: "none",
7787
+ borderRadius: 6,
7788
+ border: "1px solid #ccc",
7789
+ background: active ? "#e0f2fe" : "#f5f5f5",
7790
+ color: active ? activeColor : inactiveColor,
7791
+ transition: "background 120ms, color 120ms, box-shadow 120ms",
7792
+ boxShadow: active ? "0 0 0 2px rgba(29,78,216,0.3)" : "none",
7793
+ ...style
7794
+ };
7795
+ return /*#__PURE__*/React__default.createElement("span", {
7796
+ role: "button",
7797
+ "aria-label": label,
7798
+ "aria-pressed": toggle || multiUrlList ? active : undefined,
7799
+ tabIndex: disabled ? -1 : 0,
7800
+ title: title,
7801
+ onClick: onAction,
7802
+ onKeyDown: handleKey,
7803
+ className: `icon-input ${className}`.trim(),
7804
+ style: baseStyle,
7805
+ "data-active": active ? "true" : "false"
7806
+ }, icon);
7807
+ }
7808
+
7809
+ var propTypes = {exports: {}};
7277
7810
 
7278
- // When urSearchParams is enabled, keep the URL search param `search`
7279
- // in sync with the extraSearchTerm prop without reloading the page.
7280
- // When urSearchParams is enabled, keep the URL search param `search`
7281
- // in sync with the extraSearchTerm prop without reloading the page.
7282
- useEffect(() => {
7283
- if (!urSearchParams) return;
7284
- try {
7285
- const url = new URL(window.location.href);
7286
- if (extraSearchTerm && String(extraSearchTerm).length > 0) {
7287
- url.searchParams.set('search', String(extraSearchTerm));
7288
- } else {
7289
- url.searchParams.delete('search');
7290
- }
7291
- window.history.replaceState({}, '', url.toString());
7292
- } catch (e) {
7293
- // fallback: do nothing if URL constructor fails (very unlikely in browsers)
7294
- }
7295
- }, [urSearchParams, extraSearchTerm]);
7811
+ /*
7812
+ object-assign
7813
+ (c) Sindre Sorhus
7814
+ @license MIT
7815
+ */
7296
7816
 
7297
- // Clear MultiSelectDropdown values if extraSearchTerm is set (input search used)
7298
- useEffect(() => {
7299
- if (!extraSearchTerm || !urSearchParams) return;
7300
- // Find all multiselect filters and clear them
7301
- config.forEach(item => {
7302
- if (item.type === 'multiselect' && item.value && item.value.length > 0) {
7303
- onChange?.(item.key, item.isMulti ? [] : '');
7304
- }
7305
- });
7306
- }, [extraSearchTerm, urSearchParams]);
7307
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
7308
- className: "filters-wrapper"
7309
- }, /*#__PURE__*/React__default.createElement("div", {
7310
- className: "filters-header"
7311
- }, /*#__PURE__*/React__default.createElement("div", {
7312
- className: "filters-title"
7313
- }, title), /*#__PURE__*/React__default.createElement("button", {
7314
- className: "basic-button",
7315
- onClick: () => setCollapsed(prev => !prev)
7316
- }, collapsed ? ' ' + t("showFilters") : ' ' + t("hideFilters")), sortingLocalStorage && /*#__PURE__*/React__default.createElement("button", {
7317
- className: "basic-button confirm",
7318
- onClick: () => {
7319
- setSorting(false);
7320
- context("resetSortingTrigger", true);
7321
- localStorage.removeItem("tableSort");
7322
- window.dispatchEvent(new Event("storageUpdated"));
7323
- }
7324
- }, t("resetSorting") + " " + (sorting || "")), !hideResetSearchButton && /*#__PURE__*/React__default.createElement("button", {
7325
- className: "basic-button",
7326
- onClick: handleReset
7327
- }, t("resetSearching"))), !collapsed && /*#__PURE__*/React__default.createElement("div", {
7328
- className: "filters-container"
7329
- }, config.map((item, index) => {
7330
- const tooltip = item.tooltip || '';
7331
- const roleAllowed = !item.role || userRole.some(r => item.role.includes(r));
7332
- if (!roleAllowed) return null;
7333
- switch (item.type) {
7334
- case 'group':
7335
- return /*#__PURE__*/React__default.createElement("div", {
7336
- key: index,
7337
- className: "button-group",
7338
- title: item.label
7339
- }, item.buttons.map((btn, i) => {
7340
- const actionFn = btn.onAction || onAction;
7341
- if (!actionFn) return null;
7342
- const handleClick = () => {
7343
- if (btn.confirm) {
7344
- openConfirmModal(btn.label, btn.key, actionFn);
7345
- } else {
7346
- actionFn(btn.key);
7347
- }
7348
- };
7349
- return /*#__PURE__*/React__default.createElement("button", {
7350
- className: "basic-button",
7351
- key: i,
7352
- onClick: handleClick,
7353
- title: btn.tooltip || btn.label
7354
- }, t(btn.label));
7355
- }));
7356
- case 'input':
7357
- return /*#__PURE__*/React__default.createElement("div", {
7358
- key: index,
7359
- className: "filter-input-wrapper",
7360
- title: tooltip
7361
- }, /*#__PURE__*/React__default.createElement("input", {
7362
- className: "basic-input",
7363
- type: "search",
7364
- placeholder: item.placeholder || '',
7365
- value: item.value || '',
7366
- onChange: e => {
7367
- // If input search is used, clear all multiselects
7368
- if (urSearchParams && e.target.value) {
7369
- config.forEach(f => {
7370
- if (f.type === 'multiselect' && f.value && f.value.length > 0) {
7371
- onChange?.(f.key, f.isMulti ? [] : '');
7372
- }
7373
- });
7374
- }
7375
- onChange?.(item.key, e.target.value);
7376
- }
7377
- }));
7378
- case 'select':
7379
- return /*#__PURE__*/React__default.createElement("select", {
7380
- key: index,
7381
- value: item.value || '',
7382
- onChange: e => onChange?.(item.key, e.target.value),
7383
- className: "filter-select",
7384
- title: tooltip
7385
- }, item.options?.map((opt, i) => /*#__PURE__*/React__default.createElement("option", {
7386
- key: i,
7387
- value: opt.value
7388
- }, opt.label)));
7389
- case 'multiselect':
7390
- return /*#__PURE__*/React__default.createElement("div", {
7391
- key: index,
7392
- className: "filter-multiselect",
7393
- title: tooltip
7394
- }, /*#__PURE__*/React__default.createElement(MultiSelectDropdown, {
7395
- label: item.label || t("role"),
7396
- selected: Array.isArray(item.value) ? item.value : item.value ? [item.value] : [],
7397
- onChange: newValues => {
7398
- // If multiselect is used, clear all input search fields
7399
- if (urSearchParams && newValues && newValues.length > 0) {
7400
- config.forEach(f => {
7401
- if (f.type === 'input' && f.value && f.value.length > 0) {
7402
- onChange?.(f.key, '');
7403
- }
7404
- });
7405
- }
7406
- onChange?.(item.key, item.isMulti ? newValues : newValues[0] || "");
7407
- if (urSearchParams) {
7408
- try {
7409
- const url = new URL(window.location.href);
7410
- // Combine all selected values from all MultiSelectDropdowns
7411
- let allSelected = [];
7412
- config.forEach(f => {
7413
- if (f.type === 'multiselect') {
7414
- // Skip the current item being changed, we'll use newValues for it
7415
- if (f.key === item.key) {
7416
- if (Array.isArray(newValues) && newValues.length > 0) {
7417
- allSelected = allSelected.concat(newValues);
7418
- } else if (newValues && !Array.isArray(newValues)) {
7419
- allSelected.push(newValues);
7420
- }
7421
- } else if (f.value) {
7422
- // For other multiselects, use their current value
7423
- if (Array.isArray(f.value)) {
7424
- allSelected = allSelected.concat(f.value);
7425
- } else if (f.value) {
7426
- allSelected.push(f.value);
7427
- }
7428
- }
7429
- }
7430
- });
7431
- // Filter out empty/null/undefined values
7432
- allSelected = allSelected.filter(v => v !== undefined && v !== null && v !== '');
7433
- const joined = allSelected.join(",");
7434
- if (joined && joined.length > 0) {
7435
- url.searchParams.set('search', joined);
7436
- } else {
7437
- url.searchParams.delete('search');
7438
- }
7439
- window.history.replaceState({}, '', url.toString());
7440
- } catch (e) {
7441
- // ignore
7442
- }
7443
- }
7444
- },
7445
- required: item.required,
7446
- isMulti: item.isMulti,
7447
- theme: theme,
7448
- fetchOptions: item.fetchOptions,
7449
- options: item.options
7450
- }));
7451
- case 'date':
7452
- return /*#__PURE__*/React__default.createElement("div", {
7453
- key: index,
7454
- className: "filter-date",
7455
- title: tooltip
7456
- }, /*#__PURE__*/React__default.createElement("input", {
7457
- className: "basic-input",
7458
- type: item.addTime ? 'datetime-local' : 'date',
7459
- value: item.value || '',
7460
- onChange: e => onChange?.(item.key, e.target.value)
7461
- }), item.value && /*#__PURE__*/React__default.createElement("span", {
7462
- className: "date-clear",
7463
- onClick: () => onChange?.(item.key, ''),
7464
- title: "Clear date"
7465
- }, "\u2716\uFE0F"));
7466
- case 'button':
7467
- return /*#__PURE__*/React__default.createElement("button", {
7468
- style: item?.style,
7469
- className: "basic-button",
7470
- key: index,
7471
- onClick: () => {
7472
- const actionFn = item.onAction || onAction;
7473
- if (!actionFn) return;
7474
- if (item.confirm) {
7475
- openConfirmModal(item.label, item.key, actionFn);
7476
- } else {
7477
- actionFn(item.key);
7478
- }
7479
- },
7480
- title: tooltip
7481
- }, t(item.label));
7482
- case 'icon':
7483
- return /*#__PURE__*/React__default.createElement("span", {
7484
- key: index,
7485
- className: `filter-icon ${item.className || ''}`,
7486
- style: item.style,
7487
- onClick: () => onAction?.(item.key),
7488
- title: tooltip
7489
- }, item.icon);
7490
- default:
7491
- return null;
7492
- }
7493
- }))), /*#__PURE__*/React__default.createElement(Modal, {
7494
- isOpen: modalState.isOpen,
7495
- title: t("confirmTitle") || "Confirm",
7496
- onCancel: closeModal,
7497
- onConfirm: modalState.onConfirm,
7498
- showCancel: true,
7499
- showConfirm: true,
7500
- confirmLabel: t("confirm") || "Confirm",
7501
- cancelLabel: t("cancel") || "Cancel"
7502
- }, t("confirmUnknown"), " ", modalState.label, "?"));
7503
- };
7817
+ var objectAssign;
7818
+ var hasRequiredObjectAssign;
7819
+
7820
+ function requireObjectAssign () {
7821
+ if (hasRequiredObjectAssign) return objectAssign;
7822
+ hasRequiredObjectAssign = 1;
7823
+ /* eslint-disable no-unused-vars */
7824
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
7825
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
7826
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
7827
+
7828
+ function toObject(val) {
7829
+ if (val === null || val === undefined) {
7830
+ throw new TypeError('Object.assign cannot be called with null or undefined');
7831
+ }
7832
+
7833
+ return Object(val);
7834
+ }
7835
+
7836
+ function shouldUseNative() {
7837
+ try {
7838
+ if (!Object.assign) {
7839
+ return false;
7840
+ }
7841
+
7842
+ // Detect buggy property enumeration order in older V8 versions.
7843
+
7844
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
7845
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
7846
+ test1[5] = 'de';
7847
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
7848
+ return false;
7849
+ }
7850
+
7851
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
7852
+ var test2 = {};
7853
+ for (var i = 0; i < 10; i++) {
7854
+ test2['_' + String.fromCharCode(i)] = i;
7855
+ }
7856
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
7857
+ return test2[n];
7858
+ });
7859
+ if (order2.join('') !== '0123456789') {
7860
+ return false;
7861
+ }
7862
+
7863
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
7864
+ var test3 = {};
7865
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
7866
+ test3[letter] = letter;
7867
+ });
7868
+ if (Object.keys(Object.assign({}, test3)).join('') !==
7869
+ 'abcdefghijklmnopqrst') {
7870
+ return false;
7871
+ }
7872
+
7873
+ return true;
7874
+ } catch (err) {
7875
+ // We don't expect any of the above to throw, but better to be safe.
7876
+ return false;
7877
+ }
7878
+ }
7879
+
7880
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
7881
+ var from;
7882
+ var to = toObject(target);
7883
+ var symbols;
7884
+
7885
+ for (var s = 1; s < arguments.length; s++) {
7886
+ from = Object(arguments[s]);
7887
+
7888
+ for (var key in from) {
7889
+ if (hasOwnProperty.call(from, key)) {
7890
+ to[key] = from[key];
7891
+ }
7892
+ }
7893
+
7894
+ if (getOwnPropertySymbols) {
7895
+ symbols = getOwnPropertySymbols(from);
7896
+ for (var i = 0; i < symbols.length; i++) {
7897
+ if (propIsEnumerable.call(from, symbols[i])) {
7898
+ to[symbols[i]] = from[symbols[i]];
7899
+ }
7900
+ }
7901
+ }
7902
+ }
7903
+
7904
+ return to;
7905
+ };
7906
+ return objectAssign;
7907
+ }
7908
+
7909
+ /**
7910
+ * Copyright (c) 2013-present, Facebook, Inc.
7911
+ *
7912
+ * This source code is licensed under the MIT license found in the
7913
+ * LICENSE file in the root directory of this source tree.
7914
+ */
7915
+
7916
+ var ReactPropTypesSecret_1;
7917
+ var hasRequiredReactPropTypesSecret;
7918
+
7919
+ function requireReactPropTypesSecret () {
7920
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
7921
+ hasRequiredReactPropTypesSecret = 1;
7922
+
7923
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
7924
+
7925
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
7926
+ return ReactPropTypesSecret_1;
7927
+ }
7504
7928
 
7505
- // src/index.js
7506
- // if you want named import
7929
+ var has;
7930
+ var hasRequiredHas;
7931
+
7932
+ function requireHas () {
7933
+ if (hasRequiredHas) return has;
7934
+ hasRequiredHas = 1;
7935
+ has = Function.call.bind(Object.prototype.hasOwnProperty);
7936
+ return has;
7937
+ }
7938
+
7939
+ /**
7940
+ * Copyright (c) 2013-present, Facebook, Inc.
7941
+ *
7942
+ * This source code is licensed under the MIT license found in the
7943
+ * LICENSE file in the root directory of this source tree.
7944
+ */
7945
+
7946
+ var checkPropTypes_1;
7947
+ var hasRequiredCheckPropTypes;
7948
+
7949
+ function requireCheckPropTypes () {
7950
+ if (hasRequiredCheckPropTypes) return checkPropTypes_1;
7951
+ hasRequiredCheckPropTypes = 1;
7952
+
7953
+ var printWarning = function() {};
7954
+
7955
+ if (process.env.NODE_ENV !== 'production') {
7956
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
7957
+ var loggedTypeFailures = {};
7958
+ var has = /*@__PURE__*/ requireHas();
7959
+
7960
+ printWarning = function(text) {
7961
+ var message = 'Warning: ' + text;
7962
+ if (typeof console !== 'undefined') {
7963
+ console.error(message);
7964
+ }
7965
+ try {
7966
+ // --- Welcome to debugging React ---
7967
+ // This error was thrown as a convenience so that you can use this stack
7968
+ // to find the callsite that caused this warning to fire.
7969
+ throw new Error(message);
7970
+ } catch (x) { /**/ }
7971
+ };
7972
+ }
7973
+
7974
+ /**
7975
+ * Assert that the values match with the type specs.
7976
+ * Error messages are memorized and will only be shown once.
7977
+ *
7978
+ * @param {object} typeSpecs Map of name to a ReactPropType
7979
+ * @param {object} values Runtime values that need to be type-checked
7980
+ * @param {string} location e.g. "prop", "context", "child context"
7981
+ * @param {string} componentName Name of the component for error messages.
7982
+ * @param {?Function} getStack Returns the component stack.
7983
+ * @private
7984
+ */
7985
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
7986
+ if (process.env.NODE_ENV !== 'production') {
7987
+ for (var typeSpecName in typeSpecs) {
7988
+ if (has(typeSpecs, typeSpecName)) {
7989
+ var error;
7990
+ // Prop type validation may throw. In case they do, we don't want to
7991
+ // fail the render phase where it didn't fail before. So we log it.
7992
+ // After these have been cleaned up, we'll let them throw.
7993
+ try {
7994
+ // This is intentionally an invariant that gets caught. It's the same
7995
+ // behavior as without this statement except with a better message.
7996
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
7997
+ var err = Error(
7998
+ (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
7999
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
8000
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
8001
+ );
8002
+ err.name = 'Invariant Violation';
8003
+ throw err;
8004
+ }
8005
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
8006
+ } catch (ex) {
8007
+ error = ex;
8008
+ }
8009
+ if (error && !(error instanceof Error)) {
8010
+ printWarning(
8011
+ (componentName || 'React class') + ': type specification of ' +
8012
+ location + ' `' + typeSpecName + '` is invalid; the type checker ' +
8013
+ 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
8014
+ 'You may have forgotten to pass an argument to the type checker ' +
8015
+ 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
8016
+ 'shape all require an argument).'
8017
+ );
8018
+ }
8019
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
8020
+ // Only monitor this failure once because there tends to be a lot of the
8021
+ // same error.
8022
+ loggedTypeFailures[error.message] = true;
8023
+
8024
+ var stack = getStack ? getStack() : '';
8025
+
8026
+ printWarning(
8027
+ 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
8028
+ );
8029
+ }
8030
+ }
8031
+ }
8032
+ }
8033
+ }
8034
+
8035
+ /**
8036
+ * Resets warning cache when testing.
8037
+ *
8038
+ * @private
8039
+ */
8040
+ checkPropTypes.resetWarningCache = function() {
8041
+ if (process.env.NODE_ENV !== 'production') {
8042
+ loggedTypeFailures = {};
8043
+ }
8044
+ };
8045
+
8046
+ checkPropTypes_1 = checkPropTypes;
8047
+ return checkPropTypes_1;
8048
+ }
8049
+
8050
+ /**
8051
+ * Copyright (c) 2013-present, Facebook, Inc.
8052
+ *
8053
+ * This source code is licensed under the MIT license found in the
8054
+ * LICENSE file in the root directory of this source tree.
8055
+ */
8056
+
8057
+ var factoryWithTypeCheckers;
8058
+ var hasRequiredFactoryWithTypeCheckers;
8059
+
8060
+ function requireFactoryWithTypeCheckers () {
8061
+ if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
8062
+ hasRequiredFactoryWithTypeCheckers = 1;
8063
+
8064
+ var ReactIs = requireReactIs();
8065
+ var assign = requireObjectAssign();
8066
+
8067
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
8068
+ var has = /*@__PURE__*/ requireHas();
8069
+ var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
8070
+
8071
+ var printWarning = function() {};
8072
+
8073
+ if (process.env.NODE_ENV !== 'production') {
8074
+ printWarning = function(text) {
8075
+ var message = 'Warning: ' + text;
8076
+ if (typeof console !== 'undefined') {
8077
+ console.error(message);
8078
+ }
8079
+ try {
8080
+ // --- Welcome to debugging React ---
8081
+ // This error was thrown as a convenience so that you can use this stack
8082
+ // to find the callsite that caused this warning to fire.
8083
+ throw new Error(message);
8084
+ } catch (x) {}
8085
+ };
8086
+ }
8087
+
8088
+ function emptyFunctionThatReturnsNull() {
8089
+ return null;
8090
+ }
8091
+
8092
+ factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
8093
+ /* global Symbol */
8094
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
8095
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
8096
+
8097
+ /**
8098
+ * Returns the iterator method function contained on the iterable object.
8099
+ *
8100
+ * Be sure to invoke the function with the iterable as context:
8101
+ *
8102
+ * var iteratorFn = getIteratorFn(myIterable);
8103
+ * if (iteratorFn) {
8104
+ * var iterator = iteratorFn.call(myIterable);
8105
+ * ...
8106
+ * }
8107
+ *
8108
+ * @param {?object} maybeIterable
8109
+ * @return {?function}
8110
+ */
8111
+ function getIteratorFn(maybeIterable) {
8112
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
8113
+ if (typeof iteratorFn === 'function') {
8114
+ return iteratorFn;
8115
+ }
8116
+ }
8117
+
8118
+ /**
8119
+ * Collection of methods that allow declaration and validation of props that are
8120
+ * supplied to React components. Example usage:
8121
+ *
8122
+ * var Props = require('ReactPropTypes');
8123
+ * var MyArticle = React.createClass({
8124
+ * propTypes: {
8125
+ * // An optional string prop named "description".
8126
+ * description: Props.string,
8127
+ *
8128
+ * // A required enum prop named "category".
8129
+ * category: Props.oneOf(['News','Photos']).isRequired,
8130
+ *
8131
+ * // A prop named "dialog" that requires an instance of Dialog.
8132
+ * dialog: Props.instanceOf(Dialog).isRequired
8133
+ * },
8134
+ * render: function() { ... }
8135
+ * });
8136
+ *
8137
+ * A more formal specification of how these methods are used:
8138
+ *
8139
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
8140
+ * decl := ReactPropTypes.{type}(.isRequired)?
8141
+ *
8142
+ * Each and every declaration produces a function with the same signature. This
8143
+ * allows the creation of custom validation functions. For example:
8144
+ *
8145
+ * var MyLink = React.createClass({
8146
+ * propTypes: {
8147
+ * // An optional string or URI prop named "href".
8148
+ * href: function(props, propName, componentName) {
8149
+ * var propValue = props[propName];
8150
+ * if (propValue != null && typeof propValue !== 'string' &&
8151
+ * !(propValue instanceof URI)) {
8152
+ * return new Error(
8153
+ * 'Expected a string or an URI for ' + propName + ' in ' +
8154
+ * componentName
8155
+ * );
8156
+ * }
8157
+ * }
8158
+ * },
8159
+ * render: function() {...}
8160
+ * });
8161
+ *
8162
+ * @internal
8163
+ */
8164
+
8165
+ var ANONYMOUS = '<<anonymous>>';
8166
+
8167
+ // Important!
8168
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
8169
+ var ReactPropTypes = {
8170
+ array: createPrimitiveTypeChecker('array'),
8171
+ bigint: createPrimitiveTypeChecker('bigint'),
8172
+ bool: createPrimitiveTypeChecker('boolean'),
8173
+ func: createPrimitiveTypeChecker('function'),
8174
+ number: createPrimitiveTypeChecker('number'),
8175
+ object: createPrimitiveTypeChecker('object'),
8176
+ string: createPrimitiveTypeChecker('string'),
8177
+ symbol: createPrimitiveTypeChecker('symbol'),
8178
+
8179
+ any: createAnyTypeChecker(),
8180
+ arrayOf: createArrayOfTypeChecker,
8181
+ element: createElementTypeChecker(),
8182
+ elementType: createElementTypeTypeChecker(),
8183
+ instanceOf: createInstanceTypeChecker,
8184
+ node: createNodeChecker(),
8185
+ objectOf: createObjectOfTypeChecker,
8186
+ oneOf: createEnumTypeChecker,
8187
+ oneOfType: createUnionTypeChecker,
8188
+ shape: createShapeTypeChecker,
8189
+ exact: createStrictShapeTypeChecker,
8190
+ };
8191
+
8192
+ /**
8193
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
8194
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
8195
+ */
8196
+ /*eslint-disable no-self-compare*/
8197
+ function is(x, y) {
8198
+ // SameValue algorithm
8199
+ if (x === y) {
8200
+ // Steps 1-5, 7-10
8201
+ // Steps 6.b-6.e: +0 != -0
8202
+ return x !== 0 || 1 / x === 1 / y;
8203
+ } else {
8204
+ // Step 6.a: NaN == NaN
8205
+ return x !== x && y !== y;
8206
+ }
8207
+ }
8208
+ /*eslint-enable no-self-compare*/
8209
+
8210
+ /**
8211
+ * We use an Error-like object for backward compatibility as people may call
8212
+ * PropTypes directly and inspect their output. However, we don't use real
8213
+ * Errors anymore. We don't inspect their stack anyway, and creating them
8214
+ * is prohibitively expensive if they are created too often, such as what
8215
+ * happens in oneOfType() for any type before the one that matched.
8216
+ */
8217
+ function PropTypeError(message, data) {
8218
+ this.message = message;
8219
+ this.data = data && typeof data === 'object' ? data: {};
8220
+ this.stack = '';
8221
+ }
8222
+ // Make `instanceof Error` still work for returned errors.
8223
+ PropTypeError.prototype = Error.prototype;
8224
+
8225
+ function createChainableTypeChecker(validate) {
8226
+ if (process.env.NODE_ENV !== 'production') {
8227
+ var manualPropTypeCallCache = {};
8228
+ var manualPropTypeWarningCount = 0;
8229
+ }
8230
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
8231
+ componentName = componentName || ANONYMOUS;
8232
+ propFullName = propFullName || propName;
8233
+
8234
+ if (secret !== ReactPropTypesSecret) {
8235
+ if (throwOnDirectAccess) {
8236
+ // New behavior only for users of `prop-types` package
8237
+ var err = new Error(
8238
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
8239
+ 'Use `PropTypes.checkPropTypes()` to call them. ' +
8240
+ 'Read more at http://fb.me/use-check-prop-types'
8241
+ );
8242
+ err.name = 'Invariant Violation';
8243
+ throw err;
8244
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
8245
+ // Old behavior for people using React.PropTypes
8246
+ var cacheKey = componentName + ':' + propName;
8247
+ if (
8248
+ !manualPropTypeCallCache[cacheKey] &&
8249
+ // Avoid spamming the console because they are often not actionable except for lib authors
8250
+ manualPropTypeWarningCount < 3
8251
+ ) {
8252
+ printWarning(
8253
+ 'You are manually calling a React.PropTypes validation ' +
8254
+ 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
8255
+ 'and will throw in the standalone `prop-types` package. ' +
8256
+ 'You may be seeing this warning due to a third-party PropTypes ' +
8257
+ 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
8258
+ );
8259
+ manualPropTypeCallCache[cacheKey] = true;
8260
+ manualPropTypeWarningCount++;
8261
+ }
8262
+ }
8263
+ }
8264
+ if (props[propName] == null) {
8265
+ if (isRequired) {
8266
+ if (props[propName] === null) {
8267
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
8268
+ }
8269
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
8270
+ }
8271
+ return null;
8272
+ } else {
8273
+ return validate(props, propName, componentName, location, propFullName);
8274
+ }
8275
+ }
8276
+
8277
+ var chainedCheckType = checkType.bind(null, false);
8278
+ chainedCheckType.isRequired = checkType.bind(null, true);
8279
+
8280
+ return chainedCheckType;
8281
+ }
8282
+
8283
+ function createPrimitiveTypeChecker(expectedType) {
8284
+ function validate(props, propName, componentName, location, propFullName, secret) {
8285
+ var propValue = props[propName];
8286
+ var propType = getPropType(propValue);
8287
+ if (propType !== expectedType) {
8288
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
8289
+ // check, but we can offer a more precise error message here rather than
8290
+ // 'of type `object`'.
8291
+ var preciseType = getPreciseType(propValue);
8292
+
8293
+ return new PropTypeError(
8294
+ 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
8295
+ {expectedType: expectedType}
8296
+ );
8297
+ }
8298
+ return null;
8299
+ }
8300
+ return createChainableTypeChecker(validate);
8301
+ }
8302
+
8303
+ function createAnyTypeChecker() {
8304
+ return createChainableTypeChecker(emptyFunctionThatReturnsNull);
8305
+ }
8306
+
8307
+ function createArrayOfTypeChecker(typeChecker) {
8308
+ function validate(props, propName, componentName, location, propFullName) {
8309
+ if (typeof typeChecker !== 'function') {
8310
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
8311
+ }
8312
+ var propValue = props[propName];
8313
+ if (!Array.isArray(propValue)) {
8314
+ var propType = getPropType(propValue);
8315
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
8316
+ }
8317
+ for (var i = 0; i < propValue.length; i++) {
8318
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
8319
+ if (error instanceof Error) {
8320
+ return error;
8321
+ }
8322
+ }
8323
+ return null;
8324
+ }
8325
+ return createChainableTypeChecker(validate);
8326
+ }
8327
+
8328
+ function createElementTypeChecker() {
8329
+ function validate(props, propName, componentName, location, propFullName) {
8330
+ var propValue = props[propName];
8331
+ if (!isValidElement(propValue)) {
8332
+ var propType = getPropType(propValue);
8333
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
8334
+ }
8335
+ return null;
8336
+ }
8337
+ return createChainableTypeChecker(validate);
8338
+ }
8339
+
8340
+ function createElementTypeTypeChecker() {
8341
+ function validate(props, propName, componentName, location, propFullName) {
8342
+ var propValue = props[propName];
8343
+ if (!ReactIs.isValidElementType(propValue)) {
8344
+ var propType = getPropType(propValue);
8345
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
8346
+ }
8347
+ return null;
8348
+ }
8349
+ return createChainableTypeChecker(validate);
8350
+ }
8351
+
8352
+ function createInstanceTypeChecker(expectedClass) {
8353
+ function validate(props, propName, componentName, location, propFullName) {
8354
+ if (!(props[propName] instanceof expectedClass)) {
8355
+ var expectedClassName = expectedClass.name || ANONYMOUS;
8356
+ var actualClassName = getClassName(props[propName]);
8357
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
8358
+ }
8359
+ return null;
8360
+ }
8361
+ return createChainableTypeChecker(validate);
8362
+ }
8363
+
8364
+ function createEnumTypeChecker(expectedValues) {
8365
+ if (!Array.isArray(expectedValues)) {
8366
+ if (process.env.NODE_ENV !== 'production') {
8367
+ if (arguments.length > 1) {
8368
+ printWarning(
8369
+ 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
8370
+ 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
8371
+ );
8372
+ } else {
8373
+ printWarning('Invalid argument supplied to oneOf, expected an array.');
8374
+ }
8375
+ }
8376
+ return emptyFunctionThatReturnsNull;
8377
+ }
8378
+
8379
+ function validate(props, propName, componentName, location, propFullName) {
8380
+ var propValue = props[propName];
8381
+ for (var i = 0; i < expectedValues.length; i++) {
8382
+ if (is(propValue, expectedValues[i])) {
8383
+ return null;
8384
+ }
8385
+ }
8386
+
8387
+ var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
8388
+ var type = getPreciseType(value);
8389
+ if (type === 'symbol') {
8390
+ return String(value);
8391
+ }
8392
+ return value;
8393
+ });
8394
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
8395
+ }
8396
+ return createChainableTypeChecker(validate);
8397
+ }
8398
+
8399
+ function createObjectOfTypeChecker(typeChecker) {
8400
+ function validate(props, propName, componentName, location, propFullName) {
8401
+ if (typeof typeChecker !== 'function') {
8402
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
8403
+ }
8404
+ var propValue = props[propName];
8405
+ var propType = getPropType(propValue);
8406
+ if (propType !== 'object') {
8407
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
8408
+ }
8409
+ for (var key in propValue) {
8410
+ if (has(propValue, key)) {
8411
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
8412
+ if (error instanceof Error) {
8413
+ return error;
8414
+ }
8415
+ }
8416
+ }
8417
+ return null;
8418
+ }
8419
+ return createChainableTypeChecker(validate);
8420
+ }
8421
+
8422
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
8423
+ if (!Array.isArray(arrayOfTypeCheckers)) {
8424
+ process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
8425
+ return emptyFunctionThatReturnsNull;
8426
+ }
8427
+
8428
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
8429
+ var checker = arrayOfTypeCheckers[i];
8430
+ if (typeof checker !== 'function') {
8431
+ printWarning(
8432
+ 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
8433
+ 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
8434
+ );
8435
+ return emptyFunctionThatReturnsNull;
8436
+ }
8437
+ }
8438
+
8439
+ function validate(props, propName, componentName, location, propFullName) {
8440
+ var expectedTypes = [];
8441
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
8442
+ var checker = arrayOfTypeCheckers[i];
8443
+ var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
8444
+ if (checkerResult == null) {
8445
+ return null;
8446
+ }
8447
+ if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
8448
+ expectedTypes.push(checkerResult.data.expectedType);
8449
+ }
8450
+ }
8451
+ var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
8452
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
8453
+ }
8454
+ return createChainableTypeChecker(validate);
8455
+ }
8456
+
8457
+ function createNodeChecker() {
8458
+ function validate(props, propName, componentName, location, propFullName) {
8459
+ if (!isNode(props[propName])) {
8460
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
8461
+ }
8462
+ return null;
8463
+ }
8464
+ return createChainableTypeChecker(validate);
8465
+ }
8466
+
8467
+ function invalidValidatorError(componentName, location, propFullName, key, type) {
8468
+ return new PropTypeError(
8469
+ (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
8470
+ 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
8471
+ );
8472
+ }
8473
+
8474
+ function createShapeTypeChecker(shapeTypes) {
8475
+ function validate(props, propName, componentName, location, propFullName) {
8476
+ var propValue = props[propName];
8477
+ var propType = getPropType(propValue);
8478
+ if (propType !== 'object') {
8479
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
8480
+ }
8481
+ for (var key in shapeTypes) {
8482
+ var checker = shapeTypes[key];
8483
+ if (typeof checker !== 'function') {
8484
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
8485
+ }
8486
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
8487
+ if (error) {
8488
+ return error;
8489
+ }
8490
+ }
8491
+ return null;
8492
+ }
8493
+ return createChainableTypeChecker(validate);
8494
+ }
8495
+
8496
+ function createStrictShapeTypeChecker(shapeTypes) {
8497
+ function validate(props, propName, componentName, location, propFullName) {
8498
+ var propValue = props[propName];
8499
+ var propType = getPropType(propValue);
8500
+ if (propType !== 'object') {
8501
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
8502
+ }
8503
+ // We need to check all keys in case some are required but missing from props.
8504
+ var allKeys = assign({}, props[propName], shapeTypes);
8505
+ for (var key in allKeys) {
8506
+ var checker = shapeTypes[key];
8507
+ if (has(shapeTypes, key) && typeof checker !== 'function') {
8508
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
8509
+ }
8510
+ if (!checker) {
8511
+ return new PropTypeError(
8512
+ 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
8513
+ '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
8514
+ '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
8515
+ );
8516
+ }
8517
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
8518
+ if (error) {
8519
+ return error;
8520
+ }
8521
+ }
8522
+ return null;
8523
+ }
8524
+
8525
+ return createChainableTypeChecker(validate);
8526
+ }
8527
+
8528
+ function isNode(propValue) {
8529
+ switch (typeof propValue) {
8530
+ case 'number':
8531
+ case 'string':
8532
+ case 'undefined':
8533
+ return true;
8534
+ case 'boolean':
8535
+ return !propValue;
8536
+ case 'object':
8537
+ if (Array.isArray(propValue)) {
8538
+ return propValue.every(isNode);
8539
+ }
8540
+ if (propValue === null || isValidElement(propValue)) {
8541
+ return true;
8542
+ }
8543
+
8544
+ var iteratorFn = getIteratorFn(propValue);
8545
+ if (iteratorFn) {
8546
+ var iterator = iteratorFn.call(propValue);
8547
+ var step;
8548
+ if (iteratorFn !== propValue.entries) {
8549
+ while (!(step = iterator.next()).done) {
8550
+ if (!isNode(step.value)) {
8551
+ return false;
8552
+ }
8553
+ }
8554
+ } else {
8555
+ // Iterator will provide entry [k,v] tuples rather than values.
8556
+ while (!(step = iterator.next()).done) {
8557
+ var entry = step.value;
8558
+ if (entry) {
8559
+ if (!isNode(entry[1])) {
8560
+ return false;
8561
+ }
8562
+ }
8563
+ }
8564
+ }
8565
+ } else {
8566
+ return false;
8567
+ }
8568
+
8569
+ return true;
8570
+ default:
8571
+ return false;
8572
+ }
8573
+ }
8574
+
8575
+ function isSymbol(propType, propValue) {
8576
+ // Native Symbol.
8577
+ if (propType === 'symbol') {
8578
+ return true;
8579
+ }
8580
+
8581
+ // falsy value can't be a Symbol
8582
+ if (!propValue) {
8583
+ return false;
8584
+ }
8585
+
8586
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
8587
+ if (propValue['@@toStringTag'] === 'Symbol') {
8588
+ return true;
8589
+ }
8590
+
8591
+ // Fallback for non-spec compliant Symbols which are polyfilled.
8592
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
8593
+ return true;
8594
+ }
8595
+
8596
+ return false;
8597
+ }
8598
+
8599
+ // Equivalent of `typeof` but with special handling for array and regexp.
8600
+ function getPropType(propValue) {
8601
+ var propType = typeof propValue;
8602
+ if (Array.isArray(propValue)) {
8603
+ return 'array';
8604
+ }
8605
+ if (propValue instanceof RegExp) {
8606
+ // Old webkits (at least until Android 4.0) return 'function' rather than
8607
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
8608
+ // passes PropTypes.object.
8609
+ return 'object';
8610
+ }
8611
+ if (isSymbol(propType, propValue)) {
8612
+ return 'symbol';
8613
+ }
8614
+ return propType;
8615
+ }
8616
+
8617
+ // This handles more types than `getPropType`. Only used for error messages.
8618
+ // See `createPrimitiveTypeChecker`.
8619
+ function getPreciseType(propValue) {
8620
+ if (typeof propValue === 'undefined' || propValue === null) {
8621
+ return '' + propValue;
8622
+ }
8623
+ var propType = getPropType(propValue);
8624
+ if (propType === 'object') {
8625
+ if (propValue instanceof Date) {
8626
+ return 'date';
8627
+ } else if (propValue instanceof RegExp) {
8628
+ return 'regexp';
8629
+ }
8630
+ }
8631
+ return propType;
8632
+ }
8633
+
8634
+ // Returns a string that is postfixed to a warning about an invalid type.
8635
+ // For example, "undefined" or "of type array"
8636
+ function getPostfixForTypeWarning(value) {
8637
+ var type = getPreciseType(value);
8638
+ switch (type) {
8639
+ case 'array':
8640
+ case 'object':
8641
+ return 'an ' + type;
8642
+ case 'boolean':
8643
+ case 'date':
8644
+ case 'regexp':
8645
+ return 'a ' + type;
8646
+ default:
8647
+ return type;
8648
+ }
8649
+ }
8650
+
8651
+ // Returns class name of the object, if any.
8652
+ function getClassName(propValue) {
8653
+ if (!propValue.constructor || !propValue.constructor.name) {
8654
+ return ANONYMOUS;
8655
+ }
8656
+ return propValue.constructor.name;
8657
+ }
8658
+
8659
+ ReactPropTypes.checkPropTypes = checkPropTypes;
8660
+ ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
8661
+ ReactPropTypes.PropTypes = ReactPropTypes;
8662
+
8663
+ return ReactPropTypes;
8664
+ };
8665
+ return factoryWithTypeCheckers;
8666
+ }
8667
+
8668
+ /**
8669
+ * Copyright (c) 2013-present, Facebook, Inc.
8670
+ *
8671
+ * This source code is licensed under the MIT license found in the
8672
+ * LICENSE file in the root directory of this source tree.
8673
+ */
8674
+
8675
+ var factoryWithThrowingShims;
8676
+ var hasRequiredFactoryWithThrowingShims;
8677
+
8678
+ function requireFactoryWithThrowingShims () {
8679
+ if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
8680
+ hasRequiredFactoryWithThrowingShims = 1;
8681
+
8682
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
8683
+
8684
+ function emptyFunction() {}
8685
+ function emptyFunctionWithReset() {}
8686
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
8687
+
8688
+ factoryWithThrowingShims = function() {
8689
+ function shim(props, propName, componentName, location, propFullName, secret) {
8690
+ if (secret === ReactPropTypesSecret) {
8691
+ // It is still safe when called from React.
8692
+ return;
8693
+ }
8694
+ var err = new Error(
8695
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
8696
+ 'Use PropTypes.checkPropTypes() to call them. ' +
8697
+ 'Read more at http://fb.me/use-check-prop-types'
8698
+ );
8699
+ err.name = 'Invariant Violation';
8700
+ throw err;
8701
+ } shim.isRequired = shim;
8702
+ function getShim() {
8703
+ return shim;
8704
+ } // Important!
8705
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
8706
+ var ReactPropTypes = {
8707
+ array: shim,
8708
+ bigint: shim,
8709
+ bool: shim,
8710
+ func: shim,
8711
+ number: shim,
8712
+ object: shim,
8713
+ string: shim,
8714
+ symbol: shim,
8715
+
8716
+ any: shim,
8717
+ arrayOf: getShim,
8718
+ element: shim,
8719
+ elementType: shim,
8720
+ instanceOf: getShim,
8721
+ node: shim,
8722
+ objectOf: getShim,
8723
+ oneOf: getShim,
8724
+ oneOfType: getShim,
8725
+ shape: getShim,
8726
+ exact: getShim,
8727
+
8728
+ checkPropTypes: emptyFunctionWithReset,
8729
+ resetWarningCache: emptyFunction
8730
+ };
8731
+
8732
+ ReactPropTypes.PropTypes = ReactPropTypes;
8733
+
8734
+ return ReactPropTypes;
8735
+ };
8736
+ return factoryWithThrowingShims;
8737
+ }
8738
+
8739
+ /**
8740
+ * Copyright (c) 2013-present, Facebook, Inc.
8741
+ *
8742
+ * This source code is licensed under the MIT license found in the
8743
+ * LICENSE file in the root directory of this source tree.
8744
+ */
8745
+
8746
+ var hasRequiredPropTypes;
8747
+
8748
+ function requirePropTypes () {
8749
+ if (hasRequiredPropTypes) return propTypes.exports;
8750
+ hasRequiredPropTypes = 1;
8751
+ if (process.env.NODE_ENV !== 'production') {
8752
+ var ReactIs = requireReactIs();
8753
+
8754
+ // By explicitly using `prop-types` you are opting into new development behavior.
8755
+ // http://fb.me/prop-types-in-prod
8756
+ var throwOnDirectAccess = true;
8757
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
8758
+ } else {
8759
+ // By explicitly using `prop-types` you are opting into new production behavior.
8760
+ // http://fb.me/prop-types-in-prod
8761
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
8762
+ }
8763
+ return propTypes.exports;
8764
+ }
8765
+
8766
+ var propTypesExports = /*@__PURE__*/ requirePropTypes();
8767
+ var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
8768
+
8769
+ /**
8770
+ * DateTimeInput (redesigned) - matches RangePicker visual style with dropdown panel.
8771
+ * Features:
8772
+ * - Single date (and optional time) selection via custom calendar popup
8773
+ * - URL param sync (stores timestamp) same as RangePicker
8774
+ * - Dynamic dropdown positioning (prevents overflow like RangePicker)
8775
+ * - Clear & OK footer actions
8776
+ */
8777
+ function DateTimeInput({
8778
+ pushUrlParamObj = false,
8779
+ value: controlledValue,
8780
+ onChange,
8781
+ time = false,
8782
+ timeStart,
8783
+ timezone,
8784
+ timeFormat,
8785
+ dateFormat,
8786
+ placeholder = "Select date",
8787
+ disabled = false,
8788
+ className = "",
8789
+ style = {},
8790
+ predefinedRanges = ["today", "yesterday"],
8791
+ ...rest
8792
+ }) {
8793
+ const paramKey = pushUrlParamObj || null;
8794
+
8795
+ // Helper: convert timestamp (number|string) to internal input string
8796
+ const toInputString = useCallback(ts => {
8797
+ if (!ts) return "";
8798
+ const d = new Date(Number(ts));
8799
+ if (isNaN(d.getTime())) return "";
8800
+ const yyyy = d.getFullYear();
8801
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
8802
+ const dd = String(d.getDate()).padStart(2, '0');
8803
+ if (time) {
8804
+ const hh = String(d.getHours()).padStart(2, '0');
8805
+ const min = String(d.getMinutes()).padStart(2, '0');
8806
+ return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
8807
+ }
8808
+ return `${yyyy}-${mm}-${dd}`;
8809
+ }, [time]);
8810
+
8811
+ // Initial value
8812
+ const [value, setValue] = useState(() => {
8813
+ if (typeof controlledValue !== "undefined") return controlledValue;
8814
+ if (!paramKey) {
8815
+ let d = new Date();
8816
+ if (time && timeStart) {
8817
+ const [h, m] = timeStart.split(":");
8818
+ d.setHours(Number(h), Number(m), 0, 0);
8819
+ }
8820
+ return toInputString(d.getTime());
8821
+ }
8822
+ const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
8823
+ const urlVal = params.get(paramKey);
8824
+ if (urlVal) return toInputString(urlVal);
8825
+ let d = new Date();
8826
+ if (time && timeStart) {
8827
+ const [h, m] = timeStart.split(":");
8828
+ d.setHours(Number(h), Number(m), 0, 0);
8829
+ }
8830
+ return toInputString(d.getTime());
8831
+ });
8832
+
8833
+ // Dropdown state & positioning
8834
+ const [open, setOpen] = useState(false);
8835
+ const dropdownRef = useRef(null);
8836
+ const [dropdownPosition, setDropdownPosition] = useState({
8837
+ left: 0,
8838
+ top: "110%"
8839
+ });
8840
+
8841
+ // Predefined single-date shortcuts
8842
+ const normalizeLabel = lbl => String(lbl).toLowerCase();
8843
+ const createPredefinedItem = useCallback(item => {
8844
+ if (typeof item === 'number') {
8845
+ // number => N days ago
8846
+ return {
8847
+ key: `daysago_${item}`,
8848
+ label: `-${item}d`,
8849
+ getDate: () => {
8850
+ const d = new Date();
8851
+ d.setHours(0, 0, 0, 0);
8852
+ d.setDate(d.getDate() - item);
8853
+ return d;
8854
+ }
8855
+ };
8856
+ }
8857
+ const str = normalizeLabel(item);
8858
+ if (str === 'today') {
8859
+ return {
8860
+ key: 'today',
8861
+ label: 'Today',
8862
+ getDate: () => {
8863
+ const d = new Date();
8864
+ d.setHours(0, 0, 0, 0);
8865
+ return d;
8866
+ }
8867
+ };
8868
+ }
8869
+ if (str === 'yesterday') {
8870
+ return {
8871
+ key: 'yesterday',
8872
+ label: 'Yesterday',
8873
+ getDate: () => {
8874
+ const d = new Date();
8875
+ d.setHours(0, 0, 0, 0);
8876
+ d.setDate(d.getDate() - 1);
8877
+ return d;
8878
+ }
8879
+ };
8880
+ }
8881
+ if (str === 'lastweek') {
8882
+ return {
8883
+ key: 'lastweek',
8884
+ label: 'Last week (Mon)',
8885
+ getDate: () => {
8886
+ // Monday of previous week
8887
+ const d = new Date();
8888
+ d.setHours(0, 0, 0, 0);
8889
+ const day = d.getDay(); // 0 Sun..6 Sat
8890
+ const mondayOffset = day === 0 ? -6 : 1 - day; // days to monday this week
8891
+ d.setDate(d.getDate() + mondayOffset - 7); // previous week's Monday
8892
+ return d;
8893
+ }
8894
+ };
8895
+ }
8896
+ if (str === 'lastmonth') {
8897
+ return {
8898
+ key: 'lastmonth',
8899
+ label: 'First day last month',
8900
+ getDate: () => {
8901
+ const d = new Date();
8902
+ d.setHours(0, 0, 0, 0);
8903
+ d.setMonth(d.getMonth() - 1, 1);
8904
+ return d;
8905
+ }
8906
+ };
8907
+ }
8908
+ if (str === 'thismonth') {
8909
+ return {
8910
+ key: 'thismonth',
8911
+ label: 'First day this month',
8912
+ getDate: () => {
8913
+ const d = new Date();
8914
+ d.setHours(0, 0, 0, 0);
8915
+ d.setDate(1);
8916
+ return d;
8917
+ }
8918
+ };
8919
+ }
8920
+ if (str === 'lastyear') {
8921
+ return {
8922
+ key: 'lastyear',
8923
+ label: 'Jan 1 last year',
8924
+ getDate: () => {
8925
+ const d = new Date();
8926
+ d.setHours(0, 0, 0, 0);
8927
+ d.setFullYear(d.getFullYear() - 1, 0, 1);
8928
+ return d;
8929
+ }
8930
+ };
8931
+ }
8932
+ return {
8933
+ key: str,
8934
+ label: item,
8935
+ getDate: () => {
8936
+ const d = new Date();
8937
+ d.setHours(0, 0, 0, 0);
8938
+ return d;
8939
+ }
8940
+ };
8941
+ }, []);
8942
+ const PREDEFINED = useMemo(() => predefinedRanges.map(createPredefinedItem), [predefinedRanges, createPredefinedItem]);
8943
+ const [selectedPredefined, setSelectedPredefined] = useState("");
8944
+ useEffect(() => {
8945
+ if (open && dropdownRef.current) {
8946
+ const rect = dropdownRef.current.getBoundingClientRect();
8947
+ const viewportWidth = window.innerWidth;
8948
+ const viewportHeight = window.innerHeight;
8949
+ const newPosition = {
8950
+ left: '0',
8951
+ top: '110%'
8952
+ };
8953
+ if (rect.right > viewportWidth - 10) newPosition.right = 0, delete newPosition.left; // align right
8954
+ if (rect.bottom > viewportHeight - 10) newPosition.top = 'auto', newPosition.bottom = '110%';
8955
+ setDropdownPosition(newPosition);
8956
+ }
8957
+ }, [open]);
8958
+
8959
+ // Calendar month state (always show month of selected value; allow navigation)
8960
+ const selectedDate = useMemo(() => value ? new Date(value) : null, [value]);
8961
+ const [monthCursor, setMonthCursor] = useState(() => {
8962
+ const d = selectedDate || new Date();
8963
+ return new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0);
8964
+ });
8965
+ // Keep monthCursor in sync when selected date changes externally
8966
+ useEffect(() => {
8967
+ if (selectedDate) {
8968
+ setMonthCursor(new Date(selectedDate.getFullYear(), selectedDate.getMonth(), 1));
8969
+ }
8970
+ // Match predefined
8971
+ if (selectedDate) {
8972
+ const ts = selectedDate.getTime();
8973
+ for (let i = 0; i < PREDEFINED.length; i++) {
8974
+ const d = PREDEFINED[i].getDate();
8975
+ if (d.getTime() === ts) {
8976
+ setSelectedPredefined(String(i));
8977
+ return;
8978
+ }
8979
+ }
8980
+ setSelectedPredefined("");
8981
+ } else {
8982
+ setSelectedPredefined("");
8983
+ }
8984
+ }, [value, selectedDate, PREDEFINED]);
8985
+
8986
+ // Build calendar days (6 weeks grid)
8987
+ const buildDays = () => {
8988
+ const startOfMonth = new Date(monthCursor.getFullYear(), monthCursor.getMonth(), 1);
8989
+ const dayOfWeek = startOfMonth.getDay(); // 0 Sun ... 6 Sat
8990
+ // We start at Sunday of the week containing the 1st
8991
+ const firstGridDate = new Date(startOfMonth);
8992
+ firstGridDate.setDate(startOfMonth.getDate() - dayOfWeek);
8993
+ const days = [];
8994
+ for (let i = 0; i < 42; i++) {
8995
+ // 6 weeks
8996
+ const d = new Date(firstGridDate);
8997
+ d.setDate(firstGridDate.getDate() + i);
8998
+ days.push(d);
8999
+ }
9000
+ return days;
9001
+ };
9002
+ const days = buildDays();
9003
+
9004
+ // Update URL param
9005
+ const setUrlParam = useCallback(val => {
9006
+ if (!paramKey) return;
9007
+ const params = new URLSearchParams(window.location.search);
9008
+ let ts = val;
9009
+ if (val && typeof val === "string" && !/^[0-9]+$/.test(val)) {
9010
+ const d = new Date(val);
9011
+ ts = d.getTime();
9012
+ }
9013
+ if (ts && String(ts).length > 0 && !isNaN(Number(ts))) params.set(paramKey, String(ts));else params.delete(paramKey);
9014
+ const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
9015
+ window.history.replaceState({}, "", newUrl);
9016
+ }, [paramKey]);
9017
+
9018
+ // Sync from URL
9019
+ useEffect(() => {
9020
+ if (!paramKey || typeof controlledValue !== 'undefined') return;
9021
+ const syncFromUrl = () => {
9022
+ const params = new URLSearchParams(window.location.search);
9023
+ const urlVal = params.get(paramKey);
9024
+ if (urlVal) {
9025
+ const str = toInputString(urlVal);
9026
+ setValue(prev => prev !== str ? str : prev);
9027
+ if (onChange && str !== controlledValue) onChange(urlVal);
9028
+ }
9029
+ };
9030
+ syncFromUrl();
9031
+ window.addEventListener('popstate', syncFromUrl);
9032
+ const patchHistory = type => {
9033
+ const orig = window.history[type];
9034
+ window.history[type] = function () {
9035
+ const rv = orig.apply(this, arguments);
9036
+ window.dispatchEvent(new Event(type));
9037
+ return rv;
9038
+ };
9039
+ };
9040
+ patchHistory('pushState');
9041
+ patchHistory('replaceState');
9042
+ window.addEventListener('pushState', syncFromUrl);
9043
+ window.addEventListener('replaceState', syncFromUrl);
9044
+ return () => {
9045
+ window.removeEventListener('popstate', syncFromUrl);
9046
+ window.removeEventListener('pushState', syncFromUrl);
9047
+ window.removeEventListener('replaceState', syncFromUrl);
9048
+ };
9049
+ }, [paramKey, controlledValue, onChange, toInputString]);
9050
+
9051
+ // Controlled value sync
9052
+ useEffect(() => {
9053
+ if (typeof controlledValue !== 'undefined') setValue(controlledValue);
9054
+ }, [controlledValue]);
9055
+
9056
+ // Formatting display (similar to RangePicker)
9057
+ const formatDisplay = () => {
9058
+ if (!value) return "";
9059
+ const d = new Date(value);
9060
+ if (isNaN(d.getTime())) return "";
9061
+ const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
9062
+ const yyyy = d.getFullYear();
9063
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
9064
+ const dd = String(d.getDate()).padStart(2, '0');
9065
+ let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
9066
+ if (time) {
9067
+ const actualTimeFormat = timeFormat || 'HH:mm';
9068
+ const hh = String(d.getHours()).padStart(2, '0');
9069
+ const min = String(d.getMinutes()).padStart(2, '0');
9070
+ const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
9071
+ return `${dateStr} ${timeStr}`;
9072
+ }
9073
+ return dateStr;
9074
+ };
9075
+ const applySelection = d => {
9076
+ const dt = new Date(d);
9077
+ if (time && timeStart && !value) {
9078
+ // apply timeStart if initial selection
9079
+ const [h, m] = timeStart.split(":");
9080
+ dt.setHours(Number(h), Number(m), 0, 0);
9081
+ }
9082
+ const str = toInputString(dt.getTime());
9083
+ if (typeof controlledValue === 'undefined') setValue(str);
9084
+ setUrlParam(str);
9085
+ onChange?.(str);
9086
+ };
9087
+ const handlePredefinedClick = idx => {
9088
+ const item = PREDEFINED[idx];
9089
+ const d = item.getDate();
9090
+ if (time && timeStart) {
9091
+ const [h, m] = (timeStart || "00:00").split(":");
9092
+ d.setHours(Number(h), Number(m), 0, 0);
9093
+ }
9094
+ applySelection(d);
9095
+ setSelectedPredefined(String(idx));
9096
+ };
9097
+ const handleDayClick = day => {
9098
+ applySelection(day);
9099
+ };
9100
+ const handleTimeChange = e => {
9101
+ const t = e.target.value; // HH:mm
9102
+ if (!value) return;
9103
+ const d = new Date(value);
9104
+ const [h, m] = t.split(":");
9105
+ d.setHours(Number(h), Number(m), 0, 0);
9106
+ const str = toInputString(d.getTime());
9107
+ if (typeof controlledValue === 'undefined') setValue(str);
9108
+ setUrlParam(str);
9109
+ onChange?.(str);
9110
+ };
9111
+ const handleClear = () => {
9112
+ if (typeof controlledValue === 'undefined') setValue("");
9113
+ setUrlParam("");
9114
+ onChange?.("");
9115
+ };
9116
+
9117
+ // Outside click close
9118
+ useEffect(() => {
9119
+ if (!open) return;
9120
+ const onClick = e => {
9121
+ if (!e.target.closest('.datetime-input-dropdown')) setOpen(false);
9122
+ };
9123
+ window.addEventListener('mousedown', onClick);
9124
+ return () => window.removeEventListener('mousedown', onClick);
9125
+ }, [open]);
9126
+ return /*#__PURE__*/React__default.createElement("div", _extends$1({
9127
+ className: `datetime-input-wrapper ${className}`,
9128
+ style: {
9129
+ position: 'relative',
9130
+ display: 'inline-block',
9131
+ ...style
9132
+ }
9133
+ }, rest), /*#__PURE__*/React__default.createElement("div", {
9134
+ className: "basic-input",
9135
+ onClick: () => !disabled && setOpen(o => !o),
9136
+ style: {
9137
+ cursor: disabled ? 'not-allowed' : 'pointer',
9138
+ padding: '6px 8px',
9139
+ minWidth: 180,
9140
+ userSelect: 'none',
9141
+ position: 'relative'
9142
+ },
9143
+ "data-timestart": timeStart || undefined,
9144
+ "data-timezone": timezone || undefined,
9145
+ "data-timeformat": timeFormat || undefined,
9146
+ "data-dateformat": dateFormat || undefined
9147
+ }, formatDisplay() || placeholder, value && /*#__PURE__*/React__default.createElement("span", {
9148
+ onClick: e => {
9149
+ e.stopPropagation();
9150
+ handleClear();
9151
+ },
9152
+ title: "Clear date",
9153
+ style: {
9154
+ position: 'absolute',
9155
+ right: 8,
9156
+ top: '50%',
9157
+ transform: 'translateY(-50%)',
9158
+ fontSize: 12,
9159
+ cursor: 'pointer'
9160
+ }
9161
+ }, "\u2716")), open && /*#__PURE__*/React__default.createElement("div", {
9162
+ ref: dropdownRef,
9163
+ className: "datetime-input-dropdown range-picker-dropdown" // reuse class for styling consistency
9164
+ ,
9165
+ style: {
9166
+ position: 'absolute',
9167
+ zIndex: 50,
9168
+ background: '#fff',
9169
+ border: '1px solid #d9d9d9',
9170
+ borderRadius: 4,
9171
+ boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
9172
+ padding: 12,
9173
+ width: 320,
9174
+ ...dropdownPosition
9175
+ }
9176
+ }, PREDEFINED.length > 0 && /*#__PURE__*/React__default.createElement("div", {
9177
+ style: {
9178
+ display: 'flex',
9179
+ flexWrap: 'wrap',
9180
+ gap: 6,
9181
+ marginBottom: 8
9182
+ }
9183
+ }, PREDEFINED.map((p, i) => {
9184
+ const active = selectedPredefined === String(i);
9185
+ return /*#__PURE__*/React__default.createElement("button", {
9186
+ key: p.key,
9187
+ type: "button",
9188
+ onClick: () => handlePredefinedClick(i),
9189
+ className: "basic-btn",
9190
+ style: {
9191
+ padding: '4px 8px',
9192
+ fontSize: 12,
9193
+ background: active ? '#1677ff' : '#fff',
9194
+ color: active ? '#fff' : '#000',
9195
+ border: active ? '1px solid #1677ff' : '1px solid #d9d9d9'
9196
+ }
9197
+ }, p.label);
9198
+ })), /*#__PURE__*/React__default.createElement("div", {
9199
+ style: {
9200
+ display: 'flex',
9201
+ justifyContent: 'space-between',
9202
+ alignItems: 'center',
9203
+ marginBottom: 8
9204
+ }
9205
+ }, /*#__PURE__*/React__default.createElement("button", {
9206
+ type: "button",
9207
+ className: "basic-btn",
9208
+ onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() - 1, 1))
9209
+ }, "\u2039"), /*#__PURE__*/React__default.createElement("div", {
9210
+ style: {
9211
+ fontWeight: 600
9212
+ }
9213
+ }, monthCursor.toLocaleString(undefined, {
9214
+ month: 'long'
9215
+ }), " ", monthCursor.getFullYear()), /*#__PURE__*/React__default.createElement("button", {
9216
+ type: "button",
9217
+ className: "basic-btn",
9218
+ onClick: () => setMonthCursor(new Date(monthCursor.getFullYear(), monthCursor.getMonth() + 1, 1))
9219
+ }, "\u203A")), /*#__PURE__*/React__default.createElement("div", {
9220
+ style: {
9221
+ display: 'grid',
9222
+ gridTemplateColumns: 'repeat(7, 1fr)',
9223
+ fontSize: 12,
9224
+ marginBottom: 4,
9225
+ opacity: 0.8
9226
+ }
9227
+ }, ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(d => /*#__PURE__*/React__default.createElement("div", {
9228
+ key: d,
9229
+ style: {
9230
+ textAlign: 'center'
9231
+ }
9232
+ }, d))), /*#__PURE__*/React__default.createElement("div", {
9233
+ style: {
9234
+ display: 'grid',
9235
+ gridTemplateColumns: 'repeat(7, 1fr)',
9236
+ gap: 2
9237
+ }
9238
+ }, days.map(d => {
9239
+ const isCurrentMonth = d.getMonth() === monthCursor.getMonth();
9240
+ const isSelected = selectedDate && d.getFullYear() === selectedDate.getFullYear() && d.getMonth() === selectedDate.getMonth() && d.getDate() === selectedDate.getDate();
9241
+ const isToday = (() => {
9242
+ const t = new Date();
9243
+ return t.getFullYear() === d.getFullYear() && t.getMonth() === d.getMonth() && t.getDate() === d.getDate();
9244
+ })();
9245
+ return /*#__PURE__*/React__default.createElement("div", {
9246
+ key: d.toISOString(),
9247
+ onClick: () => handleDayClick(d),
9248
+ style: {
9249
+ textAlign: 'center',
9250
+ padding: '6px 0',
9251
+ cursor: 'pointer',
9252
+ fontSize: 12,
9253
+ borderRadius: 4,
9254
+ background: isSelected ? '#1677ff' : isToday ? '#e6f4ff' : 'transparent',
9255
+ color: isSelected ? '#fff' : isCurrentMonth ? '#000' : '#aaa',
9256
+ border: isSelected ? '1px solid #1677ff' : '1px solid transparent'
9257
+ }
9258
+ }, d.getDate());
9259
+ })), time && /*#__PURE__*/React__default.createElement("div", {
9260
+ style: {
9261
+ marginTop: 10
9262
+ }
9263
+ }, /*#__PURE__*/React__default.createElement("label", {
9264
+ style: {
9265
+ fontSize: 12,
9266
+ display: 'block',
9267
+ marginBottom: 4
9268
+ }
9269
+ }, "Time:"), /*#__PURE__*/React__default.createElement("input", {
9270
+ type: "time",
9271
+ value: (() => {
9272
+ if (!value) return '';
9273
+ const d = new Date(value);
9274
+ const hh = String(d.getHours()).padStart(2, '0');
9275
+ const mm = String(d.getMinutes()).padStart(2, '0');
9276
+ return `${hh}:${mm}`;
9277
+ })(),
9278
+ onChange: handleTimeChange,
9279
+ className: "basic-input",
9280
+ style: {
9281
+ width: '100%'
9282
+ }
9283
+ })), /*#__PURE__*/React__default.createElement("div", {
9284
+ style: {
9285
+ display: 'flex',
9286
+ justifyContent: 'space-between',
9287
+ alignItems: 'center',
9288
+ marginTop: 12
9289
+ }
9290
+ }, /*#__PURE__*/React__default.createElement("div", {
9291
+ style: {
9292
+ display: 'flex',
9293
+ gap: 8
9294
+ }
9295
+ }, /*#__PURE__*/React__default.createElement("button", {
9296
+ type: "button",
9297
+ className: "basic-btn",
9298
+ onClick: () => {
9299
+ handleClear();
9300
+ }
9301
+ }, "Clear"), /*#__PURE__*/React__default.createElement("button", {
9302
+ type: "button",
9303
+ className: "basic-btn",
9304
+ onClick: () => {
9305
+ setOpen(false);
9306
+ }
9307
+ }, "OK")), /*#__PURE__*/React__default.createElement("button", {
9308
+ type: "button",
9309
+ className: "basic-btn",
9310
+ onClick: () => {
9311
+ handlePredefinedClick(PREDEFINED.findIndex(p => p.key === 'today'));
9312
+ }
9313
+ }, "Today"))));
9314
+ }
9315
+ DateTimeInput.propTypes = {
9316
+ pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
9317
+ value: PropTypes.string,
9318
+ onChange: PropTypes.func,
9319
+ time: PropTypes.bool,
9320
+ timeStart: PropTypes.string,
9321
+ timezone: PropTypes.string,
9322
+ timeFormat: PropTypes.string,
9323
+ dateFormat: PropTypes.string,
9324
+ placeholder: PropTypes.string,
9325
+ disabled: PropTypes.bool,
9326
+ className: PropTypes.string,
9327
+ style: PropTypes.object,
9328
+ predefinedRanges: PropTypes.array
9329
+ };
9330
+
9331
+ /**
9332
+ * CalendarRangePicker - Custom calendar UI for selecting date ranges
9333
+ * Props:
9334
+ * startDate: Date | null
9335
+ * endDate: Date | null
9336
+ * onChange: (startDate, endDate) => void
9337
+ * time: boolean - if true, show time selectors
9338
+ * timeStart, timeEnd: default times for start/end
9339
+ */
9340
+ function CalendarRangePicker({
9341
+ startDate,
9342
+ endDate,
9343
+ onChange,
9344
+ time = false,
9345
+ timeStart = "00:00",
9346
+ timeEnd = "23:59"
9347
+ }) {
9348
+ // Current view months (show 2 months)
9349
+ const [leftMonth, setLeftMonth] = useState(() => {
9350
+ const d = startDate ? new Date(startDate) : new Date();
9351
+ return new Date(d.getFullYear(), d.getMonth(), 1);
9352
+ });
9353
+ const rightMonth = new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1);
9354
+
9355
+ // Update leftMonth when startDate changes (e.g., when selecting predefined ranges)
9356
+ React__default.useEffect(() => {
9357
+ if (startDate) {
9358
+ const d = new Date(startDate);
9359
+ setLeftMonth(new Date(d.getFullYear(), d.getMonth(), 1));
9360
+ }
9361
+ }, [startDate]);
9362
+
9363
+ // Hover state for preview
9364
+ const [hoverDate, setHoverDate] = useState(null);
9365
+
9366
+ // Navigate months
9367
+ const prevMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() - 1, 1));
9368
+ const nextMonth = () => setLeftMonth(new Date(leftMonth.getFullYear(), leftMonth.getMonth() + 1, 1));
9369
+
9370
+ // Handle date click
9371
+ const handleDateClick = date => {
9372
+ const d = new Date(date);
9373
+ if (time && startDate && timeStart) {
9374
+ const [h, m] = timeStart.split(":");
9375
+ d.setHours(Number(h), Number(m), 0, 0);
9376
+ }
9377
+ if (!startDate || startDate && endDate) {
9378
+ // Start new range
9379
+ onChange(d, null);
9380
+ } else {
9381
+ // Complete range
9382
+ if (d < startDate) {
9383
+ onChange(d, startDate);
9384
+ } else {
9385
+ const endD = new Date(d);
9386
+ if (time && timeEnd) {
9387
+ const [h, m] = timeEnd.split(":");
9388
+ endD.setHours(Number(h), Number(m), 59, 999);
9389
+ }
9390
+ onChange(startDate, endD);
9391
+ }
9392
+ }
9393
+ };
9394
+
9395
+ // Check if date is in range
9396
+ const isInRange = date => {
9397
+ if (!startDate) return false;
9398
+ const check = endDate || hoverDate;
9399
+ if (!check) return false;
9400
+ const d = new Date(date).setHours(0, 0, 0, 0);
9401
+ const s = new Date(startDate).setHours(0, 0, 0, 0);
9402
+ const e = new Date(check).setHours(0, 0, 0, 0);
9403
+ return d >= Math.min(s, e) && d <= Math.max(s, e);
9404
+ };
9405
+ const isStartDate = date => {
9406
+ if (!startDate) return false;
9407
+ return new Date(date).setHours(0, 0, 0, 0) === new Date(startDate).setHours(0, 0, 0, 0);
9408
+ };
9409
+ const isEndDate = date => {
9410
+ if (!endDate) return false;
9411
+ return new Date(date).setHours(0, 0, 0, 0) === new Date(endDate).setHours(0, 0, 0, 0);
9412
+ };
9413
+ const isToday = date => {
9414
+ const today = new Date();
9415
+ return date.getDate() === today.getDate() && date.getMonth() === today.getMonth() && date.getFullYear() === today.getFullYear();
9416
+ };
9417
+
9418
+ // Render a single month
9419
+ const renderMonth = month => {
9420
+ const year = month.getFullYear();
9421
+ const monthIdx = month.getMonth();
9422
+ const firstDay = new Date(year, monthIdx, 1);
9423
+ const lastDay = new Date(year, monthIdx + 1, 0);
9424
+ const startWeekday = firstDay.getDay(); // 0 = Sunday
9425
+ const daysInMonth = lastDay.getDate();
9426
+ const days = [];
9427
+ // Padding days from previous month
9428
+ const prevMonthLastDay = new Date(year, monthIdx, 0).getDate();
9429
+ for (let i = startWeekday - 1; i >= 0; i--) {
9430
+ days.push({
9431
+ date: new Date(year, monthIdx - 1, prevMonthLastDay - i),
9432
+ otherMonth: true
9433
+ });
9434
+ }
9435
+ // Current month days
9436
+ for (let d = 1; d <= daysInMonth; d++) {
9437
+ days.push({
9438
+ date: new Date(year, monthIdx, d),
9439
+ otherMonth: false
9440
+ });
9441
+ }
9442
+ // Padding days from next month
9443
+ const remaining = 42 - days.length; // 6 rows * 7 days
9444
+ for (let d = 1; d <= remaining; d++) {
9445
+ days.push({
9446
+ date: new Date(year, monthIdx + 1, d),
9447
+ otherMonth: true
9448
+ });
9449
+ }
9450
+ return /*#__PURE__*/React__default.createElement("div", {
9451
+ style: {
9452
+ flex: 1,
9453
+ padding: "0 8px"
9454
+ }
9455
+ }, /*#__PURE__*/React__default.createElement("div", {
9456
+ style: {
9457
+ textAlign: "center",
9458
+ fontWeight: "bold",
9459
+ marginBottom: 12,
9460
+ fontSize: 14
9461
+ }
9462
+ }, month.toLocaleDateString("en-US", {
9463
+ month: "short",
9464
+ year: "numeric"
9465
+ })), /*#__PURE__*/React__default.createElement("div", {
9466
+ style: {
9467
+ display: "grid",
9468
+ gridTemplateColumns: "repeat(7, 1fr)",
9469
+ gap: 2
9470
+ }
9471
+ }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(day => /*#__PURE__*/React__default.createElement("div", {
9472
+ key: day,
9473
+ style: {
9474
+ textAlign: "center",
9475
+ fontSize: 11,
9476
+ color: "#666",
9477
+ fontWeight: 600,
9478
+ padding: "4px 0"
9479
+ }
9480
+ }, day)), days.map(({
9481
+ date,
9482
+ otherMonth
9483
+ }, idx) => {
9484
+ const inRange = isInRange(date);
9485
+ const isStart = isStartDate(date);
9486
+ const isEnd = isEndDate(date);
9487
+ const isCurrentDay = isToday(date);
9488
+ return /*#__PURE__*/React__default.createElement("div", {
9489
+ key: idx,
9490
+ onClick: () => !otherMonth && handleDateClick(date),
9491
+ onMouseEnter: () => !otherMonth && setHoverDate(date),
9492
+ style: {
9493
+ textAlign: "center",
9494
+ padding: "8px 4px",
9495
+ fontSize: 13,
9496
+ cursor: otherMonth ? "default" : "pointer",
9497
+ color: otherMonth ? "#ccc" : isStart || isEnd ? "#fff" : isCurrentDay ? "#1d4ed8" : "#333",
9498
+ fontWeight: isStart || isEnd || isCurrentDay ? "600" : "normal",
9499
+ background: isStart || isEnd ? "#1d4ed8" : inRange ? "#e0f2fe" : "transparent",
9500
+ borderRadius: isStart || isEnd ? "50%" : inRange ? 0 : 4,
9501
+ border: isCurrentDay && !isStart && !isEnd ? "1px solid #1d4ed8" : "none",
9502
+ userSelect: "none",
9503
+ transition: "all 0.15s ease"
9504
+ },
9505
+ onMouseOver: e => {
9506
+ if (!otherMonth && !isStart && !isEnd) {
9507
+ e.currentTarget.style.background = inRange ? "#bfdbfe" : "#f3f4f6";
9508
+ }
9509
+ },
9510
+ onMouseOut: e => {
9511
+ if (!otherMonth && !isStart && !isEnd) {
9512
+ e.currentTarget.style.background = inRange ? "#e0f2fe" : "transparent";
9513
+ }
9514
+ }
9515
+ }, date.getDate());
9516
+ })));
9517
+ };
9518
+ return /*#__PURE__*/React__default.createElement("div", {
9519
+ style: {
9520
+ minWidth: 560
9521
+ }
9522
+ }, /*#__PURE__*/React__default.createElement("div", {
9523
+ style: {
9524
+ display: "flex",
9525
+ justifyContent: "space-between",
9526
+ alignItems: "center",
9527
+ marginBottom: 16
9528
+ }
9529
+ }, /*#__PURE__*/React__default.createElement("button", {
9530
+ onClick: prevMonth,
9531
+ style: {
9532
+ background: "none",
9533
+ border: "none",
9534
+ fontSize: 20,
9535
+ cursor: "pointer",
9536
+ padding: "4px 8px",
9537
+ color: "#333"
9538
+ }
9539
+ }, "\u2039\u2039"), /*#__PURE__*/React__default.createElement("div", {
9540
+ style: {
9541
+ fontWeight: "600",
9542
+ fontSize: 14,
9543
+ color: "#333"
9544
+ }
9545
+ }, leftMonth.toLocaleDateString("en-US", {
9546
+ month: "long",
9547
+ year: "numeric"
9548
+ }), " \u2013 ", rightMonth.toLocaleDateString("en-US", {
9549
+ month: "long",
9550
+ year: "numeric"
9551
+ })), /*#__PURE__*/React__default.createElement("button", {
9552
+ onClick: nextMonth,
9553
+ style: {
9554
+ background: "none",
9555
+ border: "none",
9556
+ fontSize: 20,
9557
+ cursor: "pointer",
9558
+ padding: "4px 8px",
9559
+ color: "#333"
9560
+ }
9561
+ }, "\u203A\u203A")), /*#__PURE__*/React__default.createElement("div", {
9562
+ style: {
9563
+ display: "flex",
9564
+ gap: 16
9565
+ },
9566
+ onMouseLeave: () => setHoverDate(null)
9567
+ }, renderMonth(leftMonth), renderMonth(rightMonth)));
9568
+ }
9569
+ CalendarRangePicker.propTypes = {
9570
+ startDate: PropTypes.instanceOf(Date),
9571
+ endDate: PropTypes.instanceOf(Date),
9572
+ onChange: PropTypes.func.isRequired,
9573
+ time: PropTypes.bool,
9574
+ timeStart: PropTypes.string,
9575
+ timeEnd: PropTypes.string
9576
+ };
9577
+
9578
+ /**
9579
+ * RangePicker - a reusable date or datetime-local range picker with URL param sync
9580
+ * Props:
9581
+ * pushUrlParamObj: string | false - URL param key to sync value (will store as start~end)
9582
+ * value: [start, end] controlled value (optional)
9583
+ * onChange: ([start, end]) => void (optional)
9584
+ * time: boolean - if true, use datetime-local, else date
9585
+ * timeStart: string (for default start time, e.g. "00:00")
9586
+ * timeEnd: string (for default end time, e.g. "23:59")
9587
+ * timezone, timeFormat, dateFormat, placeholder, required, disabled, className, style, min, max, ...rest
9588
+ */
9589
+ // Helper to get date string in yyyy-MM-dd or yyyy-MM-ddTHH:mm
9590
+ function formatDate(date, time = false) {
9591
+ const yyyy = date.getFullYear();
9592
+ const mm = String(date.getMonth() + 1).padStart(2, '0');
9593
+ const dd = String(date.getDate()).padStart(2, '0');
9594
+ if (time) {
9595
+ const hh = String(date.getHours()).padStart(2, '0');
9596
+ const min = String(date.getMinutes()).padStart(2, '0');
9597
+ return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
9598
+ }
9599
+ return `${yyyy}-${mm}-${dd}`;
9600
+ }
9601
+ const PREDEFINED_RANGES = [{
9602
+ label: 'Today',
9603
+ getRange: time => {
9604
+ const now = new Date();
9605
+ const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
9606
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
9607
+ return [formatDate(start, time), formatDate(end, time)];
9608
+ }
9609
+ }, {
9610
+ label: 'This week',
9611
+ getRange: time => {
9612
+ const now = new Date();
9613
+ const day = now.getDay() || 7;
9614
+ const start = new Date(now);
9615
+ start.setDate(now.getDate() - day + 1);
9616
+ start.setHours(0, 0, 0, 0);
9617
+ const end = new Date(start);
9618
+ end.setDate(start.getDate() + 6);
9619
+ end.setHours(23, 59, 59, 999);
9620
+ return [formatDate(start, time), formatDate(end, time)];
9621
+ }
9622
+ }, {
9623
+ label: 'Last 7 days',
9624
+ getRange: time => {
9625
+ const now = new Date();
9626
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
9627
+ const start = new Date(end);
9628
+ start.setDate(end.getDate() - 6);
9629
+ start.setHours(0, 0, 0, 0);
9630
+ return [formatDate(start, time), formatDate(end, time)];
9631
+ }
9632
+ }, {
9633
+ label: 'This month',
9634
+ getRange: time => {
9635
+ const now = new Date();
9636
+ const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
9637
+ const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
9638
+ return [formatDate(start, time), formatDate(end, time)];
9639
+ }
9640
+ }, {
9641
+ label: 'Last 30 days',
9642
+ getRange: time => {
9643
+ const now = new Date();
9644
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
9645
+ const start = new Date(end);
9646
+ start.setDate(end.getDate() - 29);
9647
+ start.setHours(0, 0, 0, 0);
9648
+ return [formatDate(start, time), formatDate(end, time)];
9649
+ }
9650
+ }];
9651
+
9652
+ // Helper to create predefined range from simple format
9653
+ const createRangeFromSimple = (item, time) => {
9654
+ // If it's a number, treat as "last N days"
9655
+ if (typeof item === 'number') {
9656
+ return {
9657
+ label: `Last ${item} days`,
9658
+ getRange: time => {
9659
+ const now = new Date();
9660
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
9661
+ const start = new Date(end);
9662
+ start.setDate(end.getDate() - (item - 1));
9663
+ start.setHours(0, 0, 0, 0);
9664
+ return [formatDate(start, time), formatDate(end, time)];
9665
+ }
9666
+ };
9667
+ }
9668
+
9669
+ // If it's a string, map to predefined functions
9670
+ const lowerItem = item.toLowerCase();
9671
+ const rangeMap = {
9672
+ 'today': {
9673
+ label: 'Today',
9674
+ getRange: time => {
9675
+ const now = new Date();
9676
+ const start = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0);
9677
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
9678
+ return [formatDate(start, time), formatDate(end, time)];
9679
+ }
9680
+ },
9681
+ 'yesterday': {
9682
+ label: 'Yesterday',
9683
+ getRange: time => {
9684
+ const now = new Date();
9685
+ const start = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 0, 0, 0, 0);
9686
+ const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 23, 59, 59, 999);
9687
+ return [formatDate(start, time), formatDate(end, time)];
9688
+ }
9689
+ },
9690
+ 'thisweek': {
9691
+ label: 'This week',
9692
+ getRange: time => {
9693
+ const now = new Date();
9694
+ const day = now.getDay() || 7;
9695
+ const start = new Date(now);
9696
+ start.setDate(now.getDate() - day + 1);
9697
+ start.setHours(0, 0, 0, 0);
9698
+ const end = new Date(start);
9699
+ end.setDate(start.getDate() + 6);
9700
+ end.setHours(23, 59, 59, 999);
9701
+ return [formatDate(start, time), formatDate(end, time)];
9702
+ }
9703
+ },
9704
+ 'lastweek': {
9705
+ label: 'Last week',
9706
+ getRange: time => {
9707
+ const now = new Date();
9708
+ const day = now.getDay() || 7;
9709
+ const start = new Date(now);
9710
+ start.setDate(now.getDate() - day - 6);
9711
+ start.setHours(0, 0, 0, 0);
9712
+ const end = new Date(start);
9713
+ end.setDate(start.getDate() + 6);
9714
+ end.setHours(23, 59, 59, 999);
9715
+ return [formatDate(start, time), formatDate(end, time)];
9716
+ }
9717
+ },
9718
+ 'thismonth': {
9719
+ label: 'This month',
9720
+ getRange: time => {
9721
+ const now = new Date();
9722
+ const start = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0);
9723
+ const end = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999);
9724
+ return [formatDate(start, time), formatDate(end, time)];
9725
+ }
9726
+ },
9727
+ 'lastmonth': {
9728
+ label: 'Last month',
9729
+ getRange: time => {
9730
+ const now = new Date();
9731
+ const start = new Date(now.getFullYear(), now.getMonth() - 1, 1, 0, 0, 0, 0);
9732
+ const end = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
9733
+ return [formatDate(start, time), formatDate(end, time)];
9734
+ }
9735
+ },
9736
+ 'thisyear': {
9737
+ label: 'This year',
9738
+ getRange: time => {
9739
+ const now = new Date();
9740
+ const start = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0);
9741
+ const end = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
9742
+ return [formatDate(start, time), formatDate(end, time)];
9743
+ }
9744
+ },
9745
+ 'lastyear': {
9746
+ label: 'Last year',
9747
+ getRange: time => {
9748
+ const now = new Date();
9749
+ const start = new Date(now.getFullYear() - 1, 0, 1, 0, 0, 0, 0);
9750
+ const end = new Date(now.getFullYear() - 1, 11, 31, 23, 59, 59, 999);
9751
+ return [formatDate(start, time), formatDate(end, time)];
9752
+ }
9753
+ }
9754
+ };
9755
+ return rangeMap[lowerItem] || null;
9756
+ };
9757
+ function RangePicker({
9758
+ pushUrlParamObj = false,
9759
+ value: controlledValue,
9760
+ onChange,
9761
+ time = false,
9762
+ timeStart,
9763
+ timeEnd,
9764
+ timezone,
9765
+ timeFormat,
9766
+ dateFormat,
9767
+ placeholder = "",
9768
+ required = false,
9769
+ disabled = false,
9770
+ className = "",
9771
+ style = {},
9772
+ min,
9773
+ max,
9774
+ predefinedRanges = PREDEFINED_RANGES,
9775
+ ...rest
9776
+ }) {
9777
+ const paramKey = pushUrlParamObj || null;
9778
+
9779
+ // Convert simple predefinedRanges to full format
9780
+ const processedRanges = Array.isArray(predefinedRanges) ? predefinedRanges.map(item => {
9781
+ // If it's already an object with label and getRange, use it as-is
9782
+ if (typeof item === 'object' && item.label && item.getRange) {
9783
+ return item;
9784
+ }
9785
+ // Otherwise, convert from simple format
9786
+ return createRangeFromSimple(item);
9787
+ }).filter(Boolean) : [];
9788
+
9789
+ // Helper to format default value
9790
+ const getDefault = which => {
9791
+ if (time) {
9792
+ const today = new Date();
9793
+ const yyyy = today.getFullYear();
9794
+ const mm = String(today.getMonth() + 1).padStart(2, '0');
9795
+ const dd = String(today.getDate()).padStart(2, '0');
9796
+ if (which === 'start' && timeStart) return `${yyyy}-${mm}-${dd}T${timeStart}`;
9797
+ if (which === 'end' && timeEnd) return `${yyyy}-${mm}-${dd}T${timeEnd}`;
9798
+ // fallback to now
9799
+ const now = new Date();
9800
+ const hh = String(now.getHours()).padStart(2, '0');
9801
+ const min = String(now.getMinutes()).padStart(2, '0');
9802
+ return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
9803
+ }
9804
+ return "";
9805
+ };
9806
+ // Initial state
9807
+ const toInputString = ts => {
9808
+ if (!ts) return "";
9809
+ const d = new Date(Number(ts));
9810
+ if (isNaN(d.getTime())) return "";
9811
+ if (time) {
9812
+ const yyyy = d.getFullYear();
9813
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
9814
+ const dd = String(d.getDate()).padStart(2, '0');
9815
+ const hh = String(d.getHours()).padStart(2, '0');
9816
+ const min = String(d.getMinutes()).padStart(2, '0');
9817
+ return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
9818
+ } else {
9819
+ const yyyy = d.getFullYear();
9820
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
9821
+ const dd = String(d.getDate()).padStart(2, '0');
9822
+ return `${yyyy}-${mm}-${dd}`;
9823
+ }
9824
+ };
9825
+ const [range, setRange] = useState(() => {
9826
+ if (controlledValue && Array.isArray(controlledValue)) return controlledValue;
9827
+ if (!paramKey) return [getDefault('start'), getDefault('end')];
9828
+ const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
9829
+ const urlVal = params.get(paramKey);
9830
+ if (urlVal && urlVal.includes('~')) {
9831
+ const [start, end] = urlVal.split('~');
9832
+ return [toInputString(start), toInputString(end)];
9833
+ }
9834
+ return [getDefault('start'), getDefault('end')];
9835
+ });
9836
+ // Track selected predefined range
9837
+ const [selectedRange, setSelectedRange] = useState(() => {
9838
+ // Initialize with matching predefined range if any
9839
+ if (!paramKey) return "";
9840
+ const params = new URLSearchParams(typeof window !== 'undefined' ? window.location.search : '');
9841
+ const urlVal = params.get(paramKey);
9842
+ if (urlVal && urlVal.includes('~')) {
9843
+ const [start, end] = urlVal.split('~');
9844
+ // Check if this matches any predefined range
9845
+ for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
9846
+ const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
9847
+ if (new Date(pStart).getTime() === Number(start) && new Date(pEnd).getTime() === Number(end)) {
9848
+ return String(i);
9849
+ }
9850
+ }
9851
+ }
9852
+ return "";
9853
+ });
9854
+
9855
+ // Helper to check if a range matches a predefined range
9856
+ const findMatchingPredefined = (start, end) => {
9857
+ for (let i = 0; i < PREDEFINED_RANGES.length; ++i) {
9858
+ const [pStart, pEnd] = PREDEFINED_RANGES[i].getRange(time);
9859
+ // Compare as timestamps for precision
9860
+ if (new Date(pStart).getTime() === new Date(start).getTime() && new Date(pEnd).getTime() === new Date(end).getTime()) {
9861
+ return String(i);
9862
+ }
9863
+ }
9864
+ return "";
9865
+ };
9866
+
9867
+ // Sync with URL param on mount and popstate
9868
+ useEffect(() => {
9869
+ if (!paramKey || controlledValue && Array.isArray(controlledValue)) return;
9870
+ const syncFromUrl = () => {
9871
+ const params = new URLSearchParams(window.location.search);
9872
+ const urlVal = params.get(paramKey);
9873
+ if (urlVal && urlVal.includes('~')) {
9874
+ const [start, end] = urlVal.split('~');
9875
+ setRange(prev => prev[0] !== toInputString(start) || prev[1] !== toInputString(end) ? [toInputString(start), toInputString(end)] : prev);
9876
+ if (onChange && (range[0] !== toInputString(start) || range[1] !== toInputString(end))) onChange([start, end]);
9877
+ // Set dropdown if matches predefined
9878
+ const matchIdx = findMatchingPredefined(Number(start), Number(end));
9879
+ setSelectedRange(matchIdx);
9880
+ } else {
9881
+ setSelectedRange("");
9882
+ }
9883
+ };
9884
+ syncFromUrl();
9885
+ window.addEventListener("popstate", syncFromUrl);
9886
+ // Listen for pushState/replaceState (programmatic changes)
9887
+ const patchHistory = type => {
9888
+ const orig = window.history[type];
9889
+ window.history[type] = function () {
9890
+ const rv = orig.apply(this, arguments);
9891
+ window.dispatchEvent(new Event(type));
9892
+ return rv;
9893
+ };
9894
+ };
9895
+ patchHistory('pushState');
9896
+ patchHistory('replaceState');
9897
+ window.addEventListener('pushState', syncFromUrl);
9898
+ window.addEventListener('replaceState', syncFromUrl);
9899
+ return () => {
9900
+ window.removeEventListener("popstate", syncFromUrl);
9901
+ window.removeEventListener('pushState', syncFromUrl);
9902
+ window.removeEventListener('replaceState', syncFromUrl);
9903
+ };
9904
+ }, [paramKey, onChange]);
9905
+
9906
+ // If controlled, update local value when prop changes
9907
+ useEffect(() => {
9908
+ if (controlledValue && Array.isArray(controlledValue)) setRange(controlledValue);
9909
+ }, [controlledValue]);
9910
+
9911
+ // Update URL param
9912
+ const setUrlParam = useCallback(vals => {
9913
+ if (!paramKey) return;
9914
+ const params = new URLSearchParams(window.location.search);
9915
+ // Convert input strings to timestamps
9916
+ const toTs = v => {
9917
+ if (!v) return "";
9918
+ if (/^[0-9]+$/.test(v)) return v;
9919
+ const d = new Date(v);
9920
+ return d.getTime();
9921
+ };
9922
+ if (vals[0] && vals[1]) {
9923
+ params.set(paramKey, `${toTs(vals[0])}~${toTs(vals[1])}`);
9924
+ } else {
9925
+ params.delete(paramKey);
9926
+ }
9927
+ const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
9928
+ window.history.replaceState({}, "", newUrl);
9929
+ }, [paramKey]);
9930
+ const handleClear = () => {
9931
+ if (!controlledValue) setRange(["", ""]);
9932
+ setUrlParam(["", ""]);
9933
+ onChange?.(["", ""]);
9934
+ };
9935
+
9936
+ // Show/hide dropdown for range selection
9937
+ const [dropdownOpen, setDropdownOpen] = useState(false);
9938
+ const [dropdownPosition, setDropdownPosition] = useState({
9939
+ top: "110%",
9940
+ left: 0,
9941
+ right: 'auto'
9942
+ });
9943
+
9944
+ // Calculate dropdown position to prevent overflow
9945
+ const dropdownRef = React__default.useRef(null);
9946
+ React__default.useEffect(() => {
9947
+ if (!dropdownOpen || !dropdownRef.current) return;
9948
+ const dropdown = dropdownRef.current;
9949
+ const rect = dropdown.getBoundingClientRect();
9950
+ const viewportWidth = window.innerWidth;
9951
+ const viewportHeight = window.innerHeight;
9952
+ let newPosition = {
9953
+ top: "110%",
9954
+ left: 0,
9955
+ right: 'auto'
9956
+ };
9957
+
9958
+ // Check if dropdown goes beyond right edge
9959
+ if (rect.right > viewportWidth - 10) {
9960
+ newPosition.right = 0;
9961
+ newPosition.left = 'auto';
9962
+ }
9963
+
9964
+ // Check if dropdown goes beyond bottom edge
9965
+ if (rect.bottom > viewportHeight - 10) {
9966
+ newPosition.top = 'auto';
9967
+ newPosition.bottom = "110%";
9968
+ }
9969
+ setDropdownPosition(newPosition);
9970
+ }, [dropdownOpen]);
9971
+
9972
+ // Format range for display using dateFormat and timeFormat props
9973
+ const formatDisplay = () => {
9974
+ if (!range[0] && !range[1]) return {
9975
+ start: "",
9976
+ end: ""
9977
+ };
9978
+ const fmt = v => {
9979
+ if (!v) return "";
9980
+ const d = new Date(v);
9981
+ if (isNaN(d.getTime())) return "";
9982
+
9983
+ // Parse dateFormat (default: DD-MM-YYYY)
9984
+ const actualDateFormat = dateFormat || (time ? "YYYY-MM-DD" : "DD-MM-YYYY");
9985
+ const yyyy = d.getFullYear();
9986
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
9987
+ const dd = String(d.getDate()).padStart(2, '0');
9988
+ let dateStr = actualDateFormat.replace('YYYY', yyyy).replace('MM', mm).replace('DD', dd);
9989
+ if (time) {
9990
+ // Parse timeFormat (default: HH:mm)
9991
+ const actualTimeFormat = timeFormat || "HH:mm";
9992
+ const hh = String(d.getHours()).padStart(2, '0');
9993
+ const min = String(d.getMinutes()).padStart(2, '0');
9994
+ const timeStr = actualTimeFormat.replace('HH', hh).replace('mm', min);
9995
+ return `${dateStr} ${timeStr}`;
9996
+ }
9997
+ return dateStr;
9998
+ };
9999
+ return {
10000
+ start: fmt(range[0]),
10001
+ end: fmt(range[1])
10002
+ };
10003
+ };
10004
+ // Close dropdown on outside click
10005
+ useEffect(() => {
10006
+ if (!dropdownOpen) return;
10007
+ const onClick = e => {
10008
+ if (!e.target.closest('.range-picker-dropdown')) setDropdownOpen(false);
10009
+ };
10010
+ window.addEventListener('mousedown', onClick);
10011
+ return () => window.removeEventListener('mousedown', onClick);
10012
+ }, [dropdownOpen]);
10013
+ return /*#__PURE__*/React__default.createElement("div", {
10014
+ style: {
10015
+ position: "relative",
10016
+ display: "inline-flex",
10017
+ gap: 4,
10018
+ ...style
10019
+ },
10020
+ className: className
10021
+ }, /*#__PURE__*/React__default.createElement("div", {
10022
+ style: {
10023
+ position: "relative",
10024
+ flex: 1
10025
+ }
10026
+ }, /*#__PURE__*/React__default.createElement("div", {
10027
+ className: "basic-input",
10028
+ onClick: () => setDropdownOpen(!dropdownOpen),
10029
+ style: {
10030
+ cursor: "pointer",
10031
+ background: dropdownOpen ? "#f0f8ff" : "#fff",
10032
+ height: 34,
10033
+ minHeight: 34,
10034
+ width: 280,
10035
+ border: '1px solid #ccc',
10036
+ borderRadius: 2,
10037
+ display: 'flex',
10038
+ alignItems: 'center',
10039
+ padding: '0 32px 0 8px',
10040
+ position: 'relative',
10041
+ fontSize: 14
10042
+ }
10043
+ }, /*#__PURE__*/React__default.createElement("span", {
10044
+ style: {
10045
+ color: formatDisplay().start ? '#333' : '#999',
10046
+ flex: 1
10047
+ }
10048
+ }, formatDisplay().start || 'Start date'), /*#__PURE__*/React__default.createElement("span", {
10049
+ style: {
10050
+ padding: '0 8px',
10051
+ color: '#999'
10052
+ }
10053
+ }, "\u2192"), /*#__PURE__*/React__default.createElement("span", {
10054
+ style: {
10055
+ color: formatDisplay().end ? '#333' : '#999',
10056
+ flex: 1
10057
+ }
10058
+ }, formatDisplay().end || 'End date'), /*#__PURE__*/React__default.createElement("span", {
10059
+ style: {
10060
+ position: 'absolute',
10061
+ right: 8,
10062
+ top: '50%',
10063
+ transform: 'translateY(-51%)',
10064
+ fontSize: 16,
10065
+ color: '#666'
10066
+ }
10067
+ }, "\uD83D\uDCC5")), dropdownOpen && /*#__PURE__*/React__default.createElement("div", {
10068
+ ref: dropdownRef,
10069
+ className: "range-picker-dropdown",
10070
+ style: {
10071
+ position: "absolute",
10072
+ ...dropdownPosition,
10073
+ background: "#fff",
10074
+ border: "1px solid #ccc",
10075
+ borderRadius: 4,
10076
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
10077
+ padding: 12,
10078
+ zIndex: 1000,
10079
+ minWidth: 260
10080
+ }
10081
+ }, /*#__PURE__*/React__default.createElement(CalendarRangePicker, {
10082
+ startDate: range[0] ? new Date(range[0]) : null,
10083
+ endDate: range[1] ? new Date(range[1]) : null,
10084
+ onChange: (start, end) => {
10085
+ const toStr = d => {
10086
+ if (!d) return "";
10087
+ if (time) {
10088
+ const yyyy = d.getFullYear();
10089
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
10090
+ const dd = String(d.getDate()).padStart(2, '0');
10091
+ const hh = String(d.getHours()).padStart(2, '0');
10092
+ const min = String(d.getMinutes()).padStart(2, '0');
10093
+ return `${yyyy}-${mm}-${dd}T${hh}:${min}`;
10094
+ } else {
10095
+ const yyyy = d.getFullYear();
10096
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
10097
+ const dd = String(d.getDate()).padStart(2, '0');
10098
+ return `${yyyy}-${mm}-${dd}`;
10099
+ }
10100
+ };
10101
+ const newRange = [toStr(start), toStr(end)];
10102
+ if (!controlledValue) setRange(newRange);
10103
+ setUrlParam(newRange);
10104
+ onChange?.(newRange);
10105
+ },
10106
+ time: time,
10107
+ timeStart: timeStart,
10108
+ timeEnd: timeEnd
10109
+ }), processedRanges && processedRanges.length > 0 && /*#__PURE__*/React__default.createElement("div", {
10110
+ style: {
10111
+ marginTop: 12,
10112
+ paddingTop: 12,
10113
+ borderTop: '1px solid #e5e7eb',
10114
+ display: 'flex',
10115
+ gap: 6,
10116
+ flexWrap: 'wrap'
10117
+ }
10118
+ }, processedRanges.map((r, i) => {
10119
+ const isActive = selectedRange === String(i);
10120
+ return /*#__PURE__*/React__default.createElement("button", {
10121
+ key: r.label,
10122
+ type: "button",
10123
+ onClick: () => {
10124
+ const {
10125
+ getRange
10126
+ } = r;
10127
+ const newRange = getRange(time);
10128
+ if (!controlledValue) setRange(newRange);
10129
+ setUrlParam(newRange);
10130
+ setSelectedRange(String(i));
10131
+ onChange?.(newRange);
10132
+ },
10133
+ style: {
10134
+ padding: '4px 12px',
10135
+ border: isActive ? '1px solid #1d4ed8' : '1px solid #d1d5db',
10136
+ background: isActive ? '#e0f2fe' : '#fff',
10137
+ color: isActive ? '#1d4ed8' : '#333',
10138
+ borderRadius: 4,
10139
+ cursor: 'pointer',
10140
+ fontSize: 12,
10141
+ fontWeight: isActive ? 500 : 400,
10142
+ transition: 'all 0.15s ease'
10143
+ }
10144
+ }, r.label);
10145
+ })), /*#__PURE__*/React__default.createElement("div", {
10146
+ style: {
10147
+ marginTop: 12,
10148
+ textAlign: 'right',
10149
+ borderTop: '1px solid #e5e7eb',
10150
+ paddingTop: 12
10151
+ }
10152
+ }, /*#__PURE__*/React__default.createElement("button", {
10153
+ type: "button",
10154
+ onClick: handleClear,
10155
+ style: {
10156
+ marginRight: 8,
10157
+ padding: '6px 16px',
10158
+ border: '1px solid #d1d5db',
10159
+ background: '#fff',
10160
+ borderRadius: 4,
10161
+ cursor: 'pointer',
10162
+ fontSize: 13
10163
+ }
10164
+ }, "Clear"), /*#__PURE__*/React__default.createElement("button", {
10165
+ type: "button",
10166
+ onClick: () => setDropdownOpen(false),
10167
+ style: {
10168
+ padding: '6px 16px',
10169
+ border: 'none',
10170
+ background: '#1d4ed8',
10171
+ color: '#fff',
10172
+ borderRadius: 4,
10173
+ cursor: 'pointer',
10174
+ fontSize: 13,
10175
+ fontWeight: 500
10176
+ }
10177
+ }, "OK")))));
10178
+ }
10179
+ RangePicker.propTypes = {
10180
+ pushUrlParamObj: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
10181
+ value: PropTypes.arrayOf(PropTypes.string),
10182
+ onChange: PropTypes.func,
10183
+ time: PropTypes.bool,
10184
+ timeStart: PropTypes.string,
10185
+ timeEnd: PropTypes.string,
10186
+ timezone: PropTypes.string,
10187
+ timeFormat: PropTypes.string,
10188
+ dateFormat: PropTypes.string,
10189
+ placeholder: PropTypes.string,
10190
+ required: PropTypes.bool,
10191
+ disabled: PropTypes.bool,
10192
+ className: PropTypes.string,
10193
+ style: PropTypes.object,
10194
+ min: PropTypes.string,
10195
+ max: PropTypes.string,
10196
+ predefinedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,
10197
+ // e.g., "today", "yesterday", "lastweek"
10198
+ PropTypes.number,
10199
+ // e.g., 7, 30 (last N days)
10200
+ PropTypes.shape({
10201
+ label: PropTypes.string.isRequired,
10202
+ getRange: PropTypes.func.isRequired
10203
+ })])), PropTypes.arrayOf(PropTypes.shape({
10204
+ label: PropTypes.string.isRequired,
10205
+ getRange: PropTypes.func.isRequired
10206
+ }))])
10207
+ };
7507
10208
 
7508
- export { Filters as Filter, Filters as default };
10209
+ export { CalendarRangePicker, DateTimeInput, DebounceSelect, IconInput, MultiSelectDropdown, RangePicker, SearchInput };
7509
10210
  //# sourceMappingURL=index.esm.js.map