@humandialog/forms.svelte 1.7.11 → 1.7.13

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.
@@ -348,7 +348,7 @@ async function onDownloadFile(e) {
348
348
  </a>
349
349
  {/if}
350
350
  </p>
351
- {:else}
351
+ {:else if definition.onOpen}
352
352
  <p class=" text-base font-semibold
353
353
 
354
354
  whitespace-nowrap overflow-clip w-full sm:flex-none sm:{name_w}"
@@ -372,6 +372,19 @@ async function onDownloadFile(e) {
372
372
  {/if}
373
373
  -->
374
374
  </p>
375
+ {:else}
376
+ <p class=" text-base font-semibold
377
+ whitespace-nowrap overflow-clip w-full sm:flex-none sm:{name_w}"
378
+ id="__hd_list_ctrl_{getItemKey(item)}_Title"
379
+ use:editable={{
380
+ action: (text) => {change_name(text)},
381
+ active: true,
382
+ readonly: definition.title_readonly,
383
+ }}>
384
+ <span>
385
+ {element_title}
386
+ </span>
387
+ </p>
375
388
  {/if}
376
389
  {/key}
377
390
  {:else}
@@ -1,6 +1,6 @@
1
1
  <script>import { setContext, getContext, afterUpdate, tick, onMount } from "svelte";
2
2
  import { data_tick_store, contextItemsStore, contextTypesStore } from "../../stores";
3
- import { activateItem, getActive, clearActiveItem, parseWidthDirective, getPrev, getNext, swapElements, getLast, insertAfter, getActiveCount, addActiveItem } from "../../utils";
3
+ import { activateItem, getActive, clearActiveItem, parseWidthDirective, getPrev, getNext, swapElements, getLast, insertAfter, getActiveCount, addActiveItem, getFirst, insertAt, remove as removeFrom } from "../../utils";
4
4
  import Icon from "../icon.svelte";
5
5
  import { FaRegCircle, FaRegCheckCircle } from "svelte-icons/fa/";
6
6
  import { rList_definition } from "./List";
@@ -139,7 +139,8 @@ export function reload(data, selectElement = KEEP_SELECTION) {
139
139
  activate_after_dom_update = itemToActivate;
140
140
  }
141
141
  }
142
- }
142
+ } else
143
+ clearActiveItem(selectionKey);
143
144
  }
144
145
  export async function moveUp(element) {
145
146
  if (!orderAttrib)
@@ -169,6 +170,30 @@ export async function moveDown(element) {
169
170
  informModification(next, orderAttrib);
170
171
  pushChanges();
171
172
  }
173
+ export async function moveTop(element) {
174
+ if (!orderAttrib)
175
+ return;
176
+ let current = getFirst(items);
177
+ if (current == element)
178
+ return;
179
+ const firstOrder = current[orderAttrib];
180
+ while (current != element) {
181
+ const next = getNext(items, current);
182
+ const nextOrder = next[orderAttrib];
183
+ current[orderAttrib] = nextOrder;
184
+ informModification(current, orderAttrib);
185
+ current = next;
186
+ }
187
+ element[orderAttrib] = firstOrder;
188
+ informModification(element, orderAttrib);
189
+ items = removeFrom(items, element);
190
+ items = insertAt(items, 0, element);
191
+ await tick();
192
+ scrollToSelectedElement();
193
+ pushChanges();
194
+ }
195
+ export async function moveBottom(element) {
196
+ }
172
197
  let last_activated_element = null;
173
198
  export async function addRowAfter(after = null) {
174
199
  if (!definition.can_insert)
@@ -26,6 +26,8 @@ declare const __propDef: {
26
26
  reload?: ((data: object | object[], selectElement?: number) => void) | undefined;
27
27
  moveUp?: ((element: object) => Promise<void>) | undefined;
28
28
  moveDown?: ((element: object) => Promise<void>) | undefined;
29
+ moveTop?: ((element: object) => Promise<void>) | undefined;
30
+ moveBottom?: ((element: object) => Promise<void>) | undefined;
29
31
  addRowAfter?: ((after?: object | null) => Promise<void>) | undefined;
30
32
  remove?: ((element: object) => void) | undefined;
31
33
  edit?: ((element: object, property_name: string) => void) | undefined;
@@ -59,6 +61,8 @@ export default class List extends SvelteComponentTyped<ListProps, ListEvents, Li
59
61
  get reload(): (data: object | object[], selectElement?: number) => void;
60
62
  get moveUp(): (element: object) => Promise<void>;
61
63
  get moveDown(): (element: object) => Promise<void>;
64
+ get moveTop(): (element: object) => Promise<void>;
65
+ get moveBottom(): (element: object) => Promise<void>;
62
66
  get addRowAfter(): (after?: object | null) => Promise<void>;
63
67
  get remove(): (element: object) => void;
64
68
  get edit(): (element: object, property_name: string) => void;
package/dialog.svelte ADDED
@@ -0,0 +1,49 @@
1
+ <script>import { afterUpdate, onMount, tick } from "svelte";
2
+ import Icon from "./components/icon.svelte";
3
+ import { pushToolsActionsOperations, popToolsActionsOperations, fabHiddenDueToPopup } from "./stores.js";
4
+ import { isDeviceSmallerThan } from "./utils";
5
+ import { FaTimes } from "svelte-icons/fa";
6
+ import { i18n } from "./i18n.js";
7
+ export let open = false;
8
+ export function show(on_close_callback = void 0) {
9
+ open = true;
10
+ close_callback = on_close_callback;
11
+ if (isDeviceSmallerThan("sm")) {
12
+ $fabHiddenDueToPopup = true;
13
+ }
14
+ }
15
+ export function hide() {
16
+ if (!open)
17
+ return;
18
+ open = false;
19
+ $fabHiddenDueToPopup = false;
20
+ }
21
+ let root;
22
+ afterUpdate(
23
+ async () => {
24
+ if (!!root) {
25
+ let modal_root = document.getElementById("__hd_svelte_modal_root");
26
+ if (!!modal_root && root.parentElement != modal_root) {
27
+ await tick();
28
+ modal_root.appendChild(root);
29
+ }
30
+ }
31
+ }
32
+ );
33
+ let close_callback = void 0;
34
+ </script>
35
+
36
+ {#if open}
37
+ <div class="relative z-30" aria-labelledby="modal-title" role="dialog" aria-modal="true" bind:this={root}>
38
+ <div class="fixed w-screen h-screen inset-0 bg-stone-500 dark:bg-stone-800 bg-opacity-75 dark:bg-opacity-75 transition-opacity"></div>
39
+
40
+ <div class="fixed z-30 inset-0 w-screen overflow-y-auto">
41
+ <div class="flex min-h-full items-end justify-center p-1 text-center sm:items-center sm:p-0">
42
+ <div class=" p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black text-left shadow-xl transition-all
43
+ sm:my-8 w-full sm:max-w-lg"> <!-- transform overflow-hidden -->
44
+ <slot/>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ {/if}
@@ -0,0 +1,22 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ open?: boolean | undefined;
5
+ show?: ((on_close_callback?: Function | undefined) => void) | undefined;
6
+ hide?: (() => void) | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {
12
+ default: {};
13
+ };
14
+ };
15
+ export type DialogProps = typeof __propDef.props;
16
+ export type DialogEvents = typeof __propDef.events;
17
+ export type DialogSlots = typeof __propDef.slots;
18
+ export default class Dialog extends SvelteComponentTyped<DialogProps, DialogEvents, DialogSlots> {
19
+ get show(): (on_close_callback?: Function | undefined) => void;
20
+ get hide(): () => void;
21
+ }
22
+ export {};
package/index.d.ts CHANGED
@@ -42,6 +42,7 @@ export { default as ListComboProperty } from './components/list/list.combo.svelt
42
42
  export { default as ListStaticProperty } from './components/list/list.static.svelte';
43
43
  export { default as ListTags } from './components/list/list.tags.svelte';
44
44
  export { default as Modal } from './modal.svelte';
45
+ export { default as Dialog } from './dialog.svelte';
45
46
  export { default as MembersPage } from './tenant.members.svelte';
46
47
  export { default as Console } from './console.svelte';
47
48
  export { default as Tag } from './components/tag.svelte';
package/index.js CHANGED
@@ -48,6 +48,7 @@ export { default as ListComboProperty } from './components/list/list.combo.svelt
48
48
  export { default as ListStaticProperty } from './components/list/list.static.svelte';
49
49
  export { default as ListTags } from './components/list/list.tags.svelte';
50
50
  export { default as Modal } from './modal.svelte';
51
+ export { default as Dialog } from './dialog.svelte';
51
52
  export { default as MembersPage } from './tenant.members.svelte';
52
53
  export { default as Console } from './console.svelte';
53
54
  export { default as Tag } from './components/tag.svelte';
package/operations.svelte CHANGED
@@ -110,8 +110,11 @@ function update(...args) {
110
110
  ...op,
111
111
  group: group.caption
112
112
  };
113
- if (op.hideToolbarCaption)
113
+ if (op.hideToolbarCaption) {
114
+ if (!tbrOperation.tooltip)
115
+ tbrOperation.tooltip = tbrOperation.caption;
114
116
  tbrOperation.caption = "";
117
+ }
115
118
  const shouldAddSeparator = (list, groupName) => {
116
119
  if (!groupName)
117
120
  return false;
@@ -197,6 +200,14 @@ function isOperationDisabled(operation) {
197
200
  else
198
201
  return operation.disabled ?? false;
199
202
  }
203
+ function operationTooltip(operation) {
204
+ if (!operation)
205
+ return "";
206
+ else if (operation.tooltip)
207
+ return operation.tooltip;
208
+ else
209
+ return "";
210
+ }
200
211
  </script>
201
212
 
202
213
  {#if hasOperations}
@@ -221,6 +232,7 @@ function isOperationDisabled(operation) {
221
232
  inline-flex items-center"
222
233
  class:bg-stone-700={isActive}
223
234
  class:dark:bg-stone-800={isActive}
235
+ title={operationTooltip(operation)}
224
236
  on:mousedown={(e) => mousedown(e, operation)}
225
237
  on:click={(e) => {on_click(e, operation, isDisabled)}}>
226
238
  {#if operation.icon}
@@ -251,6 +263,7 @@ function isOperationDisabled(operation) {
251
263
  class:bg-stone-200={isActive}
252
264
  class:dark:bg-stone-800={isActive}
253
265
  disabled={isDisabled}
266
+ title={operationTooltip(operation)}
254
267
  on:mousedown={(e) => mousedown(e, operation)}
255
268
  on:click={(e) => {on_click(e, operation, isDisabled)}}>
256
269
  {#if operation.icon}
@@ -293,6 +306,7 @@ function isOperationDisabled(operation) {
293
306
  class:bg-stone-200={isActive}
294
307
  class:dark:bg-stone-800={isActive}
295
308
  disabled={isDisabled}
309
+ title={operationTooltip(operation)}
296
310
  on:mousedown={(e) => mousedown(e, operation)}
297
311
  on:click={(e) => {on_click(e, operation, isDisabled)}}>
298
312
  {#if operation.icon}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.7.11",
3
+ "version": "1.7.13",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -156,6 +156,7 @@
156
156
  "./components/tile.title.svelte": "./components/tile.title.svelte",
157
157
  "./console.svelte": "./console.svelte",
158
158
  "./desk.svelte": "./desk.svelte",
159
+ "./dialog.svelte": "./dialog.svelte",
159
160
  "./form.box.svelte": "./form.box.svelte",
160
161
  "./horizontal.toolbar.svelte": "./horizontal.toolbar.svelte",
161
162
  "./i18n-preprocess": "./i18n-preprocess.js",
@@ -5,7 +5,7 @@
5
5
  FaInfoCircle,
6
6
  FaUserSlash,
7
7
  FaChevronDown,
8
- FaInfo} from 'svelte-icons/fa'
8
+ FaInfo, FaLink} from 'svelte-icons/fa'
9
9
 
10
10
  import Page from './page.svelte'
11
11
  import List from './components/list/list.svelte'
@@ -189,7 +189,8 @@
189
189
  auth_group: 0,
190
190
  files_group: 0,
191
191
  acc_role: '',
192
- silently: false
192
+ silently: false,
193
+ accepted: false
193
194
  }
194
195
 
195
196
  let name_input;
@@ -367,7 +368,8 @@
367
368
  caption: i18n({en: 'Fetch info', es: 'Obtener información', pl: 'Pobierz informacje'}),
368
369
  icon: FaInfo,
369
370
  action: (f) => fetch_user_details(user),
370
- tbr: 'A'
371
+ tbr: 'A',
372
+ fab: 'S00'
371
373
  }
372
374
  ];
373
375
 
@@ -375,11 +377,11 @@
375
377
  {
376
378
  operations = [ ...operations,
377
379
  {
378
- icon: FaUserPlus,
380
+ //icon: FaUserPlus,
379
381
  caption: i18n({en: 'Revert removing', es: 'Revertir eliminación', pl: 'Cofnij usunięcie'}),
380
382
  action: (f) => askToAddAgain(user),
381
383
  // fab: 'M10',
382
- tbr: 'A'
384
+ // tbr: 'A'
383
385
  }
384
386
  ];
385
387
  }
@@ -391,16 +393,24 @@
391
393
  icon: FaPen,
392
394
  caption: i18n({en: 'Change', es: 'Cambiar', pl: 'Zmień'}),
393
395
  menu: edit_operations,
394
- //fab: 'M20',
396
+ fab: 'M20',
395
397
  tbr: 'A'
396
398
  });
397
399
 
398
400
  operations.push({
399
401
  caption: i18n({en: 'Remove user', es: 'Eliminar usuario', pl: 'Usuń użytkownika'}),
400
- icon: FaUserMinus,
402
+ // icon: FaUserMinus,
401
403
  action: (focused) => askToRemove(user),
402
404
  // fab: 'M30',
403
- tbr: 'A'
405
+ // tbr: 'A'
406
+ });
407
+
408
+ operations.push({
409
+ caption: i18n({en: 'Copy the invitation link', es: 'Copie el enlace de invitación', pl: 'Skopuj link zapraszający'}),
410
+ //icon: FaLink,
411
+ action: (focused) => regenerateAndCopyInvitationLink(user),
412
+ // fab: 'M30',
413
+ //tbr: 'A'
404
414
  });
405
415
  }
406
416
 
@@ -408,6 +418,7 @@
408
418
  return {
409
419
  opver: 2,
410
420
  fab: 'M00',
421
+ tbr: 'D',
411
422
  operations: [
412
423
  {
413
424
  caption: i18n({en: 'User', es: 'Usuario', pl: 'Użytkownik'}),
@@ -418,7 +429,37 @@
418
429
  }
419
430
  }
420
431
 
421
-
432
+ async function regenerateAndCopyInvitationLink(user)
433
+ {
434
+ try {
435
+ let params = `username=${user[emailAttrib]}`
436
+ params += `&client_id=${$session.configuration.client_id}`
437
+ params += `&redirect_uri=${encodeURIComponent(window.location.origin+'/#/auth/cb')}`
438
+ params += `&state=${encodeURIComponent(window.location.origin+'/#/auth/signin')}`
439
+ params += `&tenant=${$session.tid}`
440
+ params += `&scope=${$session.appId}`
441
+
442
+ console.log(params)
443
+
444
+ const res = await reef.fetch(`/auth/regenerate_invitation_link?${params}`)
445
+
446
+ if(res.ok)
447
+ {
448
+ const result = await res.json();
449
+ console.log(result.invitation_link)
450
+ navigator.clipboard.writeText(result.invitation_link)
451
+ }
452
+ else
453
+ {
454
+ const err_msg = await res.text();
455
+ onErrorShowAlert(err_msg);
456
+ }
457
+ }
458
+ catch (err)
459
+ {
460
+ onErrorShowAlert(err);
461
+ }
462
+ }
422
463
 
423
464
  let data_item =
424
465
  {
@@ -541,6 +582,7 @@
541
582
  state: `${window.location.origin}/#/auth/signin`,
542
583
  idempotency_token: inviteUserIdempotencyToken,
543
584
  silently: new_user.silently ?? false,
585
+ accepted: new_user.accepted ?? false,
544
586
  set:
545
587
  {
546
588
  [nameAttrib]: new_user.name,
@@ -593,6 +635,7 @@
593
635
  new_user.files_group = 0;
594
636
  new_user.acc_role = ''
595
637
  new_user.silently = false;
638
+ new_user.accepted = false;
596
639
 
597
640
  create_new_user_enabled = false;
598
641
  }
@@ -605,6 +648,7 @@
605
648
  new_user.files_group = 0;
606
649
  new_user.acc_role = ''
607
650
  new_user.silently = false;
651
+ new_user.accepted = false;
608
652
 
609
653
  create_new_user_enabled = false;
610
654
  }
@@ -693,6 +737,7 @@
693
737
  new_user.email = user[emailAttrib];
694
738
  new_user.name = user[nameAttrib];
695
739
  new_user.silently = true;
740
+ new_user.accepted = true;
696
741
 
697
742
  //name_input?.setReadonly(true)
698
743
  //email_input?.setReadonly(true)
@@ -725,7 +770,8 @@
725
770
  title='Members'
726
771
  toolbarOperations={user_operations}
727
772
  bind:this={list}>
728
- <ListTitle a={nameAttrib} onChange={on_name_changed} hrefFunc={getHRefFunc()}/>
773
+ <!-- hrefFunc={getHRefFunc()}-->
774
+ <ListTitle a={nameAttrib} onChange={on_name_changed} />
729
775
  <ListSummary a={emailAttrib} readonly/>
730
776
 
731
777
  <ListStaticProperty name="Membership" a="membership_tag"/>
@@ -770,14 +816,14 @@
770
816
  a="email"
771
817
  validation={is_valid_email_address}
772
818
  bind:this={email_input}
773
- readonly={new_user.silently}/>
819
+ readonly={new_user.accepted}/>
774
820
 
775
821
  <Input label={i18n({en: 'Name', es: 'Nombre', pl: 'Imię'})}
776
822
  placeholder='Optional'
777
823
  self={new_user}
778
824
  a="name"
779
825
  bind:this={name_input}
780
- readonly={new_user.silently}/>
826
+ readonly={new_user.accepted}/>
781
827
 
782
828
  <!--Checkbox class="mt-2 text-xs font-normal" self={new_user} a="maintainer">
783
829
  <div class="flex flex-row items-center">
@@ -789,6 +835,10 @@
789
835
  </div>
790
836
  </Checkbox-->
791
837
 
838
+ <Checkbox class="mt-2 text-xs font-normal" self={new_user} a="silently">
839
+ {i18n({en: 'Add user without sending an email', es: 'Añadir usuario sin enviar correo electrónico', pl: 'Dodaj użytkownika bez wysyłania e-maila'})}
840
+ </Checkbox>
841
+
792
842
  <!-- There is problem with dropdown/combo on dialogs (nested fixed stacks) -->
793
843
  <!--Combo class="mt-2" label='Privileges' a='auth_group' self={new_user} >
794
844
  <ComboItem name='No auth access' key={0} />