@bluemarble/bm-components 1.18.0 → 1.20.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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5141,39 +5141,61 @@ 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
|
}
|
|
5176
|
+
var normalize = (str) => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
5167
5177
|
function createSearch(options) {
|
|
5168
5178
|
const searchValue = options.caseSensitive ? options.value : String(options.value).toLowerCase();
|
|
5169
|
-
function
|
|
5170
|
-
|
|
5179
|
+
function getValue2(value) {
|
|
5180
|
+
if (options.caseSensitive)
|
|
5181
|
+
return String(value);
|
|
5182
|
+
return String(value).toLowerCase();
|
|
5183
|
+
}
|
|
5184
|
+
function compare(key, objValue) {
|
|
5185
|
+
if (options.ignoredKeys) {
|
|
5186
|
+
const isIgnoredKey = options.ignoredKeys.includes(key);
|
|
5187
|
+
if (isIgnoredKey)
|
|
5188
|
+
return false;
|
|
5189
|
+
}
|
|
5190
|
+
const value = getValue2(objValue);
|
|
5171
5191
|
if (options.exact)
|
|
5172
5192
|
return value === searchValue;
|
|
5193
|
+
if (options.ignoreAccentMark)
|
|
5194
|
+
return normalize(value).includes(normalize(searchValue));
|
|
5173
5195
|
return value.includes(searchValue);
|
|
5174
5196
|
}
|
|
5175
5197
|
return (row) => {
|
|
5176
|
-
const match = searchKeysForValue(row, compare);
|
|
5198
|
+
const match = searchKeysForValue(row, "", compare);
|
|
5177
5199
|
return match;
|
|
5178
5200
|
};
|
|
5179
5201
|
}
|