@ims360/svelte-ivory 0.0.30 → 0.0.32

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.
@@ -64,7 +64,7 @@
64
64
  <Portal>
65
65
  <HiddenBackground
66
66
  onclose={close}
67
- class="flex h-full w-full flex-col items-center justify-start p-16"
67
+ class="flex h-full w-full flex-col items-center justify-start p-8 lg:p-12 xl:p-16"
68
68
  >
69
69
  {#if modal}
70
70
  <!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -4,7 +4,7 @@ interface SearchConfig<T extends TableRow<T>> {
4
4
  matches: (row: T) => boolean;
5
5
  }
6
6
  export declare function searchPlugin<T extends TableRow<T>>(conf: SearchConfig<T>): TablePlugin<T>;
7
- /** collapses everything that doesnt match the searchString expands direct search hit */
7
+ /** collapses everything that doesnt match the searchString, expands direct search hit */
8
8
  export declare const search: <T extends TableRow<T>>(nodes: T[], searchString: string, stringsMatch: (a: T, b: string) => boolean) => {
9
9
  hidden: Set<string>;
10
10
  expanded: Set<string>;
@@ -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;;;CA8B7C,CAAC"}
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,CA6BzF;AAED,yFAAyF;AACzF,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"}
@@ -14,9 +14,8 @@ export function searchPlugin(conf) {
14
14
  if (!conf.search)
15
15
  return state;
16
16
  // ensure we store the state before the we started searching
17
- if (conf.search && !prevSearch) {
17
+ if (conf.search && !prevSearch)
18
18
  expandedBeforeSearch = state.expanded;
19
- }
20
19
  // figure out which nodes to expand and hide
21
20
  const { expanded, hidden } = search(state.data, conf.search, conf.matches);
22
21
  prevSearch = conf.search;
@@ -27,16 +26,16 @@ export function searchPlugin(conf) {
27
26
  };
28
27
  return middleware;
29
28
  }
30
- /** collapses everything that doesnt match the searchString expands direct search hit */
29
+ /** collapses everything that doesnt match the searchString, expands direct search hit */
31
30
  export const search = (nodes, searchString, stringsMatch) => {
32
31
  const search = searchString.trim().toLowerCase();
33
32
  const hidden = new Set();
34
33
  const expanded = new Set();
35
- const recursor = (node, childOfMatch = false) => {
34
+ function nodeMatches(node, childOfMatch = false) {
36
35
  const matches = stringsMatch(node, search);
37
36
  let intermediate = false;
38
37
  for (const child of node.children || []) {
39
- const childMatches = recursor(child, matches || childOfMatch);
38
+ const childMatches = nodeMatches(child, matches || childOfMatch);
40
39
  if (childMatches && !intermediate)
41
40
  intermediate = true;
42
41
  }
@@ -47,8 +46,8 @@ export const search = (nodes, searchString, stringsMatch) => {
47
46
  hidden.add(node.id);
48
47
  }
49
48
  return matches || intermediate;
50
- };
51
- nodes.forEach((n) => recursor(n));
49
+ }
50
+ nodes.forEach((n) => nodeMatches(n));
52
51
  return {
53
52
  hidden,
54
53
  expanded
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ims360/svelte-ivory",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "keywords": [
5
5
  "svelte"
6
6
  ],
@@ -64,7 +64,7 @@
64
64
  <Portal>
65
65
  <HiddenBackground
66
66
  onclose={close}
67
- class="flex h-full w-full flex-col items-center justify-start p-16"
67
+ class="flex h-full w-full flex-col items-center justify-start p-8 lg:p-12 xl:p-16"
68
68
  >
69
69
  {#if modal}
70
70
  <!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -23,14 +23,12 @@ export function searchPlugin<T extends TableRow<T>>(conf: SearchConfig<T>): Tabl
23
23
  if (!conf.search) return state;
24
24
 
25
25
  // ensure we store the state before the we started searching
26
- if (conf.search && !prevSearch) {
27
- expandedBeforeSearch = state.expanded;
28
- }
26
+ if (conf.search && !prevSearch) expandedBeforeSearch = state.expanded;
29
27
 
30
28
  // figure out which nodes to expand and hide
31
29
  const { expanded, hidden } = search(state.data, conf.search, conf.matches);
32
-
33
30
  prevSearch = conf.search;
31
+
34
32
  return {
35
33
  data: state.data.filter((d) => !hidden.has(d.id)),
36
34
  expanded: new SvelteSet(expanded)
@@ -39,7 +37,7 @@ export function searchPlugin<T extends TableRow<T>>(conf: SearchConfig<T>): Tabl
39
37
  return middleware;
40
38
  }
41
39
 
42
- /** collapses everything that doesnt match the searchString expands direct search hit */
40
+ /** collapses everything that doesnt match the searchString, expands direct search hit */
43
41
  export const search = <T extends TableRow<T>>(
44
42
  nodes: T[],
45
43
  searchString: string,
@@ -49,12 +47,12 @@ export const search = <T extends TableRow<T>>(
49
47
  const hidden = new Set<string>();
50
48
  const expanded = new Set<string>();
51
49
 
52
- const recursor = (node: T, childOfMatch = false): boolean => {
50
+ function nodeMatches(node: T, childOfMatch = false): boolean {
53
51
  const matches = stringsMatch(node, search);
54
52
 
55
53
  let intermediate = false;
56
54
  for (const child of node.children || []) {
57
- const childMatches = recursor(child, matches || childOfMatch);
55
+ const childMatches = nodeMatches(child, matches || childOfMatch);
58
56
  if (childMatches && !intermediate) intermediate = true;
59
57
  }
60
58
 
@@ -65,9 +63,9 @@ export const search = <T extends TableRow<T>>(
65
63
  }
66
64
 
67
65
  return matches || intermediate;
68
- };
66
+ }
69
67
 
70
- nodes.forEach((n) => recursor(n));
68
+ nodes.forEach((n) => nodeMatches(n));
71
69
 
72
70
  return {
73
71
  hidden,