@humandialog/forms.svelte 0.3.4 → 0.4.1

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.
Files changed (41) hide show
  1. package/README.md +30 -17
  2. package/components/Fab.svelte +82 -0
  3. package/components/Fab.svelte.d.ts +14 -0
  4. package/components/combo/combo.svelte +1 -1
  5. package/components/contextmenu.svelte +188 -0
  6. package/components/contextmenu.svelte.d.ts +24 -0
  7. package/components/delayed.spinner.svelte +18 -0
  8. package/components/delayed.spinner.svelte.d.ts +16 -0
  9. package/components/document/internal/palette.row.svelte +1 -1
  10. package/components/file.loader.svelte +1 -1
  11. package/{icon.svelte → components/icon.svelte} +1 -6
  12. package/components/inputbox.ltop.svelte.d.ts +4 -4
  13. package/components/menu.d.ts +1 -0
  14. package/components/menu.js +16 -0
  15. package/components/simple.table.svelte.d.ts +4 -4
  16. package/components/table/_template.table.svelte.d.ts +4 -4
  17. package/components/table/table.svelte +19 -2
  18. package/components/table/table.svelte.d.ts +2 -0
  19. package/components/textarea.ltop.svelte.d.ts +2 -2
  20. package/components/tile.title.svelte.d.ts +2 -2
  21. package/desk.svelte +202 -0
  22. package/desk.svelte.d.ts +23 -0
  23. package/horizontal.toolbar.svelte +150 -0
  24. package/horizontal.toolbar.svelte.d.ts +23 -0
  25. package/index.d.ts +9 -1
  26. package/index.js +9 -1
  27. package/internal/configurable.content.svelte +81 -0
  28. package/internal/configurable.content.svelte.d.ts +27 -0
  29. package/internal/loading.svelte +6 -0
  30. package/internal/loading.svelte.d.ts +23 -0
  31. package/operations.svelte +35 -0
  32. package/operations.svelte.d.ts +14 -0
  33. package/package.json +19 -4
  34. package/page.svelte +34 -12
  35. package/page.svelte.d.ts +4 -0
  36. package/stores.d.ts +15 -0
  37. package/stores.js +72 -1
  38. package/vertical.toolbar.svelte +146 -0
  39. package/vertical.toolbar.svelte.d.ts +23 -0
  40. package/LICENSE +0 -21
  41. /package/{icon.svelte.d.ts → components/icon.svelte.d.ts} +0 -0
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "0.3.4",
3
+ "version": "0.4.1",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
7
7
  "@sveltejs/adapter-auto": "^1.0.0-next.90",
8
8
  "@sveltejs/kit": "^1.0.0-next.587",
9
9
  "@sveltejs/package": "^1.0.0-next.6",
10
+ "@tailwindcss/typography": "^0.5.10",
10
11
  "@typescript-eslint/eslint-plugin": "^5.45.0",
11
12
  "@typescript-eslint/parser": "^5.45.0",
13
+ "autoprefixer": "^10.4.15",
12
14
  "eslint": "^8.28.0",
13
15
  "eslint-config-prettier": "^8.5.0",
14
16
  "eslint-plugin-svelte3": "^4.0.0",
17
+ "postcss": "^8.4.29",
15
18
  "prettier": "^2.8.0",
16
19
  "prettier-plugin-svelte": "^2.8.1",
17
20
  "svelte": "^3.54.0",
18
21
  "svelte-check": "^2.9.2",
22
+ "tailwindcss": "^3.3.3",
19
23
  "tslib": "^2.4.1",
20
24
  "typescript": "^4.9.3",
21
25
  "vite": "^4.0.0"
@@ -24,7 +28,8 @@
24
28
  "dependencies": {
25
29
  "@humandialog/auth.svelte": "^1.0.2",
26
30
  "flowbite-svelte": "^0.29.13",
27
- "svelte-icons": "^2.1.0"
31
+ "svelte-icons": "^2.1.0",
32
+ "svelte-spa-router": "^3.3.0"
28
33
  },
29
34
  "keywords": [
30
35
  "svelte",
@@ -52,7 +57,9 @@
52
57
  "./components/combo/combo.source.svelte": "./components/combo/combo.source.svelte",
53
58
  "./components/combo/combo.svelte": "./components/combo/combo.svelte",
54
59
  "./components/combo/combo": "./components/combo/combo.js",
60
+ "./components/contextmenu.svelte": "./components/contextmenu.svelte",
55
61
  "./components/date.svelte": "./components/date.svelte",
62
+ "./components/delayed.spinner.svelte": "./components/delayed.spinner.svelte",
56
63
  "./components/document/internal/Document_command": "./components/document/internal/Document_command.js",
57
64
  "./components/document/internal/palette.row.svelte": "./components/document/internal/palette.row.svelte",
58
65
  "./components/document/internal/palette.svelte": "./components/document/internal/palette.svelte",
@@ -60,9 +67,12 @@
60
67
  "./components/document/internal/Selection_range": "./components/document/internal/Selection_range.js",
61
68
  "./components/document/rich.edit.svelte": "./components/document/rich.edit.svelte",
62
69
  "./components/edit.field.svelte": "./components/edit.field.svelte",
70
+ "./components/Fab.svelte": "./components/Fab.svelte",
63
71
  "./components/file.loader.svelte": "./components/file.loader.svelte",
72
+ "./components/icon.svelte": "./components/icon.svelte",
64
73
  "./components/input.text.svelte": "./components/input.text.svelte",
65
74
  "./components/inputbox.ltop.svelte": "./components/inputbox.ltop.svelte",
75
+ "./components/menu": "./components/menu.js",
66
76
  "./components/radio.svelte": "./components/radio.svelte",
67
77
  "./components/simple.table.svelte": "./components/simple.table.svelte",
68
78
  "./components/table/column.svelte": "./components/table/column.svelte",
@@ -71,9 +81,13 @@
71
81
  "./components/table/table": "./components/table/table.js",
72
82
  "./components/textarea.ltop.svelte": "./components/textarea.ltop.svelte",
73
83
  "./components/tile.title.svelte": "./components/tile.title.svelte",
84
+ "./desk.svelte": "./desk.svelte",
74
85
  "./form.box.svelte": "./form.box.svelte",
75
- "./icon.svelte": "./icon.svelte",
86
+ "./horizontal.toolbar.svelte": "./horizontal.toolbar.svelte",
76
87
  ".": "./index.js",
88
+ "./internal/configurable.content.svelte": "./internal/configurable.content.svelte",
89
+ "./internal/loading.svelte": "./internal/loading.svelte",
90
+ "./operations.svelte": "./operations.svelte",
77
91
  "./page.row.svelte": "./page.row.svelte",
78
92
  "./page.svelte": "./page.svelte",
79
93
  "./stores": "./stores.js",
@@ -81,7 +95,8 @@
81
95
  "./tiles.row.svelte": "./tiles.row.svelte",
82
96
  "./tiles.vertical.row.svelte": "./tiles.vertical.row.svelte",
83
97
  "./updates": "./updates.js",
84
- "./utils": "./utils.js"
98
+ "./utils": "./utils.js",
99
+ "./vertical.toolbar.svelte": "./vertical.toolbar.svelte"
85
100
  },
86
101
  "svelte": "./index.js"
87
102
  }
package/page.svelte CHANGED
@@ -1,4 +1,14 @@
1
1
  <script>
2
+ import { setContext, onMount } from 'svelte';
3
+ import {
4
+ context_items_store,
5
+ data_tick_store,
6
+ context_types_store,
7
+ context_info_store,
8
+ context_toolbar_operations,
9
+ page_toolbar_operations } from './stores.js'
10
+
11
+
2
12
  export let context = "data"
3
13
  export let self = null
4
14
  export let typename = '';
@@ -7,17 +17,11 @@
7
17
  export let cl =
8
18
  "w-full h-full flex flex-col dark:bg-slate-800 overflow-y-hidden overflow-x-hidden py-1 px-1 border-0" // border-green-500
9
19
  export let c = ''
10
- import {
11
- writable
12
- } from 'svelte/store';
13
- import {
14
- setContext
15
- } from 'svelte';
16
- import {
17
- context_items_store,
18
- data_tick_store,
19
- context_types_store
20
- } from './stores.js'
20
+
21
+ export let toolbar_operations = [];
22
+ export let clears_context = '';
23
+
24
+
21
25
  switch (c) {
22
26
  case 'main':
23
27
  cl = "w-full h-full flex flex-col dark:bg-slate-800 overflow-y-hidden overflow-x-hidden py-1 px-1 border-0"
@@ -28,6 +32,12 @@
28
32
  default:
29
33
  //NOP
30
34
  }
35
+
36
+ onMount(() => {
37
+ $page_toolbar_operations = [...toolbar_operations]
38
+ return () => { $page_toolbar_operations = [] }
39
+ })
40
+
31
41
  setContext('ctx', context)
32
42
  let item = null;
33
43
  let visibilty = "hidden"
@@ -74,9 +84,21 @@
74
84
  //console.log("--------------")
75
85
  }
76
86
  }
87
+
88
+ function clear_selection(e)
89
+ {
90
+ if(!clears_context)
91
+ return;
92
+
93
+ e.stopPropagation();
94
+ $context_items_store[clears_context] = null;
95
+ $context_info_store[clears_context] = '';
96
+ $context_toolbar_operations = [];
97
+ $data_tick_store = $data_tick_store + 1;
98
+ }
77
99
  </script>
78
100
 
79
- <div class="{visibilty} {cl} bg-slate-100 dark:bg-slate-800 ">
101
+ <div class="bg-slate-100 dark:bg-slate-800 {visibilty} {cl}" on:click={clear_selection}>
80
102
  {#if visibilty == "" }
81
103
  <slot/>
82
104
  {/if}
package/page.svelte.d.ts CHANGED
@@ -9,6 +9,8 @@ export default class Page extends SvelteComponentTyped<{
9
9
  typename?: string | undefined;
10
10
  focused_only?: boolean | undefined;
11
11
  in_context?: string | undefined;
12
+ toolbar_operations?: any[] | undefined;
13
+ clears_context?: string | undefined;
12
14
  }, {
13
15
  [evt: string]: CustomEvent<any>;
14
16
  }, {
@@ -28,6 +30,8 @@ declare const __propDef: {
28
30
  typename?: string | undefined;
29
31
  focused_only?: boolean | undefined;
30
32
  in_context?: string | undefined;
33
+ toolbar_operations?: any[] | undefined;
34
+ clears_context?: string | undefined;
31
35
  };
32
36
  events: {
33
37
  [evt: string]: CustomEvent<any>;
package/stores.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ export function has_selected_item(): boolean;
2
+ export function has_data_item(): boolean;
3
+ export function restore_defults(): void;
4
+ export function toggle_sidebar(index: any): void;
5
+ export function auto_hide_sidebar(): void;
6
+ export function hide_sidebar(): void;
7
+ export function show_sidebar(index: any): void;
1
8
  export const data_tick_store: import("svelte/store").Writable<number>;
2
9
  export const context_items_store: import("svelte/store").Writable<{
3
10
  focused: string;
@@ -13,3 +20,11 @@ export const context_types_store: import("svelte/store").Writable<{
13
20
  data: null;
14
21
  sel: null;
15
22
  }>;
23
+ export const context_toolbar_operations: import("svelte/store").Writable<never[]>;
24
+ export const page_toolbar_operations: import("svelte/store").Writable<never[]>;
25
+ export const dark_mode_store: import("svelte/store").Writable<any>;
26
+ export const main_sidebar_visible_store: import("svelte/store").Writable<any>;
27
+ export const tools_visible_store: import("svelte/store").Writable<any>;
28
+ export const bottom_bar_visible_store: import("svelte/store").Writable<any>;
29
+ export const right_sidebar_visible_store: import("svelte/store").Writable<boolean>;
30
+ export const visible_property_tab_store: import("svelte/store").Writable<string>;
package/stores.js CHANGED
@@ -4,4 +4,75 @@ import {writable, get} from 'svelte/store';
4
4
  export const data_tick_store = writable(1);
5
5
  export const context_items_store = writable({focused:'', data: null, sel: null})
6
6
  export const context_info_store = writable({data: '', sel: ''})
7
- export const context_types_store = writable({focused:'', data: null, sel: null})
7
+ export const context_types_store = writable({focused:'', data: null, sel: null})
8
+ export const context_toolbar_operations = writable([]);
9
+ export const page_toolbar_operations = writable([]);
10
+
11
+ export function has_selected_item()
12
+ {
13
+ let itm = get(context_items_store).sel
14
+ return itm !== null && itm !== undefined;
15
+ }
16
+
17
+ export function has_data_item()
18
+ {
19
+ let itm = get(context_items_store).data
20
+ return itm !== null && itm !== undefined;
21
+ }
22
+
23
+
24
+ export const dark_mode_store = writable( localStorage.dark_mode || '')
25
+ dark_mode_store.subscribe( (value) => { localStorage.dark_mode = value } );
26
+
27
+ export const main_sidebar_visible_store = writable(sessionStorage.main_sidebar_visible_store || '*');
28
+ main_sidebar_visible_store.subscribe( (value) => { sessionStorage.main_sidebar_visible_store = value });
29
+
30
+ export const tools_visible_store = writable ((sessionStorage.tools_visible_store && sessionStorage.tools_visible_store == 'true') || false);
31
+ tools_visible_store.subscribe( (value) => { sessionStorage.tools_visible_store = (value ? 'true' : '') } );
32
+
33
+ export const bottom_bar_visible_store = writable( (sessionStorage.bottom_bar_visible_store && sessionStorage.bottom_bar_visible_store == 'true') || false);
34
+ bottom_bar_visible_store.subscribe( (value) => { sessionStorage.bottom_bar_visible_store = (value ? 'true' : '') } );
35
+
36
+ export const right_sidebar_visible_store = writable(false)
37
+ export const visible_property_tab_store = writable('');
38
+
39
+ export function restore_defults()
40
+ {
41
+ main_sidebar_visible_store.set('*');
42
+ tools_visible_store.set(false);
43
+ bottom_bar_visible_store.set(false);
44
+ right_sidebar_visible_store.set(false);
45
+ visible_property_tab_store.set('');
46
+ }
47
+
48
+ export function toggle_sidebar(index)
49
+ {
50
+ //console.log("ts: " + index)
51
+ if(get(main_sidebar_visible_store) == index)
52
+ main_sidebar_visible_store.set('*')
53
+ else
54
+ main_sidebar_visible_store.set(index)
55
+ }
56
+
57
+ export function auto_hide_sidebar()
58
+ {
59
+ // console.log("sw: " + screen.width)
60
+
61
+ if(screen.width < 1024)
62
+ hide_sidebar()
63
+ }
64
+
65
+ export function hide_sidebar()
66
+ {
67
+ main_sidebar_visible_store.set('*')
68
+ //console.log("auto_hide_sidebar:" + get(main_sidebar_visible_store))
69
+ }
70
+
71
+ export function show_sidebar(index)
72
+ {
73
+ //console.log('show_sidebar:', index);
74
+ main_sidebar_visible_store.set(index)
75
+ }
76
+
77
+
78
+
@@ -0,0 +1,146 @@
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 FaTools from 'svelte-icons/fa/FaTools.svelte'
6
+ import GoPrimitiveDot from 'svelte-icons/go/GoPrimitiveDot.svelte'
7
+ import FaSignInAlt from 'svelte-icons/fa/FaSignInAlt.svelte'
8
+ import FaSignOutAlt from 'svelte-icons/fa/FaSignOutAlt.svelte'
9
+
10
+ import {dark_mode_store,
11
+ toggle_sidebar,
12
+ show_sidebar,
13
+ hide_sidebar,
14
+ tools_visible_store,
15
+ bottom_bar_visible_store,
16
+ right_sidebar_visible_store,
17
+ main_sidebar_visible_store} from "./stores.js";
18
+ import Icon from './components/icon.svelte';
19
+ import {session, signin_href, signout_href} from '@humandialog/auth.svelte'
20
+
21
+ export let app_config;
22
+
23
+
24
+ let tabs = new Array();
25
+ let config = null;
26
+ let has_selection_details = false;
27
+
28
+ let show_sign_in_out_icons = false;
29
+ let is_logged_in = false;
30
+ let sign_in_href = '';
31
+ let sign_out_href = '';
32
+
33
+ $:{
34
+ config = app_config.mainToolbar;
35
+ has_selection_details = app_config.selectionDetails;
36
+ is_logged_in = $session.is_active;
37
+ show_sign_in_out_icons = app_config.auth ? true : false;
38
+ sign_in_href = $signin_href;
39
+ sign_out_href = $signout_href;
40
+
41
+ tabs = new Array();
42
+
43
+ Object.keys(app_config.sidebar).forEach( (key) =>
44
+ {
45
+ const ctab = app_config.sidebar[key];
46
+ const can_show = (ctab.authorized && is_logged_in) || (!ctab.authorized)
47
+ if(can_show)
48
+ tabs.push({key: key, icon: ctab.icon});
49
+ });
50
+
51
+ // there is no current visible sidebar
52
+ if($main_sidebar_visible_store != '*')
53
+ {
54
+ if(tabs.every( (e) => e.key != $main_sidebar_visible_store))
55
+ {
56
+ if(tabs.length)
57
+ show_sidebar(tabs[0].key);
58
+ else
59
+ hide_sidebar();
60
+ }
61
+ }
62
+
63
+ }
64
+
65
+ </script>
66
+
67
+
68
+ <div class="px-0 w-10">
69
+ {#each tabs as tab}
70
+ <button
71
+ class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500"
72
+ class:text-blue-300={$main_sidebar_visible_store == tab.key}
73
+ on:click={()=> (toggle_sidebar(tab.key))}>
74
+
75
+ <Icon size={6} component={tab.icon}/>
76
+ </button>
77
+ {/each}
78
+ </div>
79
+
80
+ <div class="mt-auto h-auto items-center w-full">
81
+
82
+ {#if show_sign_in_out_icons }
83
+ {#if !is_logged_in}
84
+ <a href={sign_in_href} class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500">
85
+ <Icon size={6} component={FaSignInAlt}/>
86
+ </a>
87
+ {:else}
88
+ <a href={sign_out_href} class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500">
89
+ <Icon size={6} component={FaSignOutAlt}/>
90
+ </a>
91
+ {/if}
92
+ {/if}
93
+
94
+ {#if config && config.operations}
95
+ <button
96
+ class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500"
97
+ class:text-blue-300={$tools_visible_store}
98
+ on:click={()=> ($tools_visible_store = !$tools_visible_store)}
99
+ >
100
+
101
+ <Icon size={6} component={FaTools}/>
102
+ </button>
103
+ {/if}
104
+
105
+ {#if !config || config.darkMode }
106
+ {#if $dark_mode_store == ''}
107
+ <button
108
+ class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500"
109
+ on:click={()=> ($dark_mode_store = 'dark')}
110
+ >
111
+ <Icon size={6} component={FaMoon} />
112
+ </button>
113
+ {:else}
114
+ <button
115
+ class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500"
116
+ on:click={()=> ($dark_mode_store = '')}
117
+ >
118
+ <Icon size={6} component={FaSun} />
119
+
120
+ </button>
121
+ {/if}
122
+ {/if}
123
+
124
+ {#if !config || config.gotoRoot }
125
+ <a href='#/'>
126
+ <button
127
+ class="h-16 px-0 flex justify-center items-center w-full hover:bg-orange-500"
128
+ >
129
+ <Icon size={6} component={GoPrimitiveDot} />
130
+ </button>
131
+ </a>
132
+ {/if}
133
+
134
+ {#if has_selection_details}
135
+ <button
136
+ class="h-16 px-0 flex justify-center items-center w-full text-slate-200 hover:bg-orange-500"
137
+ class:text-blue-300={$bottom_bar_visible_store}
138
+ on:click={()=> ($bottom_bar_visible_store = !$bottom_bar_visible_store)}
139
+ >
140
+
141
+ <Icon size={6} component={FaEllipsisH} />
142
+ </button>
143
+ {/if}
144
+
145
+ </div>
146
+
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} VerticalProps */
2
+ /** @typedef {typeof __propDef.events} VerticalEvents */
3
+ /** @typedef {typeof __propDef.slots} VerticalSlots */
4
+ export default class Vertical extends SvelteComponentTyped<{
5
+ app_config: any;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type VerticalProps = typeof __propDef.props;
11
+ export type VerticalEvents = typeof __propDef.events;
12
+ export type VerticalSlots = typeof __propDef.slots;
13
+ import { SvelteComponentTyped } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ app_config: any;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 ObjectReef
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.