@humandialog/forms.svelte 0.5.19 → 0.5.20
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/button.svelte +45 -11
- package/components/button.svelte.d.ts +2 -0
- package/desk.svelte +5 -2
- package/package.json +1 -1
package/components/button.svelte
CHANGED
|
@@ -8,11 +8,15 @@ export let params = null;
|
|
|
8
8
|
export let context = "";
|
|
9
9
|
export let typename = "";
|
|
10
10
|
export let action = null;
|
|
11
|
+
export let hiddenFunc = void 0;
|
|
12
|
+
export let disabledFunc = void 0;
|
|
11
13
|
let ctx = context ? context : getContext("ctx");
|
|
12
14
|
let is_table_component = getContext("rIs-table-component");
|
|
13
15
|
let can_be_activated = true;
|
|
14
16
|
let item = null;
|
|
15
|
-
let
|
|
17
|
+
let definedClass = $$restProps.class ?? "";
|
|
18
|
+
let hidden = false;
|
|
19
|
+
let disabled = false;
|
|
16
20
|
let last_tick = -1;
|
|
17
21
|
$:
|
|
18
22
|
setup($data_tick_store);
|
|
@@ -20,10 +24,18 @@ function setup(data_tick_store2) {
|
|
|
20
24
|
if (data_tick_store2 <= last_tick)
|
|
21
25
|
return;
|
|
22
26
|
last_tick = data_tick_store2;
|
|
23
|
-
|
|
27
|
+
{
|
|
24
28
|
item = self ?? $contextItemsStore[ctx];
|
|
25
29
|
if (!typename)
|
|
26
30
|
typename = $contextTypesStore[ctx];
|
|
31
|
+
if (!typename && !!item) {
|
|
32
|
+
if (item.$type)
|
|
33
|
+
typename = item.$type;
|
|
34
|
+
else if (item.$ref) {
|
|
35
|
+
let s = item.$ref.split("/");
|
|
36
|
+
typename = s[1];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
27
39
|
}
|
|
28
40
|
if (is_table_component) {
|
|
29
41
|
if ($contextItemsStore["sel"] != self)
|
|
@@ -31,14 +43,33 @@ function setup(data_tick_store2) {
|
|
|
31
43
|
else
|
|
32
44
|
can_be_activated = true;
|
|
33
45
|
} else
|
|
34
|
-
can_be_activated =
|
|
46
|
+
can_be_activated = !!item;
|
|
47
|
+
if (hiddenFunc) {
|
|
48
|
+
if (item)
|
|
49
|
+
hidden = hiddenFunc(item);
|
|
50
|
+
else
|
|
51
|
+
hidden = true;
|
|
52
|
+
} else if (disabledFunc) {
|
|
53
|
+
if (item)
|
|
54
|
+
disabled = disabledFunc(item);
|
|
55
|
+
else
|
|
56
|
+
disabled = true;
|
|
57
|
+
} else
|
|
58
|
+
disabled = !item;
|
|
35
59
|
}
|
|
36
60
|
async function click() {
|
|
37
61
|
if (action) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
if (context) {
|
|
63
|
+
if (params)
|
|
64
|
+
action(item, params);
|
|
65
|
+
else
|
|
66
|
+
action(item);
|
|
67
|
+
} else {
|
|
68
|
+
if (params)
|
|
69
|
+
action(params);
|
|
70
|
+
else
|
|
71
|
+
action();
|
|
72
|
+
}
|
|
42
73
|
$data_tick_store = $data_tick_store + 1;
|
|
43
74
|
} else if (item && operation && typename) {
|
|
44
75
|
try {
|
|
@@ -58,7 +89,7 @@ async function click() {
|
|
|
58
89
|
|
|
59
90
|
{#if is_table_component}
|
|
60
91
|
{#if can_be_activated}
|
|
61
|
-
<Button on:click={click} class="h-7 {
|
|
92
|
+
<Button on:click={click} class="h-7 {definedClass}"
|
|
62
93
|
disabled={!can_be_activated}
|
|
63
94
|
color='alternative'
|
|
64
95
|
>
|
|
@@ -67,8 +98,11 @@ async function click() {
|
|
|
67
98
|
{/if}
|
|
68
99
|
{:else}
|
|
69
100
|
|
|
70
|
-
<
|
|
71
|
-
|
|
101
|
+
<button on:click={click}
|
|
102
|
+
class={definedClass}
|
|
103
|
+
{hidden}
|
|
104
|
+
{disabled}>
|
|
72
105
|
<slot/>
|
|
73
|
-
</
|
|
106
|
+
</button>
|
|
107
|
+
|
|
74
108
|
{/if}
|
package/desk.svelte
CHANGED
|
@@ -69,15 +69,18 @@
|
|
|
69
69
|
set_dark_mode_default(layout.dark.default)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
|
|
72
73
|
if(layout.operations != undefined)
|
|
73
74
|
{
|
|
74
75
|
if(layout.operations.optional)
|
|
75
76
|
layout.mainToolbar.operations = true;
|
|
76
77
|
|
|
77
|
-
if(layout.operations.default)
|
|
78
|
+
if(layout.operations.default != undefined)
|
|
78
79
|
set_default_tools_visible(layout.operations.default)
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
else
|
|
82
|
+
set_default_tools_visible(false)
|
|
83
|
+
|
|
81
84
|
$: { visible_sidebar = $main_sidebar_visible_store
|
|
82
85
|
|
|
83
86
|
if(visible_sidebar == "*")
|