@likable-hair/svelte 3.1.51 → 3.2.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.
@@ -32,33 +32,42 @@ 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
+ return builder;
62
71
  }
63
72
  </script>
64
73
 
@@ -105,6 +114,7 @@ function handleFiltersChange() {
105
114
  bind:items
106
115
  bind:sortedBy
107
116
  bind:sortDirection
117
+ on:sort={handleFiltersChange}
108
118
  on:sort
109
119
  on:rowClick
110
120
  {calculateRowStyles}
@@ -13,9 +13,13 @@ export let calculateRowClasses = void 0;
13
13
  onMount(() => {
14
14
  if (resizableColumns) {
15
15
  for (const head of [...headers, { value: "slot-append" }]) {
16
- let th = document.getElementById(head.value);
16
+ let th;
17
+ if (head.value == "slot-append") {
18
+ th = document.getElementsByClassName(head.value).item(0);
19
+ } else {
20
+ th = document.getElementById(head.value);
21
+ }
17
22
  if (!!th) {
18
- let { paddingLeft, paddingRight } = getComputedStyle(th);
19
23
  let widthWihtPadding;
20
24
  if (!!resizedColumnSizeWithPadding[head.value]) {
21
25
  widthWihtPadding = resizedColumnSizeWithPadding[head.value];
@@ -23,7 +27,19 @@ onMount(() => {
23
27
  widthWihtPadding = th.getBoundingClientRect().width;
24
28
  resizedColumnSizeWithPadding[head.value] = widthWihtPadding;
25
29
  }
26
- let width = widthWihtPadding - parseFloat(paddingLeft) - parseFloat(paddingRight);
30
+ }
31
+ }
32
+ for (const head of [...headers, { value: "slot-append" }]) {
33
+ let th;
34
+ if (head.value == "slot-append") {
35
+ th = document.getElementsByClassName(head.value).item(0);
36
+ } else {
37
+ th = document.getElementById(head.value);
38
+ }
39
+ if (!!th) {
40
+ let { paddingLeft, paddingRight } = getComputedStyle(th);
41
+ let width = resizedColumnSizeWithPadding[head.value] - parseFloat(paddingLeft) - parseFloat(paddingRight);
42
+ console.log(resizedColumnSizeWithPadding[head.value], paddingLeft, paddingRight, width);
27
43
  th.style.width = `${width}px`;
28
44
  }
29
45
  }
@@ -82,7 +98,6 @@ function resize(node) {
82
98
  }
83
99
  }, mouseUpHandler = function(e) {
84
100
  if (!!th) {
85
- e.stopPropagation();
86
101
  resizing = false;
87
102
  let { paddingLeft, paddingRight } = getComputedStyle(th);
88
103
  width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
@@ -157,7 +172,7 @@ function resize(node) {
157
172
  </th>
158
173
  {/each}
159
174
  {#if $$slots.rowActions || $$slots.append}
160
- <th id="slot-append">
175
+ <th class="slot-append">
161
176
  <slot name="append" index={-1} items={undefined} />
162
177
  </th>
163
178
  {/if}
@@ -210,7 +225,7 @@ function resize(node) {
210
225
  </td>
211
226
  {/each}
212
227
  {#if $$slots.rowActions || $$slots.append}
213
- <td class="{clazz.cell || ''}">
228
+ <td class="{clazz.cell || ''} append" style:width="fit-content">
214
229
  <slot name="rowActions" index={i} {item} />
215
230
  <slot name="append" index={i} {item} />
216
231
  </td>
@@ -223,6 +238,20 @@ function resize(node) {
223
238
  {/if}
224
239
 
225
240
  <style>
241
+
242
+ th.slot-append {
243
+ width: 1px;
244
+ min-width: unset;
245
+ }
246
+
247
+ .table.resizable .slot-append {
248
+ box-sizing: content-box;
249
+ }
250
+
251
+ .table.resizable td.append {
252
+ padding: 0;
253
+ }
254
+
226
255
  .simple-table-container.resizable {
227
256
  overflow-x: auto;
228
257
  }
@@ -239,6 +268,7 @@ function resize(node) {
239
268
  cursor: col-resize;
240
269
  background-clip: content-box;
241
270
  padding: 0px 5px 0px 5px;
271
+ box-sizing: content-box;
242
272
  }
243
273
 
244
274
  th:hover .resizer {
@@ -398,6 +428,7 @@ function resize(node) {
398
428
  min-width: 100px;
399
429
  position: relative;
400
430
  user-select: none;
431
+ box-sizing: content-box;
401
432
  }
402
433
 
403
434
  td {
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.51",
4
+ "version": "3.2.0",
5
5
  "scripts": {
6
6
  "host": "vite --host",
7
7
  "dev": "vite dev",