@humandialog/forms.svelte 1.3.17 → 1.4.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.
Files changed (36) hide show
  1. package/components/Fab.svelte +77 -46
  2. package/components/combo/combo.svelte +18 -15
  3. package/components/combo/combo.svelte.d.ts +1 -0
  4. package/components/contextmenu.svelte +25 -6
  5. package/components/date.svelte +10 -4
  6. package/components/date.svelte.d.ts +1 -0
  7. package/components/date_utils.d.ts +1 -0
  8. package/components/date_utils.js +10 -0
  9. package/components/delayed.spinner.svelte +1 -2
  10. package/components/document/editor.svelte +419 -46
  11. package/components/document/editor.svelte.d.ts +115 -0
  12. package/components/document/internal/palette.svelte +20 -0
  13. package/components/list/List.d.ts +6 -0
  14. package/components/list/List.js +6 -0
  15. package/components/list/internal/list.element.props.svelte +23 -8
  16. package/components/list/internal/list.element.svelte +17 -5
  17. package/components/list/list.combo.svelte +6 -0
  18. package/components/list/list.combo.svelte.d.ts +3 -0
  19. package/components/list/list.date.svelte +8 -0
  20. package/components/list/list.date.svelte.d.ts +4 -0
  21. package/components/list/list.static.svelte +6 -0
  22. package/components/list/list.static.svelte.d.ts +3 -0
  23. package/components/list/list.tags.svelte +32 -0
  24. package/components/list/list.tags.svelte.d.ts +24 -0
  25. package/components/sidebar/sidebar.item.svelte +12 -8
  26. package/components/tags.svelte +15 -7
  27. package/components/tags.svelte.d.ts +2 -0
  28. package/desk.svelte +5 -5
  29. package/index.d.ts +7 -2
  30. package/index.js +7 -2
  31. package/operations.svelte +61 -12
  32. package/package.json +4 -2
  33. package/stores.d.ts +3 -0
  34. package/stores.js +25 -2
  35. package/tenant.members.svelte +61 -59
  36. package/tenant.members.svelte.d.ts +2 -0
@@ -1,7 +1,7 @@
1
1
  <script>import { each } from "svelte/internal";
2
2
  import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations } from "../stores.js";
3
3
  import { showFloatingToolbar, showMenu, showGridMenu } from "./menu.js";
4
- import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle } from "svelte-icons/fa/";
4
+ import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV } from "svelte-icons/fa/";
5
5
  $:
6
6
  setupCurrentContextOperations($pageToolbarOperations, $contextToolbarOperations, $toolsActionsOperations);
7
7
  let operations = [];
@@ -13,49 +13,82 @@ let vToolboxExpanded = false;
13
13
  let hToolboxExpanded = false;
14
14
  let isDirectPositioningMode = false;
15
15
  function setupCurrentContextOperations(...args) {
16
+ let opVer = 0;
16
17
  isDirectPositioningMode = false;
17
18
  if ($toolsActionsOperations && Array.isArray($toolsActionsOperations) && toolsActionsOperations.length > 0) {
18
19
  operations = $toolsActionsOperations;
19
20
  } else if ($toolsActionsOperations && $toolsActionsOperations.operations && $toolsActionsOperations.operations.length > 0) {
20
21
  operations = $toolsActionsOperations.operations;
21
- if ($toolsActionsOperations.opver && $toolsActionsOperations.opver == 1)
22
+ opVer = $toolsActionsOperations.opver ?? 0;
23
+ if (opVer > 0)
22
24
  isDirectPositioningMode = true;
23
25
  } else if ($contextToolbarOperations && Array.isArray($contextToolbarOperations) && $contextToolbarOperations.length > 0) {
24
26
  operations = $contextToolbarOperations;
25
27
  } else if ($contextToolbarOperations && $contextToolbarOperations.operations && $contextToolbarOperations.operations.length > 0) {
26
28
  operations = $contextToolbarOperations.operations;
27
- if ($contextToolbarOperations.opver && $contextToolbarOperations.opver == 1)
29
+ opVer = $contextToolbarOperations.opver ?? 0;
30
+ if (opVer > 0)
28
31
  isDirectPositioningMode = true;
29
32
  } else {
30
33
  if (Array.isArray($pageToolbarOperations))
31
34
  operations = $pageToolbarOperations;
32
35
  else {
33
36
  operations = $pageToolbarOperations.operations;
34
- if ($pageToolbarOperations.opver && $pageToolbarOperations.opver == 1)
37
+ opVer = $pageToolbarOperations.opver ?? 0;
38
+ if (opVer > 0)
35
39
  isDirectPositioningMode = true;
36
40
  }
37
41
  }
38
- if (isDirectPositioningMode)
39
- return;
40
- if (operations.length > 0)
41
- mainOperation = operations[0];
42
- else
43
- mainOperation = null;
44
- secondaryOperation = null;
45
- toolboxOperations = [];
46
- if (operations.length > 1) {
47
- const operation = operations[1];
48
- if (!operation.separator) {
49
- if (!operation.toolbox)
50
- secondaryOperation = operation;
51
- else
52
- toolboxOperations = operation.toolbox;
42
+ if (opVer == 1) {
43
+ let flatOperations = [];
44
+ operations.forEach((group) => {
45
+ flatOperations = [...flatOperations, ...group.operations];
46
+ });
47
+ operations = flatOperations;
48
+ } else if (opVer == 2) {
49
+ let flatOperations = [];
50
+ operations.forEach((group) => {
51
+ flatOperations.push({
52
+ caption: group.caption,
53
+ separator: true
54
+ });
55
+ flatOperations = [...flatOperations, ...group.operations];
56
+ });
57
+ const realOps = flatOperations.filter((el) => !!el.separator == false);
58
+ if (realOps.length > 1) {
59
+ mainOperation = {
60
+ icon: FaEllipsisV,
61
+ menu: flatOperations,
62
+ fab: "M00"
63
+ };
64
+ operations = [mainOperation];
65
+ } else if (realOps.length == 1) {
66
+ mainOperation = realOps[0];
67
+ mainOperation["fab"] = "M00";
68
+ operations = [mainOperation];
69
+ } else
70
+ operations = [];
71
+ } else {
72
+ if (operations.length > 0)
73
+ mainOperation = operations[0];
74
+ else
75
+ mainOperation = null;
76
+ secondaryOperation = null;
77
+ toolboxOperations = [];
78
+ if (operations.length > 1) {
79
+ const operation = operations[1];
80
+ if (!operation.separator) {
81
+ if (!operation.toolbox)
82
+ secondaryOperation = operation;
83
+ else
84
+ toolboxOperations = operation.toolbox;
85
+ }
53
86
  }
87
+ if (operations.length == 3 && secondaryOperation != null || operations.length > 3 || toolboxOperations.length > 0)
88
+ isExpandable = true;
89
+ else
90
+ isExpandable = false;
54
91
  }
55
- if (operations.length == 3 && secondaryOperation != null || operations.length > 3 || toolboxOperations.length > 0)
56
- isExpandable = true;
57
- else
58
- isExpandable = false;
59
92
  }
60
93
  export function activateMainOperation() {
61
94
  const mainOperationButton = document.getElementById("__hd_fab_mainOperation");
@@ -69,6 +102,8 @@ function on_click(e, operation) {
69
102
  let owner = e.target;
70
103
  while (owner && (owner.tagName != "BUTTON" && owner.tagName != "LI"))
71
104
  owner = owner.parentElement;
105
+ if (operation.preAction)
106
+ operation.preAction(owner);
72
107
  if (operation.action) {
73
108
  operation.action(owner);
74
109
  }
@@ -178,29 +213,25 @@ function operationVisible(operation) {
178
213
 
179
214
  {#if isDirectPositioningMode}
180
215
  {#if operations && operations.length > 0}
181
- {#each operations as group}
182
- {#if group.operations && group.operations.length > 0}
183
- {#each group.operations as operation}
184
- {#if operationVisible(operation)}
185
- {@const position = calculatePosition(operation)}
186
- {#if position}
187
- <button
188
- class="text-white bg-blue-700/70 hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300
189
- font-medium rounded-full text-sm text-center shadow-md
190
- w-[35px] h-[35px]
191
- fixed m-0
192
- dark:bg-blue-600/50 dark:hover:bg-blue-700 dark:focus:ring-blue-800
193
- flex items-center justify-center
194
- disable-dbl-tap-zoom
195
- cursor-pointer z-40"
196
- style={position}
197
- on:click|stopPropagation={(e) => {on_click(e, operation)}}
198
- on:mousedown={mousedown} >
199
- <div class="w-5 h-5"><svelte:component this={operation.icon}/></div>
200
- </button>
201
- {/if}
202
- {/if}
203
- {/each}
216
+ {#each operations as operation}
217
+ {#if operationVisible(operation)}
218
+ {@const position = calculatePosition(operation)}
219
+ {#if position}
220
+ <button
221
+ class="text-white bg-blue-700/70 hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300
222
+ font-medium rounded-full text-sm text-center shadow-md
223
+ w-[35px] h-[35px]
224
+ fixed m-0
225
+ dark:bg-blue-600/50 dark:hover:bg-blue-700 dark:focus:ring-blue-800
226
+ flex items-center justify-center
227
+ disable-dbl-tap-zoom
228
+ cursor-pointer z-40"
229
+ style={position}
230
+ on:click|stopPropagation={(e) => {on_click(e, operation)}}
231
+ on:mousedown={mousedown} >
232
+ <div class="w-5 h-5"><svelte:component this={operation.icon}/></div>
233
+ </button>
234
+ {/if}
204
235
  {/if}
205
236
  {/each}
206
237
  {/if}
@@ -27,6 +27,7 @@ export let cached = false;
27
27
  export let filtered = false;
28
28
  export let pushChangesImmediately = true;
29
29
  export let hasNone = isAssociation;
30
+ export let readOnly = false;
30
31
  let userClass = $$restProps.class ?? "";
31
32
  let is_compact = getContext("rIs-table-component") || compact;
32
33
  if (!definition) {
@@ -92,7 +93,7 @@ else
92
93
  dark:border-stone-600 dark:placeholder-stone-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500`;
93
94
  let cs = c ? parseWidthDirective(c) : "col-span-1";
94
95
  let ctx = context ? context : getContext("ctx");
95
- let can_be_activated = true;
96
+ let can_be_activated = !readOnly;
96
97
  let last_tick = -1;
97
98
  $:
98
99
  setup($data_tick_store, $contextItemsStore);
@@ -110,7 +111,9 @@ function setup(...args) {
110
111
  }
111
112
  }
112
113
  tick_request_internal = tick_request_internal + 1;
113
- if (is_compact) {
114
+ if (readOnly)
115
+ can_be_activated = false;
116
+ else if (is_compact) {
114
117
  can_be_activated = false;
115
118
  let contexts = inContext.split(" ");
116
119
  contexts.forEach((ctx2) => {
@@ -670,7 +673,8 @@ function on_focus_out(e) {
670
673
  {#if definition.source && definition.source.length}
671
674
  {#if hasNone}
672
675
  <!-- svelte-ignore a11y-click-events-have-key-events -->
673
- <li class="rounded p-2 flex flex-row items-center {font_size}"
676
+ <li class="rounded flex flex-row items-center {font_size}
677
+ space-x-10 px-4 py-2 ml-12 sm:ml-0"
674
678
  class:bg-stone-100={highlighted_option == null}
675
679
  class:dark:bg-stone-700={highlighted_option == null}
676
680
  class:dark:hover:bg-stone-700={highlighted_option == null}
@@ -678,46 +682,45 @@ function on_focus_out(e) {
678
682
  on:click|preventDefault|stopPropagation={async () => await on_choose(null)}
679
683
  tabindex="-1">
680
684
 
681
- <div class="ml-2">
685
+ <h4 class="ml-2">
682
686
  &lt;none&gt;
683
- </div>
687
+ </h4>
684
688
  </li>
685
689
  {/if}
686
690
 
687
691
  {@const _filtered_source = filtered_source ? filtered_source : definition.source}
688
692
  {#if _filtered_source.length > 0}
689
693
  {#each _filtered_source as item (item.Key)}
694
+ {@const active=(highlighted_option == item) ? 'bg-stone-400/30 dark:bg-stone-400/30' : ''}
690
695
  <!-- svelte-ignore a11y-click-events-have-key-events -->
691
- <li class="rounded p-2 flex flex-row items-center {font_size}"
692
- class:bg-stone-100={highlighted_option == item}
693
- class:dark:bg-stone-700={highlighted_option == item}
694
- class:dark:hover:bg-stone-700={highlighted_option == item}
696
+ <li class="rounded flex flex-row items-center {font_size}
697
+ space-x-10 px-4 py-2 pl-12 sm:pl-2 {active}"
695
698
  on:mousemove={() => on_mouse_move(item)}
696
699
  on:click|preventDefault|stopPropagation={async () => await on_choose(item)}
697
700
  tabindex="-1">
698
701
 
699
702
  {#if icon}
700
703
  {#if item.Color}
701
- <Icon size={5} circle={true} color={item.Color}/>
704
+ <Icon size={4} circle={true} color={item.Color}/>
702
705
  {:else if item.Avatar}
703
- <Icon size={5} circle={true} symbol={item.Avatar}/>
706
+ <Icon size={4} circle={true} symbol={item.Avatar}/>
704
707
  {:else if item.Icon}
705
708
  <Icon size={4} component={item.Icon}/>
706
709
  {:else if item.Icon == null}
707
710
  <div class="w-4 h-4"></div>
708
711
  {:else if item.Name}
709
- <Icon size={5} circle={true} label={item.Name}/>
712
+ <Icon size={4} circle={true} label={item.Name}/>
710
713
  {:else}
711
- <Icon size={5} circle={true}/>
714
+ <Icon size={4} circle={true}/>
712
715
  {/if}
713
716
  {/if}
714
- <div class="ml-2">
717
+ <h4 class="ml-2">
715
718
  {#if item.Name}
716
719
  {item.Name}
717
720
  {:else if item.Key}
718
721
  {item.Key}
719
722
  {/if}
720
- </div>
723
+ </h4>
721
724
  </li>
722
725
  {/each}
723
726
  {:else}
@@ -24,6 +24,7 @@ declare const __propDef: {
24
24
  filtered?: boolean | undefined;
25
25
  pushChangesImmediately?: boolean | undefined;
26
26
  hasNone?: boolean | undefined;
27
+ readOnly?: boolean | undefined;
27
28
  show?: ((event: any, hide_callback: any) => void) | undefined;
28
29
  hide?: (() => void) | undefined;
29
30
  };
@@ -274,10 +274,23 @@ function hide_submenu() {
274
274
  function mousedown(e) {
275
275
  e.preventDefault();
276
276
  }
277
+ function calculateBackground(is_highlighted, active) {
278
+ if (is_highlighted) {
279
+ if (active)
280
+ return "bg-stone-400/40 dark:bg-stone-400/40";
281
+ else
282
+ return "bg-stone-400/30 dark:bg-stone-400/30";
283
+ } else {
284
+ if (active)
285
+ return "bg-stone-400/20 dark:bg-stone-400/20";
286
+ else
287
+ return "";
288
+ }
289
+ }
277
290
  </script>
278
291
 
279
292
  <div id="__hd_svelte_contextmenu"
280
- class=" bg-white dark:bg-stone-700 text-stone-600 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-900 shadow-md
293
+ class=" 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
281
294
  z-30 fixed min-w-[{min_width_px}px] w-max overflow-y-auto"
282
295
  style={css_position}
283
296
  bind:this={menu_root}>
@@ -285,7 +298,9 @@ function mousedown(e) {
285
298
  {#each operations as operation, index}
286
299
  {@const is_separator = operation.separator}
287
300
  {#if is_separator}
288
- <hr class="my-1 mx-0 border-1 dark:border-stone-900">
301
+ {#if index>0 && index < operations.length-1}
302
+ <hr class="my-1 mx-4 border-1 border-stone-300 dark:border-stone-700">
303
+ {/if}
289
304
  {:else}
290
305
  {@const mobile = isDeviceSmallerThan("sm")}
291
306
  {@const icon_placeholder_without_desc = mobile ? 12 : 10}
@@ -296,10 +311,10 @@ function mousedown(e) {
296
311
  {@const isBottom = index == operations.length-1}
297
312
  {@const isFocused = index == focused_index}
298
313
  {@const clipFocusedBorder = isFocused ? (isTop ? 'rounded-t-lg' : (isBottom ? 'rounded-b-lg' : '')) : ''}
299
- {@const active = ((!mobile) && isFocused) ? `bg-stone-200 dark:bg-stone-600 ${clipFocusedBorder}` : ''}
314
+ {@const active = calculateBackground(isFocused, false)}
300
315
  {@const has_submenu = operation.menu !== undefined && operation.menu.length > 0}
301
316
 
302
- <button class="font-medium m-0 py-2 pr-4 text-lg sm:text-sm w-full text-left flex flex-row cursor-context-menu {active} focus:outline-none"
317
+ <button class="block w-full pr-4 text-left flex flex-row cursor-context-menu {active} focus:outline-none"
303
318
  id={menu_item_id}
304
319
  bind:this={menu_items[index]}
305
320
  on:click|stopPropagation={(e) => { execute_action(operation, index) } }
@@ -309,18 +324,22 @@ function mousedown(e) {
309
324
  disabled={operation.disabled}
310
325
  class:opacity-60={operation.disabled}>
311
326
 
312
- <div class="flex items-center justify-center mt-1 sm:mt-0.5" style:width={`${icon_placeholder_size*0.25}rem`}>
327
+ <div class="flex items-center justify-center space-x-10 px-4 py-2 ml-12 sm:ml-0" >
313
328
  {#if operation.icon}
314
329
  {@const cc = mobile ? 7 : 6}
315
330
  {@const icon_size = icon_placeholder_size - cc}
316
331
  <Icon size={icon_size} component={operation.icon}/>
332
+ {:else}
333
+ {@const cc = mobile ? 7 : 6}
334
+ {@const icon_size = icon_placeholder_size - cc}
335
+ <div style="width: {icon_size*0.25}rem; height: {icon_size*0.25}rem;"></div>
317
336
  {/if}
318
337
  </div>
319
338
  <div class="">
320
339
  <p> {operation.caption}</p>
321
340
  {#if operation.description}
322
341
  {@const shortcut_width_px = operation.shortcut ? 80 : 0}
323
- <p class=" text-sm font-normal text-stone-900 dark:text-stone-500 truncate inline-block">
342
+ <p class="truncate inline-block">
324
343
  {operation.description}
325
344
  </p>
326
345
  {/if}
@@ -3,7 +3,7 @@ import { data_tick_store, contextItemsStore, contextTypesStore } from "../stores
3
3
  import { informModification, pushChanges } from "../updates.js";
4
4
  import { parseWidthDirective, isDeviceSmallerThan } from "../utils.js";
5
5
  import FaChevronDown from "svelte-icons/fa/FaChevronDown.svelte";
6
- import { getFormattedStringDate, getNiceStringDate } from "./date_utils.js";
6
+ import { getFormattedStringDate, getNiceStringDate, getNiceStringDateTime } from "./date_utils.js";
7
7
  export let self = null;
8
8
  export let a = "";
9
9
  export let context = "";
@@ -12,6 +12,7 @@ export let date = null;
12
12
  export let onSelect = void 0;
13
13
  export let type = "date";
14
14
  export let changed = void 0;
15
+ export let readOnly = false;
15
16
  export let s = "sm";
16
17
  export let c = "";
17
18
  export let compact = false;
@@ -97,7 +98,7 @@ if (!is_compact) {
97
98
  } else {
98
99
  style = `${font_size}`;
99
100
  }
100
- let can_be_activated = true;
101
+ let can_be_activated = !readOnly;
101
102
  let last_tick = -1;
102
103
  $:
103
104
  setup($data_tick_store, $contextItemsStore);
@@ -124,7 +125,9 @@ function setup(...args) {
124
125
  value = new Date(item[a]);
125
126
  } else
126
127
  value = date;
127
- if (is_compact) {
128
+ if (readOnly)
129
+ can_be_activated = false;
130
+ else if (is_compact) {
128
131
  can_be_activated = false;
129
132
  let contexts = inContext.split(" ");
130
133
  contexts.forEach((ctx2) => {
@@ -134,7 +137,10 @@ function setup(...args) {
134
137
  } else
135
138
  can_be_activated = true;
136
139
  rValue = getFormattedStringDate(value, type);
137
- pretty_value = getNiceStringDate(value);
140
+ if (type == "datetime-local")
141
+ pretty_value = getNiceStringDateTime(value);
142
+ else
143
+ pretty_value = getNiceStringDate(value);
138
144
  }
139
145
  async function on_changed() {
140
146
  if (!rValue)
@@ -10,6 +10,7 @@ declare const __propDef: {
10
10
  onSelect?: undefined;
11
11
  type?: string | undefined;
12
12
  changed?: undefined;
13
+ readOnly?: boolean | undefined;
13
14
  s?: string | undefined;
14
15
  c?: string | undefined;
15
16
  compact?: boolean | undefined;
@@ -1,4 +1,5 @@
1
1
  export function getFormattedStringDate(d: any, type?: string): string;
2
+ export function getNiceStringDateTime(d: any): string;
2
3
  export function getNiceStringDate(d: any): string;
3
4
  export function dayName(d: any): "" | "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat";
4
5
  export function monthName(m: any): "" | "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec";
@@ -28,6 +28,16 @@ export function getFormattedStringDate(d, type = "datetime")
28
28
  return `${year}-${month}-${day}`;
29
29
  }
30
30
 
31
+ export function getNiceStringDateTime(d)
32
+ {
33
+ const dt = getNiceStringDate(d);
34
+ const tm = d.toLocaleTimeString(undefined, {
35
+ timeStyle: 'short'
36
+ })
37
+ return `${dt}, ${tm}`
38
+ }
39
+
40
+
31
41
  export function getNiceStringDate(d)
32
42
  {
33
43
  if(!d)
@@ -1,5 +1,4 @@
1
- <script>import { Spinner } from "flowbite-svelte";
2
- import { onMount } from "svelte";
1
+ <script>import { onMount } from "svelte";
3
2
  export let color = "blue";
4
3
  export let size = 8;
5
4
  export let delay = 1e3;