@apia/components 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import React__default, { createContext, useContext, useMemo, useEffect, useState, useRef, forwardRef, useCallback, useTransition, useDeferredValue, Children, memo, isValidElement, cloneElement, lazy } from 'react';
4
4
  import { shallowEqual } from '@apia/store';
5
5
  import { Box, getVariant, Button, Flex, spacing, Spinner, IconButton as IconButton$1, Image, Input, useBreakpointIndex, Close, responsive, Heading, useThemeUI, injectStyles, Select, focusOutline, makeStyledComponent, Label, Progress, Grid } from '@apia/theme';
6
- import { findScrollContainer, getSpecificParent, getLabel, useUpdateEffect, debugDispatcher, useCombinedRefs, focus, focusSelector, getFocusSelector, screenLocker, customEvents, isChild, getDateFormat, persistentStorage, disableChildrenFocus, enableChildrenFocus, EventEmitter, useDebouncedCallback, getIndex, addBoundary, noNaN, useMount, makeSingleImperativeComponent, useLatest, useImperativeComponentEvents, usePrevious, arrayOrArray } from '@apia/util';
6
+ import { findScrollContainer, getSpecificParent, getLabel, useUpdateEffect, debugDispatcher, useCombinedRefs, focus, focusSelector, getFocusSelector, screenLocker, customEvents, isChild, getDateFormat, persistentStorage, disableChildrenFocus, enableChildrenFocus, EventEmitter, useDebouncedCallback, getIndex, addBoundary, noNaN, useLatest, usePrevious, useMount, makeSingleImperativeComponent, useImperativeComponentEvents } from '@apia/util';
7
7
  import { icons, Icon as Icon$1 } from '@apia/icons';
8
8
  import { uniqueId as uniqueId$1, isFunction as isFunction$1 } from 'lodash-es';
9
9
  import dayjs from 'dayjs';
@@ -16,6 +16,7 @@ import { BarLoader } from 'react-spinners';
16
16
  import AnimateHeight from 'react-animate-height';
17
17
  import { useUpdateEffect as useUpdateEffect$1 } from 'ahooks';
18
18
  import { createFAsomeStore } from '@apia/dom-store';
19
+ import { ApiaUtil } from '@apia/objects';
19
20
  import { IconButton as IconButton$2 } from '@apia/components';
20
21
 
21
22
  const AccordionContext = createContext(null);
@@ -132,32 +133,32 @@ class AccordionHandler {
132
133
  }
133
134
  }
134
135
 
135
- var __defProp$F = Object.defineProperty;
136
- var __defProps$w = Object.defineProperties;
137
- var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
138
- var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
139
- var __hasOwnProp$G = Object.prototype.hasOwnProperty;
140
- var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
141
- var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
142
- var __spreadValues$F = (a, b) => {
136
+ var __defProp$G = Object.defineProperty;
137
+ var __defProps$x = Object.defineProperties;
138
+ var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
139
+ var __getOwnPropSymbols$H = Object.getOwnPropertySymbols;
140
+ var __hasOwnProp$H = Object.prototype.hasOwnProperty;
141
+ var __propIsEnum$H = Object.prototype.propertyIsEnumerable;
142
+ var __defNormalProp$G = (obj, key, value) => key in obj ? __defProp$G(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
143
+ var __spreadValues$G = (a, b) => {
143
144
  for (var prop in b || (b = {}))
144
- if (__hasOwnProp$G.call(b, prop))
145
- __defNormalProp$F(a, prop, b[prop]);
146
- if (__getOwnPropSymbols$G)
147
- for (var prop of __getOwnPropSymbols$G(b)) {
148
- if (__propIsEnum$G.call(b, prop))
149
- __defNormalProp$F(a, prop, b[prop]);
145
+ if (__hasOwnProp$H.call(b, prop))
146
+ __defNormalProp$G(a, prop, b[prop]);
147
+ if (__getOwnPropSymbols$H)
148
+ for (var prop of __getOwnPropSymbols$H(b)) {
149
+ if (__propIsEnum$H.call(b, prop))
150
+ __defNormalProp$G(a, prop, b[prop]);
150
151
  }
151
152
  return a;
152
153
  };
153
- var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
154
+ var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
154
155
  const KeyHandler$1 = (props) => {
155
156
  const [ref, setRef] = useState(null);
156
157
  const handler = useAccordionContext();
157
158
  useEffect(() => {
158
159
  if (ref) {
159
160
  ref.addEventListener("keydown", (ev) => {
160
- var _a, _b, _c, _d, _e, _f, _g;
161
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
161
162
  const accordionItem = (_a = ev.target) == null ? void 0 : _a.closest(
162
163
  ".accordion__item"
163
164
  );
@@ -182,6 +183,24 @@ const KeyHandler$1 = (props) => {
182
183
  ".accordion__item__button"
183
184
  )) == null ? void 0 : _g.focus();
184
185
  }
186
+ } else if (ev.code === "ArrowLeft") {
187
+ if ((_h = allItems[currentIndex]) == null ? void 0 : _h.querySelector(
188
+ '[aria-expanded="true"]'
189
+ )) {
190
+ ev.preventDefault();
191
+ (_j = (_i = allItems[currentIndex]) == null ? void 0 : _i.querySelector(
192
+ ".accordion__item__button"
193
+ )) == null ? void 0 : _j.click();
194
+ }
195
+ } else if (ev.code === "ArrowRight") {
196
+ if ((_k = allItems[currentIndex]) == null ? void 0 : _k.querySelector(
197
+ '[aria-expanded="false"]'
198
+ )) {
199
+ ev.preventDefault();
200
+ (_m = (_l = allItems[currentIndex]) == null ? void 0 : _l.querySelector(
201
+ ".accordion__item__button"
202
+ )) == null ? void 0 : _m.click();
203
+ }
185
204
  } else if (ev.code === "Space") {
186
205
  ev.preventDefault();
187
206
  ev.stopPropagation();
@@ -196,31 +215,31 @@ const KeyHandler$1 = (props) => {
196
215
  const variant = handler.hooks.usePropsSelector((current) => current.variant);
197
216
  return /* @__PURE__ */ jsx(
198
217
  Box,
199
- __spreadValues$F(__spreadProps$w(__spreadValues$F({}, props), {
218
+ __spreadValues$G(__spreadProps$x(__spreadValues$G({}, props), {
200
219
  ref: setRef
201
220
  }), variant ? getVariant(variant) : void 0)
202
221
  );
203
222
  };
204
223
 
205
- var __defProp$E = Object.defineProperty;
206
- var __defProps$v = Object.defineProperties;
207
- var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
208
- var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
209
- var __hasOwnProp$F = Object.prototype.hasOwnProperty;
210
- var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
211
- var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
212
- var __spreadValues$E = (a, b) => {
224
+ var __defProp$F = Object.defineProperty;
225
+ var __defProps$w = Object.defineProperties;
226
+ var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
227
+ var __getOwnPropSymbols$G = Object.getOwnPropertySymbols;
228
+ var __hasOwnProp$G = Object.prototype.hasOwnProperty;
229
+ var __propIsEnum$G = Object.prototype.propertyIsEnumerable;
230
+ var __defNormalProp$F = (obj, key, value) => key in obj ? __defProp$F(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
231
+ var __spreadValues$F = (a, b) => {
213
232
  for (var prop in b || (b = {}))
214
- if (__hasOwnProp$F.call(b, prop))
215
- __defNormalProp$E(a, prop, b[prop]);
216
- if (__getOwnPropSymbols$F)
217
- for (var prop of __getOwnPropSymbols$F(b)) {
218
- if (__propIsEnum$F.call(b, prop))
219
- __defNormalProp$E(a, prop, b[prop]);
233
+ if (__hasOwnProp$G.call(b, prop))
234
+ __defNormalProp$F(a, prop, b[prop]);
235
+ if (__getOwnPropSymbols$G)
236
+ for (var prop of __getOwnPropSymbols$G(b)) {
237
+ if (__propIsEnum$G.call(b, prop))
238
+ __defNormalProp$F(a, prop, b[prop]);
220
239
  }
221
240
  return a;
222
241
  };
223
- var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
242
+ var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
224
243
  function makeRowKey(rowIndex) {
225
244
  return `row_${typeof rowIndex === "number" ? rowIndex : rowIndex.rowIndex}`;
226
245
  }
@@ -258,7 +277,7 @@ function getDistinctors(storeId) {
258
277
  focused: state.focusedRow === distinctions.rowIndex
259
278
  }
260
279
  },
261
- etc: __spreadProps$v(__spreadValues$E({}, state.allowSelection ? {
280
+ etc: __spreadProps$w(__spreadValues$F({}, state.allowSelection ? {
262
281
  "aria-selected": state.selectedRows.includes(
263
282
  distinctions.rowIndex
264
283
  )
@@ -324,7 +343,7 @@ const keysMakers$1 = {
324
343
  };
325
344
  function getInitialState$1(initialState) {
326
345
  var _a, _b, _c;
327
- return __spreadProps$v(__spreadValues$E(__spreadValues$E({}, defaultState), initialState), {
346
+ return __spreadProps$w(__spreadValues$F(__spreadValues$F({}, defaultState), initialState), {
328
347
  searchFunction: (_a = initialState.searchFunction) != null ? _a : (label, searchString) => !!label.match(new RegExp(searchString)),
329
348
  startsWithFunction: (_b = initialState.startsWithFunction) != null ? _b : (label, searchString) => {
330
349
  return label.startsWith(searchString);
@@ -388,33 +407,33 @@ const AccordionItemButton = ({ children }) => {
388
407
  return /* @__PURE__ */ jsx(Fragment, { children });
389
408
  };
390
409
 
391
- var __defProp$D = Object.defineProperty;
392
- var __defProps$u = Object.defineProperties;
393
- var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
394
- var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
395
- var __hasOwnProp$E = Object.prototype.hasOwnProperty;
396
- var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
397
- var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
398
- var __spreadValues$D = (a, b) => {
410
+ var __defProp$E = Object.defineProperty;
411
+ var __defProps$v = Object.defineProperties;
412
+ var __getOwnPropDescs$v = Object.getOwnPropertyDescriptors;
413
+ var __getOwnPropSymbols$F = Object.getOwnPropertySymbols;
414
+ var __hasOwnProp$F = Object.prototype.hasOwnProperty;
415
+ var __propIsEnum$F = Object.prototype.propertyIsEnumerable;
416
+ var __defNormalProp$E = (obj, key, value) => key in obj ? __defProp$E(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
417
+ var __spreadValues$E = (a, b) => {
399
418
  for (var prop in b || (b = {}))
400
- if (__hasOwnProp$E.call(b, prop))
401
- __defNormalProp$D(a, prop, b[prop]);
402
- if (__getOwnPropSymbols$E)
403
- for (var prop of __getOwnPropSymbols$E(b)) {
404
- if (__propIsEnum$E.call(b, prop))
405
- __defNormalProp$D(a, prop, b[prop]);
419
+ if (__hasOwnProp$F.call(b, prop))
420
+ __defNormalProp$E(a, prop, b[prop]);
421
+ if (__getOwnPropSymbols$F)
422
+ for (var prop of __getOwnPropSymbols$F(b)) {
423
+ if (__propIsEnum$F.call(b, prop))
424
+ __defNormalProp$E(a, prop, b[prop]);
406
425
  }
407
426
  return a;
408
427
  };
409
- var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
428
+ var __spreadProps$v = (a, b) => __defProps$v(a, __getOwnPropDescs$v(b));
410
429
  var __objRest$f = (source, exclude) => {
411
430
  var target = {};
412
431
  for (var prop in source)
413
- if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
432
+ if (__hasOwnProp$F.call(source, prop) && exclude.indexOf(prop) < 0)
414
433
  target[prop] = source[prop];
415
- if (source != null && __getOwnPropSymbols$E)
416
- for (var prop of __getOwnPropSymbols$E(source)) {
417
- if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
434
+ if (source != null && __getOwnPropSymbols$F)
435
+ for (var prop of __getOwnPropSymbols$F(source)) {
436
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$F.call(source, prop))
418
437
  target[prop] = source[prop];
419
438
  }
420
439
  return target;
@@ -448,7 +467,7 @@ const BaseButton = (_a) => {
448
467
  ]);
449
468
  return /* @__PURE__ */ jsx(
450
469
  Button,
451
- __spreadProps$u(__spreadValues$D(__spreadProps$u(__spreadValues$D({
470
+ __spreadProps$v(__spreadValues$E(__spreadProps$v(__spreadValues$E({
452
471
  id,
453
472
  name,
454
473
  onClick
@@ -461,7 +480,7 @@ const BaseButton = (_a) => {
461
480
  Flex,
462
481
  {
463
482
  as: "span",
464
- sx: __spreadValues$D({
483
+ sx: __spreadValues$E({
465
484
  color: "inherit",
466
485
  width: "100%",
467
486
  flexDirection: "row",
@@ -483,33 +502,33 @@ const BaseButton = (_a) => {
483
502
  );
484
503
  };
485
504
 
486
- var __defProp$C = Object.defineProperty;
487
- var __defProps$t = Object.defineProperties;
488
- var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
489
- var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
490
- var __hasOwnProp$D = Object.prototype.hasOwnProperty;
491
- var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
492
- var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
493
- var __spreadValues$C = (a, b) => {
505
+ var __defProp$D = Object.defineProperty;
506
+ var __defProps$u = Object.defineProperties;
507
+ var __getOwnPropDescs$u = Object.getOwnPropertyDescriptors;
508
+ var __getOwnPropSymbols$E = Object.getOwnPropertySymbols;
509
+ var __hasOwnProp$E = Object.prototype.hasOwnProperty;
510
+ var __propIsEnum$E = Object.prototype.propertyIsEnumerable;
511
+ var __defNormalProp$D = (obj, key, value) => key in obj ? __defProp$D(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
512
+ var __spreadValues$D = (a, b) => {
494
513
  for (var prop in b || (b = {}))
495
- if (__hasOwnProp$D.call(b, prop))
496
- __defNormalProp$C(a, prop, b[prop]);
497
- if (__getOwnPropSymbols$D)
498
- for (var prop of __getOwnPropSymbols$D(b)) {
499
- if (__propIsEnum$D.call(b, prop))
500
- __defNormalProp$C(a, prop, b[prop]);
514
+ if (__hasOwnProp$E.call(b, prop))
515
+ __defNormalProp$D(a, prop, b[prop]);
516
+ if (__getOwnPropSymbols$E)
517
+ for (var prop of __getOwnPropSymbols$E(b)) {
518
+ if (__propIsEnum$E.call(b, prop))
519
+ __defNormalProp$D(a, prop, b[prop]);
501
520
  }
502
521
  return a;
503
522
  };
504
- var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
523
+ var __spreadProps$u = (a, b) => __defProps$u(a, __getOwnPropDescs$u(b));
505
524
  var __objRest$e = (source, exclude) => {
506
525
  var target = {};
507
526
  for (var prop in source)
508
- if (__hasOwnProp$D.call(source, prop) && exclude.indexOf(prop) < 0)
527
+ if (__hasOwnProp$E.call(source, prop) && exclude.indexOf(prop) < 0)
509
528
  target[prop] = source[prop];
510
- if (source != null && __getOwnPropSymbols$D)
511
- for (var prop of __getOwnPropSymbols$D(source)) {
512
- if (exclude.indexOf(prop) < 0 && __propIsEnum$D.call(source, prop))
529
+ if (source != null && __getOwnPropSymbols$E)
530
+ for (var prop of __getOwnPropSymbols$E(source)) {
531
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$E.call(source, prop))
513
532
  target[prop] = source[prop];
514
533
  }
515
534
  return target;
@@ -574,7 +593,7 @@ const IconButton = React.forwardRef(
574
593
  }, [icon]);
575
594
  return /* @__PURE__ */ jsx(
576
595
  IconButton$1,
577
- __spreadProps$t(__spreadValues$C(__spreadProps$t(__spreadValues$C({
596
+ __spreadProps$u(__spreadValues$D(__spreadProps$u(__spreadValues$D({
578
597
  id,
579
598
  ref,
580
599
  onClick: React.useCallback(
@@ -603,33 +622,33 @@ const IconButton = React.forwardRef(
603
622
  );
604
623
  IconButton.displayName = "IconButton";
605
624
 
606
- var __defProp$B = Object.defineProperty;
607
- var __defProps$s = Object.defineProperties;
608
- var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
609
- var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
610
- var __hasOwnProp$C = Object.prototype.hasOwnProperty;
611
- var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
612
- var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
613
- var __spreadValues$B = (a, b) => {
625
+ var __defProp$C = Object.defineProperty;
626
+ var __defProps$t = Object.defineProperties;
627
+ var __getOwnPropDescs$t = Object.getOwnPropertyDescriptors;
628
+ var __getOwnPropSymbols$D = Object.getOwnPropertySymbols;
629
+ var __hasOwnProp$D = Object.prototype.hasOwnProperty;
630
+ var __propIsEnum$D = Object.prototype.propertyIsEnumerable;
631
+ var __defNormalProp$C = (obj, key, value) => key in obj ? __defProp$C(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
632
+ var __spreadValues$C = (a, b) => {
614
633
  for (var prop in b || (b = {}))
615
- if (__hasOwnProp$C.call(b, prop))
616
- __defNormalProp$B(a, prop, b[prop]);
617
- if (__getOwnPropSymbols$C)
618
- for (var prop of __getOwnPropSymbols$C(b)) {
619
- if (__propIsEnum$C.call(b, prop))
620
- __defNormalProp$B(a, prop, b[prop]);
634
+ if (__hasOwnProp$D.call(b, prop))
635
+ __defNormalProp$C(a, prop, b[prop]);
636
+ if (__getOwnPropSymbols$D)
637
+ for (var prop of __getOwnPropSymbols$D(b)) {
638
+ if (__propIsEnum$D.call(b, prop))
639
+ __defNormalProp$C(a, prop, b[prop]);
621
640
  }
622
641
  return a;
623
642
  };
624
- var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
643
+ var __spreadProps$t = (a, b) => __defProps$t(a, __getOwnPropDescs$t(b));
625
644
  var __objRest$d = (source, exclude) => {
626
645
  var target = {};
627
646
  for (var prop in source)
628
- if (__hasOwnProp$C.call(source, prop) && exclude.indexOf(prop) < 0)
647
+ if (__hasOwnProp$D.call(source, prop) && exclude.indexOf(prop) < 0)
629
648
  target[prop] = source[prop];
630
- if (source != null && __getOwnPropSymbols$C)
631
- for (var prop of __getOwnPropSymbols$C(source)) {
632
- if (exclude.indexOf(prop) < 0 && __propIsEnum$C.call(source, prop))
649
+ if (source != null && __getOwnPropSymbols$D)
650
+ for (var prop of __getOwnPropSymbols$D(source)) {
651
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$D.call(source, prop))
633
652
  target[prop] = source[prop];
634
653
  }
635
654
  return target;
@@ -657,6 +676,7 @@ const simpleButton = {
657
676
  const SimpleButton = React.forwardRef(
658
677
  (_a, ref) => {
659
678
  var _b = _a, {
679
+ buttonSx,
660
680
  children = null,
661
681
  className,
662
682
  disabled = false,
@@ -674,6 +694,7 @@ const SimpleButton = React.forwardRef(
674
694
  type = "button",
675
695
  variant = "primary"
676
696
  } = _b, buttonProps = __objRest$d(_b, [
697
+ "buttonSx",
677
698
  "children",
678
699
  "className",
679
700
  "disabled",
@@ -713,7 +734,7 @@ const SimpleButton = React.forwardRef(
713
734
  const Icon = React.useMemo(() => icon, [icon]);
714
735
  return /* @__PURE__ */ jsxs(
715
736
  Button,
716
- __spreadProps$s(__spreadValues$B(__spreadValues$B({
737
+ __spreadProps$t(__spreadValues$C(__spreadValues$C({
717
738
  ref,
718
739
  id,
719
740
  name,
@@ -724,7 +745,7 @@ const SimpleButton = React.forwardRef(
724
745
  disabled: isLoading != null ? isLoading : disabled,
725
746
  className
726
747
  }, getVariant(`${variant}${size !== "md" && size ? `-${size}` : ""}`)), buttonProps), {
727
- sx: simpleButton,
748
+ sx: __spreadValues$C(__spreadValues$C({}, simpleButton), buttonSx),
728
749
  children: [
729
750
  Icon && iconPosition === "left" && /* @__PURE__ */ jsx(Icon, { title: "", size: iconSize, color: iconColor }),
730
751
  /* @__PURE__ */ jsx(Box, { as: "span", className: "button__content", sx: spanSx, children: children != null ? children : title }),
@@ -772,25 +793,25 @@ function useOtherTagButton(props) {
772
793
  };
773
794
  }
774
795
 
775
- var __defProp$A = Object.defineProperty;
776
- var __defProps$r = Object.defineProperties;
777
- var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
778
- var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
779
- var __hasOwnProp$B = Object.prototype.hasOwnProperty;
780
- var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
781
- var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
782
- var __spreadValues$A = (a, b) => {
796
+ var __defProp$B = Object.defineProperty;
797
+ var __defProps$s = Object.defineProperties;
798
+ var __getOwnPropDescs$s = Object.getOwnPropertyDescriptors;
799
+ var __getOwnPropSymbols$C = Object.getOwnPropertySymbols;
800
+ var __hasOwnProp$C = Object.prototype.hasOwnProperty;
801
+ var __propIsEnum$C = Object.prototype.propertyIsEnumerable;
802
+ var __defNormalProp$B = (obj, key, value) => key in obj ? __defProp$B(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
803
+ var __spreadValues$B = (a, b) => {
783
804
  for (var prop in b || (b = {}))
784
- if (__hasOwnProp$B.call(b, prop))
785
- __defNormalProp$A(a, prop, b[prop]);
786
- if (__getOwnPropSymbols$B)
787
- for (var prop of __getOwnPropSymbols$B(b)) {
788
- if (__propIsEnum$B.call(b, prop))
789
- __defNormalProp$A(a, prop, b[prop]);
805
+ if (__hasOwnProp$C.call(b, prop))
806
+ __defNormalProp$B(a, prop, b[prop]);
807
+ if (__getOwnPropSymbols$C)
808
+ for (var prop of __getOwnPropSymbols$C(b)) {
809
+ if (__propIsEnum$C.call(b, prop))
810
+ __defNormalProp$B(a, prop, b[prop]);
790
811
  }
791
812
  return a;
792
813
  };
793
- var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
814
+ var __spreadProps$s = (a, b) => __defProps$s(a, __getOwnPropDescs$s(b));
794
815
  const Captcha = ({
795
816
  name,
796
817
  imageUrl,
@@ -804,7 +825,7 @@ const Captcha = ({
804
825
  };
805
826
  return /* @__PURE__ */ jsxs(
806
827
  Flex,
807
- __spreadProps$r(__spreadValues$A({
828
+ __spreadProps$s(__spreadValues$B({
808
829
  sx: {
809
830
  flexDirection: "column"
810
831
  },
@@ -849,33 +870,33 @@ const Captcha = ({
849
870
  );
850
871
  };
851
872
 
852
- var __defProp$z = Object.defineProperty;
853
- var __defProps$q = Object.defineProperties;
854
- var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
855
- var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
856
- var __hasOwnProp$A = Object.prototype.hasOwnProperty;
857
- var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
858
- var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
859
- var __spreadValues$z = (a, b) => {
873
+ var __defProp$A = Object.defineProperty;
874
+ var __defProps$r = Object.defineProperties;
875
+ var __getOwnPropDescs$r = Object.getOwnPropertyDescriptors;
876
+ var __getOwnPropSymbols$B = Object.getOwnPropertySymbols;
877
+ var __hasOwnProp$B = Object.prototype.hasOwnProperty;
878
+ var __propIsEnum$B = Object.prototype.propertyIsEnumerable;
879
+ var __defNormalProp$A = (obj, key, value) => key in obj ? __defProp$A(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
880
+ var __spreadValues$A = (a, b) => {
860
881
  for (var prop in b || (b = {}))
861
- if (__hasOwnProp$A.call(b, prop))
862
- __defNormalProp$z(a, prop, b[prop]);
863
- if (__getOwnPropSymbols$A)
864
- for (var prop of __getOwnPropSymbols$A(b)) {
865
- if (__propIsEnum$A.call(b, prop))
866
- __defNormalProp$z(a, prop, b[prop]);
882
+ if (__hasOwnProp$B.call(b, prop))
883
+ __defNormalProp$A(a, prop, b[prop]);
884
+ if (__getOwnPropSymbols$B)
885
+ for (var prop of __getOwnPropSymbols$B(b)) {
886
+ if (__propIsEnum$B.call(b, prop))
887
+ __defNormalProp$A(a, prop, b[prop]);
867
888
  }
868
889
  return a;
869
890
  };
870
- var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
891
+ var __spreadProps$r = (a, b) => __defProps$r(a, __getOwnPropDescs$r(b));
871
892
  var __objRest$c = (source, exclude) => {
872
893
  var target = {};
873
894
  for (var prop in source)
874
- if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
895
+ if (__hasOwnProp$B.call(source, prop) && exclude.indexOf(prop) < 0)
875
896
  target[prop] = source[prop];
876
- if (source != null && __getOwnPropSymbols$A)
877
- for (var prop of __getOwnPropSymbols$A(source)) {
878
- if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
897
+ if (source != null && __getOwnPropSymbols$B)
898
+ for (var prop of __getOwnPropSymbols$B(source)) {
899
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$B.call(source, prop))
879
900
  target[prop] = source[prop];
880
901
  }
881
902
  return target;
@@ -937,7 +958,7 @@ const Checkbox$1 = forwardRef(
937
958
  // eslint-disable-next-line react/forbid-elements
938
959
  /* @__PURE__ */ jsx(
939
960
  "input",
940
- __spreadValues$z({
961
+ __spreadValues$A({
941
962
  type: "checkbox",
942
963
  onClick: props.onClick,
943
964
  "aria-checked": isChecked,
@@ -959,7 +980,7 @@ const Checkbox$1 = forwardRef(
959
980
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
960
981
  /* @__PURE__ */ jsx(
961
982
  Button,
962
- __spreadProps$q(__spreadValues$z(__spreadProps$q(__spreadValues$z({}, props), {
983
+ __spreadProps$r(__spreadValues$A(__spreadProps$r(__spreadValues$A({}, props), {
963
984
  onClick: (ev) => {
964
985
  var _a3;
965
986
  if (readOnly) {
@@ -1094,6 +1115,14 @@ const globalFocus = new (_a$1 = class {
1094
1115
  }
1095
1116
  }, _onFocusCallbacks = new WeakMap(), _a$1)();
1096
1117
 
1118
+ const ModalContext = createContext(null);
1119
+ function useModalContext() {
1120
+ const context = useContext(ModalContext);
1121
+ if (!context)
1122
+ throw new Error("There is no ModalContext");
1123
+ return context;
1124
+ }
1125
+
1097
1126
  var __accessCheck$1 = (obj, member, msg) => {
1098
1127
  if (!member.has(obj))
1099
1128
  throw TypeError("Cannot " + msg);
@@ -1190,33 +1219,33 @@ function useBodyScrollLock(isLocked) {
1190
1219
  }, [isLocked]);
1191
1220
  }
1192
1221
 
1193
- var __defProp$y = Object.defineProperty;
1194
- var __defProps$p = Object.defineProperties;
1195
- var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
1196
- var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
1197
- var __hasOwnProp$z = Object.prototype.hasOwnProperty;
1198
- var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
1199
- var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1200
- var __spreadValues$y = (a, b) => {
1222
+ var __defProp$z = Object.defineProperty;
1223
+ var __defProps$q = Object.defineProperties;
1224
+ var __getOwnPropDescs$q = Object.getOwnPropertyDescriptors;
1225
+ var __getOwnPropSymbols$A = Object.getOwnPropertySymbols;
1226
+ var __hasOwnProp$A = Object.prototype.hasOwnProperty;
1227
+ var __propIsEnum$A = Object.prototype.propertyIsEnumerable;
1228
+ var __defNormalProp$z = (obj, key, value) => key in obj ? __defProp$z(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1229
+ var __spreadValues$z = (a, b) => {
1201
1230
  for (var prop in b || (b = {}))
1202
- if (__hasOwnProp$z.call(b, prop))
1203
- __defNormalProp$y(a, prop, b[prop]);
1204
- if (__getOwnPropSymbols$z)
1205
- for (var prop of __getOwnPropSymbols$z(b)) {
1206
- if (__propIsEnum$z.call(b, prop))
1207
- __defNormalProp$y(a, prop, b[prop]);
1231
+ if (__hasOwnProp$A.call(b, prop))
1232
+ __defNormalProp$z(a, prop, b[prop]);
1233
+ if (__getOwnPropSymbols$A)
1234
+ for (var prop of __getOwnPropSymbols$A(b)) {
1235
+ if (__propIsEnum$A.call(b, prop))
1236
+ __defNormalProp$z(a, prop, b[prop]);
1208
1237
  }
1209
1238
  return a;
1210
1239
  };
1211
- var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
1240
+ var __spreadProps$q = (a, b) => __defProps$q(a, __getOwnPropDescs$q(b));
1212
1241
  var __objRest$b = (source, exclude) => {
1213
1242
  var target = {};
1214
1243
  for (var prop in source)
1215
- if (__hasOwnProp$z.call(source, prop) && exclude.indexOf(prop) < 0)
1244
+ if (__hasOwnProp$A.call(source, prop) && exclude.indexOf(prop) < 0)
1216
1245
  target[prop] = source[prop];
1217
- if (source != null && __getOwnPropSymbols$z)
1218
- for (var prop of __getOwnPropSymbols$z(source)) {
1219
- if (exclude.indexOf(prop) < 0 && __propIsEnum$z.call(source, prop))
1246
+ if (source != null && __getOwnPropSymbols$A)
1247
+ for (var prop of __getOwnPropSymbols$A(source)) {
1248
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$A.call(source, prop))
1220
1249
  target[prop] = source[prop];
1221
1250
  }
1222
1251
  return target;
@@ -1258,7 +1287,7 @@ const Overlay = React.forwardRef(
1258
1287
  unmountOnExit: true,
1259
1288
  children: /* @__PURE__ */ jsx(
1260
1289
  Box,
1261
- __spreadProps$p(__spreadValues$y(__spreadProps$p(__spreadValues$y({
1290
+ __spreadProps$q(__spreadValues$z(__spreadProps$q(__spreadValues$z({
1262
1291
  className: `${className} overlay`,
1263
1292
  ref: assignRefs
1264
1293
  }, props), {
@@ -1402,28 +1431,25 @@ const DialogHeader = ({
1402
1431
  );
1403
1432
  };
1404
1433
 
1405
- var __defProp$x = Object.defineProperty;
1406
- var __defProps$o = Object.defineProperties;
1407
- var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
1408
- var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
1409
- var __hasOwnProp$y = Object.prototype.hasOwnProperty;
1410
- var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
1411
- var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1412
- var __spreadValues$x = (a, b) => {
1434
+ var __defProp$y = Object.defineProperty;
1435
+ var __defProps$p = Object.defineProperties;
1436
+ var __getOwnPropDescs$p = Object.getOwnPropertyDescriptors;
1437
+ var __getOwnPropSymbols$z = Object.getOwnPropertySymbols;
1438
+ var __hasOwnProp$z = Object.prototype.hasOwnProperty;
1439
+ var __propIsEnum$z = Object.prototype.propertyIsEnumerable;
1440
+ var __defNormalProp$y = (obj, key, value) => key in obj ? __defProp$y(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1441
+ var __spreadValues$y = (a, b) => {
1413
1442
  for (var prop in b || (b = {}))
1414
- if (__hasOwnProp$y.call(b, prop))
1415
- __defNormalProp$x(a, prop, b[prop]);
1416
- if (__getOwnPropSymbols$y)
1417
- for (var prop of __getOwnPropSymbols$y(b)) {
1418
- if (__propIsEnum$y.call(b, prop))
1419
- __defNormalProp$x(a, prop, b[prop]);
1443
+ if (__hasOwnProp$z.call(b, prop))
1444
+ __defNormalProp$y(a, prop, b[prop]);
1445
+ if (__getOwnPropSymbols$z)
1446
+ for (var prop of __getOwnPropSymbols$z(b)) {
1447
+ if (__propIsEnum$z.call(b, prop))
1448
+ __defNormalProp$y(a, prop, b[prop]);
1420
1449
  }
1421
1450
  return a;
1422
1451
  };
1423
- var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
1424
- const ModalContext = React__default.createContext(
1425
- {}
1426
- );
1452
+ var __spreadProps$p = (a, b) => __defProps$p(a, __getOwnPropDescs$p(b));
1427
1453
  const Modal = forwardRef(
1428
1454
  ({
1429
1455
  animationDuration = 150,
@@ -1451,6 +1477,11 @@ const Modal = forwardRef(
1451
1477
  title = "",
1452
1478
  variant
1453
1479
  }, ref) => {
1480
+ const lastTitle = useRef(title);
1481
+ const [innerTitle, setInnerTitle] = useState(title);
1482
+ if (lastTitle.current !== title && innerTitle !== title) {
1483
+ setInnerTitle(title);
1484
+ }
1454
1485
  const [isOpenInner, setIsOpen] = useState(isOpen);
1455
1486
  const innerId = React__default.useMemo(() => {
1456
1487
  return `Modal${uniqueId$2()}`;
@@ -1506,7 +1537,7 @@ const Modal = forwardRef(
1506
1537
  getFocusSelector(":not(.modal__closeButton)")
1507
1538
  );
1508
1539
  },
1509
- __spreadProps$o(__spreadValues$x({}, initialFocusConfiguration), { focusEvenWhenScreenLocked: true })
1540
+ __spreadProps$p(__spreadValues$y({}, initialFocusConfiguration), { focusEvenWhenScreenLocked: true })
1510
1541
  );
1511
1542
  }
1512
1543
  }
@@ -1522,8 +1553,16 @@ const Modal = forwardRef(
1522
1553
  ModalContext.Provider,
1523
1554
  {
1524
1555
  value: React__default.useMemo(() => {
1525
- return { descriptionId: `${innerId}_Description` };
1526
- }, [innerId]),
1556
+ return {
1557
+ changeTitle: (newTitle) => {
1558
+ setInnerTitle(newTitle);
1559
+ },
1560
+ close: () => {
1561
+ closeHandler();
1562
+ },
1563
+ descriptionId: `${innerId}_Description`
1564
+ };
1565
+ }, [closeHandler, innerId]),
1527
1566
  children: /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsx(
1528
1567
  Overlay,
1529
1568
  {
@@ -1546,7 +1585,7 @@ const Modal = forwardRef(
1546
1585
  nodeRef,
1547
1586
  children: /* @__PURE__ */ jsx(
1548
1587
  Box,
1549
- __spreadProps$o(__spreadValues$x({
1588
+ __spreadProps$p(__spreadValues$y({
1550
1589
  ref: nodeRef,
1551
1590
  className: "modal__variantWrapper"
1552
1591
  }, variant ? getVariant(variant) : {}), {
@@ -1562,7 +1601,7 @@ const Modal = forwardRef(
1562
1601
  className: "modal__main",
1563
1602
  "data-scroll-lock-scrollable": true,
1564
1603
  sx: React__default.useMemo(() => {
1565
- return __spreadValues$x({
1604
+ return __spreadValues$y({
1566
1605
  variant: `layout.common.modals.${size}`
1567
1606
  }, maxWidth !== void 0 ? { maxWidth } : {});
1568
1607
  }, [maxWidth, size]),
@@ -1573,7 +1612,7 @@ const Modal = forwardRef(
1573
1612
  {
1574
1613
  className: "modal__header",
1575
1614
  NavBar,
1576
- title,
1615
+ title: innerTitle,
1577
1616
  close: closeHandler,
1578
1617
  hideCloseButton,
1579
1618
  id: `${innerId}_Header`
@@ -1602,33 +1641,33 @@ const Modal = forwardRef(
1602
1641
  );
1603
1642
  Modal.displayName = "Modal";
1604
1643
 
1605
- var __defProp$w = Object.defineProperty;
1606
- var __defProps$n = Object.defineProperties;
1607
- var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
1608
- var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
1609
- var __hasOwnProp$x = Object.prototype.hasOwnProperty;
1610
- var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
1611
- var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1612
- var __spreadValues$w = (a, b) => {
1644
+ var __defProp$x = Object.defineProperty;
1645
+ var __defProps$o = Object.defineProperties;
1646
+ var __getOwnPropDescs$o = Object.getOwnPropertyDescriptors;
1647
+ var __getOwnPropSymbols$y = Object.getOwnPropertySymbols;
1648
+ var __hasOwnProp$y = Object.prototype.hasOwnProperty;
1649
+ var __propIsEnum$y = Object.prototype.propertyIsEnumerable;
1650
+ var __defNormalProp$x = (obj, key, value) => key in obj ? __defProp$x(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1651
+ var __spreadValues$x = (a, b) => {
1613
1652
  for (var prop in b || (b = {}))
1614
- if (__hasOwnProp$x.call(b, prop))
1615
- __defNormalProp$w(a, prop, b[prop]);
1616
- if (__getOwnPropSymbols$x)
1617
- for (var prop of __getOwnPropSymbols$x(b)) {
1618
- if (__propIsEnum$x.call(b, prop))
1619
- __defNormalProp$w(a, prop, b[prop]);
1653
+ if (__hasOwnProp$y.call(b, prop))
1654
+ __defNormalProp$x(a, prop, b[prop]);
1655
+ if (__getOwnPropSymbols$y)
1656
+ for (var prop of __getOwnPropSymbols$y(b)) {
1657
+ if (__propIsEnum$y.call(b, prop))
1658
+ __defNormalProp$x(a, prop, b[prop]);
1620
1659
  }
1621
1660
  return a;
1622
1661
  };
1623
- var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
1662
+ var __spreadProps$o = (a, b) => __defProps$o(a, __getOwnPropDescs$o(b));
1624
1663
  var __objRest$a = (source, exclude) => {
1625
1664
  var target = {};
1626
1665
  for (var prop in source)
1627
- if (__hasOwnProp$x.call(source, prop) && exclude.indexOf(prop) < 0)
1666
+ if (__hasOwnProp$y.call(source, prop) && exclude.indexOf(prop) < 0)
1628
1667
  target[prop] = source[prop];
1629
- if (source != null && __getOwnPropSymbols$x)
1630
- for (var prop of __getOwnPropSymbols$x(source)) {
1631
- if (exclude.indexOf(prop) < 0 && __propIsEnum$x.call(source, prop))
1668
+ if (source != null && __getOwnPropSymbols$y)
1669
+ for (var prop of __getOwnPropSymbols$y(source)) {
1670
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$y.call(source, prop))
1632
1671
  target[prop] = source[prop];
1633
1672
  }
1634
1673
  return target;
@@ -1638,7 +1677,7 @@ const CalendarModal = React__default.forwardRef(
1638
1677
  var _b = _a, { handleClickDay, onCancel, calValue, locale, size } = _b, props = __objRest$a(_b, ["handleClickDay", "onCancel", "calValue", "locale", "size"]);
1639
1678
  return /* @__PURE__ */ jsx(
1640
1679
  Modal,
1641
- __spreadProps$n(__spreadValues$w({
1680
+ __spreadProps$o(__spreadValues$x({
1642
1681
  noHeader: true,
1643
1682
  size: size != null ? size : "cal",
1644
1683
  shouldCloseOnEsc: true,
@@ -1668,25 +1707,25 @@ const CalendarModal = React__default.forwardRef(
1668
1707
  );
1669
1708
  CalendarModal.displayName = "CalendarModal";
1670
1709
 
1671
- var __defProp$v = Object.defineProperty;
1672
- var __defProps$m = Object.defineProperties;
1673
- var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
1674
- var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1675
- var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1676
- var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1677
- var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1678
- var __spreadValues$v = (a, b) => {
1710
+ var __defProp$w = Object.defineProperty;
1711
+ var __defProps$n = Object.defineProperties;
1712
+ var __getOwnPropDescs$n = Object.getOwnPropertyDescriptors;
1713
+ var __getOwnPropSymbols$x = Object.getOwnPropertySymbols;
1714
+ var __hasOwnProp$x = Object.prototype.hasOwnProperty;
1715
+ var __propIsEnum$x = Object.prototype.propertyIsEnumerable;
1716
+ var __defNormalProp$w = (obj, key, value) => key in obj ? __defProp$w(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1717
+ var __spreadValues$w = (a, b) => {
1679
1718
  for (var prop in b || (b = {}))
1680
- if (__hasOwnProp$w.call(b, prop))
1681
- __defNormalProp$v(a, prop, b[prop]);
1682
- if (__getOwnPropSymbols$w)
1683
- for (var prop of __getOwnPropSymbols$w(b)) {
1684
- if (__propIsEnum$w.call(b, prop))
1685
- __defNormalProp$v(a, prop, b[prop]);
1719
+ if (__hasOwnProp$x.call(b, prop))
1720
+ __defNormalProp$w(a, prop, b[prop]);
1721
+ if (__getOwnPropSymbols$x)
1722
+ for (var prop of __getOwnPropSymbols$x(b)) {
1723
+ if (__propIsEnum$x.call(b, prop))
1724
+ __defNormalProp$w(a, prop, b[prop]);
1686
1725
  }
1687
1726
  return a;
1688
1727
  };
1689
- var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
1728
+ var __spreadProps$n = (a, b) => __defProps$n(a, __getOwnPropDescs$n(b));
1690
1729
  function useModal(configuration) {
1691
1730
  var _a, _b, _c;
1692
1731
  const [isLoading, setIsLoading] = React__default.useState(false);
@@ -1697,7 +1736,7 @@ function useModal(configuration) {
1697
1736
  Portal,
1698
1737
  hide: hidePortal,
1699
1738
  show: showPortal
1700
- } = usePortal(__spreadProps$m(__spreadValues$v({}, configuration == null ? void 0 : configuration.portalArgs), {
1739
+ } = usePortal(__spreadProps$n(__spreadValues$w({}, configuration == null ? void 0 : configuration.portalArgs), {
1701
1740
  containerId: "AppModals",
1702
1741
  autoRemoveContainer: false,
1703
1742
  escToHide: false,
@@ -1754,32 +1793,32 @@ function useModal(configuration) {
1754
1793
  };
1755
1794
  }
1756
1795
 
1757
- var __defProp$u = Object.defineProperty;
1758
- var __defProps$l = Object.defineProperties;
1759
- var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
1760
- var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1761
- var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1762
- var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1763
- var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1764
- var __spreadValues$u = (a, b) => {
1796
+ var __defProp$v = Object.defineProperty;
1797
+ var __defProps$m = Object.defineProperties;
1798
+ var __getOwnPropDescs$m = Object.getOwnPropertyDescriptors;
1799
+ var __getOwnPropSymbols$w = Object.getOwnPropertySymbols;
1800
+ var __hasOwnProp$w = Object.prototype.hasOwnProperty;
1801
+ var __propIsEnum$w = Object.prototype.propertyIsEnumerable;
1802
+ var __defNormalProp$v = (obj, key, value) => key in obj ? __defProp$v(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1803
+ var __spreadValues$v = (a, b) => {
1765
1804
  for (var prop in b || (b = {}))
1766
- if (__hasOwnProp$v.call(b, prop))
1767
- __defNormalProp$u(a, prop, b[prop]);
1768
- if (__getOwnPropSymbols$v)
1769
- for (var prop of __getOwnPropSymbols$v(b)) {
1770
- if (__propIsEnum$v.call(b, prop))
1771
- __defNormalProp$u(a, prop, b[prop]);
1805
+ if (__hasOwnProp$w.call(b, prop))
1806
+ __defNormalProp$v(a, prop, b[prop]);
1807
+ if (__getOwnPropSymbols$w)
1808
+ for (var prop of __getOwnPropSymbols$w(b)) {
1809
+ if (__propIsEnum$w.call(b, prop))
1810
+ __defNormalProp$v(a, prop, b[prop]);
1772
1811
  }
1773
1812
  return a;
1774
1813
  };
1775
- var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
1814
+ var __spreadProps$m = (a, b) => __defProps$m(a, __getOwnPropDescs$m(b));
1776
1815
  const DialogButtonBar = ({
1777
1816
  children,
1778
1817
  className
1779
1818
  }) => {
1780
1819
  return /* @__PURE__ */ jsx(
1781
1820
  Box,
1782
- __spreadProps$l(__spreadValues$u({
1821
+ __spreadProps$m(__spreadValues$v({
1783
1822
  className: `${className != null ? className : ""} buttonsBar`
1784
1823
  }, getVariant("layout.common.modals.buttonsBar")), {
1785
1824
  children
@@ -1787,25 +1826,25 @@ const DialogButtonBar = ({
1787
1826
  );
1788
1827
  };
1789
1828
 
1790
- var __defProp$t = Object.defineProperty;
1791
- var __defProps$k = Object.defineProperties;
1792
- var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
1793
- var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1794
- var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1795
- var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1796
- var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1797
- var __spreadValues$t = (a, b) => {
1829
+ var __defProp$u = Object.defineProperty;
1830
+ var __defProps$l = Object.defineProperties;
1831
+ var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
1832
+ var __getOwnPropSymbols$v = Object.getOwnPropertySymbols;
1833
+ var __hasOwnProp$v = Object.prototype.hasOwnProperty;
1834
+ var __propIsEnum$v = Object.prototype.propertyIsEnumerable;
1835
+ var __defNormalProp$u = (obj, key, value) => key in obj ? __defProp$u(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1836
+ var __spreadValues$u = (a, b) => {
1798
1837
  for (var prop in b || (b = {}))
1799
- if (__hasOwnProp$u.call(b, prop))
1800
- __defNormalProp$t(a, prop, b[prop]);
1801
- if (__getOwnPropSymbols$u)
1802
- for (var prop of __getOwnPropSymbols$u(b)) {
1803
- if (__propIsEnum$u.call(b, prop))
1804
- __defNormalProp$t(a, prop, b[prop]);
1838
+ if (__hasOwnProp$v.call(b, prop))
1839
+ __defNormalProp$u(a, prop, b[prop]);
1840
+ if (__getOwnPropSymbols$v)
1841
+ for (var prop of __getOwnPropSymbols$v(b)) {
1842
+ if (__propIsEnum$v.call(b, prop))
1843
+ __defNormalProp$u(a, prop, b[prop]);
1805
1844
  }
1806
1845
  return a;
1807
1846
  };
1808
- var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
1847
+ var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
1809
1848
  const Confirm = ({
1810
1849
  children,
1811
1850
  additionalButtons,
@@ -1823,10 +1862,10 @@ const Confirm = ({
1823
1862
  onConfirm,
1824
1863
  variant
1825
1864
  }) => {
1826
- const { descriptionId } = useContext(ModalContext);
1865
+ const { descriptionId } = useModalContext();
1827
1866
  return /* @__PURE__ */ jsxs(
1828
1867
  Box,
1829
- __spreadProps$k(__spreadValues$t({}, getVariant(variant != null ? variant : "layout.common.modals.confirm")), {
1868
+ __spreadProps$l(__spreadValues$u({}, getVariant(variant != null ? variant : "layout.common.modals.confirm")), {
1830
1869
  className: `${className != null ? className : ""} confirm`,
1831
1870
  children: [
1832
1871
  /* @__PURE__ */ jsx(Box, { ref: contentRef, className: "confirm__content", id: descriptionId, children }),
@@ -1875,7 +1914,7 @@ const Confirm = ({
1875
1914
  ),
1876
1915
  onCancel && !hideCancelButton && /* @__PURE__ */ jsx(
1877
1916
  SimpleButton,
1878
- __spreadProps$k(__spreadValues$t({
1917
+ __spreadProps$l(__spreadValues$u({
1879
1918
  onClick: onCancel,
1880
1919
  title: cancelText
1881
1920
  }, getVariant("secondary")), {
@@ -1917,25 +1956,25 @@ const LinearLoader = () => {
1917
1956
  );
1918
1957
  };
1919
1958
 
1920
- var __defProp$s = Object.defineProperty;
1921
- var __defProps$j = Object.defineProperties;
1922
- var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
1923
- var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
1924
- var __hasOwnProp$t = Object.prototype.hasOwnProperty;
1925
- var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
1926
- var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1927
- var __spreadValues$s = (a, b) => {
1959
+ var __defProp$t = Object.defineProperty;
1960
+ var __defProps$k = Object.defineProperties;
1961
+ var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
1962
+ var __getOwnPropSymbols$u = Object.getOwnPropertySymbols;
1963
+ var __hasOwnProp$u = Object.prototype.hasOwnProperty;
1964
+ var __propIsEnum$u = Object.prototype.propertyIsEnumerable;
1965
+ var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1966
+ var __spreadValues$t = (a, b) => {
1928
1967
  for (var prop in b || (b = {}))
1929
- if (__hasOwnProp$t.call(b, prop))
1930
- __defNormalProp$s(a, prop, b[prop]);
1931
- if (__getOwnPropSymbols$t)
1932
- for (var prop of __getOwnPropSymbols$t(b)) {
1933
- if (__propIsEnum$t.call(b, prop))
1934
- __defNormalProp$s(a, prop, b[prop]);
1968
+ if (__hasOwnProp$u.call(b, prop))
1969
+ __defNormalProp$t(a, prop, b[prop]);
1970
+ if (__getOwnPropSymbols$u)
1971
+ for (var prop of __getOwnPropSymbols$u(b)) {
1972
+ if (__propIsEnum$u.call(b, prop))
1973
+ __defNormalProp$t(a, prop, b[prop]);
1935
1974
  }
1936
1975
  return a;
1937
1976
  };
1938
- var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
1977
+ var __spreadProps$k = (a, b) => __defProps$k(a, __getOwnPropDescs$k(b));
1939
1978
  const ScreenLock = () => {
1940
1979
  const ref = React__default.useRef(null);
1941
1980
  const [hasReleasedFirstTime, setHasReleasedFirstTime] = useState(false);
@@ -1948,11 +1987,11 @@ const ScreenLock = () => {
1948
1987
  React__default.useEffect(() => {
1949
1988
  const suscriptions = [
1950
1989
  screenLocker.on("lockStateChange", (ev) => {
1951
- setLocks((current) => __spreadProps$j(__spreadValues$s({}, current), { [ev.lockName]: ev.isLocked }));
1990
+ setLocks((current) => __spreadProps$k(__spreadValues$t({}, current), { [ev.lockName]: ev.isLocked }));
1952
1991
  setHasReleasedFirstTime(ev.hasReleasedFirstTime);
1953
1992
  }),
1954
1993
  screenLocker.on("forcedStateChange", (ev) => {
1955
- setLocks((current) => __spreadProps$j(__spreadValues$s({}, current), { forced: ev.isForced }));
1994
+ setLocks((current) => __spreadProps$k(__spreadValues$t({}, current), { forced: ev.isForced }));
1956
1995
  setHasReleasedFirstTime(ev.hasReleasedFirstTime);
1957
1996
  })
1958
1997
  ];
@@ -2015,33 +2054,33 @@ const FieldErrorMessage = ({ children, name }) => {
2015
2054
  return null;
2016
2055
  };
2017
2056
 
2018
- var __defProp$r = Object.defineProperty;
2019
- var __defProps$i = Object.defineProperties;
2020
- var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
2021
- var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2022
- var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2023
- var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2024
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2025
- var __spreadValues$r = (a, b) => {
2057
+ var __defProp$s = Object.defineProperty;
2058
+ var __defProps$j = Object.defineProperties;
2059
+ var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
2060
+ var __getOwnPropSymbols$t = Object.getOwnPropertySymbols;
2061
+ var __hasOwnProp$t = Object.prototype.hasOwnProperty;
2062
+ var __propIsEnum$t = Object.prototype.propertyIsEnumerable;
2063
+ var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2064
+ var __spreadValues$s = (a, b) => {
2026
2065
  for (var prop in b || (b = {}))
2027
- if (__hasOwnProp$s.call(b, prop))
2028
- __defNormalProp$r(a, prop, b[prop]);
2029
- if (__getOwnPropSymbols$s)
2030
- for (var prop of __getOwnPropSymbols$s(b)) {
2031
- if (__propIsEnum$s.call(b, prop))
2032
- __defNormalProp$r(a, prop, b[prop]);
2066
+ if (__hasOwnProp$t.call(b, prop))
2067
+ __defNormalProp$s(a, prop, b[prop]);
2068
+ if (__getOwnPropSymbols$t)
2069
+ for (var prop of __getOwnPropSymbols$t(b)) {
2070
+ if (__propIsEnum$t.call(b, prop))
2071
+ __defNormalProp$s(a, prop, b[prop]);
2033
2072
  }
2034
2073
  return a;
2035
2074
  };
2036
- var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
2075
+ var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
2037
2076
  var __objRest$9 = (source, exclude) => {
2038
2077
  var target = {};
2039
2078
  for (var prop in source)
2040
- if (__hasOwnProp$s.call(source, prop) && exclude.indexOf(prop) < 0)
2079
+ if (__hasOwnProp$t.call(source, prop) && exclude.indexOf(prop) < 0)
2041
2080
  target[prop] = source[prop];
2042
- if (source != null && __getOwnPropSymbols$s)
2043
- for (var prop of __getOwnPropSymbols$s(source)) {
2044
- if (exclude.indexOf(prop) < 0 && __propIsEnum$s.call(source, prop))
2081
+ if (source != null && __getOwnPropSymbols$t)
2082
+ for (var prop of __getOwnPropSymbols$t(source)) {
2083
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$t.call(source, prop))
2045
2084
  target[prop] = source[prop];
2046
2085
  }
2047
2086
  return target;
@@ -2098,25 +2137,25 @@ const IconInput = (_a) => {
2098
2137
  );
2099
2138
  return /* @__PURE__ */ jsxs(
2100
2139
  Box,
2101
- __spreadProps$i(__spreadValues$r({}, getVariant("forms.iconInput")), {
2140
+ __spreadProps$j(__spreadValues$s({}, getVariant("forms.iconInput")), {
2102
2141
  className: `${className != null ? className : ""} iconInput`,
2103
2142
  ref: parentRef,
2104
2143
  onBlur: handleBlur,
2105
2144
  children: [
2106
2145
  /* @__PURE__ */ jsx(
2107
2146
  Input,
2108
- __spreadValues$r(__spreadValues$r({
2147
+ __spreadValues$s(__spreadValues$s({
2109
2148
  disabled: isLoading != null ? isLoading : disabled,
2110
2149
  ref: assignInputRef,
2111
2150
  readOnly,
2112
- sx: __spreadValues$r({ variant: "forms.input" }, inputSx),
2151
+ sx: __spreadValues$s({ variant: "forms.input" }, inputSx),
2113
2152
  "data-variant": "forms.input"
2114
2153
  }, rest), actualInputProps)
2115
2154
  ),
2116
2155
  additionalButtonsPosition === "before" && additionalButtons,
2117
2156
  !hideButton && /* @__PURE__ */ jsx(
2118
2157
  IconButton,
2119
- __spreadValues$r({
2158
+ __spreadValues$s({
2120
2159
  onClick,
2121
2160
  icon,
2122
2161
  disabled: readOnly != null ? readOnly : disabled,
@@ -2145,33 +2184,33 @@ const getFieldTouchedStyles = (isTouched) => {
2145
2184
  };
2146
2185
  };
2147
2186
 
2148
- var __defProp$q = Object.defineProperty;
2149
- var __defProps$h = Object.defineProperties;
2150
- var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
2151
- var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2152
- var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2153
- var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2154
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2155
- var __spreadValues$q = (a, b) => {
2187
+ var __defProp$r = Object.defineProperty;
2188
+ var __defProps$i = Object.defineProperties;
2189
+ var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
2190
+ var __getOwnPropSymbols$s = Object.getOwnPropertySymbols;
2191
+ var __hasOwnProp$s = Object.prototype.hasOwnProperty;
2192
+ var __propIsEnum$s = Object.prototype.propertyIsEnumerable;
2193
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2194
+ var __spreadValues$r = (a, b) => {
2156
2195
  for (var prop in b || (b = {}))
2157
- if (__hasOwnProp$r.call(b, prop))
2158
- __defNormalProp$q(a, prop, b[prop]);
2159
- if (__getOwnPropSymbols$r)
2160
- for (var prop of __getOwnPropSymbols$r(b)) {
2161
- if (__propIsEnum$r.call(b, prop))
2162
- __defNormalProp$q(a, prop, b[prop]);
2196
+ if (__hasOwnProp$s.call(b, prop))
2197
+ __defNormalProp$r(a, prop, b[prop]);
2198
+ if (__getOwnPropSymbols$s)
2199
+ for (var prop of __getOwnPropSymbols$s(b)) {
2200
+ if (__propIsEnum$s.call(b, prop))
2201
+ __defNormalProp$r(a, prop, b[prop]);
2163
2202
  }
2164
2203
  return a;
2165
2204
  };
2166
- var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
2205
+ var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
2167
2206
  var __objRest$8 = (source, exclude) => {
2168
2207
  var target = {};
2169
2208
  for (var prop in source)
2170
- if (__hasOwnProp$r.call(source, prop) && exclude.indexOf(prop) < 0)
2209
+ if (__hasOwnProp$s.call(source, prop) && exclude.indexOf(prop) < 0)
2171
2210
  target[prop] = source[prop];
2172
- if (source != null && __getOwnPropSymbols$r)
2173
- for (var prop of __getOwnPropSymbols$r(source)) {
2174
- if (exclude.indexOf(prop) < 0 && __propIsEnum$r.call(source, prop))
2211
+ if (source != null && __getOwnPropSymbols$s)
2212
+ for (var prop of __getOwnPropSymbols$s(source)) {
2213
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$s.call(source, prop))
2175
2214
  target[prop] = source[prop];
2176
2215
  }
2177
2216
  return target;
@@ -2319,7 +2358,7 @@ const DateInput = React__default.forwardRef(
2319
2358
  [id, onBlur]
2320
2359
  );
2321
2360
  const inputProps = React__default.useMemo(
2322
- () => __spreadProps$h(__spreadValues$q({}, props), {
2361
+ () => __spreadProps$i(__spreadValues$r({}, props), {
2323
2362
  className: "dateInput",
2324
2363
  value: renderLabel ? renderLabel(inputValue) : inputValue,
2325
2364
  ref,
@@ -2351,7 +2390,7 @@ const DateInput = React__default.forwardRef(
2351
2390
  const buttonProps = React__default.useMemo(
2352
2391
  () => {
2353
2392
  var _a3;
2354
- return __spreadValues$q({
2393
+ return __spreadValues$r({
2355
2394
  disabled: (_a3 = props.disabled) != null ? _a3 : props.readOnly,
2356
2395
  "aria-label": window.LBL_PICK_DATE
2357
2396
  }, outerButtonProps);
@@ -2379,7 +2418,7 @@ const DateInput = React__default.forwardRef(
2379
2418
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2380
2419
  /* @__PURE__ */ jsx(
2381
2420
  CalendarModal,
2382
- __spreadProps$h(__spreadValues$q({}, modalProps), {
2421
+ __spreadProps$i(__spreadValues$r({}, modalProps), {
2383
2422
  calValue,
2384
2423
  locale: DEFAULT_LOCALE,
2385
2424
  handleClickDay: selectDate,
@@ -2389,7 +2428,7 @@ const DateInput = React__default.forwardRef(
2389
2428
  ),
2390
2429
  /* @__PURE__ */ jsxs(
2391
2430
  Box,
2392
- __spreadProps$h(__spreadValues$q({}, getVariant("forms.dateInput")), {
2431
+ __spreadProps$i(__spreadValues$r({}, getVariant("forms.dateInput")), {
2393
2432
  className: `${className != null ? className : ""} dateInput`,
2394
2433
  id: `DateInput${id}`,
2395
2434
  ref: boxRef,
@@ -2422,33 +2461,33 @@ const DateInput = React__default.forwardRef(
2422
2461
  );
2423
2462
  DateInput.displayName = "DateInput";
2424
2463
 
2425
- var __defProp$p = Object.defineProperty;
2426
- var __defProps$g = Object.defineProperties;
2427
- var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
2428
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2429
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2430
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2431
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2432
- var __spreadValues$p = (a, b) => {
2464
+ var __defProp$q = Object.defineProperty;
2465
+ var __defProps$h = Object.defineProperties;
2466
+ var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
2467
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
2468
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
2469
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
2470
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2471
+ var __spreadValues$q = (a, b) => {
2433
2472
  for (var prop in b || (b = {}))
2434
- if (__hasOwnProp$q.call(b, prop))
2435
- __defNormalProp$p(a, prop, b[prop]);
2436
- if (__getOwnPropSymbols$q)
2437
- for (var prop of __getOwnPropSymbols$q(b)) {
2438
- if (__propIsEnum$q.call(b, prop))
2439
- __defNormalProp$p(a, prop, b[prop]);
2473
+ if (__hasOwnProp$r.call(b, prop))
2474
+ __defNormalProp$q(a, prop, b[prop]);
2475
+ if (__getOwnPropSymbols$r)
2476
+ for (var prop of __getOwnPropSymbols$r(b)) {
2477
+ if (__propIsEnum$r.call(b, prop))
2478
+ __defNormalProp$q(a, prop, b[prop]);
2440
2479
  }
2441
2480
  return a;
2442
2481
  };
2443
- var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
2482
+ var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
2444
2483
  var __objRest$7 = (source, exclude) => {
2445
2484
  var target = {};
2446
2485
  for (var prop in source)
2447
- if (__hasOwnProp$q.call(source, prop) && exclude.indexOf(prop) < 0)
2486
+ if (__hasOwnProp$r.call(source, prop) && exclude.indexOf(prop) < 0)
2448
2487
  target[prop] = source[prop];
2449
- if (source != null && __getOwnPropSymbols$q)
2450
- for (var prop of __getOwnPropSymbols$q(source)) {
2451
- if (exclude.indexOf(prop) < 0 && __propIsEnum$q.call(source, prop))
2488
+ if (source != null && __getOwnPropSymbols$r)
2489
+ for (var prop of __getOwnPropSymbols$r(source)) {
2490
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$r.call(source, prop))
2452
2491
  target[prop] = source[prop];
2453
2492
  }
2454
2493
  return target;
@@ -2568,7 +2607,7 @@ const NumberInput = React__default.forwardRef(
2568
2607
  }, [value]);
2569
2608
  return /* @__PURE__ */ jsx(
2570
2609
  Input,
2571
- __spreadProps$g(__spreadValues$p({}, props), {
2610
+ __spreadProps$h(__spreadValues$q({}, props), {
2572
2611
  onFocus: React__default.useCallback(
2573
2612
  (ev) => {
2574
2613
  var _a2;
@@ -2608,33 +2647,33 @@ const RequiredMark = ({
2608
2647
  return isRequired && !isReadonly && !isFormReadonly ? /* @__PURE__ */ jsx("abbr", { className: "requiredMark", title: getLabel("msgReqField").text, children: "*" }) : null;
2609
2648
  };
2610
2649
 
2611
- var __defProp$o = Object.defineProperty;
2612
- var __defProps$f = Object.defineProperties;
2613
- var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
2614
- var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
2615
- var __hasOwnProp$p = Object.prototype.hasOwnProperty;
2616
- var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
2617
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2618
- var __spreadValues$o = (a, b) => {
2650
+ var __defProp$p = Object.defineProperty;
2651
+ var __defProps$g = Object.defineProperties;
2652
+ var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
2653
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
2654
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
2655
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
2656
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2657
+ var __spreadValues$p = (a, b) => {
2619
2658
  for (var prop in b || (b = {}))
2620
- if (__hasOwnProp$p.call(b, prop))
2621
- __defNormalProp$o(a, prop, b[prop]);
2622
- if (__getOwnPropSymbols$p)
2623
- for (var prop of __getOwnPropSymbols$p(b)) {
2624
- if (__propIsEnum$p.call(b, prop))
2625
- __defNormalProp$o(a, prop, b[prop]);
2659
+ if (__hasOwnProp$q.call(b, prop))
2660
+ __defNormalProp$p(a, prop, b[prop]);
2661
+ if (__getOwnPropSymbols$q)
2662
+ for (var prop of __getOwnPropSymbols$q(b)) {
2663
+ if (__propIsEnum$q.call(b, prop))
2664
+ __defNormalProp$p(a, prop, b[prop]);
2626
2665
  }
2627
2666
  return a;
2628
2667
  };
2629
- var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
2668
+ var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
2630
2669
  var __objRest$6 = (source, exclude) => {
2631
2670
  var target = {};
2632
2671
  for (var prop in source)
2633
- if (__hasOwnProp$p.call(source, prop) && exclude.indexOf(prop) < 0)
2672
+ if (__hasOwnProp$q.call(source, prop) && exclude.indexOf(prop) < 0)
2634
2673
  target[prop] = source[prop];
2635
- if (source != null && __getOwnPropSymbols$p)
2636
- for (var prop of __getOwnPropSymbols$p(source)) {
2637
- if (exclude.indexOf(prop) < 0 && __propIsEnum$p.call(source, prop))
2674
+ if (source != null && __getOwnPropSymbols$q)
2675
+ for (var prop of __getOwnPropSymbols$q(source)) {
2676
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$q.call(source, prop))
2638
2677
  target[prop] = source[prop];
2639
2678
  }
2640
2679
  return target;
@@ -2671,7 +2710,7 @@ const FieldLabel = forwardRef(
2671
2710
  var _a2, _b2;
2672
2711
  return /* @__PURE__ */ jsxs(
2673
2712
  Box,
2674
- __spreadProps$f(__spreadValues$o(__spreadProps$f(__spreadValues$o({
2713
+ __spreadProps$g(__spreadValues$p(__spreadProps$g(__spreadValues$p({
2675
2714
  as: as != null ? as : "label"
2676
2715
  }, props), {
2677
2716
  className: `fieldLabel ${(_a2 = props.className) != null ? _a2 : ""}`
@@ -2818,7 +2857,7 @@ const AutoEllipsis = ({
2818
2857
  const cloneBounding = clone.current.getBoundingClientRect();
2819
2858
  const difX = Math.abs(cloneBounding.width - bound.width);
2820
2859
  const difY = Math.abs(cloneBounding.height - bound.height);
2821
- if (difX < 10 && difY < 10) {
2860
+ if (difX < 50 && difY < 30) {
2822
2861
  clone.current.remove();
2823
2862
  }
2824
2863
  }
@@ -2861,25 +2900,25 @@ const AutoEllipsis = ({
2861
2900
  );
2862
2901
  };
2863
2902
 
2864
- var __defProp$n = Object.defineProperty;
2865
- var __defProps$e = Object.defineProperties;
2866
- var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2867
- var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
2868
- var __hasOwnProp$o = Object.prototype.hasOwnProperty;
2869
- var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
2870
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2871
- var __spreadValues$n = (a, b) => {
2903
+ var __defProp$o = Object.defineProperty;
2904
+ var __defProps$f = Object.defineProperties;
2905
+ var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
2906
+ var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
2907
+ var __hasOwnProp$p = Object.prototype.hasOwnProperty;
2908
+ var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
2909
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2910
+ var __spreadValues$o = (a, b) => {
2872
2911
  for (var prop in b || (b = {}))
2873
- if (__hasOwnProp$o.call(b, prop))
2874
- __defNormalProp$n(a, prop, b[prop]);
2875
- if (__getOwnPropSymbols$o)
2876
- for (var prop of __getOwnPropSymbols$o(b)) {
2877
- if (__propIsEnum$o.call(b, prop))
2878
- __defNormalProp$n(a, prop, b[prop]);
2912
+ if (__hasOwnProp$p.call(b, prop))
2913
+ __defNormalProp$o(a, prop, b[prop]);
2914
+ if (__getOwnPropSymbols$p)
2915
+ for (var prop of __getOwnPropSymbols$p(b)) {
2916
+ if (__propIsEnum$p.call(b, prop))
2917
+ __defNormalProp$o(a, prop, b[prop]);
2879
2918
  }
2880
2919
  return a;
2881
2920
  };
2882
- var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2921
+ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
2883
2922
  function calcBreakPoint(currentWidth, breakPoints) {
2884
2923
  let currentIndex = 0;
2885
2924
  while (currentIndex < breakPoints.length && currentWidth > breakPoints[currentIndex])
@@ -2953,7 +2992,7 @@ const makeResponsiveComponent = ({
2953
2992
  const deferContainerWidth = useDeferredValue(containerWidth);
2954
2993
  return /* @__PURE__ */ jsx(Box, { ref, children: hasRendered ? /* @__PURE__ */ jsx(
2955
2994
  Component,
2956
- __spreadProps$e(__spreadValues$n({}, props), {
2995
+ __spreadProps$f(__spreadValues$o({}, props), {
2957
2996
  breakPoint: deferBreakPoint,
2958
2997
  breakPointWidth: breakPoints[deferBreakPoint],
2959
2998
  containerWidth: deferContainerWidth
@@ -2964,22 +3003,61 @@ const makeResponsiveComponent = ({
2964
3003
  );
2965
3004
  };
2966
3005
 
3006
+ var __defProp$n = Object.defineProperty;
3007
+ var __defProps$e = Object.defineProperties;
3008
+ var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
3009
+ var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
3010
+ var __hasOwnProp$o = Object.prototype.hasOwnProperty;
3011
+ var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
3012
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3013
+ var __spreadValues$n = (a, b) => {
3014
+ for (var prop in b || (b = {}))
3015
+ if (__hasOwnProp$o.call(b, prop))
3016
+ __defNormalProp$n(a, prop, b[prop]);
3017
+ if (__getOwnPropSymbols$o)
3018
+ for (var prop of __getOwnPropSymbols$o(b)) {
3019
+ if (__propIsEnum$o.call(b, prop))
3020
+ __defNormalProp$n(a, prop, b[prop]);
3021
+ }
3022
+ return a;
3023
+ };
3024
+ var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2967
3025
  const DefaultAccordionItemButton = (props) => {
2968
- var _a, _b, _c;
3026
+ var _a, _b, _c, _d, _e, _f;
2969
3027
  const handler = useAccordionContext();
2970
3028
  const { isExpanded } = handler.hooks.useItemStateSelector((props2) => props2);
2971
3029
  const id = handler.hooks.useItemId();
2972
3030
  const [isChecked, setIsChecked] = useIsChecked(props);
2973
- const handleClick = useCallback(() => {
2974
- handler.udpateItem(id, (current) => ({
2975
- isExpanded: !current.isExpanded
2976
- }));
2977
- }, [handler, id]);
3031
+ const handleClick = useCallback(
3032
+ (ev) => {
3033
+ var _a2;
3034
+ (_a2 = props.onClick) == null ? void 0 : _a2.call(props, ev);
3035
+ if (!ev.isDefaultPrevented())
3036
+ handler.udpateItem(id, (current) => ({
3037
+ isExpanded: !current.isExpanded
3038
+ }));
3039
+ },
3040
+ [handler, id, props]
3041
+ );
3042
+ const handleKeyDown = useCallback(
3043
+ (ev) => {
3044
+ var _a2;
3045
+ if (ev.code === "Enter") {
3046
+ (_a2 = props.onUserPressEnter) == null ? void 0 : _a2.call(props, ev);
3047
+ if (!ev.isDefaultPrevented() && props.rightButtons)
3048
+ handler.udpateItem(id, (current) => ({
3049
+ isExpanded: !current.isExpanded
3050
+ }));
3051
+ }
3052
+ },
3053
+ [handler, id, props]
3054
+ );
2978
3055
  return /* @__PURE__ */ jsxs(
2979
3056
  SimpleButton,
2980
- {
2981
- className: "accordion__item__button",
3057
+ __spreadProps$e(__spreadValues$n({}, props.domButtonProps), {
3058
+ className: `accordion__item__button ${(_a = props.className) != null ? _a : ""} ${(_c = (_b = props.domButtonProps) == null ? void 0 : _b.className) != null ? _c : ""}`,
2982
3059
  onClick: handleClick,
3060
+ onKeyDown: handleKeyDown,
2983
3061
  "aria-expanded": isExpanded,
2984
3062
  "aria-controls": `accordion__${handler.id}__${id}`,
2985
3063
  "aria-checked": isChecked,
@@ -2996,18 +3074,21 @@ const DefaultAccordionItemButton = (props) => {
2996
3074
  onChange: setIsChecked
2997
3075
  }
2998
3076
  ),
2999
- /* @__PURE__ */ jsx(Box, { as: "h3", className: "accordion__item__button__label", children: /* @__PURE__ */ jsx(AutoEllipsis, { overrideStyles: () => ({ textAlign: "left" }), children: (_b = (_a = props.label) != null ? _a : props.title) != null ? _b : props.ariaLabel }) })
3077
+ /* @__PURE__ */ jsx(Box, { as: "h3", className: "accordion__item__button__label", children: /* @__PURE__ */ jsx(AutoEllipsis, { overrideStyles: () => ({ textAlign: "left" }), children: (_e = (_d = props.label) != null ? _d : props.title) != null ? _e : props.ariaLabel }) })
3000
3078
  ] }),
3001
- /* @__PURE__ */ jsx(Box, { className: "accordion__item__button__rightGroup", children: /* @__PURE__ */ jsx(
3002
- Icon$1,
3003
- {
3004
- name: isExpanded ? "ArrowUpThin" : "ArrowDownThin",
3005
- title: (_c = props.title) != null ? _c : props.ariaLabel,
3006
- size: 23
3007
- }
3008
- ) })
3079
+ /* @__PURE__ */ jsxs(Box, { className: "accordion__item__button__rightGroup", children: [
3080
+ props.rightButtons,
3081
+ /* @__PURE__ */ jsx(
3082
+ Icon$1,
3083
+ {
3084
+ name: isExpanded ? "ArrowUpThin" : "ArrowDownThin",
3085
+ title: (_f = props.title) != null ? _f : props.ariaLabel,
3086
+ size: 23
3087
+ }
3088
+ )
3089
+ ] })
3009
3090
  ]
3010
- }
3091
+ })
3011
3092
  );
3012
3093
  };
3013
3094
 
@@ -4201,6 +4282,11 @@ const moveFocusAndToggleSelection = makeOperation((state, { isShiftKey, which },
4201
4282
  }
4202
4283
  state.isEverythingSelected = false;
4203
4284
  });
4285
+ const resetFocus = makeOperation((state, _, keys) => {
4286
+ keys.push(makeRowKey(state.focusedRow));
4287
+ state.focusedRow = 0;
4288
+ keys.push(makeRowKey(0));
4289
+ });
4204
4290
  const searchElementsByStartingCharacters = makeOperation((state, payload, keys) => {
4205
4291
  const currentIndex = state.shownRows.findIndex(
4206
4292
  (current) => current === state.focusedRow
@@ -4347,6 +4433,7 @@ const operations$1 = {
4347
4433
  * acuerdo a las especificaciones de wai-aria.
4348
4434
  */
4349
4435
  moveFocusAndToggleSelection,
4436
+ resetFocus,
4350
4437
  /**
4351
4438
  * Este método debe utilizarse para la búsqueda por caracter simple o
4352
4439
  * múltiple en cuanto a la implementación de las funcionalidades
@@ -4429,9 +4516,10 @@ function useShoutSelectionChange(onSelectionChange, registerCallback) {
4429
4516
  );
4430
4517
  }
4431
4518
 
4432
- function useIndexedChildren(children) {
4519
+ function useIndexedChildren(children, listboxActions) {
4433
4520
  return useMemo(
4434
4521
  function makeChildrenIndices() {
4522
+ listboxActions.resetFocus(null);
4435
4523
  return Children.map(children, (child, rowIndex) => {
4436
4524
  if (isValidElement(child) && child.type === ListboxItem) {
4437
4525
  return cloneElement(
@@ -4444,7 +4532,7 @@ function useIndexedChildren(children) {
4444
4532
  return child;
4445
4533
  });
4446
4534
  },
4447
- [children]
4535
+ [children, listboxActions]
4448
4536
  );
4449
4537
  }
4450
4538
 
@@ -4541,7 +4629,7 @@ const NoMemoListbox = makeStyledComponent(
4541
4629
  );
4542
4630
  useShoutSelectionChange(props.onSelectionChange, registerCallback);
4543
4631
  useUpdateRowCount(props.children, listboxActions);
4544
- const indexedChildren = useIndexedChildren(props.children);
4632
+ const indexedChildren = useIndexedChildren(props.children, listboxActions);
4545
4633
  const { onClick, onFocus } = useListboxAutofocus(storeId, getState);
4546
4634
  const ref = useListbox("listbox", null);
4547
4635
  const variant = props.unstyled ? "" : "layout.components.listbox";
@@ -4917,413 +5005,12 @@ const useStore = ({
4917
5005
  ];
4918
5006
  };
4919
5007
 
4920
- function isAttachToElementAFunction(attachToElement) {
4921
- return attachToElement instanceof Function && getParamNames(attachToElement).length === 0;
4922
- }
4923
-
4924
- const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
4925
- const ARGUMENT_NAMES = /([^\s,]+)/g;
4926
- function getParamNames(func) {
4927
- const fnStr = func.toString().replace(STRIP_COMMENTS, "");
4928
- let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
4929
- if (result === null)
4930
- result = [];
4931
- return result;
4932
- }
4933
- function determineAnchorPoint({
4934
- attachToElement,
4935
- attachToElementAnchorPoint
4936
- }) {
4937
- let actualAnchorPoint = { left: 0, top: 0 };
4938
- const element = isAttachToElementAFunction(attachToElement) ? attachToElement() : attachToElement.current;
4939
- if (element) {
4940
- const rect = element.getBoundingClientRect();
4941
- const point = attachToElementAnchorPoint != null ? attachToElementAnchorPoint : "topRight";
4942
- switch (point) {
4943
- case "bottomLeft":
4944
- actualAnchorPoint = {
4945
- left: rect.left,
4946
- top: rect.bottom
4947
- };
4948
- break;
4949
- case "bottomRight":
4950
- actualAnchorPoint = {
4951
- left: rect.right,
4952
- top: rect.bottom
4953
- };
4954
- break;
4955
- case "center":
4956
- actualAnchorPoint = {
4957
- left: (rect.left + rect.right) / 2,
4958
- top: (rect.bottom + rect.top) / 2
4959
- };
4960
- break;
4961
- case "topLeft":
4962
- actualAnchorPoint = {
4963
- left: rect.left,
4964
- top: rect.top
4965
- };
4966
- break;
4967
- case "topRight":
4968
- actualAnchorPoint = {
4969
- left: rect.right,
4970
- top: rect.top
4971
- };
4972
- break;
4973
- }
4974
- } else {
4975
- console.warn(
4976
- "Cannot resolve element, will use default positioning ",
4977
- attachToElement
4978
- );
4979
- }
4980
- return actualAnchorPoint;
4981
- }
4982
- function calculateTooltipPosition({
4983
- anchorPoint,
4984
- attachToElement,
4985
- attachToElementAnchorPoint,
4986
- minSize,
4987
- preferredOrientationX,
4988
- preferredOrientationY,
4989
- preferredSize = { height: "auto", width: "auto" }
4990
- }) {
4991
- var _a, _b, _c, _d, _e, _f, _g, _h;
4992
- let actualAnchorPoint = anchorPoint;
4993
- if (attachToElement) {
4994
- actualAnchorPoint = determineAnchorPoint({
4995
- attachToElement,
4996
- attachToElementAnchorPoint
4997
- });
4998
- }
4999
- if (actualAnchorPoint) {
5000
- const availableBottomSpace = window.innerHeight - actualAnchorPoint.top;
5001
- const availableTopSpace = actualAnchorPoint.top;
5002
- const availableLeftSpace = actualAnchorPoint.left;
5003
- const availableRightSpace = window.innerWidth - actualAnchorPoint.left;
5004
- const isEnoughToRight = ((_a = minSize == null ? void 0 : minSize.width) != null ? _a : 0) <= availableRightSpace;
5005
- const isEnoughToLeft = ((_b = minSize == null ? void 0 : minSize.width) != null ? _b : 0) <= availableLeftSpace;
5006
- const isEnoughToBottom = ((_c = minSize == null ? void 0 : minSize.height) != null ? _c : 0) <= availableBottomSpace;
5007
- const isEnoughToTop = ((_d = minSize == null ? void 0 : minSize.height) != null ? _d : 0) <= availableTopSpace;
5008
- const preferredWidth = preferredSize.width === "auto" ? Infinity : preferredSize.width;
5009
- const preferredHeight = preferredSize.height === "auto" ? Infinity : preferredSize.height;
5010
- const position = {
5011
- "& > *": {
5012
- width: "100%",
5013
- height: "100%"
5014
- },
5015
- width: preferredSize.width === "auto" ? "auto" : "100%",
5016
- height: preferredSize.height === "auto" ? "auto" : "100%"
5017
- };
5018
- if (preferredOrientationX === "left") {
5019
- if (isEnoughToLeft) {
5020
- position.maxWidth = Math.min(preferredWidth, availableLeftSpace);
5021
- position.right = window.innerWidth - actualAnchorPoint.left;
5022
- } else if (isEnoughToRight) {
5023
- position.maxWidth = Math.min(preferredWidth, availableRightSpace);
5024
- position.left = actualAnchorPoint.left;
5025
- } else {
5026
- position.left = 0;
5027
- position.maxWidth = "100vw";
5028
- }
5029
- } else {
5030
- if (isEnoughToRight) {
5031
- position.maxWidth = Math.min(preferredWidth, availableRightSpace);
5032
- position.left = actualAnchorPoint.left;
5033
- } else if (isEnoughToLeft) {
5034
- position.maxWidth = Math.min(preferredWidth, availableLeftSpace);
5035
- position.right = window.innerWidth - actualAnchorPoint.left;
5036
- } else {
5037
- position.left = 0;
5038
- position.maxWidth = "100vw";
5039
- }
5040
- }
5041
- if (preferredOrientationY === "top") {
5042
- if (isEnoughToTop) {
5043
- position.maxHeight = Math.min(preferredHeight, availableTopSpace);
5044
- position.bottom = window.innerHeight - actualAnchorPoint.top;
5045
- } else if (isEnoughToBottom) {
5046
- position.maxHeight = Math.min(preferredHeight, availableBottomSpace);
5047
- position.top = actualAnchorPoint.top;
5048
- } else {
5049
- position.maxHeight = "100vh";
5050
- position.top = 0;
5051
- }
5052
- } else {
5053
- if (isEnoughToBottom) {
5054
- position.maxHeight = Math.min(preferredHeight, availableBottomSpace);
5055
- position.top = actualAnchorPoint.top;
5056
- } else if (isEnoughToTop) {
5057
- position.maxHeight = Math.min(preferredHeight, availableTopSpace);
5058
- position.bottom = window.innerHeight - actualAnchorPoint.top;
5059
- } else {
5060
- position.maxHeight = "100vh";
5061
- position.top = 0;
5062
- }
5063
- }
5064
- position.minHeight = typeof position.maxHeight === "number" ? Math.min(position.maxHeight, (_e = minSize == null ? void 0 : minSize.height) != null ? _e : 0) : (_f = minSize == null ? void 0 : minSize.height) != null ? _f : 0;
5065
- position.minWidth = typeof position.minWidth === "number" ? Math.min(position.minWidth, (_g = minSize == null ? void 0 : minSize.width) != null ? _g : 0) : (_h = minSize == null ? void 0 : minSize.width) != null ? _h : 0;
5066
- return position;
5067
- }
5068
- return { left: 0, top: 0, width: "auto", height: "auto" };
5069
- }
5070
- function useHandlers({
5071
- attachToElement,
5072
- closeOnClick,
5073
- closeOnClickOut,
5074
- closeOnEscape,
5075
- closeOnMouseLeaveTooltip,
5076
- closeOnMouseLeaveAttachedElement,
5077
- closeOnScrollOut
5078
- }) {
5079
- const hasInited = useRef(false);
5080
- const close = useCallback(() => {
5081
- tooltipsHandler("close", void 0);
5082
- }, []);
5083
- useMount(() => {
5084
- function handleEscape(ev) {
5085
- if (ev.code === "Escape" && closeOnEscape) {
5086
- close();
5087
- }
5088
- }
5089
- function handleMouseDownOut(ev) {
5090
- if (!hasInited.current)
5091
- return;
5092
- if (closeOnClickOut && !isChild(
5093
- ev.target,
5094
- (current) => {
5095
- var _a;
5096
- return (_a = current.classList) == null ? void 0 : _a.contains("tooltip__wrapper");
5097
- }
5098
- )) {
5099
- close();
5100
- }
5101
- }
5102
- function handleScroll(ev) {
5103
- if (!hasInited.current)
5104
- return;
5105
- if (closeOnScrollOut && !isChild(
5106
- ev.target,
5107
- (current) => {
5108
- var _a;
5109
- return (_a = current.classList) == null ? void 0 : _a.contains("tooltip__wrapper");
5110
- }
5111
- )) {
5112
- close();
5113
- }
5114
- }
5115
- function handleMouseLeave(event) {
5116
- if (!hasInited.current || !closeOnMouseLeaveAttachedElement && !closeOnMouseLeaveTooltip)
5117
- return;
5118
- const resolvedAttachToElement = attachToElement ? isAttachToElementAFunction(attachToElement) ? attachToElement() : attachToElement.current : null;
5119
- const isTooltipTheTarget = isChild(
5120
- event.target,
5121
- (current) => current.classList.contains("tooltip__wrapper")
5122
- );
5123
- const isAttachedTheTarget = isChild(
5124
- event.target,
5125
- (current) => current === resolvedAttachToElement
5126
- );
5127
- const isTooltipRelated = isChild(
5128
- event.relatedTarget,
5129
- (current) => current.classList.contains("tooltip__wrapper")
5130
- );
5131
- const isAttachedRelated = isChild(
5132
- event.relatedTarget,
5133
- (current) => current === resolvedAttachToElement
5134
- );
5135
- if (!isTooltipTheTarget && !isAttachedTheTarget && !closeOnMouseLeaveAttachedElement && !closeOnMouseLeaveTooltip)
5136
- return;
5137
- if (isTooltipRelated || isAttachedRelated)
5138
- return;
5139
- if (isAttachedTheTarget && !closeOnMouseLeaveAttachedElement)
5140
- return;
5141
- if (isTooltipTheTarget && !closeOnMouseLeaveTooltip)
5142
- return;
5143
- close();
5144
- }
5145
- document.addEventListener("keydown", handleEscape);
5146
- document.addEventListener("mousedown", handleMouseDownOut);
5147
- document.addEventListener("scroll", handleScroll);
5148
- document.addEventListener("mouseout", handleMouseLeave);
5149
- setTimeout(() => {
5150
- hasInited.current = true;
5151
- }, 0);
5152
- return () => {
5153
- document.removeEventListener("keydown", handleEscape);
5154
- document.removeEventListener("click", handleMouseDownOut);
5155
- document.removeEventListener("scroll", handleScroll);
5156
- document.removeEventListener("mouseout", handleMouseLeave);
5157
- };
5158
- });
5159
- return {
5160
- handleOnClick: useCallback(
5161
- (ev) => {
5162
- ev.stopPropagation();
5163
- if (closeOnClick) {
5164
- close();
5165
- }
5166
- },
5167
- [close, closeOnClick]
5168
- )
5169
- };
5170
- }
5171
-
5172
- var __defProp$8 = Object.defineProperty;
5173
- var __defProps$1 = Object.defineProperties;
5174
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
5175
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
5176
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
5177
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
5178
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5179
- var __spreadValues$8 = (a, b) => {
5180
- for (var prop in b || (b = {}))
5181
- if (__hasOwnProp$8.call(b, prop))
5182
- __defNormalProp$8(a, prop, b[prop]);
5183
- if (__getOwnPropSymbols$8)
5184
- for (var prop of __getOwnPropSymbols$8(b)) {
5185
- if (__propIsEnum$8.call(b, prop))
5186
- __defNormalProp$8(a, prop, b[prop]);
5187
- }
5188
- return a;
5189
- };
5190
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
5191
- const Tooltip = ({
5192
- anchorPoint,
5193
- attachToElement,
5194
- attachToElementAnchorPoint,
5195
- children,
5196
- className,
5197
- closeOnClick = false,
5198
- closeOnClickOut = true,
5199
- closeOnEscape = true,
5200
- closeOnMouseLeaveTooltip = true,
5201
- closeOnMouseLeaveAttachedElement = true,
5202
- closeOnScrollOut = true,
5203
- minSize,
5204
- preferredOrientationX = "right",
5205
- preferredOrientationY = "bottom",
5206
- preferredSize = { height: "auto", width: "auto" },
5207
- variant = "layout.common.tooltips.primary"
5208
- }) => {
5209
- const calculatedPosition = calculateTooltipPosition({
5210
- anchorPoint,
5211
- attachToElement,
5212
- attachToElementAnchorPoint,
5213
- minSize,
5214
- preferredOrientationX,
5215
- preferredOrientationY,
5216
- preferredSize
5217
- });
5218
- const sx = __spreadValues$8({
5219
- position: "fixed"
5220
- }, calculatedPosition);
5221
- const { handleOnClick } = useHandlers({
5222
- attachToElement,
5223
- closeOnEscape,
5224
- closeOnClickOut,
5225
- closeOnClick,
5226
- closeOnMouseLeaveTooltip,
5227
- closeOnMouseLeaveAttachedElement,
5228
- closeOnScrollOut
5229
- });
5230
- return /* @__PURE__ */ jsx(
5231
- Box,
5232
- __spreadProps$1(__spreadValues$8({
5233
- className: `tooltip__wrapper ${className != null ? className : ""}`
5234
- }, getVariant(variant)), {
5235
- sx,
5236
- onClick: handleOnClick,
5237
- children
5238
- })
5239
- );
5240
- };
5241
-
5242
- var __defProp$7 = Object.defineProperty;
5243
- var __defProps = Object.defineProperties;
5244
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5245
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
5246
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
5247
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
5248
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5249
- var __spreadValues$7 = (a, b) => {
5250
- for (var prop in b || (b = {}))
5251
- if (__hasOwnProp$7.call(b, prop))
5252
- __defNormalProp$7(a, prop, b[prop]);
5253
- if (__getOwnPropSymbols$7)
5254
- for (var prop of __getOwnPropSymbols$7(b)) {
5255
- if (__propIsEnum$7.call(b, prop))
5256
- __defNormalProp$7(a, prop, b[prop]);
5257
- }
5258
- return a;
5259
- };
5260
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5261
- injectStyles("layout.common.tooltips.primary", {
5262
- background: "white",
5263
- border: "1px solid #ccc",
5264
- p: 3,
5265
- zIndex: "tooltip"
5266
- });
5267
- const [, tooltipsHandler, TooltipsProvider] = makeSingleImperativeComponent()({
5268
- Component: () => {
5269
- const [tooltip, setTooltip] = useState(null);
5270
- const tooltipRef = useLatest(tooltip);
5271
- useImperativeComponentEvents({
5272
- open: setTooltip,
5273
- close() {
5274
- var _a, _b;
5275
- (_b = (_a = tooltipRef.current) == null ? void 0 : _a.onClose) == null ? void 0 : _b.call(_a);
5276
- setTooltip(null);
5277
- }
5278
- });
5279
- if (!tooltip)
5280
- return null;
5281
- return /* @__PURE__ */ jsx(Tooltip, __spreadValues$7({}, tooltip));
5282
- }
5283
- });
5284
- function useTooltip(tooltip) {
5285
- const isOpen = useRef(false);
5286
- const open = useCallback(
5287
- (otherProps) => {
5288
- setTimeout(() => {
5289
- isOpen.current = true;
5290
- if (!tooltip && !(otherProps == null ? void 0 : otherProps.children))
5291
- throw new Error("There is no children set for the current tooltip");
5292
- tooltipsHandler("open", __spreadProps(__spreadValues$7(__spreadValues$7({}, tooltip), otherProps), {
5293
- onClose() {
5294
- var _a, _b;
5295
- (_a = tooltip == null ? void 0 : tooltip.onClose) == null ? void 0 : _a.call(tooltip);
5296
- (_b = otherProps == null ? void 0 : otherProps.onClose) == null ? void 0 : _b.call(otherProps);
5297
- isOpen.current = false;
5298
- }
5299
- }));
5300
- }, 0);
5301
- },
5302
- [tooltip]
5303
- );
5304
- return {
5305
- close: useCallback(() => {
5306
- tooltipsHandler("close", void 0);
5307
- }, []),
5308
- open,
5309
- toggle: useCallback(
5310
- (otherProps) => {
5311
- if (isOpen.current) {
5312
- tooltipsHandler("close", void 0);
5313
- } else
5314
- open(otherProps);
5315
- },
5316
- [open]
5317
- )
5318
- };
5319
- }
5320
-
5321
- function findIcon(icons, arg) {
5322
- var _a, _b;
5323
- const iconId = arg instanceof HTMLElement ? (_b = (_a = arg.closest(".iconsList__iconWrapper[data-id]")) == null ? void 0 : _a.dataset) == null ? void 0 : _b.id : arg;
5324
- if (iconId !== void 0) {
5325
- const icon = icons.find((current) => String(current.id) === iconId);
5326
- return icon != null ? icon : null;
5008
+ function findIcon(icons, arg) {
5009
+ var _a, _b;
5010
+ const iconId = arg instanceof HTMLElement ? (_b = (_a = arg.closest(".iconsList__iconWrapper[data-id]")) == null ? void 0 : _a.dataset) == null ? void 0 : _b.id : arg;
5011
+ if (iconId !== void 0) {
5012
+ const icon = icons.find((current) => String(current.id) === iconId);
5013
+ return icon != null ? icon : null;
5327
5014
  }
5328
5015
  }
5329
5016
  const KeyHandler = ({
@@ -5337,22 +5024,20 @@ const KeyHandler = ({
5337
5024
  }) => {
5338
5025
  const { actions, getState, useProps } = useIconsListStoreContext();
5339
5026
  const ref = useProps("grid", null);
5340
- const { open } = useTooltip({
5341
- minSize: { width: 200, height: 0 }
5342
- });
5343
5027
  const showIconDetails = useCallback(
5344
5028
  (icon) => {
5345
5029
  if (onIconGetDetails) {
5346
- open({
5347
- children: onIconGetDetails(icon),
5030
+ new ApiaUtil().tooltips.open({
5348
5031
  attachToElement: () => document.querySelector(
5349
5032
  `#${storeId} .iconsList__iconWrapper[data-id="${icon.id}"]`
5350
5033
  ),
5351
- closeOnClick: false
5034
+ children: onIconGetDetails(icon),
5035
+ closeOnClick: false,
5036
+ minSize: { width: 200, height: 0 }
5352
5037
  });
5353
5038
  }
5354
5039
  },
5355
- [onIconGetDetails, open, storeId]
5040
+ [onIconGetDetails, storeId]
5356
5041
  );
5357
5042
  return /* @__PURE__ */ jsx(
5358
5043
  Box,
@@ -5456,19 +5141,19 @@ const KeyHandler = ({
5456
5141
  );
5457
5142
  };
5458
5143
 
5459
- var __defProp$6 = Object.defineProperty;
5460
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
5461
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
5462
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
5463
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5464
- var __spreadValues$6 = (a, b) => {
5144
+ var __defProp$8 = Object.defineProperty;
5145
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
5146
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
5147
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
5148
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5149
+ var __spreadValues$8 = (a, b) => {
5465
5150
  for (var prop in b || (b = {}))
5466
- if (__hasOwnProp$6.call(b, prop))
5467
- __defNormalProp$6(a, prop, b[prop]);
5468
- if (__getOwnPropSymbols$6)
5469
- for (var prop of __getOwnPropSymbols$6(b)) {
5470
- if (__propIsEnum$6.call(b, prop))
5471
- __defNormalProp$6(a, prop, b[prop]);
5151
+ if (__hasOwnProp$8.call(b, prop))
5152
+ __defNormalProp$8(a, prop, b[prop]);
5153
+ if (__getOwnPropSymbols$8)
5154
+ for (var prop of __getOwnPropSymbols$8(b)) {
5155
+ if (__propIsEnum$8.call(b, prop))
5156
+ __defNormalProp$8(a, prop, b[prop]);
5472
5157
  }
5473
5158
  return a;
5474
5159
  };
@@ -5491,7 +5176,7 @@ const styles$1 = {
5491
5176
  flexDirection: "column",
5492
5177
  gap: 3,
5493
5178
  "&:hover": (theme) => {
5494
- return __spreadValues$6({}, theme.palette.getOneState(
5179
+ return __spreadValues$8({}, theme.palette.getOneState(
5495
5180
  { backgroundColor: "palette.background.paper" },
5496
5181
  "hover"
5497
5182
  ));
@@ -5508,7 +5193,7 @@ const styles$1 = {
5508
5193
  },
5509
5194
  ".iconsList__keyHandler:focus": {
5510
5195
  outline: "none",
5511
- ".focused .iconsList__icon__wrapper": __spreadValues$6({}, focusOutline)
5196
+ ".focused .iconsList__icon__wrapper": __spreadValues$8({}, focusOutline)
5512
5197
  }
5513
5198
  };
5514
5199
 
@@ -5551,15 +5236,254 @@ function getRowIcons({
5551
5236
  justToFillTheRow
5552
5237
  )
5553
5238
  );
5554
- return actualIcons;
5555
- }
5239
+ return actualIcons;
5240
+ }
5241
+
5242
+ const IconRendererContext = createContext(
5243
+ null
5244
+ );
5245
+ function useIconRendererContext() {
5246
+ const context = useContext(IconRendererContext);
5247
+ if (!context)
5248
+ throw new Error("There is no IconRendererContext");
5249
+ return context;
5250
+ }
5251
+
5252
+ var __defProp$7 = Object.defineProperty;
5253
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
5254
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
5255
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
5256
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5257
+ var __spreadValues$7 = (a, b) => {
5258
+ for (var prop in b || (b = {}))
5259
+ if (__hasOwnProp$7.call(b, prop))
5260
+ __defNormalProp$7(a, prop, b[prop]);
5261
+ if (__getOwnPropSymbols$7)
5262
+ for (var prop of __getOwnPropSymbols$7(b)) {
5263
+ if (__propIsEnum$7.call(b, prop))
5264
+ __defNormalProp$7(a, prop, b[prop]);
5265
+ }
5266
+ return a;
5267
+ };
5268
+ const Icon = (props) => {
5269
+ var _a;
5270
+ const { useProps } = useIconsListStoreContext();
5271
+ const ref = useProps("cell", {
5272
+ columnIndex: props.colIndex,
5273
+ rowIndex: props.rowIndex
5274
+ });
5275
+ const Renderer = useIconRendererContext();
5276
+ return /* @__PURE__ */ jsx(
5277
+ Box,
5278
+ {
5279
+ ref,
5280
+ role: "gridcell",
5281
+ "data-id": props.id,
5282
+ className: `iconsList__iconWrapper ${(_a = props.className) != null ? _a : ""}`,
5283
+ "aria-label": props.ariaLabel,
5284
+ sx: useMemo(
5285
+ () => ({
5286
+ width: `${props.width}px`,
5287
+ ".iconsList__icon__image__wrapper": {
5288
+ height: `${props.width - 4}px`
5289
+ },
5290
+ ".iconsList__icon__image": {
5291
+ maxHeight: `${props.width - 32}px`,
5292
+ maxWidth: `${props.width - 32}px`
5293
+ }
5294
+ }),
5295
+ [props.width]
5296
+ ),
5297
+ "aria-colindex": props.colIndex,
5298
+ children: /* @__PURE__ */ jsx(Renderer, __spreadValues$7({}, props))
5299
+ }
5300
+ );
5301
+ };
5302
+
5303
+ var __defProp$6 = Object.defineProperty;
5304
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
5305
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
5306
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
5307
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5308
+ var __spreadValues$6 = (a, b) => {
5309
+ for (var prop in b || (b = {}))
5310
+ if (__hasOwnProp$6.call(b, prop))
5311
+ __defNormalProp$6(a, prop, b[prop]);
5312
+ if (__getOwnPropSymbols$6)
5313
+ for (var prop of __getOwnPropSymbols$6(b)) {
5314
+ if (__propIsEnum$6.call(b, prop))
5315
+ __defNormalProp$6(a, prop, b[prop]);
5316
+ }
5317
+ return a;
5318
+ };
5319
+ const IconWrapper = ({
5320
+ icon,
5321
+ iconWidth,
5322
+ rowIndex,
5323
+ colIndex
5324
+ }) => {
5325
+ return icon === justToFillTheRow ? /* @__PURE__ */ jsx(Box, { sx: { width: `${iconWidth}px` }, className: "fill__the__row" }) : /* @__PURE__ */ jsx(
5326
+ Icon,
5327
+ __spreadValues$6({
5328
+ rowIndex,
5329
+ colIndex,
5330
+ width: iconWidth
5331
+ }, icon)
5332
+ );
5333
+ };
5334
+
5335
+ const DefaultIconRendererNoMemo = (props) => {
5336
+ if (!props.icon && !props.imageUrl) {
5337
+ console.error({ props });
5338
+ throw new Error("The icon has no imageUrl nor icon defined");
5339
+ }
5340
+ return /* @__PURE__ */ jsxs(Box, { title: props.label, className: "iconsList__icon__wrapper", children: [
5341
+ /* @__PURE__ */ jsxs(Box, { className: "iconsList__icon__image__wrapper", children: [
5342
+ props.imageUrl && /* @__PURE__ */ jsx(
5343
+ Image,
5344
+ {
5345
+ className: "iconsList__icon__image",
5346
+ src: props.imageUrl,
5347
+ role: "decoration"
5348
+ }
5349
+ ),
5350
+ props.icon && /* @__PURE__ */ jsx(Icon$1, { icon: props.icon, title: props.ariaLabel })
5351
+ ] }),
5352
+ /* @__PURE__ */ jsx(Box, { className: "iconsList__icon__label", children: props.label })
5353
+ ] });
5354
+ };
5355
+ const DefaultIconRenderer = memo(DefaultIconRendererNoMemo);
5356
+
5357
+ const IconsListNonForwarded = (props, ref) => {
5358
+ var _a, _b, _c;
5359
+ const propsRef = useLatest(props);
5360
+ let render = () => {
5361
+ };
5362
+ const previousProps = usePrevious(props);
5363
+ if (!shallowEqual(props, previousProps.current)) {
5364
+ setTimeout(() => render(), 0);
5365
+ }
5366
+ const ResponsiveContainer = useMemo(() => {
5367
+ var _a2, _b2;
5368
+ const iconWidth = (_a2 = propsRef.current.iconWidth) != null ? _a2 : 100;
5369
+ const minGap = (_b2 = propsRef.current.minHorizontalGap) != null ? _b2 : 30;
5370
+ const blockWidth = iconWidth + minGap;
5371
+ const styledComponent = (styledComponentProps) => {
5372
+ var _a3, _b3;
5373
+ const { breakPoint, containerWidth } = styledComponentProps;
5374
+ const [, doRender] = useState(true);
5375
+ render = useCallback(() => doRender((current) => !current), []);
5376
+ const storeId = useMemo(() => uniqueId("IconsList"), []);
5377
+ const [actions, , , , Context] = useStore({ storeId });
5378
+ const rows = Math.ceil(propsRef.current.icons.length / breakPoint);
5379
+ const sx = useStyles({
5380
+ breakPoint,
5381
+ containerWidth,
5382
+ iconWidth: (_a3 = propsRef.current.iconWidth) != null ? _a3 : 100,
5383
+ verticalGap: propsRef.current.verticalGap,
5384
+ removeHorizontalPadding: propsRef.current.removeHorizontalPadding
5385
+ });
5386
+ useEffect(() => {
5387
+ actions.recalculateIndexByResize();
5388
+ }, [breakPoint]);
5389
+ const IconRenderer = (_b3 = propsRef.current.iconRenderer) != null ? _b3 : DefaultIconRenderer;
5390
+ return /* @__PURE__ */ jsx(IconRendererContext.Provider, { value: IconRenderer, children: /* @__PURE__ */ jsx(Context, { children: /* @__PURE__ */ jsx(
5391
+ KeyHandler,
5392
+ {
5393
+ icons: propsRef.current.icons,
5394
+ onIconClick: propsRef.current.onIconClick,
5395
+ onIconDoubleClick: propsRef.current.onIconDoubleClick,
5396
+ onIconGetDetails: propsRef.current.onIconGetDetails,
5397
+ onIconKeyDown: propsRef.current.onIconKeyDown,
5398
+ storeId,
5399
+ children: /* @__PURE__ */ jsx(
5400
+ Box,
5401
+ {
5402
+ id: storeId,
5403
+ role: "grid",
5404
+ "aria-rowcount": rows,
5405
+ "aria-colcount": breakPoint,
5406
+ children: Array(rows).fill(1).map((_, i) => {
5407
+ const icons = getRowIcons({
5408
+ breakPoint,
5409
+ i,
5410
+ icons: propsRef.current.icons
5411
+ });
5412
+ return /* @__PURE__ */ jsx(
5413
+ Grid,
5414
+ {
5415
+ "aria-rowindex": i + 1,
5416
+ role: "row",
5417
+ ref,
5418
+ sx,
5419
+ children: icons.map((current, j) => {
5420
+ var _a4;
5421
+ return /* @__PURE__ */ jsx(
5422
+ IconWrapper,
5423
+ {
5424
+ colIndex: j + 1,
5425
+ icon: current,
5426
+ iconWidth: (_a4 = propsRef.current.iconWidth) != null ? _a4 : 100,
5427
+ rowIndex: i + 1
5428
+ },
5429
+ uniqueId(String(j + i))
5430
+ );
5431
+ })
5432
+ },
5433
+ i
5434
+ );
5435
+ })
5436
+ }
5437
+ )
5438
+ }
5439
+ ) }) });
5440
+ };
5441
+ const Component = makeResponsiveComponent({
5442
+ breakPoints: getBreakpoints(blockWidth),
5443
+ Component: makeStyledComponent(
5444
+ "IconsList",
5445
+ "layout.common.components.iconsList",
5446
+ styles$1,
5447
+ styledComponent
5448
+ ),
5449
+ debounce: 50
5450
+ });
5451
+ return Component;
5452
+ }, []);
5453
+ if (((_a = previousProps.current) == null ? void 0 : _a.iconWidth) !== props.iconWidth) {
5454
+ const iconWidth = (_b = props.iconWidth) != null ? _b : 100;
5455
+ const minGap = (_c = props.minHorizontalGap) != null ? _c : 30;
5456
+ const blockWidth = iconWidth + minGap;
5457
+ setTimeout(
5458
+ () => ResponsiveContainer.setBreakpoints.current(getBreakpoints(blockWidth)),
5459
+ 0
5460
+ );
5461
+ }
5462
+ return /* @__PURE__ */ jsx(ResponsiveContainer, {});
5463
+ };
5464
+ IconsListNonForwarded.displayName = "IconsList";
5465
+ const IconsList = forwardRef(
5466
+ IconsListNonForwarded
5467
+ );
5556
5468
 
5557
- const IconRendererContext = createContext(null);
5558
- function useIconRendererContext() {
5559
- const context = useContext(IconRendererContext);
5560
- if (!context)
5561
- throw new Error("There is no IconRendererContext");
5562
- return context;
5469
+ function importComponent(path) {
5470
+ return lazy(() => {
5471
+ return new Promise((resolve) => {
5472
+ import(
5473
+ /* webpackInclude: /\.tsx?$/ */
5474
+ `/customComponents/${path}`
5475
+ ).then((result) => {
5476
+ resolve(result);
5477
+ }).catch((error) => {
5478
+ resolve({
5479
+ default: () => {
5480
+ console.error(error);
5481
+ return /* @__PURE__ */ jsx(Fragment, { children: "Error" });
5482
+ }
5483
+ });
5484
+ });
5485
+ });
5486
+ });
5563
5487
  }
5564
5488
 
5565
5489
  var __defProp$5 = Object.defineProperty;
@@ -5578,39 +5502,55 @@ var __spreadValues$5 = (a, b) => {
5578
5502
  }
5579
5503
  return a;
5580
5504
  };
5581
- const Icon = (props) => {
5582
- var _a;
5583
- const { useProps } = useIconsListStoreContext();
5584
- const ref = useProps("cell", {
5585
- columnIndex: props.colIndex,
5586
- rowIndex: props.rowIndex
5587
- });
5588
- const Renderer = useIconRendererContext();
5589
- return /* @__PURE__ */ jsx(
5590
- Box,
5591
- {
5592
- ref,
5593
- role: "gridcell",
5594
- "data-id": props.id,
5595
- className: `iconsList__iconWrapper ${(_a = props.className) != null ? _a : ""}`,
5596
- "aria-label": props.ariaLabel,
5597
- sx: useMemo(
5598
- () => ({
5599
- width: `${props.width}px`,
5600
- ".iconsList__icon__image__wrapper": {
5601
- height: `${props.width - 4}px`
5602
- },
5603
- ".iconsList__icon__image": {
5604
- maxHeight: `${props.width - 32}px`,
5605
- maxWidth: `${props.width - 32}px`
5505
+ const styles = {
5506
+ backgroundColor: "palette.background.default",
5507
+ "ul.listbox__list": {
5508
+ display: "flex",
5509
+ padding: "4px",
5510
+ gap: "2px",
5511
+ "[data-separator]": {
5512
+ "&:focus, &.focused": {
5513
+ outline: "none"
5514
+ }
5515
+ },
5516
+ ".listbox__row": {
5517
+ p: 0,
5518
+ display: "flex",
5519
+ alignItems: "center",
5520
+ justifyContent: "center"
5521
+ },
5522
+ ".iconButton": {
5523
+ borderRadius: "4px",
5524
+ height: "32px",
5525
+ width: "32px",
5526
+ background: "transparent",
5527
+ svg: {
5528
+ path: {
5529
+ fill: "palette.text.primary"
5530
+ }
5531
+ },
5532
+ "&:disabled": {
5533
+ svg: {
5534
+ path: {
5535
+ fill: "palette.border.section"
5606
5536
  }
5607
- }),
5608
- [props.width]
5609
- ),
5610
- "aria-colindex": props.colIndex,
5611
- children: /* @__PURE__ */ jsx(Renderer, __spreadValues$5({}, props))
5537
+ }
5538
+ }
5539
+ },
5540
+ ".separator": {
5541
+ borderLeft: "1px solid",
5542
+ borderRight: "1px solid",
5543
+ borderColor: "palette.gray.750",
5544
+ height: "60%",
5545
+ width: "3px"
5546
+ },
5547
+ ".toggled": (theme) => {
5548
+ return __spreadValues$5({}, theme.palette.getOneState(
5549
+ { backgroundColor: theme.palette.background.default },
5550
+ "selected"
5551
+ ));
5612
5552
  }
5613
- );
5553
+ }
5614
5554
  };
5615
5555
 
5616
5556
  var __defProp$4 = Object.defineProperty;
@@ -5629,291 +5569,470 @@ var __spreadValues$4 = (a, b) => {
5629
5569
  }
5630
5570
  return a;
5631
5571
  };
5632
- const IconWrapper = ({
5633
- icon,
5634
- iconWidth,
5635
- rowIndex,
5636
- colIndex
5637
- }) => {
5638
- return icon === justToFillTheRow ? /* @__PURE__ */ jsx(Box, { sx: { width: `${iconWidth}px` }, className: "fill__the__row" }) : /* @__PURE__ */ jsx(
5639
- Icon,
5640
- __spreadValues$4({
5641
- rowIndex,
5642
- colIndex,
5643
- width: iconWidth
5644
- }, icon)
5645
- );
5572
+ class ToolbarController extends EventEmitter {
5573
+ constructor() {
5574
+ super(...arguments);
5575
+ this.eventListeners = {};
5576
+ this.itemsState = {};
5577
+ this.hooks = {
5578
+ useItemState: (id, initialState) => {
5579
+ const [state, setState] = useState(initialState);
5580
+ useEffect(() => {
5581
+ this.itemsState[id] = initialState;
5582
+ this.on("updateItemState", (evId) => {
5583
+ if (evId === id) {
5584
+ setState(__spreadValues$4({}, this.itemsState[id]));
5585
+ }
5586
+ });
5587
+ }, []);
5588
+ return state;
5589
+ }
5590
+ };
5591
+ this.setItemState = (id, newState) => {
5592
+ this.itemsState[id] = __spreadValues$4(__spreadValues$4({}, this.itemsState[id]), newState);
5593
+ this.emit("updateItemState", id);
5594
+ };
5595
+ this.Context = ({ children }) => {
5596
+ return /* @__PURE__ */ jsx(ToolbarControllerContext.Provider, { value: this, children });
5597
+ };
5598
+ }
5599
+ }
5600
+ const ToolbarControllerContext = createContext(
5601
+ null
5602
+ );
5603
+ const useToolbarControllerContext = () => {
5604
+ const context = useContext(ToolbarControllerContext);
5605
+ if (!context)
5606
+ throw new Error("There is no Toolbar controller context");
5607
+ return context;
5608
+ };
5609
+
5610
+ var __defProp$3 = Object.defineProperty;
5611
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
5612
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
5613
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
5614
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5615
+ var __spreadValues$3 = (a, b) => {
5616
+ for (var prop in b || (b = {}))
5617
+ if (__hasOwnProp$3.call(b, prop))
5618
+ __defNormalProp$3(a, prop, b[prop]);
5619
+ if (__getOwnPropSymbols$3)
5620
+ for (var prop of __getOwnPropSymbols$3(b)) {
5621
+ if (__propIsEnum$3.call(b, prop))
5622
+ __defNormalProp$3(a, prop, b[prop]);
5623
+ }
5624
+ return a;
5625
+ };
5626
+ const ToolbarItemButton = ({
5627
+ id,
5628
+ action,
5629
+ allowToggle,
5630
+ defaultToggled,
5631
+ disabled,
5632
+ icon,
5633
+ iconSize,
5634
+ title,
5635
+ toggled: toggledProp
5636
+ }) => {
5637
+ const [innerIsToggled, setInnerIsToggled] = useState(
5638
+ toggledProp != null ? toggledProp : allowToggle ? defaultToggled != null ? defaultToggled : false : false
5639
+ );
5640
+ const [isDisabled, setIsDisabled] = useState(!!disabled);
5641
+ const lastToggledProp = useRef(toggledProp);
5642
+ if (toggledProp !== void 0 && innerIsToggled !== toggledProp && lastToggledProp.current !== toggledProp) {
5643
+ lastToggledProp.current = toggledProp;
5644
+ setInnerIsToggled(toggledProp);
5645
+ }
5646
+ const handleClick = useCallback(() => {
5647
+ if (lastToggledProp.current !== void 0) {
5648
+ action({ isToggled: !lastToggledProp.current });
5649
+ } else if (allowToggle) {
5650
+ let isToggled = false;
5651
+ setInnerIsToggled((current) => {
5652
+ isToggled = !current;
5653
+ return isToggled;
5654
+ });
5655
+ action({ isToggled });
5656
+ } else {
5657
+ action({ isToggled: false });
5658
+ }
5659
+ }, [action, allowToggle]);
5660
+ const context = useToolbarControllerContext();
5661
+ useEffect(() => {
5662
+ const unsuscribe1 = context.on("updateItemState", (evId) => {
5663
+ if (evId === id) {
5664
+ setInnerIsToggled(!!context.itemsState[evId].toggled);
5665
+ setIsDisabled(!!context.itemsState[evId].disabled);
5666
+ }
5667
+ });
5668
+ const unsuscribe2 = context.on("pressEnter", (evId) => {
5669
+ if (evId === id)
5670
+ handleClick();
5671
+ });
5672
+ return () => {
5673
+ unsuscribe1();
5674
+ unsuscribe2();
5675
+ };
5676
+ }, [context, id, handleClick]);
5677
+ useMount(() => {
5678
+ if (context.itemsState[id]) {
5679
+ if (context.itemsState[id].disabled !== void 0) {
5680
+ setIsDisabled(!!context.itemsState[id].disabled);
5681
+ }
5682
+ if (context.itemsState[id].toggled !== void 0) {
5683
+ setInnerIsToggled(!!context.itemsState[id].toggled);
5684
+ }
5685
+ } else
5686
+ context.itemsState[id] = __spreadValues$3({
5687
+ disabled: isDisabled,
5688
+ toggled: innerIsToggled
5689
+ }, context.itemsState[id]);
5690
+ });
5691
+ return /* @__PURE__ */ jsx(
5692
+ IconButton$2,
5693
+ {
5694
+ className: `toolbarItem ${innerIsToggled ? "toggled" : ""}`,
5695
+ size: iconSize != null ? iconSize : "Md",
5696
+ icon,
5697
+ onClick: handleClick,
5698
+ "data-id": id,
5699
+ title,
5700
+ disabled: isDisabled
5701
+ }
5702
+ );
5703
+ };
5704
+
5705
+ function isSeparator(params) {
5706
+ return !!params.separator;
5707
+ }
5708
+
5709
+ var __defProp$2 = Object.defineProperty;
5710
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
5711
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
5712
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
5713
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5714
+ var __spreadValues$2 = (a, b) => {
5715
+ for (var prop in b || (b = {}))
5716
+ if (__hasOwnProp$2.call(b, prop))
5717
+ __defNormalProp$2(a, prop, b[prop]);
5718
+ if (__getOwnPropSymbols$2)
5719
+ for (var prop of __getOwnPropSymbols$2(b)) {
5720
+ if (__propIsEnum$2.call(b, prop))
5721
+ __defNormalProp$2(a, prop, b[prop]);
5722
+ }
5723
+ return a;
5724
+ };
5725
+ const ToolbarItem = (props) => {
5726
+ if (isSeparator(props)) {
5727
+ return /* @__PURE__ */ jsx(Box, { className: "separator", children: "\xA0" });
5728
+ }
5729
+ return /* @__PURE__ */ jsx(ToolbarItemButton, __spreadValues$2({}, props));
5646
5730
  };
5647
5731
 
5648
- const DefaultIconRendererNoMemo = (props) => {
5649
- return /* @__PURE__ */ jsxs(Box, { title: props.label, className: "iconsList__icon__wrapper", children: [
5650
- /* @__PURE__ */ jsx(Box, { className: "iconsList__icon__image__wrapper", children: /* @__PURE__ */ jsx(
5651
- Image,
5732
+ const Toolbar = makeStyledComponent(
5733
+ "toolbar",
5734
+ "layout.components.toolbar",
5735
+ styles,
5736
+ ({ children, getController }) => {
5737
+ const controller = useMemo(() => new ToolbarController(), []);
5738
+ let separator = 0;
5739
+ useMount(() => {
5740
+ getController == null ? void 0 : getController(controller);
5741
+ });
5742
+ return /* @__PURE__ */ jsx(controller.Context, { children: /* @__PURE__ */ jsx(
5743
+ Listbox,
5652
5744
  {
5653
- className: "iconsList__icon__image",
5654
- src: props.imageUrl,
5655
- role: "decoration"
5656
- }
5657
- ) }),
5658
- /* @__PURE__ */ jsx(Box, { className: "iconsList__icon__label", children: props.label })
5659
- ] });
5660
- };
5661
- const DefaultIconRenderer = memo(DefaultIconRendererNoMemo);
5662
-
5663
- const IconsListNonForwarded = (props, ref) => {
5664
- var _a, _b, _c;
5665
- const propsRef = useLatest(props);
5666
- let render = () => {
5667
- };
5668
- const previousProps = usePrevious(props);
5669
- if (!shallowEqual(props, previousProps.current)) {
5670
- setTimeout(() => render(), 0);
5671
- }
5672
- const ResponsiveContainer = useMemo(() => {
5673
- var _a2, _b2;
5674
- const iconWidth = (_a2 = propsRef.current.iconWidth) != null ? _a2 : 100;
5675
- const minGap = (_b2 = propsRef.current.minHorizontalGap) != null ? _b2 : 30;
5676
- const blockWidth = iconWidth + minGap;
5677
- const styledComponent = (styledComponentProps) => {
5678
- var _a3, _b3;
5679
- const { breakPoint, containerWidth } = styledComponentProps;
5680
- const [, doRender] = useState(true);
5681
- render = useCallback(() => doRender((current) => !current), []);
5682
- const storeId = useMemo(() => uniqueId("IconsList"), []);
5683
- const [actions, , , , Context] = useStore({ storeId });
5684
- const rows = Math.ceil(propsRef.current.icons.length / breakPoint);
5685
- const sx = useStyles({
5686
- breakPoint,
5687
- containerWidth,
5688
- iconWidth: (_a3 = propsRef.current.iconWidth) != null ? _a3 : 100,
5689
- verticalGap: propsRef.current.verticalGap,
5690
- removeHorizontalPadding: propsRef.current.removeHorizontalPadding
5691
- });
5692
- useEffect(() => {
5693
- actions.recalculateIndexByResize();
5694
- }, [breakPoint]);
5695
- const IconRenderer = (_b3 = propsRef.current.iconRenderer) != null ? _b3 : DefaultIconRenderer;
5696
- return /* @__PURE__ */ jsx(IconRendererContext.Provider, { value: IconRenderer, children: /* @__PURE__ */ jsx(Context, { children: /* @__PURE__ */ jsx(
5697
- KeyHandler,
5698
- {
5699
- icons: propsRef.current.icons,
5700
- onIconClick: propsRef.current.onIconClick,
5701
- onIconDoubleClick: propsRef.current.onIconDoubleClick,
5702
- onIconGetDetails: propsRef.current.onIconGetDetails,
5703
- onIconKeyDown: propsRef.current.onIconKeyDown,
5704
- storeId,
5705
- children: /* @__PURE__ */ jsx(
5706
- Box,
5707
- {
5708
- id: storeId,
5709
- role: "grid",
5710
- "aria-rowcount": rows,
5711
- "aria-colcount": breakPoint,
5712
- children: arrayOrArray(rows).fill(1).map((_, i) => {
5713
- const icons = getRowIcons({
5714
- breakPoint,
5715
- i,
5716
- icons: propsRef.current.icons
5717
- });
5718
- return /* @__PURE__ */ jsx(
5719
- Grid,
5720
- {
5721
- "aria-rowindex": i + 1,
5722
- role: "row",
5723
- ref,
5724
- sx,
5725
- children: icons.map((current, j) => {
5726
- var _a4;
5727
- return /* @__PURE__ */ jsx(
5728
- IconWrapper,
5729
- {
5730
- colIndex: j + 1,
5731
- icon: current,
5732
- iconWidth: (_a4 = propsRef.current.iconWidth) != null ? _a4 : 100,
5733
- rowIndex: i + 1
5734
- },
5735
- uniqueId(String(j + i))
5736
- );
5737
- })
5738
- },
5739
- i
5740
- );
5741
- })
5745
+ className: "toolbar",
5746
+ onPressKeyOnNode: (ev) => {
5747
+ if (ev.code === "Enter" || ev.code === "Space") {
5748
+ const target = ev.target;
5749
+ const item = target.querySelector(".toolbarItem");
5750
+ const id = item.dataset.id;
5751
+ if (!id) {
5752
+ console.error("Error event", ev);
5753
+ throw new Error(
5754
+ "Cannot find target in toolbar press enter event."
5755
+ );
5742
5756
  }
5743
- )
5744
- }
5745
- ) }) });
5746
- };
5747
- const Component = makeResponsiveComponent({
5748
- breakPoints: getBreakpoints(blockWidth),
5749
- Component: makeStyledComponent(
5750
- "IconsList",
5751
- "layout.common.components.iconsList",
5752
- styles$1,
5753
- styledComponent
5754
- ),
5755
- debounce: 50
5756
- });
5757
- return Component;
5758
- }, []);
5759
- if (((_a = previousProps.current) == null ? void 0 : _a.iconWidth) !== props.iconWidth) {
5760
- const iconWidth = (_b = props.iconWidth) != null ? _b : 100;
5761
- const minGap = (_c = props.minHorizontalGap) != null ? _c : 30;
5762
- const blockWidth = iconWidth + minGap;
5763
- setTimeout(
5764
- () => ResponsiveContainer.setBreakpoints.current(getBreakpoints(blockWidth)),
5765
- 0
5766
- );
5757
+ controller.emit("pressEnter", id);
5758
+ }
5759
+ },
5760
+ children: Children.toArray(children).map((current) => {
5761
+ const props = current == null ? void 0 : current.props;
5762
+ if (!props)
5763
+ throw new Error("Toolbar items must be of ToolbarItem type.");
5764
+ const { id, title } = props;
5765
+ return /* @__PURE__ */ jsx(
5766
+ ListboxItem,
5767
+ {
5768
+ label: title,
5769
+ "data-separator": id ? void 0 : "true",
5770
+ children: current
5771
+ },
5772
+ id != null ? id : `separator${separator++}`
5773
+ );
5774
+ })
5775
+ }
5776
+ ) });
5767
5777
  }
5768
- return /* @__PURE__ */ jsx(ResponsiveContainer, {});
5769
- };
5770
- IconsListNonForwarded.displayName = "IconsList";
5771
- const IconsList = forwardRef(
5772
- IconsListNonForwarded
5773
5778
  );
5774
5779
 
5775
- function importComponent(path) {
5776
- return lazy(() => {
5777
- return new Promise((resolve) => {
5778
- import(
5779
- /* webpackInclude: /\.tsx?$/ */
5780
- `/customComponents/${path}`
5781
- ).then((result) => {
5782
- resolve(result);
5783
- }).catch((error) => {
5784
- resolve({
5785
- default: () => {
5786
- console.error(error);
5787
- return /* @__PURE__ */ jsx(Fragment, { children: "Error" });
5788
- }
5789
- });
5790
- });
5791
- });
5792
- });
5780
+ function isAttachToElementAFunction(attachToElement) {
5781
+ return attachToElement instanceof Function && getParamNames(attachToElement).length === 0;
5782
+ }
5783
+
5784
+ const STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;
5785
+ const ARGUMENT_NAMES = /([^\s,]+)/g;
5786
+ function getParamNames(func) {
5787
+ const fnStr = func.toString().replace(STRIP_COMMENTS, "");
5788
+ let result = fnStr.slice(fnStr.indexOf("(") + 1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
5789
+ if (result === null)
5790
+ result = [];
5791
+ return result;
5792
+ }
5793
+ function determineAnchorPoint({
5794
+ attachToElement,
5795
+ attachToElementAnchorPoint
5796
+ }) {
5797
+ let actualAnchorPoint = { left: 0, top: 0 };
5798
+ const element = isAttachToElementAFunction(attachToElement) ? attachToElement() : attachToElement.current;
5799
+ if (element) {
5800
+ const rect = element.getBoundingClientRect();
5801
+ const point = attachToElementAnchorPoint != null ? attachToElementAnchorPoint : "topRight";
5802
+ switch (point) {
5803
+ case "bottomLeft":
5804
+ actualAnchorPoint = {
5805
+ left: rect.left,
5806
+ top: rect.bottom
5807
+ };
5808
+ break;
5809
+ case "bottomRight":
5810
+ actualAnchorPoint = {
5811
+ left: rect.right,
5812
+ top: rect.bottom
5813
+ };
5814
+ break;
5815
+ case "center":
5816
+ actualAnchorPoint = {
5817
+ left: (rect.left + rect.right) / 2,
5818
+ top: (rect.bottom + rect.top) / 2
5819
+ };
5820
+ break;
5821
+ case "topLeft":
5822
+ actualAnchorPoint = {
5823
+ left: rect.left,
5824
+ top: rect.top
5825
+ };
5826
+ break;
5827
+ case "topRight":
5828
+ actualAnchorPoint = {
5829
+ left: rect.right,
5830
+ top: rect.top
5831
+ };
5832
+ break;
5833
+ }
5834
+ } else {
5835
+ console.warn(
5836
+ "Cannot resolve element, will use default positioning ",
5837
+ attachToElement
5838
+ );
5839
+ }
5840
+ return actualAnchorPoint;
5793
5841
  }
5794
-
5795
- var __defProp$3 = Object.defineProperty;
5796
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
5797
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
5798
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
5799
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5800
- var __spreadValues$3 = (a, b) => {
5801
- for (var prop in b || (b = {}))
5802
- if (__hasOwnProp$3.call(b, prop))
5803
- __defNormalProp$3(a, prop, b[prop]);
5804
- if (__getOwnPropSymbols$3)
5805
- for (var prop of __getOwnPropSymbols$3(b)) {
5806
- if (__propIsEnum$3.call(b, prop))
5807
- __defNormalProp$3(a, prop, b[prop]);
5842
+ function calculateTooltipPosition({
5843
+ anchorPoint,
5844
+ attachToElement,
5845
+ attachToElementAnchorPoint,
5846
+ minSize,
5847
+ preferredOrientationX,
5848
+ preferredOrientationY,
5849
+ preferredSize = { height: "auto", width: "auto" }
5850
+ }) {
5851
+ var _a, _b, _c, _d, _e, _f, _g, _h;
5852
+ let actualAnchorPoint = anchorPoint;
5853
+ if (attachToElement) {
5854
+ actualAnchorPoint = determineAnchorPoint({
5855
+ attachToElement,
5856
+ attachToElementAnchorPoint
5857
+ });
5858
+ }
5859
+ if (actualAnchorPoint) {
5860
+ const availableBottomSpace = window.innerHeight - actualAnchorPoint.top;
5861
+ const availableTopSpace = actualAnchorPoint.top;
5862
+ const availableLeftSpace = actualAnchorPoint.left;
5863
+ const availableRightSpace = window.innerWidth - actualAnchorPoint.left;
5864
+ const isEnoughToRight = ((_a = minSize == null ? void 0 : minSize.width) != null ? _a : 0) <= availableRightSpace;
5865
+ const isEnoughToLeft = ((_b = minSize == null ? void 0 : minSize.width) != null ? _b : 0) <= availableLeftSpace;
5866
+ const isEnoughToBottom = ((_c = minSize == null ? void 0 : minSize.height) != null ? _c : 0) <= availableBottomSpace;
5867
+ const isEnoughToTop = ((_d = minSize == null ? void 0 : minSize.height) != null ? _d : 0) <= availableTopSpace;
5868
+ const preferredWidth = preferredSize.width === "auto" ? Infinity : preferredSize.width;
5869
+ const preferredHeight = preferredSize.height === "auto" ? Infinity : preferredSize.height;
5870
+ const position = {
5871
+ "& > *": {
5872
+ width: "100%",
5873
+ height: "100%"
5874
+ },
5875
+ width: preferredSize.width === "auto" ? "auto" : "100%",
5876
+ height: preferredSize.height === "auto" ? "auto" : "100%"
5877
+ };
5878
+ if (preferredOrientationX === "left") {
5879
+ if (isEnoughToLeft) {
5880
+ position.maxWidth = Math.min(preferredWidth, availableLeftSpace);
5881
+ position.right = window.innerWidth - actualAnchorPoint.left;
5882
+ } else if (isEnoughToRight) {
5883
+ position.maxWidth = Math.min(preferredWidth, availableRightSpace);
5884
+ position.left = actualAnchorPoint.left;
5885
+ } else {
5886
+ position.left = 0;
5887
+ position.maxWidth = "100vw";
5888
+ }
5889
+ } else {
5890
+ if (isEnoughToRight) {
5891
+ position.maxWidth = Math.min(preferredWidth, availableRightSpace);
5892
+ position.left = actualAnchorPoint.left;
5893
+ } else if (isEnoughToLeft) {
5894
+ position.maxWidth = Math.min(preferredWidth, availableLeftSpace);
5895
+ position.right = window.innerWidth - actualAnchorPoint.left;
5896
+ } else {
5897
+ position.left = 0;
5898
+ position.maxWidth = "100vw";
5899
+ }
5808
5900
  }
5809
- return a;
5810
- };
5811
- const styles = {
5812
- backgroundColor: "palette.background.default",
5813
- "ul.listbox__list": {
5814
- display: "flex",
5815
- padding: "4px",
5816
- gap: "2px",
5817
- "[data-separator]": {
5818
- "&:focus, &.focused": {
5819
- outline: "none"
5901
+ if (preferredOrientationY === "top") {
5902
+ if (isEnoughToTop) {
5903
+ position.maxHeight = Math.min(preferredHeight, availableTopSpace);
5904
+ position.bottom = window.innerHeight - actualAnchorPoint.top;
5905
+ } else if (isEnoughToBottom) {
5906
+ position.maxHeight = Math.min(preferredHeight, availableBottomSpace);
5907
+ position.top = actualAnchorPoint.top;
5908
+ } else {
5909
+ position.maxHeight = "100vh";
5910
+ position.top = 0;
5820
5911
  }
5821
- },
5822
- ".listbox__row": {
5823
- p: 0,
5824
- display: "flex",
5825
- alignItems: "center",
5826
- justifyContent: "center"
5827
- },
5828
- ".iconButton": {
5829
- borderRadius: "4px",
5830
- height: "32px",
5831
- width: "32px",
5832
- background: "transparent",
5833
- svg: {
5834
- path: {
5835
- fill: "palette.text.primary"
5836
- }
5837
- },
5838
- "&:disabled": {
5839
- svg: {
5840
- path: {
5841
- fill: "palette.border.section"
5842
- }
5843
- }
5912
+ } else {
5913
+ if (isEnoughToBottom) {
5914
+ position.maxHeight = Math.min(preferredHeight, availableBottomSpace);
5915
+ position.top = actualAnchorPoint.top;
5916
+ } else if (isEnoughToTop) {
5917
+ position.maxHeight = Math.min(preferredHeight, availableTopSpace);
5918
+ position.bottom = window.innerHeight - actualAnchorPoint.top;
5919
+ } else {
5920
+ position.maxHeight = "100vh";
5921
+ position.top = 0;
5844
5922
  }
5845
- },
5846
- ".separator": {
5847
- borderLeft: "1px solid",
5848
- borderRight: "1px solid",
5849
- borderColor: "palette.gray.750",
5850
- height: "60%",
5851
- width: "3px"
5852
- },
5853
- ".toggled": (theme) => {
5854
- return __spreadValues$3({}, theme.palette.getOneState(
5855
- { backgroundColor: theme.palette.background.default },
5856
- "selected"
5857
- ));
5858
5923
  }
5924
+ position.minHeight = typeof position.maxHeight === "number" ? Math.min(position.maxHeight, (_e = minSize == null ? void 0 : minSize.height) != null ? _e : 0) : (_f = minSize == null ? void 0 : minSize.height) != null ? _f : 0;
5925
+ position.minWidth = typeof position.minWidth === "number" ? Math.min(position.minWidth, (_g = minSize == null ? void 0 : minSize.width) != null ? _g : 0) : (_h = minSize == null ? void 0 : minSize.width) != null ? _h : 0;
5926
+ return position;
5859
5927
  }
5860
- };
5861
-
5862
- var __defProp$2 = Object.defineProperty;
5863
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
5864
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
5865
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
5866
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5867
- var __spreadValues$2 = (a, b) => {
5868
- for (var prop in b || (b = {}))
5869
- if (__hasOwnProp$2.call(b, prop))
5870
- __defNormalProp$2(a, prop, b[prop]);
5871
- if (__getOwnPropSymbols$2)
5872
- for (var prop of __getOwnPropSymbols$2(b)) {
5873
- if (__propIsEnum$2.call(b, prop))
5874
- __defNormalProp$2(a, prop, b[prop]);
5928
+ return { left: 0, top: 0, width: "auto", height: "auto" };
5929
+ }
5930
+ function useHandlers({
5931
+ attachToElement,
5932
+ closeOnClick,
5933
+ closeOnClickOut,
5934
+ closeOnEscape,
5935
+ closeOnMouseLeaveTooltip,
5936
+ closeOnMouseLeaveAttachedElement,
5937
+ closeOnScrollOut,
5938
+ onClose
5939
+ }) {
5940
+ const hasInited = useRef(false);
5941
+ const close = useCallback(() => {
5942
+ onClose == null ? void 0 : onClose();
5943
+ }, [onClose]);
5944
+ useMount(() => {
5945
+ function handleEscape(ev) {
5946
+ if (ev.code === "Escape" && closeOnEscape) {
5947
+ close();
5948
+ }
5875
5949
  }
5876
- return a;
5877
- };
5878
- class ToolbarController extends EventEmitter {
5879
- constructor() {
5880
- super(...arguments);
5881
- this.eventListeners = {};
5882
- this.itemsState = {};
5883
- this.hooks = {
5884
- useItemState: (id, initialState) => {
5885
- const [state, setState] = useState(initialState);
5886
- useEffect(() => {
5887
- this.itemsState[id] = initialState;
5888
- this.on("updateItemState", (evId) => {
5889
- if (evId === id) {
5890
- setState(__spreadValues$2({}, this.itemsState[id]));
5891
- }
5892
- });
5893
- }, []);
5894
- return state;
5950
+ function handleMouseDownOut(ev) {
5951
+ if (!hasInited.current)
5952
+ return;
5953
+ if (closeOnClickOut && !isChild(
5954
+ ev.target,
5955
+ (current) => {
5956
+ var _a;
5957
+ return (_a = current.classList) == null ? void 0 : _a.contains("tooltip__wrapper");
5958
+ }
5959
+ )) {
5960
+ close();
5895
5961
  }
5962
+ }
5963
+ function handleScroll(ev) {
5964
+ if (!hasInited.current)
5965
+ return;
5966
+ if (closeOnScrollOut && !isChild(
5967
+ ev.target,
5968
+ (current) => {
5969
+ var _a;
5970
+ return (_a = current.classList) == null ? void 0 : _a.contains("tooltip__wrapper");
5971
+ }
5972
+ )) {
5973
+ close();
5974
+ }
5975
+ }
5976
+ function handleMouseLeave(event) {
5977
+ if (!hasInited.current || !closeOnMouseLeaveAttachedElement && !closeOnMouseLeaveTooltip)
5978
+ return;
5979
+ const resolvedAttachToElement = attachToElement ? isAttachToElementAFunction(attachToElement) ? attachToElement() : attachToElement.current : null;
5980
+ const isTooltipTheTarget = isChild(
5981
+ event.target,
5982
+ (current) => current.classList.contains("tooltip__wrapper")
5983
+ );
5984
+ const isAttachedTheTarget = isChild(
5985
+ event.target,
5986
+ (current) => current === resolvedAttachToElement
5987
+ );
5988
+ const isTooltipRelated = isChild(
5989
+ event.relatedTarget,
5990
+ (current) => current.classList.contains("tooltip__wrapper")
5991
+ );
5992
+ const isAttachedRelated = isChild(
5993
+ event.relatedTarget,
5994
+ (current) => current === resolvedAttachToElement
5995
+ );
5996
+ if (!isTooltipTheTarget && !isAttachedTheTarget && !closeOnMouseLeaveAttachedElement && !closeOnMouseLeaveTooltip)
5997
+ return;
5998
+ if (isTooltipRelated || isAttachedRelated)
5999
+ return;
6000
+ if (isAttachedTheTarget && !closeOnMouseLeaveAttachedElement)
6001
+ return;
6002
+ if (isTooltipTheTarget && !closeOnMouseLeaveTooltip)
6003
+ return;
6004
+ close();
6005
+ }
6006
+ document.addEventListener("keydown", handleEscape);
6007
+ document.addEventListener("mousedown", handleMouseDownOut);
6008
+ document.addEventListener("scroll", handleScroll);
6009
+ document.addEventListener("mouseout", handleMouseLeave);
6010
+ setTimeout(() => {
6011
+ hasInited.current = true;
6012
+ }, 0);
6013
+ return () => {
6014
+ document.removeEventListener("keydown", handleEscape);
6015
+ document.removeEventListener("click", handleMouseDownOut);
6016
+ document.removeEventListener("scroll", handleScroll);
6017
+ document.removeEventListener("mouseout", handleMouseLeave);
5896
6018
  };
5897
- this.setItemState = (id, newState) => {
5898
- this.itemsState[id] = __spreadValues$2(__spreadValues$2({}, this.itemsState[id]), newState);
5899
- this.emit("updateItemState", id);
5900
- };
5901
- this.Context = ({ children }) => {
5902
- return /* @__PURE__ */ jsx(ToolbarControllerContext.Provider, { value: this, children });
5903
- };
5904
- }
6019
+ });
6020
+ return {
6021
+ handleOnClick: useCallback(
6022
+ (ev) => {
6023
+ ev.stopPropagation();
6024
+ if (closeOnClick) {
6025
+ close();
6026
+ }
6027
+ },
6028
+ [close, closeOnClick]
6029
+ )
6030
+ };
5905
6031
  }
5906
- const ToolbarControllerContext = createContext(
5907
- null
5908
- );
5909
- const useToolbarControllerContext = () => {
5910
- const context = useContext(ToolbarControllerContext);
5911
- if (!context)
5912
- throw new Error("There is no Toolbar controller context");
5913
- return context;
5914
- };
5915
6032
 
5916
6033
  var __defProp$1 = Object.defineProperty;
6034
+ var __defProps$1 = Object.defineProperties;
6035
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
5917
6036
  var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
5918
6037
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
5919
6038
  var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
@@ -5929,90 +6048,63 @@ var __spreadValues$1 = (a, b) => {
5929
6048
  }
5930
6049
  return a;
5931
6050
  };
5932
- const ToolbarItemButton = ({
5933
- id,
5934
- action,
5935
- allowToggle,
5936
- defaultToggled,
5937
- disabled,
5938
- icon,
5939
- iconSize,
5940
- title,
5941
- toggled: toggledProp
6051
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
6052
+ const Tooltip = ({
6053
+ anchorPoint,
6054
+ attachToElement,
6055
+ attachToElementAnchorPoint,
6056
+ children,
6057
+ className,
6058
+ closeOnClick = false,
6059
+ closeOnClickOut = true,
6060
+ closeOnEscape = true,
6061
+ closeOnMouseLeaveTooltip = true,
6062
+ closeOnMouseLeaveAttachedElement = true,
6063
+ closeOnScrollOut = true,
6064
+ minSize,
6065
+ onClose,
6066
+ preferredOrientationX = "right",
6067
+ preferredOrientationY = "bottom",
6068
+ preferredSize = { height: "auto", width: "auto" },
6069
+ variant = "layout.common.tooltips.primary"
5942
6070
  }) => {
5943
- const [innerIsToggled, setInnerIsToggled] = useState(
5944
- toggledProp != null ? toggledProp : allowToggle ? defaultToggled != null ? defaultToggled : false : false
5945
- );
5946
- const [isDisabled, setIsDisabled] = useState(!!disabled);
5947
- const lastToggledProp = useRef(toggledProp);
5948
- if (toggledProp !== void 0 && innerIsToggled !== toggledProp && lastToggledProp.current !== toggledProp) {
5949
- lastToggledProp.current = toggledProp;
5950
- setInnerIsToggled(toggledProp);
5951
- }
5952
- const handleClick = useCallback(() => {
5953
- if (lastToggledProp.current !== void 0) {
5954
- action({ isToggled: !lastToggledProp.current });
5955
- } else if (allowToggle) {
5956
- let isToggled = false;
5957
- setInnerIsToggled((current) => {
5958
- isToggled = !current;
5959
- return isToggled;
5960
- });
5961
- action({ isToggled });
5962
- } else {
5963
- action({ isToggled: false });
5964
- }
5965
- }, [action, allowToggle]);
5966
- const context = useToolbarControllerContext();
5967
- useEffect(() => {
5968
- const unsuscribe1 = context.on("updateItemState", (evId) => {
5969
- if (evId === id) {
5970
- setInnerIsToggled(!!context.itemsState[evId].toggled);
5971
- setIsDisabled(!!context.itemsState[evId].disabled);
5972
- }
5973
- });
5974
- const unsuscribe2 = context.on("pressEnter", (evId) => {
5975
- if (evId === id)
5976
- handleClick();
5977
- });
5978
- return () => {
5979
- unsuscribe1();
5980
- unsuscribe2();
5981
- };
5982
- }, [context, id, handleClick]);
5983
- useMount(() => {
5984
- if (context.itemsState[id]) {
5985
- if (context.itemsState[id].disabled !== void 0) {
5986
- setIsDisabled(!!context.itemsState[id].disabled);
5987
- }
5988
- if (context.itemsState[id].toggled !== void 0) {
5989
- setInnerIsToggled(!!context.itemsState[id].toggled);
5990
- }
5991
- } else
5992
- context.itemsState[id] = __spreadValues$1({
5993
- disabled: isDisabled,
5994
- toggled: innerIsToggled
5995
- }, context.itemsState[id]);
6071
+ const calculatedPosition = calculateTooltipPosition({
6072
+ anchorPoint,
6073
+ attachToElement,
6074
+ attachToElementAnchorPoint,
6075
+ minSize,
6076
+ preferredOrientationX,
6077
+ preferredOrientationY,
6078
+ preferredSize
6079
+ });
6080
+ const sx = __spreadValues$1({
6081
+ position: "fixed"
6082
+ }, calculatedPosition);
6083
+ const { handleOnClick } = useHandlers({
6084
+ attachToElement,
6085
+ closeOnEscape,
6086
+ closeOnClickOut,
6087
+ closeOnClick,
6088
+ closeOnMouseLeaveTooltip,
6089
+ closeOnMouseLeaveAttachedElement,
6090
+ closeOnScrollOut,
6091
+ onClose
5996
6092
  });
5997
6093
  return /* @__PURE__ */ jsx(
5998
- IconButton$2,
5999
- {
6000
- className: `toolbarItem ${innerIsToggled ? "toggled" : ""}`,
6001
- size: iconSize != null ? iconSize : "Md",
6002
- icon,
6003
- onClick: handleClick,
6004
- "data-id": id,
6005
- title,
6006
- disabled: isDisabled
6007
- }
6094
+ Box,
6095
+ __spreadProps$1(__spreadValues$1({
6096
+ className: `tooltip__wrapper ${className != null ? className : ""}`
6097
+ }, getVariant(variant)), {
6098
+ sx,
6099
+ onClick: handleOnClick,
6100
+ children
6101
+ })
6008
6102
  );
6009
6103
  };
6010
6104
 
6011
- function isSeparator(params) {
6012
- return !!params.separator;
6013
- }
6014
-
6015
6105
  var __defProp = Object.defineProperty;
6106
+ var __defProps = Object.defineProperties;
6107
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6016
6108
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6017
6109
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6018
6110
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -6028,61 +6120,59 @@ var __spreadValues = (a, b) => {
6028
6120
  }
6029
6121
  return a;
6030
6122
  };
6031
- const ToolbarItem = (props) => {
6032
- if (isSeparator(props)) {
6033
- return /* @__PURE__ */ jsx(Box, { className: "separator", children: "\xA0" });
6034
- }
6035
- return /* @__PURE__ */ jsx(ToolbarItemButton, __spreadValues({}, props));
6036
- };
6037
-
6038
- const Toolbar = makeStyledComponent(
6039
- "toolbar",
6040
- "layout.components.toolbar",
6041
- styles,
6042
- ({ children, getController }) => {
6043
- const controller = useMemo(() => new ToolbarController(), []);
6044
- let separator = 0;
6045
- useMount(() => {
6046
- getController == null ? void 0 : getController(controller);
6047
- });
6048
- return /* @__PURE__ */ jsx(controller.Context, { children: /* @__PURE__ */ jsx(
6049
- Listbox,
6050
- {
6051
- className: "toolbar",
6052
- onPressKeyOnNode: (ev) => {
6053
- if (ev.code === "Enter" || ev.code === "Space") {
6054
- const target = ev.target;
6055
- const item = target.querySelector(".toolbarItem");
6056
- const id = item.dataset.id;
6057
- if (!id) {
6058
- console.error("Error event", ev);
6059
- throw new Error(
6060
- "Cannot find target in toolbar press enter event."
6061
- );
6062
- }
6063
- controller.emit("pressEnter", id);
6064
- }
6065
- },
6066
- children: Children.toArray(children).map((current) => {
6067
- const props = current == null ? void 0 : current.props;
6068
- if (!props)
6069
- throw new Error(
6070
- "Toolbar items must be of ToolbarItem type and have an id defined."
6071
- );
6072
- const { id, title } = props;
6073
- return /* @__PURE__ */ jsx(
6074
- ListboxItem,
6075
- {
6076
- label: title,
6077
- "data-separator": id ? void 0 : "true",
6078
- children: current
6079
- },
6080
- id != null ? id : `separator${separator++}`
6081
- );
6082
- })
6123
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
6124
+ const [, tooltipsHandler, TooltipsProvider] = makeSingleImperativeComponent()({
6125
+ Component: () => {
6126
+ const [tooltip, setTooltip] = useState(null);
6127
+ const tooltipRef = useLatest(tooltip);
6128
+ useImperativeComponentEvents({
6129
+ open: setTooltip,
6130
+ close() {
6131
+ var _a, _b;
6132
+ (_b = (_a = tooltipRef.current) == null ? void 0 : _a.onClose) == null ? void 0 : _b.call(_a);
6133
+ setTooltip(null);
6083
6134
  }
6084
- ) });
6135
+ });
6136
+ if (!tooltip)
6137
+ return null;
6138
+ return /* @__PURE__ */ jsx(Tooltip, __spreadValues({}, tooltip));
6085
6139
  }
6086
- );
6140
+ });
6141
+ function useTooltip(tooltip) {
6142
+ const isOpen = useRef(false);
6143
+ const open = useCallback(
6144
+ (otherProps) => {
6145
+ setTimeout(() => {
6146
+ isOpen.current = true;
6147
+ if (!tooltip && !(otherProps == null ? void 0 : otherProps.children))
6148
+ throw new Error("There is no children set for the current tooltip");
6149
+ tooltipsHandler("open", __spreadProps(__spreadValues(__spreadValues({}, tooltip), otherProps), {
6150
+ onClose() {
6151
+ var _a, _b;
6152
+ (_a = tooltip == null ? void 0 : tooltip.onClose) == null ? void 0 : _a.call(tooltip);
6153
+ (_b = otherProps == null ? void 0 : otherProps.onClose) == null ? void 0 : _b.call(otherProps);
6154
+ isOpen.current = false;
6155
+ }
6156
+ }));
6157
+ }, 0);
6158
+ },
6159
+ [tooltip]
6160
+ );
6161
+ return {
6162
+ close: useCallback(() => {
6163
+ tooltipsHandler("close", void 0);
6164
+ }, []),
6165
+ open,
6166
+ toggle: useCallback(
6167
+ (otherProps) => {
6168
+ if (isOpen.current) {
6169
+ tooltipsHandler("close", void 0);
6170
+ } else
6171
+ open(otherProps);
6172
+ },
6173
+ [open]
6174
+ )
6175
+ };
6176
+ }
6087
6177
 
6088
- export { Accordion, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, AutoEllipsis, BaseButton, CalendarModal, Captcha, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, DateInput, DialogButtonBar, FieldErrorMessage, FieldLabel, IconButton, IconInput, IconsList, LinearLoader, Listbox, ListboxItem, LoaderSpinner, Modal, ModalContext, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, Toolbar, ToolbarController, ToolbarItem, TooltipsProvider, WaiTypeAhead, getFieldErrorStyles, getFieldTouchedStyles, importComponent, makeResponsiveComponent, parseNumberInputValueToNumber, parseNumberValueToNumberInput, tooltipsHandler, useAccordionContext, useModal, useOtherTagButton, useTooltip };
6178
+ export { Accordion, AccordionContext, AccordionItem, AccordionItemButton, AccordionItemContent, AccordionItemContext, AlertModal, ApiaFilter, AutoEllipsis, BaseButton, CalendarModal, Captcha, Checkbox$1 as Checkbox, CollapsiblePanel, Confirm, ConfirmModal, DateInput, DefaultIconRenderer, DialogButtonBar, FieldErrorMessage, FieldLabel, IconButton, IconInput, IconsList, LinearLoader, Listbox, ListboxItem, LoaderSpinner, Modal, NumberInput, Overlay, ProgressBar, RequiredMark, ScreenLock, SimpleButton, Toolbar, ToolbarController, ToolbarItem, Tooltip, TooltipsProvider, WaiTypeAhead, getFieldErrorStyles, getFieldTouchedStyles, importComponent, makeResponsiveComponent, parseNumberInputValueToNumber, parseNumberValueToNumberInput, tooltipsHandler, useAccordionContext, useModal, useModalContext, useOtherTagButton, useTooltip };