@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.cjs.js CHANGED
@@ -6249,7 +6249,7 @@ return numeral;
6249
6249
  }));
6250
6250
  });
6251
6251
 
6252
- var noop = function noop() {};
6252
+ var noop$1 = function noop() {};
6253
6253
  var formatMoneyString = function formatMoneyString(s) {
6254
6254
  return numeral(s).format("$0,0.00");
6255
6255
  };
@@ -6383,7 +6383,7 @@ var wrapIndex = function wrapIndex(index, length) {
6383
6383
 
6384
6384
  var general = /*#__PURE__*/Object.freeze({
6385
6385
  __proto__: null,
6386
- noop: noop,
6386
+ noop: noop$1,
6387
6387
  displayCurrency: displayCurrency,
6388
6388
  convertCentsToMoneyInt: convertCentsToMoneyInt,
6389
6389
  formatPercent: formatPercent,
@@ -10575,7 +10575,7 @@ var isRefObject = function (ref) {
10575
10575
  return typeof ref === "object" && ref.hasOwnProperty("current");
10576
10576
  };
10577
10577
 
10578
- var noop$1 = function (v) { return v; };
10578
+ var noop$2 = function (v) { return v; };
10579
10579
  var ComponentDragControls = /** @class */ (function () {
10580
10580
  function ComponentDragControls(_a) {
10581
10581
  var ref = _a.ref, values = _a.values, controls = _a.controls;
@@ -10603,7 +10603,7 @@ var ComponentDragControls = /** @class */ (function () {
10603
10603
  * @internal
10604
10604
  */
10605
10605
  this.props = {
10606
- transformPagePoint: noop$1,
10606
+ transformPagePoint: noop$2,
10607
10607
  };
10608
10608
  /**
10609
10609
  * References to the MotionValues used for tracking the current dragged point.
@@ -13033,7 +13033,7 @@ var Spinner = function Spinner(_ref) {
13033
13033
 
13034
13034
  var ButtonWithAction = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
13035
13035
  var _ref2$action = _ref2.action,
13036
- action = _ref2$action === void 0 ? noop : _ref2$action,
13036
+ action = _ref2$action === void 0 ? noop$1 : _ref2$action,
13037
13037
  _ref2$variant = _ref2.variant,
13038
13038
  variant = _ref2$variant === void 0 ? "primary" : _ref2$variant,
13039
13039
  text = _ref2.text,
@@ -13075,7 +13075,7 @@ var ButtonWithAction = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
13075
13075
  disabledStyles: disabledStyles,
13076
13076
  "aria-disabled": disabled,
13077
13077
  as: "button",
13078
- onClick: isLoading || disabled ? noop : action,
13078
+ onClick: isLoading || disabled ? noop$1 : action,
13079
13079
  borderRadius: "2px",
13080
13080
  theme: themeContext,
13081
13081
  extraStyles: "margin: 0.5rem; ".concat(extraStyles),
@@ -23248,7 +23248,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
23248
23248
  name = _ref5.name,
23249
23249
  checked = _ref5.checked,
23250
23250
  _ref5$onChange = _ref5.onChange,
23251
- onChange = _ref5$onChange === void 0 ? noop : _ref5$onChange,
23251
+ onChange = _ref5$onChange === void 0 ? noop$1 : _ref5$onChange,
23252
23252
  _ref5$disabled = _ref5.disabled,
23253
23253
  disabled = _ref5$disabled === void 0 ? false : _ref5$disabled,
23254
23254
  themeValues = _ref5.themeValues,
@@ -23447,7 +23447,7 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
23447
23447
  padding: "0.875rem",
23448
23448
  borderRadius: "4px",
23449
23449
  minWidth: "30%",
23450
- onClick: disabled ? noop : onSelect,
23450
+ onClick: disabled ? noop$1 : onSelect,
23451
23451
  borderColor: borderColor,
23452
23452
  borderSize: "1px",
23453
23453
  color: color,
@@ -23462,8 +23462,8 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
23462
23462
  name: name,
23463
23463
  "aria-label": name,
23464
23464
  htmlFor: "checkbox-".concat(name, "-").concat(index),
23465
- onClick: disabled ? noop : onSelect,
23466
- onKeyDown: disabled ? noop : onSelect,
23465
+ onClick: disabled ? noop$1 : onSelect,
23466
+ onKeyDown: disabled ? noop$1 : onSelect,
23467
23467
  tabIndex: 0
23468
23468
  }, /*#__PURE__*/React__default.createElement(styled.ThemeProvider, {
23469
23469
  theme: {
@@ -23691,7 +23691,7 @@ var SortableTableHeading = function SortableTableHeading(_ref) {
23691
23691
  disabled: disabled,
23692
23692
  extraStyles: "cursor: pointer; ".concat(extraStyles),
23693
23693
  onClick: function onClick(event) {
23694
- return disabled ? noop : onSortChange(event);
23694
+ return disabled ? noop$1 : onSortChange(event);
23695
23695
  },
23696
23696
  "aria-controls": ariaControlsId
23697
23697
  }, /*#__PURE__*/React__default.createElement(Cluster, {
@@ -25121,7 +25121,7 @@ var Dropdown = function Dropdown(_ref13) {
25121
25121
  _ref13$disabledValues = _ref13.disabledValues,
25122
25122
  disabledValues = _ref13$disabledValues === void 0 ? [] : _ref13$disabledValues,
25123
25123
  _ref13$onClick = _ref13.onClick,
25124
- _onClick = _ref13$onClick === void 0 ? noop : _ref13$onClick,
25124
+ _onClick = _ref13$onClick === void 0 ? noop$1 : _ref13$onClick,
25125
25125
  themeValues = _ref13.themeValues,
25126
25126
  maxHeight = _ref13.maxHeight,
25127
25127
  _ref13$widthFitOption = _ref13.widthFitOptions,
@@ -26570,6 +26570,15 @@ var DisplayBox$1 = themeComponent(DisplayBox, "DisplayBox", fallbackValues$l);
26570
26570
  var useOutsideClickHook = function useOutsideClickHook(handler) {
26571
26571
  var ref = React.useRef();
26572
26572
  React.useEffect(function () {
26573
+ var handleOutsideClick = function handleOutsideClick(e) {
26574
+ if (ref.current && !ref.current.contains(e.target)) {
26575
+ handler();
26576
+ }
26577
+ };
26578
+ document.addEventListener("click", handleOutsideClick, true);
26579
+ return function () {
26580
+ document.removeEventListener("click", handleOutsideClick, true);
26581
+ };
26573
26582
  }, [ref]);
26574
26583
  return ref;
26575
26584
  };
@@ -26760,13 +26769,15 @@ var Popover = function Popover(_ref) {
26760
26769
  togglePopover(popoverState);
26761
26770
  }
26762
26771
  };
26763
- var triggerRef = useOutsideClickHook();
26772
+ var triggerRef = useOutsideClickHook(function () {
26773
+ return handleTogglePopover(false);
26774
+ });
26764
26775
  return /*#__PURE__*/React__default.createElement(Box, {
26765
26776
  padding: "0",
26766
26777
  extraStyles: "position: relative; ".concat(extraStyles)
26767
26778
  }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
26768
26779
  action: function action() {
26769
- return noop;
26780
+ return noop$1;
26770
26781
  },
26771
26782
  onFocus: function onFocus() {
26772
26783
  handleTogglePopover(true);
@@ -27096,83 +27107,79 @@ var createFormat = function createFormat(formats, formatChar) {
27096
27107
  var FormattedInput = function FormattedInput(_ref) {
27097
27108
  var value = _ref.value,
27098
27109
  formatter = _ref.formatter,
27099
- onChange = _ref.onChange,
27110
+ _onChange = _ref.onChange,
27100
27111
  props = _objectWithoutProperties$1(_ref, ["value", "formatter", "onChange"]);
27101
27112
 
27102
- var _useState = React.useState(format$1(formatter)(value)),
27103
- _useState2 = _slicedToArray$1(_useState, 2),
27104
- formattedValue = _useState2[0],
27105
- setFormattedValue = _useState2[1];
27106
-
27107
27113
  var inputEl = React.useRef(null);
27108
- var stateRefs = React.useRef({
27114
+
27115
+ var _useState = React.useState({
27109
27116
  selectionStart: 0,
27110
27117
  selectionEnd: 0,
27111
- isDelete: false,
27112
- rawValue: ''
27113
- });
27118
+ rawValue: value,
27119
+ "delete": false,
27120
+ formattedValue: format$1(formatter)(value)
27121
+ }),
27122
+ _useState2 = _slicedToArray$1(_useState, 2),
27123
+ state = _useState2[0],
27124
+ setState = _useState2[1];
27125
+
27114
27126
  React.useLayoutEffect(function () {
27115
27127
  // A lot of the work here is cursor manipulation
27116
27128
  if (inputEl.current && inputEl.current === document.activeElement) {
27117
- inputEl.current.setSelectionRange(stateRefs.current.selectionStart, stateRefs.current.selectionEnd);
27118
- }
27119
- }, [stateRefs]);
27120
-
27121
- var handleChange = function handleChange(event) {
27122
- var deleteKeyPressed = stateRefs.current.isDelete;
27123
- var maxFormatExceeded = stateRefs.current.rawValue.length >= formatter.formats.length - 1;
27124
-
27125
- if (maxFormatExceeded && !deleteKeyPressed) {
27126
- return;
27127
- }
27128
- /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
27129
- * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
27130
- * the unformatted value for the user's onChange, the formatted string and unformatted injection need
27131
- * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
27132
- * old unformatted value.
27133
- */
27134
-
27135
-
27136
- var injectionLength = event.target.value.length - formattedValue.length;
27137
- var end = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? stateRefs.current.selectionStart + injectionLength : stateRefs.current.selectionEnd - 1;
27138
- var injection = event.target.value.substring(stateRefs.current.selectionStart, end); // Injection is the new unformatted piece of the input
27139
- // Need to find where to put it
27140
-
27141
- var rawInjectionPointStart = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter);
27142
- var rawInjectionPointEnd = formattedToUnformattedIndex(stateRefs.current.selectionEnd, stateRefs.current.rawValue, formatter); // Unformat the previous formatted value for injection
27143
- // Using the relevant format string, strips away chars not marked with the formatChar
27144
-
27145
- var unformattedOldValue = unformat(formatter)(formattedValue, stateRefs.current.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
27146
-
27147
- var injectIntoOldValue = inject(unformattedOldValue);
27148
- var unformattedNewValue = deleteKeyPressed ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
27149
- var lengthDifference = unformattedNewValue.length - stateRefs.current.rawValue.length;
27150
- var rawIndex = formattedToUnformattedIndex(stateRefs.current.selectionStart, stateRefs.current.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
27151
- // Applied by useLayoutEffect
27152
-
27153
- var newFormattedCursorPosition = stateRefs.current.selectionStart === stateRefs.current.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, deleteKeyPressed) : deleteKeyPressed ? stateRefs.current.selectionStart : stateRefs.current.selectionEnd;
27154
- var formattedNewValue = format$1(formatter)(unformattedNewValue);
27155
- setFormattedValue(formattedNewValue); // Apply the external onChange function to the raw underlying string
27156
- // This is where the user generally updates the input value
27157
-
27158
- if (onChange) {
27159
- onChange(unformattedNewValue);
27129
+ inputEl.current.setSelectionRange(state.selectionStart, state.selectionEnd);
27160
27130
  }
27161
- };
27162
-
27131
+ });
27163
27132
  return React__default.createElement("input", _extends$2({}, props, {
27164
27133
  ref: inputEl,
27165
27134
  value: format$1(formatter)(value),
27166
27135
  onKeyDown: function onKeyDown(event) {
27167
- // Keep track of the state of the input before onChange
27168
- stateRefs.current = {
27169
- isDelete: event.key === "Backspace" || event.key === "Delete",
27136
+ // Keep track of the state of the input before onChange, including if user is hitting delete
27137
+ setState({
27138
+ rawValue: value,
27170
27139
  selectionStart: event.target.selectionStart,
27171
27140
  selectionEnd: event.target.selectionEnd,
27172
- rawValue: value
27173
- };
27141
+ "delete": event.key === "Backspace" || event.key === "Delete",
27142
+ formattedValue: event.target.value
27143
+ });
27174
27144
  },
27175
- onChange: handleChange
27145
+ onChange: function onChange(event) {
27146
+ /* At the beginning of onChange, event.target.value is a concat of the previous formatted value
27147
+ * and an unformatted injection at the start, end, or in the middle (maybe a deletion). To prepare
27148
+ * the unformatted value for the user's onChange, the formatted string and unformatted injection need
27149
+ * to be separated, then unformat the formatted string, then insert (or delete) the injection from the
27150
+ * old unformatted value.
27151
+ */
27152
+ var injectionLength = event.target.value.length - state.formattedValue.length;
27153
+ var end = state.selectionStart === state.selectionEnd ? state.selectionStart + injectionLength : state.selectionEnd - 1;
27154
+ var injection = event.target.value.substring(state.selectionStart, end); // Injection is the new unformatted piece of the input
27155
+ // Need to find where to put it
27156
+
27157
+ var rawInjectionPointStart = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter);
27158
+ var rawInjectionPointEnd = formattedToUnformattedIndex(state.selectionEnd, state.rawValue, formatter); // Unformat the previous formatted value for injection
27159
+ // Using the relevant format string, strips away chars not marked with the formatChar
27160
+
27161
+ var unformattedOldValue = unformat(formatter)(state.formattedValue, state.rawValue.length); // Edit the previous unformatted value (either add, update or delete)
27162
+
27163
+ var injectIntoOldValue = inject(unformattedOldValue);
27164
+ var unformattedNewValue = state["delete"] ? rawInjectionPointStart === rawInjectionPointEnd ? injectIntoOldValue(rawInjectionPointStart - 1, rawInjectionPointStart, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, "") : injectIntoOldValue(rawInjectionPointStart, rawInjectionPointEnd, injection);
27165
+ var lengthDifference = unformattedNewValue.length - state.rawValue.length;
27166
+ var rawIndex = formattedToUnformattedIndex(state.selectionStart, state.rawValue, formatter) + lengthDifference; // Find the new cursor position for the potential formatted value
27167
+ // Applied by useLayoutEffect
27168
+
27169
+ var newFormattedCursorPosition = state.selectionStart == state.selectionEnd ? unformattedToFormattedIndex(rawIndex, unformattedNewValue, formatter, state["delete"]) : state["delete"] ? state.selectionStart : state.selectionEnd;
27170
+ setState({
27171
+ selectionStart: newFormattedCursorPosition,
27172
+ selectionEnd: newFormattedCursorPosition,
27173
+ rawValue: state.rawValue,
27174
+ "delete": false,
27175
+ formattedValue: state.formattedValue
27176
+ }); // Apply the external onChange function to the raw underlying string
27177
+ // This is where the user generally updates the input value
27178
+
27179
+ if (_onChange) {
27180
+ _onChange(unformattedNewValue);
27181
+ }
27182
+ }
27176
27183
  }));
27177
27184
  };
27178
27185
 
@@ -27769,7 +27776,7 @@ var HamburgerButton = function HamburgerButton(_ref4) {
27769
27776
  inactiveColor = _ref4.inactiveColor,
27770
27777
  isActive = _ref4.isActive,
27771
27778
  _ref4$onClick = _ref4.onClick,
27772
- onClick = _ref4$onClick === void 0 ? noop : _ref4$onClick,
27779
+ onClick = _ref4$onClick === void 0 ? noop$1 : _ref4$onClick,
27773
27780
  controls = _ref4.controls;
27774
27781
  return /*#__PURE__*/React__default.createElement(Hamburger, {
27775
27782
  className: isActive === true ? "active" : "",
@@ -28660,7 +28667,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
28660
28667
  themeValues = _ref5.themeValues,
28661
28668
  index = _ref5.index,
28662
28669
  _ref5$handleChange = _ref5.handleChange,
28663
- handleChange = _ref5$handleChange === void 0 ? noop : _ref5$handleChange,
28670
+ handleChange = _ref5$handleChange === void 0 ? noop$1 : _ref5$handleChange,
28664
28671
  field = _ref5.field,
28665
28672
  config = _ref5.config;
28666
28673
  var getDefaultChecked = function getDefaultChecked(value, idx) {
@@ -28877,7 +28884,7 @@ var Search = function Search(_ref) {
28877
28884
  "aria-controls": ariaControlsId,
28878
28885
  extraStyles: "border-radius: 4px 0 0 4px; border: none; box-shadow: 0px 1px 2px 0px ".concat(CHARADE_GREY, "1A; font-size: 0.875rem;"),
28879
28886
  onKeyDown: function onKeyDown(e) {
28880
- return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop;
28887
+ return searchOnKeypress || e.key === "Enter" ? handleSubmit() : noop$1;
28881
28888
  },
28882
28889
  field: field,
28883
28890
  fieldActions: fieldActions,
@@ -39665,7 +39672,7 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
39665
39672
  _ref10$isOn = _ref10.isOn,
39666
39673
  isOn = _ref10$isOn === void 0 ? false : _ref10$isOn,
39667
39674
  _ref10$onToggle = _ref10.onToggle,
39668
- onToggle = _ref10$onToggle === void 0 ? noop : _ref10$onToggle,
39675
+ onToggle = _ref10$onToggle === void 0 ? noop$1 : _ref10$onToggle,
39669
39676
  _ref10$disabled = _ref10.disabled,
39670
39677
  disabled = _ref10$disabled === void 0 ? false : _ref10$disabled,
39671
39678
  _ref10$name = _ref10.name,
@@ -39765,13 +39772,13 @@ var ToggleSwitch = function ToggleSwitch(_ref10) {
39765
39772
  "aria-labelledby": label ? "".concat(nameId, "-label") : null,
39766
39773
  "aria-describedby": ariaDescribedBy ? ariaDescribedBy : null,
39767
39774
  checked: isOn,
39768
- onChange: disabled ? noop : onToggle,
39775
+ onChange: disabled ? noop$1 : onToggle,
39769
39776
  disabled: disabled,
39770
39777
  id: "#".concat(nameId),
39771
39778
  isMobile: isMobile
39772
39779
  }), /*#__PURE__*/React__default.createElement(VisibleSwitch, {
39773
- onClick: disabled ? noop : onToggle,
39774
- onKeyDown: disabled ? noop : handleKeyDown,
39780
+ onClick: disabled ? noop$1 : onToggle,
39781
+ onKeyDown: disabled ? noop$1 : handleKeyDown,
39775
39782
  pose: isOn ? "on" : "off",
39776
39783
  tabIndex: disabled ? -1 : 0,
39777
39784
  disabled: disabled,
@@ -39940,7 +39947,7 @@ var Card = function Card(_ref) {
39940
39947
  imgObjectFit = _ref$imgObjectFit === void 0 ? "none" : _ref$imgObjectFit,
39941
39948
  imgAltText = _ref.imgAltText,
39942
39949
  _ref$onQuitClick = _ref.onQuitClick,
39943
- onQuitClick = _ref$onQuitClick === void 0 ? noop : _ref$onQuitClick,
39950
+ onQuitClick = _ref$onQuitClick === void 0 ? noop$1 : _ref$onQuitClick,
39944
39951
  _ref$padding = _ref.padding,
39945
39952
  padding = _ref$padding === void 0 ? "24px" : _ref$padding,
39946
39953
  _ref$showQuitLink = _ref.showQuitLink,
@@ -40973,7 +40980,7 @@ var AddressForm = function AddressForm(_ref) {
40973
40980
  clearOnDismount = _ref.clearOnDismount,
40974
40981
  showErrors = _ref.showErrors,
40975
40982
  _ref$handleSubmit = _ref.handleSubmit,
40976
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
40983
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
40977
40984
  showWalletCheckbox = _ref.showWalletCheckbox,
40978
40985
  saveToWallet = _ref.saveToWallet,
40979
40986
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -41173,7 +41180,7 @@ var ChangePasswordForm = function ChangePasswordForm(_ref) {
41173
41180
  fields = _ref.fields,
41174
41181
  actions = _ref.actions,
41175
41182
  _ref$handleSubmit = _ref.handleSubmit,
41176
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
41183
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
41177
41184
  showErrors = _ref.showErrors,
41178
41185
  isMobile = _ref.isMobile,
41179
41186
  revenueManagement = _ref.revenueManagement,
@@ -41384,8 +41391,8 @@ var CollapsibleSection = function CollapsibleSection(_ref) {
41384
41391
  }, /*#__PURE__*/React__default.createElement(Box, {
41385
41392
  padding: customPadding ? customPadding : "0",
41386
41393
  background: themeValues.headingBackgroundColor,
41387
- onClick: isMobile && supportsTouch ? noop : toggleSection,
41388
- onTouchEnd: isMobile && supportsTouch ? toggleSection : noop,
41394
+ onClick: isMobile && supportsTouch ? noop$1 : toggleSection,
41395
+ onTouchEnd: isMobile && supportsTouch ? toggleSection : noop$1,
41389
41396
  key: "header",
41390
41397
  hoverStyles: "cursor: pointer;",
41391
41398
  tabIndex: "0",
@@ -41603,7 +41610,7 @@ var EditNameForm = function EditNameForm(_ref) {
41603
41610
  clearOnDismount = _ref.clearOnDismount,
41604
41611
  showErrors = _ref.showErrors,
41605
41612
  _ref$handleSubmit = _ref.handleSubmit,
41606
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
41613
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
41607
41614
  if (clearOnDismount) {
41608
41615
  React.useEffect(function () {
41609
41616
  return function () {
@@ -41946,7 +41953,7 @@ var EmailForm = function EmailForm(_ref) {
41946
41953
  showErrors = _ref.showErrors,
41947
41954
  guestCheckout = _ref.guestCheckout,
41948
41955
  _ref$handleSubmit = _ref.handleSubmit,
41949
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
41956
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
41950
41957
  showWalletCheckbox = _ref.showWalletCheckbox,
41951
41958
  saveToWallet = _ref.saveToWallet,
41952
41959
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -42044,7 +42051,7 @@ var ForgotPasswordForm = function ForgotPasswordForm(_ref) {
42044
42051
  clearOnDismount = _ref.clearOnDismount,
42045
42052
  showErrors = _ref.showErrors,
42046
42053
  _ref$handleSubmit = _ref.handleSubmit,
42047
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
42054
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
42048
42055
  if (clearOnDismount) {
42049
42056
  React.useEffect(function () {
42050
42057
  return function () {
@@ -42638,7 +42645,7 @@ var LinkCard = function LinkCard(_ref) {
42638
42645
  extraStyles: extraStyles,
42639
42646
  hoverStyles: extraHoverStyles,
42640
42647
  activeStyles: extraActiveStyles,
42641
- onClick: disabled ? noop : onClick,
42648
+ onClick: disabled ? noop$1 : onClick,
42642
42649
  "aria-disabled": disabled,
42643
42650
  isDisabled: disabled,
42644
42651
  role: "group",
@@ -42687,7 +42694,7 @@ var LoginForm = function LoginForm(_ref) {
42687
42694
  actions = _ref.actions,
42688
42695
  showErrors = _ref.showErrors,
42689
42696
  _ref$handleSubmit = _ref.handleSubmit,
42690
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit;
42697
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit;
42691
42698
  if (clearOnDismount) {
42692
42699
  React.useEffect(function () {
42693
42700
  return function () {
@@ -46357,13 +46364,13 @@ var CancelButton = function CancelButton(_ref) {
46357
46364
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46358
46365
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46359
46366
  _ref$cancelAction = _ref.cancelAction,
46360
- cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46367
+ cancelAction = _ref$cancelAction === void 0 ? noop$1 : _ref$cancelAction,
46361
46368
  _ref$cancelButtonText = _ref.cancelButtonText,
46362
46369
  cancelButtonText = _ref$cancelButtonText === void 0 ? "" : _ref$cancelButtonText,
46363
46370
  _ref$cancelButtonVari = _ref.cancelButtonVariant,
46364
46371
  cancelButtonVariant = _ref$cancelButtonVari === void 0 ? "secondary" : _ref$cancelButtonVari,
46365
46372
  _ref$hideModal = _ref.hideModal,
46366
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46373
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46367
46374
  _ref$isMobile = _ref.isMobile,
46368
46375
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46369
46376
  var fontSize = "font-size: ".concat(isMobile ? FONT_SIZE.XS : FONT_SIZE.SM, ";");
@@ -46390,7 +46397,7 @@ var CloseButton = function CloseButton(_ref) {
46390
46397
  _ref$closeButtonVaria = _ref.closeButtonVariant,
46391
46398
  closeButtonVariant = _ref$closeButtonVaria === void 0 ? "primary" : _ref$closeButtonVaria,
46392
46399
  _ref$hideModal = _ref.hideModal,
46393
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46400
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46394
46401
  _ref$isMobile = _ref.isMobile,
46395
46402
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile;
46396
46403
  var fontSize = "font-size: ".concat(isMobile ? FONT_SIZE.XS : FONT_SIZE.SM, ";");
@@ -46412,7 +46419,7 @@ var CloseButton = function CloseButton(_ref) {
46412
46419
  var CloseIconButton = function CloseIconButton(_ref) {
46413
46420
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46414
46421
  _ref$hideModal = _ref.hideModal,
46415
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46422
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46416
46423
  _ref$iconWidth = _ref.iconWidth,
46417
46424
  iconWidth = _ref$iconWidth === void 0 ? "24px" : _ref$iconWidth,
46418
46425
  _ref$iconHeight = _ref.iconHeight,
@@ -46437,7 +46444,7 @@ var ContinueButton = function ContinueButton(_ref) {
46437
46444
  var _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46438
46445
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46439
46446
  _ref$continueAction = _ref.continueAction,
46440
- continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46447
+ continueAction = _ref$continueAction === void 0 ? noop$1 : _ref$continueAction,
46441
46448
  _ref$continueButtonTe = _ref.continueButtonText,
46442
46449
  continueButtonText = _ref$continueButtonTe === void 0 ? "" : _ref$continueButtonTe,
46443
46450
  _ref$continueURL = _ref.continueURL,
@@ -46492,7 +46499,7 @@ var Modal$2 = function Modal(_ref) {
46492
46499
  _ref$buttonExtraStyle = _ref.buttonExtraStyles,
46493
46500
  buttonExtraStyles = _ref$buttonExtraStyle === void 0 ? "" : _ref$buttonExtraStyle,
46494
46501
  _ref$cancelAction = _ref.cancelAction,
46495
- cancelAction = _ref$cancelAction === void 0 ? noop : _ref$cancelAction,
46502
+ cancelAction = _ref$cancelAction === void 0 ? noop$1 : _ref$cancelAction,
46496
46503
  _ref$cancelButtonText = _ref.cancelButtonText,
46497
46504
  cancelButtonText = _ref$cancelButtonText === void 0 ? "Cancel" : _ref$cancelButtonText,
46498
46505
  _ref$cancelButtonVari = _ref.cancelButtonVariant,
@@ -46504,7 +46511,7 @@ var Modal$2 = function Modal(_ref) {
46504
46511
  _ref$closeButtonVaria = _ref.closeButtonVariant,
46505
46512
  closeButtonVariant = _ref$closeButtonVaria === void 0 ? "primary" : _ref$closeButtonVaria,
46506
46513
  _ref$continueAction = _ref.continueAction,
46507
- continueAction = _ref$continueAction === void 0 ? noop : _ref$continueAction,
46514
+ continueAction = _ref$continueAction === void 0 ? noop$1 : _ref$continueAction,
46508
46515
  _ref$continueButtonTe = _ref.continueButtonText,
46509
46516
  continueButtonText = _ref$continueButtonTe === void 0 ? "Continue" : _ref$continueButtonTe,
46510
46517
  _ref$continueButtonVa = _ref.continueButtonVariant,
@@ -46518,7 +46525,7 @@ var Modal$2 = function Modal(_ref) {
46518
46525
  _ref$defaultWrapper = _ref.defaultWrapper,
46519
46526
  defaultWrapper = _ref$defaultWrapper === void 0 ? true : _ref$defaultWrapper,
46520
46527
  _ref$hideModal = _ref.hideModal,
46521
- hideModal = _ref$hideModal === void 0 ? noop : _ref$hideModal,
46528
+ hideModal = _ref$hideModal === void 0 ? noop$1 : _ref$hideModal,
46522
46529
  _ref$initialFocusSele = _ref.initialFocusSelector,
46523
46530
  initialFocusSelector = _ref$initialFocusSele === void 0 ? "" : _ref$initialFocusSele,
46524
46531
  _ref$isContinueAction = _ref.isContinueActionDisabled,
@@ -46999,13 +47006,13 @@ var AmountModule = function AmountModule(_ref) {
46999
47006
  subDescription: subDescription,
47000
47007
  allowedPaymentInstruments: allowedPaymentInstruments,
47001
47008
  disableActions: disableActions,
47002
- action: disableActions ? noop : function () {
47009
+ action: disableActions ? noop$1 : function () {
47003
47010
  return toggleModal(true);
47004
47011
  },
47005
- onClick: disableActions ? noop : function () {
47012
+ onClick: disableActions ? noop$1 : function () {
47006
47013
  toggleModal(true);
47007
47014
  },
47008
- onKeyPress: disableActions ? noop : function (e) {
47015
+ onKeyPress: disableActions ? noop$1 : function (e) {
47009
47016
  e.key === "Enter" && toggleModal(true);
47010
47017
  }
47011
47018
  })));
@@ -47135,7 +47142,7 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
47135
47142
  padding: "0"
47136
47143
  }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
47137
47144
  isLoading: isLoading,
47138
- action: disableActions ? noop : function () {
47145
+ action: disableActions ? noop$1 : function () {
47139
47146
  return handleClick(obligations);
47140
47147
  },
47141
47148
  text: "Pay Now",
@@ -47147,7 +47154,7 @@ var PaymentDetailsActions = function PaymentDetailsActions(_ref) {
47147
47154
  width: "100%"
47148
47155
  }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
47149
47156
  isLoading: isLoading,
47150
- action: disableActions ? noop : function () {
47157
+ action: disableActions ? noop$1 : function () {
47151
47158
  return handleClick(obligations);
47152
47159
  },
47153
47160
  text: "Pay Now",
@@ -47202,7 +47209,7 @@ var RemoveAccountModalModule = function RemoveAccountModalModule(_ref) {
47202
47209
  }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
47203
47210
  text: "Remove",
47204
47211
  variant: "secondary",
47205
- action: disableActions ? noop : function () {
47212
+ action: disableActions ? noop$1 : function () {
47206
47213
  return setModalIsOpen(true);
47207
47214
  },
47208
47215
  dataQa: "Remove Account",
@@ -47274,7 +47281,7 @@ var InactiveControlsModule = function InactiveControlsModule(_ref) {
47274
47281
  extraStyles: "flex-grow: 1;"
47275
47282
  }, /*#__PURE__*/React__default.createElement(RemoveAccountModalModule, {
47276
47283
  agencyName: agencyName,
47277
- removeAccount: disableActions ? noop : handleRemoveAccount,
47284
+ removeAccount: disableActions ? noop$1 : handleRemoveAccount,
47278
47285
  accountType: configType === "ACCOUNT" ? "Account" : "Property",
47279
47286
  isMobile: isMobile,
47280
47287
  disableActions: disableActions
@@ -47835,7 +47842,7 @@ var Pagination = function Pagination(_ref3) {
47835
47842
  return setCurrentPage({
47836
47843
  pageNumber: item.index
47837
47844
  });
47838
- } : noop,
47845
+ } : noop$1,
47839
47846
  textExtraStyles: "font-size: ".concat(fontSize, "; font-weight: ").concat(fontWeight, ";"),
47840
47847
  extraStyles: "".concat(extraStyles).concat(item.active ? currentPageStyles : ""),
47841
47848
  dataQa: index
@@ -48198,7 +48205,7 @@ var PaymentDetails = function PaymentDetails(_ref4) {
48198
48205
  _ref4$voidableTransac = _ref4.voidableTransactionDetails,
48199
48206
  voidableTransactionDetails = _ref4$voidableTransac === void 0 ? [] : _ref4$voidableTransac,
48200
48207
  _ref4$partialVoidActi = _ref4.partialVoidAction,
48201
- partialVoidAction = _ref4$partialVoidActi === void 0 ? noop : _ref4$partialVoidActi,
48208
+ partialVoidAction = _ref4$partialVoidActi === void 0 ? noop$1 : _ref4$partialVoidActi,
48202
48209
  _ref4$voidableAmountP = _ref4.voidableAmountPaid,
48203
48210
  voidableAmountPaid = _ref4$voidableAmountP === void 0 ? 0 : _ref4$voidableAmountP,
48204
48211
  _ref4$remainingBalanc = _ref4.remainingBalance,
@@ -48675,7 +48682,7 @@ var PaymentFormACH = function PaymentFormACH(_ref) {
48675
48682
  actions = _ref.actions,
48676
48683
  showErrors = _ref.showErrors,
48677
48684
  _ref$handleSubmit = _ref.handleSubmit,
48678
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
48685
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
48679
48686
  showWalletCheckbox = _ref.showWalletCheckbox,
48680
48687
  saveToWallet = _ref.saveToWallet,
48681
48688
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -48877,7 +48884,7 @@ var PaymentFormCard = function PaymentFormCard(_ref) {
48877
48884
  actions = _ref.actions,
48878
48885
  showErrors = _ref.showErrors,
48879
48886
  _ref$handleSubmit = _ref.handleSubmit,
48880
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
48887
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
48881
48888
  showWalletCheckbox = _ref.showWalletCheckbox,
48882
48889
  saveToWallet = _ref.saveToWallet,
48883
48890
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -49182,7 +49189,7 @@ var PhoneForm = function PhoneForm(_ref) {
49182
49189
  clearOnDismount = _ref.clearOnDismount,
49183
49190
  showErrors = _ref.showErrors,
49184
49191
  _ref$handleSubmit = _ref.handleSubmit,
49185
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49192
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49186
49193
  showWalletCheckbox = _ref.showWalletCheckbox,
49187
49194
  saveToWallet = _ref.saveToWallet,
49188
49195
  walletCheckboxMarked = _ref.walletCheckboxMarked,
@@ -49266,7 +49273,7 @@ var RadioGroup = function RadioGroup(_ref2) {
49266
49273
  config = _ref2.config,
49267
49274
  extraStyles = _ref2.extraStyles,
49268
49275
  _ref2$handleChange = _ref2.handleChange,
49269
- handleChange = _ref2$handleChange === void 0 ? noop : _ref2$handleChange,
49276
+ handleChange = _ref2$handleChange === void 0 ? noop$1 : _ref2$handleChange,
49270
49277
  field = _ref2.field,
49271
49278
  fieldActions = _ref2.fieldActions;
49272
49279
  var setValue = function setValue(value) {
@@ -49331,7 +49338,7 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49331
49338
  ariaLabelledBy = _ref.ariaLabelledBy,
49332
49339
  isLastGroupedItemInSection = _ref.isLastGroupedItemInSection,
49333
49340
  _ref$onKeyDown = _ref.onKeyDown,
49334
- onKeyDown = _ref$onKeyDown === void 0 ? noop : _ref$onKeyDown;
49341
+ onKeyDown = _ref$onKeyDown === void 0 ? noop$1 : _ref$onKeyDown;
49335
49342
  var wrapper = {
49336
49343
  open: {
49337
49344
  height: openHeight,
@@ -49388,12 +49395,12 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49388
49395
  "aria-required": section.required,
49389
49396
  "aria-labelledby": ariaLabelledBy,
49390
49397
  "aria-describedby": ariaDescribedBy,
49391
- onClick: isMobile && supportsTouch || section.disabled || section.id === openSection ? noop : function () {
49398
+ onClick: isMobile && supportsTouch || section.disabled || section.id === openSection ? noop$1 : function () {
49392
49399
  return toggleOpenSection(section.id);
49393
49400
  },
49394
49401
  onTouchEnd: isMobile && supportsTouch && !section.disabled && section.id !== openSection ? function () {
49395
49402
  return toggleOpenSection(section.id);
49396
- } : noop,
49403
+ } : noop$1,
49397
49404
  id: "inner-radio-section-".concat(sectionIndex),
49398
49405
  "data-qa": section.dataQa ? section.dataQa : section.id || "inner-radio-section-".concat(sectionIndex)
49399
49406
  }, /*#__PURE__*/React__default.createElement(Stack, {
@@ -49423,7 +49430,7 @@ var InnerRadioSection = function InnerRadioSection(_ref) {
49423
49430
  ariaDescribedBy: ariaDescribedBy,
49424
49431
  radioOn: openSection === section.id,
49425
49432
  radioFocused: focused === section.id,
49426
- toggleRadio: section.disabled ? noop : function () {
49433
+ toggleRadio: section.disabled ? noop$1 : function () {
49427
49434
  return toggleOpenSection(section.id);
49428
49435
  },
49429
49436
  tabIndex: "-1",
@@ -49608,7 +49615,7 @@ var RegistrationForm = function RegistrationForm(_ref) {
49608
49615
  fields = _ref.fields,
49609
49616
  actions = _ref.actions,
49610
49617
  _ref$handleSubmit = _ref.handleSubmit,
49611
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49618
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49612
49619
  showErrors = _ref.showErrors,
49613
49620
  isMobile = _ref.isMobile;
49614
49621
  if (clearOnDismount) {
@@ -49775,7 +49782,7 @@ var ResetConfirmationForm$1 = withWindowSize(ResetConfirmationForm);
49775
49782
 
49776
49783
  var ResetPasswordForm = function ResetPasswordForm(_ref) {
49777
49784
  var _ref$handleSubmit = _ref.handleSubmit,
49778
- handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
49785
+ handleSubmit = _ref$handleSubmit === void 0 ? noop$1 : _ref$handleSubmit,
49779
49786
  clearOnDismount = _ref.clearOnDismount,
49780
49787
  fields = _ref.fields,
49781
49788
  actions = _ref.actions,
@@ -50469,6 +50476,58 @@ var fallbackValues$_ = {
50469
50476
  secondaryColor: secondaryColor
50470
50477
  };
50471
50478
 
50479
+ var StyledFilterContainer = styled__default(Box).withConfig({
50480
+ displayName: "MultipleSelectFilterstyled__StyledFilterContainer",
50481
+ componentId: "sc-126xgc2-0"
50482
+ })(["position:relative;box-sizing:border-box;padding:0;", ""], function (_ref) {
50483
+ var extraStyles = _ref.extraStyles;
50484
+ return extraStyles;
50485
+ });
50486
+ var FilterContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
50487
+ return /*#__PURE__*/React__default.createElement(StyledFilterContainer, _extends({
50488
+ ref: ref
50489
+ }, props));
50490
+ });
50491
+ var StyledFilterDropdown = styled__default(Box).withConfig({
50492
+ displayName: "MultipleSelectFilterstyled__StyledFilterDropdown",
50493
+ componentId: "sc-126xgc2-1"
50494
+ })(["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;"]);
50495
+ var FilterDropdownContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
50496
+ return /*#__PURE__*/React__default.createElement(StyledFilterDropdown, _extends({
50497
+ ref: ref
50498
+ }, props));
50499
+ });
50500
+ var FilterButton = styled__default(ButtonWithAction).withConfig({
50501
+ displayName: "MultipleSelectFilterstyled__FilterButton",
50502
+ componentId: "sc-126xgc2-2"
50503
+ })(["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) {
50504
+ var textColor = _ref2.textColor;
50505
+ return "\n color: ".concat(textColor, ";\n ");
50506
+ }, function (_ref3) {
50507
+ var backgroundColor = _ref3.backgroundColor;
50508
+ return "\n background-color: ".concat(backgroundColor, ";\n :hover,\n :active,\n :focus {\n background-color: ").concat(backgroundColor, ";\n }\n ");
50509
+ });
50510
+ var StyledFilterButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
50511
+ return /*#__PURE__*/React__default.createElement(FilterButton, _extends({
50512
+ ref: ref
50513
+ }, props));
50514
+ });
50515
+
50516
+ var ActionLinkButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50517
+ var action = _ref.action,
50518
+ text = _ref.text,
50519
+ dataQa = _ref.dataQa;
50520
+ return /*#__PURE__*/React__default.createElement(ButtonWithAction, {
50521
+ ref: ref,
50522
+ action: action,
50523
+ variant: "tertiary",
50524
+ extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50525
+ textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50526
+ text: text,
50527
+ dataQa: dataQa
50528
+ });
50529
+ });
50530
+
50472
50531
  var _excluded$J = ["width", "height", "color"];
50473
50532
  var DropdownIconV2 = function DropdownIconV2(_ref) {
50474
50533
  var _ref$width = _ref.width,
@@ -50517,205 +50576,392 @@ var DropdownIconV2 = function DropdownIconV2(_ref) {
50517
50576
  }))));
50518
50577
  };
50519
50578
 
50520
- var StyledFilterContainer = styled__default(Box).withConfig({
50521
- displayName: "MultipleSelectFilterstyled__StyledFilterContainer",
50522
- componentId: "sc-126xgc2-0"
50523
- })(["position:relative;box-sizing:border-box;padding:0;", ""], function (_ref) {
50524
- var extraStyles = _ref.extraStyles;
50525
- return extraStyles;
50526
- });
50527
- var FilterContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
50528
- return /*#__PURE__*/React__default.createElement(StyledFilterContainer, _extends({
50529
- ref: ref
50530
- }, props));
50531
- });
50532
- var StyledFilterDropdown = styled__default(Box).withConfig({
50533
- displayName: "MultipleSelectFilterstyled__StyledFilterDropdown",
50534
- componentId: "sc-126xgc2-1"
50535
- })(["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;"]);
50536
- var FilterDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
50537
- return /*#__PURE__*/React__default.createElement(StyledFilterDropdown, _extends({
50538
- ref: ref
50539
- }, props));
50579
+ var FilterButton$1 = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50580
+ var btnContentOverride = _ref.btnContentOverride,
50581
+ _ref$action = _ref.action,
50582
+ action = _ref$action === void 0 ? noop$1 : _ref$action,
50583
+ opened = _ref.opened,
50584
+ backgroundColor = _ref.backgroundColor,
50585
+ contentColor = _ref.contentColor,
50586
+ name = _ref.name,
50587
+ filterDropdownID = _ref.filterDropdownID,
50588
+ _ref$hasIcon = _ref.hasIcon,
50589
+ hasIcon = _ref$hasIcon === void 0 ? false : _ref$hasIcon,
50590
+ Icon = _ref.icon,
50591
+ truncateBtnTextWidth = _ref.truncateBtnTextWidth,
50592
+ filterLabel = _ref.filterLabel,
50593
+ selectedOptions = _ref.selectedOptions;
50594
+ return /*#__PURE__*/React__default.createElement(StyledFilterButton, {
50595
+ ref: ref,
50596
+ variant: "tertiary",
50597
+ action: action,
50598
+ "aria-haspopup": "listbox",
50599
+ "aria-expanded": opened,
50600
+ "aria-controls": filterDropdownID,
50601
+ backgroundColor: backgroundColor,
50602
+ dataQa: "".concat(name, "-filter-button"),
50603
+ contentOverride: true
50604
+ }, btnContentOverride ? btnContentOverride : /*#__PURE__*/React__default.createElement(Center, {
50605
+ as: "span",
50606
+ style: {
50607
+ display: "flex",
50608
+ flexDirection: "row"
50609
+ },
50610
+ intrinsic: true
50611
+ }, hasIcon && /*#__PURE__*/React__default.createElement(Icon, {
50612
+ color: contentColor
50613
+ }), /*#__PURE__*/React__default.createElement(Center, {
50614
+ as: "span",
50615
+ style: {
50616
+ display: "flex",
50617
+ flexDirection: "row",
50618
+ padding: "0 0.5rem 0 0.25rem"
50619
+ },
50620
+ intrinsic: true
50621
+ }, /*#__PURE__*/React__default.createElement(Text$1, {
50622
+ variant: "pS",
50623
+ color: contentColor,
50624
+ extraStyles: "\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ".concat(truncateBtnTextWidth && "max-width:" + truncateBtnTextWidth, "\n ")
50625
+ }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? "".concat(filterLabel ? filterLabel + ": " : "").concat(selectedOptions[0].name) : "".concat(filterLabel ? filterLabel : "")), /*#__PURE__*/React__default.createElement(Text$1, {
50626
+ color: contentColor,
50627
+ variant: "pS"
50628
+ }, 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__default.createElement(DropdownIconV2, {
50629
+ color: contentColor
50630
+ })));
50540
50631
  });
50541
- var StyledFilterButton = styled__default(ButtonWithAction).withConfig({
50542
- displayName: "MultipleSelectFilterstyled__StyledFilterButton",
50543
- componentId: "sc-126xgc2-2"
50544
- })(["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) {
50545
- var textColor = _ref2.textColor;
50546
- return "\n color: ".concat(textColor, ";\n ");
50547
- }, function (_ref3) {
50548
- var backgroundColor = _ref3.backgroundColor;
50549
- return "\n background-color: ".concat(backgroundColor, ";\n :hover,\n :active,\n :focus {\n background-color: ").concat(backgroundColor, ";\n }\n ");
50632
+
50633
+ var FilterDropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50634
+ var id = _ref.id,
50635
+ ariaOwns = _ref.ariaOwns,
50636
+ opened = _ref.opened,
50637
+ children = _ref.children;
50638
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, opened && /*#__PURE__*/React__default.createElement(FilterDropdownContainer, {
50639
+ ref: ref,
50640
+ id: id,
50641
+ role: "combobox",
50642
+ "aria-expanded": opened,
50643
+ "aria-haspopup": "listbox",
50644
+ "aria-owns": ariaOwns
50645
+ }, children));
50550
50646
  });
50551
- var FilterButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
50552
- return /*#__PURE__*/React__default.createElement(StyledFilterButton, _extends({
50553
- ref: ref
50554
- }, props));
50647
+
50648
+ var SearchBox = function SearchBox(_ref) {
50649
+ var autocompleteValue = _ref.autocompleteValue,
50650
+ fields = _ref.fields,
50651
+ actions = _ref.actions,
50652
+ placeholder = _ref.placeholder,
50653
+ disabled = _ref.disabled,
50654
+ showSearchBox = _ref.showSearchBox;
50655
+ return /*#__PURE__*/React__default.createElement(Box, {
50656
+ padding: "0 0 0.5rem"
50657
+ }, showSearchBox && /*#__PURE__*/React__default.createElement(FormInput$1, {
50658
+ autocompleteValue: autocompleteValue,
50659
+ showFieldErrorRow: false,
50660
+ errorMessages: {},
50661
+ field: fields.searchTerm,
50662
+ fieldActions: actions.fields.searchTerm,
50663
+ placeholder: placeholder,
50664
+ disabled: disabled,
50665
+ 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 ")
50666
+ }));
50667
+ };
50668
+
50669
+ var FilterableListItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50670
+ var index = _ref.index,
50671
+ option = _ref.option,
50672
+ checked = _ref.checked,
50673
+ selectOption = _ref.selectOption,
50674
+ disabled = _ref.disabled,
50675
+ tabIndex = _ref.tabIndex,
50676
+ name = _ref.name,
50677
+ themeValues = _ref.themeValues;
50678
+ return /*#__PURE__*/React__default.createElement(Box, {
50679
+ padding: "0",
50680
+ key: index,
50681
+ extraStyles: "\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n ")
50682
+ }, /*#__PURE__*/React__default.createElement(Checkbox$1, {
50683
+ ref: ref,
50684
+ title: option.name,
50685
+ name: option.name,
50686
+ checked: checked,
50687
+ onChange: function onChange() {
50688
+ return selectOption(option);
50689
+ },
50690
+ textExtraStyles: "font-size: 0.875rem; margin: 0;",
50691
+ disabled: disabled,
50692
+ extraStyles: "\n padding: 0.075rem 0.325rem; \n margin: 0;\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n "),
50693
+ checkboxMargin: "0.3rem",
50694
+ role: "option",
50695
+ checkboxExtraStyles: "\n width: 1.375rem; \n height: 1.375rem;\n ".concat(checked && !disabled ? "background: " + themeValues.secondaryColor + ";" : "", "\n "),
50696
+ tabIndex: tabIndex,
50697
+ dataQa: "".concat(name, "-option-").concat(index)
50698
+ }));
50555
50699
  });
50556
50700
 
50557
- var ScrollableOptionsList = function ScrollableOptionsList(_ref) {
50558
- var id = _ref.id,
50559
- optionsList = _ref.optionsList,
50701
+ var filterItemsList = function filterItemsList(list, searchTerm) {
50702
+ return list.filter(function (item) {
50703
+ var _item$name;
50704
+ 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());
50705
+ });
50706
+ };
50707
+ var sortItemsList = function sortItemsList(list) {
50708
+ return list.slice().sort(function (a, b) {
50709
+ return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
50710
+ });
50711
+ };
50712
+ var isMaxSelectionReached = function isMaxSelectionReached(maxSelection, selectedOptions) {
50713
+ return maxSelection && maxSelection === (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
50714
+ };
50715
+ var isChecked = function isChecked(option, selectedOptions) {
50716
+ return selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.some(function (selectedOption) {
50717
+ return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.name) === (option === null || option === void 0 ? void 0 : option.name);
50718
+ });
50719
+ };
50720
+ var selectValues = function selectValues(items) {
50721
+ return items.map(function (item) {
50722
+ return item.value;
50723
+ });
50724
+ };
50725
+ var selectOption = function selectOption(option, selectedOptions, setSelectedOptions) {
50726
+ if (selectValues(selectedOptions).includes(option.value)) {
50727
+ var fewerOptions = selectedOptions.filter(function (selectedOption) {
50728
+ return selectedOption.value !== option.value;
50729
+ });
50730
+ setSelectedOptions(fewerOptions);
50731
+ } else {
50732
+ var moreOptions = selectedOptions.concat(option);
50733
+ setSelectedOptions(moreOptions);
50734
+ }
50735
+ };
50736
+
50737
+ var useKeyboardNavigation = function useKeyboardNavigation(_ref) {
50738
+ var options = _ref.options,
50739
+ appliedOptions = _ref.appliedOptions,
50560
50740
  selectedOptions = _ref.selectedOptions,
50561
- themeValues = _ref.themeValues,
50562
- selectOption = _ref.selectOption,
50563
- maxSelections = _ref.maxSelections,
50564
- name = _ref.name;
50741
+ maxSelections = _ref.maxSelections;
50565
50742
  var _useState = React.useState(-1),
50566
50743
  _useState2 = _slicedToArray(_useState, 2),
50567
50744
  focusedIndex = _useState2[0],
50568
50745
  setFocusedIndex = _useState2[1];
50569
- var checkboxRefs = React.useRef([]);
50570
- var isMaxSelectionReached = maxSelections && maxSelections === (selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
50571
- var isChecked = function isChecked(option) {
50572
- return selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.some(function (selectedOption) {
50573
- return (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.name) === (option === null || option === void 0 ? void 0 : option.name);
50746
+ var itemRefs = React.useRef([]);
50747
+ var totalItemsLength = options.length + appliedOptions.length;
50748
+ var handleArrowUp = function handleArrowUp(event) {
50749
+ event.preventDefault();
50750
+ setFocusedIndex(function (prevIndex) {
50751
+ return prevIndex > 0 ? prevIndex - 1 : totalItemsLength - 1;
50574
50752
  });
50575
50753
  };
50576
- React.useEffect(function () {
50577
- if (focusedIndex !== -1 && checkboxRefs.current && checkboxRefs.current[focusedIndex]) {
50578
- checkboxRefs.current[focusedIndex].focus(); // move focus to the active option
50754
+ var handleArrowDown = function handleArrowDown(event) {
50755
+ event.preventDefault();
50756
+ setFocusedIndex(function (prevIndex) {
50757
+ return prevIndex < totalItemsLength - 1 ? prevIndex + 1 : 0;
50758
+ });
50759
+ };
50760
+ var handleSpacebar = function handleSpacebar(event) {
50761
+ event.preventDefault();
50762
+ var validFocusedIndex = focusedIndex < 0 ? 0 : focusedIndex;
50763
+ // Select option on spacebar press if the maximum selection hasn't been reached.
50764
+ if (!isMaxSelectionReached(maxSelections, selectedOptions) && itemRefs.current && itemRefs.current[validFocusedIndex]) {
50765
+ var nestedInput = itemRefs.current[validFocusedIndex].querySelector("input");
50766
+ if (nestedInput) {
50767
+ nestedInput.click();
50768
+ }
50579
50769
  }
50580
- }, [focusedIndex]);
50770
+ };
50771
+ var handleTab = function handleTab(event) {
50772
+ // Reset focus when tabbing out of the list.
50773
+ setFocusedIndex(-1);
50774
+ };
50775
+ var keyActions = {
50776
+ " ": function _(event) {
50777
+ return handleSpacebar(event);
50778
+ },
50779
+ Space: function Space(event) {
50780
+ return handleSpacebar(event);
50781
+ },
50782
+ Tab: function Tab(event) {
50783
+ return handleTab();
50784
+ },
50785
+ ArrowUp: function ArrowUp(event) {
50786
+ return handleArrowUp(event);
50787
+ },
50788
+ ArrowDown: function ArrowDown(event) {
50789
+ return handleArrowDown(event);
50790
+ }
50791
+ };
50581
50792
  var handleKeyDown = function handleKeyDown(event) {
50582
- if (event.key === "ArrowDown") {
50583
- event.preventDefault();
50584
- setFocusedIndex(function (prevIndex) {
50585
- return prevIndex < optionsList.length - 1 ? prevIndex + 1 : 0;
50586
- });
50587
- } else if (event.key === "ArrowUp") {
50588
- event.preventDefault();
50589
- setFocusedIndex(function (prevIndex) {
50590
- return prevIndex > 0 ? prevIndex - 1 : optionsList.length - 1;
50591
- });
50592
- } else if (event.key === " ") {
50593
- event.preventDefault();
50594
- // Select option on spacebar press if the maximum selection hasn't been reached.
50595
- var validFocusedIndex = focusedIndex < 0 ? 0 : focusedIndex;
50596
- if (!isMaxSelectionReached || focusedIndex !== -1 && isChecked(optionsList[validFocusedIndex])) {
50597
- selectOption(optionsList[validFocusedIndex]);
50598
- }
50599
- } else if (event.key === "Tab") {
50600
- // Reset focus when tabbing out of the list.
50601
- setTimeout(function () {
50602
- setFocusedIndex(-1);
50603
- }, 500);
50793
+ var eventKey = event.code || event.key;
50794
+ var action = keyActions[eventKey];
50795
+ if (action) {
50796
+ action(event);
50604
50797
  }
50605
50798
  };
50799
+ React.useEffect(function () {
50800
+ if (focusedIndex !== -1 && itemRefs.current && itemRefs.current[focusedIndex]) {
50801
+ itemRefs.current[focusedIndex].focus(); // move focus to the active option
50802
+ }
50803
+ }, [focusedIndex]);
50804
+ return {
50805
+ itemRefs: itemRefs,
50806
+ focusedIndex: focusedIndex,
50807
+ handleKeyDown: handleKeyDown
50808
+ };
50809
+ };
50810
+
50811
+ var FilterableList = function FilterableList(_ref) {
50812
+ var id = _ref.id,
50813
+ options = _ref.options,
50814
+ appliedOptions = _ref.appliedOptions,
50815
+ selectedOptions = _ref.selectedOptions,
50816
+ maxSelections = _ref.maxSelections,
50817
+ name = _ref.name,
50818
+ setSelectedOptions = _ref.setSelectedOptions,
50819
+ searchTerm = _ref.searchTerm,
50820
+ themeValues = _ref.themeValues;
50821
+ var _useState = React.useState([]),
50822
+ _useState2 = _slicedToArray(_useState, 2),
50823
+ filteredOptions = _useState2[0],
50824
+ setFilteredOptions = _useState2[1];
50825
+ var _useState3 = React.useState([]),
50826
+ _useState4 = _slicedToArray(_useState3, 2),
50827
+ filteredAppliedOptions = _useState4[0],
50828
+ setFilteredAppliedOptions = _useState4[1];
50829
+ React.useEffect(function () {
50830
+ setFilteredOptions(options);
50831
+ setFilteredAppliedOptions(appliedOptions);
50832
+ }, [options, appliedOptions]);
50833
+ React.useEffect(function () {
50834
+ var filteredOptionItems = filterItemsList(options, searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.rawValue);
50835
+ var filteredAppliedItems = filterItemsList(appliedOptions, searchTerm === null || searchTerm === void 0 ? void 0 : searchTerm.rawValue);
50836
+ setFilteredOptions(filteredOptionItems.length ? filteredOptionItems : filteredOptions);
50837
+ setFilteredAppliedOptions(filteredAppliedItems);
50838
+ }, [searchTerm.rawValue]);
50839
+ var handleSelectOption = function handleSelectOption(option) {
50840
+ return selectOption(option, selectedOptions, setSelectedOptions);
50841
+ };
50842
+ var isAppliedOption = function isAppliedOption(option) {
50843
+ return filteredAppliedOptions === null || filteredAppliedOptions === void 0 ? void 0 : filteredAppliedOptions.some(function (appliedItem) {
50844
+ return (appliedItem === null || appliedItem === void 0 ? void 0 : appliedItem.name) === (option === null || option === void 0 ? void 0 : option.name);
50845
+ });
50846
+ };
50847
+ var currentFilteredOptions = filteredOptions.filter(function (option) {
50848
+ return !isAppliedOption(option);
50849
+ });
50850
+ var sortedOptions = sortItemsList(currentFilteredOptions);
50851
+ var sortedAppliedOptions = sortItemsList(filteredAppliedOptions);
50852
+ var _useKeyboardNavigatio = useKeyboardNavigation({
50853
+ options: sortedOptions,
50854
+ appliedOptions: sortedAppliedOptions,
50855
+ selectedOptions: selectedOptions,
50856
+ maxSelections: maxSelections
50857
+ }),
50858
+ itemRefs = _useKeyboardNavigatio.itemRefs,
50859
+ focusedIndex = _useKeyboardNavigatio.focusedIndex,
50860
+ handleKeyDown = _useKeyboardNavigatio.handleKeyDown;
50606
50861
  return /*#__PURE__*/React__default.createElement(Box, {
50607
50862
  id: id,
50608
50863
  role: "listbox",
50609
50864
  padding: "0",
50610
- extraStyles: "\n overflow-y: auto; \n max-height: 250px; \n display: flex; \n flex-flow: column;\n ",
50865
+ extraStyles: "\n overflow-y: auto;\n max-height: 250px;\n display: flex;\n flex-flow: column;\n ",
50611
50866
  onKeyDown: handleKeyDown
50612
- }, optionsList.map(function (option, index) {
50613
- var checked = isChecked(option);
50614
- var isDisabled = isMaxSelectionReached && !checked;
50867
+ }, (sortedAppliedOptions === null || sortedAppliedOptions === void 0 ? void 0 : sortedAppliedOptions.length) > 0 && /*#__PURE__*/React__default.createElement(Box, {
50868
+ padding: "0",
50869
+ extraStyles: sortedOptions.length > 0 && "border-bottom: 1px solid ".concat(GHOST_GREY)
50870
+ }, sortedAppliedOptions.map(function (option, index) {
50871
+ var checked = isChecked(option, selectedOptions);
50615
50872
  var tabIndex = index === focusedIndex || index === 0 && focusedIndex === -1 ? "0" : "-1";
50616
- return /*#__PURE__*/React__default.createElement(Box, {
50617
- padding: "0",
50873
+ return /*#__PURE__*/React__default.createElement(FilterableListItem, {
50618
50874
  key: index,
50619
- extraStyles: "\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n ")
50620
- }, /*#__PURE__*/React__default.createElement(Checkbox$1, {
50621
50875
  ref: function ref(el) {
50622
- return checkboxRefs.current[index] = el;
50876
+ return itemRefs.current[index] = el;
50623
50877
  },
50624
- title: option.name,
50625
- name: option.name,
50878
+ index: index,
50879
+ option: option,
50626
50880
  checked: checked,
50627
- onChange: function onChange() {
50628
- return isDisabled ? noop : selectOption(option);
50881
+ selectOption: handleSelectOption,
50882
+ tabIndex: tabIndex,
50883
+ name: name,
50884
+ themeValues: themeValues
50885
+ });
50886
+ })), sortedOptions.map(function (option, index) {
50887
+ var checked = isChecked(option, selectedOptions);
50888
+ var isDisabled = isMaxSelectionReached(maxSelections, selectedOptions) && !checked;
50889
+ var indexOffset = sortedAppliedOptions !== null && sortedAppliedOptions !== void 0 && sortedAppliedOptions.length ? sortedAppliedOptions === null || sortedAppliedOptions === void 0 ? void 0 : sortedAppliedOptions.length : 0;
50890
+ var currentIndex = index === 0 ? indexOffset : index + indexOffset;
50891
+ var tabIndex = currentIndex === focusedIndex || indexOffset === 0 && currentIndex === indexOffset && focusedIndex === -1 ? "0" : "-1";
50892
+ return /*#__PURE__*/React__default.createElement(FilterableListItem, {
50893
+ key: currentIndex,
50894
+ ref: function ref(el) {
50895
+ return itemRefs.current[currentIndex] = el;
50629
50896
  },
50630
- textExtraStyles: "font-size: 0.875rem; margin: 0;",
50897
+ index: currentIndex,
50898
+ option: option,
50899
+ checked: checked,
50900
+ selectOption: isDisabled ? noop : handleSelectOption,
50631
50901
  disabled: isDisabled,
50632
- extraStyles: "\n padding: 0.075rem 0.325rem; \n margin: 0;\n :hover,\n :active,\n :focus {\n background-color: ".concat(themeValues.primaryColor, ";\n }\n "),
50633
- checkboxMargin: "0.3rem",
50634
- role: "option",
50635
- checkboxExtraStyles: "\n width: 1.375rem; \n height: 1.375rem; \n ".concat(checked && !isDisabled ? "background: " + themeValues.secondaryColor + ";" : ""),
50636
50902
  tabIndex: tabIndex,
50637
- dataQa: "".concat(name, "-option-").concat(index)
50638
- }));
50903
+ name: name,
50904
+ themeValues: themeValues
50905
+ });
50639
50906
  }));
50640
50907
  };
50641
- var MultipleSelectFilter = function MultipleSelectFilter(_ref2) {
50642
- var actions = _ref2.actions,
50643
- autocompleteValue = _ref2.autocompleteValue,
50644
- btnContentOverride = _ref2.btnContentOverride,
50645
- disabled = _ref2.disabled,
50646
- extraStyles = _ref2.extraStyles,
50647
- fields = _ref2.fields,
50648
- filterLabel = _ref2.filterLabel,
50649
- _ref2$hasIcon = _ref2.hasIcon,
50650
- hasIcon = _ref2$hasIcon === void 0 ? false : _ref2$hasIcon,
50651
- Icon = _ref2.icon,
50652
- maxSelections = _ref2.maxSelections,
50653
- _ref2$name = _ref2.name,
50654
- name = _ref2$name === void 0 ? "MultipleSelectFilter" : _ref2$name,
50655
- _ref2$onApply = _ref2.onApply,
50656
- onApply = _ref2$onApply === void 0 ? noop : _ref2$onApply,
50657
- _ref2$onClear = _ref2.onClear,
50658
- onClear = _ref2$onClear === void 0 ? noop : _ref2$onClear,
50659
- options = _ref2.options,
50660
- _ref2$placeholder = _ref2.placeholder,
50661
- placeholder = _ref2$placeholder === void 0 ? "Search" : _ref2$placeholder,
50662
- _ref2$searchable = _ref2.searchable,
50663
- searchable = _ref2$searchable === void 0 ? true : _ref2$searchable,
50664
- selectedOptions = _ref2.selectedOptions,
50665
- setSelectedOptions = _ref2.setSelectedOptions,
50666
- themeValues = _ref2.themeValues,
50667
- _ref2$truncateBtnText = _ref2.truncateBtnTextWidth,
50668
- truncateBtnTextWidth = _ref2$truncateBtnText === void 0 ? "15rem" : _ref2$truncateBtnText;
50908
+ var FilterableList$1 = /*#__PURE__*/React__default.memo(FilterableList);
50909
+
50910
+ var MultipleSelectFilter = function MultipleSelectFilter(_ref) {
50911
+ var actions = _ref.actions,
50912
+ autocompleteValue = _ref.autocompleteValue,
50913
+ btnContentOverride = _ref.btnContentOverride,
50914
+ disabled = _ref.disabled,
50915
+ extraStyles = _ref.extraStyles,
50916
+ fields = _ref.fields,
50917
+ filterLabel = _ref.filterLabel,
50918
+ _ref$hasIcon = _ref.hasIcon,
50919
+ hasIcon = _ref$hasIcon === void 0 ? false : _ref$hasIcon,
50920
+ Icon = _ref.icon,
50921
+ maxSelections = _ref.maxSelections,
50922
+ _ref$name = _ref.name,
50923
+ name = _ref$name === void 0 ? "MultipleSelectFilter" : _ref$name,
50924
+ _ref$onApply = _ref.onApply,
50925
+ onApply = _ref$onApply === void 0 ? noop$1 : _ref$onApply,
50926
+ _ref$onClear = _ref.onClear,
50927
+ onClear = _ref$onClear === void 0 ? noop$1 : _ref$onClear,
50928
+ options = _ref.options,
50929
+ _ref$placeholder = _ref.placeholder,
50930
+ placeholder = _ref$placeholder === void 0 ? "Search" : _ref$placeholder,
50931
+ _ref$searchable = _ref.searchable,
50932
+ searchable = _ref$searchable === void 0 ? true : _ref$searchable,
50933
+ selectedOptions = _ref.selectedOptions,
50934
+ setSelectedOptions = _ref.setSelectedOptions,
50935
+ themeValues = _ref.themeValues,
50936
+ _ref$truncateBtnTextW = _ref.truncateBtnTextWidth,
50937
+ truncateBtnTextWidth = _ref$truncateBtnTextW === void 0 ? "15rem" : _ref$truncateBtnTextW;
50938
+ var _useState = React.useState(false),
50939
+ _useState2 = _slicedToArray(_useState, 2),
50940
+ opened = _useState2[0],
50941
+ setOpened = _useState2[1];
50669
50942
  var _useState3 = React.useState([]),
50670
50943
  _useState4 = _slicedToArray(_useState3, 2),
50671
- itemList = _useState4[0],
50672
- setItemList = _useState4[1];
50673
- var _useState5 = React.useState(false),
50674
- _useState6 = _slicedToArray(_useState5, 2),
50675
- opened = _useState6[0],
50676
- setOpened = _useState6[1];
50677
- var containerRef = React.useRef(null);
50944
+ appliedOptions = _useState4[0],
50945
+ setAppliedOptions = _useState4[1];
50946
+ var handleClickOutsideContainer = function handleClickOutsideContainer() {
50947
+ setOpened(false);
50948
+ actions.fields.searchTerm.set("");
50949
+ onApply(selectedOptions);
50950
+ };
50951
+ var containerRef = useOutsideClickHook(function () {
50952
+ return handleClickOutsideContainer();
50953
+ });
50678
50954
  var dropdownRef = React.useRef(null);
50679
50955
  var filterButtonRef = React.useRef(null);
50680
50956
  var applyFilterButtonRef = React.useRef(null);
50681
50957
  var filterDropdownID = "".concat(name, "-filter-dropdown");
50682
50958
  var checkboxListID = "".concat(name, "-checkbox-list");
50683
- var backgroundColor = opened ? themeValues.primaryColor : selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? themeValues.secondaryColor : WHITE;
50684
- var contentColor = !opened && selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? WHITE : "#292A33";
50685
- var completeOptionsList = itemList.slice().sort(function (a, b) {
50686
- return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
50687
- });
50688
- var selectValues = function selectValues(items) {
50689
- return items.map(function (item) {
50690
- return item.value;
50691
- });
50692
- };
50693
- var selectOption = function selectOption(selectedOption) {
50694
- if (selectValues(selectedOptions).includes(selectedOption.value)) {
50695
- var fewerOptions = selectedOptions.filter(function (option) {
50696
- return option.value !== selectedOption.value;
50697
- });
50698
- setSelectedOptions(fewerOptions);
50699
- } else {
50700
- var moreOptions = selectedOptions.concat(selectedOption);
50701
- setSelectedOptions(moreOptions);
50702
- }
50703
- };
50704
- React.useEffect(function () {
50705
- return setItemList(options);
50706
- }, [options]);
50707
50959
  React.useEffect(function () {
50708
- var filteredItems = options.filter(function (item) {
50709
- var _item$name, _fields$searchTerm;
50710
- 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());
50711
- });
50712
- // If no items are filtered, display the entire list of options.
50713
- if (filteredItems !== null && filteredItems !== void 0 && filteredItems.length) {
50714
- setItemList(filteredItems);
50715
- } else {
50716
- setItemList(options);
50960
+ if (!opened) {
50961
+ onApply(selectedOptions);
50962
+ setAppliedOptions(selectedOptions);
50717
50963
  }
50718
- }, [fields.searchTerm.rawValue]);
50964
+ }, [opened]);
50719
50965
  React.useEffect(function () {
50720
50966
  var handleKeyDown = function handleKeyDown(event) {
50721
50967
  if (event.key === "Escape") {
@@ -50732,114 +50978,72 @@ var MultipleSelectFilter = function MultipleSelectFilter(_ref2) {
50732
50978
  onApply(selectedOptions);
50733
50979
  }
50734
50980
  };
50735
- var handleClickOutside = function handleClickOutside(event) {
50736
- if (containerRef.current && !containerRef.current.contains(event.target) && dropdownRef.current && !dropdownRef.current.contains(event.target)) {
50737
- setOpened(false);
50738
- actions.fields.searchTerm.set("");
50739
- onApply(selectedOptions);
50740
- }
50741
- };
50742
- document.addEventListener("mousedown", handleClickOutside);
50743
50981
  document.addEventListener("keydown", handleKeyDown);
50744
50982
  return function () {
50745
- document.addEventListener("mousedown", handleClickOutside);
50746
50983
  document.removeEventListener("keydown", handleKeyDown);
50747
50984
  };
50748
50985
  }, []);
50749
50986
  return /*#__PURE__*/React__default.createElement(FilterContainer, {
50750
50987
  ref: containerRef,
50751
50988
  extraStyles: "".concat(extraStyles)
50752
- }, /*#__PURE__*/React__default.createElement(FilterButton, {
50989
+ }, /*#__PURE__*/React__default.createElement(FilterButton$1, {
50753
50990
  ref: filterButtonRef,
50754
- variant: "tertiary",
50991
+ btnContentOverride: btnContentOverride,
50755
50992
  action: function action() {
50756
50993
  actions.fields.searchTerm.set("");
50757
50994
  setOpened(!opened);
50758
50995
  },
50759
- "aria-haspopup": "listbox",
50760
- "aria-expanded": opened,
50761
- "aria-controls": filterDropdownID,
50762
- backgroundColor: backgroundColor,
50763
- dataQa: "".concat(name, "-filter-button"),
50764
- contentOverride: true
50765
- }, btnContentOverride ? btnContentOverride : /*#__PURE__*/React__default.createElement(Center, {
50766
- as: "span",
50767
- style: {
50768
- display: "flex",
50769
- flexDirection: "row"
50770
- },
50771
- intrinsic: true
50772
- }, hasIcon && /*#__PURE__*/React__default.createElement(Icon, {
50773
- color: contentColor
50774
- }), /*#__PURE__*/React__default.createElement(Center, {
50775
- as: "span",
50776
- style: {
50777
- display: "flex",
50778
- flexDirection: "row",
50779
- padding: "0 0.5rem 0 0.25rem"
50780
- },
50781
- intrinsic: true
50782
- }, /*#__PURE__*/React__default.createElement(Text$1, {
50783
- variant: "pS",
50784
- color: contentColor,
50785
- extraStyles: "\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n ".concat(truncateBtnTextWidth && "max-width:" + truncateBtnTextWidth, "\n ")
50786
- }, selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? "".concat(filterLabel ? filterLabel + ": " : "").concat(selectedOptions[0].name) : "".concat(filterLabel ? filterLabel : "")), /*#__PURE__*/React__default.createElement(Text$1, {
50787
- color: contentColor,
50788
- variant: "pS"
50789
- }, 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__default.createElement(DropdownIconV2, {
50790
- color: contentColor
50791
- }))), /*#__PURE__*/React__default.createElement(FilterDropdown, {
50996
+ opened: opened,
50997
+ backgroundColor: opened ? themeValues.primaryColor : selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? themeValues.secondaryColor : WHITE,
50998
+ contentColor: !opened && selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? WHITE : CHARADE_GREY,
50999
+ name: name,
51000
+ filterDropdownID: filterDropdownID,
51001
+ hasIcon: hasIcon,
51002
+ icon: Icon,
51003
+ truncateBtnTextWidth: truncateBtnTextWidth,
51004
+ filterLabel: filterLabel,
51005
+ selectedOptions: selectedOptions
51006
+ }), /*#__PURE__*/React__default.createElement(FilterDropdown, {
50792
51007
  id: filterDropdownID,
50793
51008
  ref: dropdownRef,
50794
- hidden: !opened,
50795
- role: "combobox",
50796
- "aria-expanded": opened,
50797
- "aria-haspopup": "listbox",
50798
- "aria-owns": checkboxListID
50799
- }, /*#__PURE__*/React__default.createElement(Box, {
50800
- padding: "0 0 0.5rem"
50801
- }, searchable && (options === null || options === void 0 ? void 0 : options.length) > 8 && /*#__PURE__*/React__default.createElement(FormInput$1, {
51009
+ ariaOwns: checkboxListID,
51010
+ opened: opened
51011
+ }, /*#__PURE__*/React__default.createElement(SearchBox, {
51012
+ showSearchBox: searchable && (options === null || options === void 0 ? void 0 : options.length) > 8,
50802
51013
  autocompleteValue: autocompleteValue,
50803
- showFieldErrorRow: false,
50804
- errorMessages: {},
50805
- field: fields.searchTerm,
50806
- fieldActions: actions.fields.searchTerm,
51014
+ fields: fields,
51015
+ actions: actions,
50807
51016
  placeholder: placeholder,
50808
- disabled: disabled,
50809
- 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 ")
50810
- })), /*#__PURE__*/React__default.createElement(ScrollableOptionsList, {
51017
+ disabled: disabled
51018
+ }), /*#__PURE__*/React__default.createElement(FilterableList$1, {
50811
51019
  id: checkboxListID,
50812
- optionsList: completeOptionsList,
50813
- selectedOptions: selectedOptions,
51020
+ options: options,
51021
+ appliedOptions: appliedOptions,
50814
51022
  themeValues: themeValues,
50815
- selectOption: selectOption,
51023
+ selectedOptions: selectedOptions,
50816
51024
  maxSelections: maxSelections,
50817
- name: name
51025
+ name: name,
51026
+ setSelectedOptions: setSelectedOptions,
51027
+ searchTerm: fields === null || fields === void 0 ? void 0 : fields.searchTerm
50818
51028
  }), /*#__PURE__*/React__default.createElement(Box, {
50819
51029
  padding: "0 0.5rem 0.0625rem 0.5rem",
50820
51030
  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 ")
50821
- }, /*#__PURE__*/React__default.createElement(ButtonWithAction, {
51031
+ }, /*#__PURE__*/React__default.createElement(ActionLinkButton, {
50822
51032
  action: function action() {
50823
51033
  setOpened(false);
50824
51034
  setSelectedOptions([]);
50825
51035
  actions.fields.searchTerm.set("");
50826
51036
  onClear();
50827
51037
  },
50828
- variant: "tertiary",
50829
- extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50830
- textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50831
51038
  text: "Clear",
50832
51039
  dataQa: "".concat(name, "-clear-filters")
50833
- }), /*#__PURE__*/React__default.createElement(ButtonWithAction, {
51040
+ }), /*#__PURE__*/React__default.createElement(ActionLinkButton, {
50834
51041
  ref: applyFilterButtonRef,
50835
51042
  action: function action() {
50836
51043
  setOpened(false);
50837
51044
  actions.fields.searchTerm.set("");
50838
51045
  onApply(selectedOptions);
50839
51046
  },
50840
- variant: "tertiary",
50841
- extraStyles: "\n padding: 0.2rem; \n margin: 0.5rem; \n min-height: auto; \n min-width: auto;\n ",
50842
- textExtraStyles: "font-weight: ".concat(FONT_WEIGHT_REGULAR, ";"),
50843
51047
  text: "Apply",
50844
51048
  dataQa: "".concat(name, "-apply-filters")
50845
51049
  }))));