@poirazis/supercomponents-shared 1.2.16 → 1.2.18

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.
Files changed (31) hide show
  1. package/dist/index.js +17703 -22317
  2. package/dist/index.umd.cjs +19 -19
  3. package/package.json +11 -11
  4. package/src/lib/SuperButton/SuperButton.svelte +57 -22
  5. package/src/lib/SuperField/SuperField.svelte +0 -2
  6. package/src/lib/SuperForm/InnerForm.svelte +7 -8
  7. package/src/lib/SuperTable/SuperTable.css +13 -6
  8. package/src/lib/SuperTable/SuperTable.svelte +26 -15
  9. package/src/lib/SuperTable/constants.js +1 -1
  10. package/src/lib/SuperTable/controls/RowButtonsColumn.svelte +33 -17
  11. package/src/lib/SuperTable/controls/SelectionColumn.svelte +2 -2
  12. package/src/lib/SuperTableCells/CellBoolean.svelte +52 -45
  13. package/src/lib/SuperTableCells/CellDatetime.svelte +268 -120
  14. package/src/lib/SuperTableCells/CellLink.svelte +16 -7
  15. package/src/lib/SuperTableCells/CellLinkPickerSelect.svelte +28 -24
  16. package/src/lib/SuperTableCells/CellLinkPickerTree.svelte +22 -20
  17. package/src/lib/SuperTableCells/CellNumber.svelte +55 -53
  18. package/src/lib/SuperTableCells/CellOptions.svelte +59 -32
  19. package/src/lib/SuperTableCells/CellOptionsAdvanced.svelte +131 -129
  20. package/src/lib/SuperTableCells/CellSQLLink.svelte +32 -32
  21. package/src/lib/SuperTableCells/CellSQLLinkPicker.svelte +2 -7
  22. package/src/lib/SuperTableCells/CellString.svelte +49 -47
  23. package/src/lib/SuperTableCells/CellStringMask.svelte +41 -40
  24. package/src/lib/SuperTableColumn/SuperTableColumn.svelte +2 -0
  25. package/src/lib/SuperTableColumn/parts/SuperColumnBody.svelte +3 -0
  26. package/src/lib/SuperTableColumn/parts/SuperColumnHeader.svelte +44 -42
  27. package/src/lib/SuperTableColumn/parts/SuperColumnRow.svelte +1 -1
  28. package/src/lib/SuperTabs/SuperTabs.svelte +33 -17
  29. package/src/lib/UI/elements/Checkbox.svelte +68 -10
  30. package/src/lib/UI/elements/Switch.svelte +162 -0
  31. package/src/lib/UI/elements/Tooltip.svelte +15 -43
@@ -145,7 +145,13 @@
145
145
 
146
146
  if (singleSelect) {
147
147
  editorState.close();
148
- anchor.focus();
148
+ }
149
+
150
+ if (cellOptions.debounced) {
151
+ dispatch(
152
+ "change",
153
+ returnSingle && localValue ? localValue[0] : localValue,
154
+ );
149
155
  }
150
156
  };
151
157
 
@@ -193,7 +199,7 @@
193
199
  class:open-popup={$editorState == "Open"}
194
200
  style:color={cellOptions.color}
195
201
  style:background={cellOptions.background}
196
- on:focusin={cellState.focus}
202
+ on:focus={cellState.focus}
197
203
  on:keydown|self={handleKeyboard}
198
204
  on:focusout={cellState.focusout}
199
205
  on:mousedown={cellState.toggle}
@@ -203,14 +209,12 @@
203
209
  {/if}
204
210
 
205
211
  <div class="value" class:placeholder={localValue?.length < 1}>
206
- {#if localValue?.length < 1}
207
- <span> {placeholder} </span>
208
- {:else if simpleView}
212
+ {#if simpleView}
209
213
  <span>
210
214
  {#if cellOptions.role == "formInput" && localValue.length > 1}
211
215
  ({localValue.length})
212
216
  {/if}
213
- {localValue.map((v) => v.primaryDisplay).join(", ")}
217
+ {localValue.map((v) => v.primaryDisplay).join(", ") || placeholder}
214
218
  </span>
215
219
  {:else}
216
220
  <div
@@ -221,7 +225,7 @@
221
225
  class:withCount={localValue.length > 5}
222
226
  class:inEdit
223
227
  >
224
- {#each localValue as val, idx}
228
+ {#each localValue as val, idx (val)}
225
229
  {#if idx < 5}
226
230
  <div
227
231
  class="item"
@@ -238,6 +242,11 @@
238
242
  </div>
239
243
  {/if}
240
244
  {/each}
245
+
246
+ {#if localValue.length == 0}
247
+ <span>{placeholder}</span>
248
+ {/if}
249
+
241
250
  {#if localValue.length > 5}
242
251
  <span class="count">
243
252
  (+ {localValue.length - 5})
@@ -265,34 +265,38 @@
265
265
  <div class="list" bind:this={listElement} on:scroll={handleScroll}>
266
266
  <div class="options">
267
267
  {#key localValue}
268
- {#if $fetch?.rows?.length || ($fetch?.loading && !$fetch?.loaded)}
269
- {#each $fetch?.rows || [] as row, idx (idx)}
270
- <div
271
- class="option"
272
- class:selected={rowSelected(row)}
273
- class:highlighted={focusIdx == idx}
274
- on:mouseenter={() => (focusIdx = idx)}
275
- on:mouseleave={() => (focusIdx = -1)}
276
- on:mousedown|preventDefault|stopPropagation={selectRow(row)}
277
- >
278
- {row[primaryDisplay]}
279
- <i class="ri-check-line"></i>
280
- </div>
281
- {/each}
282
- {#if $fetch?.loading && $fetch.loaded}
268
+ {#key $fetch?.rows}
269
+ {#if $fetch?.rows?.length || ($fetch?.loading && !$fetch?.loaded)}
270
+ {#each $fetch?.rows || [] as row, idx (idx)}
271
+ <div
272
+ class="option"
273
+ class:selected={rowSelected(row)}
274
+ class:highlighted={focusIdx == idx}
275
+ on:mouseenter={() => (focusIdx = idx)}
276
+ on:mouseleave={() => (focusIdx = -1)}
277
+ on:mousedown|preventDefault|stopPropagation={selectRow(
278
+ row,
279
+ )}
280
+ >
281
+ {row[primaryDisplay]}
282
+ <i class="ri-check-line"></i>
283
+ </div>
284
+ {/each}
285
+ {#if $fetch?.loading && $fetch.loaded}
286
+ <div class="option loading">
287
+ <i class="ri-loader-2-line rotating"></i>
288
+ Loading more...
289
+ </div>
290
+ {/if}
291
+ {:else if $fetch?.loading}
283
292
  <div class="option loading">
284
293
  <i class="ri-loader-2-line rotating"></i>
285
- Loading more...
294
+ Loading...
286
295
  </div>
296
+ {:else}
297
+ <div class="option">No Results Found</div>
287
298
  {/if}
288
- {:else if $fetch?.loading}
289
- <div class="option loading">
290
- <i class="ri-loader-2-line rotating"></i>
291
- Loading...
292
- </div>
293
- {:else}
294
- <div class="option">No Results Found</div>
295
- {/if}
299
+ {/key}
296
300
  {/key}
297
301
  </div>
298
302
  </div>
@@ -108,7 +108,7 @@
108
108
  $selectedNodes = [e.detail];
109
109
  } else {
110
110
  notificationStore.actions.warning(
111
- "Cannot select more than " + maxNodeSelection + " items"
111
+ "Cannot select more than " + maxNodeSelection + " items",
112
112
  );
113
113
  }
114
114
  } else {
@@ -123,7 +123,7 @@
123
123
  "change",
124
124
  $selectedNodes.map((x) => {
125
125
  return { _id: x.id, primaryDisplay: x.label };
126
- })
126
+ }),
127
127
  );
128
128
  };
129
129
 
@@ -183,24 +183,26 @@
183
183
  style="margin: unset;"
184
184
  class:spectrum-TreeView--quiet={quiet}
185
185
  >
186
- {#if $fetch.loaded && $fetch.rows?.length}
187
- {#each tree?.children as node, idx (idx)}
188
- <SuperTree
189
- tree={node}
190
- nodeSelection
191
- {selectedNodes}
192
- on:nodeSelect={handleNodeSelect}
193
- />
194
- {/each}
195
- {:else if $fetch.loading}
196
- <li class="spectrum-TreeView-item" class:is-open={true}>
197
- <div class="spectrum-TreeView-itemLink">Loading</div>
198
- </li>
199
- {:else}
200
- <li class="spectrum-TreeView-item" class:is-open={true}>
201
- <div class="spectrum-TreeView-itemLink">No Matches</div>
202
- </li>
203
- {/if}
186
+ {#key $fetch.rows}
187
+ {#if $fetch.loaded && $fetch.rows?.length}
188
+ {#each tree?.children as node, idx (idx)}
189
+ <SuperTree
190
+ tree={node}
191
+ nodeSelection
192
+ {selectedNodes}
193
+ on:nodeSelect={handleNodeSelect}
194
+ />
195
+ {/each}
196
+ {:else if $fetch.loading}
197
+ <li class="spectrum-TreeView-item" class:is-open={true}>
198
+ <div class="spectrum-TreeView-itemLink">Loading</div>
199
+ </li>
200
+ {:else}
201
+ <li class="spectrum-TreeView-item" class:is-open={true}>
202
+ <div class="spectrum-TreeView-itemLink">No Matches</div>
203
+ </li>
204
+ {/if}
205
+ {/key}
204
206
  </ul>
205
207
  </div>
206
208
 
@@ -311,61 +311,63 @@
311
311
  tabIndex={disabled ? -1 : (cellOptions.order ?? 0)}
312
312
  on:focusin={cellState.focus}
313
313
  >
314
- {#if icon}
315
- <i class={icon + " field-icon"} class:with-error={error}></i>
316
- {/if}
317
-
318
- {#if $cellState == "Editing"}
319
- <input
320
- class="editor"
321
- bind:this={editor}
322
- class:placeholder={!localValue}
323
- style:text-align={cellOptions.align == "flex-start"
324
- ? "left"
325
- : cellOptions.align == "center"
326
- ? "center"
327
- : "right "}
328
- value={localValue || ""}
329
- on:keydown={(e) => cellState.handleKeyboard(e)}
330
- on:input={(e) => cellState.handleInput(e)}
331
- on:focusout={(e) => cellState.focusout(e)}
332
- on:wheel={(e) => cellState.handleWheel(e)}
333
- use:focus
334
- />
335
-
336
- <!-- svelte-ignore a11y-no-static-element-interactions -->
337
- <i
338
- class="ri-close-line clear-icon"
339
- class:visible={clearValue}
340
- on:mousedown|preventDefault|stopPropagation={cellState.clear}
341
- >
342
- </i>
343
-
344
- {#if showStepper}
345
- <div class="controls">
346
- <!-- svelte-ignore a11y-no-static-element-interactions -->
347
- <i
348
- class="ph ph-minus"
349
- on:mousedown|preventDefault|stopPropagation={(e) =>
350
- cellState.decrement(e)}
351
- ></i>
352
- <!-- svelte-ignore a11y-no-static-element-interactions -->
353
- <i
354
- class="ph ph-plus"
355
- on:mousedown|preventDefault|stopPropagation={(e) =>
356
- cellState.increment(e)}
357
- ></i>
314
+ {#key $cellState}
315
+ {#if icon}
316
+ <i class={icon + " field-icon"} class:with-error={error}></i>
317
+ {/if}
318
+
319
+ {#if $cellState == "Editing"}
320
+ <input
321
+ class="editor"
322
+ bind:this={editor}
323
+ class:placeholder={!localValue}
324
+ style:text-align={cellOptions.align == "flex-start"
325
+ ? "left"
326
+ : cellOptions.align == "center"
327
+ ? "center"
328
+ : "right "}
329
+ value={localValue || ""}
330
+ on:keydown={(e) => cellState.handleKeyboard(e)}
331
+ on:input={(e) => cellState.handleInput(e)}
332
+ on:focusout={(e) => cellState.focusout(e)}
333
+ on:wheel={(e) => cellState.handleWheel(e)}
334
+ use:focus
335
+ />
336
+
337
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
338
+ <i
339
+ class="ri-close-line clear-icon"
340
+ class:visible={clearValue}
341
+ on:mousedown|preventDefault|stopPropagation={cellState.clear}
342
+ >
343
+ </i>
344
+
345
+ {#if showStepper}
346
+ <div class="controls">
347
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
348
+ <i
349
+ class="ph ph-minus"
350
+ on:mousedown|preventDefault|stopPropagation={(e) =>
351
+ cellState.decrement(e)}
352
+ ></i>
353
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
354
+ <i
355
+ class="ph ph-plus"
356
+ on:mousedown|preventDefault|stopPropagation={(e) =>
357
+ cellState.increment(e)}
358
+ ></i>
359
+ </div>
360
+ {/if}
361
+ {:else}
362
+ <div
363
+ class="value"
364
+ class:placeholder={!value && value !== 0}
365
+ style:justify-content={cellOptions.align ?? "flex-end"}
366
+ >
367
+ {value != null ? formattedValue : placeholder || ""}
358
368
  </div>
359
369
  {/if}
360
- {:else}
361
- <div
362
- class="value"
363
- class:placeholder={!value && value !== 0}
364
- style:justify-content={cellOptions.align ?? "flex-end"}
365
- >
366
- {value != null ? formattedValue : placeholder || ""}
367
- </div>
368
- {/if}
370
+ {/key}
369
371
  </div>
370
372
 
371
373
  <style>
@@ -100,6 +100,12 @@
100
100
  clearTimeout(timer);
101
101
  timer = setTimeout(() => {
102
102
  dispatch("change", multi ? localValue : localValue[0]);
103
+ dispatch(
104
+ "labelChange",
105
+ multi
106
+ ? localValue.map((val) => $labels[val] || val)
107
+ : $labels[localValue[0]] || localValue[0],
108
+ );
103
109
  }, cellOptions.debounce ?? 0);
104
110
  }
105
111
 
@@ -196,7 +202,6 @@
196
202
  },
197
203
  handleKeyboard(e) {
198
204
  if (e.key === "Backspace" || e.key === "Delete") {
199
- console.log(searchTerm, "before deletion");
200
205
  searchTerm = searchTerm.slice(0, -1);
201
206
  this.filterOptions(searchTerm);
202
207
  } else if (e.key.length === 1 && /[a-zA-Z0-9]/.test(e.key)) {
@@ -379,6 +384,8 @@
379
384
  filteredOptions = $options;
380
385
  },
381
386
  loadCustomOptions() {
387
+ $options = [];
388
+ $labels = {};
382
389
  if (customOptions?.length) {
383
390
  customOptions.forEach((row) => {
384
391
  $options.push(row.value || row);
@@ -469,6 +476,12 @@
469
476
  if (cellOptions.debounce && isDirty) {
470
477
  clearTimeout(timer);
471
478
  dispatch("change", multi ? localValue : localValue[0]);
479
+ dispatch(
480
+ "labelChange",
481
+ multi
482
+ ? localValue.map((val) => $labels[val] || val)
483
+ : $labels[localValue[0]] || localValue[0],
484
+ );
472
485
  } else {
473
486
  this.submit();
474
487
  }
@@ -485,12 +498,24 @@
485
498
  if (isDirty && !cellOptions.debounce) {
486
499
  if (multi) dispatch("change", localValue);
487
500
  else dispatch("change", localValue[0]);
501
+
502
+ if (multi) {
503
+ dispatch(
504
+ "labelChange",
505
+ localValue.map((val) => $labels[val] || val),
506
+ );
507
+ } else {
508
+ dispatch("labelChange", $labels[localValue[0]] || localValue[0]);
509
+ }
488
510
  }
489
511
  },
490
512
  clear() {
491
513
  localValue = [];
492
514
  anchor?.focus();
493
- if (cellOptions.debounce) dispatch("change", null);
515
+ if (cellOptions.debounce) {
516
+ dispatch("change", null);
517
+ dispatch("labelChange", null);
518
+ }
494
519
  },
495
520
  cancel() {
496
521
  localValue = JSON.parse(originalValue);
@@ -674,38 +699,40 @@
674
699
  </div>
675
700
  {:else}
676
701
  <div class="value" class:placeholder={isEmpty && !searchTerm}>
677
- {#if isEmpty}
678
- {#if open}
679
- {searchTerm ? searchTerm : "Type to search..."}
680
- {:else}
681
- {loading ? "Loading..." : placeholder}
682
- {/if}
683
- {:else}
684
- <div
685
- class="items"
686
- class:pills
687
- class:bullets
688
- style:justify-content={cellOptions.align ?? "flex-start"}
689
- >
690
- {#if plaintext}
691
- {#each localValue as val, idx (val)}
692
- {$labels[val] || val}
693
- {idx < localValue.length - 1 ? ", " : ""}
694
- {/each}
702
+ {#key isEmpty}
703
+ {#if localValue?.length < 1}
704
+ {#if open}
705
+ {searchTerm ? searchTerm : "Type to search..."}
695
706
  {:else}
696
- {#each localValue as val, idx}
697
- <div
698
- class="item"
699
- style:--option-color={$colors[val] ||
700
- colorsArray[idx % colorsArray.length]}
701
- >
702
- <div class="loope"></div>
703
- <span> {isObjects ? "JSON" : $labels[val] || val} </span>
704
- </div>
705
- {/each}
707
+ {loading ? "Loading..." : placeholder}
706
708
  {/if}
707
- </div>
708
- {/if}
709
+ {:else}
710
+ <div
711
+ class="items"
712
+ class:pills
713
+ class:bullets
714
+ style:justify-content={cellOptions.align ?? "flex-start"}
715
+ >
716
+ {#if plaintext}
717
+ {#each localValue as val, idx (val)}
718
+ {$labels[val] || val}
719
+ {idx < localValue.length - 1 ? ", " : ""}
720
+ {/each}
721
+ {:else}
722
+ {#each localValue as val, idx (val)}
723
+ <div
724
+ class="item"
725
+ style:--option-color={$colors[val] ||
726
+ colorsArray[idx % colorsArray.length]}
727
+ >
728
+ <div class="loope"></div>
729
+ <span> {isObjects ? "JSON" : $labels[val] || val} </span>
730
+ </div>
731
+ {/each}
732
+ {/if}
733
+ </div>
734
+ {/if}
735
+ {/key}
709
736
  </div>
710
737
  {#if !readonly && (role == "formInput" || inEdit)}
711
738
  <i class="ph ph-caret-down control-icon"></i>