Comparing version 1.1.23 to 1.1.24
@@ -85,3 +85,3 @@ "use strict"; | ||
return [2 /*return*/, []]; | ||
}); }); } : _h, _j = _a.data, data = _j === void 0 ? [] : _j, errors = _a.errors, _k = _a.required, required = _k === void 0 ? false : _k, name = _a.name, _l = _a.fullWidth, fullWidth = _l === void 0 ? false : _l, placeholder = _a.placeholder, id = _a.id, _m = _a.type, type = _m === void 0 ? 'custom_select' : _m, _o = _a.selectedItems, propsSeelctedItems = _o === void 0 ? [] : _o, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.disabled, disabled = _q === void 0 ? false : _q, value = _a.value, _r = _a.isMultiple, isMultiple = _r === void 0 ? false : _r, _s = _a.desc, desc = _s === void 0 ? 'name' : _s, _t = _a.descId, descId = _t === void 0 ? 'id' : _t, singleSelect = _a.singleSelect, className = _a.className, _u = _a.async, async = _u === void 0 ? false : _u, paginationEnabled = _a.paginationEnabled, initialLoad = _a.initialLoad, actionLabel = _a.actionLabel, handleAction = _a.handleAction, nextBlock = _a.nextBlock, notDataMessage = _a.notDataMessage, onFocus = _a.onFocus; | ||
}); }); } : _h, _j = _a.data, data = _j === void 0 ? [] : _j, errors = _a.errors, _k = _a.required, required = _k === void 0 ? false : _k, name = _a.name, _l = _a.fullWidth, fullWidth = _l === void 0 ? false : _l, placeholder = _a.placeholder, id = _a.id, _m = _a.type, type = _m === void 0 ? 'custom_select' : _m, _o = _a.selectedItems, propsSeelctedItems = _o === void 0 ? [] : _o, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.disabled, disabled = _q === void 0 ? false : _q, value = _a.value, _r = _a.isMultiple, isMultiple = _r === void 0 ? false : _r, _s = _a.desc, desc = _s === void 0 ? 'name' : _s, _t = _a.descId, descId = _t === void 0 ? 'id' : _t, singleSelect = _a.singleSelect, className = _a.className, _u = _a.async, async = _u === void 0 ? false : _u, paginationEnabled = _a.paginationEnabled, initialLoad = _a.initialLoad, actionLabel = _a.actionLabel, handleAction = _a.handleAction, nextBlock = _a.nextBlock, notDataMessage = _a.notDataMessage, onFocus = _a.onFocus, selectAllLabel = _a.selectAllLabel, selectAll = _a.selectAll; | ||
var dropdownRef = (0, react_1.useRef)(null); | ||
@@ -260,2 +260,19 @@ // State Hooks Section | ||
: ''; | ||
var handleSelctAll = function (e) { | ||
var checked = e.target.checked; | ||
if (checked) { | ||
setSelectedItems(__spreadArray([], filteredData, true)); | ||
} | ||
else { | ||
setSelectedItems([]); | ||
} | ||
}; | ||
var arraysAreEqual = function () { | ||
// Check if every object in filteredData is in selectedItems | ||
return filteredData.every(function (filteredItem) { | ||
return selectedItems.some(function (selectedItem) { | ||
return JSON.stringify(filteredItem) === JSON.stringify(selectedItem); | ||
}); | ||
}); | ||
}; | ||
return (react_1.default.createElement("div", { className: fullWidth ? 'fullWidth' : 'autoWidth', ref: dropdownRef }, | ||
@@ -298,2 +315,10 @@ label && (react_1.default.createElement("div", { style: { | ||
react_1.default.createElement("div", { className: "qbs-autocomplete-suggestions-sub" }, | ||
!selectAll && (react_1.default.createElement("div", { className: "qbs-autocomplete-listitem-container ".concat((isMultiple || singleSelect) && | ||
'qbs-autocomplete-checkbox-container', " ").concat(arraysAreEqual() ? 'is-selected' : '') }, | ||
(isMultiple || singleSelect) && (react_1.default.createElement("div", { className: "qbs-autocomplete-checkbox" }, | ||
react_1.default.createElement("input", { onChange: function (e) { return handleSelctAll(e); }, type: "checkbox", checked: arraysAreEqual(), id: "qbs-checkbox-selectAll" }), | ||
react_1.default.createElement("label", { htmlFor: "qbs-checkbox-selectAll" }, | ||
react_1.default.createElement("svg", { width: "8", height: "6", viewBox: "0 0 8 6", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, | ||
react_1.default.createElement("path", { d: "M0 3.21739L2.89883 6L8 1.06994L6.89494 0L2.89883 3.86768L1.09728 2.14745L0 3.21739Z", fill: "white" }))))), | ||
react_1.default.createElement("li", { className: "qbs-autocomplete-suggestions-item ".concat(arraysAreEqual() ? 'is-selected' : '') }, selectAllLabel !== null && selectAllLabel !== void 0 ? selectAllLabel : 'Select All'))), | ||
(filteredData === null || filteredData === void 0 ? void 0 : filteredData.length) > 0 ? (filteredData.map(function (suggestion, idx) { return (react_1.default.createElement("div", { key: idx.toString(), className: "qbs-autocomplete-listitem-container ".concat((isMultiple || singleSelect) && | ||
@@ -300,0 +325,0 @@ 'qbs-autocomplete-checkbox-container', " ").concat(isSelected(suggestion, selected) ? 'is-selected' : '') }, |
@@ -36,3 +36,5 @@ /// <reference types="react" /> | ||
hideClose?: boolean; | ||
selectAllLabel?: string; | ||
selectAll?: boolean; | ||
} | ||
export {}; |
{ | ||
"name": "qbs-core", | ||
"version": "1.1.23", | ||
"version": "1.1.24", | ||
"description": "React Components", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -39,2 +39,4 @@ type ValueProps = { | ||
hideClose?: boolean; | ||
selectAllLabel?: string; | ||
selectAll?: boolean; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
205843
4336