@humandialog/forms.svelte 0.4.39 → 0.4.41

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.
@@ -135,7 +135,7 @@ function toggle_expand(e) {
135
135
  disable-dbl-tap-zoom">
136
136
  <div class=" w-[55px] h-[55px]
137
137
  text-white bg-zinc-500 group-hover:bg-zinc-500
138
- dark:bg-zinc-500 dark:group-hover:bg-blue-700
138
+ dark:bg-zinc-500 dark:group-hover:bg-zinc-500
139
139
  font-medium rounded-full text-sm text-center shadow-md
140
140
  flex items-center justify-center">
141
141
  <div class="w-5 h-5"><svelte:component this={operation.icon}/></div>
@@ -82,31 +82,41 @@ function edit(e) {
82
82
  export function activate() {
83
83
  activate_row(null, item);
84
84
  }
85
- function activate_row(e, item2) {
86
- if (is_row_active) {
87
- let can_show_context_menu = true;
88
- let n = e.target;
89
- while (n) {
90
- let is_in_cell = n.getAttribute("role") == "gridcell";
91
- if (is_in_cell) {
92
- can_show_context_menu = false;
93
- break;
94
- }
95
- n = n.parentElement;
85
+ function edit_row_property(e, part) {
86
+ if (!is_row_active)
87
+ return;
88
+ let click_on_empty_space = true;
89
+ let n = e.target;
90
+ while (n) {
91
+ let is_in_cell = n.getAttribute("role") == "gridcell";
92
+ if (is_in_cell) {
93
+ click_on_empty_space = false;
94
+ break;
96
95
  }
97
- can_show_context_menu = false;
98
- if (can_show_context_menu && context_menu) {
99
- const pt = new DOMPoint(e.clientX, e.clientY);
100
- let context_operations = context_menu(item2);
101
- if (context_operations !== null) {
102
- if (typeof context_operations === "object") {
103
- if (Array.isArray(context_operations))
104
- show_menu(pt, context_operations);
105
- else if (context_operations.grid)
106
- show_grid_menu(pt, context_operations.grid);
107
- }
96
+ n = n.parentElement;
97
+ }
98
+ let can_show_context_menu = click_on_empty_space;
99
+ can_show_context_menu = false;
100
+ if (can_show_context_menu && context_menu) {
101
+ const pt = new DOMPoint(e.clientX, e.clientY);
102
+ let context_operations = context_menu(item);
103
+ if (context_operations !== null) {
104
+ if (typeof context_operations === "object") {
105
+ if (Array.isArray(context_operations))
106
+ show_menu(pt, context_operations);
107
+ else if (context_operations.grid)
108
+ show_grid_menu(pt, context_operations.grid);
108
109
  }
109
110
  }
111
+ } else if (click_on_empty_space) {
112
+ if (part == "top" && !definition.title_readonly)
113
+ force_editing("Title");
114
+ else if (part == "bottom" && !definition.summary_readonly)
115
+ force_editing("Summary");
116
+ }
117
+ }
118
+ function activate_row(e, item2) {
119
+ if (is_row_active) {
110
120
  }
111
121
  activate_item("props", item2, toolbar_operations(item2));
112
122
  if (e)
@@ -222,7 +232,7 @@ async function edit_date(field, prop_idx) {
222
232
  <slot name="left" element={item}/>
223
233
 
224
234
  <div class="ml-3 w-full py-1" use:selectable={item} on:click={(e) => {activate_row(e, item)}} role="row" tabindex="0">
225
- <div class="flex flex-row">
235
+ <div class="flex flex-row" on:click={(e) => edit_row_property(e, 'top')}>
226
236
  <p class="font-bold whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3">
227
237
  {#if definition.title_readonly}
228
238
  <span id="__hd_list_ctrl_{item[item_key]}_Title" role="gridcell" tabindex="0">
@@ -279,7 +289,7 @@ async function edit_date(field, prop_idx) {
279
289
 
280
290
  {#if summary && (item[summary] || placeholder=='Summary')}
281
291
  {@const element_id = `__hd_list_ctrl_${item[item_key]}_Summary`}
282
- <p class="text-xs text-slate-400" style="min-height: 1rem;">
292
+ <p class="text-xs text-slate-400" style="min-height: 1rem;" on:click={(e) => edit_row_property(e, 'bottom')}>
283
293
  {#if definition.summary_readonly}
284
294
  <span id={element_id} role="gridcell" tabindex="0">
285
295
  {item[summary]}
@@ -1,5 +1,5 @@
1
- <script>import { setContext, getContext, afterUpdate, tick } from "svelte";
2
- import { data_tick_store, context_items_store, context_types_store } from "../../stores";
1
+ <script>import { setContext, getContext, afterUpdate, tick, onMount } from "svelte";
2
+ import { data_tick_store, context_items_store, context_types_store, page_title } from "../../stores";
3
3
  import { activate_item, get_active, clear_active_item, parse_width_directive } from "../../utils";
4
4
  import { rList_definition } from "./List";
5
5
  import List_element from "./internal/list.element.svelte";
@@ -133,8 +133,8 @@ export function edit(element, property_name) {
133
133
 
134
134
 
135
135
  {#if title}
136
- <p class="mt-3 uppercase text-sm text-center">{title}</p>
137
- <hr class="w-full">
136
+ <p class="hidden sm:block mt-3 uppercase text-sm text-center">{title}</p>
137
+ <hr class="hidden sm:block w-full">
138
138
  {/if}
139
139
 
140
140
  <!--div class="w-full h-full overflow-y-auto"-->
@@ -3,14 +3,18 @@
3
3
  export let href = "/";
4
4
  export let img = "";
5
5
 
6
+ let user_class = $$props.class ?? "";
7
+
6
8
  </script>
7
9
 
8
- <a href={href} class="flex items-center pl-2.5 mb-5">
9
- {#if img}
10
- <img src={img} class="h-6 mr-3 sm:h-7" alt="" />
11
- {/if}
10
+ <section class={user_class}>
11
+ <a href={href} class="flex items-center pl-2.5 mb-5">
12
+ {#if img}
13
+ <img src={img} class="h-6 mr-3 sm:h-7" alt="" />
14
+ {/if}
12
15
 
13
- <span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
14
- <slot/>
15
- </span>
16
- </a>
16
+ <span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
17
+ <slot/>
18
+ </span>
19
+ </a>
20
+ </section>
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} SidebarEvents */
3
3
  /** @typedef {typeof __propDef.slots} SidebarSlots */
4
4
  export default class Sidebar extends SvelteComponentTyped<{
5
+ [x: string]: any;
5
6
  img?: string | undefined;
6
7
  href?: string | undefined;
7
8
  }, {
@@ -16,6 +17,7 @@ export type SidebarSlots = typeof __propDef.slots;
16
17
  import { SvelteComponentTyped } from "svelte";
17
18
  declare const __propDef: {
18
19
  props: {
20
+ [x: string]: any;
19
21
  img?: string | undefined;
20
22
  href?: string | undefined;
21
23
  };
@@ -79,18 +79,17 @@ function on_show_menu(e) {
79
79
  on:contextmenu={on_contextmenu}
80
80
  on:keydown
81
81
  on:keyup
82
- class=" p-2 border border-transparent rounded-lg
82
+ class=" border border-transparent rounded-lg
83
83
  text-base font-normal
84
- text-gray-900 hover:bg-gray-100
85
- dark:text-white dark:hover:bg-gray-700 {user_class}
84
+ text-gray-900 sm:hover:bg-gray-100
85
+ dark:text-white sm:dark:hover:bg-gray-700 {user_class}
86
86
  flex flex-row justify-between"
87
87
  class:bg-gray-200={active}
88
88
  class:dark:bg-gray-700={active}
89
- use:selectable_if_needed={selectable}
90
89
  class:selected={selected(selectable, context_data)}>
91
90
  <a href={href}
92
91
  on:click={on_link_clicked}
93
- class="inline-flex items-center group">
92
+ class="flex-1 m-2 inline-flex items-center group">
94
93
  {#if icon}
95
94
  <Icon size={5} component={icon}/>
96
95
  {/if}
@@ -99,12 +98,15 @@ function on_show_menu(e) {
99
98
  <slot/>
100
99
  </span>
101
100
  </a>
102
-
103
- {#if can_show_context_menu(selectable, context_data)}
104
- <button class="w-4 h-4 mt-1" on:click={on_show_menu}>
105
- <FaBars/>
106
- </button>
107
- {/if}
101
+
102
+ <section class="flex-0 w-20 h-10 flex-0 flex flex-row"
103
+ use:selectable_if_needed={selectable}>
104
+ {#if can_show_context_menu(selectable, context_data)}
105
+ <button class="w-4 h-4 mt-3 mr-2 ml-auto" on:click={on_show_menu}>
106
+ <FaBars/>
107
+ </button>
108
+ {/if}
109
+ </section>
108
110
  </div>
109
111
  </li>
110
112
 
@@ -23,7 +23,13 @@
23
23
  bottom_bar_visible_store,
24
24
  previously_visible_sidebar,
25
25
  main_sidebar_visible_store,
26
- sidebar_left_pos
26
+ sidebar_left_pos,
27
+
28
+ page_title,
29
+
30
+ nav_titles
31
+
32
+
27
33
  } from "./stores.js";
28
34
  import Icon from './components/icon.svelte';
29
35
  import {session, signin_href, signout_href} from '@humandialog/auth.svelte'
@@ -63,6 +69,20 @@
63
69
  }
64
70
  }
65
71
 
72
+ let title = ''
73
+ $:{
74
+ if($main_sidebar_visible_store == '*')
75
+ title = $page_title;
76
+ else
77
+ {
78
+ let nav_title = $nav_titles[$main_sidebar_visible_store];
79
+ if(nav_title != undefined)
80
+ title = nav_title
81
+ else
82
+ title = ''
83
+ }
84
+ }
85
+
66
86
  function toggle_navigator(e)
67
87
  {
68
88
  if(tabs.length == 1)
@@ -176,19 +196,27 @@
176
196
 
177
197
  </script>
178
198
 
179
- <div class="ml-auto flex h-10">
180
- <button
181
- class="h-full w-10 px-0 flex justify-center items-center text-slate-300 hover:text-slate-100"
182
- on:click={show_options}>
199
+ <div class="flex flex-row w-full">
200
+ <div class="flex-none left-0 flex h-10">
201
+ <button class="w-10 h-full flex justify-center items-center text-slate-300 hover:text-slate-100" on:click={toggle_navigator}>
202
+ <Icon size={6} component={icon}/>
203
+ </button>
204
+ </div>
183
205
 
184
- <Icon size={4} component={FaCog} />
185
- </button>
186
- </div>
206
+ <div class="grow">
207
+
208
+ <div class="block sm:hidden mt-3 uppercase text-sm text-center">{@html title}</div>
209
+ </div>
210
+
211
+ <div class="flex-none ml-auto flex h-10">
212
+ <button
213
+ class="h-full w-10 px-0 flex justify-center items-center text-slate-300 hover:text-slate-100"
214
+ on:click={show_options}>
215
+
216
+ <Icon size={4} component={FaCog} />
217
+ </button>
218
+ </div>
187
219
 
188
- <div class="right-0 flex h-10">
189
- <button class="w-10 h-full flex justify-center items-center text-slate-300 hover:text-slate-100" on:click={toggle_navigator}>
190
- <Icon size={6} component={icon}/>
191
- </button>
192
220
  </div>
193
221
 
194
222
  {#if tabs.length > 1 && $main_sidebar_visible_store != "*"}
package/index.d.ts CHANGED
@@ -38,6 +38,6 @@ export { default as ListStaticProperty } from './components/list/list.static.sve
38
38
  export { default as Modal } from './modal.svelte';
39
39
  export { default as MembersPage } from './tenant.members.svelte';
40
40
  export { select_item, activate_item, clear_active_item, is_active, is_selected, get_active, editable, start_editing, selectable, handle_select } from './utils';
41
- export { data_tick_store, has_selected_item, has_data_item } from "./stores";
41
+ export { data_tick_store, has_selected_item, has_data_item, set_navigator_title } from "./stores";
42
42
  export { context_toolbar_operations, page_toolbar_operations, context_items_store, context_types_store } from './stores';
43
43
  export { inform_modification, inform_item, push_changes } from './updates';
package/index.js CHANGED
@@ -44,6 +44,6 @@ export { default as ListStaticProperty } from './components/list/list.static.sve
44
44
  export { default as Modal } from './modal.svelte';
45
45
  export { default as MembersPage } from './tenant.members.svelte';
46
46
  export { select_item, activate_item, clear_active_item, is_active, is_selected, get_active, editable, start_editing, selectable, handle_select } from './utils';
47
- export { data_tick_store, has_selected_item, has_data_item } from "./stores";
47
+ export { data_tick_store, has_selected_item, has_data_item, set_navigator_title } from "./stores";
48
48
  export { context_toolbar_operations, page_toolbar_operations, context_items_store, context_types_store } from './stores'; // tmp
49
49
  export { inform_modification, inform_item, push_changes } from './updates'; // tmp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "0.4.39",
3
+ "version": "0.4.41",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
package/page.svelte CHANGED
@@ -6,7 +6,8 @@
6
6
  context_types_store,
7
7
  context_info_store,
8
8
  context_toolbar_operations,
9
- page_toolbar_operations } from './stores.js'
9
+ page_toolbar_operations,
10
+ page_title } from './stores.js'
10
11
 
11
12
  //import {chnages} from './utils.js'
12
13
 
@@ -21,6 +22,7 @@
21
22
 
22
23
  export let toolbar_operations = undefined;
23
24
  export let clears_context = '';
25
+ export let title = '';
24
26
 
25
27
 
26
28
  switch (c) {
@@ -36,12 +38,15 @@
36
38
 
37
39
  onMount(() => {
38
40
  if(toolbar_operations != undefined && Array.isArray(toolbar_operations))
39
- {
40
41
  $page_toolbar_operations = [...toolbar_operations]
41
- return () => { $page_toolbar_operations = [] }
42
+
43
+ $page_title = title;
44
+
45
+ return () =>
46
+ {
47
+ $page_toolbar_operations = []
48
+ $page_title = ''
42
49
  }
43
- else
44
- return () => {}
45
50
  })
46
51
 
47
52
  setContext('ctx', context)
package/page.svelte.d.ts CHANGED
@@ -11,6 +11,7 @@ export default class Page extends SvelteComponentTyped<{
11
11
  in_context?: string | undefined;
12
12
  toolbar_operations?: any;
13
13
  clears_context?: string | undefined;
14
+ title?: string | undefined;
14
15
  }, {
15
16
  [evt: string]: CustomEvent<any>;
16
17
  }, {
@@ -32,6 +33,7 @@ declare const __propDef: {
32
33
  in_context?: string | undefined;
33
34
  toolbar_operations?: any;
34
35
  clears_context?: string | undefined;
36
+ title?: string | undefined;
35
37
  };
36
38
  events: {
37
39
  [evt: string]: CustomEvent<any>;
package/stores.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export function set_navigator_title(key: any, title: any): void;
1
2
  export function has_selected_item(): boolean;
2
3
  export function has_data_item(): boolean;
3
4
  export function set_dark_mode_default(value: any): void;
@@ -24,6 +25,8 @@ export const context_types_store: import("svelte/store").Writable<{
24
25
  }>;
25
26
  export const context_toolbar_operations: import("svelte/store").Writable<never[]>;
26
27
  export const page_toolbar_operations: import("svelte/store").Writable<never[]>;
28
+ export const page_title: import("svelte/store").Writable<string>;
29
+ export const nav_titles: import("svelte/store").Writable<{}>;
27
30
  export const dark_mode_store: import("svelte/store").Writable<any>;
28
31
  export const main_sidebar_visible_store: import("svelte/store").Writable<any>;
29
32
  export let previously_visible_sidebar: string;
package/stores.js CHANGED
@@ -8,6 +8,15 @@ export const context_info_store = writable({data: '', sel: ''})
8
8
  export const context_types_store = writable({focused:'', data: null, sel: null})
9
9
  export const context_toolbar_operations = writable([]);
10
10
  export const page_toolbar_operations = writable([]);
11
+ export const page_title = writable('');
12
+ export const nav_titles = writable({});
13
+
14
+ export function set_navigator_title(key, title)
15
+ {
16
+ let titles = get(nav_titles);
17
+ titles[key] = title;
18
+ nav_titles.set(titles);
19
+ }
11
20
 
12
21
  export function has_selected_item()
13
22
  {
@@ -70,8 +70,8 @@
70
70
  })
71
71
  }
72
72
 
73
- fake_users = [];
74
- add_fake_users(fake_users);
73
+ //fake_users = [];
74
+ //add_fake_users(fake_users);
75
75
 
76
76
  await fetch_details();
77
77
 
@@ -427,10 +427,10 @@
427
427
  cl="!bg-white dark:!bg-slate-900 w-full h-full flex flex-col overflow-y-auto overflow-x-hidden py-1 px-1 border-0"
428
428
  toolbar_operations={page_operations}
429
429
  clears_context='props sel'>
430
- <a href="/" class="underline text-sm font-semibold ml-3"> &lt; Back to root</a>
430
+ <!--a href="/" class="underline text-sm font-semibold ml-3"> &lt; Back to root</a-->
431
431
 
432
- {#if fake_users && fake_users.length > 0}
433
- <List objects={fake_users}
432
+ {#if reef_users && reef_users.length > 0}
433
+ <List objects={reef_users}
434
434
  title='Members'
435
435
  toolbar_operations={user_operations}
436
436
  context_menu={user_context_menu}
package/utils.js CHANGED
@@ -166,6 +166,11 @@ export function editable(node, action)
166
166
  await tick();
167
167
  let range = document.createRange();
168
168
  range.selectNodeContents(node);
169
+ let end_offset = range.endOffset;
170
+ let end_container = range.endContainer;
171
+ range.setStart(end_container, end_offset)
172
+ range.setEnd(end_container, end_offset)
173
+ console.log('range rect: ', range.getBoundingClientRect())
169
174
  let sel = window.getSelection();
170
175
  sel.removeAllRanges();
171
176
  sel.addRange(range);