@northlight/ui 2.12.2 → 2.12.3

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.
@@ -454,8 +454,8 @@
454
454
  };
455
455
 
456
456
  var __defProp$25 = Object.defineProperty;
457
- var __defProps$y = Object.defineProperties;
458
- var __getOwnPropDescs$y = Object.getOwnPropertyDescriptors;
457
+ var __defProps$z = Object.defineProperties;
458
+ var __getOwnPropDescs$z = Object.getOwnPropertyDescriptors;
459
459
  var __getOwnPropSymbols$25 = Object.getOwnPropertySymbols;
460
460
  var __hasOwnProp$25 = Object.prototype.hasOwnProperty;
461
461
  var __propIsEnum$25 = Object.prototype.propertyIsEnumerable;
@@ -471,43 +471,43 @@
471
471
  }
472
472
  return a;
473
473
  };
474
- var __spreadProps$y = (a, b) => __defProps$y(a, __getOwnPropDescs$y(b));
474
+ var __spreadProps$z = (a, b) => __defProps$z(a, __getOwnPropDescs$z(b));
475
475
  const customSelectStyles = {
476
- container: (provided) => __spreadProps$y(__spreadValues$25({}, provided), {
476
+ container: (provided) => __spreadProps$z(__spreadValues$25({}, provided), {
477
477
  width: "100%",
478
478
  color: "text.default"
479
479
  }),
480
- option: (provided, state) => __spreadProps$y(__spreadValues$25({}, provided), {
480
+ option: (provided, state) => __spreadProps$z(__spreadValues$25({}, provided), {
481
481
  background: state.isFocused && "background.select.option-focus",
482
482
  _active: {
483
483
  background: "background.select.option-active"
484
484
  }
485
485
  }),
486
- valueContainer: (provided) => __spreadProps$y(__spreadValues$25({}, provided), {
486
+ valueContainer: (provided) => __spreadProps$z(__spreadValues$25({}, provided), {
487
487
  paddingInlineStart: "padding-inline.select.default"
488
488
  }),
489
- downChevron: (provided) => __spreadProps$y(__spreadValues$25({}, provided), {
489
+ downChevron: (provided) => __spreadProps$z(__spreadValues$25({}, provided), {
490
490
  color: "icon.select.default"
491
491
  }),
492
- placeholder: (provided) => __spreadProps$y(__spreadValues$25({}, provided), {
492
+ placeholder: (provided) => __spreadProps$z(__spreadValues$25({}, provided), {
493
493
  color: "text.select.placeholder"
494
494
  }),
495
495
  multiValue: (provided, state) => {
496
496
  var _a;
497
497
  const background = state.data.isFixed ? "background.select.option-disabled" : (_a = state.data.color) != null ? _a : provided.bgColor;
498
- return __spreadProps$y(__spreadValues$25({}, provided), {
498
+ return __spreadProps$z(__spreadValues$25({}, provided), {
499
499
  bgColor: background,
500
500
  color: getContrastColor(background)
501
501
  });
502
502
  },
503
- menuList: (provided) => __spreadProps$y(__spreadValues$25({}, provided), {
503
+ menuList: (provided) => __spreadProps$z(__spreadValues$25({}, provided), {
504
504
  bgColor: "background.default"
505
505
  })
506
506
  };
507
507
 
508
508
  var __defProp$24 = Object.defineProperty;
509
- var __defProps$x = Object.defineProperties;
510
- var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
509
+ var __defProps$y = Object.defineProperties;
510
+ var __getOwnPropDescs$y = Object.getOwnPropertyDescriptors;
511
511
  var __getOwnPropSymbols$24 = Object.getOwnPropertySymbols;
512
512
  var __hasOwnProp$24 = Object.prototype.hasOwnProperty;
513
513
  var __propIsEnum$24 = Object.prototype.propertyIsEnumerable;
@@ -523,9 +523,9 @@
523
523
  }
524
524
  return a;
525
525
  };
526
- var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
527
- const tagsInputStyles = (isFocused, borderColor) => __spreadProps$x(__spreadValues$24({}, customSelectStyles), {
528
- container: (provided) => __spreadProps$x(__spreadValues$24({}, provided), {
526
+ var __spreadProps$y = (a, b) => __defProps$y(a, __getOwnPropDescs$y(b));
527
+ const tagsInputStyles = (isFocused, borderColor) => __spreadProps$y(__spreadValues$24({}, customSelectStyles), {
528
+ container: (provided) => __spreadProps$y(__spreadValues$24({}, provided), {
529
529
  w: "full",
530
530
  height: "100%",
531
531
  resize: "vertical",
@@ -538,12 +538,12 @@
538
538
  color: "text.default",
539
539
  boxShadow: isFocused ? `0 0 0 1px ${borderColor}` : "none"
540
540
  }),
541
- control: (provided) => __spreadProps$x(__spreadValues$24({}, provided), {
541
+ control: (provided) => __spreadProps$y(__spreadValues$24({}, provided), {
542
542
  minHeight: "20",
543
543
  height: "100%",
544
544
  alignItems: "start"
545
545
  }),
546
- valueContainer: (provided) => __spreadProps$x(__spreadValues$24({}, provided), {
546
+ valueContainer: (provided) => __spreadProps$y(__spreadValues$24({}, provided), {
547
547
  paddingInlineStart: "padding-inline.select.default",
548
548
  overflowY: "auto",
549
549
  maxH: "100%"
@@ -551,8 +551,8 @@
551
551
  });
552
552
 
553
553
  var __defProp$23 = Object.defineProperty;
554
- var __defProps$w = Object.defineProperties;
555
- var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
554
+ var __defProps$x = Object.defineProperties;
555
+ var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
556
556
  var __getOwnPropSymbols$23 = Object.getOwnPropertySymbols;
557
557
  var __hasOwnProp$23 = Object.prototype.hasOwnProperty;
558
558
  var __propIsEnum$23 = Object.prototype.propertyIsEnumerable;
@@ -568,7 +568,7 @@
568
568
  }
569
569
  return a;
570
570
  };
571
- var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
571
+ var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
572
572
  var __objRest$1w = (source, exclude) => {
573
573
  var target = {};
574
574
  for (var prop in source)
@@ -657,7 +657,7 @@
657
657
  };
658
658
  return /* @__PURE__ */ React.createElement(react.Box, { w: "full", "data-testid": testId }, /* @__PURE__ */ React.createElement(
659
659
  CustomSelect,
660
- __spreadValues$23(__spreadProps$w(__spreadValues$23({
660
+ __spreadValues$23(__spreadProps$x(__spreadValues$23({
661
661
  isMulti: true,
662
662
  menuPortalTarget: document.body,
663
663
  placeholder: "Type something and press Enter or comma...",
@@ -1511,7 +1511,7 @@
1511
1511
  }
1512
1512
  return target;
1513
1513
  };
1514
- const Label$1 = (_a) => {
1514
+ const Label$1 = React.forwardRef((_a, ref) => {
1515
1515
  var _b = _a, {
1516
1516
  children,
1517
1517
  size = "sm",
@@ -1526,11 +1526,12 @@
1526
1526
  react.FormLabel,
1527
1527
  __spreadValues$1N({
1528
1528
  sx: styles,
1529
- requiredIndicator: /* @__PURE__ */ React.createElement(react.VisuallyHidden, null)
1529
+ requiredIndicator: /* @__PURE__ */ React.createElement(react.VisuallyHidden, null),
1530
+ ref
1530
1531
  }, rest),
1531
1532
  children
1532
1533
  );
1533
- };
1534
+ });
1534
1535
 
1535
1536
  const positiveOrZero = ramda.ifElse(ramda.gt(0), ramda.always(0), ramda.identity);
1536
1537
  const EMPTY_RECT = {
@@ -1903,6 +1904,8 @@
1903
1904
  });
1904
1905
 
1905
1906
  var __defProp$1G = Object.defineProperty;
1907
+ var __defProps$w = Object.defineProperties;
1908
+ var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
1906
1909
  var __getOwnPropSymbols$1G = Object.getOwnPropertySymbols;
1907
1910
  var __hasOwnProp$1G = Object.prototype.hasOwnProperty;
1908
1911
  var __propIsEnum$1G = Object.prototype.propertyIsEnumerable;
@@ -1918,6 +1921,7 @@
1918
1921
  }
1919
1922
  return a;
1920
1923
  };
1924
+ var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
1921
1925
  var __objRest$19 = (source, exclude) => {
1922
1926
  var target = {};
1923
1927
  for (var prop in source)
@@ -1930,7 +1934,7 @@
1930
1934
  }
1931
1935
  return target;
1932
1936
  };
1933
- const FormLabel = (_a) => {
1937
+ const FormLabel = React.forwardRef((_a, ref) => {
1934
1938
  var _b = _a, {
1935
1939
  children: label
1936
1940
  } = _b, rest = __objRest$19(_b, [
@@ -1938,7 +1942,7 @@
1938
1942
  ]);
1939
1943
  return /* @__PURE__ */ React.createElement(
1940
1944
  Label$1,
1941
- __spreadValues$1G({
1945
+ __spreadProps$w(__spreadValues$1G({
1942
1946
  size: "sm",
1943
1947
  sx: {
1944
1948
  width: "80%",
@@ -1947,10 +1951,12 @@
1947
1951
  marginInlineEnd: 3
1948
1952
  },
1949
1953
  requiredIndicator: void 0
1950
- }, rest),
1954
+ }, rest), {
1955
+ ref
1956
+ }),
1951
1957
  label
1952
1958
  );
1953
- };
1959
+ });
1954
1960
 
1955
1961
  var __defProp$1F = Object.defineProperty;
1956
1962
  var __getOwnPropSymbols$1F = Object.getOwnPropertySymbols;
@@ -1980,7 +1986,7 @@
1980
1986
  }
1981
1987
  return target;
1982
1988
  };
1983
- function Field(_a) {
1989
+ const BaseField = (_a, ref) => {
1984
1990
  var _b = _a, {
1985
1991
  name,
1986
1992
  label,
@@ -2004,7 +2010,7 @@
2004
2010
  const { formState: { errors } } = methods;
2005
2011
  const control = passedControl != null ? passedControl : methods.control;
2006
2012
  const fieldError = getFieldError(name, errors);
2007
- return /* @__PURE__ */ React.createElement(react.FormControl, { isInvalid: !!fieldError, isRequired }, /* @__PURE__ */ React.createElement(
2013
+ return /* @__PURE__ */ React.createElement(react.FormControl, { isInvalid: !!fieldError, isRequired, ref }, /* @__PURE__ */ React.createElement(
2008
2014
  react.Stack,
2009
2015
  __spreadValues$1F({
2010
2016
  spacing: "auto",
@@ -2022,7 +2028,8 @@
2022
2028
  }
2023
2029
  )
2024
2030
  ), /* @__PURE__ */ React.createElement(react.FormErrorMessage, null, fieldError && (fieldError == null ? void 0 : fieldError.message)));
2025
- }
2031
+ };
2032
+ const Field = React.forwardRef(BaseField);
2026
2033
 
2027
2034
  const useSetValueRefreshed = () => {
2028
2035
  const { setValue, watch } = reactHookForm.useFormContext();
@@ -2061,7 +2068,7 @@
2061
2068
  }
2062
2069
  return target;
2063
2070
  };
2064
- const CheckboxField = (_a) => {
2071
+ const CheckboxField = React.forwardRef((_a, ref) => {
2065
2072
  var _b = _a, {
2066
2073
  name,
2067
2074
  label,
@@ -2096,7 +2103,8 @@
2096
2103
  label: "",
2097
2104
  isRequired,
2098
2105
  direction,
2099
- validate
2106
+ validate,
2107
+ ref
2100
2108
  },
2101
2109
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
2102
2110
  react.Flex,
@@ -2121,7 +2129,7 @@
2121
2129
  )
2122
2130
  )
2123
2131
  );
2124
- };
2132
+ });
2125
2133
 
2126
2134
  var __defProp$1D = Object.defineProperty;
2127
2135
  var __getOwnPropSymbols$1D = Object.getOwnPropertySymbols;
@@ -2727,7 +2735,7 @@
2727
2735
  }
2728
2736
  return target;
2729
2737
  };
2730
- const FlipButtonGroupField = (_a) => {
2738
+ const FlipButtonGroupField = React.forwardRef((_a, ref) => {
2731
2739
  var _b = _a, {
2732
2740
  name,
2733
2741
  label,
@@ -2754,7 +2762,8 @@
2754
2762
  label,
2755
2763
  direction,
2756
2764
  isRequired,
2757
- validate
2765
+ validate,
2766
+ ref
2758
2767
  },
2759
2768
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
2760
2769
  FlipButtonGroup,
@@ -2771,7 +2780,7 @@
2771
2780
  children
2772
2781
  )
2773
2782
  );
2774
- };
2783
+ });
2775
2784
 
2776
2785
  var __defProp$1w = Object.defineProperty;
2777
2786
  var __defProps$s = Object.defineProperties;
@@ -3364,13 +3373,20 @@
3364
3373
  dateFormat
3365
3374
  })
3366
3375
  )
3367
- )), /* @__PURE__ */ React.createElement(react.InputRightElement, { zIndex: 0 }, /* @__PURE__ */ React.createElement(
3368
- Trigger,
3369
- __spreadProps$l(__spreadValues$1n({}, buttonProps), {
3370
- isDisabled,
3371
- handleClick: togglePopup
3372
- })
3373
- ))), /* @__PURE__ */ React.createElement(
3376
+ )), /* @__PURE__ */ React.createElement(
3377
+ react.InputRightElement,
3378
+ {
3379
+ sx: { height: "100%", paddingRight: "1" },
3380
+ zIndex: 0
3381
+ },
3382
+ /* @__PURE__ */ React.createElement(
3383
+ Trigger,
3384
+ __spreadProps$l(__spreadValues$1n({}, buttonProps), {
3385
+ isDisabled,
3386
+ handleClick: togglePopup
3387
+ })
3388
+ )
3389
+ )), /* @__PURE__ */ React.createElement(
3374
3390
  IconButton,
3375
3391
  {
3376
3392
  "aria-label": "reset-date",
@@ -4664,7 +4680,7 @@
4664
4680
  dateFormat
4665
4681
  })
4666
4682
  )
4667
- )), /* @__PURE__ */ React.createElement(react.InputRightElement, null, /* @__PURE__ */ React.createElement(
4683
+ )), /* @__PURE__ */ React.createElement(react.InputRightElement, { sx: { height: "100%", paddingRight: "1" } }, /* @__PURE__ */ React.createElement(
4668
4684
  Trigger,
4669
4685
  __spreadProps$f(__spreadValues$1a({}, buttonProps), {
4670
4686
  isDisabled,
@@ -4775,7 +4791,7 @@
4775
4791
  }
4776
4792
  return target;
4777
4793
  };
4778
- const DatePickerField = (_a) => {
4794
+ const DatePickerField = React.forwardRef((_a, ref) => {
4779
4795
  var _b = _a, {
4780
4796
  name,
4781
4797
  minValue,
@@ -4821,7 +4837,8 @@
4821
4837
  label,
4822
4838
  direction,
4823
4839
  isRequired,
4824
- validate
4840
+ validate,
4841
+ ref
4825
4842
  },
4826
4843
  ({ value, onChange }, { formState: { errors } }) => /* @__PURE__ */ React.createElement(
4827
4844
  InputGroupWrapper,
@@ -4845,7 +4862,7 @@
4845
4862
  )
4846
4863
  )
4847
4864
  );
4848
- };
4865
+ });
4849
4866
 
4850
4867
  var __defProp$17 = Object.defineProperty;
4851
4868
  var __getOwnPropSymbols$17 = Object.getOwnPropertySymbols;
@@ -4875,7 +4892,7 @@
4875
4892
  }
4876
4893
  return target;
4877
4894
  };
4878
- const DateRangePickerField = (_a) => {
4895
+ const DateRangePickerField = React.forwardRef((_a, ref) => {
4879
4896
  var _b = _a, {
4880
4897
  name,
4881
4898
  minValue,
@@ -4919,7 +4936,8 @@
4919
4936
  label,
4920
4937
  direction,
4921
4938
  isRequired,
4922
- validate
4939
+ validate,
4940
+ ref
4923
4941
  },
4924
4942
  ({ value, onChange }, { formState: { errors } }) => /* @__PURE__ */ React.createElement(
4925
4943
  DateRangePicker,
@@ -4937,7 +4955,7 @@
4937
4955
  }, rest)
4938
4956
  )
4939
4957
  );
4940
- };
4958
+ });
4941
4959
 
4942
4960
  var __defProp$16 = Object.defineProperty;
4943
4961
  var __defProps$e = Object.defineProperties;
@@ -5302,7 +5320,7 @@
5302
5320
  }
5303
5321
  return target;
5304
5322
  };
5305
- const RadioGroupField = (_a) => {
5323
+ const RadioGroupField = React.forwardRef((_a, ref) => {
5306
5324
  var _b = _a, {
5307
5325
  name,
5308
5326
  label,
@@ -5327,7 +5345,8 @@
5327
5345
  label,
5328
5346
  direction,
5329
5347
  isRequired,
5330
- validate
5348
+ validate,
5349
+ ref
5331
5350
  },
5332
5351
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
5333
5352
  RadioGroup,
@@ -5344,7 +5363,7 @@
5344
5363
  children
5345
5364
  )
5346
5365
  ));
5347
- };
5366
+ });
5348
5367
 
5349
5368
  const carouselItemWidth = 150;
5350
5369
  const carouselItemSpacing = 60;
@@ -5824,7 +5843,7 @@
5824
5843
  }
5825
5844
  return target;
5826
5845
  };
5827
- const SearchBarField = (_a) => {
5846
+ const BaseSearchBarField = (_a, ref) => {
5828
5847
  var _b = _a, {
5829
5848
  name,
5830
5849
  label,
@@ -5856,7 +5875,8 @@
5856
5875
  direction,
5857
5876
  isRequired,
5858
5877
  noLabelConnection: true,
5859
- validate
5878
+ validate,
5879
+ ref
5860
5880
  },
5861
5881
  ({ value, onChange }) => /* @__PURE__ */ React.createElement(react.HStack, { w: "full" }, /* @__PURE__ */ React.createElement(
5862
5882
  InputGroupWrapper,
@@ -5892,6 +5912,7 @@
5892
5912
  ))
5893
5913
  );
5894
5914
  };
5915
+ const SearchBarField = React.forwardRef(BaseSearchBarField);
5895
5916
 
5896
5917
  var __defProp$V = Object.defineProperty;
5897
5918
  var __getOwnPropSymbols$V = Object.getOwnPropertySymbols;
@@ -6799,7 +6820,7 @@
6799
6820
  "leftItem"
6800
6821
  ]);
6801
6822
  const [value, setValue] = React.useState(inputValue);
6802
- const { input, preview } = react.useMultiStyleConfig("EditableText", { size });
6823
+ const { input, preview } = react.useMultiStyleConfig("EditableText", { size, value });
6803
6824
  React.useEffect(() => {
6804
6825
  setValue(inputValue);
6805
6826
  }, [inputValue]);
@@ -10505,7 +10526,7 @@
10505
10526
  }
10506
10527
  })
10507
10528
  },
10508
- baseStyle: {
10529
+ baseStyle: ({ value }) => ({
10509
10530
  controls: {
10510
10531
  mr: 1
10511
10532
  },
@@ -10515,12 +10536,13 @@
10515
10536
  whiteSpace: "nowrap",
10516
10537
  overflow: "hidden",
10517
10538
  paddingTop: 0,
10518
- paddingBottom: 0
10539
+ paddingBottom: 0,
10540
+ color: ramda.isNil(value) || ramda.isEmpty(value) ? "text.subdued" : "text.default"
10519
10541
  },
10520
10542
  input: {
10521
10543
  fontWeight: "semibold"
10522
10544
  }
10523
- }
10545
+ })
10524
10546
  };
10525
10547
 
10526
10548
  const Toolbox = {
@@ -10892,7 +10914,7 @@
10892
10914
 
10893
10915
  const NumberInputStepper = ({
10894
10916
  includePercentage = false
10895
- }) => /* @__PURE__ */ React.createElement(react.NumberInputStepper, null, /* @__PURE__ */ React.createElement(react.HStack, { alignItems: "center", h: "full" }, includePercentage && /* @__PURE__ */ React.createElement(react.Center, { bgColor: "gray.50", borderRadius: "md", boxSize: "6" }, /* @__PURE__ */ React.createElement(P$1, null, "%")), /* @__PURE__ */ React.createElement(react.Divider, { orientation: "vertical", h: "50%" }), /* @__PURE__ */ React.createElement(react.NumberIncrementStepper, { border: "none" }, /* @__PURE__ */ React.createElement(
10917
+ }) => /* @__PURE__ */ React.createElement(react.NumberInputStepper, null, /* @__PURE__ */ React.createElement(react.HStack, { alignItems: "center", h: "full" }, includePercentage && /* @__PURE__ */ React.createElement(react.Center, { bgColor: "gray.50", borderRadius: "md", boxSize: "6" }, /* @__PURE__ */ React.createElement(P$1, null, "%")), /* @__PURE__ */ React.createElement(react.HStack, { alignItems: "center", h: "full" }, /* @__PURE__ */ React.createElement(react.Divider, { orientation: "vertical", h: "50%" }), /* @__PURE__ */ React.createElement(react.NumberIncrementStepper, { border: "none" }, /* @__PURE__ */ React.createElement(
10896
10918
  Icon$1,
10897
10919
  {
10898
10920
  as: icons.ChevronUpSolid,
@@ -10906,7 +10928,7 @@
10906
10928
  color: "icon.input-stepper.default",
10907
10929
  boxSize: 4
10908
10930
  }
10909
- ))));
10931
+ )))));
10910
10932
 
10911
10933
  const regex = /(9{13,}|0{13,})(\d)*$/gm;
10912
10934
  const advancedParseFloat = (value) => {
@@ -11028,7 +11050,7 @@
11028
11050
  }
11029
11051
  return target;
11030
11052
  };
11031
- const NumberInputField = (_a) => {
11053
+ const NumberInputField = React.forwardRef((_a, ref) => {
11032
11054
  var _b = _a, {
11033
11055
  name,
11034
11056
  label,
@@ -11058,7 +11080,8 @@
11058
11080
  label,
11059
11081
  direction,
11060
11082
  isRequired,
11061
- validate
11083
+ validate,
11084
+ ref
11062
11085
  },
11063
11086
  ({ onChange, value }) => {
11064
11087
  const initialValue = ramda.isNil(value) || Number.isNaN(parseFloat(value)) ? "" : formatNumber(value, 100);
@@ -11087,7 +11110,7 @@
11087
11110
  );
11088
11111
  }
11089
11112
  );
11090
- };
11113
+ });
11091
11114
 
11092
11115
  var __defProp$o = Object.defineProperty;
11093
11116
  var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
@@ -11214,6 +11237,49 @@
11214
11237
  return value;
11215
11238
  };
11216
11239
 
11240
+ const useAdaptiveMenuPlacement = ({
11241
+ dropdownHeightPx,
11242
+ containerRef
11243
+ }) => {
11244
+ const [menuPlacement, setMenuPlacement] = React.useState("bottom");
11245
+ const selectContainerRef = React.useRef(null);
11246
+ const adjustMenuPlacement = () => {
11247
+ if (ramda.isNil(selectContainerRef.current))
11248
+ return;
11249
+ let node = selectContainerRef.current.parentNode;
11250
+ while (node.parentNode) {
11251
+ const { overflowY, maxHeight, height } = getComputedStyle(node);
11252
+ if (overflowY !== "visible" || maxHeight || height)
11253
+ break;
11254
+ node = node.parentNode;
11255
+ }
11256
+ const selectRect = selectContainerRef.current.getBoundingClientRect();
11257
+ const containerRect = containerRef && containerRef.current ? containerRef.current.getBoundingClientRect() : node.getBoundingClientRect();
11258
+ const pxToContainerBottom = Math.abs(
11259
+ selectRect.bottom - containerRect.bottom
11260
+ );
11261
+ const pxToContainerTop = Math.abs(selectRect.top - containerRect.top);
11262
+ const pxToWindowBottom = Math.abs(selectRect.bottom - window.innerHeight);
11263
+ const shouldBeAtTop = dropdownHeightPx > pxToContainerBottom && pxToContainerTop > pxToContainerBottom || dropdownHeightPx > pxToWindowBottom && selectRect.top > pxToWindowBottom;
11264
+ setMenuPlacement(shouldBeAtTop ? "top" : "bottom");
11265
+ };
11266
+ React.useEffect(() => {
11267
+ adjustMenuPlacement();
11268
+ window.addEventListener("resize", adjustMenuPlacement);
11269
+ window.addEventListener("scroll", adjustMenuPlacement);
11270
+ return () => {
11271
+ window.removeEventListener("resize", adjustMenuPlacement);
11272
+ window.addEventListener("scroll", adjustMenuPlacement);
11273
+ };
11274
+ }, []);
11275
+ return { selectContainerRef, menuPlacement };
11276
+ };
11277
+
11278
+ const DROPDOWN_MAX_HEIGHT = 300;
11279
+ const DROPDOWN_MIN_HEIGHT = 55;
11280
+ const DROPDOWN_OPTION_HEIGHT = 37;
11281
+ const DROPDOWN_PADDING = 30;
11282
+
11217
11283
  var __defProp$m = Object.defineProperty;
11218
11284
  var __defProps$3 = Object.defineProperties;
11219
11285
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
@@ -11258,7 +11324,9 @@
11258
11324
  customOption = null,
11259
11325
  customTag = null,
11260
11326
  value,
11261
- icon
11327
+ icon,
11328
+ containerRef,
11329
+ dropdownMinHeightPx = DROPDOWN_MIN_HEIGHT
11262
11330
  } = _b, rest = __objRest$h(_b, [
11263
11331
  "options",
11264
11332
  "isMulti",
@@ -11271,7 +11339,9 @@
11271
11339
  "customOption",
11272
11340
  "customTag",
11273
11341
  "value",
11274
- "icon"
11342
+ "icon",
11343
+ "containerRef",
11344
+ "dropdownMinHeightPx"
11275
11345
  ]);
11276
11346
  const handleChange = useSelectCallbacks({
11277
11347
  onChange,
@@ -11293,7 +11363,18 @@
11293
11363
  }
11294
11364
  return prevOptions.current;
11295
11365
  }, [options]);
11296
- return /* @__PURE__ */ React.createElement(react.Box, { w: "full", "data-testid": testId }, /* @__PURE__ */ React.createElement(
11366
+ const dropdownHeightPx = Math.max(
11367
+ Math.min(
11368
+ ramda.length(options || []) * DROPDOWN_OPTION_HEIGHT + DROPDOWN_PADDING,
11369
+ DROPDOWN_MAX_HEIGHT
11370
+ ),
11371
+ dropdownMinHeightPx
11372
+ );
11373
+ const { selectContainerRef, menuPlacement } = useAdaptiveMenuPlacement({
11374
+ dropdownHeightPx,
11375
+ containerRef
11376
+ });
11377
+ return /* @__PURE__ */ React.createElement(react.Box, { w: "full", "data-testid": testId, "data-role": "select-container", ref: selectContainerRef }, /* @__PURE__ */ React.createElement(
11297
11378
  chakraReactSelect.Select,
11298
11379
  __spreadValues$m(__spreadProps$3(__spreadValues$m({
11299
11380
  isMulti,
@@ -11311,6 +11392,7 @@
11311
11392
  customOption,
11312
11393
  customTag,
11313
11394
  icon,
11395
+ menuPlacement,
11314
11396
  components: customComponents,
11315
11397
  ref
11316
11398
  }), rest)
@@ -11345,7 +11427,7 @@
11345
11427
  }
11346
11428
  return target;
11347
11429
  };
11348
- function SelectField(_a) {
11430
+ const BaseSelectField = (_a, ref) => {
11349
11431
  var _b = _a, {
11350
11432
  name,
11351
11433
  label,
@@ -11379,7 +11461,8 @@
11379
11461
  direction,
11380
11462
  isRequired,
11381
11463
  noLabelConnection: true,
11382
- validate
11464
+ validate,
11465
+ ref
11383
11466
  },
11384
11467
  ({ value, onChange }) => /* @__PURE__ */ React.createElement(react.HStack, { w: "full" }, /* @__PURE__ */ React.createElement(
11385
11468
  InputGroupWrapper,
@@ -11417,7 +11500,8 @@
11417
11500
  }
11418
11501
  ))
11419
11502
  );
11420
- }
11503
+ };
11504
+ const SelectField = React.forwardRef(BaseSelectField);
11421
11505
 
11422
11506
  var __defProp$k = Object.defineProperty;
11423
11507
  var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
@@ -11498,7 +11582,7 @@
11498
11582
  }
11499
11583
  return target;
11500
11584
  };
11501
- const SwitchField = (_a) => {
11585
+ const SwitchField = React.forwardRef((_a, ref) => {
11502
11586
  var _b = _a, {
11503
11587
  name,
11504
11588
  label,
@@ -11506,7 +11590,8 @@
11506
11590
  validate,
11507
11591
  onChange: onChangeCallback = ramda.identity,
11508
11592
  direction = "row",
11509
- labelPosition = "right"
11593
+ labelPlacement = "right",
11594
+ labelSize = "md"
11510
11595
  } = _b, rest = __objRest$e(_b, [
11511
11596
  "name",
11512
11597
  "label",
@@ -11514,22 +11599,26 @@
11514
11599
  "validate",
11515
11600
  "onChange",
11516
11601
  "direction",
11517
- "labelPosition"
11602
+ "labelPlacement",
11603
+ "labelSize"
11518
11604
  ]);
11519
- return /* @__PURE__ */ React.createElement(react.Box, { w: label ? "full" : "fit-content" }, /* @__PURE__ */ React.createElement(
11605
+ return /* @__PURE__ */ React.createElement(react.Box, { w: label ? "full" : "fit-content", display: "inline-flex" }, /* @__PURE__ */ React.createElement(
11520
11606
  Field,
11521
11607
  {
11522
11608
  name,
11523
11609
  label: "",
11524
11610
  isRequired,
11525
11611
  direction,
11526
- validate
11612
+ validate,
11613
+ ref
11527
11614
  },
11528
11615
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
11529
11616
  react.Flex,
11530
11617
  {
11618
+ display: "inline-flex",
11619
+ alignItems: "center",
11531
11620
  gap: 2,
11532
- direction: labelPosition === "left" ? "row-reverse" : "row"
11621
+ direction: labelPlacement === "left" ? "row-reverse" : "row"
11533
11622
  },
11534
11623
  /* @__PURE__ */ React.createElement(
11535
11624
  Switch,
@@ -11543,10 +11632,10 @@
11543
11632
  "data-testid": "switch-field-test-id"
11544
11633
  }, rest)
11545
11634
  ),
11546
- label && /* @__PURE__ */ React.createElement(Label$1, { htmlFor: name }, label)
11635
+ /* @__PURE__ */ React.createElement(Label$1, { htmlFor: name, sx: { fontWeight: "normal" }, size: labelSize }, label)
11547
11636
  )
11548
11637
  ));
11549
- };
11638
+ });
11550
11639
 
11551
11640
  var __defProp$i = Object.defineProperty;
11552
11641
  var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
@@ -11693,7 +11782,7 @@
11693
11782
  }
11694
11783
  return target;
11695
11784
  };
11696
- const TextareaField = (_a) => {
11785
+ const TextareaField = React.forwardRef((_a, ref) => {
11697
11786
  var _b = _a, {
11698
11787
  name,
11699
11788
  label,
@@ -11716,7 +11805,8 @@
11716
11805
  label,
11717
11806
  isRequired,
11718
11807
  validate,
11719
- direction
11808
+ direction,
11809
+ ref
11720
11810
  },
11721
11811
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
11722
11812
  Textarea,
@@ -11731,7 +11821,7 @@
11731
11821
  }, rest)
11732
11822
  )
11733
11823
  );
11734
- };
11824
+ });
11735
11825
 
11736
11826
  const roundToPrecision = (value, numberOfDecimals) => parseFloat(value.toFixed(numberOfDecimals));
11737
11827
 
@@ -11788,7 +11878,9 @@
11788
11878
  value,
11789
11879
  numberOfDecimals = 2,
11790
11880
  max = Infinity,
11791
- min = -Infinity
11881
+ min = -Infinity,
11882
+ inputLeftElement,
11883
+ inputRightElement
11792
11884
  } = _b, rest = __objRest$a(_b, [
11793
11885
  "preset",
11794
11886
  "isPercentage",
@@ -11796,33 +11888,54 @@
11796
11888
  "value",
11797
11889
  "numberOfDecimals",
11798
11890
  "max",
11799
- "min"
11891
+ "min",
11892
+ "inputLeftElement",
11893
+ "inputRightElement"
11800
11894
  ]);
11801
11895
  const props = presetMap[preset];
11896
+ const [v, setV] = React.useState(value);
11897
+ const validateRange = () => {
11898
+ if (ramda.isNil(v))
11899
+ return;
11900
+ const vNum = typeof v === "string" ? parseFloat(v) : v;
11901
+ const factor = isPercentage ? 100 : 1;
11902
+ if (vNum * factor > max) {
11903
+ const newValue = roundToPrecision(max / factor, numberOfDecimals);
11904
+ setV(newValue);
11905
+ }
11906
+ if (vNum * factor < min) {
11907
+ const newValue = roundToPrecision(min / factor, numberOfDecimals);
11908
+ setV(newValue);
11909
+ }
11910
+ };
11802
11911
  const onValueChangeHandler = (values, sourceInfo) => {
11912
+ const newFloatValue = values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, numberOfDecimals) : values.floatValue;
11913
+ setV(newFloatValue);
11803
11914
  onChange(
11804
11915
  __spreadProps$2(__spreadValues$e({}, values), {
11805
- floatValue: values.floatValue && isPercentage ? roundToPrecision(values.floatValue / 100, numberOfDecimals) : values.floatValue
11916
+ floatValue: newFloatValue
11806
11917
  }),
11807
11918
  sourceInfo
11808
11919
  );
11809
11920
  };
11810
11921
  return /* @__PURE__ */ React.createElement(
11811
- reactNumberFormat.NumericFormat,
11812
- __spreadValues$e(__spreadValues$e({
11813
- allowLeadingZeros: true,
11814
- customInput: react.Input,
11815
- max: 100,
11816
- min: 0,
11817
- onValueChange: onValueChangeHandler,
11818
- decimalScale: numberOfDecimals,
11819
- value: isPercentage ? roundToPrecision(parseFloat(`${value != null ? value : 0}`) * 100, numberOfDecimals) : value,
11820
- suffix: isPercentage ? "%" : "",
11821
- isAllowed: (values) => {
11822
- const { floatValue } = values;
11823
- return floatValue ? floatValue < max && floatValue > min : false;
11824
- }
11825
- }, props), rest)
11922
+ InputGroupWrapper,
11923
+ {
11924
+ inputLeftElement,
11925
+ inputRightElement
11926
+ },
11927
+ /* @__PURE__ */ React.createElement(
11928
+ reactNumberFormat.NumericFormat,
11929
+ __spreadValues$e(__spreadValues$e({
11930
+ allowLeadingZeros: true,
11931
+ customInput: react.Input,
11932
+ onBlur: validateRange,
11933
+ onValueChange: onValueChangeHandler,
11934
+ decimalScale: numberOfDecimals,
11935
+ value: isPercentage ? roundToPrecision(parseFloat(`${v != null ? v : 0}`) * 100, numberOfDecimals) : v,
11936
+ suffix: isPercentage ? "%" : ""
11937
+ }, props), rest)
11938
+ )
11826
11939
  );
11827
11940
  };
11828
11941
 
@@ -11854,7 +11967,7 @@
11854
11967
  }
11855
11968
  return target;
11856
11969
  };
11857
- const FormattedNumberInputField = (_a) => {
11970
+ const FormattedNumberInputField = React.forwardRef((_a, ref) => {
11858
11971
  var _b = _a, {
11859
11972
  name,
11860
11973
  label,
@@ -11877,7 +11990,8 @@
11877
11990
  label,
11878
11991
  isRequired,
11879
11992
  direction,
11880
- validate
11993
+ validate,
11994
+ ref
11881
11995
  },
11882
11996
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
11883
11997
  FormattedNumberInput,
@@ -11891,7 +12005,7 @@
11891
12005
  }, rest)
11892
12006
  )
11893
12007
  );
11894
- };
12008
+ });
11895
12009
 
11896
12010
  var __defProp$c = Object.defineProperty;
11897
12011
  var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
@@ -11992,7 +12106,7 @@
11992
12106
  }
11993
12107
  return target;
11994
12108
  };
11995
- const TextField = (_a) => {
12109
+ const TextField = React.forwardRef((_a, ref) => {
11996
12110
  var _b = _a, {
11997
12111
  name,
11998
12112
  label,
@@ -12021,7 +12135,8 @@
12021
12135
  label,
12022
12136
  isRequired,
12023
12137
  validate: ramda.isNil(validate) && isRequired ? { validate: (value) => !!value.trim() } : validate,
12024
- direction
12138
+ direction,
12139
+ ref
12025
12140
  },
12026
12141
  ({ onChange, value }) => /* @__PURE__ */ React.createElement(
12027
12142
  InputGroupWrapper,
@@ -12044,7 +12159,7 @@
12044
12159
  )
12045
12160
  )
12046
12161
  );
12047
- };
12162
+ });
12048
12163
 
12049
12164
  const toastIconMap = {
12050
12165
  success: icons.CheckCircleSolid,