@humandialog/forms.svelte 1.3.14 → 1.3.16

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.
@@ -66,15 +66,12 @@ export function activateMainOperation() {
66
66
  function on_click(e, operation) {
67
67
  if (!operation)
68
68
  return;
69
- if (operation.action) {
70
- let focused_item = null;
71
- if ($contextItemsStore.focused)
72
- focused_item = $contextItemsStore[$contextItemsStore.focused];
73
- operation.action(focused_item);
74
- }
75
69
  let owner = e.target;
76
70
  while (owner && (owner.tagName != "BUTTON" && owner.tagName != "LI"))
77
71
  owner = owner.parentElement;
72
+ if (operation.action) {
73
+ operation.action(owner);
74
+ }
78
75
  if (!owner)
79
76
  return;
80
77
  let rect = owner.getBoundingClientRect();
@@ -1,6 +1,6 @@
1
1
  <script>import { tick, afterUpdate } from "svelte";
2
2
  import { isDeviceSmallerThan } from "../utils";
3
- import { toolsActionsOperations } from "../stores";
3
+ import { pushToolsActionsOperations, popToolsActionsOperations } from "../stores";
4
4
  import { FaTimes } from "svelte-icons/fa";
5
5
  let x;
6
6
  let y;
@@ -35,7 +35,7 @@ export async function show(around, _toolbar, _props = {}) {
35
35
  hide_window_indicator = 0;
36
36
  window.addEventListener("click", on_before_window_click, true);
37
37
  if (isDeviceSmallerThan("sm")) {
38
- $toolsActionsOperations = {
38
+ pushToolsActionsOperations({
39
39
  opver: 1,
40
40
  operations: [
41
41
  {
@@ -52,7 +52,7 @@ export async function show(around, _toolbar, _props = {}) {
52
52
  ]
53
53
  }
54
54
  ]
55
- };
55
+ });
56
56
  }
57
57
  await tick();
58
58
  if (!was_visible)
@@ -63,9 +63,10 @@ export function isVisible() {
63
63
  return visible;
64
64
  }
65
65
  export function hide() {
66
+ if (visible)
67
+ popToolsActionsOperations();
66
68
  visible = false;
67
69
  cssPosition = calculatePosition(x, y, around_rect, false, false);
68
- $toolsActionsOperations = [];
69
70
  window.removeEventListener("click", on_before_window_click, true);
70
71
  rootElement?.removeEventListener("click", on_before_container_click, true);
71
72
  }
@@ -1,4 +1,4 @@
1
- <script>import { data_tick_store, contextItemsStore, contextTypesStore, toolsActionsOperations } from "../../stores.js";
1
+ <script>import { data_tick_store, contextItemsStore, contextTypesStore, pushToolsActionsOperations, popToolsActionsOperations } from "../../stores.js";
2
2
  import { informModification, pushChanges } from "../../updates.js";
3
3
  import { isDeviceSmallerThan, parseWidthDirective, shouldBeComapact } from "../../utils.js";
4
4
  import { afterUpdate, getContext, onMount, setContext } from "svelte";
@@ -171,7 +171,11 @@ export function show(event, hide_callback) {
171
171
  client_rect.y = 0;
172
172
  client_rect.width = window.innerWidth;
173
173
  client_rect.height = window.innerHeight;
174
- let rect = textbox.getBoundingClientRect();
174
+ let rect;
175
+ if (is_compact)
176
+ rect = textbox.getBoundingClientRect();
177
+ else
178
+ rect = combo.getBoundingClientRect();
175
179
  let top_space = rect.y;
176
180
  let bottom_space = client_rect.height - (rect.y + rect.height);
177
181
  let palette_max_height_px = 500;
@@ -216,6 +220,8 @@ export function show(event, hide_callback) {
216
220
  dropdown_position = `min-width: ${palette_width_px}px; max-height:${palette_max_height_px}px; position: fixed; left:${x}px; top:${y}px;`;
217
221
  if (show_above)
218
222
  dropdown_position += " transform: translate(0, -100%);";
223
+ if (!is_compact)
224
+ dropdown_position += `width: ${preferred_palette_width}px`;
219
225
  }
220
226
  is_dropdown_open = true;
221
227
  if (filtered) {
@@ -235,7 +241,7 @@ export function show(event, hide_callback) {
235
241
  });
236
242
  }
237
243
  if (isDeviceSmallerThan("sm")) {
238
- $toolsActionsOperations = {
244
+ pushToolsActionsOperations({
239
245
  opver: 1,
240
246
  operations: [
241
247
  {
@@ -252,14 +258,16 @@ export function show(event, hide_callback) {
252
258
  ]
253
259
  }
254
260
  ]
255
- };
261
+ });
256
262
  }
257
263
  }
258
264
  export function hide() {
265
+ if (!is_dropdown_open)
266
+ return;
259
267
  if (mutation_observer)
260
268
  mutation_observer.disconnect();
261
269
  is_dropdown_open = false;
262
- $toolsActionsOperations = [];
270
+ popToolsActionsOperations();
263
271
  dropdown_position = "display: none;";
264
272
  combo_text = get_combo_text();
265
273
  if (!!textbox)
@@ -643,7 +651,8 @@ function on_focus_out(e) {
643
651
  {combo_text}</span>
644
652
 
645
653
  {#if can_be_activated }
646
- <div class="w-3 h-3 no-print flex-none text-stone-700 dark:text-stone-300 {chevron_mt}">
654
+ <div class="w-3 h-3 no-print flex-none text-stone-700 dark:text-stone-300 {chevron_mt}"
655
+ class:ms-auto={!is_compact}>
647
656
  <FaChevronDown/>
648
657
  </div>
649
658
  {/if}
@@ -1,6 +1,6 @@
1
1
  <script>import { afterUpdate, tick } from "svelte";
2
2
  import Icon from "./icon.svelte";
3
- import { contextItemsStore, toolsActionsOperations } from "../stores";
3
+ import { contextItemsStore, pushToolsActionsOperations, popToolsActionsOperations } from "../stores";
4
4
  import { isDeviceSmallerThan, isOnScreenKeyboardVisible } from "../utils";
5
5
  import { hideWholeContextMenu } from "./menu";
6
6
  import { FaTimes } from "svelte-icons/fa";
@@ -109,7 +109,7 @@ export async function show(around, _operations) {
109
109
  window.addEventListener("click", on_before_window_click, true);
110
110
  }
111
111
  if (isDeviceSmallerThan("sm")) {
112
- $toolsActionsOperations = {
112
+ pushToolsActionsOperations({
113
113
  opver: 1,
114
114
  operations: [
115
115
  {
@@ -126,7 +126,7 @@ export async function show(around, _operations) {
126
126
  ]
127
127
  }
128
128
  ]
129
- };
129
+ });
130
130
  }
131
131
  await tick();
132
132
  css_position = calculatePosition(x, y, around_rect, true, false);
@@ -139,7 +139,8 @@ export function isVisible() {
139
139
  return visible;
140
140
  }
141
141
  export function hide() {
142
- $toolsActionsOperations = [];
142
+ if (visible)
143
+ popToolsActionsOperations();
143
144
  visible = false;
144
145
  css_position = calculatePosition(x, y, around_rect, false, false);
145
146
  window.removeEventListener("click", on_before_window_click, true);
@@ -319,8 +320,9 @@ function mousedown(e) {
319
320
  <p> {operation.caption}</p>
320
321
  {#if operation.description}
321
322
  {@const shortcut_width_px = operation.shortcut ? 80 : 0}
322
- <p class="text-sm font-normal text-stone-900 dark:text-stone-500 truncate inline-block"
323
- style:max-width={`calc(${width_px-shortcut_width_px} - 3rem)`} >{operation.description}</p>
323
+ <p class=" text-sm font-normal text-stone-900 dark:text-stone-500 truncate inline-block">
324
+ {operation.description}
325
+ </p>
324
326
  {/if}
325
327
  </div>
326
328
  {#if has_submenu}
@@ -3,6 +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
7
  export let self = null;
7
8
  export let a = "";
8
9
  export let context = "";
@@ -132,141 +133,8 @@ function setup(...args) {
132
133
  });
133
134
  } else
134
135
  can_be_activated = true;
135
- rValue = get_formatted_date(value);
136
- pretty_value = get_pretty_value(value);
137
- }
138
- function get_pretty_value(d) {
139
- if (!d)
140
- return "";
141
- let month = d.getMonth();
142
- let day = d.getDate();
143
- let year = d.getFullYear();
144
- const now = new Date(Date.now());
145
- let current_month = now.getMonth();
146
- let current_day = now.getDate();
147
- let current_year = now.getFullYear();
148
- let is_far_date = true;
149
- const far_date_threshold = 14 * 24 * 60 * 60 * 1e3;
150
- if (Math.abs(now.getTime() - d.getTime()) < far_date_threshold)
151
- is_far_date = false;
152
- if (year != current_year) {
153
- if (is_far_date)
154
- return `${day} ${month_name(month)} ${year}`;
155
- else
156
- return `${day_name(d.getDay())}, ${day} ${month_name(month)}`;
157
- }
158
- if (month != current_month) {
159
- if (is_far_date)
160
- return `${day} ${month_name(month)}`;
161
- else
162
- return `${day_name(d.getDay())}, ${day} ${month_name(month)}`;
163
- } else {
164
- let day_of_week = d.getDay();
165
- let current_day_of_week = now.getDay();
166
- if (day_of_week == 0)
167
- day_of_week = 7;
168
- if (current_day_of_week == 0)
169
- current_day_of_week = 7;
170
- let days_diff = day - current_day;
171
- if (days_diff == 0)
172
- return "Today";
173
- else if (days_diff == 1)
174
- return "Tomorrow";
175
- else if (days_diff == -1)
176
- return "Yesterday";
177
- else if (days_diff > 0 && days_diff <= 7) {
178
- if (day_of_week > current_day_of_week)
179
- return day_name(day_of_week);
180
- else
181
- return `${day_name(day_of_week)}, ${d.getDate()} ${month_name(d.getMonth())}`;
182
- } else if (days_diff > 0) {
183
- if (is_far_date)
184
- return `${d.getDate()} ${month_name(d.getMonth())}`;
185
- else
186
- return `${day_name(day_of_week)}, ${d.getDate()} ${month_name(d.getMonth())}`;
187
- } else if (days_diff < 0 && days_diff > -7) {
188
- if (day_of_week < current_day_of_week)
189
- return day_name(day_of_week);
190
- else
191
- return `${day_name(day_of_week)}, ${d.getDate()} ${month_name(d.getMonth())}`;
192
- } else {
193
- if (is_far_date)
194
- return `${d.getDate()} ${month_name(d.getMonth())}`;
195
- else
196
- return `${day_name(day_of_week)}, ${d.getDate()} ${month_name(d.getMonth())}`;
197
- }
198
- }
199
- }
200
- function day_name(d) {
201
- switch (d) {
202
- case 0:
203
- return "Sun";
204
- case 1:
205
- return "Mon";
206
- case 2:
207
- return "Tue";
208
- case 3:
209
- return "Wed";
210
- case 4:
211
- return "Thu";
212
- case 5:
213
- return "Fri";
214
- case 6:
215
- return "Sat";
216
- case 7:
217
- return "Sun";
218
- }
219
- return "";
220
- }
221
- function month_name(m) {
222
- switch (m) {
223
- case 0:
224
- return "Jan";
225
- case 1:
226
- return "Feb";
227
- case 2:
228
- return "Mar";
229
- case 3:
230
- return "Apr";
231
- case 4:
232
- return "May";
233
- case 5:
234
- return "Jun";
235
- case 6:
236
- return "Jul";
237
- case 7:
238
- return "Aug";
239
- case 8:
240
- return "Sep";
241
- case 9:
242
- return "Oct";
243
- case 10:
244
- return "Nov";
245
- case 11:
246
- return "Dec";
247
- }
248
- return "";
249
- }
250
- function get_formatted_date(d) {
251
- if (!d)
252
- return "";
253
- let month = "" + (d.getMonth() + 1);
254
- let day = "" + d.getDate();
255
- let year = d.getFullYear();
256
- let hour = "" + d.getHours();
257
- let minutes = "" + d.getMinutes();
258
- if (day.length < 2)
259
- day = "0" + day;
260
- if (month.length < 2)
261
- month = "0" + month;
262
- if (hour.length < 2)
263
- hour = "0" + hour;
264
- if (minutes.length < 2)
265
- minutes = "0" + minutes;
266
- if (type == "datetime-local")
267
- return `${year}-${month}-${day} ${hour}:${minutes}`;
268
- else
269
- return `${year}-${month}-${day}`;
136
+ rValue = getFormattedStringDate(value, type);
137
+ pretty_value = getNiceStringDate(value);
270
138
  }
271
139
  async function on_changed() {
272
140
  if (!rValue)
@@ -0,0 +1,4 @@
1
+ export function getFormattedStringDate(d: any, type?: string): string;
2
+ export function getNiceStringDate(d: any): string;
3
+ export function dayName(d: any): "" | "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat";
4
+ export function monthName(m: any): "" | "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec";
@@ -0,0 +1,178 @@
1
+
2
+ export function getFormattedStringDate(d, type = "datetime")
3
+ {
4
+ if(!d)
5
+ return '';
6
+
7
+ let month = '' + (d.getMonth() + 1);
8
+ let day = '' + d.getDate();
9
+ let year = d.getFullYear();
10
+ let hour = '' + d.getHours();
11
+ let minutes = '' + d.getMinutes();
12
+
13
+ if(day.length < 2)
14
+ day = '0' + day;
15
+
16
+ if(month.length < 2)
17
+ month = '0' + month;
18
+
19
+ if(hour.length < 2)
20
+ hour = '0' + hour;
21
+
22
+ if(minutes.length < 2)
23
+ minutes = '0' + minutes;
24
+
25
+ if(type == "datetime-local")
26
+ return `${year}-${month}-${day} ${hour}:${minutes}`;
27
+ else
28
+ return `${year}-${month}-${day}`;
29
+ }
30
+
31
+ export function getNiceStringDate(d)
32
+ {
33
+ if(!d)
34
+ return '';
35
+
36
+ let month = d.getMonth();
37
+ let day = d.getDate();
38
+ let year = d.getFullYear();
39
+
40
+ const now = new Date( Date.now())
41
+ let current_month = now.getMonth();
42
+ let current_day = now.getDate();
43
+ let current_year = now.getFullYear();
44
+
45
+ let is_far_date = true;
46
+ const far_date_threshold = 14*24*60*60*1000; // 14 days
47
+ if(Math.abs( now.getTime() - d.getTime()) < far_date_threshold)
48
+ is_far_date = false;
49
+
50
+ if(year != current_year)
51
+ {
52
+ if(is_far_date)
53
+ return `${day} ${monthName(month)} ${year}`
54
+ else
55
+ return `${dayName(d.getDay())}, ${day} ${monthName(month)}`
56
+ }
57
+
58
+ if(month != current_month)
59
+ {
60
+ if(is_far_date)
61
+ return `${day} ${monthName(month)}`
62
+ else
63
+ return `${dayName(d.getDay())}, ${day} ${monthName(month)}`
64
+ }
65
+ else
66
+ {
67
+ let day_of_week = d.getDay() // 0 == Sunday
68
+ let current_day_of_week = now.getDay()
69
+
70
+ if(day_of_week == 0)
71
+ day_of_week = 7
72
+
73
+ if(current_day_of_week == 0)
74
+ current_day_of_week = 7;
75
+
76
+
77
+ let days_diff = day - current_day;
78
+ if(days_diff == 0)
79
+ return 'Today';
80
+ else if(days_diff == 1)
81
+ return 'Tomorrow';
82
+ else if(days_diff == -1)
83
+ return 'Yesterday';
84
+ else if(days_diff > 0 && days_diff <= 7)
85
+ {
86
+ if(day_of_week > current_day_of_week)
87
+ return dayName(day_of_week);
88
+ else
89
+ return `${dayName(day_of_week)}, ${d.getDate()} ${monthName(d.getMonth())}`
90
+ }
91
+ else if(days_diff > 0)
92
+ {
93
+ if(is_far_date)
94
+ return `${d.getDate()} ${monthName(d.getMonth())}`
95
+ else
96
+ return `${dayName(day_of_week)}, ${d.getDate()} ${monthName(d.getMonth())}`
97
+ }
98
+ else if(days_diff < 0 && days_diff > -7)
99
+ {
100
+ if(day_of_week < current_day_of_week)
101
+ return dayName(day_of_week);
102
+ else
103
+ return `${dayName(day_of_week)}, ${d.getDate()} ${monthName(d.getMonth())}`
104
+ }
105
+ else
106
+ {
107
+ if(is_far_date)
108
+ return `${d.getDate()} ${monthName(d.getMonth())}`
109
+ else
110
+ return `${dayName(day_of_week)}, ${d.getDate()} ${monthName(d.getMonth())}`
111
+ }
112
+ }
113
+ }
114
+
115
+ export function dayName(d)
116
+ {
117
+ switch(d)
118
+ {
119
+ case 0:
120
+ return 'Sun';
121
+
122
+ case 1:
123
+ return 'Mon';
124
+
125
+ case 2:
126
+ return 'Tue';
127
+
128
+ case 3:
129
+ return 'Wed';
130
+
131
+ case 4:
132
+ return 'Thu';
133
+
134
+ case 5:
135
+ return 'Fri';
136
+
137
+ case 6:
138
+ return 'Sat';
139
+
140
+ case 7:
141
+ return 'Sun';
142
+ }
143
+
144
+ return '';
145
+ }
146
+
147
+ export function monthName(m)
148
+ {
149
+ switch(m)
150
+ {
151
+ case 0:
152
+ return "Jan";
153
+ case 1:
154
+ return "Feb";
155
+ case 2:
156
+ return "Mar";
157
+ case 3:
158
+ return "Apr";
159
+ case 4:
160
+ return "May";
161
+ case 5:
162
+ return "Jun";
163
+ case 6:
164
+ return "Jul";
165
+ case 7:
166
+ return "Aug";
167
+ case 8:
168
+ return "Sep";
169
+ case 9:
170
+ return "Oct";
171
+ case 10:
172
+ return "Nov";
173
+ case 11:
174
+ return "Dec";
175
+ }
176
+
177
+ return '';
178
+ }
@@ -26,7 +26,7 @@ import Underline from "@tiptap/extension-underline";
26
26
  import Dropcursor from "@tiptap/extension-dropcursor";
27
27
  import Gapcursor from "@tiptap/extension-gapcursor";
28
28
  import History from "@tiptap/extension-history";
29
- import { data_tick_store, contextItemsStore, contextTypesStore, onErrorShowAlert, toolsActionsOperations } from "../../stores.js";
29
+ import { data_tick_store, contextItemsStore, contextTypesStore, onErrorShowAlert, pushToolsActionsOperations, popToolsActionsOperations } from "../../stores.js";
30
30
  import { informModification, pushChanges } from "../../updates.js";
31
31
  import { isDeviceSmallerThan, parseWidthDirective, refreshToolbarOperations, UI } from "../../utils.js";
32
32
  import Palette from "./internal/palette.svelte";
@@ -62,6 +62,7 @@ export let a = "";
62
62
  export let context = "";
63
63
  export let typename = "";
64
64
  export let compact = false;
65
+ export let onChange = void 0;
65
66
  export let onFocusCb = void 0;
66
67
  export let onBlurCb = void 0;
67
68
  export let onAddImage = void 0;
@@ -480,12 +481,16 @@ onMount(() => {
480
481
  content: value,
481
482
  injectCSS: false,
482
483
  onTransaction({ editor: editor2, transaction }) {
483
- hasChangedValue = true;
484
- changedValue = editor2.getHTML();
485
- handleImagesChanges(transaction);
484
+ const wasContentChanged = transaction.steps.length > 0;
485
+ if (wasContentChanged) {
486
+ hasChangedValue = true;
487
+ changedValue = editor2.getHTML();
488
+ handleImagesChanges(transaction);
489
+ }
486
490
  refreshToolbarOperations();
487
491
  },
488
492
  onFocus({ editor: editor2, event }) {
493
+ on_focus();
489
494
  if (onFocusCb)
490
495
  onFocusCb();
491
496
  },
@@ -512,7 +517,24 @@ onDestroy(() => {
512
517
  if (is_command_palette_visible)
513
518
  palette.hide();
514
519
  });
520
+ const isAutoSaveEnabled = false;
521
+ let autoSaveTimerId = 0;
522
+ function on_focus() {
523
+ if (isAutoSaveEnabled) {
524
+ autoSaveTimerId = setInterval(
525
+ () => {
526
+ if (hasChangedValue)
527
+ saveData();
528
+ },
529
+ 1e4
530
+ );
531
+ }
532
+ }
515
533
  function on_blur() {
534
+ if (autoSaveTimerId) {
535
+ clearInterval(autoSaveTimerId);
536
+ autoSaveTimerId = 0;
537
+ }
516
538
  if (onFinishEditing) {
517
539
  onFinishEditing();
518
540
  onFinishEditing = void 0;
@@ -529,9 +551,15 @@ export function save() {
529
551
  }
530
552
  }
531
553
  function saveData() {
532
- if (item && a && hasChangedValue) {
554
+ if (!hasChangedValue)
555
+ return false;
556
+ hasChangedValue = false;
557
+ console.log("editor: saveData");
558
+ if (onChange) {
559
+ onChange(changedValue);
560
+ return true;
561
+ } else if (item && a) {
533
562
  item[a] = changedValue;
534
- hasChangedValue = false;
535
563
  if (typename)
536
564
  informModification(item, a, typename);
537
565
  else
@@ -563,7 +591,7 @@ function on_palette_mouse_click() {
563
591
  function on_palette_shown() {
564
592
  is_command_palette_visible = true;
565
593
  if (isDeviceSmallerThan("sm")) {
566
- $toolsActionsOperations = {
594
+ pushToolsActionsOperations({
567
595
  opver: 1,
568
596
  operations: [
569
597
  {
@@ -581,12 +609,13 @@ function on_palette_shown() {
581
609
  ]
582
610
  }
583
611
  ]
584
- };
612
+ });
585
613
  }
586
614
  }
587
615
  function on_palette_hidden() {
616
+ if (is_command_palette_visible)
617
+ popToolsActionsOperations();
588
618
  is_command_palette_visible = false;
589
- $toolsActionsOperations = [];
590
619
  }
591
620
  function show_command_palette(cursor_rect) {
592
621
  let client_rect = get_window_box();
@@ -9,6 +9,7 @@ declare const __propDef: {
9
9
  context?: string | undefined;
10
10
  typename?: string | undefined;
11
11
  compact?: boolean | undefined;
12
+ onChange?: undefined;
12
13
  onFocusCb?: undefined;
13
14
  onBlurCb?: undefined;
14
15
  onAddImage?: undefined;
@@ -52,17 +52,27 @@
52
52
  itype = itype;
53
53
  }
54
54
 
55
+ export function refresh(itm=undefined)
56
+ {
57
+ if(itm)
58
+ self = itm;
59
+
60
+ item = self ?? $contextItemsStore[ctx];
61
+ setup()
62
+ }
63
+
64
+ let userClass = $$restProps.class ?? '';
55
65
 
56
66
  let item = null
57
67
 
58
- let labelMargins = 'mt-1 mb-0.5' //
68
+ let labelMargins = 'mb-0.5' //
59
69
  let input_pt = 'pt-0.5'
60
70
  let input_pb = 'pb-1'
61
71
 
62
72
  switch (s)
63
73
  {
64
74
  case 'md':
65
- labelMargins = 'mt-1 mb-1';
75
+ labelMargins = 'mb-1';
66
76
  input_pt = 'pt-2.5'
67
77
  input_pb = 'pb-2.5';
68
78
  break;
@@ -127,7 +137,7 @@
127
137
 
128
138
  {#if itype == 'text'}
129
139
  {@const border_style = invalid ? "border-red-300 dark:border-red-600" : "border-stone-300 dark:border-stone-500" }
130
- <div class={cs}>
140
+ <div class="{cs} {userClass}">
131
141
  <label for="name" class="block {labelMargins} text-xs font-small text-stone-900 dark:text-white">{label}</label>
132
142
 
133
143
  <input type=text name="name" id="name"
@@ -20,11 +20,13 @@ export default class Inputbox extends SvelteComponentTyped<{
20
20
  validation?: any;
21
21
  validate?: (() => boolean) | undefined;
22
22
  setReadonly?: ((val: any) => void) | undefined;
23
+ refresh?: ((itm?: undefined) => void) | undefined;
23
24
  }, {
24
25
  [evt: string]: CustomEvent<any>;
25
26
  }, {}> {
26
27
  get validate(): () => boolean;
27
28
  get setReadonly(): (val: any) => void;
29
+ get refresh(): (itm?: undefined) => void;
28
30
  }
29
31
  export type InputboxProps = typeof __propDef.props;
30
32
  export type InputboxEvents = typeof __propDef.events;
@@ -50,6 +52,7 @@ declare const __propDef: {
50
52
  validation?: any;
51
53
  validate?: (() => boolean) | undefined;
52
54
  setReadonly?: ((val: any) => void) | undefined;
55
+ refresh?: ((itm?: undefined) => void) | undefined;
53
56
  };
54
57
  events: {
55
58
  [evt: string]: CustomEvent<any>;
@@ -210,7 +210,7 @@ function showAttachementIcon() {
210
210
  {@const canOpen = isLinkLike || hasOpen}
211
211
  {@const openableClass = canOpen ? "sm:hover:cursor-pointer underline" : ""}
212
212
  {@const showIcon = showAttachementIcon()}
213
- <h3 class=" text-base font-semibold pb-1
213
+ <h3 class=" h3 text-base font-semibold pb-1
214
214
  whitespace-nowrap overflow-clip truncate w-full sm:flex-none
215
215
  relative {openableClass}"
216
216
  use:editable={{
@@ -224,7 +224,9 @@ function showAttachementIcon() {
224
224
  condition: canOpen,
225
225
  callback: performOpen}}
226
226
  bind:this={titleElement}>
227
+ <!--a href="#"-->
227
228
  {item[definition.titleAttrib]}
229
+ <!--/a-->
228
230
 
229
231
  {#if showIcon}
230
232
  <span id="attachement" class="absolute top-1 right-0 w-5 h-5 sm:w-3 sm:h-3">
@@ -31,8 +31,8 @@ async function onSummaryChanged(text) {
31
31
  <li class=" mx-2 pt-2 pb-4 px-1 rounded-md border border-transparent
32
32
  bg-stone-100 dark:bg-stone-700">
33
33
 
34
- <h3 class=" text-lg font-semibold min-h-[1.75rem]
35
- sm:text-sm sm:font-semibold sm:min-h-[1.25rem]
34
+ <h3 class=" text-base font-semibold min-h-[1.75rem]
35
+ sm:min-h-[1.25rem]
36
36
  whitespace-nowrap overflow-clip w-full sm:flex-none "
37
37
  use:editable={{
38
38
  action: (text) => onInsert(text, ''),
@@ -43,10 +43,9 @@ async function onSummaryChanged(text) {
43
43
  </h3>
44
44
 
45
45
  {#if editSummary}
46
- <p class=" sm:text-xs sm:min-h-[1rem]
47
- text-base min-h-[1.5rem]
46
+ <p class=" text-sm min-h-[1.25rem]
48
47
  text-stone-400
49
- max-h-[75px] sm:max-h-[64px]
48
+ max-h-[75px]
50
49
  overflow-hidden"
51
50
  use:editable={{
52
51
  action: (text) => onSummaryChanged(text),
@@ -1,9 +1,11 @@
1
1
  <script>import { getContext } from "svelte";
2
2
  export let onAdd = void 0;
3
3
  export let onOpen = void 0;
4
+ export let onReplace = void 0;
4
5
  export let getCardOperations = void 0;
5
6
  let definition = getContext("rKanban-definition");
6
7
  definition.onAdd = onAdd;
7
8
  definition.onOpen = onOpen;
9
+ definition.onReplace = onReplace;
8
10
  definition.getCardOperations = getCardOperations;
9
11
  </script>
@@ -3,6 +3,7 @@ declare const __propDef: {
3
3
  props: {
4
4
  onAdd?: Function | undefined;
5
5
  onOpen?: Function | undefined;
6
+ onReplace?: Function | undefined;
6
7
  getCardOperations?: Function | undefined;
7
8
  };
8
9
  events: {
@@ -200,7 +200,7 @@ export function moveDown(item) {
200
200
  }
201
201
  const ORDER_STEP = 64;
202
202
  const MIN_ORDER = 0;
203
- function reorderElements(items, from = null) {
203
+ function reorderElements(items, from = null, pushImediatelly = true) {
204
204
  const oa = definition.orderAttrib;
205
205
  let fromIdx;
206
206
  let fromOrder;
@@ -218,9 +218,10 @@ function reorderElements(items, from = null) {
218
218
  informModification(el, oa);
219
219
  order += ORDER_STEP;
220
220
  }
221
- pushChanges();
221
+ if (pushImediatelly)
222
+ pushChanges();
222
223
  }
223
- export function replace(item, toColumnIdx, afterElement) {
224
+ export async function replace(item, toColumnIdx, afterElement) {
224
225
  const fromColumnIdx = getColumnIdx(item);
225
226
  let allItems = definition.getItems();
226
227
  const oa = definition.orderAttrib;
@@ -230,18 +231,21 @@ export function replace(item, toColumnIdx, afterElement) {
230
231
  const toListBottom = allItems.findLast((e) => e[sa] == toColumnState);
231
232
  const fromColumn = columns[fromColumnIdx];
232
233
  const toColumn = columns[toColumnIdx];
234
+ const propsChanges = {
235
+ order: -1,
236
+ state: -1
237
+ };
233
238
  switch (afterElement) {
234
239
  case KanbanColumnTop:
235
240
  if (!toListTop || toListTop[oa] > item[oa]) {
236
- item[sa] = toColumnState;
237
- informModification(item, sa);
241
+ propsChanges.state = toColumnState;
238
242
  } else {
239
243
  const prevItem = getPrev(allItems, toListTop);
240
244
  if (!prevItem) {
241
- item[sa] = toColumnState;
242
245
  item[oa] = toListTop[oa] - ORDER_STEP;
243
- informModification(item, sa);
244
246
  informModification(item, oa);
247
+ propsChanges.state = toColumnState;
248
+ propsChanges.order = item[oa];
245
249
  remove(allItems, item);
246
250
  insertAt(allItems, 0, item);
247
251
  } else {
@@ -249,35 +253,31 @@ export function replace(item, toColumnIdx, afterElement) {
249
253
  let nextOrder = toListTop[oa];
250
254
  let orderSpace = nextOrder - prevOrder;
251
255
  if (orderSpace < 2) {
252
- reorderElements(allItems, prevItem);
256
+ reorderElements(allItems, prevItem, false);
253
257
  prevOrder = prevItem[oa];
254
258
  nextOrder = toListTop[oa];
255
259
  orderSpace = nextOrder - prevOrder;
256
260
  }
257
- item[sa] = toColumnState;
258
261
  item[oa] = prevOrder + Math.floor(orderSpace / 2);
259
- informModification(item, sa);
260
262
  informModification(item, oa);
263
+ propsChanges.state = toColumnState;
264
+ propsChanges.order = item[oa];
261
265
  remove(allItems, item);
262
266
  insertAfter(allItems, prevItem, item);
263
267
  }
264
268
  }
265
- pushChanges();
266
- fromColumn.reload();
267
- toColumn.reload();
268
- return;
269
+ break;
269
270
  case KanbanColumnBottom:
270
271
  default:
271
272
  if (!toListBottom || item[oa] > toListBottom[oa]) {
272
- item[sa] = toColumnState;
273
- informModification(item, sa);
273
+ propsChanges.state = toColumnState;
274
274
  } else {
275
275
  const nextItem = getNext(allItems, toListBottom);
276
276
  if (!nextItem) {
277
- item[sa] = toColumnState;
278
277
  item[oa] = toListBottom[oa] + ORDER_STEP;
279
- informModification(item, sa);
280
278
  informModification(item, oa);
279
+ propsChanges.state = toColumnState;
280
+ propsChanges.order = item[oa];
281
281
  remove(allItems, item);
282
282
  insertAfter(allItems, toListBottom, item);
283
283
  } else {
@@ -285,23 +285,39 @@ export function replace(item, toColumnIdx, afterElement) {
285
285
  let prevOrder = toListBottom[oa];
286
286
  let orderSpace = nextOrder - prevOrder;
287
287
  if (orderSpace < 2) {
288
- reorderElements(allItems, toListBottom);
288
+ reorderElements(allItems, toListBottom, false);
289
289
  prevOrder = toListBottom[oa];
290
290
  nextOrder = nextItem[oa];
291
291
  orderSpace = nextOrder - prevOrder;
292
292
  }
293
- item[sa] = toColumnState;
294
293
  item[oa] = prevOrder + Math.floor(orderSpace / 2);
295
- informModification(item, sa);
296
294
  informModification(item, oa);
295
+ propsChanges.state = toColumnState;
296
+ propsChanges.order = item[oa];
297
297
  remove(allItems, item);
298
298
  insertAfter(allItems, toListBottom, item);
299
299
  }
300
300
  }
301
+ break;
302
+ }
303
+ if (definition.onReplace) {
304
+ if (propsChanges.state >= 0) {
301
305
  pushChanges();
302
- fromColumn.reload();
303
- toColumn.reload();
304
- return;
306
+ }
307
+ const req = {
308
+ [sa]: propsChanges.state,
309
+ item,
310
+ toColumn: toColumnIdx
311
+ };
312
+ await definition.onReplace(req);
313
+ } else {
314
+ if (propsChanges.state >= 0) {
315
+ item[sa] = propsChanges.state;
316
+ informModification(item, sa);
317
+ }
318
+ pushChanges();
319
+ fromColumn.reload();
320
+ toColumn.reload();
305
321
  }
306
322
  }
307
323
  async function onInsert(columnIdx, title2, summary, afterId) {
@@ -397,7 +413,7 @@ async function onInsert(columnIdx, title2, summary, afterId) {
397
413
  }
398
414
  }
399
415
  if (definition.onAdd)
400
- await definition.onAdd(newElement);
416
+ await definition.onAdd(newElement, columnIdx);
401
417
  }
402
418
  export function activateColumn(columnIdx) {
403
419
  columns[columnIdx].activate();
@@ -16,7 +16,7 @@ declare const __propDef: {
16
16
  scrollViewToCard?: ((item: any) => void) | undefined;
17
17
  moveUp?: ((item: object) => void) | undefined;
18
18
  moveDown?: ((item: object) => void) | undefined;
19
- replace?: ((item: any, toColumnIdx: any, afterElement: any) => void) | undefined;
19
+ replace?: ((item: any, toColumnIdx: any, afterElement: any) => Promise<void>) | undefined;
20
20
  activateColumn?: ((columnIdx: number) => void) | undefined;
21
21
  editColumnName?: ((columnIdx: number, onFinish?: Function | undefined) => void) | undefined;
22
22
  moveCardsTo?: ((items: object[], toColumnIdx: number) => void) | undefined;
@@ -55,7 +55,7 @@ export default class Kanban extends SvelteComponentTyped<KanbanProps, KanbanEven
55
55
  get scrollViewToCard(): (item: any) => void;
56
56
  get moveUp(): (item: object) => void;
57
57
  get moveDown(): (item: object) => void;
58
- get replace(): (item: any, toColumnIdx: any, afterElement: any) => void;
58
+ get replace(): (item: any, toColumnIdx: any, afterElement: any) => Promise<void>;
59
59
  get activateColumn(): (columnIdx: number) => void;
60
60
  get editColumnName(): (columnIdx: number, onFinish?: Function | undefined) => void;
61
61
  get moveCardsTo(): (items: object[], toColumnIdx: number) => void;
package/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.s
56
56
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
57
57
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
58
58
  export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, UI, } from './utils';
59
+ export { getFormattedStringDate, getNiceStringDate, dayName, monthName } from './components/date_utils';
59
60
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
60
61
  export { data_tick_store, // tmp
61
62
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/index.js CHANGED
@@ -62,6 +62,7 @@ export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.s
62
62
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
63
63
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
64
64
  export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, UI, } from './utils';
65
+ export { getFormattedStringDate, getNiceStringDate, dayName, monthName } from './components/date_utils';
65
66
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
66
67
  export { data_tick_store, // tmp
67
68
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/modal.svelte CHANGED
@@ -1,6 +1,6 @@
1
1
  <script>import { afterUpdate, onMount, tick } from "svelte";
2
2
  import Icon from "./components/icon.svelte";
3
- import { toolsActionsOperations } from "./stores.js";
3
+ import { pushToolsActionsOperations, popToolsActionsOperations } from "./stores.js";
4
4
  import { isDeviceSmallerThan } from "./utils";
5
5
  import { FaTimes } from "svelte-icons/fa";
6
6
  export let title = "";
@@ -20,7 +20,7 @@ export function show(on_close_callback = void 0) {
20
20
  open = true;
21
21
  close_callback = on_close_callback;
22
22
  if (isDeviceSmallerThan("sm")) {
23
- $toolsActionsOperations = {
23
+ pushToolsActionsOperations({
24
24
  opver: 1,
25
25
  operations: [
26
26
  {
@@ -37,12 +37,14 @@ export function show(on_close_callback = void 0) {
37
37
  ]
38
38
  }
39
39
  ]
40
- };
40
+ });
41
41
  }
42
42
  }
43
43
  export function hide() {
44
+ if (!open)
45
+ return;
44
46
  open = false;
45
- $toolsActionsOperations = [];
47
+ popToolsActionsOperations();
46
48
  }
47
49
  let root;
48
50
  afterUpdate(
@@ -98,8 +100,9 @@ function on_cancel(event) {
98
100
  From: "opacity-100 translate-y-0 sm:scale-100"
99
101
  To: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
100
102
  -->
101
- <div class=" transform overflow-hidden rounded-lg bg-white dark:bg-stone-700 text-left shadow-xl transition-all
102
- sm:my-8 w-full sm:max-w-lg">
103
+
104
+ <div class=" rounded-lg bg-white dark:bg-stone-700 text-left shadow-xl transition-all
105
+ sm:my-8 w-full sm:max-w-lg"> <!-- transform overflow-hidden -->
103
106
  <div class="bg-white dark:bg-stone-700 px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
104
107
  <div class="sm:flex sm:items-start">
105
108
  <div class="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10">
package/operations.svelte CHANGED
@@ -46,16 +46,13 @@ function update(...args) {
46
46
  function on_click(e, operation) {
47
47
  if (!operation)
48
48
  return;
49
- if (operation.action) {
50
- let focused_item = null;
51
- if ($contextItemsStore.focused)
52
- focused_item = $contextItemsStore[$contextItemsStore.focused];
53
- operation.action(focused_item);
54
- return;
55
- }
56
49
  let owner = e.target;
57
50
  while (owner && owner.tagName != "BUTTON")
58
51
  owner = owner.parentElement;
52
+ if (operation.action) {
53
+ operation.action(owner);
54
+ return;
55
+ }
59
56
  if (!owner)
60
57
  return;
61
58
  let rect = owner.getBoundingClientRect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.3.14",
3
+ "version": "1.3.16",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -74,6 +74,7 @@
74
74
  "./components/combo/combo": "./components/combo/combo.js",
75
75
  "./components/contextmenu.svelte": "./components/contextmenu.svelte",
76
76
  "./components/date.svelte": "./components/date.svelte",
77
+ "./components/date_utils": "./components/date_utils.js",
77
78
  "./components/delayed.spinner.svelte": "./components/delayed.spinner.svelte",
78
79
  "./components/document/editor.svelte": "./components/document/editor.svelte",
79
80
  "./components/document/internal/Document_command": "./components/document/internal/Document_command.js",
package/stores.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export function pushToolsActionsOperations(operations: any): void;
2
+ export function popToolsActionsOperations(): void;
1
3
  export function setNavigatorTitle(key: any, title: any): void;
2
4
  export function hasSelectedItem(): boolean;
3
5
  export function hasDataItem(): boolean;
package/stores.js CHANGED
@@ -15,6 +15,31 @@ export const mainContentPageReloader = writable(1);
15
15
  export const wholeAppReloader = writable(1)
16
16
  export const alerts = writable([])
17
17
 
18
+
19
+ let toolsActionsOperationsStack = []
20
+ export function pushToolsActionsOperations(operations)
21
+ {
22
+ toolsActionsOperationsStack.push(operations)
23
+ toolsActionsOperations.set(operations)
24
+ }
25
+
26
+ export function popToolsActionsOperations()
27
+ {
28
+ toolsActionsOperationsStack.pop();
29
+ const stackSize = toolsActionsOperationsStack.length;
30
+ if(stackSize == 0)
31
+ {
32
+ //console.log('stack empty')
33
+ toolsActionsOperations.set([])
34
+ }
35
+ else
36
+ {
37
+ const lastElement = toolsActionsOperationsStack[stackSize-1];
38
+ //console.log('stack not empty (stackSize)', lastElement)
39
+ toolsActionsOperations.set(lastElement)
40
+ }
41
+ }
42
+
18
43
  export const addAlert = (txt) => {
19
44
  let al = get(alerts)
20
45
  al = [txt, ...al];