@likable-hair/svelte 3.1.52 → 3.2.1

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.
@@ -32,33 +32,45 @@ function handleRowsPerPageChange(e) {
32
32
  handlePaginationChange();
33
33
  }
34
34
  function handlePaginationChange() {
35
+ let builder = buildFilters();
35
36
  dispatch("paginationChange", {
36
37
  rowsPerPage,
37
- page
38
+ page,
39
+ builder
38
40
  });
39
41
  }
40
42
  function handleSearchChange(searchText2) {
43
+ let builder = buildFilters({ searchText: searchText2 });
44
+ dispatch("filtersChange", {
45
+ builder
46
+ });
47
+ }
48
+ $:
49
+ handleSearchChange(searchText);
50
+ function handleFiltersChange() {
51
+ let builder = buildFilters({ searchText });
52
+ dispatch("filtersChange", {
53
+ builder
54
+ });
55
+ }
56
+ function buildFilters(params) {
41
57
  let converter = new Converter();
42
58
  let builder;
43
59
  builder = converter.createBuilder({
44
60
  filters: filters || []
45
61
  });
46
- if (!!searchText2 && !!searchBarColumns && searchBarColumns.length > 0) {
62
+ if (!!params?.searchText && !!searchBarColumns && searchBarColumns.length > 0) {
47
63
  builder.where((b) => {
48
- b.where(searchBarColumns[0], "ilike", "%" + searchText2 + "%");
64
+ b.where(searchBarColumns[0], "ilike", "%" + params?.searchText + "%");
49
65
  for (let i = 1; i < searchBarColumns.length; i += 1) {
50
- b.orWhere(searchBarColumns[i], "ilike", "%" + searchText2 + "%");
66
+ b.orWhere(searchBarColumns[i], "ilike", "%" + params?.searchText + "%");
51
67
  }
52
68
  });
53
69
  }
54
- dispatch("filtersChange", {
55
- builder
56
- });
57
- }
58
- $:
59
- handleSearchChange(searchText);
60
- function handleFiltersChange() {
61
- handleSearchChange(searchText);
70
+ if (!!sortedBy) {
71
+ builder.orderBy(sortedBy, sortDirection || "asc");
72
+ }
73
+ return builder;
62
74
  }
63
75
  </script>
64
76
 
@@ -105,6 +117,7 @@ function handleFiltersChange() {
105
117
  bind:items
106
118
  bind:sortedBy
107
119
  bind:sortDirection
120
+ on:sort={handleFiltersChange}
108
121
  on:sort
109
122
  on:rowClick
110
123
  {calculateRowStyles}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likable-hair/svelte",
3
3
  "description": "A Svelte component for likablehair and others",
4
- "version": "3.1.52",
4
+ "version": "3.2.1",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",