@humandialog/forms.svelte 1.3.12 → 1.3.14

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.
@@ -1,9 +1,9 @@
1
1
  <script>import { each } from "svelte/internal";
2
- import { contextToolbarOperations, pageToolbarOperations, contextItemsStore } from "../stores.js";
2
+ import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations } from "../stores.js";
3
3
  import { showFloatingToolbar, showMenu, showGridMenu } from "./menu.js";
4
4
  import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle } from "svelte-icons/fa/";
5
5
  $:
6
- update($pageToolbarOperations, $contextToolbarOperations);
6
+ setupCurrentContextOperations($pageToolbarOperations, $contextToolbarOperations, $toolsActionsOperations);
7
7
  let operations = [];
8
8
  let mainOperation = null;
9
9
  let secondaryOperation = null;
@@ -12,11 +12,17 @@ let isExpandable = false;
12
12
  let vToolboxExpanded = false;
13
13
  let hToolboxExpanded = false;
14
14
  let isDirectPositioningMode = false;
15
- function update(...args) {
15
+ function setupCurrentContextOperations(...args) {
16
16
  isDirectPositioningMode = false;
17
- if ($contextToolbarOperations && Array.isArray($contextToolbarOperations) && $contextToolbarOperations.length > 0)
17
+ if ($toolsActionsOperations && Array.isArray($toolsActionsOperations) && toolsActionsOperations.length > 0) {
18
+ operations = $toolsActionsOperations;
19
+ } else if ($toolsActionsOperations && $toolsActionsOperations.operations && $toolsActionsOperations.operations.length > 0) {
20
+ operations = $toolsActionsOperations.operations;
21
+ if ($toolsActionsOperations.opver && $toolsActionsOperations.opver == 1)
22
+ isDirectPositioningMode = true;
23
+ } else if ($contextToolbarOperations && Array.isArray($contextToolbarOperations) && $contextToolbarOperations.length > 0) {
18
24
  operations = $contextToolbarOperations;
19
- else if ($contextToolbarOperations && $contextToolbarOperations.operations && $contextToolbarOperations.operations.length > 0) {
25
+ } else if ($contextToolbarOperations && $contextToolbarOperations.operations && $contextToolbarOperations.operations.length > 0) {
20
26
  operations = $contextToolbarOperations.operations;
21
27
  if ($contextToolbarOperations.opver && $contextToolbarOperations.opver == 1)
22
28
  isDirectPositioningMode = true;
@@ -189,7 +195,7 @@ function operationVisible(operation) {
189
195
  dark:bg-blue-600/50 dark:hover:bg-blue-700 dark:focus:ring-blue-800
190
196
  flex items-center justify-center
191
197
  disable-dbl-tap-zoom
192
- cursor-pointer z-10"
198
+ cursor-pointer z-40"
193
199
  style={position}
194
200
  on:click|stopPropagation={(e) => {on_click(e, operation)}}
195
201
  on:mousedown={mousedown} >
@@ -1,13 +1,15 @@
1
1
  <script>import { tick, afterUpdate } from "svelte";
2
+ import { isDeviceSmallerThan } from "../utils";
3
+ import { toolsActionsOperations } from "../stores";
4
+ import { FaTimes } from "svelte-icons/fa";
2
5
  let x;
3
6
  let y;
4
7
  let visible = false;
5
8
  let toolbar;
6
9
  let props = {};
7
10
  let around_rect;
8
- let root_element;
9
- $:
10
- display = visible ? "fixed" : "hidden";
11
+ let rootElement;
12
+ let internalElement;
11
13
  export async function show(around, _toolbar, _props = {}) {
12
14
  if (around instanceof DOMRect) {
13
15
  x = around.left;
@@ -19,25 +21,61 @@ export async function show(around, _toolbar, _props = {}) {
19
21
  around_rect = new DOMRect(x, y, 0, 0);
20
22
  }
21
23
  const was_visible = visible;
24
+ if (!was_visible && toolbar == _toolbar && internalElement && internalElement.reload) {
25
+ internalElement.reload();
26
+ }
22
27
  visible = true;
23
28
  toolbar = _toolbar;
24
29
  props = _props;
30
+ cssPosition = calculatePosition(x, y, around_rect, true, true);
25
31
  props.onHide = () => {
26
32
  hide();
27
33
  };
34
+ props.onSizeChanged = () => onSizeChanged();
28
35
  hide_window_indicator = 0;
29
36
  window.addEventListener("click", on_before_window_click, true);
37
+ if (isDeviceSmallerThan("sm")) {
38
+ $toolsActionsOperations = {
39
+ opver: 1,
40
+ operations: [
41
+ {
42
+ caption: "Menu",
43
+ operations: [
44
+ {
45
+ icon: FaTimes,
46
+ action: (f) => {
47
+ hide();
48
+ },
49
+ fab: "M00",
50
+ tbr: "A"
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ };
56
+ }
30
57
  await tick();
31
58
  if (!was_visible)
32
- root_element.addEventListener("click", on_before_container_click, true);
59
+ rootElement.addEventListener("click", on_before_container_click, true);
60
+ cssPosition = calculatePosition(x, y, around_rect, true, false);
33
61
  }
34
62
  export function isVisible() {
35
63
  return visible;
36
64
  }
37
65
  export function hide() {
38
66
  visible = false;
67
+ cssPosition = calculatePosition(x, y, around_rect, false, false);
68
+ $toolsActionsOperations = [];
39
69
  window.removeEventListener("click", on_before_window_click, true);
40
- root_element.removeEventListener("click", on_before_container_click, true);
70
+ rootElement?.removeEventListener("click", on_before_container_click, true);
71
+ }
72
+ export function isSameToolbar(_toolbar) {
73
+ return _toolbar == toolbar;
74
+ }
75
+ async function onSizeChanged() {
76
+ cssPosition = calculatePosition(x, y, around_rect, true, true);
77
+ await tick();
78
+ cssPosition = calculatePosition(x, y, around_rect, true, false);
41
79
  }
42
80
  let hide_window_indicator = 0;
43
81
  function on_before_window_click() {
@@ -52,29 +90,68 @@ function on_before_window_click() {
52
90
  function on_before_container_click() {
53
91
  hide_window_indicator--;
54
92
  }
55
- afterUpdate(() => {
56
- if (!root_element)
57
- return;
58
- let rect = root_element.getBoundingClientRect();
59
- if (rect.height == 0)
60
- return;
61
- const m = 15;
62
- let container_rect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
63
- if (rect.right > container_rect.right)
64
- x = container_rect.right - rect.width;
65
- if (rect.bottom > container_rect.bottom)
66
- y = container_rect.bottom - rect.height - around_rect.height;
67
- if (rect.left < container_rect.left)
68
- x = container_rect.left;
69
- if (rect.top < container_rect.top)
70
- y = container_rect.top;
71
- });
93
+ let cssPosition = "";
94
+ function calculatePosition(x2, y2, around, visible2, fresh) {
95
+ let result = "";
96
+ if (!visible2) {
97
+ result = "display: none";
98
+ } else if (isDeviceSmallerThan("sm")) {
99
+ let screenRect = new DOMRect();
100
+ screenRect.x = 0;
101
+ screenRect.y = 0;
102
+ screenRect.width = window.innerWidth;
103
+ screenRect.height = window.innerHeight;
104
+ const margin = 5;
105
+ let myRect = null;
106
+ if (!fresh) {
107
+ myRect = rootElement.getBoundingClientRect();
108
+ if (myRect && myRect.height == 0)
109
+ myRect = null;
110
+ }
111
+ if (myRect) {
112
+ let maxHeight = screenRect.height / 2 - margin;
113
+ if (myRect.height < maxHeight)
114
+ maxHeight = myRect.height;
115
+ const width = screenRect.width - 2 * margin;
116
+ x2 = margin;
117
+ y2 = screenRect.bottom - maxHeight - margin;
118
+ result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
119
+ } else {
120
+ const maxHeight = screenRect.height / 2 - margin;
121
+ const width = screenRect.width - 2 * margin;
122
+ x2 = margin;
123
+ y2 = screenRect.bottom - maxHeight - margin;
124
+ result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
125
+ }
126
+ } else {
127
+ let myRect = null;
128
+ if (!fresh) {
129
+ myRect = rootElement.getBoundingClientRect();
130
+ if (myRect && myRect.height == 0)
131
+ myRect = null;
132
+ }
133
+ const m = 15;
134
+ let screenRect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
135
+ if (myRect) {
136
+ if (myRect.right > screenRect.right)
137
+ x2 = screenRect.right - myRect.width;
138
+ if (myRect.bottom > screenRect.bottom)
139
+ y2 = screenRect.bottom - myRect.height - around_rect.height;
140
+ if (myRect.left < screenRect.left)
141
+ x2 = screenRect.left;
142
+ if (myRect.top < screenRect.top)
143
+ y2 = screenRect.top;
144
+ }
145
+ result = `left:${x2}px; top:${y2}px; width: max-content; height:max-content; display: block`;
146
+ }
147
+ return result;
148
+ }
72
149
  </script>
73
150
 
74
151
  <div id="__hd_svelte_floating_container"
75
- class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow {display} z-30"
76
- style="left:{x}px; top:{y}px; width: max-content; height:max-content"
77
- bind:this={root_element}>
78
- <svelte:component this={toolbar} {...props} />
152
+ class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow z-30 fixed"
153
+ style={cssPosition}
154
+ bind:this={rootElement}>
155
+ <svelte:component this={toolbar} {...props} bind:this={internalElement} />
79
156
  </div>
80
157
 
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  show?: ((around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>) | undefined;
5
5
  isVisible?: (() => boolean) | undefined;
6
6
  hide?: (() => void) | undefined;
7
+ isSameToolbar?: ((_toolbar: any) => boolean) | undefined;
7
8
  };
8
9
  events: {
9
10
  [evt: string]: CustomEvent<any>;
@@ -17,5 +18,6 @@ export default class FloatingContainer extends SvelteComponentTyped<FloatingCont
17
18
  get show(): (around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>;
18
19
  get isVisible(): () => boolean;
19
20
  get hide(): () => void;
21
+ get isSameToolbar(): (_toolbar: any) => boolean;
20
22
  }
21
23
  export {};
@@ -1,9 +1,9 @@
1
- <script>import { data_tick_store, contextItemsStore, contextTypesStore } from "../../stores.js";
1
+ <script>import { data_tick_store, contextItemsStore, contextTypesStore, toolsActionsOperations } from "../../stores.js";
2
2
  import { informModification, pushChanges } from "../../updates.js";
3
- import { parseWidthDirective, shouldBeComapact } from "../../utils.js";
3
+ import { isDeviceSmallerThan, parseWidthDirective, shouldBeComapact } from "../../utils.js";
4
4
  import { afterUpdate, getContext, onMount, setContext } from "svelte";
5
5
  import { rCombo_definition, rCombo_item, cached_sources } from "./combo";
6
- import FaChevronDown from "svelte-icons/fa/FaChevronDown.svelte";
6
+ import { FaChevronDown, FaTimes } from "svelte-icons/fa";
7
7
  import Icon from "../icon.svelte";
8
8
  import { reef } from "@humandialog/auth.svelte/dist/index.js";
9
9
  export let label = "";
@@ -198,17 +198,25 @@ export function show(event, hide_callback) {
198
198
  show_above = true;
199
199
  } else
200
200
  y = rect.y + rect.height;
201
- if (show_fullscreen) {
201
+ if (isDeviceSmallerThan("sm")) {
202
+ let screenRect = new DOMRect();
203
+ screenRect.x = 0;
204
+ screenRect.y = 0;
205
+ screenRect.width = window.innerWidth;
206
+ screenRect.height = window.innerHeight;
207
+ const margin = 5;
208
+ const maxHeight = screenRect.height / 2 - margin;
209
+ const width = screenRect.width - 2 * margin;
210
+ x = margin;
211
+ y = screenRect.bottom - margin;
212
+ dropdown_position = `position: fixed; left: ${x}px; top: ${y}px; transform: translate(0, -100%); width: ${width}px; max-height: ${maxHeight}px; display: block`;
213
+ } else if (show_fullscreen) {
202
214
  dropdown_position = `position: fixed; left: 0px; top: 0px; width: ${client_rect.width}px; height: ${client_rect.height}px;`;
203
215
  } else {
204
216
  dropdown_position = `min-width: ${palette_width_px}px; max-height:${palette_max_height_px}px; position: fixed; left:${x}px; top:${y}px;`;
205
217
  if (show_above)
206
218
  dropdown_position += " transform: translate(0, -100%);";
207
219
  }
208
- console.log("dropdown_position", dropdown_position, rect, client_rect);
209
- console.log("preferred_palette_height", preferred_palette_height);
210
- console.log("bottom_space", bottom_space);
211
- console.log("top_space", top_space);
212
220
  is_dropdown_open = true;
213
221
  if (filtered) {
214
222
  if (!textbox)
@@ -226,11 +234,33 @@ export function show(event, hide_callback) {
226
234
  subtree: true
227
235
  });
228
236
  }
237
+ if (isDeviceSmallerThan("sm")) {
238
+ $toolsActionsOperations = {
239
+ opver: 1,
240
+ operations: [
241
+ {
242
+ caption: "Menu",
243
+ operations: [
244
+ {
245
+ icon: FaTimes,
246
+ action: (f) => {
247
+ hide();
248
+ },
249
+ fab: "M00",
250
+ tbr: "A"
251
+ }
252
+ ]
253
+ }
254
+ ]
255
+ };
256
+ }
229
257
  }
230
258
  export function hide() {
231
259
  if (mutation_observer)
232
260
  mutation_observer.disconnect();
233
261
  is_dropdown_open = false;
262
+ $toolsActionsOperations = [];
263
+ dropdown_position = "display: none;";
234
264
  combo_text = get_combo_text();
235
265
  if (!!textbox)
236
266
  textbox.innerHtml = combo_text;
@@ -1,8 +1,9 @@
1
1
  <script>import { afterUpdate, tick } from "svelte";
2
2
  import Icon from "./icon.svelte";
3
- import { contextItemsStore } from "../stores";
3
+ import { contextItemsStore, toolsActionsOperations } from "../stores";
4
4
  import { isDeviceSmallerThan, isOnScreenKeyboardVisible } from "../utils";
5
5
  import { hideWholeContextMenu } from "./menu";
6
+ import { FaTimes } from "svelte-icons/fa";
6
7
  export let widthPx = 400;
7
8
  export let menu_items_id_prefix = "__hd_svelte_menuitem_";
8
9
  export let owner_menu_item = void 0;
@@ -16,36 +17,78 @@ let focused_index = 0;
16
17
  let menu_items = [];
17
18
  let submenus = [];
18
19
  let around_rect;
20
+ let css_position = "";
19
21
  $:
20
22
  display = visible ? "block" : "none";
21
- afterUpdate(() => {
22
- let rect = menu_root.getBoundingClientRect();
23
- if (rect.height == 0)
24
- return;
25
- const m = 15;
26
- let container_rect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
27
- if (isOnScreenKeyboardVisible()) {
28
- container_rect.height -= 300;
29
- }
30
- let xShifted = false;
31
- if (rect.right > container_rect.right) {
32
- x = container_rect.right - rect.width + m;
33
- xShifted = true;
34
- }
35
- let yShifted = false;
36
- if (rect.bottom > container_rect.bottom) {
37
- y = container_rect.bottom - rect.height - m;
38
- if (xShifted)
39
- x -= around_rect.width;
40
- else
41
- y -= around_rect.height - m;
42
- yShifted = true;
23
+ function calculatePosition(x2, y2, around, visible2, fresh) {
24
+ let result = "";
25
+ if (!visible2) {
26
+ result = "display: none";
27
+ } else if (isDeviceSmallerThan("sm")) {
28
+ let screenRect = new DOMRect();
29
+ screenRect.x = 0;
30
+ screenRect.y = 0;
31
+ screenRect.width = window.innerWidth;
32
+ screenRect.height = window.innerHeight;
33
+ const margin = 5;
34
+ let myRect = null;
35
+ if (!fresh) {
36
+ myRect = menu_root.getBoundingClientRect();
37
+ if (myRect.height == 0) {
38
+ myRect = null;
39
+ }
40
+ }
41
+ if (myRect) {
42
+ let maxHeight = screenRect.height / 2 - margin;
43
+ if (myRect.height < maxHeight)
44
+ maxHeight = myRect.height;
45
+ const width = screenRect.width - 2 * margin;
46
+ x2 = margin;
47
+ y2 = screenRect.bottom - maxHeight - margin;
48
+ result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
49
+ } else {
50
+ const maxHeight = screenRect.height / 2 - margin;
51
+ const width = screenRect.width - 2 * margin;
52
+ x2 = margin;
53
+ y2 = screenRect.bottom - maxHeight - margin;
54
+ result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
55
+ }
56
+ } else {
57
+ let myRect = null;
58
+ if (!fresh) {
59
+ myRect = menu_root.getBoundingClientRect();
60
+ if (myRect.height == 0) {
61
+ myRect = null;
62
+ }
63
+ }
64
+ if (myRect) {
65
+ const m = 15;
66
+ let screenRect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
67
+ let xShifted = false;
68
+ if (myRect.right > screenRect.right) {
69
+ x2 = screenRect.right - myRect.width + m;
70
+ xShifted = true;
71
+ }
72
+ let yShifted = false;
73
+ if (myRect.bottom > screenRect.bottom) {
74
+ y2 = screenRect.bottom - myRect.height - m;
75
+ if (around) {
76
+ if (xShifted)
77
+ x2 -= around.width;
78
+ else
79
+ y2 -= around.height - m;
80
+ }
81
+ yShifted = true;
82
+ }
83
+ if (myRect.left < screenRect.left)
84
+ x2 = screenRect.left;
85
+ if (myRect.top < screenRect.top)
86
+ y2 = screenRect.top;
87
+ }
88
+ result = `left:${x2}px; top:${y2}px; display: block`;
43
89
  }
44
- if (rect.left < container_rect.left)
45
- x = container_rect.left;
46
- if (rect.top < container_rect.top)
47
- y = container_rect.top;
48
- });
90
+ return result;
91
+ }
49
92
  export async function show(around, _operations) {
50
93
  if (around instanceof DOMRect) {
51
94
  x = around.left;
@@ -57,6 +100,7 @@ export async function show(around, _operations) {
57
100
  around_rect = new DOMRect(x, y, 0, 0);
58
101
  }
59
102
  visible = true;
103
+ css_position = calculatePosition(x, y, around_rect, true, true);
60
104
  operations = [..._operations];
61
105
  focused_index = operations.findIndex((o) => !o.disabled);
62
106
  const is_root_menu = owner_menu_item == void 0;
@@ -64,7 +108,28 @@ export async function show(around, _operations) {
64
108
  hide_window_indicator = 0;
65
109
  window.addEventListener("click", on_before_window_click, true);
66
110
  }
111
+ if (isDeviceSmallerThan("sm")) {
112
+ $toolsActionsOperations = {
113
+ opver: 1,
114
+ operations: [
115
+ {
116
+ caption: "Menu",
117
+ operations: [
118
+ {
119
+ icon: FaTimes,
120
+ action: (f) => {
121
+ hide();
122
+ },
123
+ fab: "M00",
124
+ tbr: "A"
125
+ }
126
+ ]
127
+ }
128
+ ]
129
+ };
130
+ }
67
131
  await tick();
132
+ css_position = calculatePosition(x, y, around_rect, true, false);
68
133
  if (is_root_menu)
69
134
  menu_root.addEventListener("click", on_before_container_click, true);
70
135
  if (menu_items.length && !isDeviceSmallerThan("sm"))
@@ -74,7 +139,9 @@ export function isVisible() {
74
139
  return visible;
75
140
  }
76
141
  export function hide() {
142
+ $toolsActionsOperations = [];
77
143
  visible = false;
144
+ css_position = calculatePosition(x, y, around_rect, false, false);
78
145
  window.removeEventListener("click", on_before_window_click, true);
79
146
  menu_root.removeEventListener("click", on_before_container_click, true);
80
147
  }
@@ -210,8 +277,8 @@ function mousedown(e) {
210
277
 
211
278
  <div id="__hd_svelte_contextmenu"
212
279
  class=" bg-white dark:bg-stone-700 text-stone-600 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-900 shadow-md
213
- z-30 fixed min-w-[{min_width_px}px] w-max"
214
- style={`left:${x}px; top:${y}px; display:${display}`}
280
+ z-30 fixed min-w-[{min_width_px}px] w-max overflow-y-auto"
281
+ style={css_position}
215
282
  bind:this={menu_root}>
216
283
 
217
284
  {#each operations as operation, index}
@@ -26,7 +26,7 @@ import Underline from "@tiptap/extension-underline";
26
26
  import Dropcursor from "@tiptap/extension-dropcursor";
27
27
  import Gapcursor from "@tiptap/extension-gapcursor";
28
28
  import History from "@tiptap/extension-history";
29
- import { data_tick_store, contextItemsStore, contextTypesStore, onErrorShowAlert } from "../../stores.js";
29
+ import { data_tick_store, contextItemsStore, contextTypesStore, onErrorShowAlert, toolsActionsOperations } from "../../stores.js";
30
30
  import { informModification, pushChanges } from "../../updates.js";
31
31
  import { isDeviceSmallerThan, parseWidthDirective, refreshToolbarOperations, UI } from "../../utils.js";
32
32
  import Palette from "./internal/palette.svelte";
@@ -46,7 +46,8 @@ import {
46
46
  FaArrowLeft,
47
47
  FaGripLines,
48
48
  FaListUl,
49
- FaTable
49
+ FaTable,
50
+ FaTimes
50
51
  } from "svelte-icons/fa";
51
52
  import IcH1 from "./internal/h1.icon.svelte";
52
53
  import IcH2 from "./internal/h2.icon.svelte";
@@ -75,20 +76,6 @@ export function run(onStop = void 0) {
75
76
  let suggestionRange = void 0;
76
77
  export function getFormattingOperations(withCaptions = false) {
77
78
  let result = [];
78
- if (isDeviceSmallerThan("sm")) {
79
- result = [
80
- {
81
- caption: "Back to edit",
82
- icon: FaArrowLeft,
83
- action: (fi) => {
84
- editor?.commands.focus();
85
- }
86
- },
87
- {
88
- separator: true
89
- }
90
- ];
91
- }
92
79
  commands.forEach((c2) => {
93
80
  if (c2.separator) {
94
81
  result.push({ separator: true });
@@ -97,7 +84,8 @@ export function getFormattingOperations(withCaptions = false) {
97
84
  caption: withCaptions ? c2.caption : "",
98
85
  icon: c2.icon,
99
86
  action: (f) => c2.on_choice(suggestionRange),
100
- activeFunc: c2.is_active
87
+ activeFunc: c2.is_active,
88
+ tbr: "B"
101
89
  });
102
90
  }
103
91
  });
@@ -574,9 +562,31 @@ function on_palette_mouse_click() {
574
562
  }
575
563
  function on_palette_shown() {
576
564
  is_command_palette_visible = true;
565
+ if (isDeviceSmallerThan("sm")) {
566
+ $toolsActionsOperations = {
567
+ opver: 1,
568
+ operations: [
569
+ {
570
+ caption: "Palette",
571
+ operations: [
572
+ {
573
+ icon: FaTimes,
574
+ action: (f) => {
575
+ palette.hide();
576
+ editor?.commands.focus();
577
+ },
578
+ fab: "M00",
579
+ tbr: "A"
580
+ }
581
+ ]
582
+ }
583
+ ]
584
+ };
585
+ }
577
586
  }
578
587
  function on_palette_hidden() {
579
588
  is_command_palette_visible = false;
589
+ $toolsActionsOperations = [];
580
590
  }
581
591
  function show_command_palette(cursor_rect) {
582
592
  let client_rect = get_window_box();
@@ -664,9 +674,7 @@ function handleImagesChanges(transaction) {
664
674
  }
665
675
  let commands = [
666
676
  //{ caption: 'Styles', separator: true },
667
- { caption: "Back to edit", description: "Escape", icon: FaArrowLeft, on_choice: () => {
668
- editor?.commands.focus();
669
- }, is_visible: () => isDeviceSmallerThan("sm") },
677
+ // { caption: 'Back to edit', description: 'Escape', icon: FaArrowLeft, on_choice: () => { editor?.commands.focus()}, is_visible: () => isDeviceSmallerThan("sm") },
670
678
  { caption: "Normal", description: "This is normal text style", tags: "text", icon: FaRemoveFormat, on_choice: (range) => {
671
679
  if (range)
672
680
  editor.chain().focus().deleteRange(range).setParagraph().run();
@@ -38,7 +38,7 @@ export function scrollToView() {
38
38
  on:mousemove
39
39
  on:mousedown
40
40
  bind:this={element}>
41
- <div class="flex items-center justify-center space-x-10 px-4 py-2" >
41
+ <div class="flex items-center justify-center space-x-10 px-4 py-2 ml-12 sm:ml-0" >
42
42
  {#if cmd.icon}
43
43
  <Icon size={icon_size} component={cmd.icon}/>
44
44
  {/if}
@@ -3,7 +3,7 @@
3
3
  import Pallete_row from "./palette.row.svelte";
4
4
  import { createEventDispatcher } from "svelte";
5
5
  import Icon from "../../icon.svelte";
6
- import { isDeviceSmallerThan } from "../../../utils.js";
6
+ import { isDeviceSmallerThan, UI } from "../../../utils.js";
7
7
  export let commands;
8
8
  export let width_px = 400;
9
9
  export let max_height_px = 500;
@@ -265,11 +265,12 @@ function isRowActive(cmd) {
265
265
  {/if}
266
266
  </menu>
267
267
  {:else}
268
- <div id="__hd_FormattingPalette"
269
- class="bg-white dark:bg-stone-800 text-stone-500 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-700 shadow-md z-30 overflow-y-auto"
268
+ <div class="bg-white dark:bg-stone-800 text-stone-500 dark:text-stone-400 rounded-lg border border-stone-200 dark:border-stone-700 shadow-md overflow-y-auto z-20"
269
+ id="__hd_FormattingPalette"
270
+ bind:this={paletteElement}
270
271
  hidden={!visible}
271
- style={css_style}
272
- bind:this={paletteElement}>
272
+ style={css_style} >
273
+
273
274
  {#if filtered_commands && filtered_commands.length}
274
275
  {#each filtered_commands as cmd, idx (cmd.caption)}
275
276
  {#if cmd.separator}
@@ -295,5 +296,6 @@ function isRowActive(cmd) {
295
296
  {/if}
296
297
 
297
298
  </div>
299
+
298
300
  {/if}
299
301
 
@@ -28,6 +28,7 @@ export declare class rList_property_tags extends rList_property {
28
28
  onUpdateAllTags: Function | undefined;
29
29
  }
30
30
  export declare class rList_definition {
31
+ name: string;
31
32
  title: string;
32
33
  title_editable: boolean;
33
34
  on_title_changed: Function | undefined;
@@ -36,6 +36,7 @@ export class rList_property_tags extends rList_property {
36
36
  onUpdateAllTags = undefined;
37
37
  }
38
38
  export class rList_definition {
39
+ name = '';
39
40
  title = '';
40
41
  title_editable = false;
41
42
  on_title_changed = undefined;
@@ -21,8 +21,8 @@ export let item;
21
21
  export let title = "";
22
22
  export let summary = "";
23
23
  export let typename = void 0;
24
- export let toolbarOperations;
25
- export let contextMenu;
24
+ export let toolbarOperations = void 0;
25
+ export let contextMenu = void 0;
26
26
  let definition = getContext("rList-definition");
27
27
  let placeholder = "";
28
28
  let props_sm;
@@ -47,10 +47,10 @@ if (!typename) {
47
47
  }
48
48
  let item_key = "";
49
49
  let keys = Object.keys(item);
50
- if (keys.includes("Id"))
51
- item_key = "Id";
52
- else if (keys.includes("$ref"))
50
+ if (keys.includes("$ref"))
53
51
  item_key = "$ref";
52
+ else if (keys.includes("Id"))
53
+ item_key = "Id";
54
54
  else if (keys.length > 0)
55
55
  item_key = keys[0];
56
56
  if (!title)
@@ -152,9 +152,11 @@ function getHRef() {
152
152
  return "";
153
153
  }
154
154
  function activate_row(e, item2) {
155
- activateItem("props", item2, toolbarOperations(item2));
156
- if (e)
157
- e.stopPropagation();
155
+ if (toolbarOperations) {
156
+ activateItem("props", item2, toolbarOperations(item2));
157
+ if (e)
158
+ e.stopPropagation();
159
+ }
158
160
  }
159
161
  function on_contextmenu(e) {
160
162
  if (!contextMenu)
@@ -318,7 +320,7 @@ export function scrollToView() {
318
320
  {#key item[summary] }
319
321
  {#if is_row_active}
320
322
  <p id={element_id}
321
- class=" text-sm mb-2
323
+ class=" text-sm
322
324
  text-stone-400"
323
325
  use:editable={{
324
326
  action: (text) => {change_summary(text)},
@@ -330,7 +332,7 @@ export function scrollToView() {
330
332
  </p>
331
333
  {:else}
332
334
  <p id={element_id}
333
- class=" text-sm mb-2
335
+ class=" text-sm
334
336
  text-stone-400"
335
337
  on:click={(e) => on_active_row_clicked(e, 'bottom')}>
336
338
  {item[summary]}
@@ -5,8 +5,8 @@ declare const __propDef: {
5
5
  title?: string | undefined;
6
6
  summary?: string | undefined;
7
7
  typename?: string | undefined;
8
- toolbarOperations: any;
9
- contextMenu: any;
8
+ toolbarOperations?: undefined;
9
+ contextMenu?: undefined;
10
10
  activate?: (() => void) | undefined;
11
11
  editProperty?: ((field: string) => void) | undefined;
12
12
  scrollToView?: (() => void) | undefined;
@@ -26,7 +26,7 @@ async function onSummaryChanged(text) {
26
26
  }
27
27
  </script>
28
28
 
29
- <section class="mt-3 my-0 w-full text-lg sm:text-sm text-stone-700 dark:text-stone-400 cursor-default rounded-md border border-transparent bg-stone-200 dark:bg-stone-700">
29
+ <section class=" my-1 w-full text-base text-stone-700 dark:text-stone-400 cursor-default rounded-md border border-transparent bg-stone-200 dark:bg-stone-700">
30
30
  <div class="flex flex-row">
31
31
  {#if icon}
32
32
  <!--Icon size={3}
@@ -36,8 +36,8 @@ async function onSummaryChanged(text) {
36
36
  {/if}
37
37
 
38
38
  <p class=" ml-3 py-1
39
- text-lg font-semibold min-h-[1.75rem]
40
- sm:text-sm sm:font-semibold sm:min-h-[1.25rem]
39
+ text-base font-semibold min-h-[1.75rem]
40
+ sm:min-h-[1.25rem]
41
41
  whitespace-nowrap overflow-clip flex-none w-1/2 sm:w-1/3" tabindex="0"
42
42
  bind:this={titleElement}
43
43
  use:editable={{
@@ -51,8 +51,8 @@ async function onSummaryChanged(text) {
51
51
  {#if editSummary}
52
52
  <p bind:this={summaryElement}
53
53
  class=" ml-10 sm:ml-9
54
- sm:text-xs sm:min-h-[1rem]
55
- text-base min-h-[1.5rem]
54
+ sm:min-h-[1rem]
55
+ text-sm min-h-[1.5rem]
56
56
  text-stone-400"
57
57
  use:editable={{
58
58
  action: onSummaryChanged,
@@ -1,5 +1,5 @@
1
1
  <script>import { setContext, getContext, afterUpdate, tick, onMount } from "svelte";
2
- import { data_tick_store, contextItemsStore, contextTypesStore, page_title } from "../../stores";
2
+ import { data_tick_store, contextItemsStore, contextTypesStore } from "../../stores";
3
3
  import { activateItem, getActive, clearActiveItem, parseWidthDirective, getPrev, getNext, swapElements, getLast, insertAfter } from "../../utils";
4
4
  import { rList_definition } from "./List";
5
5
  import List_element from "./internal/list.element.svelte";
@@ -13,8 +13,8 @@ export let orderAttrib = void 0;
13
13
  export let context = "";
14
14
  export let typename = "";
15
15
  export let c = "";
16
- export let toolbarOperations;
17
- export let contextMenu;
16
+ export let toolbarOperations = void 0;
17
+ export let contextMenu = void 0;
18
18
  export let key = "";
19
19
  export const CLEAR_SELECTION = 0;
20
20
  export const KEEP_SELECTION = -1;
@@ -26,6 +26,7 @@ export const MIN_ORDER = 0;
26
26
  let definition = new rList_definition();
27
27
  setContext("rList-definition", definition);
28
28
  setContext("rIs-table-component", true);
29
+ definition.name = `List ${a}`;
29
30
  let item = null;
30
31
  let items = void 0;
31
32
  let ctx = context ? context : getContext("ctx");
@@ -35,7 +36,8 @@ const END_OF_LIST = {};
35
36
  let rows = [];
36
37
  let activate_after_dom_update = null;
37
38
  let inserter;
38
- clearActiveItem("props");
39
+ if (toolbarOperations)
40
+ clearActiveItem("props");
39
41
  let last_tick = -1;
40
42
  $:
41
43
  setup($data_tick_store, $contextItemsStore);
@@ -55,10 +57,10 @@ function setup(...args) {
55
57
  function getItemKey(item2) {
56
58
  if (key)
57
59
  return item2[key];
58
- else if (item2.Id)
59
- return item2.Id;
60
60
  else if (item2.$ref)
61
61
  return item2.$ref;
62
+ else if (item2.Id)
63
+ return item2.Id;
62
64
  else
63
65
  return 0;
64
66
  }
@@ -9,8 +9,8 @@ declare const __propDef: {
9
9
  context?: string | undefined;
10
10
  typename?: string | undefined;
11
11
  c?: string | undefined;
12
- toolbarOperations: any;
13
- contextMenu: any;
12
+ toolbarOperations?: undefined;
13
+ contextMenu?: undefined;
14
14
  key?: string | undefined;
15
15
  CLEAR_SELECTION?: 0 | undefined;
16
16
  KEEP_SELECTION?: -1 | undefined;
@@ -39,14 +39,12 @@ export function showFloatingToolbar(around, toolbar, props = {}) {
39
39
  toolbar_component.show(around, toolbar, props);
40
40
  }
41
41
  else if (toolbar_component) {
42
- //if(toolbar_component.isVisible())
43
- //{
44
- // toolbar_component.hide();
45
- //}
46
- //else
47
- //{
48
- toolbar_component.show(around, toolbar, props);
49
- //}
42
+ if (toolbar_component.isVisible() && toolbar_component.isSameToolbar(toolbar)) {
43
+ toolbar_component.hide();
44
+ }
45
+ else {
46
+ toolbar_component.show(around, toolbar, props);
47
+ }
50
48
  }
51
49
  else
52
50
  console.error('what now?');
@@ -1,4 +1,4 @@
1
- <script>import { getContext } from "svelte";
1
+ <script>import { getContext, tick } from "svelte";
2
2
  import Icon from "../icon.svelte";
3
3
  import { contextItemsStore, auto_hide_sidebar, contextToolbarOperations } from "../../stores";
4
4
  import { FaBars, FaEllipsisH } from "svelte-icons/fa";
package/desk.svelte CHANGED
@@ -95,7 +95,7 @@
95
95
  lg_content_area_horizontal_dim = ""
96
96
  }
97
97
 
98
- console.log('main_side_panel_visibility', main_side_panel_visibility)
98
+ //console.log('main_side_panel_visibility', main_side_panel_visibility)
99
99
  }
100
100
 
101
101
  let tools_visibility = "hidden"
@@ -268,6 +268,7 @@
268
268
 
269
269
  function onSelectionChanged(e)
270
270
  {
271
+ console.log('onSelectionChanged')
271
272
  determineFABVisibilityAsync();
272
273
  }
273
274
 
package/index.d.ts CHANGED
@@ -55,7 +55,7 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
55
55
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
56
56
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
57
57
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
58
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
58
+ export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, UI, } from './utils';
59
59
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
60
60
  export { data_tick_store, // tmp
61
61
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/index.js CHANGED
@@ -61,7 +61,7 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
61
61
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
62
62
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
63
63
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
64
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
64
+ export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, UI, } from './utils';
65
65
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
66
66
  export { data_tick_store, // tmp
67
67
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/modal.svelte CHANGED
@@ -1,5 +1,8 @@
1
1
  <script>import { afterUpdate, onMount, tick } from "svelte";
2
2
  import Icon from "./components/icon.svelte";
3
+ import { toolsActionsOperations } from "./stores.js";
4
+ import { isDeviceSmallerThan } from "./utils";
5
+ import { FaTimes } from "svelte-icons/fa";
3
6
  export let title = "";
4
7
  export let open = false;
5
8
  export let content = "";
@@ -16,9 +19,30 @@ export let onCancelCallback = void 0;
16
19
  export function show(on_close_callback = void 0) {
17
20
  open = true;
18
21
  close_callback = on_close_callback;
22
+ if (isDeviceSmallerThan("sm")) {
23
+ $toolsActionsOperations = {
24
+ opver: 1,
25
+ operations: [
26
+ {
27
+ caption: "Modal",
28
+ operations: [
29
+ {
30
+ icon: FaTimes,
31
+ action: (f) => {
32
+ on_cancel(void 0);
33
+ },
34
+ fab: "M00",
35
+ tbr: "A"
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ };
41
+ }
19
42
  }
20
43
  export function hide() {
21
44
  open = false;
45
+ $toolsActionsOperations = [];
22
46
  }
23
47
  let root;
24
48
  afterUpdate(
@@ -40,7 +64,7 @@ function on_ok(event) {
40
64
  close_callback("OK");
41
65
  }
42
66
  function on_cancel(event) {
43
- open = false;
67
+ hide();
44
68
  if (onCancelCallback)
45
69
  onCancelCallback();
46
70
  if (close_callback)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "type": "module",
28
28
  "dependencies": {
29
- "@humandialog/auth.svelte": "^1.8.4",
29
+ "@humandialog/auth.svelte": "^1.8.5",
30
30
  "@tiptap/core": "^2.11.0",
31
31
  "@tiptap/extension-bullet-list": "^2.11.5",
32
32
  "@tiptap/extension-code-block": "^2.11.5",
package/stores.d.ts CHANGED
@@ -27,6 +27,7 @@ export const contextTypesStore: import("svelte/store").Writable<{
27
27
  }>;
28
28
  export const contextToolbarOperations: import("svelte/store").Writable<never[]>;
29
29
  export const pageToolbarOperations: import("svelte/store").Writable<never[]>;
30
+ export const toolsActionsOperations: import("svelte/store").Writable<never[]>;
30
31
  export const page_title: import("svelte/store").Writable<string>;
31
32
  export const nav_titles: import("svelte/store").Writable<{}>;
32
33
  export const mainContentPageReloader: import("svelte/store").Writable<number>;
package/stores.js CHANGED
@@ -8,6 +8,7 @@ export const context_info_store = writable({data: '', sel: ''})
8
8
  export const contextTypesStore = writable({focused:'', data: null, sel: null})
9
9
  export const contextToolbarOperations = writable([]);
10
10
  export const pageToolbarOperations = writable([]);
11
+ export const toolsActionsOperations = writable([]);
11
12
  export const page_title = writable('');
12
13
  export const nav_titles = writable({});
13
14
  export const mainContentPageReloader = writable(1);
@@ -120,9 +121,11 @@ export function restore_defults()
120
121
 
121
122
  export function toggle_sidebar(index)
122
123
  {
123
- previously_visible_sidebar = get(main_sidebar_visible_store);
124
+ const prevVisile = get(main_sidebar_visible_store);
125
+ if(prevVisile != '*')
126
+ previously_visible_sidebar = prevVisile;
124
127
 
125
- console.log('toggle_sidebar', previously_visible_sidebar, '=>', index)
128
+ //console.log('toggle_sidebar', previously_visible_sidebar, '=>', index)
126
129
 
127
130
  if(get(main_sidebar_visible_store) == index)
128
131
  main_sidebar_visible_store.set('*')
@@ -132,7 +135,8 @@ export function toggle_sidebar(index)
132
135
 
133
136
  export function auto_hide_sidebar()
134
137
  {
135
- console.log('auto_hide_sidebar')
138
+
139
+ //console.log('auto_hide_sidebar')
136
140
  //console.log("sw: " + window.innerWidth, SCREEN_SIZES.lg)
137
141
  if(window.innerWidth < SCREEN_SIZES.lg)
138
142
  hide_sidebar()
@@ -140,14 +144,21 @@ export function auto_hide_sidebar()
140
144
 
141
145
  export function hide_sidebar()
142
146
  {
143
- previously_visible_sidebar = get(main_sidebar_visible_store);
147
+
148
+ const prevVisile = get(main_sidebar_visible_store);
149
+ if(prevVisile != '*')
150
+ previously_visible_sidebar = prevVisile;
151
+
144
152
  main_sidebar_visible_store.set('*')
145
153
  //console.log("auto_hide_sidebar:" + get(main_sidebar_visible_store))
146
154
  }
147
155
 
148
156
  export function show_sidebar(index)
149
157
  {
150
- previously_visible_sidebar = get(main_sidebar_visible_store);
158
+ const prevVisile = get(main_sidebar_visible_store);
159
+ if(prevVisile != '*')
160
+ previously_visible_sidebar = prevVisile;
161
+
151
162
  main_sidebar_visible_store.set(index)
152
163
  }
153
164
 
package/updates.js CHANGED
@@ -122,6 +122,7 @@ update_request_ticket.subscribe(async (v) => {
122
122
  changes.push(value.item);
123
123
  });
124
124
 
125
+
125
126
  /*
126
127
  const res = await reef.post('/Push', { Items: changes }, onErrorShowAlert);
127
128
 
package/utils.d.ts CHANGED
@@ -46,5 +46,6 @@ export let currentEditable: null;
46
46
  export namespace UI {
47
47
  const operations: null;
48
48
  const fab: null;
49
+ const navigator: null;
49
50
  }
50
51
  export const NAVIGATION_PAGE_PATH: "/";
package/utils.js CHANGED
@@ -350,6 +350,7 @@ export function editable(node, params)
350
350
 
351
351
  return {
352
352
  destroy() {
353
+
353
354
  node.removeEventListener("edit", edit_listener)
354
355
  node.classList.remove("editable")
355
356
  node.contentEditable = "false"
@@ -650,7 +651,8 @@ export function isOnScreenKeyboardVisible()
650
651
 
651
652
  export const UI = {
652
653
  operations: null,
653
- fab: null
654
+ fab: null,
655
+ navigator: null
654
656
  }
655
657
 
656
658
  export const NAVIGATION_PAGE_PATH = '/'