@humandialog/forms.svelte 1.4.6 → 1.4.8

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.
@@ -1,10 +1,19 @@
1
- <script>import { each } from "svelte/internal";
2
- import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations } from "../stores.js";
1
+ <script>import { contextToolbarOperations, pageToolbarOperations, leftHandedFAB, toolsActionsOperations, fabCollapsed, bottom_bar_visible_store, main_sidebar_visible_store } from "../stores.js";
3
2
  import { showFloatingToolbar, showMenu, showGridMenu } from "./menu.js";
4
- import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV } from "svelte-icons/fa/";
3
+ import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV, FaRegDotCircle, FaDotCircle } from "svelte-icons/fa/";
5
4
  import { isDeviceSmallerThan } from "../utils.js";
5
+ import { tick } from "svelte";
6
+ export let mainPageCoords = void 0;
6
7
  $:
7
- setupCurrentContextOperations($pageToolbarOperations, $contextToolbarOperations, $toolsActionsOperations);
8
+ setupCurrentContextOperations(
9
+ $pageToolbarOperations,
10
+ $contextToolbarOperations,
11
+ $toolsActionsOperations,
12
+ $fabCollapsed,
13
+ $bottom_bar_visible_store,
14
+ $main_sidebar_visible_store,
15
+ $leftHandedFAB
16
+ );
8
17
  let operations = [];
9
18
  let mainOperation = null;
10
19
  let secondaryOperation = null;
@@ -13,7 +22,8 @@ let isExpandable = false;
13
22
  let vToolboxExpanded = false;
14
23
  let hToolboxExpanded = false;
15
24
  let isDirectPositioningMode = false;
16
- function setupCurrentContextOperations(...args) {
25
+ async function setupCurrentContextOperations(...args) {
26
+ await tick();
17
27
  let opVer = 0;
18
28
  let main_FAB_position = "";
19
29
  isDirectPositioningMode = false;
@@ -83,6 +93,16 @@ function setupCurrentContextOperations(...args) {
83
93
  }
84
94
  });
85
95
  });
96
+ if (operations.length > 1) {
97
+ if (!operations.find((op) => op.fab == "M10")) {
98
+ const collapseFAB = {
99
+ icon: $fabCollapsed ? FaRegDotCircle : FaDotCircle,
100
+ fab: "M10",
101
+ action: (f) => toggleExpandAdditionalOperations()
102
+ };
103
+ operations = [...operations, collapseFAB];
104
+ }
105
+ }
86
106
  } else {
87
107
  if (operations.length > 0)
88
108
  mainOperation = operations[0];
@@ -105,6 +125,9 @@ function setupCurrentContextOperations(...args) {
105
125
  isExpandable = false;
106
126
  }
107
127
  }
128
+ function toggleExpandAdditionalOperations() {
129
+ $fabCollapsed = !$fabCollapsed;
130
+ }
108
131
  export function activateMainOperation() {
109
132
  const mainOperationButton = document.getElementById("__hd_fab_mainOperation");
110
133
  if (!mainOperationButton)
@@ -166,7 +189,6 @@ function getSelectionPos() {
166
189
  return 0;
167
190
  }
168
191
  function calculatePosition(operation) {
169
- const isLeftHanded = false;
170
192
  let result = "";
171
193
  const fab = operation.fab;
172
194
  if (fab.length != 3)
@@ -179,46 +201,62 @@ function calculatePosition(operation) {
179
201
  const width = 55;
180
202
  const height = 55;
181
203
  const margin = 10;
182
- if (!isLeftHanded) {
204
+ let lShift = 0;
205
+ let tShift = 0;
206
+ let rShift = 0;
207
+ let bShift = 0;
208
+ let vMiddle = "50vh";
209
+ if (!isDeviceSmallerThan("sm")) {
210
+ const container = document.getElementById("__hd_svelte_main_content_container");
211
+ if (container) {
212
+ const containerRect = container?.getBoundingClientRect();
213
+ lShift = containerRect.x;
214
+ tShift = containerRect.y;
215
+ bShift = window.innerHeight - containerRect.bottom;
216
+ rShift = window.innerWidth - containerRect.right;
217
+ vMiddle = `${containerRect.x + containerRect.width / 2}px`;
218
+ }
219
+ }
220
+ if (!$leftHandedFAB) {
183
221
  switch (section) {
184
222
  case "M":
185
- result = `right: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
223
+ result = `right: ${rShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
186
224
  break;
187
225
  case "S":
188
- result = `left: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
226
+ result = `left: ${lShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
189
227
  break;
190
228
  case "A":
191
- result = `right: ${margin + col_no * width}px; top: calc(50vh - ${row_no * height}px)`;
229
+ result = `right: ${rShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
192
230
  break;
193
231
  case "C":
194
- result = `left: ${margin + col_no * width}px; top: calc(50vh - ${row_no * height}px)`;
232
+ result = `left: ${lShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
195
233
  break;
196
234
  case "T":
197
- result = `right: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
235
+ result = `right: ${rShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
198
236
  break;
199
237
  case "F":
200
- result = `left: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
238
+ result = `left: ${lShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
201
239
  break;
202
240
  }
203
241
  } else {
204
242
  switch (section) {
205
243
  case "M":
206
- result = `left: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
244
+ result = `left: ${lShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
207
245
  break;
208
246
  case "S":
209
- result = `right: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
247
+ result = `right: ${rShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
210
248
  break;
211
249
  case "A":
212
- result = `left: ${margin + col_no * width}px; top: calc(50vh - ${row_no * height}px)`;
250
+ result = `left: ${lShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
213
251
  break;
214
252
  case "C":
215
- result = `right: ${margin + col_no * width}px; top: calc(50vh - ${row_no * height}px)`;
253
+ result = `right: ${rShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
216
254
  break;
217
255
  case "T":
218
- result = `left: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
256
+ result = `left: ${lShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
219
257
  break;
220
258
  case "F":
221
- result = `right: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
259
+ result = `right: ${rShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
222
260
  break;
223
261
  }
224
262
  }
@@ -227,7 +265,19 @@ function calculatePosition(operation) {
227
265
  function operationVisible(operation) {
228
266
  if (!operation.fab)
229
267
  return false;
230
- return true;
268
+ if ($fabCollapsed) {
269
+ if (operation.fab == "M00")
270
+ return true;
271
+ if (operation.fab == "M10")
272
+ return true;
273
+ return false;
274
+ } else {
275
+ if (operation.disabledFunc)
276
+ return !operation.disabledFunc();
277
+ else if (operation.disabled)
278
+ return false;
279
+ return true;
280
+ }
231
281
  }
232
282
  </script>
233
283
 
@@ -238,15 +288,15 @@ function operationVisible(operation) {
238
288
  {@const position = calculatePosition(operation)}
239
289
  {#if position}
240
290
  <button
241
- class="text-stone-500 bg-stone-200/70 hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300
242
- font-medium rounded-full text-sm text-center
291
+ class=" text-stone-500 bg-stone-200/70 hover:bg-stone-200
292
+ focus:outline-none font-medium rounded-full text-sm text-center
293
+ dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
294
+ focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800
243
295
  w-[30px] h-[30px]
244
- fixed m-0
245
- dark:text-stone-500
246
- dark:bg-stone-700/80 dark:hover:bg-blue-700 dark:focus:ring-blue-800
296
+ fixed m-0
247
297
  flex items-center justify-center
248
298
  disable-dbl-tap-zoom
249
- cursor-pointer z-40"
299
+ cursor-pointer z-20"
250
300
  style={position}
251
301
  on:click|stopPropagation={(e) => {on_click(e, operation)}}
252
302
  on:mousedown={mousedown} >
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ mainPageCoords?: undefined;
4
5
  activateMainOperation?: (() => void) | undefined;
5
6
  };
6
7
  events: {
@@ -2,6 +2,7 @@
2
2
  import { isDeviceSmallerThan } from "../utils";
3
3
  import { pushToolsActionsOperations, popToolsActionsOperations } from "../stores";
4
4
  import { FaTimes } from "svelte-icons/fa";
5
+ import Icon from "./icon.svelte";
5
6
  let x;
6
7
  let y;
7
8
  let visible = false;
@@ -10,6 +11,7 @@ let props = {};
10
11
  let around_rect;
11
12
  let rootElement;
12
13
  let internalElement;
14
+ let closeButtonPos = "";
13
15
  export async function show(around, _toolbar, _props = {}) {
14
16
  if (around instanceof DOMRect) {
15
17
  x = around.left;
@@ -22,7 +24,7 @@ export async function show(around, _toolbar, _props = {}) {
22
24
  }
23
25
  const was_visible = visible;
24
26
  if (!was_visible && toolbar == _toolbar && internalElement && internalElement.reload) {
25
- internalElement.reload();
27
+ internalElement.reload(_props);
26
28
  }
27
29
  visible = true;
28
30
  toolbar = _toolbar;
@@ -34,7 +36,7 @@ export async function show(around, _toolbar, _props = {}) {
34
36
  props.onSizeChanged = () => onSizeChanged();
35
37
  hide_window_indicator = 0;
36
38
  window.addEventListener("click", on_before_window_click, true);
37
- if (isDeviceSmallerThan("sm")) {
39
+ if (false) {
38
40
  pushToolsActionsOperations({
39
41
  opver: 1,
40
42
  operations: [
@@ -63,7 +65,7 @@ export function isVisible() {
63
65
  return visible;
64
66
  }
65
67
  export function hide() {
66
- if (visible)
68
+ if (false)
67
69
  popToolsActionsOperations();
68
70
  visible = false;
69
71
  cssPosition = calculatePosition(x, y, around_rect, false, false);
@@ -124,6 +126,7 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
124
126
  y2 = screenRect.bottom - maxHeight - margin;
125
127
  result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
126
128
  }
129
+ closeButtonPos = `right: ${margin}px; top: calc(${y2}px - 1.75rem)`;
127
130
  } else {
128
131
  let myRect = null;
129
132
  if (!fresh) {
@@ -144,15 +147,28 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
144
147
  y2 = screenRect.top;
145
148
  }
146
149
  result = `left:${x2}px; top:${y2}px; width: max-content; height:max-content; display: block`;
150
+ closeButtonPos = ``;
147
151
  }
148
152
  return result;
149
153
  }
150
154
  </script>
151
155
 
152
156
  <div id="__hd_svelte_floating_container"
153
- class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black z-30 fixed "
157
+ class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black z-40 fixed "
154
158
  style={cssPosition}
155
159
  bind:this={rootElement}>
160
+ {#if closeButtonPos}
161
+ <button class=" fixed w-6 h-6 flex items-center justify-center
162
+ text-stone-500 bg-stone-200/70 hover:bg-stone-200
163
+ focus:outline-none font-medium rounded-full text-sm text-center
164
+ dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
165
+ focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800"
166
+ style={closeButtonPos}
167
+ on:click={ hide }>
168
+ <Icon component={FaTimes} s="md"/>
169
+ </button>
170
+ {/if}
171
+
156
172
  <svelte:component this={toolbar} {...props} bind:this={internalElement} />
157
173
  </div>
158
174
 
@@ -16,4 +16,7 @@ definition.element_key = key;
16
16
  definition.element_name = name;
17
17
  definition.element_avatar = avatar;
18
18
  definition.element_icon = icon;
19
+ export function updateObjects(objects2) {
20
+ definition.collection = objects2;
21
+ }
19
22
  </script>
@@ -9,6 +9,7 @@ declare const __propDef: {
9
9
  name?: string | undefined;
10
10
  avatar?: string | undefined;
11
11
  icon?: string | undefined;
12
+ updateObjects?: ((objects: object[]) => void) | undefined;
12
13
  };
13
14
  events: {
14
15
  [evt: string]: CustomEvent<any>;
@@ -19,5 +20,6 @@ export type ComboProps = typeof __propDef.props;
19
20
  export type ComboEvents = typeof __propDef.events;
20
21
  export type ComboSlots = typeof __propDef.slots;
21
22
  export default class Combo extends SvelteComponentTyped<ComboProps, ComboEvents, ComboSlots> {
23
+ get updateObjects(): (objects: object[]) => void;
22
24
  }
23
25
  export {};
@@ -6,6 +6,7 @@ import { rCombo_definition, rCombo_item, cached_sources } from "./combo";
6
6
  import { FaChevronDown, FaTimes } from "svelte-icons/fa";
7
7
  import Icon from "../icon.svelte";
8
8
  import { reef } from "@humandialog/auth.svelte/dist/index.js";
9
+ import { showMenu } from "../menu.js";
9
10
  export let label = "";
10
11
  export let self = null;
11
12
  export let a = "";
@@ -140,13 +141,19 @@ afterUpdate(() => {
140
141
  if (is_dropdown_open && textbox && document.activeElement != textbox)
141
142
  textbox.focus();
142
143
  });
144
+ let closeButtonPos = "";
145
+ let dropdownElement;
143
146
  function dropdown_action(node) {
144
- if (is_dropdown_open)
145
- dropdown_height = node.getBoundingClientRect().height;
147
+ if (is_dropdown_open) {
148
+ const rect = node.getBoundingClientRect();
149
+ dropdown_height = rect.height;
150
+ }
146
151
  return {
147
152
  update() {
148
- if (is_dropdown_open)
149
- dropdown_height = node.getBoundingClientRect().height;
153
+ if (is_dropdown_open) {
154
+ const rect = node.getBoundingClientRect();
155
+ dropdown_height = rect.height;
156
+ }
150
157
  },
151
158
  destroy() {
152
159
  }
@@ -174,58 +181,7 @@ export function show(event, hide_callback) {
174
181
  client_rect.y = 0;
175
182
  client_rect.width = window.innerWidth;
176
183
  client_rect.height = window.innerHeight;
177
- let rect;
178
- if (is_compact)
179
- rect = textbox.getBoundingClientRect();
180
- else
181
- rect = combo.getBoundingClientRect();
182
- let top_space = rect.y;
183
- let bottom_space = client_rect.height - (rect.y + rect.height);
184
- let palette_max_height_px = 500;
185
- let palette_width_px = rect.width;
186
- if (palette_width_px < 120)
187
- palette_width_px = 120;
188
- let preferred_palette_height = dropdown_height > 0 ? dropdown_height : palette_max_height_px;
189
- let preferred_palette_width = palette_width_px;
190
- let x = 0, y = 0;
191
- let show_above = false;
192
- let show_fullscreen = false;
193
- if (client_rect.width < preferred_palette_width)
194
- show_fullscreen = true;
195
- else if (rect.x + preferred_palette_width > client_rect.width)
196
- x = client_rect.width - preferred_palette_width;
197
- else
198
- x = rect.x;
199
- if (client_rect.height < preferred_palette_height)
200
- show_fullscreen = true;
201
- else if (bottom_space >= preferred_palette_height)
202
- y = rect.y + rect.height;
203
- else if (top_space >= preferred_palette_height) {
204
- y = rect.y;
205
- show_above = true;
206
- } else
207
- y = rect.y + rect.height;
208
- if (isDeviceSmallerThan("sm")) {
209
- let screenRect = new DOMRect();
210
- screenRect.x = 0;
211
- screenRect.y = 0;
212
- screenRect.width = window.innerWidth;
213
- screenRect.height = window.innerHeight;
214
- const margin = 5;
215
- const maxHeight = screenRect.height / 2 - margin;
216
- const width = screenRect.width - 2 * margin;
217
- x = margin;
218
- y = screenRect.bottom - margin;
219
- dropdown_position = `position: fixed; left: ${x}px; top: ${y}px; transform: translate(0, -100%); width: ${width}px; max-height: ${maxHeight}px; display: block`;
220
- } else if (show_fullscreen) {
221
- dropdown_position = `position: fixed; left: 0px; top: 0px; width: ${client_rect.width}px; height: ${client_rect.height}px;`;
222
- } else {
223
- dropdown_position = `min-width: ${palette_width_px}px; max-height:${palette_max_height_px}px; position: fixed; left:${x}px; top:${y}px;`;
224
- if (show_above)
225
- dropdown_position += " transform: translate(0, -100%);";
226
- if (!is_compact)
227
- dropdown_position += `width: ${preferred_palette_width}px`;
228
- }
184
+ openDropdownAsMenu();
229
185
  is_dropdown_open = true;
230
186
  if (filtered) {
231
187
  if (!textbox)
@@ -243,7 +199,7 @@ export function show(event, hide_callback) {
243
199
  subtree: true
244
200
  });
245
201
  }
246
- if (isDeviceSmallerThan("sm")) {
202
+ if (false) {
247
203
  pushToolsActionsOperations({
248
204
  opver: 1,
249
205
  operations: [
@@ -264,13 +220,37 @@ export function show(event, hide_callback) {
264
220
  });
265
221
  }
266
222
  }
223
+ function openDropdownAsMenu() {
224
+ let rect;
225
+ if (is_compact)
226
+ rect = textbox.getBoundingClientRect();
227
+ else
228
+ rect = combo.getBoundingClientRect();
229
+ let operations = [];
230
+ if (hasNone)
231
+ operations.push({
232
+ caption: "<none>",
233
+ action: (f) => on_choose(null)
234
+ });
235
+ if (definition && definition.collection)
236
+ source_fetched(definition.collection);
237
+ const _filtered_source = filtered_source ? filtered_source : definition.source;
238
+ _filtered_source.forEach((i) => {
239
+ operations.push({
240
+ caption: i.Name ?? i.Key,
241
+ icon: i.Icon ?? void 0,
242
+ action: (f) => on_choose(i)
243
+ });
244
+ });
245
+ console.log("operations", operations);
246
+ showMenu(rect, operations);
247
+ }
267
248
  export function hide() {
268
249
  if (!is_dropdown_open)
269
250
  return;
270
251
  if (mutation_observer)
271
252
  mutation_observer.disconnect();
272
253
  is_dropdown_open = false;
273
- popToolsActionsOperations();
274
254
  dropdown_position = "display: none;";
275
255
  combo_text = get_combo_text();
276
256
  if (!!textbox)
@@ -464,7 +444,7 @@ function on_input_change() {
464
444
  if (!is_dropdown_open)
465
445
  return;
466
446
  filtered_source = get_filtered_source();
467
- highlighted_option = filtered_source.length > 0 ? filtered_source[0] : null;
447
+ openDropdownAsMenu();
468
448
  }
469
449
  let new_item_option;
470
450
  function get_filtered_source() {
@@ -630,13 +610,13 @@ function on_focus_out(e) {
630
610
  {#if true || !is_dropdown_open}
631
611
  {#if icon && sel_item}
632
612
  {#if sel_item.Color}
633
- <Icon size={5} circle={true} color={sel_item.Color}/>
613
+ <Icon s="xl" circle={true} color={sel_item.Color}/>
634
614
  {:else if sel_item.Icon}
635
- <Icon size={4} component={sel_item.Icon}/>
615
+ <Icon s="md" component={sel_item.Icon}/>
636
616
  {:else if sel_item.Icon == null}
637
617
  <div class="w-4 h-4"></div>
638
618
  {:else}
639
- <Icon size={5} circle={true} symbol={sel_item.Avatar} label={sel_item.Name}/>
619
+ <Icon s="xl" circle={true} symbol={sel_item.Avatar} label={sel_item.Name}/>
640
620
  {/if}
641
621
  {/if}
642
622
  {/if}
@@ -664,71 +644,91 @@ function on_focus_out(e) {
664
644
 
665
645
  </div>
666
646
 
667
- <div hidden={!is_dropdown_open}
668
- class="not-prose {cs} bg-white dark:bg-stone-800 text-stone-500 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-700 shadow-md overflow-y-auto cursor-pointer z-30"
669
- style={dropdown_position}
670
- use:dropdown_action>
671
- <ul class="py-1">
647
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
648
+ <!--div hidden={!is_dropdown_open}>
649
+ {#if closeButtonPos}
650
+ {#key closeButtonPos}
651
+ <button class=" fixed w-6 h-6 flex items-center justify-center
652
+ text-stone-500 bg-stone-200/70 hover:bg-stone-200
653
+ focus:outline-none font-medium rounded-full text-sm text-center
654
+ dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
655
+ focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800"
656
+ style={closeButtonPos}
657
+ on:click={ hide }>
658
+ <Icon component={FaTimes} s="md"/>
659
+ </button>
660
+ {/key}
661
+ {/if}
672
662
 
673
- {#if definition.source && definition.source.length}
674
- {#if hasNone}
675
- <!-- svelte-ignore a11y-click-events-have-key-events -->
676
- <li class="rounded flex flex-row items-center {font_size}
677
- space-x-10 px-4 py-2 ml-12 sm:ml-0"
678
- class:bg-stone-100={highlighted_option == null}
679
- class:dark:bg-stone-700={highlighted_option == null}
680
- class:dark:hover:bg-stone-700={highlighted_option == null}
681
- on:mousemove={() => on_mouse_move(null)}
682
- on:click|preventDefault|stopPropagation={async () => await on_choose(null)}
683
- tabindex="-1">
663
+ <div class="not-prose {cs} bg-white dark:bg-stone-800 text-stone-500 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-700 shadow-md overflow-y-auto cursor-pointer z-40
664
+ fixed"
665
+ style={dropdown_position}
666
+ bind:this={dropdownElement}
667
+ use:dropdown_action>
668
+
669
+
684
670
 
685
- <h4 class="ml-2">
686
- &lt;none&gt;
687
- </h4>
688
- </li>
689
- {/if}
671
+ <ul class="py-1">
690
672
 
691
- {@const _filtered_source = filtered_source ? filtered_source : definition.source}
692
- {#if _filtered_source.length > 0}
693
- {#each _filtered_source as item (item.Key)}
694
- {@const active=(highlighted_option == item) ? 'bg-stone-400/30 dark:bg-stone-400/30' : ''}
695
- <!-- svelte-ignore a11y-click-events-have-key-events -->
673
+ {#if definition.source && definition.source.length}
674
+ {#if hasNone}
675
+
696
676
  <li class="rounded flex flex-row items-center {font_size}
697
- space-x-10 px-4 py-2 pl-12 sm:pl-2 {active}"
698
- on:mousemove={() => on_mouse_move(item)}
699
- on:click|preventDefault|stopPropagation={async () => await on_choose(item)}
677
+ space-x-10 px-4 py-2 ml-12 sm:ml-0"
678
+ class:bg-stone-100={highlighted_option == null}
679
+ class:dark:bg-stone-700={highlighted_option == null}
680
+ class:dark:hover:bg-stone-700={highlighted_option == null}
681
+ on:mousemove={() => on_mouse_move(null)}
682
+ on:click|preventDefault|stopPropagation={async () => await on_choose(null)}
700
683
  tabindex="-1">
701
684
 
702
- {#if icon}
703
- {#if item.Color}
704
- <Icon size={4} circle={true} color={item.Color}/>
705
- {:else if item.Avatar}
706
- <Icon size={4} circle={true} symbol={item.Avatar}/>
707
- {:else if item.Icon}
708
- <Icon size={4} component={item.Icon}/>
709
- {:else if item.Icon == null}
710
- <div class="w-4 h-4"></div>
711
- {:else if item.Name}
712
- <Icon size={4} circle={true} label={item.Name}/>
713
- {:else}
714
- <Icon size={4} circle={true}/>
715
- {/if}
716
- {/if}
717
- <h4 class="ml-2">
718
- {#if item.Name}
719
- {item.Name}
720
- {:else if item.Key}
721
- {item.Key}
722
- {/if}
685
+ <h4 class="ml-2 text-stone-400 dark:text-stone-500">
686
+ &lt;none&gt;
723
687
  </h4>
724
688
  </li>
725
- {/each}
726
- {:else}
727
- <li class="rounded p-2">No options</li>
689
+ {/if}
690
+
691
+ {@const _filtered_source = filtered_source ? filtered_source : definition.source}
692
+ {#if _filtered_source.length > 0}
693
+ {#each _filtered_source as item (item.Key)}
694
+ {@const active=(highlighted_option == item) ? 'bg-stone-400/30 dark:bg-stone-400/30' : ''}
695
+ <li class="rounded flex flex-row items-center {font_size}
696
+ space-x-10 px-4 py-2 pl-12 sm:pl-2 {active}"
697
+ on:mousemove={() => on_mouse_move(item)}
698
+ on:click|preventDefault|stopPropagation={async () => await on_choose(item)}
699
+ tabindex="-1">
700
+
701
+ {#if icon}
702
+ {#if item.Color}
703
+ <Icon s="md" circle={true} color={item.Color}/>
704
+ {:else if item.Avatar}
705
+ <Icon s="md" circle={true} symbol={item.Avatar}/>
706
+ {:else if item.Icon}
707
+ <Icon s="md" component={item.Icon}/>
708
+ {:else if item.Icon == null}
709
+ <div class="w-4 h-4"></div>
710
+ {:else if item.Name}
711
+ <Icon s="md" circle={true} label={item.Name}/>
712
+ {:else}
713
+ <Icon s="md" circle={true}/>
714
+ {/if}
715
+ {/if}
716
+ <h4 class="ml-2">
717
+ {#if item.Name}
718
+ {item.Name}
719
+ {:else if item.Key}
720
+ {item.Key}
721
+ {/if}
722
+ </h4>
723
+ </li>
724
+ {/each}
725
+ {:else}
726
+ <li class="rounded p-2">No options</li>
727
+ {/if}
728
728
  {/if}
729
- {/if}
730
- </ul>
731
- </div>
729
+ </ul>
730
+ </div>
731
+ </div-->
732
732
  </div>
733
733
  {/if}
734
734