@bluemarble/bm-components 1.18.0 → 1.19.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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +29 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5141,39 +5141,53 @@ function useGrid({
|
|
|
5141
5141
|
clearSort
|
|
5142
5142
|
};
|
|
5143
5143
|
}
|
|
5144
|
-
|
|
5144
|
+
var isNumberOrString = (value) => ["number", "string"].includes(typeof value);
|
|
5145
|
+
var concatenateKey = (key, prev) => {
|
|
5146
|
+
if (!prev)
|
|
5147
|
+
return key;
|
|
5148
|
+
return `${prev}.${key}`;
|
|
5149
|
+
};
|
|
5150
|
+
function searchKeysForValue(row, accKey, compare) {
|
|
5145
5151
|
if (typeof row === "undefined")
|
|
5146
5152
|
return false;
|
|
5147
5153
|
const rowKeys = Object.keys(row);
|
|
5148
5154
|
let match = false;
|
|
5149
|
-
const isNumberOrString = (value) => ["number", "string"].includes(typeof value);
|
|
5150
5155
|
for (const key of rowKeys) {
|
|
5156
|
+
if (match)
|
|
5157
|
+
break;
|
|
5151
5158
|
const objValue = row[key];
|
|
5152
|
-
if (objValue)
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
match = compare(row[key]);
|
|
5161
|
-
if (match)
|
|
5162
|
-
return match;
|
|
5159
|
+
if (!objValue)
|
|
5160
|
+
continue;
|
|
5161
|
+
const concatenatedKey = concatenateKey(key, accKey);
|
|
5162
|
+
if (Array.isArray(objValue)) {
|
|
5163
|
+
match = objValue.some(
|
|
5164
|
+
(obj) => isNumberOrString(obj) ? compare(concatenatedKey, obj) : searchKeysForValue(obj, concatenatedKey, compare)
|
|
5165
|
+
);
|
|
5166
|
+
continue;
|
|
5163
5167
|
}
|
|
5168
|
+
if (typeof objValue === "object") {
|
|
5169
|
+
match = searchKeysForValue(objValue, concatenatedKey, compare);
|
|
5170
|
+
continue;
|
|
5171
|
+
}
|
|
5172
|
+
match = compare(concatenatedKey, row[key]);
|
|
5164
5173
|
}
|
|
5165
5174
|
return match;
|
|
5166
5175
|
}
|
|
5167
5176
|
function createSearch(options) {
|
|
5168
5177
|
const searchValue = options.caseSensitive ? options.value : String(options.value).toLowerCase();
|
|
5169
|
-
function compare(objValue) {
|
|
5178
|
+
function compare(key, objValue) {
|
|
5179
|
+
if (options.ignoredKeys) {
|
|
5180
|
+
const isIgnoredKey = options.ignoredKeys.includes(key);
|
|
5181
|
+
if (isIgnoredKey)
|
|
5182
|
+
return false;
|
|
5183
|
+
}
|
|
5170
5184
|
const value = options.caseSensitive ? String(objValue) : String(objValue).toLowerCase();
|
|
5171
5185
|
if (options.exact)
|
|
5172
5186
|
return value === searchValue;
|
|
5173
5187
|
return value.includes(searchValue);
|
|
5174
5188
|
}
|
|
5175
5189
|
return (row) => {
|
|
5176
|
-
const match = searchKeysForValue(row, compare);
|
|
5190
|
+
const match = searchKeysForValue(row, "", compare);
|
|
5177
5191
|
return match;
|
|
5178
5192
|
};
|
|
5179
5193
|
}
|