not-bulma 1.2.27 → 1.2.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-bulma",
3
- "version": "1.2.27",
3
+ "version": "1.2.28",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -1,24 +1,37 @@
1
1
  <script>
2
- import {LOCALE} from '../../locale';
3
- export let title = '';
4
- export let font = '';
5
- export let size = '';
2
+ import { LOCALE } from "../../locale";
3
+ /**
4
+ * @property {string} [title='']
5
+ **/
6
+ export let title = "";
7
+ /**
8
+ * @property {string} font
9
+ **/
10
+ export let font = "";
11
+ /**
12
+ * @property {string} [size=''] medium|large
13
+ **/
14
+ export let size = "";
6
15
  </script>
7
16
 
8
17
  {#if title}
9
- <span class="icon-text">
10
- <span class="icon {size?`is-${size}`:''}">
11
- <i class="fas
18
+ <span class="icon-text">
19
+ <span class="icon {size ? `is-${size}` : ''}">
20
+ <i
21
+ class="fas
12
22
  fa-{font}
13
- {size=='medium'?'fa-lg':''}
14
- {size=='large'?'fa-2x':''}
15
- "></i>
16
- </span>
17
- <span>{$LOCALE[title]}</span>
18
- </span>
23
+ {size == 'medium' ? 'fa-lg' : ''}
24
+ {size == 'large' ? 'fa-2x' : ''}
25
+ "
26
+ ></i>
27
+ </span>
28
+ <span>{$LOCALE[title]}</span>
29
+ </span>
19
30
  {:else}
20
- <span class="icon {size?`is-${size}`:''} {size=='medium'?'fa-lg':''}
21
- {size=='large'?'fa-2x':''}">
22
- <i class="fas fa-{font}"></i>
23
- </span>
31
+ <span
32
+ class="icon {size ? `is-${size}` : ''} {size == 'medium' ? 'fa-lg' : ''}
33
+ {size == 'large' ? 'fa-2x' : ''}"
34
+ >
35
+ <i class="fas fa-{font}"></i>
36
+ </span>
24
37
  {/if}
@@ -156,6 +156,14 @@ class notTable extends EventEmitter {
156
156
  }
157
157
  }
158
158
 
159
+ onSorterChange(sorter) {
160
+ if (sorter) {
161
+ this.setSorter(sorter);
162
+ } else {
163
+ this.resetSorter();
164
+ }
165
+ }
166
+
159
167
  onFilterChange(filter) {
160
168
  if (filter) {
161
169
  this.setFilter(filter);
@@ -229,6 +237,7 @@ class notTable extends EventEmitter {
229
237
  search: "",
230
238
  showSelect: this.getOptions("showSelect"),
231
239
  showSearch: this.getOptions("showSearch"),
240
+ showSort: this.getOptions("showSort"),
232
241
  idField: this.getOptions("idField"),
233
242
  getItemId: this.getOptions("getItemId"),
234
243
  filter: this.getFilter(),
@@ -236,6 +245,7 @@ class notTable extends EventEmitter {
236
245
  });
237
246
  }
238
247
  this.ui.table.$on("searchChange", (e) => this.onSearchChange(e.detail));
248
+ this.ui.table.$on("sorterChange", (e) => this.onSorterChange(e.detail));
239
249
  this.ui.table.$on("filterChange", (e) => this.onFilterChange(e.detail));
240
250
  this.ui.table.$on("goToPage", (e) => this.goToPage(e.detail));
241
251
  this.ui.table.$on("goToNextPage", () => this.goToNext());
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { UILinks } from "../../../elements/link";
9
9
  import { UIButtons } from "../../../elements/button";
10
+ import UIIcon from "../../../elements/icon/ui.icon.font.svelte";
10
11
 
11
12
  import { onMount, createEventDispatcher } from "svelte";
12
13
  let dispatch = createEventDispatcher();
@@ -18,6 +19,7 @@
18
19
  export let helpers = {};
19
20
  export let state = {};
20
21
  export let filter = {};
22
+ export let sorter = {};
21
23
  export let fields = [];
22
24
  export let selected = {};
23
25
  export let items = [];
@@ -104,6 +106,18 @@
104
106
  return value;
105
107
  });
106
108
  }
109
+
110
+ function onFieldHeadClick(field) {
111
+ const propPath = field.path.substring(1);
112
+ if (Object.hasOwn(sorter, propPath)) {
113
+ sorter[propPath] = parseInt(sorter[propPath]) * -1;
114
+ } else {
115
+ sorter = {
116
+ [propPath]: 1,
117
+ };
118
+ }
119
+ dispatch("sorterChange", sorter);
120
+ }
107
121
  </script>
108
122
 
109
123
  {#if links.length}
@@ -153,9 +167,20 @@
153
167
  >
154
168
  {/if}
155
169
  {#each fields as field}
156
- <th class={field.hideOnMobile ? "is-hidden-touch" : ""}
157
- >{$LOCALE[field.title]}</th
170
+ {@const propPath = field.path.substring(1)}
171
+ <th
172
+ class={field.hideOnMobile ? "is-hidden-touch" : ""}
173
+ on:click={onFieldHeadClick(field)}
158
174
  >
175
+ {#if field.sortable && Object.hasOwn(sorter, propPath)}
176
+ <UIIcon
177
+ font={sorter[propPath] > 0 ? "sort-up" : "sort-down"}
178
+ title={field.title}
179
+ />
180
+ {:else}
181
+ {$LOCALE[field.title]}
182
+ {/if}
183
+ </th>
159
184
  {/each}
160
185
  </thead>
161
186
  <tbody>