@apia/components 4.0.45 → 4.0.47

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.js CHANGED
@@ -4,10 +4,10 @@ import React__default, { createContext, useContext, useEffect, useMemo, useState
4
4
  import parse, { domToReact, Element } from 'html-react-parser';
5
5
  import { Spinner as Spinner$1, Box as Box$1 } from 'theme-ui';
6
6
  import { uniqueId as uniqueId$3, cloneDeep, isFunction as isFunction$1 } from 'lodash-es';
7
- import { Box, getVariant, useBreakpointIndex, Close, responsive, spacing, Heading, Link, Button, Spinner, createElement, Select, Input, Flex, IconButton as IconButton$1, Image, injectStyles, focusOutline, makeStyledComponent, useThemeUI, Label as Label$1, Progress, Grid, Paragraph, Container, Textarea } from '@apia/theme';
7
+ import { Box, getVariant, useBreakpointIndex, Close, responsive, spacing, Heading, Link, Button, Spinner, createElement, Select, Input, Flex, IconButton as IconButton$1, Image, injectStyles, focusOutline, makeStyledComponent, useThemeUI, Label as Label$1, Progress, Grid, Paragraph, Container, Switch, Textarea } from '@apia/theme';
8
8
  import { BarLoader } from 'react-spinners';
9
9
  import uniqueId$2 from 'lodash-es/uniqueId';
10
- import { findScrollContainer, useUpdateEffect, focus, focusSelector, getFocusSelector, addBoundary, useCombinedRefs, usePrevious, getLabel, isChild, EventEmitter, useUnmount, useMount, StatefulEmitter, shallowEqual as shallowEqual$1, getSpecificParent, getDateFormat, customEvents, persistentStorage, disableChildrenFocus, enableChildrenFocus, decodeHTMLEntities, useDebouncedCallback, getIndex, noNaN, useLatest, useSubscription, uniqueId as uniqueId$4, useMatchScrollDirection, arrayOrArray } from '@apia/util';
10
+ import { findScrollContainer, useUpdateEffect, focus, focusSelector, getFocusSelector, addBoundary, useCombinedRefs, usePrevious, getLabel, isChild, EventEmitter, useUnmount, useMount, StatefulEmitter, shallowEqual as shallowEqual$1, getSpecificParent, uniqueId as uniqueId$4, getDateFormat, customEvents, persistentStorage, disableChildrenFocus, enableChildrenFocus, decodeHTMLEntities, useDebouncedCallback, getIndex, noNaN, useLatest, useSubscription, toBoolean, useMatchScrollDirection, arrayOrArray } from '@apia/util';
11
11
  import usePortal from 'react-cool-portal';
12
12
  import { CSSTransition } from 'react-transition-group';
13
13
  import { uniqueId as uniqueId$1, defaultNotifier, NotificationsList } from '@apia/notifications';
@@ -21,13 +21,14 @@ import { shallowEqual } from '@apia/store';
21
21
  import AnimateHeight from 'react-animate-height';
22
22
  import { useUpdateEffect as useUpdateEffect$1, useScroll } from 'ahooks';
23
23
  import { FaCalendarAlt, FaBars } from '@meronex/icons/fa';
24
- import dayjs from 'dayjs';
25
- import Calendar from 'react-calendar';
26
24
  import ReactInputMask from 'react-input-mask';
25
+ import Calendar from 'react-calendar';
26
+ import dayjs from 'dayjs';
27
27
  import isFunction from 'lodash-es/isFunction';
28
28
  import { createFAsomeStore } from '@apia/dom-store';
29
29
  import { keyframes } from '@emotion/react';
30
30
  import { Remarkable } from 'remarkable';
31
+ import { makeApiaUsersModal2, makeApiaPoolsModals2 } from '@apia/api';
31
32
 
32
33
  const AccordionContext = createContext(null);
33
34
  const AccordionItemContext = createContext(null);
@@ -38,10 +39,10 @@ const useAccordionContext = () => {
38
39
  return context;
39
40
  };
40
41
 
41
- var __defProp$o = Object.defineProperty;
42
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
43
- var __publicField$o = (obj, key, value) => {
44
- __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
42
+ var __defProp$p = Object.defineProperty;
43
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
44
+ var __publicField$p = (obj, key, value) => {
45
+ __defNormalProp$p(obj, typeof key !== "symbol" ? key + "" : key, value);
45
46
  return value;
46
47
  };
47
48
  function makeItemStateSelectorHook(handler) {
@@ -73,10 +74,10 @@ class AccordionHandler {
73
74
  constructor(id, props) {
74
75
  this.id = id;
75
76
  this.props = props;
76
- __publicField$o(this, "itemsState", {});
77
- __publicField$o(this, "itemsStateListeners", {});
78
- __publicField$o(this, "propsListeners", []);
79
- __publicField$o(this, "hooks", {
77
+ __publicField$p(this, "itemsState", {});
78
+ __publicField$p(this, "itemsStateListeners", {});
79
+ __publicField$p(this, "propsListeners", []);
80
+ __publicField$p(this, "hooks", {
80
81
  useAccordionContextProvider: () => {
81
82
  const Provider = useMemo(
82
83
  () => ({ children }) => /* @__PURE__ */ jsx(AccordionContext.Provider, { value: this, children }),
@@ -1019,10 +1020,10 @@ const WindowModal = forwardRef(
1019
1020
  }
1020
1021
  );
1021
1022
 
1022
- var __defProp$n = Object.defineProperty;
1023
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1024
- var __publicField$n = (obj, key, value) => {
1025
- __defNormalProp$n(obj, key + "" , value);
1023
+ var __defProp$o = Object.defineProperty;
1024
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1025
+ var __publicField$o = (obj, key, value) => {
1026
+ __defNormalProp$o(obj, key + "" , value);
1026
1027
  return value;
1027
1028
  };
1028
1029
  var __accessCheck$d = (obj, member, msg) => {
@@ -1087,7 +1088,7 @@ _onDestroyCb = new WeakMap();
1087
1088
  const BodyScrollLock = new (_a = class {
1088
1089
  constructor() {
1089
1090
  __privateAdd$d(this, _evaluate);
1090
- __publicField$n(this, "lockers", []);
1091
+ __publicField$o(this, "lockers", []);
1091
1092
  }
1092
1093
  getLocker() {
1093
1094
  const locker = new BodyScrollLocker();
@@ -1432,10 +1433,10 @@ const OpenModal = (props) => {
1432
1433
  );
1433
1434
  };
1434
1435
 
1435
- var __defProp$m = Object.defineProperty;
1436
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1437
- var __publicField$m = (obj, key, value) => {
1438
- __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
1436
+ var __defProp$n = Object.defineProperty;
1437
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1438
+ var __publicField$n = (obj, key, value) => {
1439
+ __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
1439
1440
  return value;
1440
1441
  };
1441
1442
  var __accessCheck$c = (obj, member, msg) => {
@@ -1479,14 +1480,14 @@ class ApiaUtilModalHandler {
1479
1480
  }
1480
1481
  class ApiaUtilModals {
1481
1482
  constructor() {
1482
- __publicField$m(this, "overlays", []);
1483
- __publicField$m(this, "modals", []);
1483
+ __publicField$n(this, "overlays", []);
1484
+ __publicField$n(this, "modals", []);
1484
1485
  __privateAdd$c(this, _maxId$1, 0);
1485
1486
  __privateAdd$c(this, _maxOverlay, 0);
1486
1487
  __privateAdd$c(this, _innerClose, (id) => {
1487
1488
  this.modals = this.modals.filter((s) => s.id !== id);
1488
1489
  });
1489
- __publicField$m(this, "Component", observer(() => {
1490
+ __publicField$n(this, "Component", observer(() => {
1490
1491
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1491
1492
  this.modals.map((current) => /* @__PURE__ */ jsx(OpenModal, { ...current }, current.id)),
1492
1493
  this.overlays.map((c) => c.render)
@@ -1576,29 +1577,37 @@ _maxId$1 = new WeakMap();
1576
1577
  _maxOverlay = new WeakMap();
1577
1578
  _innerClose = new WeakMap();
1578
1579
 
1579
- var __defProp$l = Object.defineProperty;
1580
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1581
- var __publicField$l = (obj, key, value) => {
1582
- __defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
1580
+ var __defProp$m = Object.defineProperty;
1581
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1582
+ var __publicField$m = (obj, key, value) => {
1583
+ __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
1583
1584
  return value;
1584
1585
  };
1585
1586
  class ApiaUtilNotifications {
1586
- constructor() {
1587
- __publicField$l(this, "close", (id) => {
1587
+ constructor(util) {
1588
+ this.util = util;
1589
+ __publicField$m(this, "close", (id) => {
1588
1590
  defaultNotifier.close(id);
1589
1591
  });
1590
- __publicField$l(this, "closeAll", () => {
1592
+ __publicField$m(this, "closeAll", () => {
1591
1593
  defaultNotifier.closeAll();
1592
1594
  });
1593
- __publicField$l(this, "notify", (notification) => {
1594
- defaultNotifier.notify({
1595
- ...notification,
1596
- type: notification.type ?? "warning"
1597
- });
1595
+ __publicField$m(this, "notify", (notification) => {
1596
+ if (notification.type === "modal") {
1597
+ this.util.dialogs.alert({
1598
+ children: notification.message,
1599
+ title: notification.title || ""
1600
+ });
1601
+ } else {
1602
+ defaultNotifier.notify({
1603
+ ...notification,
1604
+ type: notification.type ?? "warning"
1605
+ });
1606
+ }
1598
1607
  });
1599
1608
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1600
- __publicField$l(this, "useSelector", (selector) => defaultNotifier.useSelector(selector));
1601
- __publicField$l(this, "Component", () => {
1609
+ __publicField$m(this, "useSelector", (selector) => defaultNotifier.useSelector(selector));
1610
+ __publicField$m(this, "Component", () => {
1602
1611
  return /* @__PURE__ */ jsx(NotificationsList, {});
1603
1612
  });
1604
1613
  }
@@ -2021,10 +2030,10 @@ const AlertModal = ({
2021
2030
  );
2022
2031
  };
2023
2032
 
2024
- var __defProp$k = Object.defineProperty;
2025
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2026
- var __publicField$k = (obj, key, value) => {
2027
- __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
2033
+ var __defProp$l = Object.defineProperty;
2034
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2035
+ var __publicField$l = (obj, key, value) => {
2036
+ __defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
2028
2037
  return value;
2029
2038
  };
2030
2039
  var __accessCheck$b = (obj, member, msg) => {
@@ -2058,9 +2067,9 @@ class ApiaUtilDialogs {
2058
2067
  constructor() {
2059
2068
  __privateAdd$b(this, _maxIdAlert, 0);
2060
2069
  __privateAdd$b(this, _maxIdConfirm, 0);
2061
- __publicField$k(this, "alerts", []);
2062
- __publicField$k(this, "dialogs", []);
2063
- __publicField$k(this, "Component", observer(() => {
2070
+ __publicField$l(this, "alerts", []);
2071
+ __publicField$l(this, "dialogs", []);
2072
+ __publicField$l(this, "Component", observer(() => {
2064
2073
  const removeModal = useCallback(
2065
2074
  (which) => {
2066
2075
  this.dialogs = this.dialogs.filter((search) => search !== which);
@@ -2324,10 +2333,10 @@ parseCellValue_fn = function(cellValue) {
2324
2333
  return cellValue.match(/^\s*"?([^"]+)"?[\s\r\n]*$/)?.[1] ?? cellValue;
2325
2334
  };
2326
2335
 
2327
- var __defProp$j = Object.defineProperty;
2328
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2329
- var __publicField$j = (obj, key, value) => {
2330
- __defNormalProp$j(obj, key + "" , value);
2336
+ var __defProp$k = Object.defineProperty;
2337
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2338
+ var __publicField$k = (obj, key, value) => {
2339
+ __defNormalProp$k(obj, key + "" , value);
2331
2340
  return value;
2332
2341
  };
2333
2342
  let maxId = 0;
@@ -2335,14 +2344,14 @@ class ApiaUtilTooltip {
2335
2344
  constructor(props, close) {
2336
2345
  this.props = props;
2337
2346
  this.close = close;
2338
- __publicField$j(this, "id", `tooltip__${maxId++}`);
2347
+ __publicField$k(this, "id", `tooltip__${maxId++}`);
2339
2348
  }
2340
2349
  }
2341
2350
 
2342
- var __defProp$i = Object.defineProperty;
2343
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2344
- var __publicField$i = (obj, key, value) => {
2345
- __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
2351
+ var __defProp$j = Object.defineProperty;
2352
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2353
+ var __publicField$j = (obj, key, value) => {
2354
+ __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
2346
2355
  return value;
2347
2356
  };
2348
2357
  var __accessCheck$9 = (obj, member, msg) => {
@@ -2375,7 +2384,7 @@ class AutomaticTooltip {
2375
2384
  __privateAdd$9(this, _timeout$1, 500);
2376
2385
  __privateAdd$9(this, _tooltipTimeout, 0);
2377
2386
  __privateAdd$9(this, _unsuscribe, null);
2378
- __publicField$i(this, "ref", (el) => {
2387
+ __publicField$j(this, "ref", (el) => {
2379
2388
  var _a, _b;
2380
2389
  (_a = __privateGet$7(this, _unsuscribe)) == null ? void 0 : _a.call(this);
2381
2390
  const listener = () => {
@@ -2407,7 +2416,7 @@ class AutomaticTooltip {
2407
2416
  }
2408
2417
  });
2409
2418
  __privateAdd$9(this, _tooltip, null);
2410
- __publicField$i(this, "update", (tooltip) => {
2419
+ __publicField$j(this, "update", (tooltip) => {
2411
2420
  __privateSet$5(this, _tooltip, tooltip);
2412
2421
  });
2413
2422
  __privateSet$5(this, _tooltip, tooltip);
@@ -2758,10 +2767,10 @@ const Tooltip = ({
2758
2767
  );
2759
2768
  };
2760
2769
 
2761
- var __defProp$h = Object.defineProperty;
2762
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2763
- var __publicField$h = (obj, key, value) => {
2764
- __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
2770
+ var __defProp$i = Object.defineProperty;
2771
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2772
+ var __publicField$i = (obj, key, value) => {
2773
+ __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
2765
2774
  return value;
2766
2775
  };
2767
2776
  var __accessCheck$8 = (obj, member, msg) => {
@@ -2781,7 +2790,7 @@ var _emitter$2, _shoutChangedList;
2781
2790
  class ApiaUtilTooltips {
2782
2791
  constructor() {
2783
2792
  __privateAdd$8(this, _emitter$2, new EventEmitter());
2784
- __publicField$h(this, "tooltips", []);
2793
+ __publicField$i(this, "tooltips", []);
2785
2794
  __privateAdd$8(this, _shoutChangedList, () => {
2786
2795
  __privateGet$6(this, _emitter$2).emit("changedList", [...this.tooltips]);
2787
2796
  });
@@ -2789,7 +2798,7 @@ class ApiaUtilTooltips {
2789
2798
  * Permite crear un tooltip que se abrirá automáticamente al estar parado
2790
2799
  * sobre un elemento durante 300ms
2791
2800
  */
2792
- __publicField$h(this, "useHover", (tooltip) => {
2801
+ __publicField$i(this, "useHover", (tooltip) => {
2793
2802
  let tt = void 0;
2794
2803
  tt = useMemo(() => {
2795
2804
  tt?.ref(null);
@@ -2800,15 +2809,15 @@ class ApiaUtilTooltips {
2800
2809
  });
2801
2810
  return tt;
2802
2811
  });
2803
- __publicField$h(this, "close", (id) => {
2812
+ __publicField$i(this, "close", (id) => {
2804
2813
  this.tooltips = this.tooltips.filter((current) => current.id !== id);
2805
2814
  __privateGet$6(this, _shoutChangedList).call(this);
2806
2815
  });
2807
- __publicField$h(this, "closeAll", () => {
2816
+ __publicField$i(this, "closeAll", () => {
2808
2817
  this.tooltips = [];
2809
2818
  __privateGet$6(this, _shoutChangedList).call(this);
2810
2819
  });
2811
- __publicField$h(this, "open", (tooltip) => {
2820
+ __publicField$i(this, "open", (tooltip) => {
2812
2821
  const controller = new ApiaUtilTooltip(tooltip, () => {
2813
2822
  this.close(controller.id);
2814
2823
  controller.props.onClose?.();
@@ -2821,7 +2830,7 @@ class ApiaUtilTooltips {
2821
2830
  __privateGet$6(this, _shoutChangedList).call(this);
2822
2831
  return controller;
2823
2832
  });
2824
- __publicField$h(this, "Component", () => {
2833
+ __publicField$i(this, "Component", () => {
2825
2834
  const [tooltips, setTooltips] = useState(this.tooltips);
2826
2835
  useMount(() => {
2827
2836
  const unsuscribeToList = __privateGet$6(this, _emitter$2).on("changedList", (ev) => {
@@ -2863,10 +2872,10 @@ class ApiaUtilTooltips {
2863
2872
  _emitter$2 = new WeakMap();
2864
2873
  _shoutChangedList = new WeakMap();
2865
2874
 
2866
- var __defProp$g = Object.defineProperty;
2867
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2868
- var __publicField$g = (obj, key, value) => {
2869
- __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
2875
+ var __defProp$h = Object.defineProperty;
2876
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2877
+ var __publicField$h = (obj, key, value) => {
2878
+ __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
2870
2879
  return value;
2871
2880
  };
2872
2881
  var __accessCheck$7 = (obj, member, msg) => {
@@ -2903,7 +2912,7 @@ class ApiaUtilMenu {
2903
2912
  constructor() {
2904
2913
  __privateAdd$7(this, _emitter$1, new EventEmitter());
2905
2914
  __privateAdd$7(this, _items$1, []);
2906
- __publicField$g(this, "menuProps", null);
2915
+ __publicField$h(this, "menuProps", null);
2907
2916
  __privateAdd$7(this, _hooks, {
2908
2917
  useIsOpen: () => {
2909
2918
  const [isOpen, setIsOpen] = useState(false);
@@ -2918,10 +2927,10 @@ class ApiaUtilMenu {
2918
2927
  ];
2919
2928
  }
2920
2929
  });
2921
- __publicField$g(this, "close", () => {
2930
+ __publicField$h(this, "close", () => {
2922
2931
  __privateGet$5(this, _emitter$1).emit("toggle", false);
2923
2932
  });
2924
- __publicField$g(this, "open", ({
2933
+ __publicField$h(this, "open", ({
2925
2934
  menuProps,
2926
2935
  items
2927
2936
  }) => {
@@ -2962,7 +2971,7 @@ class ApiaUtilMenu {
2962
2971
  return /* @__PURE__ */ createElement(MenuItem, { ...current, key: current.key }, children);
2963
2972
  }) });
2964
2973
  });
2965
- __publicField$g(this, "Component", () => {
2974
+ __publicField$h(this, "Component", () => {
2966
2975
  const [isOpen, close] = __privateGet$5(this, _hooks).useIsOpen();
2967
2976
  if (!isOpen)
2968
2977
  return null;
@@ -2987,17 +2996,17 @@ _hooks = new WeakMap();
2987
2996
  _maxId = new WeakMap();
2988
2997
  _RenderMenu = new WeakMap();
2989
2998
 
2990
- var __defProp$f = Object.defineProperty;
2991
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2992
- var __publicField$f = (obj, key, value) => {
2993
- __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
2999
+ var __defProp$g = Object.defineProperty;
3000
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3001
+ var __publicField$g = (obj, key, value) => {
3002
+ __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
2994
3003
  return value;
2995
3004
  };
2996
3005
  class ApiaUtilMouse extends EventEmitter {
2997
3006
  constructor() {
2998
3007
  super();
2999
- __publicField$f(this, "x", 0);
3000
- __publicField$f(this, "y", 0);
3008
+ __publicField$g(this, "x", 0);
3009
+ __publicField$g(this, "y", 0);
3001
3010
  document.addEventListener("mousemove", (ev) => {
3002
3011
  this.x = ev.clientX;
3003
3012
  this.y = ev.clientY;
@@ -3009,10 +3018,10 @@ class ApiaUtilMouse extends EventEmitter {
3009
3018
  }
3010
3019
  }
3011
3020
 
3012
- var __defProp$e = Object.defineProperty;
3013
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3014
- var __publicField$e = (obj, key, value) => {
3015
- __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
3021
+ var __defProp$f = Object.defineProperty;
3022
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3023
+ var __publicField$f = (obj, key, value) => {
3024
+ __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
3016
3025
  return value;
3017
3026
  };
3018
3027
  var __accessCheck$6 = (obj, member, msg) => {
@@ -3036,15 +3045,15 @@ var __privateSet$3 = (obj, member, value, setter) => {
3036
3045
  var _instance;
3037
3046
  const _ApiaUtil = class _ApiaUtil {
3038
3047
  constructor() {
3039
- __publicField$e(this, "dialogs");
3040
- __publicField$e(this, "menu");
3041
- __publicField$e(this, "modals");
3042
- __publicField$e(this, "mouse");
3043
- __publicField$e(this, "notifications");
3044
- __publicField$e(this, "parsers");
3045
- __publicField$e(this, "tabs");
3046
- __publicField$e(this, "tooltips");
3047
- __publicField$e(this, "Component", () => {
3048
+ __publicField$f(this, "dialogs");
3049
+ __publicField$f(this, "menu");
3050
+ __publicField$f(this, "modals");
3051
+ __publicField$f(this, "mouse");
3052
+ __publicField$f(this, "notifications");
3053
+ __publicField$f(this, "parsers");
3054
+ __publicField$f(this, "tabs");
3055
+ __publicField$f(this, "tooltips");
3056
+ __publicField$f(this, "Component", () => {
3048
3057
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3049
3058
  /* @__PURE__ */ jsx(this.dialogs.Component, {}),
3050
3059
  /* @__PURE__ */ jsx(this.modals.Component, {}),
@@ -3057,7 +3066,7 @@ const _ApiaUtil = class _ApiaUtil {
3057
3066
  this.menu = new ApiaUtilMenu();
3058
3067
  this.modals = new ApiaUtilModals();
3059
3068
  this.mouse = new ApiaUtilMouse();
3060
- this.notifications = new ApiaUtilNotifications();
3069
+ this.notifications = new ApiaUtilNotifications(this);
3061
3070
  this.parsers = new ApiaUtilParsers();
3062
3071
  this.tabs = new ApiaUtilTabsController();
3063
3072
  this.tooltips = new ApiaUtilTooltips();
@@ -3073,22 +3082,22 @@ _instance = new WeakMap();
3073
3082
  __privateAdd$6(_ApiaUtil, _instance, void 0);
3074
3083
  let ApiaUtil = _ApiaUtil;
3075
3084
 
3076
- var __defProp$d = Object.defineProperty;
3077
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3078
- var __publicField$d = (obj, key, value) => {
3079
- __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
3085
+ var __defProp$e = Object.defineProperty;
3086
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3087
+ var __publicField$e = (obj, key, value) => {
3088
+ __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
3080
3089
  return value;
3081
3090
  };
3082
3091
  class ScreenLocker {
3083
3092
  constructor() {
3084
- __publicField$d(this, "emitter", new StatefulEmitter({
3093
+ __publicField$e(this, "emitter", new StatefulEmitter({
3085
3094
  locks: {
3086
3095
  common: { count: 0 },
3087
3096
  linear: { count: 0 },
3088
3097
  white: { count: 1 }
3089
3098
  }
3090
3099
  }));
3091
- __publicField$d(this, "lock", (options) => {
3100
+ __publicField$e(this, "lock", (options) => {
3092
3101
  this.emitter.setState("locks", (s) => {
3093
3102
  const key = options?.type ?? "common";
3094
3103
  return {
@@ -3104,11 +3113,11 @@ class ScreenLocker {
3104
3113
  };
3105
3114
  });
3106
3115
  });
3107
- __publicField$d(this, "hasReleased", false);
3116
+ __publicField$e(this, "hasReleased", false);
3108
3117
  /**
3109
3118
  * This method will work once, then, the action will be ignored. The ScreenLocker starts always locked on white, when this method is called, all listeners of onRelease will be called and the lock will be released.
3110
3119
  */
3111
- __publicField$d(this, "release", () => {
3120
+ __publicField$e(this, "release", () => {
3112
3121
  if (this.hasReleased)
3113
3122
  return;
3114
3123
  this.hasReleased = true;
@@ -3124,11 +3133,11 @@ class ScreenLocker {
3124
3133
  /**
3125
3134
  * This method notifies when the screenLock is released by the first time.
3126
3135
  */
3127
- __publicField$d(this, "onRelease", this.emitter.on.bind(this.emitter, "release"));
3136
+ __publicField$e(this, "onRelease", this.emitter.on.bind(this.emitter, "release"));
3128
3137
  /**
3129
3138
  * This component is the responsible for putting the lock courtain in the browser when it's required. It must be used once per application.
3130
3139
  */
3131
- __publicField$d(this, "Component", () => {
3140
+ __publicField$e(this, "Component", () => {
3132
3141
  const locks = this.emitter.useState("locks");
3133
3142
  const style = {
3134
3143
  alignItems: "center",
@@ -3201,10 +3210,10 @@ const OptionsBox = observer(() => {
3201
3210
  }) });
3202
3211
  });
3203
3212
 
3204
- var __defProp$c = Object.defineProperty;
3205
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3206
- var __publicField$c = (obj, key, value) => {
3207
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
3213
+ var __defProp$d = Object.defineProperty;
3214
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3215
+ var __publicField$d = (obj, key, value) => {
3216
+ __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
3208
3217
  return value;
3209
3218
  };
3210
3219
  var __accessCheck$5 = (obj, member, msg) => {
@@ -3228,7 +3237,7 @@ var __privateSet$2 = (obj, member, value, setter) => {
3228
3237
  var _actualSearch, _timeout;
3229
3238
  class AutocompleteController {
3230
3239
  constructor(properties) {
3231
- __publicField$c(this, "state", {
3240
+ __publicField$d(this, "state", {
3232
3241
  disabled: false,
3233
3242
  readOnly: false,
3234
3243
  id: uniqueId$3("autocomplete"),
@@ -3261,7 +3270,7 @@ class AutocompleteController {
3261
3270
  }
3262
3271
  });
3263
3272
  __privateAdd$5(this, _timeout, 0);
3264
- __publicField$c(this, "tooltipRef", null);
3273
+ __publicField$d(this, "tooltipRef", null);
3265
3274
  Object.assign(this.state, properties);
3266
3275
  if (properties.value) {
3267
3276
  this.state.showValue = String(
@@ -3996,30 +4005,6 @@ const Checkbox$1 = forwardRef(
3996
4005
  );
3997
4006
  Checkbox$1.displayName = "Checkbox";
3998
4007
 
3999
- const CalModal = React__default.forwardRef(
4000
- ({ handleClickDay, calValue, locale }) => {
4001
- return /* @__PURE__ */ jsx(
4002
- Box,
4003
- {
4004
- ...getVariant("layout.common.components.datePicker"),
4005
- className: "datePicker",
4006
- children: /* @__PURE__ */ jsx(
4007
- Calendar,
4008
- {
4009
- onClickDay: handleClickDay,
4010
- locale,
4011
- value: calValue || /* @__PURE__ */ new Date(),
4012
- nextLabel: "\u203A",
4013
- next2Label: "\xBB",
4014
- prevLabel: "\u2039",
4015
- prev2Label: "\xAB"
4016
- }
4017
- )
4018
- }
4019
- );
4020
- }
4021
- );
4022
-
4023
4008
  const IconInput = ({
4024
4009
  additionalButtons,
4025
4010
  additionalButtonsPosition = "before",
@@ -4096,6 +4081,36 @@ const IconInput = ({
4096
4081
  );
4097
4082
  };
4098
4083
 
4084
+ const CalModal = React__default.forwardRef(
4085
+ ({ handleClickDay, calValue, locale }) => {
4086
+ return /* @__PURE__ */ jsx(
4087
+ Box,
4088
+ {
4089
+ ...getVariant("layout.common.components.datePicker"),
4090
+ className: "datePicker",
4091
+ children: /* @__PURE__ */ jsx(
4092
+ Calendar,
4093
+ {
4094
+ onClickDay: handleClickDay,
4095
+ locale,
4096
+ value: calValue || /* @__PURE__ */ new Date(),
4097
+ nextLabel: "\u203A",
4098
+ next2Label: "\xBB",
4099
+ prevLabel: "\u2039",
4100
+ prev2Label: "\xAB"
4101
+ }
4102
+ )
4103
+ }
4104
+ );
4105
+ }
4106
+ );
4107
+
4108
+ var __defProp$c = Object.defineProperty;
4109
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4110
+ var __publicField$c = (obj, key, value) => {
4111
+ __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
4112
+ return value;
4113
+ };
4099
4114
  const DEFAULT_LOCALE = window.LANG_CODE;
4100
4115
  const DEFAULT_MASK_PLACEHOLDER = "_";
4101
4116
  const dateFormat = getDateFormat();
@@ -4104,331 +4119,217 @@ const getMaskForDateFormat = () => {
4104
4119
  return "9999/99/99";
4105
4120
  return "99/99/9999";
4106
4121
  };
4107
- const DateInput = React__default.forwardRef(
4108
- ({
4109
- allowPickBeforeToday,
4110
- buttonProps: outerButtonProps,
4111
- CalModalRenderer,
4112
- className,
4113
- error,
4114
- getCustomMask,
4115
- inputClassName,
4116
- isLoading,
4117
- onBlur,
4118
- onChange,
4119
- onDelete,
4120
- onError,
4121
- renderLabel,
4122
- value: outerValue,
4123
- avoidErrorMessage,
4124
- ...props
4125
- }, ref) => {
4126
- const id = React__default.useMemo(uniqueId$3, []);
4127
- const [inputValue, setInputValue] = React__default.useState(outerValue ?? "");
4128
- const [calValue, setCalValue] = React__default.useState();
4129
- const boxRef = React__default.useRef(null);
4130
- const { deleteFiltersTimestamp, ...otherProps } = props;
4131
- const hasBlured = useRef(false);
4132
- const [stateError, setError] = React__default.useState(error ?? null);
4133
- const [isFocused, setIsFocused] = React__default.useState(false);
4134
- const lastEmittedValue = React__default.useRef(outerValue ?? "");
4135
- useUpdateEffect$1(() => {
4136
- setInputValue(outerValue ?? "");
4137
- lastEmittedValue.current = outerValue;
4138
- }, [outerValue]);
4139
- useUpdateEffect$1(() => {
4140
- setError(error ?? null);
4141
- }, [error]);
4142
- useUpdateEffect$1(() => {
4143
- setError(null);
4144
- if (deleteFiltersTimestamp !== void 0) {
4145
- setCalendarValue("");
4146
- }
4147
- }, [deleteFiltersTimestamp]);
4148
- useUpdateEffect$1(() => {
4149
- if (onError)
4150
- onError(stateError);
4151
- if (stateError) {
4152
- setInputValue("");
4153
- }
4154
- if (onError)
4155
- onError(stateError ?? "");
4156
- }, [stateError]);
4157
- const shoutOnChange = React__default.useCallback(
4158
- (newValue) => {
4159
- lastEmittedValue.current = newValue;
4160
- return onChange?.(newValue) ?? true;
4161
- },
4162
- [onChange]
4122
+ class DateInputController {
4123
+ constructor(actualId) {
4124
+ __publicField$c(this, "props", {});
4125
+ __publicField$c(this, "state", {});
4126
+ __publicField$c(this, "_ref", null);
4127
+ __publicField$c(this, "error", false);
4128
+ __publicField$c(this, "inputValue", "");
4129
+ __publicField$c(this, "value", null);
4130
+ __publicField$c(this, "previousValue", "");
4131
+ this.props.id = uniqueId$4(actualId ?? "date-input");
4132
+ makeAutoObservable(this);
4133
+ }
4134
+ clear() {
4135
+ this.setValueFromString("");
4136
+ this.focus();
4137
+ }
4138
+ focus() {
4139
+ const input = this._ref?.querySelector("input");
4140
+ if (input) {
4141
+ input.focus();
4142
+ setTimeout(() => {
4143
+ window.requestAnimationFrame(() => {
4144
+ input.setSelectionRange(0, input.value.length);
4145
+ });
4146
+ }, 0);
4147
+ }
4148
+ }
4149
+ ref(el) {
4150
+ this._ref = el;
4151
+ }
4152
+ get calendarElementId() {
4153
+ return `DateModal${this.props.id}`;
4154
+ }
4155
+ isInsidePicker(el) {
4156
+ return !!el?.closest(
4157
+ `#${CSS.escape(this.props.id ?? "")}, #${CSS.escape(this.calendarElementId)}`
4163
4158
  );
4164
- const setCalendarValue = React__default.useCallback(
4165
- (value, nocheck, avoidShout) => {
4166
- if (value === "") {
4167
- if (getMaskForDateFormat().replaceAll("9", DEFAULT_MASK_PLACEHOLDER) !== inputValue)
4168
- void shoutOnChange("");
4169
- setInputValue("");
4170
- setCalValue(/* @__PURE__ */ new Date());
4171
- return;
4172
- }
4173
- let newDate = dayjs(value, dateFormat);
4174
- if (!newDate.isValid())
4175
- newDate = dayjs(/* @__PURE__ */ new Date(), dateFormat);
4176
- const formattedDate = newDate.format(dateFormat);
4177
- const today = /* @__PURE__ */ new Date();
4178
- today.setHours(0, 0, 0, 0);
4179
- if (formattedDate !== inputValue && nocheck !== true) {
4180
- void shoutOnChange("");
4181
- setInputValue("");
4182
- setError(window.MSG_INVALID_DATE);
4183
- } else if (allowPickBeforeToday === false && newDate.isBefore(today)) {
4184
- void shoutOnChange("");
4185
- setInputValue("");
4186
- setError(window.MSG_FEC_FIN_MAY_FEC_INI);
4187
- } else {
4188
- if (avoidShout) {
4189
- setInputValue(formattedDate);
4190
- setError(null);
4191
- setCalValue(newDate.toDate());
4192
- } else {
4193
- const shoutResult = shoutOnChange(
4194
- value === "" ? "" : formattedDate
4195
- );
4196
- if (shoutResult === false) {
4197
- setInputValue(shoutResult || "");
4198
- setError(null);
4199
- setCalValue(/* @__PURE__ */ new Date());
4200
- } else if (typeof shoutResult === "string") {
4201
- setInputValue("");
4202
- setError(shoutResult);
4203
- setCalValue(/* @__PURE__ */ new Date());
4204
- } else {
4205
- setInputValue(formattedDate);
4206
- setError(null);
4207
- setCalValue(newDate.toDate());
4208
- }
4159
+ }
4160
+ onBlur(ev) {
4161
+ if (!this.isInsidePicker(ev.relatedTarget)) {
4162
+ if (this.error) {
4163
+ this.inputValue = "";
4164
+ this.value = null;
4165
+ this.error = false;
4166
+ }
4167
+ this.props.onBlur?.(this.inputValue, ev);
4168
+ }
4169
+ }
4170
+ onInputChange(ev) {
4171
+ this.setValueFromString(ev.target.value);
4172
+ }
4173
+ onCalendarSelect(value) {
4174
+ this.setValue(value);
4175
+ }
4176
+ openCalendar(ev) {
4177
+ const tooltip = ApiaUtil.instance.tooltips.open({
4178
+ attachToElement() {
4179
+ return ev.target.closest("button");
4180
+ },
4181
+ attachToElementAnchorPoint: "center",
4182
+ closeOnClick: false,
4183
+ closeOnClickOut: true,
4184
+ closeOnEscape: true,
4185
+ closeOnMouseLeaveTooltip: false,
4186
+ closeOnMouseLeaveAttachedElement: false,
4187
+ closeOnScrollOut: true,
4188
+ children: /* @__PURE__ */ jsx("div", { id: this.calendarElementId, children: /* @__PURE__ */ jsx(
4189
+ CalModal,
4190
+ {
4191
+ calValue: this.value || /* @__PURE__ */ new Date(),
4192
+ locale: DEFAULT_LOCALE,
4193
+ handleClickDay: (date) => {
4194
+ tooltip.close();
4195
+ this.onCalendarSelect(date);
4196
+ this.focus();
4209
4197
  }
4210
4198
  }
4199
+ ) }),
4200
+ initialFocusGetter(el) {
4201
+ return el.querySelector(`.react-calendar__tile--active`);
4211
4202
  },
4212
- [allowPickBeforeToday, inputValue, shoutOnChange]
4213
- );
4214
- const selectDate = React__default.useCallback(
4215
- (val) => {
4216
- const newValue = dayjs(val).format(dateFormat);
4217
- setCalendarValue(newValue, true);
4218
- },
4219
- [setCalendarValue]
4220
- );
4221
- useEffect(() => {
4222
- if (stateError !== "" && stateError !== null && !avoidErrorMessage) {
4223
- ApiaUtil.instance.notifications.notify({
4224
- message: stateError,
4225
- type: "warning"
4203
+ minSize: { width: 350, height: 310 },
4204
+ onClose: () => {
4205
+ window.requestAnimationFrame(() => {
4206
+ if (!this.isInsidePicker(document.activeElement)) {
4207
+ this.props.onBlur?.(this.inputValue);
4208
+ }
4226
4209
  });
4227
4210
  }
4228
- }, [avoidErrorMessage, stateError]);
4229
- const handleBlur = React__default.useCallback(
4230
- (ev) => {
4231
- hasBlured.current = true;
4232
- if (ev.target.value && !dayjs(ev.target.value, dateFormat, true).isValid()) {
4233
- setInputValue("");
4234
- onError?.(window.MSG_INVALID_DATE);
4235
- return;
4236
- }
4237
- if (onBlur && !isChild(ev.relatedTarget, (current) => {
4238
- return current.id === `DateModal${id}` || current.id === `DateInput${id}`;
4239
- })) {
4240
- const newEvent = {
4241
- ...ev,
4242
- target: ev.target.matches("input.dateInput") ? ev.target : ev.target.closest(".dateInput")?.querySelector(
4243
- "input"
4244
- )
4245
- };
4246
- const actualBlur = onBlur instanceof Promise ? onBlur : (ev2) => new Promise((resolve) => {
4247
- const result = onBlur?.(ev2);
4248
- resolve(result);
4249
- });
4250
- void actualBlur(newEvent).then((result) => {
4251
- if (typeof result === "string") {
4252
- setError(result);
4253
- } else if (result === false) {
4254
- setInputValue("");
4255
- }
4256
- });
4257
- }
4258
- },
4259
- [id, onBlur, onError]
4260
- );
4261
- const inputProps = React__default.useMemo(
4262
- () => ({
4263
- ...otherProps,
4264
- className: `dateInput ${inputClassName ?? ""}`,
4265
- value: stateError ? "" : renderLabel ? renderLabel(inputValue) : inputValue,
4266
- ref,
4267
- onChange: (ev) => {
4268
- if (props.readOnly) {
4269
- return;
4270
- }
4271
- setInputValue(ev.target.value);
4272
- if (getMaskForDateFormat().replaceAll("9", DEFAULT_MASK_PLACEHOLDER) !== ev.target.value && ev.target.value !== "") {
4273
- setError(null);
4274
- const hasPlaceHolder = ev.target.value.match(/_/);
4275
- if (!hasPlaceHolder)
4276
- return onChange?.(ev.target.value);
4277
- }
4278
- },
4279
- onBlur: (ev) => {
4280
- setIsFocused(false);
4281
- if (!(props.readOnly || getCustomMask || document.querySelector(".overlay.screenLock")))
4282
- setCalendarValue(ev.target.value, false, true);
4283
- if (hasBlured.current) {
4284
- hasBlured.current = false;
4285
- } else if (!document.querySelector(".overlay.screenLock")) {
4286
- handleBlur(ev);
4287
- }
4288
- },
4289
- onFocus: () => {
4290
- setIsFocused(true);
4291
- },
4292
- onKeyDown: (ev) => {
4293
- if (ev.key === "Enter")
4294
- setCalendarValue(inputValue);
4211
+ });
4212
+ }
4213
+ setValueFromString(str, fire = true) {
4214
+ if (str === "" || str.replaceAll("_", "9") === getMaskForDateFormat()) {
4215
+ this.inputValue = "";
4216
+ this.setValue(null, fire);
4217
+ } else if (str !== this.inputValue) {
4218
+ const hasPlaceHolder = str.match(/_/);
4219
+ if (!hasPlaceHolder) {
4220
+ const value = dayjs(str, dateFormat);
4221
+ const formattedDate = value.format(dateFormat);
4222
+ if (value.isValid() && formattedDate === str) {
4223
+ this.setValue(value.toDate(), fire);
4224
+ } else {
4225
+ this.inputValue = str;
4226
+ this.props.onError?.(getLabel("msgInvalidDate").text);
4227
+ this.error = true;
4295
4228
  }
4296
- }),
4297
- // eslint-disable-next-line react-hooks/exhaustive-deps
4298
- [
4299
- otherProps,
4300
- inputClassName,
4301
- stateError,
4302
- renderLabel,
4303
- inputValue,
4304
- ref,
4305
- props.readOnly,
4306
- getCustomMask,
4307
- setCalendarValue,
4308
- handleBlur
4309
- ]
4310
- );
4311
- const buttonProps = React__default.useMemo(
4312
- () => ({
4313
- disabled: props.disabled || props.readOnly,
4314
- "aria-label": window.LBL_PICK_DATE,
4315
- ...outerButtonProps
4316
- }),
4317
- [outerButtonProps, props.disabled, props.readOnly]
4229
+ } else {
4230
+ this.inputValue = str;
4231
+ }
4232
+ }
4233
+ }
4234
+ async setValue(date, fire = true) {
4235
+ this.error = false;
4236
+ if (date !== this.value) {
4237
+ const dateValue = dayjs(date);
4238
+ const newValue = dateValue.isValid() ? dateValue.format(dateFormat) : "";
4239
+ const res = fire ? await this.props.onChange?.(newValue) : null;
4240
+ this.inputValue = newValue || "";
4241
+ if (typeof res !== "string") {
4242
+ this.value = date;
4243
+ } else {
4244
+ this.error = true;
4245
+ this.value = null;
4246
+ this.props.onError?.(res);
4247
+ }
4248
+ }
4249
+ }
4250
+ render(props) {
4251
+ const { onBlur, onChange, onError, id } = props;
4252
+ Object.assign(this.props, {
4253
+ onBlur,
4254
+ onChange,
4255
+ onError,
4256
+ id: id ?? this.props.id
4257
+ });
4258
+ const { value, disabled, readonly } = props;
4259
+ Object.assign(this.state, { readonly, value, disabled });
4260
+ if (value !== void 0 && this.previousValue !== value) {
4261
+ this.previousValue = value;
4262
+ this.setValueFromString(value, false);
4263
+ }
4264
+ }
4265
+ }
4266
+ const DateInput = observer(
4267
+ ({
4268
+ className,
4269
+ disabled,
4270
+ id: outerId,
4271
+ inputRef,
4272
+ onBlur,
4273
+ onChange,
4274
+ onError,
4275
+ readonly,
4276
+ value: outerValue
4277
+ }) => {
4278
+ const controller = useMemo(
4279
+ () => new DateInputController(outerId),
4280
+ [outerId]
4318
4281
  );
4319
- const additionalButtons = React__default.useMemo(() => {
4320
- const doDelete = (e) => {
4321
- e?.stopPropagation();
4322
- setCalendarValue("");
4323
- onDelete?.();
4324
- document.querySelector(`#DateInput${id} input`)?.focus();
4325
- };
4326
- return /* @__PURE__ */ jsx(
4327
- "span",
4328
- {
4329
- role: "button",
4330
- tabIndex: 0,
4331
- onMouseDown: (e) => {
4332
- e.preventDefault();
4333
- e.stopPropagation();
4334
- },
4335
- onClick: (e) => {
4336
- e.stopPropagation();
4337
- doDelete(e);
4338
- },
4339
- onKeyDown: (e) => {
4340
- if (e.key === "Enter" || e.key === " ") {
4341
- e.preventDefault();
4342
- doDelete(e);
4343
- }
4344
- },
4345
- "aria-label": getLabel("btnAiDelete").text,
4346
- title: getLabel("btnAiDelete").text,
4347
- children: /* @__PURE__ */ jsx(Close, { type: "button", className: "delete_date_button" })
4348
- }
4349
- );
4350
- }, [id, onDelete, setCalendarValue]);
4351
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4282
+ controller.render({
4283
+ className,
4284
+ disabled,
4285
+ id: outerId,
4286
+ inputRef,
4287
+ onBlur,
4288
+ onChange,
4289
+ onError,
4290
+ readonly,
4291
+ value: outerValue
4292
+ });
4293
+ return /* @__PURE__ */ jsx(
4352
4294
  Box,
4353
4295
  {
4354
4296
  ...getVariant("forms.dateInput"),
4355
4297
  className: `${className ?? ""} dateInput`,
4356
- id: `DateInput${id}`,
4357
- ref: boxRef,
4358
- onBlur: (e) => {
4359
- setIsFocused(false);
4360
- if (hasBlured.current) {
4361
- hasBlured.current = false;
4362
- } else if (!document.querySelector(".overlay.screenLock")) {
4363
- handleBlur(e);
4364
- }
4365
- },
4298
+ id: controller.props.id,
4299
+ onBlur: controller.onBlur.bind(controller),
4300
+ ref: controller.ref.bind(controller),
4366
4301
  children: /* @__PURE__ */ jsx(
4367
4302
  IconInput,
4368
4303
  {
4369
- additionalButtons: (
4370
- // mostrar sólo si el campo tiene valor, no está en modo placeholder,
4371
- // no es readOnly/disabled Y el input está enfocado
4372
- inputValue && inputValue !== getMaskForDateFormat().replaceAll(
4373
- "9",
4374
- DEFAULT_MASK_PLACEHOLDER
4375
- ) && !props.readOnly && !props.disabled && isFocused ? additionalButtons : void 0
4376
- ),
4377
- buttonProps,
4378
- className: `${stateError !== null ? "field__withError" : ""}`,
4304
+ additionalButtons: controller.inputValue && getMaskForDateFormat().replaceAll("9", DEFAULT_MASK_PLACEHOLDER) !== controller.inputValue ? /* @__PURE__ */ jsx(
4305
+ Close,
4306
+ {
4307
+ as: "button",
4308
+ onClick: controller.clear.bind(controller),
4309
+ className: "delete_date_button",
4310
+ onMouseDown: (e) => {
4311
+ e.preventDefault();
4312
+ e.stopPropagation();
4313
+ }
4314
+ }
4315
+ ) : void 0,
4316
+ buttonProps: { disabled },
4379
4317
  icon: FaCalendarAlt,
4380
- inputProps,
4381
- isLoading,
4382
- mask: getCustomMask ? getCustomMask() : getMaskForDateFormat(),
4383
- maskPlaceholder: DEFAULT_MASK_PLACEHOLDER,
4384
- onClick: (ev) => {
4385
- const tooltip = ApiaUtil.instance.tooltips.open({
4386
- attachToElement() {
4387
- return ev.target.closest(
4388
- "button"
4389
- );
4390
- },
4391
- attachToElementAnchorPoint: "center",
4392
- closeOnClick: false,
4393
- closeOnClickOut: true,
4394
- closeOnEscape: true,
4395
- closeOnMouseLeaveTooltip: false,
4396
- closeOnMouseLeaveAttachedElement: false,
4397
- closeOnScrollOut: true,
4398
- children: CalModalRenderer ? /* @__PURE__ */ jsx(
4399
- CalModalRenderer,
4400
- {
4401
- calValue,
4402
- locale: DEFAULT_LOCALE,
4403
- handleClickDay: (ev2) => {
4404
- selectDate(ev2);
4405
- setCalValue(ev2);
4406
- tooltip.close();
4407
- }
4408
- }
4409
- ) : /* @__PURE__ */ jsx(
4410
- CalModal,
4411
- {
4412
- calValue,
4413
- locale: DEFAULT_LOCALE,
4414
- handleClickDay: (ev2) => {
4415
- selectDate(ev2);
4416
- setCalValue(ev2);
4417
- tooltip.close();
4418
- }
4419
- }
4420
- ),
4421
- initialFocusGetter(el) {
4422
- return el.querySelector(`.react-calendar__tile--active`);
4423
- },
4424
- minSize: { width: 350, height: 310 }
4425
- });
4318
+ inputProps: {
4319
+ disabled,
4320
+ onChange: controller.onInputChange.bind(controller),
4321
+ value: controller.inputValue,
4322
+ id: outerId,
4323
+ name: outerId
4426
4324
  },
4427
- readOnly: props.readOnly
4325
+ mask: getMaskForDateFormat(),
4326
+ maskPlaceholder: DEFAULT_MASK_PLACEHOLDER,
4327
+ onClick: controller.openCalendar.bind(controller),
4328
+ readOnly: readonly
4428
4329
  }
4429
4330
  )
4430
4331
  }
4431
- ) });
4332
+ );
4432
4333
  }
4433
4334
  );
4434
4335
 
@@ -4983,7 +4884,25 @@ const DefaultAccordionItemButton = (props) => {
4983
4884
  onChange: setIsChecked
4984
4885
  }
4985
4886
  ),
4986
- /* @__PURE__ */ jsx(Box, { as: "h3", className: "accordion__item__button__label", children: /* @__PURE__ */ jsx(AutoEllipsis, { overrideStyles: () => ({ textAlign: "left" }), children: props.label ?? props.title ?? props.ariaLabel }) })
4887
+ (props.label ?? props.title ?? props.ariaLabel).split(" | ").map((content, i) => {
4888
+ if (typeof props.isHtml === "boolean" && props.isHtml || Array.isArray(props.isHtml) && props.isHtml[i]) {
4889
+ return /* @__PURE__ */ jsx(
4890
+ Box,
4891
+ {
4892
+ className: "accordion__item__button__html",
4893
+ dangerouslySetInnerHTML: {
4894
+ __html: String(content).replaceAll(
4895
+ /<TOK(\d+)/g,
4896
+ "&lt;TOK$1"
4897
+ )
4898
+ },
4899
+ as: "span"
4900
+ }
4901
+ );
4902
+ } else {
4903
+ return /* @__PURE__ */ jsx(Box, { as: "h3", className: "accordion__item__button__label", children: /* @__PURE__ */ jsx(AutoEllipsis, { overrideStyles: () => ({ textAlign: "left" }), children: content }) });
4904
+ }
4905
+ })
4987
4906
  ] }),
4988
4907
  /* @__PURE__ */ jsxs(Box, { className: "accordion__item__button__rightGroup", children: [
4989
4908
  props.rightButtons,
@@ -8817,6 +8736,253 @@ const MDRenderer = ({ str }) => {
8817
8736
  };
8818
8737
  var index = memo(MDRenderer);
8819
8738
 
8739
+ const SwitchCard = observer(
8740
+ ({
8741
+ align = "left",
8742
+ icon,
8743
+ label,
8744
+ notSwitchedLabel,
8745
+ onClose,
8746
+ onSwitch,
8747
+ switchedLabel,
8748
+ switchProps,
8749
+ value,
8750
+ disabled
8751
+ }) => {
8752
+ const [isSwitched, setIsSwitched] = useState(toBoolean(value));
8753
+ useEffect(() => {
8754
+ setIsSwitched(toBoolean(value));
8755
+ }, [value]);
8756
+ const handleSwitchChange = (e) => {
8757
+ const newValue = e.target.checked;
8758
+ setIsSwitched(newValue);
8759
+ if (onSwitch) {
8760
+ onSwitch(newValue);
8761
+ }
8762
+ };
8763
+ return /* @__PURE__ */ jsxs(
8764
+ Box,
8765
+ {
8766
+ className: "switch__card",
8767
+ ...getVariant("layout.common.components.switchCard"),
8768
+ children: [
8769
+ align === "left" && /* @__PURE__ */ jsx(
8770
+ Switch,
8771
+ {
8772
+ disabled,
8773
+ checked: isSwitched,
8774
+ ...switchProps,
8775
+ onChange: handleSwitchChange
8776
+ }
8777
+ ),
8778
+ /* @__PURE__ */ jsxs(Box, { className: "label__container", title: label, children: [
8779
+ icon && /* @__PURE__ */ jsx(Icon$1, { name: icon, title: "" }),
8780
+ label
8781
+ ] }),
8782
+ (switchedLabel && isSwitched || align === "right" || onClose) && /* @__PURE__ */ jsxs(Box, { className: "switch__container", children: [
8783
+ !notSwitchedLabel && (isSwitched ? getLabel("lblCanUpdate").text : getLabel("lblCannotUpdate").text),
8784
+ align === "right" && /* @__PURE__ */ jsx(
8785
+ Switch,
8786
+ {
8787
+ disabled,
8788
+ checked: isSwitched,
8789
+ ...switchProps,
8790
+ onChange: handleSwitchChange,
8791
+ className: "switch",
8792
+ title: isSwitched ? getLabel("lblCanUpdate").text : getLabel("lblCannotUpdate").text
8793
+ }
8794
+ ),
8795
+ onClose && !disabled && /* @__PURE__ */ jsx(Close, { disabled, onClick: onClose })
8796
+ ] })
8797
+ ]
8798
+ }
8799
+ );
8800
+ }
8801
+ );
8802
+
8803
+ const PermissionsList = observer(() => {
8804
+ const controller = usePermissionsContext();
8805
+ const state = controller.permissions;
8806
+ return /* @__PURE__ */ jsxs(Box, { className: "permissions__list", children: [
8807
+ state.users && state.users.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
8808
+ /* @__PURE__ */ jsx("span", { children: getLabel("sbtUsers").text }),
8809
+ /* @__PURE__ */ jsx(Box, { as: "ul", children: state.users.map((c) => {
8810
+ return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
8811
+ SwitchCard,
8812
+ {
8813
+ disabled: controller.disabled,
8814
+ label: c.userLogin,
8815
+ align: "right",
8816
+ icon: "User2",
8817
+ onClose: () => controller.onChangeUsers(
8818
+ controller.permissions.users.filter(
8819
+ (s) => s.userId !== c.userId
8820
+ )
8821
+ ),
8822
+ onSwitch: (isSwitched) => c.canUpdate = isSwitched,
8823
+ value: c.canUpdate
8824
+ }
8825
+ ) }, c.userId);
8826
+ }) })
8827
+ ] }),
8828
+ state.pools && state.pools.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
8829
+ /* @__PURE__ */ jsx("span", { children: getLabel("lblPool").text }),
8830
+ /* @__PURE__ */ jsx(Box, { as: "ul", children: state.pools.map((c) => {
8831
+ return /* @__PURE__ */ jsx(Box, { as: "li", children: /* @__PURE__ */ jsx(
8832
+ SwitchCard,
8833
+ {
8834
+ label: c.poolName,
8835
+ align: "right",
8836
+ icon: "Groups",
8837
+ onClose: () => controller.onChangePools(
8838
+ controller.permissions.pools.filter(
8839
+ (s) => s.poolId !== c.poolId
8840
+ )
8841
+ ),
8842
+ onSwitch: (isSwitched) => c.canUpdate = isSwitched,
8843
+ value: c.canUpdate
8844
+ }
8845
+ ) }, c.poolName);
8846
+ }) })
8847
+ ] })
8848
+ ] });
8849
+ });
8850
+
8851
+ const UserModalBtn = observer(() => {
8852
+ const context = usePermissionsContext();
8853
+ return /* @__PURE__ */ jsx(
8854
+ SimpleButton,
8855
+ {
8856
+ disabled: context.disabled,
8857
+ variant: "outline",
8858
+ onClick: () => {
8859
+ makeApiaUsersModal2().openModal({
8860
+ title: window.LBL_ADD_USER
8861
+ }).then((selected) => {
8862
+ context.onChangeUsers(
8863
+ selected.reduce(
8864
+ (acc, c) => {
8865
+ const newItem = {
8866
+ userId: c.row.id,
8867
+ userLogin: String(c.row.cells[0].children),
8868
+ canUpdate: false
8869
+ };
8870
+ if (!acc.some((c2) => c2.userId === newItem.userId)) {
8871
+ acc.push(newItem);
8872
+ }
8873
+ return acc;
8874
+ },
8875
+ [...context.permissions.users]
8876
+ )
8877
+ );
8878
+ });
8879
+ },
8880
+ children: getLabel("btnAddUser").text
8881
+ }
8882
+ );
8883
+ });
8884
+
8885
+ const PoolModalBtn = observer(() => {
8886
+ const context = usePermissionsContext();
8887
+ return /* @__PURE__ */ jsx(
8888
+ SimpleButton,
8889
+ {
8890
+ disabled: context.disabled,
8891
+ variant: "outline",
8892
+ onClick: () => {
8893
+ makeApiaPoolsModals2().openModal({
8894
+ title: window.LBL_ADD_GROUP
8895
+ }).then((selected) => {
8896
+ context.onChangePools(
8897
+ selected.reduce(
8898
+ (acc, c) => {
8899
+ const newItem = {
8900
+ poolId: c.row.id,
8901
+ poolName: String(c.row.cells[0].children),
8902
+ canUpdate: false
8903
+ };
8904
+ if (!acc.some((c2) => c2.poolId === newItem.poolId)) {
8905
+ acc.push(newItem);
8906
+ }
8907
+ return acc;
8908
+ },
8909
+ [...context.permissions.pools]
8910
+ )
8911
+ );
8912
+ });
8913
+ },
8914
+ children: getLabel("btnAddPool").text
8915
+ }
8916
+ );
8917
+ });
8918
+
8919
+ const PermissionsContext = createContext(null);
8920
+ function usePermissionsContext() {
8921
+ return useContext(PermissionsContext);
8922
+ }
8923
+ const Permissions = observer(
8924
+ ({
8925
+ everyonePermissionsValue,
8926
+ collapsePermissions,
8927
+ disabled,
8928
+ onChangeEveryonePermissions,
8929
+ onChangeUsers,
8930
+ onChangePools,
8931
+ permissions
8932
+ }) => {
8933
+ return /* @__PURE__ */ jsx(
8934
+ CollapsiblePanel,
8935
+ {
8936
+ label: /* @__PURE__ */ jsx("span", { children: getLabel("lblPer").text }),
8937
+ id: "permissions",
8938
+ collapseIconToRight: true,
8939
+ closedIcon: "ArrowUpThin",
8940
+ openIcon: "ArrowDownThin",
8941
+ className: "uploader__permissions",
8942
+ collapsed: collapsePermissions,
8943
+ children: /* @__PURE__ */ jsx(
8944
+ PermissionsContext.Provider,
8945
+ {
8946
+ value: {
8947
+ onChangeUsers,
8948
+ onChangePools,
8949
+ permissions,
8950
+ disabled
8951
+ },
8952
+ children: /* @__PURE__ */ jsxs(Box, { ...getVariant("layout.common.components.uploader.permissions"), children: [
8953
+ /* @__PURE__ */ jsxs("label", { className: "uploader__permissions_selection", children: [
8954
+ /* @__PURE__ */ jsxs(Box, { children: [
8955
+ /* @__PURE__ */ jsx("span", { children: getLabel("lblTod").text }),
8956
+ /* @__PURE__ */ jsxs(
8957
+ Select,
8958
+ {
8959
+ disabled,
8960
+ onChange: (ev) => {
8961
+ onChangeEveryonePermissions(
8962
+ ev.target.value
8963
+ );
8964
+ },
8965
+ value: everyonePermissionsValue,
8966
+ children: [
8967
+ /* @__PURE__ */ jsx("option", { value: "M", children: getLabel("lblPerMod").text }),
8968
+ /* @__PURE__ */ jsx("option", { value: "R", children: getLabel("lblPerVer").text }),
8969
+ /* @__PURE__ */ jsx("option", { value: "", children: getLabel("lblAccessDenied").text })
8970
+ ]
8971
+ }
8972
+ )
8973
+ ] }),
8974
+ /* @__PURE__ */ jsx(UserModalBtn, {}),
8975
+ /* @__PURE__ */ jsx(PoolModalBtn, {})
8976
+ ] }),
8977
+ /* @__PURE__ */ jsx(PermissionsList, {})
8978
+ ] })
8979
+ }
8980
+ )
8981
+ }
8982
+ );
8983
+ }
8984
+ );
8985
+
8820
8986
  const TabsContext = React__default.createContext(null);
8821
8987
  function useTabsContext() {
8822
8988
  return React__default.useContext(TabsContext);
@@ -11126,5 +11292,5 @@ const _FiltersStore = class _FiltersStore {
11126
11292
  __publicField(_FiltersStore, "instance", new _FiltersStore());
11127
11293
  let FiltersStore = _FiltersStore;
11128
11294
 
11129
- export { Accordion, AccordionAside, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, ApiaUtil, ApiaUtilModalHandler, ApiaUtilTooltip, Aside, AsideLoader, AsidePanel, AutoEllipsis, Autocomplete, AutocompleteController, AutogrowTextarea, BaseButton, BodyAside, CalendarModal, Captcha, CenteredHeaderButtons, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, ContainerWithHeader, DateInput, DeadSessionModal, DefaultIconRenderer, DefaultTabsLabelRenderer, DialogButtonBar, Dropzone, FavoriteIcon, FieldErrorMessage, FieldLabel, FileCard, FilterConditionDTO, FilterDTO, FiltersStore, FloatingAside, FooterButtons, FooterResponsiveButtons, HamburguerMenu, Header, HeaderButtons, IconButton, IconInput, IconsList, Label, LabelBox, LinearLoader, LinearSpinnerLock, ListSkeletonLoader, Listbox, ListboxItem, LoaderSpinner, index as MDRenderer, Modal, ModalContext, NumberInput, Overlay, Pagination, Parameter, ParameterRender, Parameters, ParametersGroup, ParametersStore, ParametersTable, ProgressBar, RequiredMark, ScreenLocker, ShowResponsive, SimpleButton, SortableList, SortableListItem, Tab, Tabs, TabsContent, TabsController, TabsList, Templater, Toolbar, ToolbarController, ToolbarIconButton, ToolbarInput, ToolbarSelect, ToolbarSeparator, ToolbarTextButton, UnstyledSortableList, UploadHandler, Uploader, WaiTypeAhead, getFieldErrorStyles, getFieldTouchedStyles, importComponent, isFavoriteIcon, isParametersGroup, makeResponsiveComponent, menuController, parseNumberInputValueToNumber, parseNumberValueToNumberInput, useAccordionContext, useCurrentTab, useMenu, useModal, useModalContext, useOtherTagButton, useTabsContext };
11295
+ export { Accordion, AccordionAside, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, ApiaUtil, ApiaUtilModalHandler, ApiaUtilTooltip, Aside, AsideLoader, AsidePanel, AutoEllipsis, Autocomplete, AutocompleteController, AutogrowTextarea, BaseButton, BodyAside, CalendarModal, Captcha, CenteredHeaderButtons, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, ContainerWithHeader, DateInput, DeadSessionModal, DefaultIconRenderer, DefaultTabsLabelRenderer, DialogButtonBar, Dropzone, FavoriteIcon, FieldErrorMessage, FieldLabel, FileCard, FilterConditionDTO, FilterDTO, FiltersStore, FloatingAside, FooterButtons, FooterResponsiveButtons, HamburguerMenu, Header, HeaderButtons, IconButton, IconInput, IconsList, Label, LabelBox, LinearLoader, LinearSpinnerLock, ListSkeletonLoader, Listbox, ListboxItem, LoaderSpinner, index as MDRenderer, Modal, ModalContext, NumberInput, Overlay, Pagination, Parameter, ParameterRender, Parameters, ParametersGroup, ParametersStore, ParametersTable, Permissions, ProgressBar, RequiredMark, ScreenLocker, ShowResponsive, SimpleButton, SortableList, SortableListItem, SwitchCard, Tab, Tabs, TabsContent, TabsController, TabsList, Templater, Toolbar, ToolbarController, ToolbarIconButton, ToolbarInput, ToolbarSelect, ToolbarSeparator, ToolbarTextButton, UnstyledSortableList, UploadHandler, Uploader, WaiTypeAhead, getFieldErrorStyles, getFieldTouchedStyles, importComponent, isFavoriteIcon, isParametersGroup, makeResponsiveComponent, menuController, parseNumberInputValueToNumber, parseNumberValueToNumberInput, useAccordionContext, useCurrentTab, useMenu, useModal, useModalContext, useOtherTagButton, useTabsContext };
11130
11296
  //# sourceMappingURL=index.js.map