@humandialog/forms.svelte 0.4.8 → 0.4.10
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/combo/combo.svelte +9 -7
- package/components/combo/combo.svelte.d.ts +2 -0
- package/components/icon.svelte +2 -2
- package/components/menu.js +4 -3
- package/desk.svelte +22 -2
- package/operations.svelte +6 -1
- package/package.json +1 -1
- package/page.svelte +0 -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: {
|
|
@@ -17,7 +17,9 @@ export let icon = false;
|
|
|
17
17
|
export let placeholder = "Choose wisely...";
|
|
18
18
|
export let s = "sm";
|
|
19
19
|
export let c = "";
|
|
20
|
-
let
|
|
20
|
+
export let compact = false;
|
|
21
|
+
export let in_context = "sel";
|
|
22
|
+
let is_compact = getContext("rIs-table-component") || compact;
|
|
21
23
|
let definition = new rCombo_definition();
|
|
22
24
|
setContext("rCombo-definition", definition);
|
|
23
25
|
let is_dropdown_open = false;
|
|
@@ -40,7 +42,7 @@ switch (s) {
|
|
|
40
42
|
break;
|
|
41
43
|
}
|
|
42
44
|
let appearance_class;
|
|
43
|
-
if (
|
|
45
|
+
if (is_compact)
|
|
44
46
|
appearance_class = ` text-gray-900 text-sm
|
|
45
47
|
focus:ring-primary-600 block w-full ${input_pb} ${input_pt} px-2.5 dark:bg-gray-700
|
|
46
48
|
dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500`;
|
|
@@ -53,7 +55,7 @@ let ctx = context ? context : getContext("ctx");
|
|
|
53
55
|
let can_be_activated = true;
|
|
54
56
|
let last_tick = -1;
|
|
55
57
|
$:
|
|
56
|
-
setup($data_tick_store);
|
|
58
|
+
setup($data_tick_store, $context_items_store);
|
|
57
59
|
function setup(...args) {
|
|
58
60
|
if ($data_tick_store <= last_tick)
|
|
59
61
|
return;
|
|
@@ -64,8 +66,8 @@ function setup(...args) {
|
|
|
64
66
|
if (!label)
|
|
65
67
|
label = a;
|
|
66
68
|
tick_request_internal = tick_request_internal + 1;
|
|
67
|
-
if (
|
|
68
|
-
if ($context_items_store[
|
|
69
|
+
if (is_compact) {
|
|
70
|
+
if ($context_items_store[in_context] != self)
|
|
69
71
|
can_be_activated = false;
|
|
70
72
|
else
|
|
71
73
|
can_be_activated = true;
|
|
@@ -209,7 +211,7 @@ function get_combo_text() {
|
|
|
209
211
|
if (found)
|
|
210
212
|
return found.Name ?? found.Key;
|
|
211
213
|
else
|
|
212
|
-
return !
|
|
214
|
+
return !is_compact ? placeholder : "";
|
|
213
215
|
} else
|
|
214
216
|
return textbox.innerHTML;
|
|
215
217
|
}
|
|
@@ -430,7 +432,7 @@ function setup_view(...args) {
|
|
|
430
432
|
|
|
431
433
|
<div class={cs}
|
|
432
434
|
on:focusout={(e) => setTimeout(() => {hide()}, 100)}>
|
|
433
|
-
{#if !
|
|
435
|
+
{#if !is_compact}
|
|
434
436
|
<label for="name" class="block {label_mb} text-xs font-small text-gray-900 dark:text-white">{label}</label>
|
|
435
437
|
{/if}
|
|
436
438
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
package/components/icon.svelte
CHANGED
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,24 @@
|
|
|
23
25
|
let lg_content_area_horizontal_dim = ""
|
|
24
26
|
|
|
25
27
|
let visible_sidebar = "*"
|
|
28
|
+
|
|
29
|
+
if(layout.dark != undefined)
|
|
30
|
+
{
|
|
31
|
+
if(layout.dark.optional)
|
|
32
|
+
layout.mainToolbar.darkMode = true;
|
|
33
|
+
|
|
34
|
+
if(layout.dark.default)
|
|
35
|
+
set_dark_mode_default(layout.dark.default)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if(layout.operations != undefined)
|
|
39
|
+
{
|
|
40
|
+
if(layout.operations.optional)
|
|
41
|
+
layout.mainToolbar.operations = true;
|
|
42
|
+
|
|
43
|
+
if(layout.operations.default)
|
|
44
|
+
set_default_tools_visible(layout.operations.default)
|
|
45
|
+
}
|
|
26
46
|
|
|
27
47
|
$: { visible_sidebar = $main_sidebar_visible_store
|
|
28
48
|
|
|
@@ -113,7 +133,7 @@
|
|
|
113
133
|
<svelte:window bind:innerWidth bind:outerWidth bind:innerHeight bind:outerHeight />
|
|
114
134
|
|
|
115
135
|
<AuthorizedView>
|
|
116
|
-
<div class="{$dark_mode_store}">
|
|
136
|
+
<div id="__hd_svelte_layout_root" class="{$dark_mode_store}">
|
|
117
137
|
<div class="bg-white dark:bg-gray-900 dark:text-white min-h-screen h-screen">
|
|
118
138
|
<!--###########################################################-->
|
|
119
139
|
<!--## 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/page.svelte
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('');
|