@humandialog/forms.svelte 0.4.8 → 0.4.9
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/components/Floating_container.svelte +5 -3
- package/components/Grid.menu.svelte +6 -5
- package/components/Grid.menu.svelte.d.ts +2 -0
- package/components/menu.js +4 -3
- package/desk.svelte +24 -2
- package/operations.svelte +6 -1
- package/package.json +1 -1
- package/stores.d.ts +2 -0
- package/stores.js +41 -7
|
@@ -27,8 +27,10 @@ function focus_first_element() {
|
|
|
27
27
|
console.log(focusable);
|
|
28
28
|
focusable.focus();
|
|
29
29
|
}
|
|
30
|
-
function on_focus_out() {
|
|
31
|
-
|
|
30
|
+
function on_focus_out(e) {
|
|
31
|
+
if (e.relatedTarget && root_element?.contains(e.relatedTarget)) {
|
|
32
|
+
} else
|
|
33
|
+
hide();
|
|
32
34
|
}
|
|
33
35
|
</script>
|
|
34
36
|
|
|
@@ -38,6 +40,6 @@ function on_focus_out() {
|
|
|
38
40
|
on:focusout={on_focus_out}
|
|
39
41
|
bind:this={root_element}>
|
|
40
42
|
<button class="w-0 h-0 fixed bg-transparent " bind:this={invisible_button}></button>
|
|
41
|
-
<svelte:component this={toolbar} {...props}/>
|
|
43
|
+
<svelte:component this={toolbar} {...props} hide={() => hide()}/>
|
|
42
44
|
</div>
|
|
43
45
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {context_items_store} from '..'
|
|
3
3
|
|
|
4
4
|
export let operations = []
|
|
5
|
-
|
|
6
|
-
$: grid_cols = init(operations);
|
|
5
|
+
export let hide = undefined;
|
|
7
6
|
|
|
7
|
+
$: grid_cols = init(operations);
|
|
8
8
|
|
|
9
9
|
function init(operations)
|
|
10
10
|
{
|
|
@@ -94,7 +94,9 @@
|
|
|
94
94
|
|
|
95
95
|
function execute_action(e, operation)
|
|
96
96
|
{
|
|
97
|
-
|
|
97
|
+
if(hide != undefined)
|
|
98
|
+
hide();
|
|
99
|
+
|
|
98
100
|
if(!operation)
|
|
99
101
|
return;
|
|
100
102
|
|
|
@@ -105,7 +107,6 @@
|
|
|
105
107
|
if($context_items_store.focused)
|
|
106
108
|
context_item = $context_items_store[$context_items_store.focused]
|
|
107
109
|
|
|
108
|
-
|
|
109
110
|
operation.action(context_item);
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -119,7 +120,7 @@
|
|
|
119
120
|
|
|
120
121
|
<button class=" py-2.5 px-5 {col}
|
|
121
122
|
text-xs font-medium text-gray-900 dark:text-gray-400 dark:hover:text-white
|
|
122
|
-
bg-slate-100 hover:bg-slate-200 dark:bg-gray-800 dark:hover:bg-gray-700
|
|
123
|
+
bg-slate-100 hover:bg-slate-200 dark:bg-gray-800 dark:hover:bg-gray-700 active:bg-slate-300 dark:active:bg-gray-600
|
|
123
124
|
border rounded border-gray-200 dark:border-gray-600 focus:outline-none
|
|
124
125
|
inline-flex items-center justify-center"
|
|
125
126
|
on:click={(e) => {execute_action(e, operation)}}>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} GridEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} GridSlots */
|
|
4
4
|
export default class Grid extends SvelteComponentTyped<{
|
|
5
|
+
hide?: any;
|
|
5
6
|
operations?: any[] | undefined;
|
|
6
7
|
}, {
|
|
7
8
|
[evt: string]: CustomEvent<any>;
|
|
@@ -13,6 +14,7 @@ export type GridSlots = typeof __propDef.slots;
|
|
|
13
14
|
import { SvelteComponentTyped } from "svelte";
|
|
14
15
|
declare const __propDef: {
|
|
15
16
|
props: {
|
|
17
|
+
hide?: any;
|
|
16
18
|
operations?: any[] | undefined;
|
|
17
19
|
};
|
|
18
20
|
events: {
|
package/components/menu.js
CHANGED
|
@@ -6,8 +6,9 @@ let toolbar_component = null;
|
|
|
6
6
|
export function show_menu(x, y, operations) {
|
|
7
7
|
let menu_element = document.getElementById("__hd_svelte_contextmenu");
|
|
8
8
|
if (!!!menu_element) {
|
|
9
|
+
let app_div = document.getElementById("__hd_svelte_layout_root");
|
|
9
10
|
menu_comopnent = new Menu({
|
|
10
|
-
target:
|
|
11
|
+
target: app_div,
|
|
11
12
|
props: {}
|
|
12
13
|
});
|
|
13
14
|
menu_comopnent.show(x, y, operations);
|
|
@@ -20,8 +21,9 @@ export function show_menu(x, y, operations) {
|
|
|
20
21
|
export function show_floating_toolbar(x, y, toolbar, props = {}) {
|
|
21
22
|
let floating_container = document.getElementById("__hd_svelte_floating_container");
|
|
22
23
|
if (!!!floating_container) {
|
|
24
|
+
let app_div = document.getElementById("__hd_svelte_layout_root");
|
|
23
25
|
toolbar_component = new Floating_container({
|
|
24
|
-
target:
|
|
26
|
+
target: app_div,
|
|
25
27
|
props: {}
|
|
26
28
|
});
|
|
27
29
|
toolbar_component.show(x, y, toolbar, props);
|
|
@@ -32,6 +34,5 @@ export function show_floating_toolbar(x, y, toolbar, props = {}) {
|
|
|
32
34
|
console.error('what now?');
|
|
33
35
|
}
|
|
34
36
|
export function show_grid_menu(x, y, operations) {
|
|
35
|
-
console.log('show_grid_menu', operations);
|
|
36
37
|
show_floating_toolbar(x, y, Grid, { operations: operations });
|
|
37
38
|
}
|
package/desk.svelte
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
auto_hide_sidebar,
|
|
12
12
|
has_selected_item,
|
|
13
13
|
dark_mode_store,
|
|
14
|
-
data_tick_store
|
|
14
|
+
data_tick_store,
|
|
15
|
+
set_default_tools_visible,
|
|
16
|
+
set_dark_mode_default } from './stores.js'
|
|
15
17
|
|
|
16
18
|
import {session, AuthorizedView, Authorized, NotAuthorized, Auth} from '@humandialog/auth.svelte'
|
|
17
19
|
|
|
@@ -23,6 +25,26 @@
|
|
|
23
25
|
let lg_content_area_horizontal_dim = ""
|
|
24
26
|
|
|
25
27
|
let visible_sidebar = "*"
|
|
28
|
+
|
|
29
|
+
if(layout.dark != undefined)
|
|
30
|
+
{
|
|
31
|
+
console.log('layout.dark', layout.dark)
|
|
32
|
+
|
|
33
|
+
if(layout.dark.optional)
|
|
34
|
+
layout.mainToolbar.darkMode = true;
|
|
35
|
+
|
|
36
|
+
if(layout.dark.default)
|
|
37
|
+
set_dark_mode_default(layout.dark.default)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if(layout.operations != undefined)
|
|
41
|
+
{
|
|
42
|
+
if(layout.operations.optional)
|
|
43
|
+
layout.mainToolbar.operations = true;
|
|
44
|
+
|
|
45
|
+
if(layout.operations.default)
|
|
46
|
+
set_default_tools_visible(layout.operations.default)
|
|
47
|
+
}
|
|
26
48
|
|
|
27
49
|
$: { visible_sidebar = $main_sidebar_visible_store
|
|
28
50
|
|
|
@@ -113,7 +135,7 @@
|
|
|
113
135
|
<svelte:window bind:innerWidth bind:outerWidth bind:innerHeight bind:outerHeight />
|
|
114
136
|
|
|
115
137
|
<AuthorizedView>
|
|
116
|
-
<div class="{$dark_mode_store}">
|
|
138
|
+
<div id="__hd_svelte_layout_root" class="{$dark_mode_store}">
|
|
117
139
|
<div class="bg-white dark:bg-gray-900 dark:text-white min-h-screen h-screen">
|
|
118
140
|
<!--###########################################################-->
|
|
119
141
|
<!--## HORIZONTAL TOOLBAR (FOR PHONES) ######################-->
|
package/operations.svelte
CHANGED
|
@@ -37,7 +37,12 @@ function on_click(e, operation) {
|
|
|
37
37
|
<div class="bg-slate-100 w-full h-10 dark:bg-slate-800 overflow-x-clip overflow-y-hidden py-0 text-xs flex flex-row">
|
|
38
38
|
|
|
39
39
|
{#each operations as operation}
|
|
40
|
-
<button type="button"
|
|
40
|
+
<button type="button"
|
|
41
|
+
class="py-2.5 px-5
|
|
42
|
+
text-xs font-medium text-gray-900 dark:text-gray-400 dark:hover:text-white
|
|
43
|
+
bg-slate-100 hover:bg-slate-200 dark:bg-gray-800 dark:hover:bg-gray-700 active:bg-slate-300 dark:active:bg-gray-600
|
|
44
|
+
border-r border-gray-200 focus:outline-none dark:border-gray-600
|
|
45
|
+
inline-flex items-center"
|
|
41
46
|
on:click={(e) => {on_click(e, operation)}}>
|
|
42
47
|
<div class="w-3 h-3"><svelte:component this={operation.icon}/></div>
|
|
43
48
|
<span class="ml-1">{operation.caption}</span>
|
package/package.json
CHANGED
package/stores.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export function has_selected_item(): boolean;
|
|
2
2
|
export function has_data_item(): boolean;
|
|
3
|
+
export function set_dark_mode_default(value: any): void;
|
|
4
|
+
export function set_default_tools_visible(value: any): void;
|
|
3
5
|
export function restore_defults(): void;
|
|
4
6
|
export function toggle_sidebar(index: any): void;
|
|
5
7
|
export function auto_hide_sidebar(): void;
|
package/stores.js
CHANGED
|
@@ -21,19 +21,53 @@ export function has_data_item()
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
let has_saved_dark_mode = false;
|
|
25
|
+
function create_dark_mode_store()
|
|
26
|
+
{
|
|
27
|
+
if(localStorage.dark_mode != undefined)
|
|
28
|
+
has_saved_dark_mode = true;
|
|
29
|
+
else
|
|
30
|
+
has_saved_dark_mode = false;
|
|
31
|
+
|
|
32
|
+
return writable( (localStorage.dark_mode) || '')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const dark_mode_store = create_dark_mode_store();
|
|
25
36
|
dark_mode_store.subscribe( (value) => { localStorage.dark_mode = value } );
|
|
26
37
|
|
|
27
|
-
export
|
|
28
|
-
|
|
38
|
+
export function set_dark_mode_default(value)
|
|
39
|
+
{
|
|
40
|
+
if(!has_saved_dark_mode)
|
|
41
|
+
dark_mode_store.set(value ? 'dark' : '')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const main_sidebar_visible_store = writable((localStorage.main_sidebar_visible_store) || '*');
|
|
45
|
+
main_sidebar_visible_store.subscribe( (value) => { localStorage.main_sidebar_visible_store = value });
|
|
29
46
|
|
|
30
47
|
export let previously_visible_sidebar = "";
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
let has_saved_tools_visible = false;
|
|
50
|
+
function create_tools_visible_store()
|
|
51
|
+
{
|
|
52
|
+
if(localStorage.tools_visible_store != undefined)
|
|
53
|
+
has_saved_tools_visible = true;
|
|
54
|
+
else
|
|
55
|
+
has_saved_tools_visible = false;
|
|
56
|
+
|
|
57
|
+
return writable ((localStorage.tools_visible_store && localStorage.tools_visible_store == 'true') || false);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const tools_visible_store = create_tools_visible_store();
|
|
61
|
+
tools_visible_store.subscribe( (value) => { localStorage.tools_visible_store = (value ? 'true' : '') } );
|
|
62
|
+
|
|
63
|
+
export function set_default_tools_visible(value)
|
|
64
|
+
{
|
|
65
|
+
if(!has_saved_tools_visible)
|
|
66
|
+
tools_visible_store.set(value)
|
|
67
|
+
}
|
|
34
68
|
|
|
35
|
-
export const bottom_bar_visible_store = writable( (
|
|
36
|
-
bottom_bar_visible_store.subscribe( (value) => {
|
|
69
|
+
export const bottom_bar_visible_store = writable( (localStorage.bottom_bar_visible_store && localStorage.bottom_bar_visible_store == 'true') || false);
|
|
70
|
+
bottom_bar_visible_store.subscribe( (value) => { localStorage.bottom_bar_visible_store = (value ? 'true' : '') } );
|
|
37
71
|
|
|
38
72
|
export const right_sidebar_visible_store = writable(false)
|
|
39
73
|
export const visible_property_tab_store = writable('');
|