@useblu/ocean-react 1.54.1 → 1.55.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/CHANGELOG.md +6 -0
- package/Chips/Chips.d.ts +1 -0
- package/Chips/Chips.d.ts.map +1 -1
- package/Chips/Options.d.ts +1 -1
- package/Chips/Options.d.ts.map +1 -1
- package/index.es.js +14 -5
- package/index.es.js.map +1 -1
- package/index.js +14 -5
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -46430,13 +46430,17 @@ var CardListItem = function (_a) {
|
|
|
46430
46430
|
};
|
|
46431
46431
|
|
|
46432
46432
|
var Options = function (_a) {
|
|
46433
|
-
var options = _a.options,
|
|
46433
|
+
var options = _a.options, selectedOptions = _a.selectedOptions, clearLabel = _a.clearLabel, filterLabel = _a.filterLabel, multiChoice = _a.multiChoice, onSelect = _a.onSelect, filterOptions = _a.filterOptions, clearOptions = _a.clearOptions;
|
|
46434
46434
|
var columns = multiChoice ? Math.ceil(10 / 5) : 1;
|
|
46435
46435
|
return (e__default["default"].createElement("div", { className: "ods-chips__options", "data-testid": "ods-chips-option" },
|
|
46436
46436
|
e__default["default"].createElement("div", { className: classNames('ods-chips__options--content', "ods-chips__options--content--columns-".concat(columns)) }, options.map(function (_a) {
|
|
46437
46437
|
var label = _a.label, value = _a.value;
|
|
46438
|
-
return (e__default["default"].createElement("button", { key: label, type: "button", value: value, onClick: function () { return onSelect(label, value); }, className:
|
|
46439
|
-
|
|
46438
|
+
return (e__default["default"].createElement("button", { key: label, type: "button", value: value, onClick: function () { return onSelect(label, value); }, className: classNames('ods-chips__options--option', {
|
|
46439
|
+
'ods-chips__options--option--selected': !multiChoice &&
|
|
46440
|
+
!Array.isArray(selectedOptions) &&
|
|
46441
|
+
selectedOptions.value === value
|
|
46442
|
+
}) },
|
|
46443
|
+
multiChoice && Array.isArray(selectedOptions) && (e__default["default"].createElement(Checkbox, { checked: !!selectedOptions.find(function (option) { return option.value === value; }), readOnly: true })),
|
|
46440
46444
|
label));
|
|
46441
46445
|
})),
|
|
46442
46446
|
multiChoice && (e__default["default"].createElement("div", { className: "ods-chips__options--footer" },
|
|
@@ -46445,7 +46449,7 @@ var Options = function (_a) {
|
|
|
46445
46449
|
};
|
|
46446
46450
|
|
|
46447
46451
|
var Chips = function (_a) {
|
|
46448
|
-
var label = _a.label, icon = _a.icon, disabled = _a.disabled, defaultValue = _a.defaultValue, _b = _a.options, options = _b === void 0 ? [] : _b, _c = _a.multiChoice, multiChoice = _c === void 0 ? false : _c, _d = _a.clearLabel, clearLabel = _d === void 0 ? 'Limpar' : _d, _e = _a.filterLabel, filterLabel = _e === void 0 ? 'Filtrar' : _e, initialCounter = _a.initialCounter, onClick = _a.onClick, onChange = _a.onChange, onClose = _a.onClose;
|
|
46452
|
+
var label = _a.label, icon = _a.icon, disabled = _a.disabled, defaultValue = _a.defaultValue, _b = _a.options, options = _b === void 0 ? [] : _b, _c = _a.multiChoice, multiChoice = _c === void 0 ? false : _c, _d = _a.clearLabel, clearLabel = _d === void 0 ? 'Limpar' : _d, _e = _a.filterLabel, filterLabel = _e === void 0 ? 'Filtrar' : _e, initialCounter = _a.initialCounter, selectedValue = _a.selectedValue, onClick = _a.onClick, onChange = _a.onChange, onClose = _a.onClose;
|
|
46449
46453
|
var wrapperRef = e.useRef(null);
|
|
46450
46454
|
var _f = e__default["default"].useState(0), counter = _f[0], setCounter = _f[1];
|
|
46451
46455
|
var _g = e__default["default"].useState(false), selectionIsOpen = _g[0], setSelectionIsOpen = _g[1];
|
|
@@ -46458,6 +46462,11 @@ var Chips = function (_a) {
|
|
|
46458
46462
|
if (onClose)
|
|
46459
46463
|
onClose();
|
|
46460
46464
|
}
|
|
46465
|
+
e.useEffect(function () {
|
|
46466
|
+
if (selectedValue && selectedValue !== selectedOptions && !multiChoice) {
|
|
46467
|
+
setSelectedOptions(selectedValue);
|
|
46468
|
+
}
|
|
46469
|
+
}, [selectedValue]);
|
|
46461
46470
|
e.useEffect(function () {
|
|
46462
46471
|
document.addEventListener('mousedown', handleClickOutside);
|
|
46463
46472
|
return function () {
|
|
@@ -46528,7 +46537,7 @@ var Chips = function (_a) {
|
|
|
46528
46537
|
(counter > 0 || initialCounter) && (e__default["default"].createElement(Badge, { color: "brand", className: "ods-chips__badge" }, initialCounter !== null && initialCounter !== void 0 ? initialCounter : counter)),
|
|
46529
46538
|
options && (options === null || options === void 0 ? void 0 : options.length) > 0 && !selectionIsOpen && e__default["default"].createElement(J, null),
|
|
46530
46539
|
options && (options === null || options === void 0 ? void 0 : options.length) > 0 && selectionIsOpen && e__default["default"].createElement(re, null)),
|
|
46531
|
-
selectionIsOpen && options && (e__default["default"].createElement(Options, { options: options, onSelect: handleSelectOption, selectedOptions:
|
|
46540
|
+
selectionIsOpen && options && (e__default["default"].createElement(Options, { options: options, onSelect: handleSelectOption, selectedOptions: selectedOptions, clearLabel: clearLabel, filterLabel: filterLabel, multiChoice: multiChoice, clearOptions: clearOptions, filterOptions: filterOptions }))));
|
|
46532
46541
|
};
|
|
46533
46542
|
Chips.displayName = 'Chips';
|
|
46534
46543
|
|