@humandialog/forms.svelte 0.6.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/desk.svelte CHANGED
@@ -14,7 +14,8 @@
14
14
  data_tick_store,
15
15
  set_default_tools_visible,
16
16
  set_dark_mode_default,
17
- sidebar_left_pos } from './stores.js'
17
+ sidebar_left_pos,
18
+ wholeAppReloader } from './stores.js'
18
19
 
19
20
  import { AuthorizedView} from '@humandialog/auth.svelte'
20
21
  import { handleSelect, isDeviceSmallerThan } from './utils'
@@ -81,6 +82,8 @@
81
82
  else
82
83
  set_default_tools_visible(false)
83
84
 
85
+ //let autoRedirectToSignIn = layout.autoRedirectToSignIn ?? true
86
+
84
87
  $: { visible_sidebar = $main_sidebar_visible_store
85
88
 
86
89
  if(visible_sidebar == "*")
@@ -158,126 +161,130 @@
158
161
 
159
162
  <svelte:window bind:innerWidth bind:outerWidth bind:innerHeight bind:outerHeight />
160
163
 
161
- <AuthorizedView>
162
- <!-- svelte-ignore a11y-click-events-have-key-events -->
163
- <div id="__hd_svelte_layout_root" class="{$dark_mode_store}"
164
- on:click={handleSelect}
165
- on:contextmenu={handleSelect}>
166
-
167
- <div class="bg-white dark:bg-stone-900 dark:text-white overflow-x-clip overflow-y-clip h-screen">
168
- <!--###########################################################-->
169
- <!--## HORIZONTAL TOOLBAR (FOR PHONES) ######################-->
170
- <!--###########################################################-->
171
- <header class="fixed sm:hidden w-screen top-0 h-[50px] sm:h-[40px] z-20 shadow shadow-stone-900/5 dark:shadow-none overflow-auto" >
172
- <div class=" flex flex-row justify-between h-full bg-stone-950 text-stone-100 ">
173
- <HorizontalToolbar appConfig={layout}/>
174
- <div>
175
- </header>
176
-
177
-
178
- <!--HorizontalToolbar /-->
179
- <!--#######################################################-->
180
- <!--## VERTICAL TOOLBAR ##################-->
181
- <!--#######################################################-->
182
- <div class="hidden sm:block fixed left-0 top-0 w-[50px] sm:w-[40px] h-screen z-20 inset-0 overflow-hidden">
183
- <div class="sticky top-0 flex h-full w-10 bg-stone-800 dark:bg-stone-950 flex-col items-center text-stone-100 shadow">
184
- <VerticalToolbar appConfig={layout}/>
185
- </div>
186
- </div>
187
-
188
- <!--VerticalToolbar /-->
189
-
190
- <!--#######################################################-->
191
- <!--## MAIN SIDE BAR ##################-->
192
- <!--#######################################################-->
193
- {#if true}
194
- {@const sidebar_left = $sidebar_left_pos==0 ? "left-0" : "left-[50px]"}
195
- {@const sidebar_small_width = $sidebar_left_pos==0 ? "w-full" : "w-[calc(100vw-50px)]"}
196
-
197
- <div class="{main_side_panel_visibility}
198
- {sidebar_left} sm:left-[40px]
199
- top-[50px] sm:top-0
200
- h-[calc(100vh-50px)] sm:h-full {lg_main_sidebar_height}
201
- {sidebar_small_width} sm:w-[320px]
202
- z-20 overflow-x-hidden">
203
-
204
- <div class=" bg-stone-50 w-full h-full dark:bg-stone-800 overflow-y-auto py-0 px-0">
205
- <Configurable config={layout.sidebar[visible_sidebar]}>
206
- <div slot='alt'></div>
207
- </Configurable>
208
- </div>
209
- </div>
210
- {/if}
211
-
212
- <!-- ! below overflow-x-clip prevents horizontal scrollbar when vertical scrollbar is visible. Default
213
- behaviour is the content expand vertically, and only vertical scrollbar can be visible.
214
- When content on the main page needs to be expanded horizontally (like kanban chart for example) then
215
- that component should define overflow-x-* itself -->
216
- <section on:click|capture={auto_hide_sidebar} class="">
164
+ <!--AuthorizedView {autoRedirectToSignIn}-->
165
+
166
+ {#key $wholeAppReloader}
167
+
168
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
169
+ <div id="__hd_svelte_layout_root" class="{$dark_mode_store}"
170
+ on:click={handleSelect}
171
+ on:contextmenu={handleSelect}>
217
172
 
173
+ <div class="bg-white dark:bg-stone-900 dark:text-white overflow-x-clip overflow-y-clip h-screen">
218
174
  <!--###########################################################-->
219
- <!--## HORIZONTAL TOOLS ######################-->
175
+ <!--## HORIZONTAL TOOLBAR (FOR PHONES) ######################-->
220
176
  <!--###########################################################-->
177
+ <header class="fixed sm:hidden w-screen top-0 h-[50px] sm:h-[40px] z-20 shadow shadow-stone-900/5 dark:shadow-none overflow-auto" >
178
+ <div class=" flex flex-row justify-between h-full bg-stone-950 text-stone-100 ">
179
+ <HorizontalToolbar appConfig={layout}/>
180
+ <div>
181
+ </header>
221
182
 
222
- <div class=" {tools_visibility}
223
- w-screen sm:w-[calc(100vw-40px)]
224
- h-[40px]
225
- left-0 sm:left-[40px]
226
- top-[40px] sm:top-0
227
- {lg_content_area_horizontal_dim}
228
- z-10 overflow-hidden " >
229
183
 
230
- <Operations/>
184
+ <!--HorizontalToolbar /-->
185
+ <!--#######################################################-->
186
+ <!--## VERTICAL TOOLBAR ##################-->
187
+ <!--#######################################################-->
188
+ <div class="hidden sm:block fixed left-0 top-0 w-[50px] sm:w-[40px] h-screen z-20 inset-0 overflow-hidden">
189
+ <div class="sticky top-0 flex h-full w-10 bg-stone-800 dark:bg-stone-950 flex-col items-center text-stone-100 shadow">
190
+ <VerticalToolbar appConfig={layout}/>
191
+ </div>
231
192
  </div>
232
193
 
233
- <div class="{fab_visibility} right-3 {fab_bottom} mb-1 cursor-pointer z-10">
234
- <Fab/>
235
- </div>
194
+ <!--VerticalToolbar /-->
236
195
 
237
196
  <!--#######################################################-->
238
- <!--## CONTENT ##################-->
197
+ <!--## MAIN SIDE BAR ##################-->
239
198
  <!--#######################################################-->
240
- <!-- fixed => relative, content-height => min content height -- -->
241
- <div id="__hd_svelte_main_content_container"
242
- class="relative left-0 w-screen
243
- sm:left-[40px] sm:w-[calc(100vw-40px)]
244
- {content_top}
245
- {content_height}
246
- {lg_content_area_horizontal_dim}
247
- z-0 overflow-x-hidden overflow-y-auto"
248
- >
249
- <Configurable config={layout.mainContent} min_h_class="min-h-full">
199
+ {#if true}
200
+ {@const sidebar_left = $sidebar_left_pos==0 ? "left-0" : "left-[50px]"}
201
+ {@const sidebar_small_width = $sidebar_left_pos==0 ? "w-full" : "w-[calc(100vw-50px)]"}
202
+
203
+ <div class="{main_side_panel_visibility}
204
+ {sidebar_left} sm:left-[40px]
205
+ top-[50px] sm:top-0
206
+ h-[calc(100vh-50px)] sm:h-full {lg_main_sidebar_height}
207
+ {sidebar_small_width} sm:w-[320px]
208
+ z-20 overflow-x-hidden">
209
+
210
+ <div class=" bg-stone-50 w-full h-full dark:bg-stone-800 overflow-y-auto py-0 px-0">
211
+ <Configurable config={layout.sidebar[visible_sidebar]}>
250
212
  <div slot='alt'></div>
251
213
  </Configurable>
214
+ </div>
252
215
  </div>
216
+ {/if}
217
+
218
+ <!-- ! below overflow-x-clip prevents horizontal scrollbar when vertical scrollbar is visible. Default
219
+ behaviour is the content expand vertically, and only vertical scrollbar can be visible.
220
+ When content on the main page needs to be expanded horizontally (like kanban chart for example) then
221
+ that component should define overflow-x-* itself -->
222
+ <section on:click|capture={auto_hide_sidebar} class="">
223
+
224
+ <!--###########################################################-->
225
+ <!--## HORIZONTAL TOOLS ######################-->
226
+ <!--###########################################################-->
227
+
228
+ <div class=" {tools_visibility}
229
+ w-screen sm:w-[calc(100vw-40px)]
230
+ h-[40px]
231
+ left-0 sm:left-[40px]
232
+ top-[40px] sm:top-0
233
+ {lg_content_area_horizontal_dim}
234
+ z-10 overflow-hidden " >
235
+
236
+ <Operations/>
237
+ </div>
238
+
239
+ <div class="{fab_visibility} right-3 {fab_bottom} mb-1 cursor-pointer z-10">
240
+ <Fab/>
241
+ </div>
242
+
243
+ <!--#######################################################-->
244
+ <!--## CONTENT ##################-->
245
+ <!--#######################################################-->
246
+ <!-- fixed => relative, content-height => min content height -- -->
247
+ <div id="__hd_svelte_main_content_container"
248
+ class="relative left-0 w-screen
249
+ sm:left-[40px] sm:w-[calc(100vw-40px)]
250
+ {content_top}
251
+ {content_height}
252
+ {lg_content_area_horizontal_dim}
253
+ z-0 overflow-x-hidden overflow-y-auto"
254
+ >
255
+ <Configurable config={layout.mainContent} min_h_class="min-h-full">
256
+ <div slot='alt'></div>
257
+ </Configurable>
258
+ </div>
259
+
260
+
261
+
262
+ <!--###########################################################-->
263
+ <!--## BOTTOM SIDEBAR ###############################-->
264
+ <!--###########################################################-->
265
+
266
+ <div class="{bottom_bar_visibility} left-0 bottom-0 w-screen h-[240px] z-20 overflow-y-hidden overflow-x-auto
267
+ sm:left-[40px] sm:w-[100vw-40px] " >
268
+ <Configurable config={layout.selectionDetails} >
269
+ <div slot="alt"></div>
270
+ </Configurable>
271
+
272
+ </div>
273
+
274
+ <!-- #########################################################-->
275
+ <!-- ## MODAL DIALOG #########################################-->
276
+ <!-- #########################################################-->
277
+ <div id="__hd_svelte_modal_root" class="z-30">
278
+ <!-- after <Modal/> component is shown it's rettached to above div
279
+ see: modal.svelte afterUpdate -->
280
+ </div>
281
+
282
+ </section>
253
283
 
254
-
255
-
256
- <!--###########################################################-->
257
- <!--## BOTTOM SIDEBAR ###############################-->
258
- <!--###########################################################-->
259
-
260
- <div class="{bottom_bar_visibility} left-0 bottom-0 w-screen h-[240px] z-20 overflow-y-hidden overflow-x-auto
261
- sm:left-[40px] sm:w-[100vw-40px] " >
262
- <Configurable config={layout.selectionDetails} >
263
- <div slot="alt"></div>
264
- </Configurable>
265
-
266
- </div>
267
-
268
- <!-- #########################################################-->
269
- <!-- ## MODAL DIALOG #########################################-->
270
- <!-- #########################################################-->
271
- <div id="__hd_svelte_modal_root" class="z-30">
272
- <!-- after <Modal/> component is shown it's rettached to above div
273
- see: modal.svelte afterUpdate -->
274
- </div>
275
-
276
- </section>
277
-
284
+ </div>
278
285
  </div>
279
- </div>
280
- </AuthorizedView>
286
+ {/key}
287
+ <!--/AuthorizedView-->
281
288
 
282
289
  <style>#__hd_svelte_layout_root {
283
290
  /* width */
@@ -1,15 +1,6 @@
1
1
  <script>
2
- import FaMoon from 'svelte-icons/fa/FaMoon.svelte'
3
- import FaSun from 'svelte-icons/fa/FaSun.svelte'
4
- import FaEllipsisH from 'svelte-icons/fa/FaEllipsisH.svelte'
5
- import FaCog from 'svelte-icons/fa/FaCog.svelte'
6
- import FaTools from 'svelte-icons/fa/FaTools.svelte'
7
- import GoPrimitiveDot from 'svelte-icons/go/GoPrimitiveDot.svelte'
8
- import FaSignInAlt from 'svelte-icons/fa/FaSignInAlt.svelte'
9
- import FaSignOutAlt from 'svelte-icons/fa/FaSignOutAlt.svelte'
10
- import FaBars from 'svelte-icons/fa/FaBars.svelte'
11
- import FaToggleOn from 'svelte-icons/fa/FaToggleOn.svelte'
12
- import FaToggleOff from 'svelte-icons/fa/FaToggleOff.svelte'
2
+ import {FaUsers, FaCog, FaSignInAlt, FaSignOutAlt, FaBars, FaToggleOn, FaToggleOff} from 'svelte-icons/fa/'
3
+ //import GoPrimitiveDot from 'svelte-icons/go/GoPrimitiveDot.svelte'
13
4
  import {showMenu} from './components/menu'
14
5
  import {push} from 'svelte-spa-router'
15
6
  import {contextItemsStore, context_info_store, contextToolbarOperations, data_tick_store} from './stores.js'
@@ -25,12 +16,9 @@
25
16
  previously_visible_sidebar,
26
17
  main_sidebar_visible_store,
27
18
  sidebar_left_pos,
28
-
29
19
  page_title,
30
-
31
- nav_titles
32
-
33
-
20
+ nav_titles,
21
+ reloadWholeApp
34
22
  } from "./stores.js";
35
23
  import Icon from './components/icon.svelte';
36
24
  import {session, signInHRef, signOutHRef} from '@humandialog/auth.svelte'
@@ -50,6 +38,7 @@
50
38
  let is_logged_in = false;
51
39
  let sign_in_href = '';
52
40
  let sign_out_href = '';
41
+ let user_is_in_multiple_groups = false;
53
42
 
54
43
  let tabs = [];
55
44
  let icon;
@@ -64,6 +53,7 @@
64
53
  show_sign_in_out_icons = config.signin ? true : false;
65
54
  sign_in_href = $signInHRef;
66
55
  sign_out_href = $signOutHRef;
56
+ user_is_in_multiple_groups = $session.tenants.length > 1
67
57
 
68
58
  tabs = Object.keys(appConfig.sidebar);
69
59
  if(tabs.length > 1)
@@ -213,6 +203,36 @@
213
203
  showMenu(pt, options);
214
204
  }
215
205
 
206
+ function show_groups(e)
207
+ {
208
+ let owner = e.target;
209
+ while(owner && owner.tagName != 'BUTTON')
210
+ owner = owner.parentElement
211
+
212
+ if(!owner)
213
+ return;
214
+
215
+ let rect = owner.getBoundingClientRect();
216
+ let options = [];
217
+
218
+ $session.tenants.forEach(tInfo =>
219
+ options.push({
220
+ caption: tInfo.name,
221
+ icon: FaUsers,
222
+ disabled: tInfo.id == $session.tid,
223
+ action: (f) => {
224
+ $session.setCurrentTenantAPI(tInfo.url, tInfo.id)
225
+ push('/')
226
+ reloadWholeApp();
227
+ }
228
+ })
229
+ )
230
+
231
+
232
+ let pt = new DOMPoint(rect.left, rect.bottom)
233
+ showMenu(pt, options);
234
+ }
235
+
216
236
  function clearSelection()
217
237
  {
218
238
  if (!clearsContext) return;
@@ -244,7 +264,14 @@
244
264
  <div class="block sm:hidden mt-4 sm:mt-3 uppercase text-sm text-center">{@html title}</div>
245
265
  </div>
246
266
 
247
- <div class="flex-none ml-auto flex h-12 sm:h-10">
267
+ <div class="flex-none ml-auto flex h-12 sm:h-10">
268
+ {#if user_is_in_multiple_groups}
269
+ <button class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
270
+ on:click|stopPropagation={show_groups}>
271
+ <Icon class="w-5 sm:w-4 h-5 sm:h-4" component={FaUsers} />
272
+ </button>
273
+ {/if}
274
+
248
275
  <button
249
276
  class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
250
277
  on:click|stopPropagation={show_options}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "0.6.1",
3
+ "version": "1.1.0",
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.5.5",
29
+ "@humandialog/auth.svelte": "^1.8.0",
30
30
  "flowbite-svelte": "^0.44.4",
31
31
  "svelte-icons": "^2.1.0",
32
32
  "svelte-spa-router": "^4.0.1"
package/page.svelte.d.ts CHANGED
@@ -4,15 +4,15 @@
4
4
  export default class Page extends SvelteComponentTyped<{
5
5
  [x: string]: any;
6
6
  self?: null | undefined;
7
- clearsContext?: string | undefined;
7
+ title?: string | undefined;
8
8
  context?: string | undefined;
9
+ typename?: string | undefined;
9
10
  c?: string | undefined;
11
+ clearsContext?: string | undefined;
10
12
  cl?: string | undefined;
11
- typename?: string | undefined;
12
13
  focused_only?: boolean | undefined;
13
14
  inContext?: string | undefined;
14
15
  toolbarOperations?: any;
15
- title?: string | undefined;
16
16
  }, {
17
17
  [evt: string]: CustomEvent<any>;
18
18
  }, {
@@ -27,15 +27,15 @@ declare const __propDef: {
27
27
  props: {
28
28
  [x: string]: any;
29
29
  self?: null | undefined;
30
- clearsContext?: string | undefined;
30
+ title?: string | undefined;
31
31
  context?: string | undefined;
32
+ typename?: string | undefined;
32
33
  c?: string | undefined;
34
+ clearsContext?: string | undefined;
33
35
  cl?: string | undefined;
34
- typename?: string | undefined;
35
36
  focused_only?: boolean | undefined;
36
37
  inContext?: string | undefined;
37
38
  toolbarOperations?: any;
38
- title?: string | undefined;
39
39
  };
40
40
  events: {
41
41
  [evt: string]: CustomEvent<any>;
package/stores.d.ts CHANGED
@@ -2,6 +2,7 @@ export function setNavigatorTitle(key: any, title: any): void;
2
2
  export function hasSelectedItem(): boolean;
3
3
  export function hasDataItem(): boolean;
4
4
  export function reloadMainContentPage(): void;
5
+ export function reloadWholeApp(): void;
5
6
  export function set_dark_mode_default(value: any): void;
6
7
  export function set_default_tools_visible(value: any): void;
7
8
  export function restore_defults(): void;
@@ -29,6 +30,7 @@ export const pageToolbarOperations: import("svelte/store").Writable<never[]>;
29
30
  export const page_title: import("svelte/store").Writable<string>;
30
31
  export const nav_titles: import("svelte/store").Writable<{}>;
31
32
  export const mainContentPageReloader: import("svelte/store").Writable<number>;
33
+ export const wholeAppReloader: import("svelte/store").Writable<number>;
32
34
  export const dark_mode_store: import("svelte/store").Writable<any>;
33
35
  export const main_sidebar_visible_store: import("svelte/store").Writable<any>;
34
36
  export let previously_visible_sidebar: string;
package/stores.js CHANGED
@@ -11,6 +11,7 @@ export const pageToolbarOperations = writable([]);
11
11
  export const page_title = writable('');
12
12
  export const nav_titles = writable({});
13
13
  export const mainContentPageReloader = writable(1);
14
+ export const wholeAppReloader = writable(1)
14
15
 
15
16
  export function setNavigatorTitle(key, title)
16
17
  {
@@ -38,6 +39,13 @@ export function reloadMainContentPage()
38
39
  mainContentPageReloader.set(val);
39
40
  }
40
41
 
42
+ export function reloadWholeApp()
43
+ {
44
+ let val = get(wholeAppReloader);
45
+ val += 1;
46
+ wholeAppReloader.set(val);
47
+ }
48
+
41
49
 
42
50
  let has_saved_dark_mode = false;
43
51
  function create_dark_mode_store()