@thecb/components 10.12.0 → 10.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -6241,7 +6241,7 @@ return numeral;
6241
6241
  }));
6242
6242
  });
6243
6243
 
6244
- var noop = function noop() {};
6244
+ var noop$1 = function noop() {};
6245
6245
  var formatMoneyString = function formatMoneyString(s) {
6246
6246
  return numeral(s).format("$0,0.00");
6247
6247
  };
@@ -6375,7 +6375,7 @@ var wrapIndex = function wrapIndex(index, length) {
6375
6375
 
6376
6376
  var general = /*#__PURE__*/Object.freeze({
6377
6377
  __proto__: null,
6378
- noop: noop,
6378
+ noop: noop$1,
6379
6379
  displayCurrency: displayCurrency,
6380
6380
  convertCentsToMoneyInt: convertCentsToMoneyInt,
6381
6381
  formatPercent: formatPercent,
@@ -10567,7 +10567,7 @@ var isRefObject = function (ref) {
10567
10567
  return typeof ref === "object" && ref.hasOwnProperty("current");
10568
10568
  };
10569
10569
 
10570
- var noop$1 = function (v) { return v; };
10570
+ var noop$2 = function (v) { return v; };
10571
10571
  var ComponentDragControls = /** @class */ (function () {
10572
10572
  function ComponentDragControls(_a) {
10573
10573
  var ref = _a.ref, values = _a.values, controls = _a.controls;
@@ -10595,7 +10595,7 @@ var ComponentDragControls = /** @class */ (function () {
10595
10595
  * @internal
10596
10596
  */
10597
10597
  this.props = {
10598
- transformPagePoint: noop$1,
10598
+ transformPagePoint: noop$2,
10599
10599
  };
10600
10600
  /**
10601
10601
  * References to the MotionValues used for tracking the current dragged point.
@@ -13025,7 +13025,7 @@ var Spinner = function Spinner(_ref) {
13025
13025
 
13026
13026
  var ButtonWithAction = /*#__PURE__*/forwardRef(function (_ref2, ref) {
13027
13027
  var _ref2$action = _ref2.action,
13028
- action = _ref2$action === void 0 ? noop : _ref2$action,
13028
+ action = _ref2$action === void 0 ? noop$1 : _ref2$action,
13029
13029
  _ref2$variant = _ref2.variant,
13030
13030
  variant = _ref2$variant === void 0 ? "primary" : _ref2$variant,
13031
13031
  text = _ref2.text,
@@ -13067,7 +13067,7 @@ var ButtonWithAction = /*#__PURE__*/forwardRef(function (_ref2, ref) {
13067
13067
  disabledStyles: disabledStyles,
13068
13068
  "aria-disabled": disabled,
13069
13069
  as: "button",
13070
- onClick: isLoading || disabled ? noop : action,
13070
+ onClick: isLoading || disabled ? noop$1 : action,
13071
13071
  borderRadius: "2px",
13072
13072
  theme: themeContext,
13073
13073
  extraStyles: "margin: 0.5rem; ".concat(extraStyles),
@@ -23240,7 +23240,7 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_ref5, ref) {
23240
23240
  name = _ref5.name,
23241
23241
  checked = _ref5.checked,
23242
23242
  _ref5$onChange = _ref5.onChange,
23243
- onChange = _ref5$onChange === void 0 ? noop : _ref5$onChange,
23243
+ onChange = _ref5$onChange === void 0 ? noop$1 : _ref5$onChange,
23244
23244
  _ref5$disabled = _ref5.disabled,
23245
23245
  disabled = _ref5$disabled === void 0 ? false : _ref5$disabled,
23246
23246
  themeValues = _ref5.themeValues,
@@ -23439,7 +23439,7 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
23439
23439
  padding: "0.875rem",
23440
23440
  borderRadius: "4px",
23441
23441
  minWidth: "30%",
23442
- onClick: disabled ? noop : onSelect,
23442
+ onClick: disabled ? noop$1 : onSelect,
23443
23443
  borderColor: borderColor,
23444
23444
  borderSize: "1px",
23445
23445
  color: color,
@@ -23454,8 +23454,8 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
23454
23454
  name: name,
23455
23455
  "aria-label": name,
23456
23456
  htmlFor: "checkbox-".concat(name, "-").concat(index),
23457
- onClick: disabled ? noop : onSelect,
23458
- onKeyDown: disabled ? noop : onSelect,
23457
+ onClick: disabled ? noop$1 : onSelect,
23458
+ onKeyDown: disabled ? noop$1 : onSelect,
23459
23459
  tabIndex: 0
23460
23460
  }, /*#__PURE__*/React.createElement(ThemeProvider, {
23461
23461
  theme: {
@@ -23683,7 +23683,7 @@ var SortableTableHeading = function SortableTableHeading(_ref) {
23683
23683
  disabled: disabled,
23684
23684
  extraStyles: "cursor: pointer; ".concat(extraStyles),
23685
23685
  onClick: function onClick(event) {
23686
- return disabled ? noop : onSortChange(event);
23686
+ return disabled ? noop$1 : onSortChange(event);
23687
23687
  },
23688
23688
  "aria-controls": ariaControlsId
23689
23689
  }, /*#__PURE__*/React.createElement(Cluster, {
@@ -25113,7 +25113,7 @@ var Dropdown = function Dropdown(_ref13) {
25113
25113
  _ref13$disabledValues = _ref13.disabledValues,
25114
25114
  disabledValues = _ref13$disabledValues === void 0 ? [] : _ref13$disabledValues,
25115
25115
  _ref13$onClick = _ref13.onClick,
25116
- _onClick = _ref13$onClick === void 0 ? noop : _ref13$onClick,
25116
+ _onClick = _ref13$onClick === void 0 ? noop$1 : _ref13$onClick,
25117
25117
  themeValues = _ref13.themeValues,
25118
25118
  maxHeight = _ref13.maxHeight,
25119
25119
  _ref13$widthFitOption = _ref13.widthFitOptions,
@@ -26562,6 +26562,15 @@ var DisplayBox$1 = themeComponent(DisplayBox, "DisplayBox", fallbackValues$l);
26562
26562
  var useOutsideClickHook = function useOutsideClickHook(handler) {
26563
26563
  var ref = useRef();
26564
26564
  useEffect$1(function () {
26565
+ var handleOutsideClick = function handleOutsideClick(e) {
26566
+ if (ref.current && !ref.current.contains(e.target)) {
26567
+ handler();
26568
+ }
26569
+ };
26570
+ document.addEventListener("click", handleOutsideClick, true);
26571
+ return function () {
26572
+ document.removeEventListener("click", handleOutsideClick, true);
26573
+ };
26565
26574
  }, [ref]);
26566
26575
  return ref;
26567
26576
  };
@@ -26752,13 +26761,15 @@ var Popover = function Popover(_ref) {
26752
26761
  togglePopover(popoverState);
26753
26762
  }
26754
26763
  };
26755
- var triggerRef = useOutsideClickHook();
26764
+ var triggerRef = useOutsideClickHook(function () {
26765
+ return handleTogglePopover(false);
26766
+ });
26756
26767
  return /*#__PURE__*/React.createElement(Box, {
26757
26768
  padding: "0",
26758
26769
  extraStyles: "position: relative; ".concat(extraStyles)
26759
26770
  }, /*#__PURE__*/React.createElement(ButtonWithAction, {
26760
26771
  action: function action() {
26761
- return noop;
26772
+ return noop$1;
26762
26773
  },
26763
26774
  onFocus: function onFocus() {
26764
26775
  handleTogglePopover(true);
@@ -27088,83 +27099,79 @@ var createFormat = function createFormat(formats, formatChar) {
27088
27099
  var FormattedInput = function FormattedInput(_ref) {
27089
27100
  var value = _ref.value,
27090
27101
  formatter = _ref.formatter,
27091
- onChange = _ref.onChange,
27102
+ _onChange = _ref.onChange,
27092
27103
  props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
27093
27104
 
27094
- var _useState = useState(format$1(formatter)(value)),
27095
- _useState2 = _slicedToArray$1(_useState, 2),
27096
- formattedValue = _useState2[0],
27097
- setFormattedValue = _useState2[1];
27098
-
27099
27105
  var inputEl = useRef(null);
27100
- var stateRefs = useRef({
27106
+
27107
+ var _useState = useState({
27101
27108
  selectionStart: 0,
27102
27109
  selectionEnd: 0,
27103
- isDelete: false,
27104
- rawValue: ''
27105
- });
27110
+ rawValue: value,
27111
+ "delete": false,
27112
+ formattedValue: format$1(formatter)(value)
27113
+ }),
27114
+ _useState2 = _slicedToArray$1(_useState, 2),
27115
+ state = _useState2[0],
27116
+ setState = _useState2[1];
27117
+
27106
27118
  useLayoutEffect(function () {
27107
27119
  // A lot of the work here is cursor manipulation
27108
27120
  if (inputEl.current && inputEl.current === document.activeElement) {
27109
- inputEl.current.setSelectionRange(stateRefs.current.selectionStart, stateRefs.current.selectionEnd);
27110
- }
27111
- }, [stateRefs]);
27112
-
27113
- var handleChange = function handleChange(event) {
27114
- var deleteKeyPressed = stateRefs.current.isDelete;
27115
- var maxFormatExceeded = stateRefs.current.rawValue.length >= formatter.formats.length - 1;
27116
-
27117
- if (maxFormatExceeded && !deleteKeyPressed) {
27118
- return;
27119
- }
27120
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
27121
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
27122
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
27123
- * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
27124
- * old unformatted value.
27125
- */
27126
-
27127
-
27128
- var injectionLength = event.target.value.length - formattedValue.length;
27129
- var end = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? stateRefs.current.selectionStart + injectionLength : stateRefs.current.selectionEnd - 1;
27130
- var injection = event.target.value.substring(stateRefs.current.selectionStart, end); // Injection is the new unformatted piece of the input
27131
- // Need to find where to put it
27132
-
27133
- var rawInjectionPointStart = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter);
27134
- var rawInjectionPointEnd = formattedToUnformattedIndex(stateRefs.current.selectionEnd, stateRefs.current.rawValue, formatter); // Unformat the previous formatted value for injection
27135
- // Using the relevant format string, strips away chars not marked with the formatChar
27136
-
27137
- var unformattedOldValue = unformat(formatter)(formattedValue, stateRefs.current.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
27138
-
27139
- var injectIntoOldValue = inject(unformattedOldValue);
27140
- var unformattedNewValue = deleteKeyPressed ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
27141
- var lengthDifference = unformattedNewValue.length - stateRefs.current.rawValue.length;
27142
- var rawIndex = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
27143
- // Applied by useLayoutEffect
27144
-
27145
- var newFormattedCursorPosition = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, deleteKeyPressed) : deleteKeyPressed ? stateRefs.current.selectionStart : stateRefs.current.selectionEnd;
27146
- var formattedNewValue = format$1(formatter)(unformattedNewValue);
27147
- setFormattedValue(formattedNewValue); // Apply the external onChange function to the raw underlying string
27148
- // This is where the user generally updates the input value
27149
-
27150
- if (onChange) {
27151
- onChange(unformattedNewValue);
27121
+ inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
27152
27122
  }
27153
- };
27154
-
27123
+ });
27155
27124
  return React.createElement("input", _extends$2({}, props, {
27156
27125
  ref: inputEl,
27157
27126
  value: format$1(formatter)(value),
27158
27127
  onKeyDown: function onKeyDown(event) {
27159
- // Keep track of the state of the input before onChange
27160
- stateRefs.current = {
27161
- isDelete: event.key === "Backspace" || event.key === "Delete",
27128
+ // Keep track of the state of the input before onChange, including if user is hitting delete
27129
+ setState({
27130
+ rawValue: value,
27162
27131
  selectionStart: event.target.selectionStart,
27163
27132
  selectionEnd: event.target.selectionEnd,
27164
- rawValue: value
27165
- };
27133
+ "delete": event.key === "Backspace" || event.key === "Delete",
27134
+ formattedValue: event.target.value
27135
+ });
27166
27136
  },
27167
- onChange: handleChange
27137
+ onChange: function onChange(event) {
27138
+ /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
27139
+ * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
27140
+ * the unformatted value for the user's onChange, the formatted string and unformatted injection need
27141
+ * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
27142
+ * old unformatted value.
27143
+ */
27144
+ var injectionLength = event.target.value.length - state.formattedValue.length;
27145
+ var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
27146
+ var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
27147
+ // Need to find where to put it
27148
+
27149
+ var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
27150
+ var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
27151
+ // Using the relevant format string, strips away chars not marked with the formatChar
27152
+
27153
+ var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
27154
+
27155
+ var injectIntoOldValue = inject(unformattedOldValue);
27156
+ var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
27157
+ var lengthDifference = unformattedNewValue.length - state.rawValue.length;
27158
+ var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
27159
+ // Applied by useLayoutEffect
27160
+
27161
+ var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
27162
+ setState({
27163
+ selectionStart: newFormattedCursorPosition,
27164
+ selectionEnd: newFormattedCursorPosition,
27165
+ rawValue: state.rawValue,
27166
+ "delete": false,
27167
+ formattedValue: state.formattedValue
27168
+ }); // Apply the external onChange function to the raw underlying string
27169
+ // This is where the user generally updates the input value
27170
+
27171
+ if (_onChange) {
27172
+ _onChange(unformattedNewValue);
27173
+ }
27174
+ }
27168
27175
  }));
27169
27176
  };
27170
27177
 
@@ -27761,7 +27768,7 @@ var HamburgerButton = function HamburgerButton(_ref4) {
27761
27768
  inactiveColor = _ref4.inactiveColor,
27762
27769
  isActive = _ref4.isActive,
27763
27770
  _ref4$onClick = _ref4.onClick,
27764
- onClick = _ref4$onClick === void 0 ? noop : _ref4$onClick,
27771
+ onClick = _ref4$onClick === void 0 ? noop$1 : _ref4$onClick,
27765
27772
  controls = _ref4.controls;
27766
27773
  return /*#__PURE__*/React.createElement(Hamburger, {
27767
27774
  className: isActive === true ? "active" : "",
@@ -28652,7 +28659,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
28652
28659
  themeValues = _ref5.themeValues,
28653
28660
  index = _ref5.index,
28654
28661
  _ref5$handleChange = _ref5.handleChange,
28655
- handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange,
28662
+ handleChange = _ref5$handleChange === void 0 ? noop$1 : _ref5$handleChange,
28656
28663
  field = _ref5.field,
28657
28664
  config = _ref5.config;
28658
28665
  var getDefaultChecked = function getDefaultChecked(value, idx) {
@@ -28869,7 +28876,7 @@ var Search = function Search(_ref) {
28869
28876
  "aria-controls": ariaControlsId,
28870
28877
  extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
28871
28878
  onKeyDown: function onKeyDown(e) {
28872
- return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28879
+ return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop$1;
28873
28880
  },
28874
28881
  field: field,
28875
28882
  fieldActions: fieldActions,
@@ -39657,7 +39664,7 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
39657
39664
  _ref10$isOn = _ref10.isOn,
39658
39665
  isOn = _ref10$isOn === void 0 ? false : _ref10$isOn,
39659
39666
  _ref10$onToggle = _ref10.onToggle,
39660
- onToggle = _ref10$onToggle === void 0 ? noop : _ref10$onToggle,
39667
+ onToggle = _ref10$onToggle === void 0 ? noop$1 : _ref10$onToggle,
39661
39668
  _ref10$disabled = _ref10.disabled,
39662
39669
  disabled = _ref10$disabled === void 0 ? false : _ref10$disabled,
39663
39670
  _ref10$name = _ref10.name,
@@ -39757,13 +39764,13 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
39757
39764
  "aria-labelledby": label ? "".concat(nameId, "-label") : null,
39758
39765
  "aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
39759
39766
  checked: isOn,
39760
- onChange: disabled ? noop : onToggle,
39767
+ onChange: disabled ? noop$1 : onToggle,
39761
39768
  disabled: disabled,
39762
39769
  id: "#".concat(nameId),
39763
39770
  isMobile: isMobile
39764
39771
  }), /*#__PURE__*/React.createElement(VisibleSwitch, {
39765
- onClick: disabled ? noop : onToggle,
39766
- onKeyDown: disabled ? noop : handleKeyDown,
39772
+ onClick: disabled ? noop$1 : onToggle,
39773
+ onKeyDown: disabled ? noop$1 : handleKeyDown,
39767
39774
  pose: isOn ? "on" : "off",
39768
39775
  tabIndex: disabled ? -1 : 0,
39769
39776
  disabled: disabled,
@@ -39932,7 +39939,7 @@ var Card = function Card(_ref) {
39932
39939
  imgObjectFit = _ref$imgObjectFit === void 0 ? "none" : _ref$imgObjectFit,
39933
39940
  imgAltText = _ref.imgAltText,
39934
39941
  _ref$onQuitClick = _ref.onQuitClick,
39935
- onQuitClick = _ref$onQuitClick === void 0 ? noop : _ref$onQuitClick,
39942
+ onQuitClick = _ref$onQuitClick === void 0 ? noop$1 : _ref$onQuitClick,
39936
39943
  _ref$padding = _ref.padding,
39937
39944
  padding = _ref$padding === void 0 ? "24px" : _ref$padding,
39938
39945
  _ref$showQuitLink = _ref.showQuitLink,
@@ -40965,7 +40972,7 @@ var AddressForm = function AddressForm(_ref) {
40965
40972
  clearOnDismount = _ref.clearOnDismount,
40966
40973
  showErrors = _ref.showErrors,
40967
40974
  _ref$handleSubmit = _ref.handleSubmit,
40968
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
40975
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
40969
40976
  showWalletCheckbox = _ref.showWalletCheckbox,
40970
40977
  saveToWallet = _ref.saveToWallet,
40971
40978
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -41165,7 +41172,7 @@ var ChangePasswordForm = function ChangePasswordForm(_ref) {
41165
41172
  fields = _ref.fields,
41166
41173
  actions = _ref.actions,
41167
41174
  _ref$handleSubmit = _ref.handleSubmit,
41168
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
41175
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
41169
41176
  showErrors = _ref.showErrors,
41170
41177
  isMobile = _ref.isMobile,
41171
41178
  revenueManagement = _ref.revenueManagement,
@@ -41376,8 +41383,8 @@ var CollapsibleSection = function CollapsibleSection(_ref) {
41376
41383
  }, /*#__PURE__*/React.createElement(Box, {
41377
41384
  padding: customPadding ? customPadding : "0",
41378
41385
  background: themeValues.headingBackgroundColor,
41379
- onClick: isMobile && supportsTouch ? noop : toggleSection,
41380
- onTouchEnd: isMobile && supportsTouch ? toggleSection : noop,
41386
+ onClick: isMobile && supportsTouch ? noop$1 : toggleSection,
41387
+ onTouchEnd: isMobile && supportsTouch ? toggleSection : noop$1,
41381
41388
  key: "header",
41382
41389
  hoverStyles: "cursor: pointer;",
41383
41390
  tabIndex: "0",
@@ -41595,7 +41602,7 @@ var EditNameForm = function EditNameForm(_ref) {
41595
41602
  clearOnDismount = _ref.clearOnDismount,
41596
41603
  showErrors = _ref.showErrors,
41597
41604
  _ref$handleSubmit = _ref.handleSubmit,
41598
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
41605
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
41599
41606
  if (clearOnDismount) {
41600
41607
  useEffect$1(function () {
41601
41608
  return function () {
@@ -41938,7 +41945,7 @@ var EmailForm = function EmailForm(_ref) {
41938
41945
  showErrors = _ref.showErrors,
41939
41946
  guestCheckout = _ref.guestCheckout,
41940
41947
  _ref$handleSubmit = _ref.handleSubmit,
41941
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
41948
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
41942
41949
  showWalletCheckbox = _ref.showWalletCheckbox,
41943
41950
  saveToWallet = _ref.saveToWallet,
41944
41951
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -42036,7 +42043,7 @@ var ForgotPasswordForm = function ForgotPasswordForm(_ref) {
42036
42043
  clearOnDismount = _ref.clearOnDismount,
42037
42044
  showErrors = _ref.showErrors,
42038
42045
  _ref$handleSubmit = _ref.handleSubmit,
42039
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
42046
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
42040
42047
  if (clearOnDismount) {
42041
42048
  useEffect$1(function () {
42042
42049
  return function () {
@@ -42630,7 +42637,7 @@ var LinkCard = function LinkCard(_ref) {
42630
42637
  extraStyles: extraStyles,
42631
42638
  hoverStyles: extraHoverStyles,
42632
42639
  activeStyles: extraActiveStyles,
42633
- onClick: disabled ? noop : onClick,
42640
+ onClick: disabled ? noop$1 : onClick,
42634
42641
  "aria-disabled": disabled,
42635
42642
  isDisabled: disabled,
42636
42643
  role: "group",
@@ -42679,7 +42686,7 @@ var LoginForm = function LoginForm(_ref) {
42679
42686
  actions = _ref.actions,
42680
42687
  showErrors = _ref.showErrors,
42681
42688
  _ref$handleSubmit = _ref.handleSubmit,
42682
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
42689
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
42683
42690
  if (clearOnDismount) {
42684
42691
  useEffect$1(function () {
42685
42692
  return function () {
@@ -46349,13 +46356,13 @@ var CancelButton = function CancelButton(_ref) {
46349
46356
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46350
46357
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46351
46358
  _ref$cancelAction = _ref.cancelAction,
46352
- cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46359
+ cancelAction = _ref$cancelAction === void 0 ? noop$1 : _ref$cancelAction,
46353
46360
  _ref$cancelButtonText = _ref.cancelButtonText,
46354
46361
  cancelButtonText = _ref$cancelButtonText === void 0 ? "" : _ref$cancelButtonText,
46355
46362
  _ref$cancelButtonVari = _ref.cancelButtonVariant,
46356
46363
  cancelButtonVariant = _ref$cancelButtonVari === void 0 ? "secondary" : _ref$cancelButtonVari,
46357
46364
  _ref$hideModal = _ref.hideModal,
46358
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46365
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46359
46366
  _ref$isMobile = _ref.isMobile,
46360
46367
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46361
46368
  var fontSize = "font-size: ".concat(isMobile ? FONT_SIZE.XS : FONT_SIZE.SM, ";");
@@ -46382,7 +46389,7 @@ var CloseButton = function CloseButton(_ref) {
46382
46389
  _ref$closeButtonVaria = _ref.closeButtonVariant,
46383
46390
  closeButtonVariant = _ref$closeButtonVaria === void 0 ? "primary" : _ref$closeButtonVaria,
46384
46391
  _ref$hideModal = _ref.hideModal,
46385
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46392
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46386
46393
  _ref$isMobile = _ref.isMobile,
46387
46394
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46388
46395
  var fontSize = "font-size: ".concat(isMobile ? FONT_SIZE.XS : FONT_SIZE.SM, ";");
@@ -46404,7 +46411,7 @@ var CloseButton = function CloseButton(_ref) {
46404
46411
  var CloseIconButton = function CloseIconButton(_ref) {
46405
46412
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46406
46413
  _ref$hideModal = _ref.hideModal,
46407
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46414
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46408
46415
  _ref$iconWidth = _ref.iconWidth,
46409
46416
  iconWidth = _ref$iconWidth === void 0 ? "24px" : _ref$iconWidth,
46410
46417
  _ref$iconHeight = _ref.iconHeight,
@@ -46429,7 +46436,7 @@ var ContinueButton = function ContinueButton(_ref) {
46429
46436
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46430
46437
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46431
46438
  _ref$continueAction = _ref.continueAction,
46432
- continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46439
+ continueAction = _ref$continueAction === void 0 ? noop$1 : _ref$continueAction,
46433
46440
  _ref$continueButtonTe = _ref.continueButtonText,
46434
46441
  continueButtonText = _ref$continueButtonTe === void 0 ? "" : _ref$continueButtonTe,
46435
46442
  _ref$continueURL = _ref.continueURL,
@@ -46484,7 +46491,7 @@ var Modal$2 = function Modal(_ref) {
46484
46491
  _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46485
46492
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46486
46493
  _ref$cancelAction = _ref.cancelAction,
46487
- cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46494
+ cancelAction = _ref$cancelAction === void 0 ? noop$1 : _ref$cancelAction,
46488
46495
  _ref$cancelButtonText = _ref.cancelButtonText,
46489
46496
  cancelButtonText = _ref$cancelButtonText === void 0 ? "Cancel" : _ref$cancelButtonText,
46490
46497
  _ref$cancelButtonVari = _ref.cancelButtonVariant,
@@ -46496,7 +46503,7 @@ var Modal$2 = function Modal(_ref) {
46496
46503
  _ref$closeButtonVaria = _ref.closeButtonVariant,
46497
46504
  closeButtonVariant = _ref$closeButtonVaria === void 0 ? "primary" : _ref$closeButtonVaria,
46498
46505
  _ref$continueAction = _ref.continueAction,
46499
- continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46506
+ continueAction = _ref$continueAction === void 0 ? noop$1 : _ref$continueAction,
46500
46507
  _ref$continueButtonTe = _ref.continueButtonText,
46501
46508
  continueButtonText = _ref$continueButtonTe === void 0 ? "Continue" : _ref$continueButtonTe,
46502
46509
  _ref$continueButtonVa = _ref.continueButtonVariant,
@@ -46510,7 +46517,7 @@ var Modal$2 = function Modal(_ref) {
46510
46517
  _ref$defaultWrapper = _ref.defaultWrapper,
46511
46518
  defaultWrapper = _ref$defaultWrapper === void 0 ? true : _ref$defaultWrapper,
46512
46519
  _ref$hideModal = _ref.hideModal,
46513
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46520
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46514
46521
  _ref$initialFocusSele = _ref.initialFocusSelector,
46515
46522
  initialFocusSelector = _ref$initialFocusSele === void 0 ? "" : _ref$initialFocusSele,
46516
46523
  _ref$isContinueAction = _ref.isContinueActionDisabled,
@@ -46991,13 +46998,13 @@ var AmountModule = function AmountModule(_ref) {
46991
46998
  subDescription: subDescription,
46992
46999
  allowedPaymentInstruments: allowedPaymentInstruments,
46993
47000
  disableActions: disableActions,
46994
- action: disableActions ? noop : function () {
47001
+ action: disableActions ? noop$1 : function () {
46995
47002
  return toggleModal(true);
46996
47003
  },
46997
- onClick: disableActions ? noop : function () {
47004
+ onClick: disableActions ? noop$1 : function () {
46998
47005
  toggleModal(true);
46999
47006
  },
47000
- onKeyPress: disableActions ? noop : function (e) {
47007
+ onKeyPress: disableActions ? noop$1 : function (e) {
47001
47008
  e.key === "Enter" && toggleModal(true);
47002
47009
  }
47003
47010
  })));
@@ -47127,7 +47134,7 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
47127
47134
  padding: "0"
47128
47135
  }, /*#__PURE__*/React.createElement(ButtonWithAction, {
47129
47136
  isLoading: isLoading,
47130
- action: disableActions ? noop : function () {
47137
+ action: disableActions ? noop$1 : function () {
47131
47138
  return handleClick(obligations);
47132
47139
  },
47133
47140
  text: "Pay Now",
@@ -47139,7 +47146,7 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
47139
47146
  width: "100%"
47140
47147
  }, /*#__PURE__*/React.createElement(ButtonWithAction, {
47141
47148
  isLoading: isLoading,
47142
- action: disableActions ? noop : function () {
47149
+ action: disableActions ? noop$1 : function () {
47143
47150
  return handleClick(obligations);
47144
47151
  },
47145
47152
  text: "Pay Now",
@@ -47194,7 +47201,7 @@ var RemoveAccountModalModule = function RemoveAccountModalModule(_ref) {
47194
47201
  }, /*#__PURE__*/React.createElement(ButtonWithAction, {
47195
47202
  text: "Remove",
47196
47203
  variant: "secondary",
47197
- action: disableActions ? noop : function () {
47204
+ action: disableActions ? noop$1 : function () {
47198
47205
  return setModalIsOpen(true);
47199
47206
  },
47200
47207
  dataQa: "Remove Account",
@@ -47266,7 +47273,7 @@ var InactiveControlsModule = function InactiveControlsModule(_ref) {
47266
47273
  extraStyles: "flex-grow: 1;"
47267
47274
  }, /*#__PURE__*/React.createElement(RemoveAccountModalModule, {
47268
47275
  agencyName: agencyName,
47269
- removeAccount: disableActions ? noop : handleRemoveAccount,
47276
+ removeAccount: disableActions ? noop$1 : handleRemoveAccount,
47270
47277
  accountType: configType === "ACCOUNT" ? "Account" : "Property",
47271
47278
  isMobile: isMobile,
47272
47279
  disableActions: disableActions
@@ -47827,7 +47834,7 @@ var Pagination = function Pagination(_ref3) {
47827
47834
  return setCurrentPage({
47828
47835
  pageNumber: item.index
47829
47836
  });
47830
- } : noop,
47837
+ } : noop$1,
47831
47838
  textExtraStyles: "font-size: ".concat(fontSize, "; font-weight: ").concat(fontWeight, ";"),
47832
47839
  extraStyles: "".concat(extraStyles).concat(item.active ? currentPageStyles : ""),
47833
47840
  dataQa: index
@@ -48190,7 +48197,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48190
48197
  _ref4$voidableTransac = _ref4.voidableTransactionDetails,
48191
48198
  voidableTransactionDetails = _ref4$voidableTransac === void 0 ? [] : _ref4$voidableTransac,
48192
48199
  _ref4$partialVoidActi = _ref4.partialVoidAction,
48193
- partialVoidAction = _ref4$partialVoidActi === void 0 ? noop : _ref4$partialVoidActi,
48200
+ partialVoidAction = _ref4$partialVoidActi === void 0 ? noop$1 : _ref4$partialVoidActi,
48194
48201
  _ref4$voidableAmountP = _ref4.voidableAmountPaid,
48195
48202
  voidableAmountPaid = _ref4$voidableAmountP === void 0 ? 0 : _ref4$voidableAmountP,
48196
48203
  _ref4$remainingBalanc = _ref4.remainingBalance,
@@ -48667,7 +48674,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
48667
48674
  actions = _ref.actions,
48668
48675
  showErrors = _ref.showErrors,
48669
48676
  _ref$handleSubmit = _ref.handleSubmit,
48670
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
48677
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
48671
48678
  showWalletCheckbox = _ref.showWalletCheckbox,
48672
48679
  saveToWallet = _ref.saveToWallet,
48673
48680
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -48869,7 +48876,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
48869
48876
  actions = _ref.actions,
48870
48877
  showErrors = _ref.showErrors,
48871
48878
  _ref$handleSubmit = _ref.handleSubmit,
48872
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
48879
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
48873
48880
  showWalletCheckbox = _ref.showWalletCheckbox,
48874
48881
  saveToWallet = _ref.saveToWallet,
48875
48882
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -49174,7 +49181,7 @@ var PhoneForm = function PhoneForm(_ref) {
49174
49181
  clearOnDismount = _ref.clearOnDismount,
49175
49182
  showErrors = _ref.showErrors,
49176
49183
  _ref$handleSubmit = _ref.handleSubmit,
49177
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49184
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49178
49185
  showWalletCheckbox = _ref.showWalletCheckbox,
49179
49186
  saveToWallet = _ref.saveToWallet,
49180
49187
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -49258,7 +49265,7 @@ var RadioGroup = function RadioGroup(_ref2) {
49258
49265
  config = _ref2.config,
49259
49266
  extraStyles = _ref2.extraStyles,
49260
49267
  _ref2$handleChange = _ref2.handleChange,
49261
- handleChange = _ref2$handleChange === void 0 ? noop : _ref2$handleChange,
49268
+ handleChange = _ref2$handleChange === void 0 ? noop$1 : _ref2$handleChange,
49262
49269
  field = _ref2.field,
49263
49270
  fieldActions = _ref2.fieldActions;
49264
49271
  var setValue = function setValue(value) {
@@ -49323,7 +49330,7 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49323
49330
  ariaLabelledBy = _ref.ariaLabelledBy,
49324
49331
  isLastGroupedItemInSection = _ref.isLastGroupedItemInSection,
49325
49332
  _ref$onKeyDown = _ref.onKeyDown,
49326
- onKeyDown = _ref$onKeyDown === void 0 ? noop : _ref$onKeyDown;
49333
+ onKeyDown = _ref$onKeyDown === void 0 ? noop$1 : _ref$onKeyDown;
49327
49334
  var wrapper = {
49328
49335
  open: {
49329
49336
  height: openHeight,
@@ -49380,12 +49387,12 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49380
49387
  "aria-required": section.required,
49381
49388
  "aria-labelledby": ariaLabelledBy,
49382
49389
  "aria-describedby": ariaDescribedBy,
49383
- onClick: isMobile && supportsTouch || section.disabled || section.id === openSection ? noop : function () {
49390
+ onClick: isMobile && supportsTouch || section.disabled || section.id === openSection ? noop$1 : function () {
49384
49391
  return toggleOpenSection(section.id);
49385
49392
  },
49386
49393
  onTouchEnd: isMobile && supportsTouch && !section.disabled && section.id !== openSection ? function () {
49387
49394
  return toggleOpenSection(section.id);
49388
- } : noop,
49395
+ } : noop$1,
49389
49396
  id: "inner-radio-section-".concat(sectionIndex),
49390
49397
  "data-qa": section.dataQa ? section.dataQa : section.id || "inner-radio-section-".concat(sectionIndex)
49391
49398
  }, /*#__PURE__*/React.createElement(Stack, {
@@ -49415,7 +49422,7 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49415
49422
  ariaDescribedBy: ariaDescribedBy,
49416
49423
  radioOn: openSection === section.id,
49417
49424
  radioFocused: focused === section.id,
49418
- toggleRadio: section.disabled ? noop : function () {
49425
+ toggleRadio: section.disabled ? noop$1 : function () {
49419
49426
  return toggleOpenSection(section.id);
49420
49427
  },
49421
49428
  tabIndex: "-1",
@@ -49600,7 +49607,7 @@ var RegistrationForm = function RegistrationForm(_ref) {
49600
49607
  fields = _ref.fields,
49601
49608
  actions = _ref.actions,
49602
49609
  _ref$handleSubmit = _ref.handleSubmit,
49603
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49610
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49604
49611
  showErrors = _ref.showErrors,
49605
49612
  isMobile = _ref.isMobile;
49606
49613
  if (clearOnDismount) {
@@ -49767,7 +49774,7 @@ var ResetConfirmationForm$1 = withWindowSize(ResetConfirmationForm);
49767
49774
 
49768
49775
  var ResetPasswordForm = function ResetPasswordForm(_ref) {
49769
49776
  var _ref$handleSubmit = _ref.handleSubmit,
49770
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49777
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49771
49778
  clearOnDismount = _ref.clearOnDismount,
49772
49779
  fields = _ref.fields,
49773
49780
  actions = _ref.actions,
@@ -50461,6 +50468,58 @@ var fallbackValues$_ = {
50461
50468
  secondaryColor: secondaryColor
50462
50469
  };
50463
50470
 
50471
+ var StyledFilterContainer = styled(Box).withConfig({
50472
+ displayName: "MultipleSelectFilterstyled__StyledFilterContainer",
50473
+ componentId: "sc-126xgc2-0"
50474
+ })(["position:relative;box-sizing:border-box;padding:0;", ""], function (_ref) {
50475
+ var extraStyles = _ref.extraStyles;
50476
+ return extraStyles;
50477
+ });
50478
+ var FilterContainer = /*#__PURE__*/forwardRef(function (props, ref) {
50479
+ return /*#__PURE__*/React.createElement(StyledFilterContainer, _extends({
50480
+ ref: ref
50481
+ }, props));
50482
+ });
50483
+ var StyledFilterDropdown = styled(Box).withConfig({
50484
+ displayName: "MultipleSelectFilterstyled__StyledFilterDropdown",
50485
+ componentId: "sc-126xgc2-1"
50486
+ })(["position:absolute;top:calc(100% + 0.5rem);left:0;width:100%;background-color:white;z-index:1000;border-radius:0.25rem;box-shadow:0px 1px 0px 0px rgba(41,42,51,0.1),0px 2px 4px 0px rgba(41,42,51,0.2),0px 1px 2px 0px rgba(41,42,51,0.1);padding:0;max-width:18.625rem;"]);
50487
+ var FilterDropdownContainer = /*#__PURE__*/forwardRef(function (props, ref) {
50488
+ return /*#__PURE__*/React.createElement(StyledFilterDropdown, _extends({
50489
+ ref: ref
50490
+ }, props));
50491
+ });
50492
+ var FilterButton = styled(ButtonWithAction).withConfig({
50493
+ displayName: "MultipleSelectFilterstyled__FilterButton",
50494
+ componentId: "sc-126xgc2-2"
50495
+ })(["min-width:auto;min-height:2.3125rem;margin:0;padding:0.5rem;border-radius:0.25rem;box-shadow:0px 1px 2px 0px rgba(41,42,51,0.1);", " ", ""], function (_ref2) {
50496
+ var textColor = _ref2.textColor;
50497
+ return "\n color: ".concat(textColor, ";\n ");
50498
+ }, function (_ref3) {
50499
+ var backgroundColor = _ref3.backgroundColor;
50500
+ return "\n background-color: ".concat(backgroundColor, ";\n :hover,\n :active,\n :focus {\n background-color: ").concat(backgroundColor, ";\n }\n ");
50501
+ });
50502
+ var StyledFilterButton = /*#__PURE__*/forwardRef(function (props, ref) {
50503
+ return /*#__PURE__*/React.createElement(FilterButton, _extends({
50504
+ ref: ref
50505
+ }, props));
50506
+ });
50507
+
50508
+ var ActionLinkButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
50509
+ var action = _ref.action,
50510
+ text = _ref.text,
50511
+ dataQa = _ref.dataQa;
50512
+ return /*#__PURE__*/React.createElement(ButtonWithAction, {
50513
+ ref: ref,
50514
+ action: action,
50515
+ variant: "tertiary",
50516
+ extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50517
+ textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50518
+ text: text,
50519
+ dataQa: dataQa
50520
+ });
50521
+ });
50522
+
50464
50523
  var _excluded$J = ["width", "height", "color"];
50465
50524
  var DropdownIconV2 = function DropdownIconV2(_ref) {
50466
50525
  var _ref$width = _ref.width,
@@ -50509,205 +50568,392 @@ var DropdownIconV2 = function DropdownIconV2(_ref) {
50509
50568
  }))));
50510
50569
  };
50511
50570
 
50512
- var StyledFilterContainer = styled(Box).withConfig({
50513
- displayName: "MultipleSelectFilterstyled__StyledFilterContainer",
50514
- componentId: "sc-126xgc2-0"
50515
- })(["position:relative;box-sizing:border-box;padding:0;", ""], function (_ref) {
50516
- var extraStyles = _ref.extraStyles;
50517
- return extraStyles;
50518
- });
50519
- var FilterContainer = /*#__PURE__*/forwardRef(function (props, ref) {
50520
- return /*#__PURE__*/React.createElement(StyledFilterContainer, _extends({
50521
- ref: ref
50522
- }, props));
50523
- });
50524
- var StyledFilterDropdown = styled(Box).withConfig({
50525
- displayName: "MultipleSelectFilterstyled__StyledFilterDropdown",
50526
- componentId: "sc-126xgc2-1"
50527
- })(["position:absolute;top:calc(100% + 0.5rem);left:0;width:100%;background-color:white;z-index:1000;border-radius:0.25rem;box-shadow:0px 1px 0px 0px rgba(41,42,51,0.1),0px 2px 4px 0px rgba(41,42,51,0.2),0px 1px 2px 0px rgba(41,42,51,0.1);padding:0;max-width:18.625rem;"]);
50528
- var FilterDropdown = /*#__PURE__*/forwardRef(function (props, ref) {
50529
- return /*#__PURE__*/React.createElement(StyledFilterDropdown, _extends({
50530
- ref: ref
50531
- }, props));
50571
+ var FilterButton$1 = /*#__PURE__*/forwardRef(function (_ref, ref) {
50572
+ var btnContentOverride = _ref.btnContentOverride,
50573
+ _ref$action = _ref.action,
50574
+ action = _ref$action === void 0 ? noop$1 : _ref$action,
50575
+ opened = _ref.opened,
50576
+ backgroundColor = _ref.backgroundColor,
50577
+ contentColor = _ref.contentColor,
50578
+ name = _ref.name,
50579
+ filterDropdownID = _ref.filterDropdownID,
50580
+ _ref$hasIcon = _ref.hasIcon,
50581
+ hasIcon = _ref$hasIcon === void 0 ? false : _ref$hasIcon,
50582
+ Icon = _ref.icon,
50583
+ truncateBtnTextWidth = _ref.truncateBtnTextWidth,
50584
+ filterLabel = _ref.filterLabel,
50585
+ selectedOptions = _ref.selectedOptions;
50586
+ return /*#__PURE__*/React.createElement(StyledFilterButton, {
50587
+ ref: ref,
50588
+ variant: "tertiary",
50589
+ action: action,
50590
+ "aria-haspopup": "listbox",
50591
+ "aria-expanded": opened,
50592
+ "aria-controls": filterDropdownID,
50593
+ backgroundColor: backgroundColor,
50594
+ dataQa: "".concat(name, "-filter-button"),
50595
+ contentOverride: true
50596
+ }, btnContentOverride ? btnContentOverride : /*#__PURE__*/React.createElement(Center, {
50597
+ as: "span",
50598
+ style: {
50599
+ display: "flex",
50600
+ flexDirection: "row"
50601
+ },
50602
+ intrinsic: true
50603
+ }, hasIcon && /*#__PURE__*/React.createElement(Icon, {
50604
+ color: contentColor
50605
+ }), /*#__PURE__*/React.createElement(Center, {
50606
+ as: "span",
50607
+ style: {
50608
+ display: "flex",
50609
+ flexDirection: "row",
50610
+ padding: "0 0.5rem 0 0.25rem"
50611
+ },
50612
+ intrinsic: true
50613
+ }, /*#__PURE__*/React.createElement(Text$1, {
50614
+ variant: "pS",
50615
+ color: contentColor,
50616
+ extraStyles: "\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ".concat(truncateBtnTextWidth && "max-width:" + truncateBtnTextWidth, "\n ")
50617
+ }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? "".concat(filterLabel ? filterLabel + ": " : "").concat(selectedOptions[0].name) : "".concat(filterLabel ? filterLabel : "")), /*#__PURE__*/React.createElement(Text$1, {
50618
+ color: contentColor,
50619
+ variant: "pS"
50620
+ }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length && (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 1 ? ", +".concat((selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) - 1, " More") : "")), /*#__PURE__*/React.createElement(DropdownIconV2, {
50621
+ color: contentColor
50622
+ })));
50532
50623
  });
50533
- var StyledFilterButton = styled(ButtonWithAction).withConfig({
50534
- displayName: "MultipleSelectFilterstyled__StyledFilterButton",
50535
- componentId: "sc-126xgc2-2"
50536
- })(["min-width:auto;min-height:2.3125rem;margin:0;padding:0.5rem;border-radius:0.25rem;box-shadow:0px 1px 2px 0px rgba(41,42,51,0.1);", " ", ""], function (_ref2) {
50537
- var textColor = _ref2.textColor;
50538
- return "\n color: ".concat(textColor, ";\n ");
50539
- }, function (_ref3) {
50540
- var backgroundColor = _ref3.backgroundColor;
50541
- return "\n background-color: ".concat(backgroundColor, ";\n :hover,\n :active,\n :focus {\n background-color: ").concat(backgroundColor, ";\n }\n ");
50624
+
50625
+ var FilterDropdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
50626
+ var id = _ref.id,
50627
+ ariaOwns = _ref.ariaOwns,
50628
+ opened = _ref.opened,
50629
+ children = _ref.children;
50630
+ return /*#__PURE__*/React.createElement(React.Fragment, null, opened && /*#__PURE__*/React.createElement(FilterDropdownContainer, {
50631
+ ref: ref,
50632
+ id: id,
50633
+ role: "combobox",
50634
+ "aria-expanded": opened,
50635
+ "aria-haspopup": "listbox",
50636
+ "aria-owns": ariaOwns
50637
+ }, children));
50542
50638
  });
50543
- var FilterButton = /*#__PURE__*/forwardRef(function (props, ref) {
50544
- return /*#__PURE__*/React.createElement(StyledFilterButton, _extends({
50545
- ref: ref
50546
- }, props));
50639
+
50640
+ var SearchBox = function SearchBox(_ref) {
50641
+ var autocompleteValue = _ref.autocompleteValue,
50642
+ fields = _ref.fields,
50643
+ actions = _ref.actions,
50644
+ placeholder = _ref.placeholder,
50645
+ disabled = _ref.disabled,
50646
+ showSearchBox = _ref.showSearchBox;
50647
+ return /*#__PURE__*/React.createElement(Box, {
50648
+ padding: "0 0 0.5rem"
50649
+ }, showSearchBox && /*#__PURE__*/React.createElement(FormInput$1, {
50650
+ autocompleteValue: autocompleteValue,
50651
+ showFieldErrorRow: false,
50652
+ errorMessages: {},
50653
+ field: fields.searchTerm,
50654
+ fieldActions: actions.fields.searchTerm,
50655
+ placeholder: placeholder,
50656
+ disabled: disabled,
50657
+ extraStyles: "\n height: 2.875rem;\n border: 0; \n border-radius: 0;\n padding: 0.45rem;\n font-size: 0.875rem;\n border-bottom: 1px solid ".concat(GHOST_GREY, ";\n ")
50658
+ }));
50659
+ };
50660
+
50661
+ var FilterableListItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
50662
+ var index = _ref.index,
50663
+ option = _ref.option,
50664
+ checked = _ref.checked,
50665
+ selectOption = _ref.selectOption,
50666
+ disabled = _ref.disabled,
50667
+ tabIndex = _ref.tabIndex,
50668
+ name = _ref.name,
50669
+ themeValues = _ref.themeValues;
50670
+ return /*#__PURE__*/React.createElement(Box, {
50671
+ padding: "0",
50672
+ key: index,
50673
+ extraStyles: "\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n ")
50674
+ }, /*#__PURE__*/React.createElement(Checkbox$1, {
50675
+ ref: ref,
50676
+ title: option.name,
50677
+ name: option.name,
50678
+ checked: checked,
50679
+ onChange: function onChange() {
50680
+ return selectOption(option);
50681
+ },
50682
+ textExtraStyles: "font-size: 0.875rem; margin: 0;",
50683
+ disabled: disabled,
50684
+ extraStyles: "\n padding: 0.075rem 0.325rem; \n margin: 0;\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n "),
50685
+ checkboxMargin: "0.3rem",
50686
+ role: "option",
50687
+ checkboxExtraStyles: "\n width: 1.375rem; \n height: 1.375rem;\n ".concat(checked && !disabled ? "background: " + themeValues.secondaryColor + ";" : "", "\n "),
50688
+ tabIndex: tabIndex,
50689
+ dataQa: "".concat(name, "-option-").concat(index)
50690
+ }));
50547
50691
  });
50548
50692
 
50549
- var ScrollableOptionsList = function ScrollableOptionsList(_ref) {
50550
- var id = _ref.id,
50551
- optionsList = _ref.optionsList,
50693
+ var filterItemsList = function filterItemsList(list, searchTerm) {
50694
+ return list.filter(function (item) {
50695
+ var _item$name;
50696
+ return item === null || item === void 0 || (_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.toLowerCase().includes(searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.toLowerCase());
50697
+ });
50698
+ };
50699
+ var sortItemsList = function sortItemsList(list) {
50700
+ return list.slice().sort(function (a, b) {
50701
+ return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
50702
+ });
50703
+ };
50704
+ var isMaxSelectionReached = function isMaxSelectionReached(maxSelection, selectedOptions) {
50705
+ return maxSelection && maxSelection === (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
50706
+ };
50707
+ var isChecked = function isChecked(option, selectedOptions) {
50708
+ return selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.some(function (selectedOption) {
50709
+ return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.name) === (option === null || option === void 0 ? void 0 : option.name);
50710
+ });
50711
+ };
50712
+ var selectValues = function selectValues(items) {
50713
+ return items.map(function (item) {
50714
+ return item.value;
50715
+ });
50716
+ };
50717
+ var selectOption = function selectOption(option, selectedOptions, setSelectedOptions) {
50718
+ if (selectValues(selectedOptions).includes(option.value)) {
50719
+ var fewerOptions = selectedOptions.filter(function (selectedOption) {
50720
+ return selectedOption.value !== option.value;
50721
+ });
50722
+ setSelectedOptions(fewerOptions);
50723
+ } else {
50724
+ var moreOptions = selectedOptions.concat(option);
50725
+ setSelectedOptions(moreOptions);
50726
+ }
50727
+ };
50728
+
50729
+ var useKeyboardNavigation = function useKeyboardNavigation(_ref) {
50730
+ var options = _ref.options,
50731
+ appliedOptions = _ref.appliedOptions,
50552
50732
  selectedOptions = _ref.selectedOptions,
50553
- themeValues = _ref.themeValues,
50554
- selectOption = _ref.selectOption,
50555
- maxSelections = _ref.maxSelections,
50556
- name = _ref.name;
50733
+ maxSelections = _ref.maxSelections;
50557
50734
  var _useState = useState(-1),
50558
50735
  _useState2 = _slicedToArray(_useState, 2),
50559
50736
  focusedIndex = _useState2[0],
50560
50737
  setFocusedIndex = _useState2[1];
50561
- var checkboxRefs = useRef([]);
50562
- var isMaxSelectionReached = maxSelections && maxSelections === (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
50563
- var isChecked = function isChecked(option) {
50564
- return selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.some(function (selectedOption) {
50565
- return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.name) === (option === null || option === void 0 ? void 0 : option.name);
50738
+ var itemRefs = useRef([]);
50739
+ var totalItemsLength = options.length + appliedOptions.length;
50740
+ var handleArrowUp = function handleArrowUp(event) {
50741
+ event.preventDefault();
50742
+ setFocusedIndex(function (prevIndex) {
50743
+ return prevIndex > 0 ? prevIndex - 1 : totalItemsLength - 1;
50566
50744
  });
50567
50745
  };
50568
- useEffect$1(function () {
50569
- if (focusedIndex !== -1 && checkboxRefs.current && checkboxRefs.current[focusedIndex]) {
50570
- checkboxRefs.current[focusedIndex].focus(); // move focus to the active option
50746
+ var handleArrowDown = function handleArrowDown(event) {
50747
+ event.preventDefault();
50748
+ setFocusedIndex(function (prevIndex) {
50749
+ return prevIndex < totalItemsLength - 1 ? prevIndex + 1 : 0;
50750
+ });
50751
+ };
50752
+ var handleSpacebar = function handleSpacebar(event) {
50753
+ event.preventDefault();
50754
+ var validFocusedIndex = focusedIndex < 0 ? 0 : focusedIndex;
50755
+ // Select option on spacebar press if the maximum selection hasn't been reached.
50756
+ if (!isMaxSelectionReached(maxSelections, selectedOptions) && itemRefs.current && itemRefs.current[validFocusedIndex]) {
50757
+ var nestedInput = itemRefs.current[validFocusedIndex].querySelector("input");
50758
+ if (nestedInput) {
50759
+ nestedInput.click();
50760
+ }
50571
50761
  }
50572
- }, [focusedIndex]);
50762
+ };
50763
+ var handleTab = function handleTab(event) {
50764
+ // Reset focus when tabbing out of the list.
50765
+ setFocusedIndex(-1);
50766
+ };
50767
+ var keyActions = {
50768
+ " ": function _(event) {
50769
+ return handleSpacebar(event);
50770
+ },
50771
+ Space: function Space(event) {
50772
+ return handleSpacebar(event);
50773
+ },
50774
+ Tab: function Tab(event) {
50775
+ return handleTab();
50776
+ },
50777
+ ArrowUp: function ArrowUp(event) {
50778
+ return handleArrowUp(event);
50779
+ },
50780
+ ArrowDown: function ArrowDown(event) {
50781
+ return handleArrowDown(event);
50782
+ }
50783
+ };
50573
50784
  var handleKeyDown = function handleKeyDown(event) {
50574
- if (event.key === "ArrowDown") {
50575
- event.preventDefault();
50576
- setFocusedIndex(function (prevIndex) {
50577
- return prevIndex < optionsList.length - 1 ? prevIndex + 1 : 0;
50578
- });
50579
- } else if (event.key === "ArrowUp") {
50580
- event.preventDefault();
50581
- setFocusedIndex(function (prevIndex) {
50582
- return prevIndex > 0 ? prevIndex - 1 : optionsList.length - 1;
50583
- });
50584
- } else if (event.key === " ") {
50585
- event.preventDefault();
50586
- // Select option on spacebar press if the maximum selection hasn't been reached.
50587
- var validFocusedIndex = focusedIndex < 0 ? 0 : focusedIndex;
50588
- if (!isMaxSelectionReached || focusedIndex !== -1 && isChecked(optionsList[validFocusedIndex])) {
50589
- selectOption(optionsList[validFocusedIndex]);
50590
- }
50591
- } else if (event.key === "Tab") {
50592
- // Reset focus when tabbing out of the list.
50593
- setTimeout(function () {
50594
- setFocusedIndex(-1);
50595
- }, 500);
50785
+ var eventKey = event.code || event.key;
50786
+ var action = keyActions[eventKey];
50787
+ if (action) {
50788
+ action(event);
50596
50789
  }
50597
50790
  };
50791
+ useEffect$1(function () {
50792
+ if (focusedIndex !== -1 && itemRefs.current && itemRefs.current[focusedIndex]) {
50793
+ itemRefs.current[focusedIndex].focus(); // move focus to the active option
50794
+ }
50795
+ }, [focusedIndex]);
50796
+ return {
50797
+ itemRefs: itemRefs,
50798
+ focusedIndex: focusedIndex,
50799
+ handleKeyDown: handleKeyDown
50800
+ };
50801
+ };
50802
+
50803
+ var FilterableList = function FilterableList(_ref) {
50804
+ var id = _ref.id,
50805
+ options = _ref.options,
50806
+ appliedOptions = _ref.appliedOptions,
50807
+ selectedOptions = _ref.selectedOptions,
50808
+ maxSelections = _ref.maxSelections,
50809
+ name = _ref.name,
50810
+ setSelectedOptions = _ref.setSelectedOptions,
50811
+ searchTerm = _ref.searchTerm,
50812
+ themeValues = _ref.themeValues;
50813
+ var _useState = useState([]),
50814
+ _useState2 = _slicedToArray(_useState, 2),
50815
+ filteredOptions = _useState2[0],
50816
+ setFilteredOptions = _useState2[1];
50817
+ var _useState3 = useState([]),
50818
+ _useState4 = _slicedToArray(_useState3, 2),
50819
+ filteredAppliedOptions = _useState4[0],
50820
+ setFilteredAppliedOptions = _useState4[1];
50821
+ useEffect$1(function () {
50822
+ setFilteredOptions(options);
50823
+ setFilteredAppliedOptions(appliedOptions);
50824
+ }, [options, appliedOptions]);
50825
+ useEffect$1(function () {
50826
+ var filteredOptionItems = filterItemsList(options, searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.rawValue);
50827
+ var filteredAppliedItems = filterItemsList(appliedOptions, searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.rawValue);
50828
+ setFilteredOptions(filteredOptionItems.length ? filteredOptionItems : filteredOptions);
50829
+ setFilteredAppliedOptions(filteredAppliedItems);
50830
+ }, [searchTerm.rawValue]);
50831
+ var handleSelectOption = function handleSelectOption(option) {
50832
+ return selectOption(option, selectedOptions, setSelectedOptions);
50833
+ };
50834
+ var isAppliedOption = function isAppliedOption(option) {
50835
+ return filteredAppliedOptions === null || filteredAppliedOptions === void 0 ? void 0 : filteredAppliedOptions.some(function (appliedItem) {
50836
+ return (appliedItem === null || appliedItem === void 0 ? void 0 : appliedItem.name) === (option === null || option === void 0 ? void 0 : option.name);
50837
+ });
50838
+ };
50839
+ var currentFilteredOptions = filteredOptions.filter(function (option) {
50840
+ return !isAppliedOption(option);
50841
+ });
50842
+ var sortedOptions = sortItemsList(currentFilteredOptions);
50843
+ var sortedAppliedOptions = sortItemsList(filteredAppliedOptions);
50844
+ var _useKeyboardNavigatio = useKeyboardNavigation({
50845
+ options: sortedOptions,
50846
+ appliedOptions: sortedAppliedOptions,
50847
+ selectedOptions: selectedOptions,
50848
+ maxSelections: maxSelections
50849
+ }),
50850
+ itemRefs = _useKeyboardNavigatio.itemRefs,
50851
+ focusedIndex = _useKeyboardNavigatio.focusedIndex,
50852
+ handleKeyDown = _useKeyboardNavigatio.handleKeyDown;
50598
50853
  return /*#__PURE__*/React.createElement(Box, {
50599
50854
  id: id,
50600
50855
  role: "listbox",
50601
50856
  padding: "0",
50602
- extraStyles: "\n overflow-y: auto; \n max-height: 250px; \n display: flex; \n flex-flow: column;\n ",
50857
+ extraStyles: "\n overflow-y: auto;\n max-height: 250px;\n display: flex;\n flex-flow: column;\n ",
50603
50858
  onKeyDown: handleKeyDown
50604
- }, optionsList.map(function (option, index) {
50605
- var checked = isChecked(option);
50606
- var isDisabled = isMaxSelectionReached && !checked;
50859
+ }, (sortedAppliedOptions === null || sortedAppliedOptions === void 0 ? void 0 : sortedAppliedOptions.length) > 0 && /*#__PURE__*/React.createElement(Box, {
50860
+ padding: "0",
50861
+ extraStyles: sortedOptions.length > 0 && "border-bottom: 1px solid ".concat(GHOST_GREY)
50862
+ }, sortedAppliedOptions.map(function (option, index) {
50863
+ var checked = isChecked(option, selectedOptions);
50607
50864
  var tabIndex = index === focusedIndex || index === 0 && focusedIndex === -1 ? "0" : "-1";
50608
- return /*#__PURE__*/React.createElement(Box, {
50609
- padding: "0",
50865
+ return /*#__PURE__*/React.createElement(FilterableListItem, {
50610
50866
  key: index,
50611
- extraStyles: "\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n ")
50612
- }, /*#__PURE__*/React.createElement(Checkbox$1, {
50613
50867
  ref: function ref(el) {
50614
- return checkboxRefs.current[index] = el;
50868
+ return itemRefs.current[index] = el;
50615
50869
  },
50616
- title: option.name,
50617
- name: option.name,
50870
+ index: index,
50871
+ option: option,
50618
50872
  checked: checked,
50619
- onChange: function onChange() {
50620
- return isDisabled ? noop : selectOption(option);
50873
+ selectOption: handleSelectOption,
50874
+ tabIndex: tabIndex,
50875
+ name: name,
50876
+ themeValues: themeValues
50877
+ });
50878
+ })), sortedOptions.map(function (option, index) {
50879
+ var checked = isChecked(option, selectedOptions);
50880
+ var isDisabled = isMaxSelectionReached(maxSelections, selectedOptions) && !checked;
50881
+ var indexOffset = sortedAppliedOptions !== null && sortedAppliedOptions !== void 0 && sortedAppliedOptions.length ? sortedAppliedOptions === null || sortedAppliedOptions === void 0 ? void 0 : sortedAppliedOptions.length : 0;
50882
+ var currentIndex = index === 0 ? indexOffset : index + indexOffset;
50883
+ var tabIndex = currentIndex === focusedIndex || indexOffset === 0 && currentIndex === indexOffset && focusedIndex === -1 ? "0" : "-1";
50884
+ return /*#__PURE__*/React.createElement(FilterableListItem, {
50885
+ key: currentIndex,
50886
+ ref: function ref(el) {
50887
+ return itemRefs.current[currentIndex] = el;
50621
50888
  },
50622
- textExtraStyles: "font-size: 0.875rem; margin: 0;",
50889
+ index: currentIndex,
50890
+ option: option,
50891
+ checked: checked,
50892
+ selectOption: isDisabled ? noop : handleSelectOption,
50623
50893
  disabled: isDisabled,
50624
- extraStyles: "\n padding: 0.075rem 0.325rem; \n margin: 0;\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n "),
50625
- checkboxMargin: "0.3rem",
50626
- role: "option",
50627
- checkboxExtraStyles: "\n width: 1.375rem; \n height: 1.375rem; \n ".concat(checked && !isDisabled ? "background: " + themeValues.secondaryColor + ";" : ""),
50628
50894
  tabIndex: tabIndex,
50629
- dataQa: "".concat(name, "-option-").concat(index)
50630
- }));
50895
+ name: name,
50896
+ themeValues: themeValues
50897
+ });
50631
50898
  }));
50632
50899
  };
50633
- var MultipleSelectFilter = function MultipleSelectFilter(_ref2) {
50634
- var actions = _ref2.actions,
50635
- autocompleteValue = _ref2.autocompleteValue,
50636
- btnContentOverride = _ref2.btnContentOverride,
50637
- disabled = _ref2.disabled,
50638
- extraStyles = _ref2.extraStyles,
50639
- fields = _ref2.fields,
50640
- filterLabel = _ref2.filterLabel,
50641
- _ref2$hasIcon = _ref2.hasIcon,
50642
- hasIcon = _ref2$hasIcon === void 0 ? false : _ref2$hasIcon,
50643
- Icon = _ref2.icon,
50644
- maxSelections = _ref2.maxSelections,
50645
- _ref2$name = _ref2.name,
50646
- name = _ref2$name === void 0 ? "MultipleSelectFilter" : _ref2$name,
50647
- _ref2$onApply = _ref2.onApply,
50648
- onApply = _ref2$onApply === void 0 ? noop : _ref2$onApply,
50649
- _ref2$onClear = _ref2.onClear,
50650
- onClear = _ref2$onClear === void 0 ? noop : _ref2$onClear,
50651
- options = _ref2.options,
50652
- _ref2$placeholder = _ref2.placeholder,
50653
- placeholder = _ref2$placeholder === void 0 ? "Search" : _ref2$placeholder,
50654
- _ref2$searchable = _ref2.searchable,
50655
- searchable = _ref2$searchable === void 0 ? true : _ref2$searchable,
50656
- selectedOptions = _ref2.selectedOptions,
50657
- setSelectedOptions = _ref2.setSelectedOptions,
50658
- themeValues = _ref2.themeValues,
50659
- _ref2$truncateBtnText = _ref2.truncateBtnTextWidth,
50660
- truncateBtnTextWidth = _ref2$truncateBtnText === void 0 ? "15rem" : _ref2$truncateBtnText;
50900
+ var FilterableList$1 = /*#__PURE__*/React.memo(FilterableList);
50901
+
50902
+ var MultipleSelectFilter = function MultipleSelectFilter(_ref) {
50903
+ var actions = _ref.actions,
50904
+ autocompleteValue = _ref.autocompleteValue,
50905
+ btnContentOverride = _ref.btnContentOverride,
50906
+ disabled = _ref.disabled,
50907
+ extraStyles = _ref.extraStyles,
50908
+ fields = _ref.fields,
50909
+ filterLabel = _ref.filterLabel,
50910
+ _ref$hasIcon = _ref.hasIcon,
50911
+ hasIcon = _ref$hasIcon === void 0 ? false : _ref$hasIcon,
50912
+ Icon = _ref.icon,
50913
+ maxSelections = _ref.maxSelections,
50914
+ _ref$name = _ref.name,
50915
+ name = _ref$name === void 0 ? "MultipleSelectFilter" : _ref$name,
50916
+ _ref$onApply = _ref.onApply,
50917
+ onApply = _ref$onApply === void 0 ? noop$1 : _ref$onApply,
50918
+ _ref$onClear = _ref.onClear,
50919
+ onClear = _ref$onClear === void 0 ? noop$1 : _ref$onClear,
50920
+ options = _ref.options,
50921
+ _ref$placeholder = _ref.placeholder,
50922
+ placeholder = _ref$placeholder === void 0 ? "Search" : _ref$placeholder,
50923
+ _ref$searchable = _ref.searchable,
50924
+ searchable = _ref$searchable === void 0 ? true : _ref$searchable,
50925
+ selectedOptions = _ref.selectedOptions,
50926
+ setSelectedOptions = _ref.setSelectedOptions,
50927
+ themeValues = _ref.themeValues,
50928
+ _ref$truncateBtnTextW = _ref.truncateBtnTextWidth,
50929
+ truncateBtnTextWidth = _ref$truncateBtnTextW === void 0 ? "15rem" : _ref$truncateBtnTextW;
50930
+ var _useState = useState(false),
50931
+ _useState2 = _slicedToArray(_useState, 2),
50932
+ opened = _useState2[0],
50933
+ setOpened = _useState2[1];
50661
50934
  var _useState3 = useState([]),
50662
50935
  _useState4 = _slicedToArray(_useState3, 2),
50663
- itemList = _useState4[0],
50664
- setItemList = _useState4[1];
50665
- var _useState5 = useState(false),
50666
- _useState6 = _slicedToArray(_useState5, 2),
50667
- opened = _useState6[0],
50668
- setOpened = _useState6[1];
50669
- var containerRef = useRef(null);
50936
+ appliedOptions = _useState4[0],
50937
+ setAppliedOptions = _useState4[1];
50938
+ var handleClickOutsideContainer = function handleClickOutsideContainer() {
50939
+ setOpened(false);
50940
+ actions.fields.searchTerm.set("");
50941
+ onApply(selectedOptions);
50942
+ };
50943
+ var containerRef = useOutsideClickHook(function () {
50944
+ return handleClickOutsideContainer();
50945
+ });
50670
50946
  var dropdownRef = useRef(null);
50671
50947
  var filterButtonRef = useRef(null);
50672
50948
  var applyFilterButtonRef = useRef(null);
50673
50949
  var filterDropdownID = "".concat(name, "-filter-dropdown");
50674
50950
  var checkboxListID = "".concat(name, "-checkbox-list");
50675
- var backgroundColor = opened ? themeValues.primaryColor : selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? themeValues.secondaryColor : WHITE;
50676
- var contentColor = !opened && selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? WHITE : "#292A33";
50677
- var completeOptionsList = itemList.slice().sort(function (a, b) {
50678
- return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
50679
- });
50680
- var selectValues = function selectValues(items) {
50681
- return items.map(function (item) {
50682
- return item.value;
50683
- });
50684
- };
50685
- var selectOption = function selectOption(selectedOption) {
50686
- if (selectValues(selectedOptions).includes(selectedOption.value)) {
50687
- var fewerOptions = selectedOptions.filter(function (option) {
50688
- return option.value !== selectedOption.value;
50689
- });
50690
- setSelectedOptions(fewerOptions);
50691
- } else {
50692
- var moreOptions = selectedOptions.concat(selectedOption);
50693
- setSelectedOptions(moreOptions);
50694
- }
50695
- };
50696
- useEffect$1(function () {
50697
- return setItemList(options);
50698
- }, [options]);
50699
50951
  useEffect$1(function () {
50700
- var filteredItems = options.filter(function (item) {
50701
- var _item$name, _fields$searchTerm;
50702
- return item === null || item === void 0 || (_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.toLowerCase().includes(fields === null || fields === void 0 || (_fields$searchTerm = fields.searchTerm) === null || _fields$searchTerm === void 0 || (_fields$searchTerm = _fields$searchTerm.rawValue) === null || _fields$searchTerm === void 0 ? void 0 : _fields$searchTerm.toLowerCase());
50703
- });
50704
- // If no items are filtered, display the entire list of options.
50705
- if (filteredItems !== null && filteredItems !== void 0 && filteredItems.length) {
50706
- setItemList(filteredItems);
50707
- } else {
50708
- setItemList(options);
50952
+ if (!opened) {
50953
+ onApply(selectedOptions);
50954
+ setAppliedOptions(selectedOptions);
50709
50955
  }
50710
- }, [fields.searchTerm.rawValue]);
50956
+ }, [opened]);
50711
50957
  useEffect$1(function () {
50712
50958
  var handleKeyDown = function handleKeyDown(event) {
50713
50959
  if (event.key === "Escape") {
@@ -50724,114 +50970,72 @@ var MultipleSelectFilter = function MultipleSelectFilter(_ref2) {
50724
50970
  onApply(selectedOptions);
50725
50971
  }
50726
50972
  };
50727
- var handleClickOutside = function handleClickOutside(event) {
50728
- if (containerRef.current && !containerRef.current.contains(event.target) && dropdownRef.current && !dropdownRef.current.contains(event.target)) {
50729
- setOpened(false);
50730
- actions.fields.searchTerm.set("");
50731
- onApply(selectedOptions);
50732
- }
50733
- };
50734
- document.addEventListener("mousedown", handleClickOutside);
50735
50973
  document.addEventListener("keydown", handleKeyDown);
50736
50974
  return function () {
50737
- document.addEventListener("mousedown", handleClickOutside);
50738
50975
  document.removeEventListener("keydown", handleKeyDown);
50739
50976
  };
50740
50977
  }, []);
50741
50978
  return /*#__PURE__*/React.createElement(FilterContainer, {
50742
50979
  ref: containerRef,
50743
50980
  extraStyles: "".concat(extraStyles)
50744
- }, /*#__PURE__*/React.createElement(FilterButton, {
50981
+ }, /*#__PURE__*/React.createElement(FilterButton$1, {
50745
50982
  ref: filterButtonRef,
50746
- variant: "tertiary",
50983
+ btnContentOverride: btnContentOverride,
50747
50984
  action: function action() {
50748
50985
  actions.fields.searchTerm.set("");
50749
50986
  setOpened(!opened);
50750
50987
  },
50751
- "aria-haspopup": "listbox",
50752
- "aria-expanded": opened,
50753
- "aria-controls": filterDropdownID,
50754
- backgroundColor: backgroundColor,
50755
- dataQa: "".concat(name, "-filter-button"),
50756
- contentOverride: true
50757
- }, btnContentOverride ? btnContentOverride : /*#__PURE__*/React.createElement(Center, {
50758
- as: "span",
50759
- style: {
50760
- display: "flex",
50761
- flexDirection: "row"
50762
- },
50763
- intrinsic: true
50764
- }, hasIcon && /*#__PURE__*/React.createElement(Icon, {
50765
- color: contentColor
50766
- }), /*#__PURE__*/React.createElement(Center, {
50767
- as: "span",
50768
- style: {
50769
- display: "flex",
50770
- flexDirection: "row",
50771
- padding: "0 0.5rem 0 0.25rem"
50772
- },
50773
- intrinsic: true
50774
- }, /*#__PURE__*/React.createElement(Text$1, {
50775
- variant: "pS",
50776
- color: contentColor,
50777
- extraStyles: "\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ".concat(truncateBtnTextWidth && "max-width:" + truncateBtnTextWidth, "\n ")
50778
- }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? "".concat(filterLabel ? filterLabel + ": " : "").concat(selectedOptions[0].name) : "".concat(filterLabel ? filterLabel : "")), /*#__PURE__*/React.createElement(Text$1, {
50779
- color: contentColor,
50780
- variant: "pS"
50781
- }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length && (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) > 1 ? ", +".concat((selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length) - 1, " More") : "")), /*#__PURE__*/React.createElement(DropdownIconV2, {
50782
- color: contentColor
50783
- }))), /*#__PURE__*/React.createElement(FilterDropdown, {
50988
+ opened: opened,
50989
+ backgroundColor: opened ? themeValues.primaryColor : selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? themeValues.secondaryColor : WHITE,
50990
+ contentColor: !opened && selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? WHITE : CHARADE_GREY,
50991
+ name: name,
50992
+ filterDropdownID: filterDropdownID,
50993
+ hasIcon: hasIcon,
50994
+ icon: Icon,
50995
+ truncateBtnTextWidth: truncateBtnTextWidth,
50996
+ filterLabel: filterLabel,
50997
+ selectedOptions: selectedOptions
50998
+ }), /*#__PURE__*/React.createElement(FilterDropdown, {
50784
50999
  id: filterDropdownID,
50785
51000
  ref: dropdownRef,
50786
- hidden: !opened,
50787
- role: "combobox",
50788
- "aria-expanded": opened,
50789
- "aria-haspopup": "listbox",
50790
- "aria-owns": checkboxListID
50791
- }, /*#__PURE__*/React.createElement(Box, {
50792
- padding: "0 0 0.5rem"
50793
- }, searchable && (options === null || options === void 0 ? void 0 : options.length) > 8 && /*#__PURE__*/React.createElement(FormInput$1, {
51001
+ ariaOwns: checkboxListID,
51002
+ opened: opened
51003
+ }, /*#__PURE__*/React.createElement(SearchBox, {
51004
+ showSearchBox: searchable && (options === null || options === void 0 ? void 0 : options.length) > 8,
50794
51005
  autocompleteValue: autocompleteValue,
50795
- showFieldErrorRow: false,
50796
- errorMessages: {},
50797
- field: fields.searchTerm,
50798
- fieldActions: actions.fields.searchTerm,
51006
+ fields: fields,
51007
+ actions: actions,
50799
51008
  placeholder: placeholder,
50800
- disabled: disabled,
50801
- extraStyles: "\n height: 2.875rem;\n border: 0; \n border-radius: 0;\n padding: 0.45rem;\n font-size: 0.875rem;\n border-bottom: 1px solid ".concat(GHOST_GREY, ";\n ")
50802
- })), /*#__PURE__*/React.createElement(ScrollableOptionsList, {
51009
+ disabled: disabled
51010
+ }), /*#__PURE__*/React.createElement(FilterableList$1, {
50803
51011
  id: checkboxListID,
50804
- optionsList: completeOptionsList,
50805
- selectedOptions: selectedOptions,
51012
+ options: options,
51013
+ appliedOptions: appliedOptions,
50806
51014
  themeValues: themeValues,
50807
- selectOption: selectOption,
51015
+ selectedOptions: selectedOptions,
50808
51016
  maxSelections: maxSelections,
50809
- name: name
51017
+ name: name,
51018
+ setSelectedOptions: setSelectedOptions,
51019
+ searchTerm: fields === null || fields === void 0 ? void 0 : fields.searchTerm
50810
51020
  }), /*#__PURE__*/React.createElement(Box, {
50811
51021
  padding: "0 0.5rem 0.0625rem 0.5rem",
50812
51022
  extraStyles: "\n max-height: 100px; \n display: flex; \n flex-flow: row; \n justify-content: space-between;\n border-top: 1px solid ".concat(GHOST_GREY, ";\n ")
50813
- }, /*#__PURE__*/React.createElement(ButtonWithAction, {
51023
+ }, /*#__PURE__*/React.createElement(ActionLinkButton, {
50814
51024
  action: function action() {
50815
51025
  setOpened(false);
50816
51026
  setSelectedOptions([]);
50817
51027
  actions.fields.searchTerm.set("");
50818
51028
  onClear();
50819
51029
  },
50820
- variant: "tertiary",
50821
- extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50822
- textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50823
51030
  text: "Clear",
50824
51031
  dataQa: "".concat(name, "-clear-filters")
50825
- }), /*#__PURE__*/React.createElement(ButtonWithAction, {
51032
+ }), /*#__PURE__*/React.createElement(ActionLinkButton, {
50826
51033
  ref: applyFilterButtonRef,
50827
51034
  action: function action() {
50828
51035
  setOpened(false);
50829
51036
  actions.fields.searchTerm.set("");
50830
51037
  onApply(selectedOptions);
50831
51038
  },
50832
- variant: "tertiary",
50833
- extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50834
- textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50835
51039
  text: "Apply",
50836
51040
  dataQa: "".concat(name, "-apply-filters")
50837
51041
  }))));