@humandialog/forms.svelte 0.4.42 → 0.4.44

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.
@@ -7,7 +7,6 @@ $:
7
7
  update($page_toolbar_operations, $context_toolbar_operations);
8
8
  let operations = [];
9
9
  function update(...args) {
10
- expanded = false;
11
10
  if ($context_toolbar_operations && $context_toolbar_operations.length > 0)
12
11
  operations = $context_toolbar_operations;
13
12
  else
@@ -121,7 +121,7 @@
121
121
  {@const col=col_span(operation.columns ?? 1)}
122
122
 
123
123
  <button class=" py-2.5 px-5 {col}
124
- text-xs font-medium text-gray-900 dark:text-gray-400 dark:hover:text-white
124
+ text-base sm:text-xs font-medium text-gray-900 dark:text-gray-400 dark:hover:text-white
125
125
  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
126
126
  border rounded border-gray-200 dark:border-gray-600 focus:outline-none
127
127
  inline-flex items-center justify-center"
@@ -48,15 +48,15 @@ switch (s) {
48
48
  label_mb = "mb-2";
49
49
  input_pt = "pt-2.5";
50
50
  input_pb = "pb-2.5";
51
- font_size = "text-sm";
52
- line_h = "h-5";
51
+ font_size = "text-lg sm:text-sm";
52
+ line_h = "h-7 sm:h-5";
53
53
  break;
54
54
  case "xs":
55
55
  label_mb = "mb-0.5";
56
56
  input_pt = "pt-0.5";
57
57
  input_pb = "pb-0.5";
58
- font_size = "text-xs";
59
- line_h = "h-4";
58
+ font_size = "text-base sm:text-xs";
59
+ line_h = "h-6 sm:h-4";
60
60
  break;
61
61
  }
62
62
  let background_class = is_compact && !icon ? "bg-slate-900/10 dark:bg-slate-100/10 rounded-lg" : "";
@@ -553,7 +553,7 @@ function on_focus_out(e) {
553
553
  {#if _filtered_source.length > 0}
554
554
  {#each _filtered_source as item (item.Key)}
555
555
  <!-- svelte-ignore a11y-click-events-have-key-events -->
556
- <li class="rounded p-2 flex flex-row items-center"
556
+ <li class="rounded p-2 flex flex-row items-center {font_size}"
557
557
  class:bg-gray-100={highlighted_option == item}
558
558
  class:dark:bg-gray-700={highlighted_option == item}
559
559
  class:dark:hover:bg-gray-700={highlighted_option == item}
@@ -188,30 +188,35 @@ function hide_submenu() {
188
188
  </script>
189
189
 
190
190
  <div id="__hd_svelte_contextmenu"
191
- class="bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded-lg border border-gray-200 dark:border-gray-700 shadow-md z-30 fixed min-w-[{min_width_px}px] w-max"
191
+ class=" bg-white dark:bg-gray-700 text-slate-600 dark:text-gray-400 rounded-lg border border-gray-200 dark:border-gray-900 shadow-md
192
+ z-30 fixed min-w-[{min_width_px}px] w-max"
192
193
  style={`left:${x}px; top:${y}px; display:${display}`}
193
194
  bind:this={menu_root}>
194
195
 
195
196
  {#each operations as operation, index}
196
197
  {@const is_separator = operation.separator}
197
198
  {#if is_separator}
198
- <hr class="my-1 mx-1">
199
+ <hr class="my-1 mx-0 border-1 dark:border-slate-900">
199
200
  {:else}
200
- {@const icon_placeholder_size = operation.description ? 12 : 10}
201
+ {@const mobile = is_device_smaller_than("sm")}
202
+ {@const icon_placeholder_without_desc = mobile ? 12 : 10}
203
+ {@const icon_placeholder_with_desc = mobile ? 14 : 12}
204
+ {@const icon_placeholder_size = operation.description ? icon_placeholder_with_desc : icon_placeholder_without_desc}
201
205
  {@const menu_item_id = menu_items_id_prefix + index}
202
- {@const active = focused_index == index ? 'bg-gray-200 dark:bg-gray-700' : ''}
206
+ {@const active = focused_index == index ? 'bg-gray-200 dark:bg-gray-600' : ''}
203
207
  {@const has_submenu = operation.menu !== undefined && operation.menu.length > 0}
204
208
 
205
- <button class="font-medium m-0 p-2 text-sm w-full text-left flex flex-row cursor-context-menu {active} focus:outline-none"
209
+ <button class="font-medium m-0 p-2 text-lg sm:text-sm w-full text-left flex flex-row cursor-context-menu {active} focus:outline-none"
206
210
  id={menu_item_id}
207
211
  bind:this={menu_items[index]}
208
212
  on:click|stopPropagation={(e) => { execute_action(operation, index) } }
209
213
  on:mouseenter = {(e) => {on_mouse_move(index)}}
210
214
  on:keydown|stopPropagation={(e) => on_keydown(e, operation, index)}>
211
215
 
212
- <div class="flex items-center justify-center" style:width={`${icon_placeholder_size*0.25}rem`}>
216
+ <div class="flex items-center justify-center mt-1 sm:mt-0.5" style:width={`${icon_placeholder_size*0.25}rem`}>
213
217
  {#if operation.icon}
214
- {@const icon_size = icon_placeholder_size - 6}
218
+ {@const cc = mobile ? 7 : 6}
219
+ {@const icon_size = icon_placeholder_size - cc}
215
220
  <Icon size={icon_size} component={operation.icon}/>
216
221
  {/if}
217
222
  </div>
@@ -219,7 +224,7 @@ function hide_submenu() {
219
224
  <p>{operation.caption}</p>
220
225
  {#if operation.description}
221
226
  {@const shortcut_width_px = operation.shortcut ? 80 : 0}
222
- <p class="text-sm font-normal text-gray-400 dark:text-gray-500 truncate inline-block"
227
+ <p class="text-sm font-normal text-slate-900 dark:text-gray-500 truncate inline-block"
223
228
  style:max-width={`calc(${width_px-shortcut_width_px} - 3rem)`} >{operation.description}</p>
224
229
  {/if}
225
230
  </div>
@@ -37,20 +37,20 @@ export function show(event, hide_callback) {
37
37
  let is_compact = getContext("rIs-table-component") || compact;
38
38
  let input_pt = "pt-0.5";
39
39
  let input_pb = "pb-1";
40
- let font_size = "text-sm";
41
- let line_h = "h-4";
40
+ let font_size = "text-lg sm:text-sm";
41
+ let line_h = "h-7 sm:h-5";
42
42
  switch (s) {
43
43
  case "md":
44
44
  input_pt = "pt-2.5";
45
45
  input_pb = "pb-2.5";
46
- font_size = "text-sm";
47
- line_h = "h-5";
46
+ font_size = "text-lg sm:text-sm";
47
+ line_h = "h-7 sm:h-5";
48
48
  break;
49
49
  case "xs":
50
50
  input_pt = "pt-0.5";
51
51
  input_pb = "pb-0.5";
52
- font_size = "text-xs";
53
- line_h = "h-4";
52
+ font_size = "text-base sm:text-xs";
53
+ line_h = "h-6 sm:h-4";
54
54
  break;
55
55
  }
56
56
  let item = null;
@@ -6,7 +6,7 @@ export let img = "";
6
6
  export let label = "";
7
7
  export let symbol = "";
8
8
  export let color = "";
9
- export let size = 5;
9
+ export let size = void 0;
10
10
  export let bg = "";
11
11
  export let circle = false;
12
12
  let additional_class = $$restProps.class ?? "";
@@ -14,7 +14,6 @@ let id = $$restProps.id ?? "";
14
14
  let _bg;
15
15
  let txt = "";
16
16
  let symbol_html = "";
17
- let icon_size = `${size * 0.25}rem`;
18
17
  $: {
19
18
  if (symbol) {
20
19
  if (symbol.startsWith("label:"))
@@ -57,11 +56,24 @@ $: {
57
56
  } else
58
57
  component = component;
59
58
  }
59
+ let style;
60
+ $: {
61
+ if (size == void 0) {
62
+ if (!additional_class) {
63
+ size = 5;
64
+ let icon_size = `${size * 0.25}rem`;
65
+ style = `width: ${icon_size}; height: ${icon_size}`;
66
+ } else
67
+ style = "";
68
+ } else {
69
+ let icon_size = `${size * 0.25}rem`;
70
+ style = `width: ${icon_size}; height: ${icon_size}`;
71
+ }
72
+ }
60
73
  </script>
61
74
 
62
75
  <div class=" {additional_class}"
63
- style:width={icon_size}
64
- style:height={icon_size}
76
+ style="{style}"
65
77
  style:background-color={_bg}
66
78
  style:border-radius={ circle ? '50%' : ''}
67
79
  {id}
@@ -224,6 +224,8 @@ async function edit_date(field, prop_idx) {
224
224
 
225
225
  <!-- svelte-ignore a11y-click-events-have-key-events -->
226
226
  {#if item}
227
+ {@const element_title = item[title]}
228
+
227
229
  <section class="flex flex-row my-0 w-full text-sm text-slate-700 dark:text-slate-400 cursor-default rounded-md border border-transparent {selected_class} {focused_class}"
228
230
  on:contextmenu={on_contextmenu}
229
231
  role="menu"
@@ -233,17 +235,21 @@ async function edit_date(field, prop_idx) {
233
235
 
234
236
  <div class="ml-3 w-full py-1" use:selectable={item} on:click={(e) => {activate_row(e, item)}} role="row" tabindex="0">
235
237
  <div class="flex flex-row" on:click={(e) => edit_row_property(e, 'top')}>
236
- <p class="font-bold whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3">
238
+ <p class=" text-lg font-semibold min-h-[1.75rem]
239
+ sm:text-sm sm:font-semibold sm:min-h-[1.25rem]
240
+ whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3">
237
241
  {#if definition.title_readonly}
238
242
  <span id="__hd_list_ctrl_{item[item_key]}_Title" role="gridcell" tabindex="0">
239
- {item[title]}
243
+ {element_title}
240
244
  </span>
241
245
  {:else}
246
+ {#key item[title]} <!-- Wymusza pełne wyrenderowanie zwłasza po zmiane z pustego na tekst -->
242
247
  <span id="__hd_list_ctrl_{item[item_key]}_Title" role="gridcell" tabindex="0"
243
248
  use:editable={(text) => {change_name(text)}}
244
249
  on:click={edit}>
245
- {item[title]}
250
+ {element_title}
246
251
  </span>
252
+ {/key}
247
253
  {/if}
248
254
  </p>
249
255
 
@@ -289,7 +295,10 @@ async function edit_date(field, prop_idx) {
289
295
 
290
296
  {#if summary && (item[summary] || placeholder=='Summary')}
291
297
  {@const element_id = `__hd_list_ctrl_${item[item_key]}_Summary`}
292
- <p class="text-xs text-slate-400" style="min-height: 1rem;" on:click={(e) => edit_row_property(e, 'bottom')}>
298
+ <p class=" sm:text-xs sm:min-h-[1rem]
299
+ text-base min-h-[1.5rem]
300
+ text-slate-400 "
301
+ on:click={(e) => edit_row_property(e, 'bottom')}>
293
302
  {#if definition.summary_readonly}
294
303
  <span id={element_id} role="gridcell" tabindex="0">
295
304
  {item[summary]}
@@ -9,15 +9,15 @@ export function run(onclose) {
9
9
  let insertion_paragraph;
10
10
  </script>
11
11
 
12
- <section class="flex flex-row my-0 w-full text-sm text-slate-700 dark:text-slate-400 cursor-default rounded-md border-2 border-transparent bg-gray-200 dark:bg-gray-700">
12
+ <section class="flex flex-row my-0 w-full text-lg sm:text-sm text-slate-700 dark:text-slate-400 cursor-default rounded-md border-2 border-transparent bg-gray-200 dark:bg-gray-700">
13
13
  {#if icon}
14
14
  <!--Icon size={3}
15
15
  component={FaPlus}
16
16
  class="mt-1.5 ml-2 "/-->
17
- <div class="h-4 w-4 mt-1.5 ml-2"></div>
17
+ <div class="h-5 w-5 sm:h-4 sm:w-4 mt-2 sm:mt-1.5 ml-2"></div>
18
18
  {/if}
19
19
 
20
- <p class="ml-3 py-1 font-bold whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3"
20
+ <p class="ml-3 py-1 font-semibold sm:font-bold whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3" tabindex="0"
21
21
  bind:this={insertion_paragraph}
22
22
  use:editable={oninsert} >
23
23
  </p>
@@ -14,7 +14,7 @@
14
14
  <slot/>
15
15
 
16
16
  {#if inserter}
17
- <Edit class="p-2 text-base font-normal text-gray-500 rounded-lg dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700" on_enter={inserter} placeholder={inserter_placeholder} inserter={true}>
17
+ <Edit class="p-3 sm:p-2 text-lg sm:text-base font-normal text-gray-500 rounded-lg dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700" on_enter={inserter} placeholder={inserter_placeholder} inserter={true}>
18
18
  <Icon size={5} component={FaPlus} class="mr-3"/>
19
19
  </Edit>
20
20
  {/if}
@@ -80,7 +80,7 @@ function on_show_menu(e) {
80
80
  on:keydown
81
81
  on:keyup
82
82
  class=" border border-transparent rounded-lg
83
- text-base font-normal
83
+ text-lg sm:text-base font-normal
84
84
  text-gray-900 sm:hover:bg-gray-100
85
85
  dark:text-white sm:dark:hover:bg-gray-700 {user_class}
86
86
  flex flex-row justify-between"
@@ -89,7 +89,7 @@ function on_show_menu(e) {
89
89
  class:selected={selected(selectable, context_data)}>
90
90
  <a href={href}
91
91
  on:click={on_link_clicked}
92
- class="flex-1 ml-2 my-2 inline-flex items-center group">
92
+ class="flex-1 ml-2 my-3 sm:my-2 inline-flex items-center group">
93
93
  {#if icon}
94
94
  <Icon size={5} component={icon}/>
95
95
  {/if}
@@ -102,7 +102,7 @@ function on_show_menu(e) {
102
102
  <section class="flex-0 w-20 sm:w-12 h-10 flex-0 flex flex-row"
103
103
  use:selectable_if_needed={selectable}>
104
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}>
105
+ <button class="w-6 sm:w-4 h-6 sm:h-4 mt-3 mr-3 sm:mr-2 ml-auto" on:click={on_show_menu}>
106
106
  <FaBars/>
107
107
  </button>
108
108
  {/if}
package/desk.svelte CHANGED
@@ -115,22 +115,22 @@
115
115
  tools_visibility = "hidden sm:block sm:fixed"
116
116
  fab_visibility = "fixed sm:hidden"
117
117
 
118
- content_top = 'top-[40px] sm:top-[40px]'
118
+ content_top = 'top-[50px] sm:top-[40px]'
119
119
 
120
120
  if(bottom_bar_visible)
121
- content_height = `h-[calc(100vh-320px)] sm:h-[calc(100vh-280px)]`
121
+ content_height = `h-[calc(100vh-290px)] sm:h-[calc(100vh-280px)]`
122
122
  else
123
- content_height = `h-[calc(100vh-80px)] sm:h-[calc(100vh-40px)]`
123
+ content_height = `h-[calc(100vh-50px)] sm:h-[calc(100vh-40px)]`
124
124
 
125
125
  }
126
126
  else
127
127
  {
128
128
  tools_visibility = "hidden"
129
- content_top = `top-[40px] sm:top-0`
129
+ content_top = `top-[50px] sm:top-0`
130
130
  if(bottom_bar_visible)
131
- content_height = `h-[calc(100vh-280px)] sm:h-[calc(100vh-240px)]`
131
+ content_height = `h-[calc(100vh-290px)] sm:h-[calc(100vh-240px)]`
132
132
  else
133
- content_height = `h-[calc(100vh-40px)] sm:h-screen`
133
+ content_height = `h-[calc(100vh-50px)] sm:h-screen`
134
134
  }
135
135
 
136
136
 
@@ -165,8 +165,8 @@
165
165
  <!--###########################################################-->
166
166
  <!--## HORIZONTAL TOOLBAR (FOR PHONES) ######################-->
167
167
  <!--###########################################################-->
168
- <header class="fixed sm:hidden w-screen top-0 h-[40px] z-20 overflow-auto shadow shadow-slate-900/5 dark:shadow-none" >
169
- <div class=" flex flex-row justify-between bg-slate-900 text-gray-100 ">
168
+ <header class="fixed sm:hidden w-screen top-0 h-[50px] sm:h-[40px] z-20 overflow-auto shadow shadow-slate-900/5 dark:shadow-none" >
169
+ <div class=" flex flex-row justify-between h-full bg-slate-900 text-gray-100 ">
170
170
  <HorizontalToolbar app_config={layout}/>
171
171
  <div>
172
172
  </header>
@@ -176,7 +176,7 @@
176
176
  <!--#######################################################-->
177
177
  <!--## VERTICAL TOOLBAR ##################-->
178
178
  <!--#######################################################-->
179
- <div class="hidden sm:block fixed left-0 top-0 w-[40px] h-screen z-20 inset-0 overflow-hidden">
179
+ <div class="hidden sm:block fixed left-0 top-0 w-[50px] sm:w-[40px] h-screen z-20 inset-0 overflow-hidden">
180
180
  <div class="sticky top-0 flex h-full w-10 bg-slate-900 flex-col items-center text-gray-100 shadow">
181
181
  <VerticalToolbar app_config={layout}/>
182
182
  </div>
@@ -188,13 +188,13 @@
188
188
  <!--## MAIN SIDE BAR ##################-->
189
189
  <!--#######################################################-->
190
190
  {#if true}
191
- {@const sidebar_left = $sidebar_left_pos==0 ? "left-0" : "left-[40px]"}
192
- {@const sidebar_small_width = $sidebar_left_pos==0 ? "w-full" : "w-[calc(100vw-40px)]"}
191
+ {@const sidebar_left = $sidebar_left_pos==0 ? "left-0" : "left-[50px]"}
192
+ {@const sidebar_small_width = $sidebar_left_pos==0 ? "w-full" : "w-[calc(100vw-50px)]"}
193
193
 
194
194
  <div class="{main_side_panel_visibility}
195
195
  {sidebar_left} sm:left-[40px]
196
- top-[40px] sm:top-0
197
- h-[calc(100vh-40px)] sm:h-full {lg_main_sidebar_height}
196
+ top-[50px] sm:top-0
197
+ h-[calc(100vh-50px)] sm:h-full {lg_main_sidebar_height}
198
198
  {sidebar_small_width} sm:w-[320px]
199
199
  z-20 overflow-x-hidden">
200
200
 
@@ -256,6 +256,14 @@
256
256
 
257
257
  </div>
258
258
 
259
+ <!-- #########################################################-->
260
+ <!-- ## MODAL DIALOG #########################################-->
261
+ <!-- #########################################################-->
262
+ <div id="__hd_svelte_modal_root" class="z-30">
263
+ <!-- after <Modal/> component is shown it's rettached to above div
264
+ see: modal.svelte afterUpdate -->
265
+ </div>
266
+
259
267
  </section>
260
268
 
261
269
  </div>
@@ -197,9 +197,9 @@
197
197
  </script>
198
198
 
199
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}/>
200
+ <div class="flex-none left-0 flex h-12 sm:h-10">
201
+ <button class="w-12 sm:w-10 h-full flex justify-center items-center text-slate-300 hover:text-slate-100" on:click={toggle_navigator}>
202
+ <Icon class="w-8 sm:w-6 h-8 sm:h-6" component={icon}/>
203
203
  </button>
204
204
  </div>
205
205
 
@@ -208,12 +208,12 @@
208
208
  <div class="block sm:hidden mt-3 uppercase text-sm text-center">{@html title}</div>
209
209
  </div>
210
210
 
211
- <div class="flex-none ml-auto flex h-10">
211
+ <div class="flex-none ml-auto flex h-12 sm:h-10">
212
212
  <button
213
- class="h-full w-10 px-0 flex justify-center items-center text-slate-300 hover:text-slate-100"
213
+ class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-slate-300 hover:text-slate-100"
214
214
  on:click={show_options}>
215
215
 
216
- <Icon size={4} component={FaCog} />
216
+ <Icon class="w-5 sm:w-4 h-5 sm:h-4" component={FaCog} />
217
217
  </button>
218
218
  </div>
219
219
 
package/modal.svelte CHANGED
@@ -1,4 +1,5 @@
1
- <script>import Icon from "./components/icon.svelte";
1
+ <script>import { afterUpdate, onMount, tick } from "svelte";
2
+ import Icon from "./components/icon.svelte";
2
3
  export let title = "";
3
4
  export let open = false;
4
5
  export let content = "";
@@ -15,6 +16,18 @@ export function show(on_close_callback = void 0) {
15
16
  open = true;
16
17
  close_callback = on_close_callback;
17
18
  }
19
+ let root;
20
+ afterUpdate(
21
+ async () => {
22
+ if (!!root) {
23
+ let modal_root = document.getElementById("__hd_svelte_modal_root");
24
+ if (!!modal_root && root.parentElement != modal_root) {
25
+ await tick();
26
+ modal_root.appendChild(root);
27
+ }
28
+ }
29
+ }
30
+ );
18
31
  let close_callback = void 0;
19
32
  function on_ok(event) {
20
33
  if (on_ok_callback)
@@ -32,7 +45,7 @@ function on_cancel(event) {
32
45
  </script>
33
46
 
34
47
  {#if open}
35
- <div class="relative z-20" aria-labelledby="modal-title" role="dialog" aria-modal="true">
48
+ <div class="relative z-20" aria-labelledby="modal-title" role="dialog" aria-modal="true" bind:this={root}>
36
49
  <!--
37
50
  Background backdrop, show/hide based on modal state.
38
51
 
@@ -43,9 +56,9 @@ function on_cancel(event) {
43
56
  From: "opacity-100"
44
57
  To: "opacity-0"
45
58
  -->
46
- <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
59
+ <div class="fixed w-screen h-screen inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
47
60
 
48
- <div class="fixed inset-0 z-20 w-screen overflow-y-auto">
61
+ <div class="fixed z-20 inset-0 w-screen overflow-y-auto">
49
62
  <div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
50
63
  <!--
51
64
  Modal panel, show/hide based on modal state.
@@ -57,7 +70,8 @@ function on_cancel(event) {
57
70
  From: "opacity-100 translate-y-0 sm:scale-100"
58
71
  To: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
59
72
  -->
60
- <div class="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
73
+ <div class=" transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all
74
+ sm:my-8 w-full sm:max-w-lg">
61
75
  <div class="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
62
76
  <div class="sm:flex sm:items-start">
63
77
  <div class="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "0.4.42",
3
+ "version": "0.4.44",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
package/utils.js CHANGED
@@ -102,7 +102,8 @@ export function editable(node, action)
102
102
  const org_text = node.textContent;
103
103
  const blur_listener = async (e) =>
104
104
  {
105
- await finish_editing(false, false);
105
+ let cancel = !node.textContent
106
+ await finish_editing(cancel, false);
106
107
  }
107
108
 
108
109
  const key_listener = async (e) =>
@@ -133,6 +134,8 @@ export function editable(node, action)
133
134
  let sel = window.getSelection();
134
135
  sel.removeAllRanges();
135
136
 
137
+ //console.log('cell_content', node.textContent)
138
+
136
139
  if(cancel)
137
140
  {
138
141
  node.innerHTML = org_text;
@@ -156,13 +159,12 @@ export function editable(node, action)
156
159
 
157
160
  const edit_listener = async (e) =>
158
161
  {
159
- //console.log('Edit event fired:', itm, "node", node)
160
162
  node.contentEditable = "true"
161
163
  node.addEventListener("blur", blur_listener);
162
164
  node.addEventListener("keydown", key_listener);
163
165
 
164
166
  node.focus();
165
-
167
+
166
168
  await tick();
167
169
  let range = document.createRange();
168
170
  range.selectNodeContents(node);
@@ -170,7 +172,7 @@ export function editable(node, action)
170
172
  let end_container = range.endContainer;
171
173
  range.setStart(end_container, end_offset)
172
174
  range.setEnd(end_container, end_offset)
173
- console.log('range rect: ', range.getBoundingClientRect())
175
+ // console.log('range rect: ', range.getBoundingClientRect())
174
176
  let sel = window.getSelection();
175
177
  sel.removeAllRanges();
176
178
  sel.addRange(range);
@@ -205,7 +207,7 @@ export function start_editing(element, finish_callback)
205
207
  {
206
208
  if(editable_node.contentEditable == "true")
207
209
  return;
208
-
210
+
209
211
  if(finish_callback)
210
212
  {
211
213
  editable_node.addEventListener("finish", (e) => { finish_callback(e.detail) })