@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.
@@ -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 additional_class = $$restProps.class ?? "";
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
- if (!action) {
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 = true;
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 (params)
39
- action(params);
40
- else
41
- action();
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 {additional_class}"
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
- <Button on:click={click} class="h-7 {additional_class}"
71
- disabled={!can_be_activated}>
101
+ <button on:click={click}
102
+ class={definedClass}
103
+ {hidden}
104
+ {disabled}>
72
105
  <slot/>
73
- </Button>
106
+ </button>
107
+
74
108
  {/if}
@@ -8,6 +8,8 @@ declare const __propDef: {
8
8
  context?: string | undefined;
9
9
  typename?: string | undefined;
10
10
  action?: null | undefined;
11
+ hiddenFunc?: undefined;
12
+ disabledFunc?: undefined;
11
13
  };
12
14
  events: {
13
15
  [evt: string]: CustomEvent<any>;
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 == "*")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "0.5.19",
3
+ "version": "0.5.20",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",