@thecb/components 11.1.8-beta.0 → 11.1.9-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/dist/index.cjs.js +76 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +76 -34
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.js +7 -15
- package/src/components/atoms/radio-button-with-label/RadioButtonWithLabel.theme.js +3 -9
- package/src/components/molecules/multiple-select-filter/MultipleSelectFilter.js +50 -11
- package/src/components/molecules/multiple-select-filter/__private__/FilterButton.js +3 -1
- package/src/components/molecules/multiple-select-filter/__private__/util.js +13 -0
- package/src/components/atoms/.DS_Store +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -28470,12 +28470,10 @@ var ProcessingFee = function ProcessingFee(_ref) {
|
|
|
28470
28470
|
var ProcessingFee$1 = themeComponent(ProcessingFee, "ProcessingFee", fallbackValues$w, "default");
|
|
28471
28471
|
|
|
28472
28472
|
var activeColor$6 = MATISSE_BLUE;
|
|
28473
|
-
var disabledColor$1 = MANATEE_GREY; // or GREY_CHATEAU?
|
|
28474
28473
|
var inactiveBorderColor = GREY_CHATEAU;
|
|
28475
28474
|
var fallbackValues$x = {
|
|
28476
|
-
|
|
28477
|
-
|
|
28478
|
-
inactiveBorderColor: inactiveBorderColor
|
|
28475
|
+
inactiveBorderColor: inactiveBorderColor,
|
|
28476
|
+
activeColor: activeColor$6
|
|
28479
28477
|
};
|
|
28480
28478
|
|
|
28481
28479
|
var HiddenRadioInput = styled__default.input.withConfig({
|
|
@@ -28486,8 +28484,8 @@ var Circle = styled__default.div.withConfig({
|
|
|
28486
28484
|
displayName: "RadioButtonWithLabel__Circle",
|
|
28487
28485
|
componentId: "sc-1m9whwg-1"
|
|
28488
28486
|
})(["flex-shrink:0;margin-right:8px;width:1.5rem;height 1.5rem;border:", ";border-radius:50%;box-sizing:border-box;padding:2px;:after{content:\"\";width:100%;height:100%;display:block;background:", ";border-radius:50%;transform:scale(0);}"], function (_ref) {
|
|
28489
|
-
var
|
|
28490
|
-
return "1px solid ".concat(
|
|
28487
|
+
var inactiveBorderColor = _ref.inactiveBorderColor;
|
|
28488
|
+
return "1px solid ".concat(inactiveBorderColor);
|
|
28491
28489
|
}, function (_ref2) {
|
|
28492
28490
|
var activeColor = _ref2.activeColor;
|
|
28493
28491
|
return activeColor;
|
|
@@ -28496,11 +28494,11 @@ var InputAndLabelContainer = styled__default(Cluster).withConfig({
|
|
|
28496
28494
|
displayName: "RadioButtonWithLabel__InputAndLabelContainer",
|
|
28497
28495
|
componentId: "sc-1m9whwg-2"
|
|
28498
28496
|
})(["overflow:visible;", ":checked + label ", ":after{transform:scale(0.85);transition:transform 0.15s;}", ":checked + label ", "{border:", "}", ":focus + label ", "{{box-shadow:", "}"], HiddenRadioInput, Circle, HiddenRadioInput, Circle, function (_ref3) {
|
|
28499
|
-
var
|
|
28500
|
-
return "1px solid ".concat(
|
|
28497
|
+
var activeColor = _ref3.activeColor;
|
|
28498
|
+
return "1px solid ".concat(activeColor, ";");
|
|
28501
28499
|
}, HiddenRadioInput, Circle, function (_ref4) {
|
|
28502
|
-
var
|
|
28503
|
-
return "0px 0px 2px 1px ".concat(
|
|
28500
|
+
var activeColor = _ref4.activeColor;
|
|
28501
|
+
return "0px 0px 2px 1px ".concat(activeColor, ";");
|
|
28504
28502
|
});
|
|
28505
28503
|
var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
28506
28504
|
var _ref5$id = _ref5.id,
|
|
@@ -28517,11 +28515,7 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
28517
28515
|
_ref5$handleChange = _ref5.handleChange,
|
|
28518
28516
|
handleChange = _ref5$handleChange === void 0 ? noop$1 : _ref5$handleChange,
|
|
28519
28517
|
field = _ref5.field,
|
|
28520
|
-
config = _ref5.config
|
|
28521
|
-
_ref5$disabled = _ref5.disabled,
|
|
28522
|
-
disabled = _ref5$disabled === void 0 ? false : _ref5$disabled,
|
|
28523
|
-
_ref5$title = _ref5.title,
|
|
28524
|
-
title = _ref5$title === void 0 ? "" : _ref5$title;
|
|
28518
|
+
config = _ref5.config;
|
|
28525
28519
|
var getDefaultChecked = function getDefaultChecked(value, idx) {
|
|
28526
28520
|
var selectionExistsInConfig = config === null || config === void 0 ? void 0 : config.map(function (c) {
|
|
28527
28521
|
return c.value;
|
|
@@ -28536,10 +28530,8 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
28536
28530
|
return /*#__PURE__*/React__default.createElement(InputAndLabelContainer, {
|
|
28537
28531
|
align: "center",
|
|
28538
28532
|
childGap: "0.5rem",
|
|
28539
|
-
|
|
28540
|
-
title: title
|
|
28533
|
+
activeColor: themeValues.activeColor
|
|
28541
28534
|
}, /*#__PURE__*/React__default.createElement(HiddenRadioInput, {
|
|
28542
|
-
disabled: disabled,
|
|
28543
28535
|
"aria-invalid": ariaInvalid,
|
|
28544
28536
|
style: {
|
|
28545
28537
|
marginTop: 0
|
|
@@ -28558,8 +28550,8 @@ var RadioButtonWithLabel = function RadioButtonWithLabel(_ref5) {
|
|
|
28558
28550
|
htmlFor: id,
|
|
28559
28551
|
extraStyles: "\n font-size: 1rem;\n display: flex; \n width: 100%;\n :hover {\n cursor: pointer;\n }\n "
|
|
28560
28552
|
}, /*#__PURE__*/React__default.createElement(Circle, {
|
|
28561
|
-
activeColor:
|
|
28562
|
-
|
|
28553
|
+
activeColor: themeValues.activeColor,
|
|
28554
|
+
inactiveBorderColor: themeValues.inactiveBorderColor
|
|
28563
28555
|
}), labelText));
|
|
28564
28556
|
};
|
|
28565
28557
|
var RadioButtonWithLabel$1 = themeComponent(RadioButtonWithLabel, "RadioButtonWithLabel", fallbackValues$x);
|
|
@@ -46479,7 +46471,7 @@ var iconsMap = (_iconsMap = {}, _defineProperty(_defineProperty(_defineProperty(
|
|
|
46479
46471
|
|
|
46480
46472
|
var disabledBackgroundColor$1 = TRANSPARENT;
|
|
46481
46473
|
var disabledBorderColor$1 = GHOST_GREY;
|
|
46482
|
-
var disabledColor$
|
|
46474
|
+
var disabledColor$1 = MANATEE_GREY;
|
|
46483
46475
|
var activeBackgroundColor$1 = CORNFLOWER_BLUE;
|
|
46484
46476
|
var backgroundColor$a = LINK_WATER;
|
|
46485
46477
|
var borderColor$5 = MOON_RAKER;
|
|
@@ -46487,7 +46479,7 @@ var color$b = ROYAL_BLUE_VIVID;
|
|
|
46487
46479
|
var fallbackValues$L = {
|
|
46488
46480
|
disabledBackgroundColor: disabledBackgroundColor$1,
|
|
46489
46481
|
disabledBorderColor: disabledBorderColor$1,
|
|
46490
|
-
disabledColor: disabledColor$
|
|
46482
|
+
disabledColor: disabledColor$1,
|
|
46491
46483
|
activeBackgroundColor: activeBackgroundColor$1,
|
|
46492
46484
|
backgroundColor: backgroundColor$a,
|
|
46493
46485
|
borderColor: borderColor$5,
|
|
@@ -50743,7 +50735,8 @@ var FilterButton$1 = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
50743
50735
|
truncateBtnTextWidth = _ref.truncateBtnTextWidth,
|
|
50744
50736
|
filterLabel = _ref.filterLabel,
|
|
50745
50737
|
selectedOptions = _ref.selectedOptions,
|
|
50746
|
-
extraStyles = _ref.extraStyles
|
|
50738
|
+
extraStyles = _ref.extraStyles,
|
|
50739
|
+
dataAppliedOptions = _ref.dataAppliedOptions;
|
|
50747
50740
|
var btnTextFilterDescription = selectedOptions !== null && selectedOptions !== void 0 && selectedOptions.length ? "".concat(filterLabel ? "".concat(filterLabel, ": ") : "").concat(selectedOptions[0].name) : "".concat(filterLabel ? filterLabel : "");
|
|
50748
50741
|
var btnTextItemsDescription = 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") : "";
|
|
50749
50742
|
return /*#__PURE__*/React__default.createElement(StyledFilterButton, {
|
|
@@ -50761,6 +50754,7 @@ var FilterButton$1 = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
50761
50754
|
dataQa: "".concat(name, "-filter-button"),
|
|
50762
50755
|
extraStyles: extraStyles,
|
|
50763
50756
|
"aria-label": "".concat(filterLabel, " Filter: ").concat(btnTextFilterDescription, " ").concat(btnTextItemsDescription),
|
|
50757
|
+
"data-applied-options": dataAppliedOptions,
|
|
50764
50758
|
contentOverride: true
|
|
50765
50759
|
}, btnContentOverride ? btnContentOverride : /*#__PURE__*/React__default.createElement(Center, {
|
|
50766
50760
|
as: "span",
|
|
@@ -50945,6 +50939,19 @@ var selectOption = function selectOption(option, selectedOptions, setSelectedOpt
|
|
|
50945
50939
|
setSelectedOptions(moreOptions);
|
|
50946
50940
|
}
|
|
50947
50941
|
};
|
|
50942
|
+
var mergeOptions = function mergeOptions(selectedOptions, activeOptions) {
|
|
50943
|
+
if (!activeOptions.length) return selectedOptions;
|
|
50944
|
+
if (!selectedOptions.length) return activeOptions;
|
|
50945
|
+
var mergedOptions = _toConsumableArray(selectedOptions);
|
|
50946
|
+
activeOptions.forEach(function (activeOption) {
|
|
50947
|
+
if (!mergedOptions.some(function (option) {
|
|
50948
|
+
return option.name === activeOption.name;
|
|
50949
|
+
})) {
|
|
50950
|
+
mergedOptions.push(activeOption);
|
|
50951
|
+
}
|
|
50952
|
+
});
|
|
50953
|
+
return mergedOptions;
|
|
50954
|
+
};
|
|
50948
50955
|
|
|
50949
50956
|
var useKeyboardNavigation = function useKeyboardNavigation(_ref) {
|
|
50950
50957
|
var options = _ref.options,
|
|
@@ -51145,41 +51152,75 @@ var MultipleSelectFilter = function MultipleSelectFilter(_ref) {
|
|
|
51145
51152
|
searchable = _ref$searchable === void 0 ? true : _ref$searchable,
|
|
51146
51153
|
themeValues = _ref.themeValues,
|
|
51147
51154
|
_ref$truncateBtnTextW = _ref.truncateBtnTextWidth,
|
|
51148
|
-
truncateBtnTextWidth = _ref$truncateBtnTextW === void 0 ? "15rem" : _ref$truncateBtnTextW
|
|
51155
|
+
truncateBtnTextWidth = _ref$truncateBtnTextW === void 0 ? "15rem" : _ref$truncateBtnTextW,
|
|
51156
|
+
activeAppliedOptions = _ref.activeAppliedOptions;
|
|
51157
|
+
// State to manage whether the dropdown is open or closed
|
|
51149
51158
|
var _useState = React.useState(false),
|
|
51150
51159
|
_useState2 = _slicedToArray(_useState, 2),
|
|
51151
51160
|
opened = _useState2[0],
|
|
51152
51161
|
setOpened = _useState2[1];
|
|
51162
|
+
|
|
51163
|
+
// State to manage the currently selected options
|
|
51153
51164
|
var _useState3 = React.useState([]),
|
|
51154
51165
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
51155
51166
|
selectedOptions = _useState4[0],
|
|
51156
51167
|
setSelectedOptions = _useState4[1];
|
|
51157
|
-
|
|
51168
|
+
|
|
51169
|
+
// State to manage the applied options, initialized with activeAppliedOptions or an empty array
|
|
51170
|
+
var _useState5 = React.useState(activeAppliedOptions || []),
|
|
51158
51171
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
51159
51172
|
appliedOptions = _useState6[0],
|
|
51160
51173
|
setAppliedOptions = _useState6[1];
|
|
51174
|
+
|
|
51175
|
+
// State to track whether the user has interacted with the component
|
|
51176
|
+
var _useState7 = React.useState(false),
|
|
51177
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
51178
|
+
hasInteracted = _useState8[0],
|
|
51179
|
+
setHasInteracted = _useState8[1];
|
|
51180
|
+
|
|
51181
|
+
// Reference to keep track of the opened state across renders without causing re-renders
|
|
51161
51182
|
var openedRef = React.useRef(opened);
|
|
51162
|
-
|
|
51163
|
-
|
|
51164
|
-
setOpened(false);
|
|
51165
|
-
actions.fields.searchTerm.set("");
|
|
51166
|
-
}
|
|
51167
|
-
};
|
|
51183
|
+
|
|
51184
|
+
// Hook to detect clicks outside the component and close the dropdown
|
|
51168
51185
|
var containerRef = useOutsideClickHook(function () {
|
|
51169
51186
|
return handleOnClose();
|
|
51170
51187
|
});
|
|
51188
|
+
|
|
51189
|
+
// References to various elements within the component
|
|
51171
51190
|
var dropdownRef = React.useRef(null);
|
|
51172
51191
|
var filterButtonRef = React.useRef(null);
|
|
51173
51192
|
var applyFilterButtonRef = React.useRef(null);
|
|
51193
|
+
|
|
51194
|
+
// IDs for accessibility and identification purposes
|
|
51174
51195
|
var filterDropdownID = "".concat(name, "-filter-dropdown");
|
|
51175
51196
|
var listGroupID = "".concat(name, "-list-group");
|
|
51197
|
+
var handleOnClose = function handleOnClose() {
|
|
51198
|
+
if (openedRef.current) {
|
|
51199
|
+
setOpened(false);
|
|
51200
|
+
actions.fields.searchTerm.set("");
|
|
51201
|
+
}
|
|
51202
|
+
};
|
|
51176
51203
|
React.useEffect(function () {
|
|
51177
51204
|
openedRef.current = opened;
|
|
51178
51205
|
if (!opened) {
|
|
51179
|
-
|
|
51180
|
-
|
|
51206
|
+
if (hasInteracted) {
|
|
51207
|
+
onApply(selectedOptions);
|
|
51208
|
+
setAppliedOptions(selectedOptions);
|
|
51209
|
+
}
|
|
51210
|
+
} else {
|
|
51211
|
+
setHasInteracted(true);
|
|
51181
51212
|
}
|
|
51182
51213
|
}, [opened]);
|
|
51214
|
+
React.useEffect(function () {
|
|
51215
|
+
// Update the applied options state with the current active applied options,
|
|
51216
|
+
// or an empty array if activeAppliedOptions is undefined or null.
|
|
51217
|
+
// This ensures that the current applied options are in sync with the parent component.
|
|
51218
|
+
setAppliedOptions(activeAppliedOptions || []);
|
|
51219
|
+
|
|
51220
|
+
// Merge the selected options with the active applied options.
|
|
51221
|
+
var mergedSelections = mergeOptions(selectedOptions, activeAppliedOptions);
|
|
51222
|
+
setSelectedOptions(mergedSelections);
|
|
51223
|
+
}, [activeAppliedOptions]);
|
|
51183
51224
|
React.useEffect(function () {
|
|
51184
51225
|
var handleKeyDown = function handleKeyDown(event) {
|
|
51185
51226
|
if (event.key === "Escape") {
|
|
@@ -51221,7 +51262,8 @@ var MultipleSelectFilter = function MultipleSelectFilter(_ref) {
|
|
|
51221
51262
|
truncateBtnTextWidth: truncateBtnTextWidth,
|
|
51222
51263
|
filterLabel: filterLabel,
|
|
51223
51264
|
selectedOptions: selectedOptions,
|
|
51224
|
-
extraStyles: btnExtraStyles
|
|
51265
|
+
extraStyles: btnExtraStyles,
|
|
51266
|
+
dataAppliedOptions: appliedOptions === null || appliedOptions === void 0 ? void 0 : appliedOptions.length
|
|
51225
51267
|
}), /*#__PURE__*/React__default.createElement(FilterDropdown, {
|
|
51226
51268
|
id: filterDropdownID,
|
|
51227
51269
|
ref: dropdownRef,
|