@thecb/components 11.1.9 → 11.1.10-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "11.1.9",
3
+ "version": "11.1.10-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -11,7 +11,6 @@ import FilterDropdown from "./__private__/FilterDropdown";
11
11
  import SearchBox from "./__private__/SearchBox";
12
12
  import FilterableList from "./__private__/FilterableList";
13
13
  import useOutsideClickHook from "../../../hooks/use-outside-click";
14
- import { mergeOptions } from "./__private__/util";
15
14
 
16
15
  const MultipleSelectFilter = ({
17
16
  actions,
@@ -33,71 +32,34 @@ const MultipleSelectFilter = ({
33
32
  placeholder = "Search",
34
33
  searchable = true,
35
34
  themeValues,
36
- truncateBtnTextWidth = "15rem",
37
- activeAppliedOptions
35
+ truncateBtnTextWidth = "15rem"
38
36
  }) => {
39
- // State to manage whether the dropdown is open or closed
40
37
  const [opened, setOpened] = useState(false);
41
-
42
- // State to manage the currently selected options
43
38
  const [selectedOptions, setSelectedOptions] = useState([]);
44
-
45
- // State to manage the applied options, initialized with activeAppliedOptions or an empty array
46
- const [appliedOptions, setAppliedOptions] = useState(
47
- activeAppliedOptions || []
48
- );
49
-
50
- // State to track whether the user has interacted with the component
51
- const [hasInteracted, setHasInteracted] = useState(false);
52
-
53
- // Reference to keep track of the opened state across renders without causing re-renders
39
+ const [appliedOptions, setAppliedOptions] = useState([]);
54
40
  const openedRef = useRef(opened);
55
41
 
56
- // Hook to detect clicks outside the component and close the dropdown
57
- const containerRef = useOutsideClickHook(() => handleOnClose());
58
-
59
- // References to various elements within the component
60
- const dropdownRef = useRef(null);
61
- const filterButtonRef = useRef(null);
62
- const applyFilterButtonRef = useRef(null);
63
-
64
- // IDs for accessibility and identification purposes
65
- const filterDropdownID = `${name}-filter-dropdown`;
66
- const listGroupID = `${name}-list-group`;
67
-
68
42
  const handleOnClose = () => {
69
43
  if (openedRef.current) {
70
44
  setOpened(false);
71
45
  actions.fields.searchTerm.set("");
72
46
  }
73
47
  };
48
+ const containerRef = useOutsideClickHook(() => handleOnClose());
49
+ const dropdownRef = useRef(null);
50
+ const filterButtonRef = useRef(null);
51
+ const applyFilterButtonRef = useRef(null);
52
+ const filterDropdownID = `${name}-filter-dropdown`;
53
+ const listGroupID = `${name}-list-group`;
74
54
 
75
55
  useEffect(() => {
76
56
  openedRef.current = opened;
77
57
  if (!opened) {
78
- if (hasInteracted) {
79
- onApply(selectedOptions);
80
- setAppliedOptions(selectedOptions);
81
- }
82
- } else {
83
- setHasInteracted(true);
58
+ onApply(selectedOptions);
59
+ setAppliedOptions(selectedOptions);
84
60
  }
85
61
  }, [opened]);
86
62
 
87
- useEffect(() => {
88
- // Update the applied options state with the current active applied options,
89
- // or an empty array if activeAppliedOptions is undefined or null.
90
- // This ensures that the current applied options are in sync with the parent component.
91
- setAppliedOptions(activeAppliedOptions || []);
92
-
93
- // Merge the selected options with the active applied options.
94
- const mergedSelections = mergeOptions(
95
- selectedOptions,
96
- activeAppliedOptions
97
- );
98
- setSelectedOptions(mergedSelections);
99
- }, [activeAppliedOptions]);
100
-
101
63
  useEffect(() => {
102
64
  const handleKeyDown = event => {
103
65
  if (event.key === "Escape") {
@@ -160,7 +122,6 @@ const MultipleSelectFilter = ({
160
122
  filterLabel={filterLabel}
161
123
  selectedOptions={selectedOptions}
162
124
  extraStyles={btnExtraStyles}
163
- dataAppliedOptions={appliedOptions?.length}
164
125
  ></FilterButton>
165
126
  <FilterDropdown
166
127
  id={filterDropdownID}
@@ -21,8 +21,7 @@ const FilterButton = forwardRef(
21
21
  truncateBtnTextWidth,
22
22
  filterLabel,
23
23
  selectedOptions,
24
- extraStyles,
25
- dataAppliedOptions
24
+ extraStyles
26
25
  },
27
26
  ref
28
27
  ) => {
@@ -49,7 +48,6 @@ const FilterButton = forwardRef(
49
48
  dataQa={`${name}-filter-button`}
50
49
  extraStyles={extraStyles}
51
50
  aria-label={`${filterLabel} Filter: ${btnTextFilterDescription} ${btnTextItemsDescription}`}
52
- data-applied-options={dataAppliedOptions}
53
51
  contentOverride
54
52
  >
55
53
  {btnContentOverride ? (
@@ -29,16 +29,3 @@ export const selectOption = (option, selectedOptions, setSelectedOptions) => {
29
29
  setSelectedOptions(moreOptions);
30
30
  }
31
31
  };
32
-
33
- export const mergeOptions = (selectedOptions, activeOptions) => {
34
- if (!activeOptions.length) return selectedOptions;
35
- if (!selectedOptions.length) return activeOptions;
36
-
37
- const mergedOptions = [...selectedOptions];
38
- activeOptions.forEach(activeOption => {
39
- if (!mergedOptions.some(option => option.name === activeOption.name)) {
40
- mergedOptions.push(activeOption);
41
- }
42
- });
43
- return mergedOptions;
44
- };
@@ -20,7 +20,7 @@ import { fallbackValues } from "./Obligation.theme";
20
20
 
21
21
  const Obligation = ({
22
22
  config,
23
- obligations,
23
+ obligations = [],
24
24
  actions,
25
25
  autoPayEnabled,
26
26
  autoPayAvailable,
@@ -121,6 +121,7 @@ const Obligation = ({
121
121
  {!isMobile && (
122
122
  <PaymentDetailsActions
123
123
  obligations={obligations}
124
+ obligationAssocID={obligationAssocID}
124
125
  autoPayEnabled={autoPayEnabled}
125
126
  autoPayAvailable={autoPayAvailable}
126
127
  handleAutopayAction={handleAutopayAction}
@@ -146,6 +147,7 @@ const Obligation = ({
146
147
  {isMobile && (
147
148
  <PaymentDetailsActions
148
149
  obligations={obligations}
150
+ obligationAssocID={obligationAssocID}
149
151
  autoPayEnabled={autoPayEnabled}
150
152
  autoPayAvailable={autoPayAvailable}
151
153
  handleAutopayAction={handleAutopayAction}
@@ -32,8 +32,8 @@ const AutopayModalModule = ({
32
32
  onKeyPress
33
33
  }) => {
34
34
  const generateMethodNeededText = (planText, allowedPaymentInstruments) => {
35
- const allowsCard = allowedPaymentInstruments.includes(CC_METHOD);
36
- const allowsACH = allowedPaymentInstruments.includes(ACH_METHOD);
35
+ const allowsCard = allowedPaymentInstruments?.includes(CC_METHOD);
36
+ const allowsACH = allowedPaymentInstruments?.includes(ACH_METHOD);
37
37
  const methodRequired =
38
38
  allowsCard && !allowsACH
39
39
  ? "debit or credit card payment method"