@humandialog/forms.svelte 1.3.13 → 1.3.15

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.
@@ -8,7 +8,8 @@ let visible = false;
8
8
  let toolbar;
9
9
  let props = {};
10
10
  let around_rect;
11
- let root_element;
11
+ let rootElement;
12
+ let internalElement;
12
13
  export async function show(around, _toolbar, _props = {}) {
13
14
  if (around instanceof DOMRect) {
14
15
  x = around.left;
@@ -20,6 +21,9 @@ export async function show(around, _toolbar, _props = {}) {
20
21
  around_rect = new DOMRect(x, y, 0, 0);
21
22
  }
22
23
  const was_visible = visible;
24
+ if (!was_visible && toolbar == _toolbar && internalElement && internalElement.reload) {
25
+ internalElement.reload();
26
+ }
23
27
  visible = true;
24
28
  toolbar = _toolbar;
25
29
  props = _props;
@@ -27,6 +31,7 @@ export async function show(around, _toolbar, _props = {}) {
27
31
  props.onHide = () => {
28
32
  hide();
29
33
  };
34
+ props.onSizeChanged = () => onSizeChanged();
30
35
  hide_window_indicator = 0;
31
36
  window.addEventListener("click", on_before_window_click, true);
32
37
  if (isDeviceSmallerThan("sm")) {
@@ -51,7 +56,7 @@ export async function show(around, _toolbar, _props = {}) {
51
56
  }
52
57
  await tick();
53
58
  if (!was_visible)
54
- root_element.addEventListener("click", on_before_container_click, true);
59
+ rootElement.addEventListener("click", on_before_container_click, true);
55
60
  cssPosition = calculatePosition(x, y, around_rect, true, false);
56
61
  }
57
62
  export function isVisible() {
@@ -62,7 +67,15 @@ export function hide() {
62
67
  cssPosition = calculatePosition(x, y, around_rect, false, false);
63
68
  $toolsActionsOperations = [];
64
69
  window.removeEventListener("click", on_before_window_click, true);
65
- root_element.removeEventListener("click", on_before_container_click, true);
70
+ rootElement?.removeEventListener("click", on_before_container_click, true);
71
+ }
72
+ export function isSameToolbar(_toolbar) {
73
+ return _toolbar == toolbar;
74
+ }
75
+ async function onSizeChanged() {
76
+ cssPosition = calculatePosition(x, y, around_rect, true, true);
77
+ await tick();
78
+ cssPosition = calculatePosition(x, y, around_rect, true, false);
66
79
  }
67
80
  let hide_window_indicator = 0;
68
81
  function on_before_window_click() {
@@ -91,7 +104,7 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
91
104
  const margin = 5;
92
105
  let myRect = null;
93
106
  if (!fresh) {
94
- myRect = root_element.getBoundingClientRect();
107
+ myRect = rootElement.getBoundingClientRect();
95
108
  if (myRect && myRect.height == 0)
96
109
  myRect = null;
97
110
  }
@@ -113,7 +126,7 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
113
126
  } else {
114
127
  let myRect = null;
115
128
  if (!fresh) {
116
- myRect = root_element.getBoundingClientRect();
129
+ myRect = rootElement.getBoundingClientRect();
117
130
  if (myRect && myRect.height == 0)
118
131
  myRect = null;
119
132
  }
@@ -131,7 +144,6 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
131
144
  }
132
145
  result = `left:${x2}px; top:${y2}px; width: max-content; height:max-content; display: block`;
133
146
  }
134
- console.log(result);
135
147
  return result;
136
148
  }
137
149
  </script>
@@ -139,7 +151,7 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
139
151
  <div id="__hd_svelte_floating_container"
140
152
  class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow z-30 fixed"
141
153
  style={cssPosition}
142
- bind:this={root_element}>
143
- <svelte:component this={toolbar} {...props} />
154
+ bind:this={rootElement}>
155
+ <svelte:component this={toolbar} {...props} bind:this={internalElement} />
144
156
  </div>
145
157
 
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  show?: ((around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>) | undefined;
5
5
  isVisible?: (() => boolean) | undefined;
6
6
  hide?: (() => void) | undefined;
7
+ isSameToolbar?: ((_toolbar: any) => boolean) | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -17,5 +18,6 @@ export default class FloatingContainer extends SvelteComponentTyped<FloatingCont
17
18
  get show(): (around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>;
18
19
  get isVisible(): () => boolean;
19
20
  get hide(): () => void;
21
+ get isSameToolbar(): (_toolbar: any) => boolean;
20
22
  }
21
23
  export {};
@@ -256,7 +256,6 @@ export function show(event, hide_callback) {
256
256
  }
257
257
  }
258
258
  export function hide() {
259
- console.log("combo hide");
260
259
  if (mutation_observer)
261
260
  mutation_observer.disconnect();
262
261
  is_dropdown_open = false;
@@ -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
+ }
@@ -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;
@@ -76,20 +77,6 @@ export function run(onStop = void 0) {
76
77
  let suggestionRange = void 0;
77
78
  export function getFormattingOperations(withCaptions = false) {
78
79
  let result = [];
79
- if (isDeviceSmallerThan("sm")) {
80
- result = [
81
- {
82
- caption: "Back to edit",
83
- icon: FaArrowLeft,
84
- action: (fi) => {
85
- editor?.commands.focus();
86
- }
87
- },
88
- {
89
- separator: true
90
- }
91
- ];
92
- }
93
80
  commands.forEach((c2) => {
94
81
  if (c2.separator) {
95
82
  result.push({ separator: true });
@@ -98,7 +85,8 @@ export function getFormattingOperations(withCaptions = false) {
98
85
  caption: withCaptions ? c2.caption : "",
99
86
  icon: c2.icon,
100
87
  action: (f) => c2.on_choice(suggestionRange),
101
- activeFunc: c2.is_active
88
+ activeFunc: c2.is_active,
89
+ tbr: "B"
102
90
  });
103
91
  }
104
92
  });
@@ -493,12 +481,16 @@ onMount(() => {
493
481
  content: value,
494
482
  injectCSS: false,
495
483
  onTransaction({ editor: editor2, transaction }) {
496
- hasChangedValue = true;
497
- changedValue = editor2.getHTML();
498
- handleImagesChanges(transaction);
484
+ const wasContentChanged = transaction.steps.length > 0;
485
+ if (wasContentChanged) {
486
+ hasChangedValue = true;
487
+ changedValue = editor2.getHTML();
488
+ handleImagesChanges(transaction);
489
+ }
499
490
  refreshToolbarOperations();
500
491
  },
501
492
  onFocus({ editor: editor2, event }) {
493
+ on_focus();
502
494
  if (onFocusCb)
503
495
  onFocusCb();
504
496
  },
@@ -525,7 +517,24 @@ onDestroy(() => {
525
517
  if (is_command_palette_visible)
526
518
  palette.hide();
527
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
+ }
528
533
  function on_blur() {
534
+ if (autoSaveTimerId) {
535
+ clearInterval(autoSaveTimerId);
536
+ autoSaveTimerId = 0;
537
+ }
529
538
  if (onFinishEditing) {
530
539
  onFinishEditing();
531
540
  onFinishEditing = void 0;
@@ -542,9 +551,15 @@ export function save() {
542
551
  }
543
552
  }
544
553
  function saveData() {
545
- 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) {
546
562
  item[a] = changedValue;
547
- hasChangedValue = false;
548
563
  if (typename)
549
564
  informModification(item, a, typename);
550
565
  else
@@ -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;
@@ -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),
@@ -28,6 +28,7 @@ export declare class rList_property_tags extends rList_property {
28
28
  onUpdateAllTags: Function | undefined;
29
29
  }
30
30
  export declare class rList_definition {
31
+ name: string;
31
32
  title: string;
32
33
  title_editable: boolean;
33
34
  on_title_changed: Function | undefined;
@@ -36,6 +36,7 @@ export class rList_property_tags extends rList_property {
36
36
  onUpdateAllTags = undefined;
37
37
  }
38
38
  export class rList_definition {
39
+ name = '';
39
40
  title = '';
40
41
  title_editable = false;
41
42
  on_title_changed = undefined;
@@ -21,8 +21,8 @@ export let item;
21
21
  export let title = "";
22
22
  export let summary = "";
23
23
  export let typename = void 0;
24
- export let toolbarOperations;
25
- export let contextMenu;
24
+ export let toolbarOperations = void 0;
25
+ export let contextMenu = void 0;
26
26
  let definition = getContext("rList-definition");
27
27
  let placeholder = "";
28
28
  let props_sm;
@@ -47,10 +47,10 @@ if (!typename) {
47
47
  }
48
48
  let item_key = "";
49
49
  let keys = Object.keys(item);
50
- if (keys.includes("Id"))
51
- item_key = "Id";
52
- else if (keys.includes("$ref"))
50
+ if (keys.includes("$ref"))
53
51
  item_key = "$ref";
52
+ else if (keys.includes("Id"))
53
+ item_key = "Id";
54
54
  else if (keys.length > 0)
55
55
  item_key = keys[0];
56
56
  if (!title)
@@ -152,9 +152,11 @@ function getHRef() {
152
152
  return "";
153
153
  }
154
154
  function activate_row(e, item2) {
155
- activateItem("props", item2, toolbarOperations(item2));
156
- if (e)
157
- e.stopPropagation();
155
+ if (toolbarOperations) {
156
+ activateItem("props", item2, toolbarOperations(item2));
157
+ if (e)
158
+ e.stopPropagation();
159
+ }
158
160
  }
159
161
  function on_contextmenu(e) {
160
162
  if (!contextMenu)
@@ -318,7 +320,7 @@ export function scrollToView() {
318
320
  {#key item[summary] }
319
321
  {#if is_row_active}
320
322
  <p id={element_id}
321
- class=" text-sm mb-2
323
+ class=" text-sm
322
324
  text-stone-400"
323
325
  use:editable={{
324
326
  action: (text) => {change_summary(text)},
@@ -330,7 +332,7 @@ export function scrollToView() {
330
332
  </p>
331
333
  {:else}
332
334
  <p id={element_id}
333
- class=" text-sm mb-2
335
+ class=" text-sm
334
336
  text-stone-400"
335
337
  on:click={(e) => on_active_row_clicked(e, 'bottom')}>
336
338
  {item[summary]}
@@ -5,8 +5,8 @@ declare const __propDef: {
5
5
  title?: string | undefined;
6
6
  summary?: string | undefined;
7
7
  typename?: string | undefined;
8
- toolbarOperations: any;
9
- contextMenu: any;
8
+ toolbarOperations?: undefined;
9
+ contextMenu?: undefined;
10
10
  activate?: (() => void) | undefined;
11
11
  editProperty?: ((field: string) => void) | undefined;
12
12
  scrollToView?: (() => void) | undefined;
@@ -26,7 +26,7 @@ async function onSummaryChanged(text) {
26
26
  }
27
27
  </script>
28
28
 
29
- <section class="mt-3 my-0 w-full text-lg sm:text-sm text-stone-700 dark:text-stone-400 cursor-default rounded-md border border-transparent bg-stone-200 dark:bg-stone-700">
29
+ <section class=" my-1 w-full text-base text-stone-700 dark:text-stone-400 cursor-default rounded-md border border-transparent bg-stone-200 dark:bg-stone-700">
30
30
  <div class="flex flex-row">
31
31
  {#if icon}
32
32
  <!--Icon size={3}
@@ -36,8 +36,8 @@ async function onSummaryChanged(text) {
36
36
  {/if}
37
37
 
38
38
  <p class=" ml-3 py-1
39
- text-lg font-semibold min-h-[1.75rem]
40
- sm:text-sm sm:font-semibold sm:min-h-[1.25rem]
39
+ text-base font-semibold min-h-[1.75rem]
40
+ sm:min-h-[1.25rem]
41
41
  whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3" tabindex="0"
42
42
  bind:this={titleElement}
43
43
  use:editable={{
@@ -51,8 +51,8 @@ async function onSummaryChanged(text) {
51
51
  {#if editSummary}
52
52
  <p bind:this={summaryElement}
53
53
  class=" ml-10 sm:ml-9
54
- sm:text-xs sm:min-h-[1rem]
55
- text-base min-h-[1.5rem]
54
+ sm:min-h-[1rem]
55
+ text-sm min-h-[1.5rem]
56
56
  text-stone-400"
57
57
  use:editable={{
58
58
  action: onSummaryChanged,
@@ -1,5 +1,5 @@
1
1
  <script>import { setContext, getContext, afterUpdate, tick, onMount } from "svelte";
2
- import { data_tick_store, contextItemsStore, contextTypesStore, page_title } from "../../stores";
2
+ import { data_tick_store, contextItemsStore, contextTypesStore } from "../../stores";
3
3
  import { activateItem, getActive, clearActiveItem, parseWidthDirective, getPrev, getNext, swapElements, getLast, insertAfter } from "../../utils";
4
4
  import { rList_definition } from "./List";
5
5
  import List_element from "./internal/list.element.svelte";
@@ -13,8 +13,8 @@ export let orderAttrib = void 0;
13
13
  export let context = "";
14
14
  export let typename = "";
15
15
  export let c = "";
16
- export let toolbarOperations;
17
- export let contextMenu;
16
+ export let toolbarOperations = void 0;
17
+ export let contextMenu = void 0;
18
18
  export let key = "";
19
19
  export const CLEAR_SELECTION = 0;
20
20
  export const KEEP_SELECTION = -1;
@@ -26,6 +26,7 @@ export const MIN_ORDER = 0;
26
26
  let definition = new rList_definition();
27
27
  setContext("rList-definition", definition);
28
28
  setContext("rIs-table-component", true);
29
+ definition.name = `List ${a}`;
29
30
  let item = null;
30
31
  let items = void 0;
31
32
  let ctx = context ? context : getContext("ctx");
@@ -35,7 +36,8 @@ const END_OF_LIST = {};
35
36
  let rows = [];
36
37
  let activate_after_dom_update = null;
37
38
  let inserter;
38
- clearActiveItem("props");
39
+ if (toolbarOperations)
40
+ clearActiveItem("props");
39
41
  let last_tick = -1;
40
42
  $:
41
43
  setup($data_tick_store, $contextItemsStore);
@@ -55,10 +57,10 @@ function setup(...args) {
55
57
  function getItemKey(item2) {
56
58
  if (key)
57
59
  return item2[key];
58
- else if (item2.Id)
59
- return item2.Id;
60
60
  else if (item2.$ref)
61
61
  return item2.$ref;
62
+ else if (item2.Id)
63
+ return item2.Id;
62
64
  else
63
65
  return 0;
64
66
  }
@@ -9,8 +9,8 @@ declare const __propDef: {
9
9
  context?: string | undefined;
10
10
  typename?: string | undefined;
11
11
  c?: string | undefined;
12
- toolbarOperations: any;
13
- contextMenu: any;
12
+ toolbarOperations?: undefined;
13
+ contextMenu?: undefined;
14
14
  key?: string | undefined;
15
15
  CLEAR_SELECTION?: 0 | undefined;
16
16
  KEEP_SELECTION?: -1 | undefined;
@@ -39,14 +39,12 @@ export function showFloatingToolbar(around, toolbar, props = {}) {
39
39
  toolbar_component.show(around, toolbar, props);
40
40
  }
41
41
  else if (toolbar_component) {
42
- //if(toolbar_component.isVisible())
43
- //{
44
- // toolbar_component.hide();
45
- //}
46
- //else
47
- //{
48
- toolbar_component.show(around, toolbar, props);
49
- //}
42
+ if (toolbar_component.isVisible() && toolbar_component.isSameToolbar(toolbar)) {
43
+ toolbar_component.hide();
44
+ }
45
+ else {
46
+ toolbar_component.show(around, toolbar, props);
47
+ }
50
48
  }
51
49
  else
52
50
  console.error('what now?');
@@ -1,4 +1,4 @@
1
- <script>import { getContext } from "svelte";
1
+ <script>import { getContext, tick } from "svelte";
2
2
  import Icon from "../icon.svelte";
3
3
  import { contextItemsStore, auto_hide_sidebar, contextToolbarOperations } from "../../stores";
4
4
  import { FaBars, FaEllipsisH } from "svelte-icons/fa";
package/index.d.ts CHANGED
@@ -55,7 +55,8 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
55
55
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
56
56
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
57
57
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
58
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
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
@@ -61,7 +61,8 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
61
61
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
62
62
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
63
63
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
64
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
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,5 +1,8 @@
1
1
  <script>import { afterUpdate, onMount, tick } from "svelte";
2
2
  import Icon from "./components/icon.svelte";
3
+ import { toolsActionsOperations } from "./stores.js";
4
+ import { isDeviceSmallerThan } from "./utils";
5
+ import { FaTimes } from "svelte-icons/fa";
3
6
  export let title = "";
4
7
  export let open = false;
5
8
  export let content = "";
@@ -16,9 +19,30 @@ export let onCancelCallback = void 0;
16
19
  export function show(on_close_callback = void 0) {
17
20
  open = true;
18
21
  close_callback = on_close_callback;
22
+ if (isDeviceSmallerThan("sm")) {
23
+ $toolsActionsOperations = {
24
+ opver: 1,
25
+ operations: [
26
+ {
27
+ caption: "Modal",
28
+ operations: [
29
+ {
30
+ icon: FaTimes,
31
+ action: (f) => {
32
+ on_cancel(void 0);
33
+ },
34
+ fab: "M00",
35
+ tbr: "A"
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ };
41
+ }
19
42
  }
20
43
  export function hide() {
21
44
  open = false;
45
+ $toolsActionsOperations = [];
22
46
  }
23
47
  let root;
24
48
  afterUpdate(
@@ -40,7 +64,7 @@ function on_ok(event) {
40
64
  close_callback("OK");
41
65
  }
42
66
  function on_cancel(event) {
43
- open = false;
67
+ hide();
44
68
  if (onCancelCallback)
45
69
  onCancelCallback();
46
70
  if (close_callback)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.3.13",
3
+ "version": "1.3.15",
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.js CHANGED
@@ -121,7 +121,9 @@ export function restore_defults()
121
121
 
122
122
  export function toggle_sidebar(index)
123
123
  {
124
- previously_visible_sidebar = get(main_sidebar_visible_store);
124
+ const prevVisile = get(main_sidebar_visible_store);
125
+ if(prevVisile != '*')
126
+ previously_visible_sidebar = prevVisile;
125
127
 
126
128
  //console.log('toggle_sidebar', previously_visible_sidebar, '=>', index)
127
129
 
@@ -133,6 +135,7 @@ export function toggle_sidebar(index)
133
135
 
134
136
  export function auto_hide_sidebar()
135
137
  {
138
+
136
139
  //console.log('auto_hide_sidebar')
137
140
  //console.log("sw: " + window.innerWidth, SCREEN_SIZES.lg)
138
141
  if(window.innerWidth < SCREEN_SIZES.lg)
@@ -141,14 +144,21 @@ export function auto_hide_sidebar()
141
144
 
142
145
  export function hide_sidebar()
143
146
  {
144
- previously_visible_sidebar = get(main_sidebar_visible_store);
147
+
148
+ const prevVisile = get(main_sidebar_visible_store);
149
+ if(prevVisile != '*')
150
+ previously_visible_sidebar = prevVisile;
151
+
145
152
  main_sidebar_visible_store.set('*')
146
153
  //console.log("auto_hide_sidebar:" + get(main_sidebar_visible_store))
147
154
  }
148
155
 
149
156
  export function show_sidebar(index)
150
157
  {
151
- previously_visible_sidebar = get(main_sidebar_visible_store);
158
+ const prevVisile = get(main_sidebar_visible_store);
159
+ if(prevVisile != '*')
160
+ previously_visible_sidebar = prevVisile;
161
+
152
162
  main_sidebar_visible_store.set(index)
153
163
  }
154
164
 
package/updates.js CHANGED
@@ -122,6 +122,7 @@ update_request_ticket.subscribe(async (v) => {
122
122
  changes.push(value.item);
123
123
  });
124
124
 
125
+
125
126
  /*
126
127
  const res = await reef.post('/Push', { Items: changes }, onErrorShowAlert);
127
128
 
package/utils.d.ts CHANGED
@@ -46,5 +46,6 @@ export let currentEditable: null;
46
46
  export namespace UI {
47
47
  const operations: null;
48
48
  const fab: null;
49
+ const navigator: null;
49
50
  }
50
51
  export const NAVIGATION_PAGE_PATH: "/";
package/utils.js CHANGED
@@ -350,6 +350,7 @@ export function editable(node, params)
350
350
 
351
351
  return {
352
352
  destroy() {
353
+
353
354
  node.removeEventListener("edit", edit_listener)
354
355
  node.classList.remove("editable")
355
356
  node.contentEditable = "false"
@@ -650,7 +651,8 @@ export function isOnScreenKeyboardVisible()
650
651
 
651
652
  export const UI = {
652
653
  operations: null,
653
- fab: null
654
+ fab: null,
655
+ navigator: null
654
656
  }
655
657
 
656
658
  export const NAVIGATION_PAGE_PATH = '/'