@humandialog/forms.svelte 1.3.10 → 1.3.12

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.
@@ -2,6 +2,7 @@
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";
5
+ import { link, push } from "svelte-spa-router";
5
6
  import {
6
7
  selectable as _selectable,
7
8
  isSelected,
@@ -9,7 +10,8 @@ import {
9
10
  handleSelect,
10
11
  activateItem,
11
12
  startEditing,
12
- getActive
13
+ getActive,
14
+ isOnNavigationPage
13
15
  } from "../../utils";
14
16
  import { showMenu } from "../menu";
15
17
  export let href;
@@ -95,14 +97,24 @@ function on_link_clicked(e) {
95
97
  handleSelect(e);
96
98
  else if (item)
97
99
  handleSelect(e);
100
+ if (!e.target)
101
+ return;
102
+ let linkNode = e.target;
103
+ while (linkNode && linkNode.tagName != "A")
104
+ linkNode = linkNode.parentElement;
105
+ if (!linkNode)
106
+ return;
107
+ const href2 = linkNode.getAttribute("href");
108
+ e.preventDefault();
98
109
  if (isOnPage) {
99
- if (!isRowActive) {
100
- e.preventDefault();
101
- } else
102
- e.stopPropagation();
110
+ if (isRowActive) {
111
+ if (href2)
112
+ push(href2);
113
+ }
103
114
  } else {
104
- e.stopPropagation();
105
115
  auto_hide_sidebar();
116
+ if (href2)
117
+ push(href2);
106
118
  }
107
119
  }
108
120
  function on_contextmenu(e) {
@@ -144,14 +156,26 @@ function activateRow(e) {
144
156
  return;
145
157
  if (!isOnPage)
146
158
  return;
147
- let operationsContainer = [];
159
+ let operationsContainer;
148
160
  if (operations) {
149
161
  let operationsList = operations(root);
150
- operationsContainer.push({
151
- icon: FaEllipsisH,
152
- menu: operationsList
153
- });
154
- }
162
+ operationsContainer = {
163
+ opver: 1,
164
+ operations: [
165
+ {
166
+ caption: "View",
167
+ operations: [
168
+ {
169
+ icon: FaEllipsisH,
170
+ menu: operationsList,
171
+ fab: "M10"
172
+ }
173
+ ]
174
+ }
175
+ ]
176
+ };
177
+ } else
178
+ operationsContainer = [];
155
179
  activateItem("props", item, operationsContainer);
156
180
  if (e)
157
181
  e.stopPropagation();
@@ -166,24 +190,24 @@ function activateRow(e) {
166
190
  on:contextmenu={on_contextmenu}
167
191
  on:keydown
168
192
  on:keyup
169
- class=" border border-transparent rounded-lg
170
- text-lg sm:text-base font-normal
193
+ class=" mb-2
194
+ border border-transparent rounded-lg
171
195
  text-stone-900 dark:text-white {user_class}"
172
196
  class:sm:hover:bg-stone-100={!!href}
173
197
  class:sm:dark:hover:bg-stone-700={!!href}
174
198
  class:bg-stone-200={isRowActive}
175
199
  class:dark:bg-stone-700={isRowActive}
176
200
  class:selected={selected(selectable, context_data)}>
177
- <div class="flex flex-row justify-between">
201
+ <div class="flex flex-row justify-between
202
+ text-base font-semibold">
178
203
  {#if href}
179
204
  <a href={href}
180
205
  on:click={on_link_clicked}
181
- class="flex-1 ml-2 mt-1 sm:mt-1 inline-flex items-center group"
182
- class:mb-3={!summary}
183
- class:sm:mb-2={!summary}
206
+ class="flex-1 ml-2 inline-flex items-center group"
184
207
  >
185
208
  {#if icon}
186
- <Icon size={5} component={icon}/>
209
+ <Icon class="w-5 h-5 mt-0.5 ml-2 mr-1" component={icon}/>
210
+
187
211
  {/if}
188
212
  <span class="ml-3 group-hover:underline"
189
213
  use:editable_if_needed={editable}>
@@ -191,12 +215,10 @@ function activateRow(e) {
191
215
  </span>
192
216
  </a>
193
217
  {:else}
194
- <p class="flex-1 ml-2 mt-1 sm:mt-1 inline-flex items-center group cursor-default"
195
- class:mb-3={!summary}
196
- class:sm:mb-2={!summary}
218
+ <p class="flex-1 ml-2 inline-flex items-center group cursor-default"
197
219
  use:selectable_if_needed={selectable}>
198
220
  {#if icon}
199
- <Icon size={2} component={icon}/>
221
+ <Icon class="w-5 h-5 mt-0.5 ml-2 mr-1" component={icon}/>
200
222
  {/if}
201
223
  <span class="ml-3"
202
224
  use:editable_if_needed={editable}>
@@ -205,11 +227,11 @@ function activateRow(e) {
205
227
  </p>
206
228
  {/if}
207
229
 
208
- {#if !isOnPage}
209
- <section class="flex-0 w-20 sm:w-12 h-10 flex-0 flex flex-row"
230
+ {#if !isOnPage}
231
+ <section class="flex-0 w-20 sm:w-12 flex-0 flex flex-row"
210
232
  use:selectable_if_needed={selectable}>
211
233
  {#if can_show_context_menu(selectable, context_data)}
212
- <button class="w-6 sm:w-4 h-6 sm:h-4 mt-3 mr-3 sm:mr-2 ml-auto" on:click={on_show_menu}>
234
+ <button class="w-5 h-5 mt-0.5 mr-3 ml-auto" on:click={on_show_menu}>
213
235
  <FaBars/>
214
236
  </button>
215
237
  {/if}
@@ -217,10 +239,11 @@ function activateRow(e) {
217
239
  {/if}
218
240
  </div>
219
241
 
220
- {#if summary}
221
- <p class="text-xs ml-10 mb-2 mr-2
242
+ {#if summaryText}
243
+ <p class="ml-14 mt-1
222
244
  text-stone-900 dark:text-stone-400
223
- cursor-default"
245
+ cursor-default
246
+ text-sm "
224
247
  use:selectable_if_needed={selectable}
225
248
  use:editable_if_needed={summaryEditable}
226
249
  bind:this={summaryElement}>
@@ -100,12 +100,14 @@ function onBlurInserter() {
100
100
  {/each }
101
101
 
102
102
  {#if inserter}
103
- <Edit class="p-3 sm:p-2 text-lg sm:text-base font-normal text-stone-500 rounded-lg dark:text-stone-400 hover:bg-stone-100 dark:hover:bg-stone-700"
103
+ <Edit class=" mb-2 ml-2
104
+ text-base font-normal
105
+ text-stone-500 rounded-lg dark:text-stone-400 hover:bg-stone-100 dark:hover:bg-stone-700"
104
106
  onEnter={onNewElement}
105
107
  placeholder={inserterPlaceholder}
106
108
  inserter={true}
107
109
  onBlur={onBlurInserter}
108
110
  bind:this={inserterElement}>
109
- <Icon size={5} component={FaPlus} class="mr-3"/>
111
+ <Icon component={FaPlus} class="w-5 h-5 mt-0.5 ml-2.5 pr-0.5 mr-4"/>
110
112
  </Edit>
111
113
  {/if}
@@ -62,9 +62,12 @@ export function selectItem(itm, cinfo2) {
62
62
  $contextTypesStore[select] = itm.oclType;
63
63
  if (focus)
64
64
  $contextItemsStore.focused = select;
65
- if (itm)
66
- $contextToolbarOperations = [...toolbarOperations];
67
- else
65
+ if (itm) {
66
+ if (Array.isArray(toolbarOperations))
67
+ $contextToolbarOperations = [...toolbarOperations];
68
+ else
69
+ $contextToolbarOperations = { ...toolbarOperations };
70
+ } else
68
71
  $contextToolbarOperations = [];
69
72
  if (nav)
70
73
  $data_tick_store = $data_tick_store + 1;
@@ -21,16 +21,19 @@ let x_size;
21
21
  switch (s) {
22
22
  case "md":
23
23
  font = "mt-0.5 text-sm font-semibold";
24
- x_size = "mt-1 w-3 h-3";
24
+ x_size = "w-3 h-3";
25
25
  break;
26
26
  case "sm":
27
27
  font = "mt-0 text-xs mb-0.5 font-semibold";
28
- x_size = "ml-3 mt-1 w-3 w-2 h-3 ";
28
+ x_size = "ml-2 w-3 h-3 ";
29
29
  break;
30
30
  case "xs":
31
31
  font = "mt-0 sm:mt-0 text-xs sm:text-[0.65rem] font-semibold sm:font-normal";
32
- x_size = "ml-3 sm:ml-1 mt-0.5 sm:mt-1 w-3 sm:w-2 h-3 sm:h-2";
32
+ x_size = "ml-3 sm:ml-1 w-3 sm:w-2 h-3 sm:h-2";
33
33
  break;
34
+ default:
35
+ font = "";
36
+ x_size = "ml-2 w-3 h-3";
34
37
  }
35
38
  let rootElement;
36
39
  let colorPicker = null;
@@ -46,19 +49,19 @@ function onSelectColor(color2) {
46
49
  }
47
50
  </script>
48
51
 
49
- <div
50
- class="mt-1 pl-2 {pr} rounded text-white flex flex-row {color}"
52
+ <span
53
+ class=" pl-2 {pr} rounded text-white flex flex-row {color} items-center"
51
54
 
52
55
  bind:this={rootElement}>
53
- <div class={font}>{name}</div>
56
+ <span class={font}>{name}</span>
54
57
  {#if onRemove}
55
- <div
58
+ <span
56
59
  class="no-print inline-block {x_size} hover:cursor-pointer"
57
60
  on:click|stopPropagation={onRemove}>
58
61
  <FaTimes />
59
- </div>
62
+ </span>
60
63
  {/if}
61
- </div>
64
+ </span>
62
65
 
63
66
  <style>
64
67
  @media print {
@@ -193,16 +193,18 @@ switch (s) {
193
193
  }
194
194
  </script>
195
195
 
196
- <div class="{userClass} flex flex-row {gap} flex-wrap mr-1 sm:mr-0">
197
- {#each tagsTable as tag}
198
- {#if isEditable}
199
- <Tag name={tag.label} color={tag.color} {s}
200
- onRemove={(e) => {onRemoveTag(tag.label)}}
201
- onColor={canChangeColor ? onColorizeTag : null}/>
202
- {:else}
203
- <Tag name={tag.label} color={tag.color} {s}/>
204
- {/if}
205
- {/each}
196
+ <section class="{userClass} flex flex-row {gap} flex-wrap mr-1 sm:mr-0">
197
+ <p class="flex flex-row {gap} flex-wrap ">
198
+ {#each tagsTable as tag}
199
+ {#if isEditable}
200
+ <Tag name={tag.label} color={tag.color} {s}
201
+ onRemove={(e) => {onRemoveTag(tag.label)}}
202
+ onColor={canChangeColor ? onColorizeTag : null}/>
203
+ {:else}
204
+ <Tag name={tag.label} color={tag.color} {s}/>
205
+ {/if}
206
+ {/each}
207
+ </p>
206
208
 
207
209
  {#if isEditable}
208
210
  {#if !addComboVisible}
@@ -227,4 +229,4 @@ switch (s) {
227
229
  </Combo>
228
230
  {/if}
229
231
  {/if}
230
- </div>
232
+ </section>
package/desk.svelte CHANGED
@@ -103,15 +103,22 @@
103
103
  let bottom_bar_visibility = "hidden"
104
104
  let bottom_bar_visible = false
105
105
  let lg_main_sidebar_height = ""
106
- let fab_base_visibility = "hidden"
107
- let fab_visibility = fab_base_visibility;
108
- let fab_bottom = "bottom-0"
106
+ //let fab_base_visibility = "hidden"
107
+ //let fab_visibility = fab_base_visibility;
108
+ //let fab_bottom = "bottom-0"
109
109
  let vertical_toolbar_visibility = "hidden sm:block"
110
110
  let content_left = "left-0 sm:left-[40px]";
111
111
  let content_width = "w-screen sm:w-[calc(100vw-40px)] ";
112
112
 
113
113
  let content_top = ""
114
- let content_height = ""
114
+ let content_height = ""
115
+
116
+ const FAB_HIDDEN = 0
117
+ const FAB_VISIBLE_ON_MOBILE = 1
118
+ const FAB_VISIBLE_ALWAYS = 2
119
+ let fab_visibility_mode = FAB_HIDDEN
120
+ let is_fab_visible = false;
121
+
115
122
 
116
123
  $: { tools_visible = $tools_visible_store
117
124
  bottom_bar_visible = $bottom_bar_visible_store
@@ -123,7 +130,8 @@
123
130
  if(tools_visible)
124
131
  {
125
132
  tools_visibility = "hidden sm:block sm:fixed"
126
- fab_base_visibility = "fixed sm:hidden"
133
+ //fab_base_visibility = "fixed sm:hidden"
134
+ fab_visibility_mode = FAB_VISIBLE_ON_MOBILE
127
135
 
128
136
  content_top = 'top-[50px] sm:top-[40px]'
129
137
 
@@ -136,6 +144,9 @@
136
144
  else
137
145
  {
138
146
  tools_visibility = "hidden"
147
+ //fab_base_visibility = "hidden"
148
+ fab_visibility_mode = FAB_HIDDEN
149
+
139
150
  content_top = `top-[50px] sm:top-0`
140
151
  if(bottom_bar_visible)
141
152
  content_height = `min-h-[calc(100vh-290px)] sm:h-[calc(100vh-240px)]`
@@ -149,16 +160,18 @@
149
160
  {
150
161
  lg_main_sidebar_height = `lg:h-[calc(100vh-240px)]`
151
162
  bottom_bar_visibility = "fixed"
152
- fab_bottom = `bottom-[240px]`;
163
+ // fab_bottom = `bottom-[240px]`;
153
164
  }
154
165
  else
155
166
  {
156
167
  lg_main_sidebar_height = ""
157
168
  bottom_bar_visibility = "hidden"
158
- fab_bottom = "bottom-0"
169
+ // fab_bottom = "bottom-0"
159
170
  }
160
171
 
161
- fab_visibility = fab_base_visibility;
172
+
173
+ //fab_visibility = fab_base_visibility;
174
+ determineFABVisibility();
162
175
  }
163
176
 
164
177
 
@@ -250,44 +263,61 @@
250
263
  const vp = window.visualViewport;
251
264
  setViewportHeight(vp)
252
265
 
253
- determineFABVisibility();
266
+ determineFABVisibilityAsync();
254
267
  }
255
268
 
256
269
  function onSelectionChanged(e)
257
270
  {
258
- determineFABVisibility();
271
+ determineFABVisibilityAsync();
259
272
  }
260
273
 
261
274
  function onFocusOut(e)
262
275
  {
263
- determineFABVisibility();
276
+ determineFABVisibilityAsync();
264
277
  }
265
278
 
266
279
  let change_ticket = 0
267
280
  let last_change_ticket = 0
268
- function determineFABVisibility()
281
+ function determineFABVisibilityAsync()
269
282
  {
270
283
  change_ticket++;
271
284
  setTimeout( () => {
272
285
  if(change_ticket != last_change_ticket)
273
286
  {
274
287
  last_change_ticket = change_ticket;
275
- let new_fab_visibility = "";
288
+ determineFABVisibility();
289
+ }
290
+ }, 200)
291
+
292
+ }
276
293
 
294
+ function determineFABVisibility()
295
+ {
296
+ switch(fab_visibility_mode)
297
+ {
298
+ case FAB_HIDDEN:
299
+ is_fab_visible = false;
300
+ break;
301
+
302
+ case FAB_VISIBLE_ON_MOBILE:
303
+ if(isDeviceSmallerThan("sm"))
304
+ {
277
305
  if(isOnScreenKeyboardVisible())
278
- {
279
- new_fab_visibility = 'hidden'
280
- }
306
+ is_fab_visible = false;
281
307
  else
282
- {
283
- new_fab_visibility = fab_base_visibility;
284
- }
285
-
286
- if(fab_visibility != new_fab_visibility)
287
- fab_visibility = new_fab_visibility;
308
+ is_fab_visible = true;
288
309
  }
289
- }, 200)
290
-
310
+ else
311
+ is_fab_visible = false;
312
+ break;
313
+
314
+ case FAB_VISIBLE_ALWAYS:
315
+ if(isOnScreenKeyboardVisible())
316
+ is_fab_visible = false;
317
+ else
318
+ is_fab_visible = true;
319
+ break;
320
+ }
291
321
  }
292
322
 
293
323
  let operationsComponent
@@ -379,9 +409,11 @@
379
409
  <Operations bind:this={operationsComponent} />
380
410
  </div>
381
411
 
382
- <div class="{fab_visibility} right-3 {fab_bottom} mb-1 cursor-pointer z-10">
412
+ {#if is_fab_visible}
413
+ <!--div class="{fab_visibility} left-3 {fab_bottom} mb-1 cursor-pointer z-10"-->
383
414
  <Fab bind:this={fabComponent}/>
384
- </div>
415
+ <!---/div-->
416
+ {/if}
385
417
 
386
418
  <!--#######################################################-->
387
419
  <!--## CONTENT ##################-->
@@ -284,7 +284,7 @@
284
284
  <div class="no-print flex flex-row w-full" on:click={clearSelection}>
285
285
  <div class="flex-none left-0 flex h-12 sm:h-10">
286
286
  <button class="w-12 sm:w-10 h-full flex justify-center items-center text-stone-300 hover:text-stone-100" on:click|stopPropagation={toggle_navigator}>
287
- <Icon class="w-8 sm:w-6 h-8 sm:h-6" component={icon}/>
287
+ <Icon class="w-5 h-5" component={icon}/>
288
288
  </button>
289
289
  </div>
290
290
 
@@ -297,7 +297,7 @@
297
297
  {#if user_is_in_multiple_groups}
298
298
  <button class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
299
299
  on:click|stopPropagation={show_groups}>
300
- <Icon class="w-5 sm:w-4 h-5 sm:h-4" component={FaUsers} />
300
+ <Icon class="w-5 h-5 " component={FaUsers} />
301
301
  </button>
302
302
  {/if}
303
303
 
@@ -305,7 +305,7 @@
305
305
  class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
306
306
  on:click|stopPropagation={show_options}>
307
307
 
308
- <Icon class="w-5 sm:w-4 h-5 sm:h-4" component={FaCog} />
308
+ <Icon class="w-5 h-5 " component={FaCog} />
309
309
  </button>
310
310
  </div>
311
311
 
package/operations.svelte CHANGED
@@ -7,12 +7,41 @@ let operations = [];
7
7
  let leftOperations = [];
8
8
  let rightOperations = [];
9
9
  function update(...args) {
10
- if ($contextToolbarOperations && $contextToolbarOperations.length > 0)
10
+ let isOpVer1 = false;
11
+ if ($contextToolbarOperations && Array.isArray($contextToolbarOperations) && $contextToolbarOperations.length > 0) {
11
12
  operations = $contextToolbarOperations;
12
- else
13
- operations = $pageToolbarOperations;
14
- leftOperations = operations.filter((o) => !o.right);
15
- rightOperations = operations.filter((o) => o.right == true);
13
+ } else if ($contextToolbarOperations && $contextToolbarOperations.operations && $contextToolbarOperations.operations.length > 0) {
14
+ operations = $contextToolbarOperations.operations;
15
+ if ($contextToolbarOperations.opver && $contextToolbarOperations.opver == 1)
16
+ isOpVer1 = true;
17
+ } else {
18
+ if (Array.isArray($pageToolbarOperations))
19
+ operations = $pageToolbarOperations;
20
+ else {
21
+ operations = $pageToolbarOperations.operations;
22
+ if ($pageToolbarOperations.opver && $pageToolbarOperations.opver == 1)
23
+ isOpVer1 = true;
24
+ }
25
+ }
26
+ leftOperations = [];
27
+ rightOperations = [];
28
+ let AOperations = [];
29
+ let BOperations = [];
30
+ let COperations = [];
31
+ if (isOpVer1) {
32
+ operations.forEach((group) => {
33
+ if (group.operations && group.operations.length > 0) {
34
+ AOperations = [...AOperations, ...group.operations.filter((o) => o.tbr == "A")];
35
+ BOperations = [...BOperations, ...group.operations.filter((o) => o.tbr == "B")];
36
+ COperations = [...COperations, ...group.operations.filter((o) => o.tbr == "C")];
37
+ }
38
+ });
39
+ leftOperations = [...AOperations, ...BOperations];
40
+ rightOperations = [...COperations];
41
+ } else {
42
+ leftOperations = operations.filter((o) => !o.right);
43
+ rightOperations = operations.filter((o) => o.right == true);
44
+ }
16
45
  }
17
46
  function on_click(e, operation) {
18
47
  if (!operation)
@@ -71,7 +100,7 @@ function isOperationActivated(operation) {
71
100
  <div class="w-3.5 h-3.5 mr-1"><svelte:component this={operation.icon}/></div>
72
101
  {/if}
73
102
  {#if operation.caption}
74
- <span>{operation.caption}</span>
103
+ <span class="ml-1">{operation.caption}</span>
75
104
  {/if}
76
105
  </button>
77
106
  {/each}
@@ -91,7 +120,7 @@ function isOperationActivated(operation) {
91
120
  <div class="w-3.5 h-3.5 mr-1"><svelte:component this={operation.icon}/></div>
92
121
  {/if}
93
122
  {#if operation.caption}
94
- <span>{operation.caption}</span>
123
+ <span class="ml-1">{operation.caption}</span>
95
124
  {/if}
96
125
  </button>
97
126
  {/if}
@@ -119,7 +148,7 @@ function isOperationActivated(operation) {
119
148
  <div class="w-3.5 h-3.5 mr-1"><svelte:component this={operation.icon}/></div>
120
149
  {/if}
121
150
  {#if operation.caption}
122
- <span>{operation.caption}</span>
151
+ <span class="ml-1">{operation.caption}</span>
123
152
  {/if}
124
153
  </button>
125
154
  {/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "type": "module",
28
28
  "dependencies": {
29
- "@humandialog/auth.svelte": "^1.8.3",
29
+ "@humandialog/auth.svelte": "^1.8.4",
30
30
  "@tiptap/core": "^2.11.0",
31
31
  "@tiptap/extension-bullet-list": "^2.11.5",
32
32
  "@tiptap/extension-code-block": "^2.11.5",
package/page.svelte CHANGED
@@ -42,8 +42,13 @@
42
42
  cl += ' ' + $$props.class
43
43
 
44
44
  onMount(() => {
45
- if (toolbarOperations != undefined && Array.isArray(toolbarOperations))
46
- $pageToolbarOperations = [...toolbarOperations];
45
+ if (toolbarOperations != undefined)
46
+ {
47
+ if(Array.isArray(toolbarOperations))
48
+ $pageToolbarOperations = [...toolbarOperations];
49
+ else
50
+ $pageToolbarOperations = {...toolbarOperations};
51
+ }
47
52
 
48
53
  $page_title = title;
49
54