@poirazis/supercomponents-shared 1.1.8 → 1.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.
Files changed (51) hide show
  1. package/dist/index.js +21180 -40125
  2. package/dist/index.umd.cjs +19 -26
  3. package/dist/style.css +1 -1
  4. package/package.json +5 -5
  5. package/src/index.js +4 -0
  6. package/src/index.ts +3 -0
  7. package/src/lib/Actions/index.js +3 -3
  8. package/src/lib/Actions/position_dropdown.js +14 -7
  9. package/src/lib/SuperButton/SuperButton.svelte +34 -3
  10. package/src/lib/SuperField/SuperField.svelte +0 -11
  11. package/src/lib/SuperForm/InnerForm.svelte +1 -1
  12. package/src/lib/SuperList/SuperList.svelte +2 -2
  13. package/src/lib/SuperList/drag-handle.svelte +8 -8
  14. package/src/lib/SuperPopover/SuperPopover.svelte +2 -2
  15. package/src/lib/SuperTable/SuperTable.css +8 -3
  16. package/src/lib/SuperTable/SuperTable.svelte +3 -3
  17. package/src/lib/SuperTable/controls/PaginationLimitOffset.svelte +2 -0
  18. package/src/lib/SuperTable/controls/SelectionColumn.svelte +18 -49
  19. package/src/lib/SuperTable/controls/SuperTableWelcome.svelte +1 -1
  20. package/src/lib/SuperTable/overlays/AddNewRowOverlay.svelte +3 -3
  21. package/src/lib/SuperTable/overlays/EmptyResultSetOverlay.svelte +1 -1
  22. package/src/lib/SuperTable/overlays/ScrollbarsOverlay.svelte +43 -43
  23. package/src/lib/SuperTableCells/CellAttachmentExpanded.svelte +1 -1
  24. package/src/lib/SuperTableCells/CellAttachmentSlider.svelte +2 -3
  25. package/src/lib/SuperTableCells/CellBoolean.svelte +1 -1
  26. package/src/lib/SuperTableCells/CellColor.svelte +7 -7
  27. package/src/lib/SuperTableCells/CellCommon.css +1 -1
  28. package/src/lib/SuperTableCells/CellIcon.svelte +7 -7
  29. package/src/lib/SuperTableCells/CellJSON.svelte +2 -2
  30. package/src/lib/SuperTableCells/CellLink.svelte +50 -43
  31. package/src/lib/SuperTableCells/CellLinkAdvanced.svelte +2 -16
  32. package/src/lib/SuperTableCells/CellLinkPickerSelect.svelte +10 -11
  33. package/src/lib/SuperTableCells/CellLinkPickerTree.svelte +4 -2
  34. package/src/lib/SuperTableCells/CellNumber.svelte +24 -5
  35. package/src/lib/SuperTableCells/CellOptions.svelte +20 -34
  36. package/src/lib/SuperTableCells/CellOptionsAdvanced.svelte +5 -5
  37. package/src/lib/SuperTableCells/CellSQLLink.svelte +24 -36
  38. package/src/lib/SuperTableCells/CellSQLLinkPicker.svelte +9 -9
  39. package/src/lib/SuperTableCells/CellString.svelte +3 -3
  40. package/src/lib/SuperTableCells/CellStringMask.svelte +1 -1
  41. package/src/lib/SuperTableCells/CellTags.svelte +151 -108
  42. package/src/lib/SuperTableCells/JSDOC_GUIDE.md +163 -3
  43. package/src/lib/SuperTableCells/types.js +141 -192
  44. package/src/lib/SuperTableColumn/SuperTableColumn.svelte +1 -1
  45. package/src/lib/SuperTableColumn/parts/SuperColumnHeader.svelte +2 -2
  46. package/src/lib/SuperTableColumn/parts/SuperColumnRow.svelte +5 -3
  47. package/src/lib/SuperTabs/SuperTabs.svelte +2 -2
  48. package/src/lib/SuperTree/SuperTree.svelte +84 -38
  49. package/src/lib/UI/elements/Checkbox.svelte +36 -6
  50. package/src/lib/UI/elements/IconButton.svelte +115 -0
  51. package/src/lib/UI/elements/Tooltip.svelte +65 -0
@@ -39,17 +39,6 @@
39
39
  if (!cellOptions.readonly && !cellOptions.disabled) return "Editing";
40
40
  },
41
41
  },
42
- Hovered: {
43
- cancel: () => {
44
- return "View";
45
- },
46
- },
47
- Focused: {
48
- unfocus() {
49
- return "View";
50
- },
51
- },
52
- Error: { check: "View" },
53
42
  Editing: {
54
43
  _enter() {
55
44
  originalValue = JSON.stringify(localValue);
@@ -61,7 +50,12 @@
61
50
  dispatch("exitedit");
62
51
  },
63
52
  focusout(e) {
64
- if (popup?.contains(e?.relatedTarget)) return;
53
+ if (
54
+ anchor?.contains(e?.relatedTarget) ||
55
+ popup?.contains(e?.relatedTarget)
56
+ )
57
+ return;
58
+
65
59
  this.submit();
66
60
  },
67
61
 
@@ -78,6 +72,8 @@
78
72
  return "View";
79
73
  },
80
74
  cancel() {
75
+ localValue = JSON.parse(originalValue);
76
+ anchor?.blur();
81
77
  return "View";
82
78
  },
83
79
  },
@@ -130,6 +126,7 @@
130
126
  const handleKeyboard = (e) => {
131
127
  if (e.key == "Escape" && $editorState == "Open") {
132
128
  editorState.close();
129
+ return;
133
130
  } else if (e.key == "Escape") {
134
131
  cellState.cancel();
135
132
  } else if (e.keyCode == 32 && $cellState == "Editing") {
@@ -146,6 +143,7 @@
146
143
 
147
144
  if (singleSelect) {
148
145
  editorState.close();
146
+ anchor.focus();
149
147
  }
150
148
  };
151
149
 
@@ -192,7 +190,6 @@
192
190
  class:error={cellOptions.error}
193
191
  style:color={cellOptions.color}
194
192
  style:background={cellOptions.background}
195
- style:font-weight={cellOptions.fontWeight}
196
193
  on:mousedown={editorState.toggle}
197
194
  on:focusin={cellState.focus}
198
195
  on:keydown|self={handleKeyboard}
@@ -224,7 +221,7 @@
224
221
  }
225
222
  : null}
226
223
  >
227
- <i class={valueIcon} />
224
+ <i class={valueIcon}></i>
228
225
  <span>{val.primaryDisplay}</span>
229
226
  </div>
230
227
  {/if}
@@ -253,36 +250,46 @@
253
250
  <SuperPopover
254
251
  {anchor}
255
252
  useAnchorWidth
256
- bind:popup
257
253
  open={$editorState == "Open"}
254
+ on:close={cellState.cancel}
255
+ bind:popup
258
256
  >
259
- {#if fieldSchema.recursiveTable}
260
- <CellLinkPickerTree
261
- {fieldSchema}
262
- filter={filter ?? []}
263
- {search}
264
- {limit}
265
- joinColumn={cellOptions.joinColumn}
266
- value={localValue}
267
- {ownId}
268
- multi={fieldSchema.relationshipType == "many-to-many" ||
269
- fieldSchema.relationshipType == "many-to-one"}
270
- on:change={handleChange}
271
- />
272
- {:else}
273
- <CellLinkPickerSelect
274
- bind:api={pickerApi}
275
- {fieldSchema}
276
- filter={filter ?? []}
277
- {singleSelect}
278
- value={localValue}
279
- {search}
280
- wide={cellOptions.wide && !singleSelect}
281
- on:change={handleChange}
282
- on:close={() => {
283
- cellState.focusout();
284
- }}
285
- />
286
- {/if}
257
+ <!-- svelte-ignore a11y-no-static-element-interactions -->
258
+ <div
259
+ class="picker-container"
260
+ on:keydown={(e) => {
261
+ if (e.key == "Escape" || e.key == "Tab") {
262
+ anchor.focus();
263
+ editorState.close();
264
+ e.preventDefault();
265
+ }
266
+ }}
267
+ >
268
+ {#if fieldSchema.recursiveTable}
269
+ <CellLinkPickerTree
270
+ {fieldSchema}
271
+ filter={filter ?? []}
272
+ {search}
273
+ {limit}
274
+ joinColumn={cellOptions.joinColumn}
275
+ value={localValue}
276
+ {ownId}
277
+ multi={fieldSchema.relationshipType == "many-to-many" ||
278
+ fieldSchema.relationshipType == "many-to-one"}
279
+ on:change={handleChange}
280
+ />
281
+ {:else}
282
+ <CellLinkPickerSelect
283
+ bind:api={pickerApi}
284
+ {fieldSchema}
285
+ filter={filter ?? []}
286
+ {singleSelect}
287
+ value={localValue}
288
+ {search}
289
+ wide={cellOptions.wide && !singleSelect}
290
+ on:change={handleChange}
291
+ />
292
+ {/if}
293
+ </div>
287
294
  </SuperPopover>
288
295
  {/if}
@@ -3,7 +3,6 @@
3
3
  import fsm from "svelte-fsm";
4
4
  import SuperPopover from "../SuperPopover/SuperPopover.svelte";
5
5
  import CellLinkPickerTree from "../../lib/SuperTableCells/CellLinkPickerTree.svelte";
6
- import { readonly } from "svelte/store";
7
6
  const dispatch = createEventDispatcher();
8
7
 
9
8
  export let value;
@@ -34,17 +33,6 @@
34
33
  if (!cellOptions.readonly && !cellOptions.disabled) return "Editing";
35
34
  },
36
35
  },
37
- Hovered: {
38
- cancel: () => {
39
- return "View";
40
- },
41
- },
42
- Focused: {
43
- unfocus() {
44
- return "View";
45
- },
46
- },
47
- Error: { check: "View" },
48
36
  Editing: {
49
37
  _enter() {
50
38
  originalValue = JSON.stringify(localValue);
@@ -62,9 +50,7 @@
62
50
  if (popup?.contains(e.relatedTarget)) return;
63
51
  this.submit();
64
52
  },
65
- popupfocusout(e) {
66
- console.log(e);
67
- },
53
+ popupfocusout(e) {},
68
54
  clear() {
69
55
  localValue = [];
70
56
  },
@@ -216,7 +202,7 @@
216
202
  class={fieldSchema.type == "link"
217
203
  ? "ri-links-line"
218
204
  : "ri-user-line"}
219
- />
205
+ ></i>
220
206
  {/if}
221
207
  <span>{val.primaryDisplay}</span>
222
208
  </div>
@@ -140,9 +140,9 @@
140
140
  e.preventDefault();
141
141
  focusIdx -= 1;
142
142
  if (focusIdx < 0) focusIdx = $fetch.rows.length - 1;
143
- } else if (e.key == "Enter" && focusIdx > -1)
143
+ } else if (e.key == "Enter" && focusIdx > -1) {
144
144
  selectRow($fetch.rows[focusIdx]);
145
- if (e.key == "Tab" || e.key == "Escape") dispatch("close");
145
+ }
146
146
  };
147
147
 
148
148
  // Auto-fetch more if initial data doesn't fill viewport
@@ -180,7 +180,7 @@
180
180
  style:color={filterTerm
181
181
  ? "var(--spectrum-global-color-blue-400)"
182
182
  : "var(--spectrum-global-color-gray-700)"}
183
- />
183
+ ></i>
184
184
  <input
185
185
  bind:this={control}
186
186
  class="search"
@@ -191,7 +191,6 @@
191
191
  : "Search"}
192
192
  on:input={handleSearch}
193
193
  on:keydown={handleNavigation}
194
- on:blur={() => dispatch("close")}
195
194
  />
196
195
  </div>
197
196
 
@@ -214,19 +213,19 @@
214
213
  )}
215
214
  >
216
215
  {row[primaryDisplay]}
217
- <i class="ri-add-line" />
216
+ <i class="ri-add-line"></i>
218
217
  </div>
219
218
  {/if}
220
219
  {/each}
221
220
  {#if $fetch?.loading && $fetch.loaded}
222
221
  <div class="option wide loading">
223
- <i class="ri-loader-2-line rotating" />
222
+ <i class="ri-loader-2-line rotating"></i>
224
223
  Loading more...
225
224
  </div>
226
225
  {/if}
227
226
  {:else if $fetch?.loading}
228
227
  <div class="option wide loading">
229
- <i class="ri-loader-2-line rotating" />
228
+ <i class="ri-loader-2-line rotating"></i>
230
229
  Loading...
231
230
  </div>
232
231
  {:else}
@@ -248,7 +247,7 @@
248
247
  )}
249
248
  >
250
249
  {val.primaryDisplay}
251
- <i class="ri-close-line" />
250
+ <i class="ri-close-line"></i>
252
251
  </div>
253
252
  {/if}
254
253
  {/each}
@@ -274,18 +273,18 @@
274
273
  on:mousedown|preventDefault|stopPropagation={selectRow(row)}
275
274
  >
276
275
  {row[primaryDisplay]}
277
- <i class="ri-check-line" />
276
+ <i class="ri-check-line"></i>
278
277
  </div>
279
278
  {/each}
280
279
  {#if $fetch?.loading && $fetch.loaded}
281
280
  <div class="option loading">
282
- <i class="ri-loader-2-line rotating" />
281
+ <i class="ri-loader-2-line rotating"></i>
283
282
  Loading more...
284
283
  </div>
285
284
  {/if}
286
285
  {:else if $fetch?.loading}
287
286
  <div class="option loading">
288
- <i class="ri-loader-2-line rotating" />
287
+ <i class="ri-loader-2-line rotating"></i>
289
288
  Loading...
290
289
  </div>
291
290
  {:else}
@@ -163,8 +163,6 @@
163
163
  role: "inlineInput",
164
164
  debounce: 50,
165
165
  };
166
-
167
- export const api = {};
168
166
  </script>
169
167
 
170
168
  <!-- svelte-ignore a11y-no-static-element-interactions -->
@@ -226,4 +224,8 @@
226
224
  display: flex;
227
225
  align-items: stretch;
228
226
  }
227
+
228
+ .spectrum-TreeView {
229
+ width: 100%;
230
+ }
229
231
  </style>
@@ -8,7 +8,7 @@
8
8
  import fsm from "svelte-fsm";
9
9
 
10
10
  /**
11
- * @typedef {import('./types.js').CellNumberOptions} CellNumberOptions
11
+ * @typedef {import('./types.js').CellOptions} CellOptions
12
12
  * @typedef {import('./types.js').CellApi} CellApi
13
13
  */
14
14
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  /** @type {number | null} */
20
20
  export let value;
21
- /** @type {CellNumberOptions} */
21
+ /** @type {CellOptions} */
22
22
  export let cellOptions = {};
23
23
  export let autofocus = false;
24
24
 
@@ -51,9 +51,28 @@
51
51
  } = cellOptions ?? {});
52
52
 
53
53
  // Helper function to format number with thousands separator
54
+ /**
55
+ * @param {number | string | null | undefined} num
56
+ * @param {string | undefined} separator
57
+ * @param {number | undefined} decimals
58
+ * @returns {string}
59
+ */
54
60
  function formatNumber(num, separator, decimals) {
55
- if (!num && num !== 0) return "";
56
- const fixed = num.toFixed(decimals ?? 0);
61
+ // Parse string to number if needed
62
+ const parsedNum = typeof num === "string" ? parseFloat(num) : num;
63
+
64
+ // Check if it's a valid number
65
+ if (isNaN(parsedNum) || (parsedNum !== 0 && !parsedNum)) return "";
66
+
67
+ // If decimals not specified and input was a string, preserve original decimals
68
+ let fixed;
69
+ if (decimals === undefined && typeof num === "string") {
70
+ // Keep the string representation to preserve decimals
71
+ fixed = parsedNum.toString();
72
+ } else {
73
+ fixed = parsedNum.toFixed(decimals ?? 0);
74
+ }
75
+
57
76
  if (!separator) return fixed;
58
77
 
59
78
  const parts = fixed.split(".");
@@ -113,7 +132,7 @@
113
132
  dispatch("exitedit");
114
133
  },
115
134
  clear() {
116
- if (debounceDelay) dispatch("change", null);
135
+ dispatch("change", null);
117
136
  lastEdit = new Date();
118
137
  localValue = null;
119
138
  },
@@ -14,6 +14,7 @@
14
14
 
15
15
  let anchor;
16
16
  let editor;
17
+ let optionsList;
17
18
  let options = memo([]);
18
19
  let labels = {};
19
20
  let optionColors = {};
@@ -85,7 +86,7 @@
85
86
  Loading: {
86
87
  _enter() {
87
88
  if (cellOptions.optionsSource != "data" || $fetch?.loaded)
88
- this.goTo.debounce(5, cellOptions.initialState || "View");
89
+ this.goTo.debounce(15, cellOptions.initialState || "View");
89
90
  },
90
91
  _exit() {
91
92
  if (cellOptions.optionsSource == "custom") this.loadCustomOptions();
@@ -158,6 +159,7 @@
158
159
  if (cellOptions.debounce) dispatch("change", null);
159
160
  },
160
161
  cancel() {
162
+ localValue = JSON.parse(originalValue);
161
163
  searchTerm = null;
162
164
  anchor?.blur();
163
165
  return "View";
@@ -208,7 +210,7 @@
208
210
  Open: {
209
211
  _enter() {
210
212
  searchTerm = "";
211
- this.filterOptions();
213
+ // this.filterOptions();
212
214
  focusedOptionIdx = -1;
213
215
  },
214
216
  filterOptions(term) {
@@ -271,8 +273,10 @@
271
273
  }
272
274
 
273
275
  if (e.key == "Escape") {
276
+ e.stopPropagation();
277
+ e.preventDefault();
274
278
  searchTerm = null;
275
- anchor?.focus();
279
+ //anchor?.focus();
276
280
  return "Closed";
277
281
  }
278
282
 
@@ -541,7 +545,7 @@
541
545
  on:keydown={editorState.handleKeyboard}
542
546
  >
543
547
  {#if icon}
544
- <i class={icon + " field-icon"} class:active={searchTerm} />
548
+ <i class={icon + " field-icon"} class:active={searchTerm}></i>
545
549
  {/if}
546
550
 
547
551
  {#if inEdit && controlType == "inputSelect"}
@@ -564,7 +568,7 @@
564
568
  style:min-width={"4rem"}
565
569
  >
566
570
  {#if pills}
567
- <div class="loope" />
571
+ <div class="loope"></div>
568
572
  {/if}
569
573
  <span> {labels[val] || val} </span>
570
574
  </div>
@@ -592,7 +596,7 @@
592
596
  <div
593
597
  class="value"
594
598
  class:placeholder={isEmpty && !searchTerm}
595
- on:mousedown={inEdit ? editorState.toggle : null}
599
+ on:mousedown={inEdit ? editorState.toggle : () => {}}
596
600
  >
597
601
  {#if isEmpty && !open}
598
602
  <span>{searchTerm || placeholder}</span>
@@ -617,7 +621,7 @@
617
621
  style:--option-color={$colors[val] ||
618
622
  colorsArray[idx % colorsArray.length]}
619
623
  >
620
- <i class={"ph-fill ph-square"} />
624
+ <i class={"ph-fill ph-square"}></i>
621
625
  <span> {isObjects ? "JSON" : labels[val] || val} </span>
622
626
  </div>
623
627
  {/each}
@@ -628,7 +632,7 @@
628
632
  <i
629
633
  class="ph ph-caret-down control-icon"
630
634
  on:mousedown={inEdit ? editorState.toggle : null}
631
- />
635
+ ></i>
632
636
  {/if}
633
637
  {/if}
634
638
  </div>
@@ -636,24 +640,19 @@
636
640
  <!-- svelte-ignore a11y-no-static-element-interactions -->
637
641
  <!-- svelte-ignore a11y-click-events-have-key-events -->
638
642
  {#if inEdit}
639
- <SuperPopover
640
- {anchor}
641
- useAnchorWidth
642
- maxHeight={250}
643
- {open}
644
- on:close={editorState.close}
645
- >
643
+ <SuperPopover {anchor} useAnchorWidth maxHeight={250} {open}>
646
644
  <div class="picker" on:mousedown|stopPropagation|preventDefault>
647
645
  {#if searchTerm && !isEmpty}
648
646
  <div class="searchControl">
649
647
  <i
650
648
  class="search-icon ph ph-magnifying-glass"
651
649
  class:active={searchTerm}
652
- />
650
+ ></i>
653
651
  <span class="search-term">{searchTerm}</span>
654
652
  </div>
655
653
  {/if}
656
654
  <div
655
+ bind:this={optionsList}
657
656
  class="options"
658
657
  on:wheel={(e) => e.stopPropagation()}
659
658
  on:mouseleave={() => (focusedOptionIdx = -1)}
@@ -661,7 +660,7 @@
661
660
  >
662
661
  {#if optionsSource == "data" && $fetch?.loading && !$fetch?.rows?.length}
663
662
  <div class="option loading">
664
- <i class="ph ph-spinner spin" />
663
+ <i class="ph ph-spinner spin"></i>
665
664
  Loading...
666
665
  </div>
667
666
  {:else if filteredOptions?.length}
@@ -682,22 +681,22 @@
682
681
  ? "ph ph-" + $fetch?.rows?.[idx]?.[iconColumn]
683
682
  : "ph-fill ph-square"}
684
683
  style:color={$colors[option]}
685
- />
684
+ ></i>
686
685
  {labels[option] || option}
687
686
  </span>
688
- <i class="ph ph-check" />
687
+ <i class="ph ph-check"></i>
689
688
  </div>
690
689
  {/each}
691
690
  {#if optionsSource == "data" && $fetch?.loading}
692
691
  <div class="option loading">
693
- <i class="ph ph-spinner spin" />
692
+ <i class="ph ph-spinner spin"></i>
694
693
  Loading more...
695
694
  </div>
696
695
  {/if}
697
696
  {:else}
698
697
  <div class="option">
699
698
  <span>
700
- <i class="ri-close-line" />
699
+ <i class="ri-close-line"></i>
701
700
  No Options Found
702
701
  </span>
703
702
  </div>
@@ -774,19 +773,6 @@
774
773
  justify-content: center;
775
774
  color: var(--spectrum-global-color-gray-500);
776
775
  font-style: italic;
777
-
778
- & > i.rotating {
779
- animation: rotate 1s linear infinite;
780
- }
781
- }
782
-
783
- @keyframes rotate {
784
- from {
785
- transform: rotate(0deg);
786
- }
787
- to {
788
- transform: rotate(360deg);
789
- }
790
776
  }
791
777
 
792
778
  .action-icon {
@@ -441,7 +441,7 @@
441
441
  : localValue.includes(option)
442
442
  ? "ph-fill ph-check-square"
443
443
  : "ph ph-square"}
444
- />
444
+ ></i>
445
445
  {labels[option] || option}
446
446
  </div>
447
447
  {/each}
@@ -469,7 +469,7 @@
469
469
  type="checkbox"
470
470
  class="spectrum-Switch-input"
471
471
  />
472
- <span class="spectrum-Switch-switch" />
472
+ <span class="spectrum-Switch-switch"></span>
473
473
  </div>
474
474
  {/if}
475
475
  </div>
@@ -483,7 +483,7 @@
483
483
  on:click={(e) => editorState.toggleOption(idx)}
484
484
  on:mouseenter={() => (focusedOptionIdx = idx)}
485
485
  >
486
- <i class={optionIcons[option] || "no-icon"} />
486
+ <i class={optionIcons[option] || "no-icon"}></i>
487
487
  <div class="text">{labels[option] || option}</div>
488
488
  <div class="spectrum-Switch spectrum-Switch--emphasized">
489
489
  <input
@@ -518,7 +518,7 @@
518
518
  {#if filteredOptions?.length < 1 || filteredOptions.length == localValue.length}
519
519
  <div class="option">
520
520
  <span>
521
- <i class="ri-close-line" />
521
+ <i class="ri-close-line"></i>
522
522
  No Options Found
523
523
  </span>
524
524
  </div>
@@ -535,7 +535,7 @@
535
535
  on:mouseenter={() => (focusedOptionIdx = idx)}
536
536
  >
537
537
  <span>
538
- <i class="ri-checkbox-blank-fill" />
538
+ <i class="ri-checkbox-blank-fill"></i>
539
539
  {labels[option] || option}
540
540
  </span>
541
541
  </div>
@@ -24,6 +24,25 @@
24
24
  let search;
25
25
  let pickerApi;
26
26
 
27
+ const editorState = fsm("Closed", {
28
+ Open: {
29
+ close() {
30
+ return "Closed";
31
+ },
32
+ toggle() {
33
+ return "Closed";
34
+ },
35
+ },
36
+ Closed: {
37
+ open() {
38
+ return "Open";
39
+ },
40
+ toggle() {
41
+ return "Open";
42
+ },
43
+ },
44
+ });
45
+
27
46
  export let cellState = fsm(cellOptions.initialState ?? "View", {
28
47
  "*": {
29
48
  goTo(state) {
@@ -39,17 +58,6 @@
39
58
  if (!cellOptions.readonly && !cellOptions.disabled) return "Editing";
40
59
  },
41
60
  },
42
- Hovered: {
43
- cancel: () => {
44
- return "View";
45
- },
46
- },
47
- Focused: {
48
- unfocus() {
49
- return "View";
50
- },
51
- },
52
- Error: { check: "View" },
53
61
  Editing: {
54
62
  _enter() {
55
63
  originalValue = JSON.stringify(localValue);
@@ -79,25 +87,6 @@
79
87
  },
80
88
  });
81
89
 
82
- const editorState = fsm("Closed", {
83
- Open: {
84
- close() {
85
- return "Closed";
86
- },
87
- toggle() {
88
- return "Closed";
89
- },
90
- },
91
- Closed: {
92
- open() {
93
- return "Open";
94
- },
95
- toggle() {
96
- return "Open";
97
- },
98
- },
99
- });
100
-
101
90
  $: relatedField = fieldSchema?.relatedField || "id";
102
91
  $: relatedTableId = fieldSchema?.tableId;
103
92
  $: relatedColumns = fieldSchema?.relatedColumns || [];
@@ -230,7 +219,6 @@
230
219
  style:color={cellOptions.color}
231
220
  style:background={cellOptions.background}
232
221
  style:font-weight={cellOptions.fontWeight}
233
- on:mousedown={editorState.toggle}
234
222
  on:focusin={cellState.focus}
235
223
  on:keydown|self={handleKeyboard}
236
224
  on:focusout={cellState.focusout}
@@ -272,7 +260,7 @@
272
260
  {/if}
273
261
  </div>
274
262
  {#if !readonly && (cellOptions.role == "formInput" || inEdit)}
275
- <i class="ph ph-caret-down control-icon"></i>
263
+ <i class="ph ph-caret-down control-icon" on:click={editorState.toggle}></i>
276
264
  {/if}
277
265
  </div>
278
266
 
@@ -280,8 +268,11 @@
280
268
  <SuperPopover
281
269
  {anchor}
282
270
  useAnchorWidth
283
- bind:popup
284
271
  open={$editorState == "Open"}
272
+ on:close={(e) => {
273
+ console.log("closing editor");
274
+ editorState.close();
275
+ }}
285
276
  >
286
277
  {#if fieldSchema.recursiveTable}
287
278
  <CellLinkPickerTree
@@ -303,9 +294,6 @@
303
294
  value={localValue}
304
295
  bind:api={pickerApi}
305
296
  on:change={handleChange}
306
- on:close={() => {
307
- cellState.focusout(null);
308
- }}
309
297
  />
310
298
  {/if}
311
299
  </SuperPopover>