@ims360/svelte-ivory 0.0.29 → 0.0.30
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/table/plugins/search.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEjD,UAAU,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAChC;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA+BzF;AAED,wFAAwF;AACxF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EACxC,OAAO,CAAC,EAAE,EACV,cAAc,MAAM,EACpB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO;;;
|
|
1
|
+
{"version":3,"file":"search.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/table/plugins/search.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAEjD,UAAU,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC;CAChC;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CA+BzF;AAED,wFAAwF;AACxF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EACxC,OAAO,CAAC,EAAE,EACV,cAAc,MAAM,EACpB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO;;;CA8B7C,CAAC"}
|
|
@@ -34,14 +34,19 @@ export const search = (nodes, searchString, stringsMatch) => {
|
|
|
34
34
|
const expanded = new Set();
|
|
35
35
|
const recursor = (node, childOfMatch = false) => {
|
|
36
36
|
const matches = stringsMatch(node, search);
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let intermediate = false;
|
|
38
|
+
for (const child of node.children || []) {
|
|
39
|
+
const childMatches = recursor(child, matches || childOfMatch);
|
|
40
|
+
if (childMatches && !intermediate)
|
|
41
|
+
intermediate = true;
|
|
42
|
+
}
|
|
43
|
+
if (intermediate) {
|
|
39
44
|
expanded.add(node.id);
|
|
40
45
|
}
|
|
41
46
|
else if (!childOfMatch) {
|
|
42
47
|
hidden.add(node.id);
|
|
43
48
|
}
|
|
44
|
-
return matches ||
|
|
49
|
+
return matches || intermediate;
|
|
45
50
|
};
|
|
46
51
|
nodes.forEach((n) => recursor(n));
|
|
47
52
|
return {
|
package/package.json
CHANGED
|
@@ -52,16 +52,19 @@ export const search = <T extends TableRow<T>>(
|
|
|
52
52
|
const recursor = (node: T, childOfMatch = false): boolean => {
|
|
53
53
|
const matches = stringsMatch(node, search);
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
let intermediate = false;
|
|
56
|
+
for (const child of node.children || []) {
|
|
57
|
+
const childMatches = recursor(child, matches || childOfMatch);
|
|
58
|
+
if (childMatches && !intermediate) intermediate = true;
|
|
59
|
+
}
|
|
57
60
|
|
|
58
|
-
if (
|
|
61
|
+
if (intermediate) {
|
|
59
62
|
expanded.add(node.id);
|
|
60
63
|
} else if (!childOfMatch) {
|
|
61
64
|
hidden.add(node.id);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
return matches ||
|
|
67
|
+
return matches || intermediate;
|
|
65
68
|
};
|
|
66
69
|
|
|
67
70
|
nodes.forEach((n) => recursor(n));
|