@humandialog/forms.svelte 1.3.6 → 1.3.7

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.
@@ -46,6 +46,7 @@ export function activateMainOperation() {
46
46
  const mainOperationButton = document.getElementById("__hd_fab_mainOperation");
47
47
  if (!mainOperationButton)
48
48
  return;
49
+ console.log("activateMainOperation");
49
50
  mainOperationButton.click();
50
51
  }
51
52
  function on_click(e, operation) {
@@ -184,7 +184,8 @@ const suggestion = {
184
184
  lockNextBlurCallbacks++;
185
185
  suggestionRange = props.range;
186
186
  editor.commands.blur();
187
- setTimeout(() => UI.fab?.activateMainOperation(), 100);
187
+ const cursorRect = props.clientRect();
188
+ setTimeout(() => show_command_palette(cursorRect), 100);
188
189
  } else {
189
190
  const cursorRect = props.clientRect();
190
191
  show_command_palette(cursorRect);
@@ -575,13 +576,26 @@ function on_palette_shown() {
575
576
  function on_palette_hidden() {
576
577
  is_command_palette_visible = false;
577
578
  }
578
- function show_command_palette(cursorRect) {
579
- let rect = cursorRect;
579
+ function show_command_palette(cursor_rect) {
580
580
  let client_rect = get_window_box();
581
+ if (isDeviceSmallerThan("sm"))
582
+ show_small_command_palette(client_rect);
583
+ else
584
+ show_big_command_palette(cursor_rect, client_rect);
585
+ }
586
+ function show_small_command_palette(client_rect) {
587
+ palette.max_height_px = client_rect.height - 64;
588
+ palette.width_px = client_rect.width - 96;
589
+ let x = 64, y = 32;
590
+ let show_above = false;
591
+ palette.show(x, y, show_above);
592
+ }
593
+ function show_big_command_palette(cursor_rect, client_rect) {
594
+ let rect = cursor_rect;
581
595
  let top_space = rect.y;
582
596
  let bottom_space = client_rect.height - (rect.y + rect.height);
583
597
  palette.max_height_px = 500;
584
- palette.width_px = 400;
598
+ palette.width_px = 200;
585
599
  let preferred_palette_height = palette.max_height_px;
586
600
  let preferred_palette_width = palette.width_px;
587
601
  let x = 0, y = 0;
@@ -0,0 +1,59 @@
1
+ <svelte:options accessors={true}/>
2
+ <script>import Icon from "../../icon.svelte";
3
+ export let id;
4
+ export let cmd;
5
+ export let width_px = 400;
6
+ export let is_highlighted = false;
7
+ export let active = false;
8
+ let icon_placeholder_size = cmd.description ? 12 : 6;
9
+ let icon_size = cmd.icon_size ? cmd.icon_size : icon_placeholder_size - 6;
10
+ let cl = $$props.class ?? "";
11
+ $:
12
+ active_class = calculateBackground(is_highlighted, active);
13
+ function calculateBackground(...args) {
14
+ if (is_highlighted) {
15
+ if (active)
16
+ return "bg-stone-400/40 dark:bg-stone-400/40";
17
+ else
18
+ return "bg-stone-400/30 dark:bg-stone-400/30";
19
+ } else {
20
+ if (active)
21
+ return "bg-stone-400/20 dark:bg-stone-400/20";
22
+ else
23
+ return "";
24
+ }
25
+ }
26
+ let element;
27
+ export function scrollToView() {
28
+ element?.scrollIntoView({
29
+ block: "nearest",
30
+ inline: "nearest"
31
+ });
32
+ }
33
+ </script>
34
+
35
+ <!-- svelte-ignore a11y-click-events-have-key-events -->
36
+ <div id={id} class="font-medium m-0 p-0 text-sm w-full text-left flex flew-row cursor-context-menu {active_class} {cl}"
37
+ on:click
38
+ on:mousemove
39
+ on:mousedown
40
+ bind:this={element}>
41
+ <div class="flex items-center justify-center" style:width={`${icon_placeholder_size*0.25}rem`}>
42
+ {#if cmd.icon}
43
+ <Icon size={icon_size} component={cmd.icon}/>
44
+ {/if}
45
+ </div>
46
+ <div class ="">
47
+ <p>{cmd.caption}</p>
48
+ {#if cmd.description}
49
+ {@const shortcut_width_px = cmd.shortcut ? 80 : 0}
50
+ <p class="text-sm font-normal text-stone-400 dark:text-stone-500 truncate inline-block"
51
+ style:max-width={`calc(${width_px-shortcut_width_px} - 3rem)`} >{cmd.description}</p>
52
+ {/if}
53
+ </div>
54
+ {#if cmd.shortcut}
55
+ <div class="pr-1 text-sm font-mono text-stone-500"
56
+ style:width={"80px"} >{cmd.shortcut}</div>
57
+ {/if}
58
+ </div>
59
+
@@ -0,0 +1,46 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Document_command } from './Document_command';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ id: string;
7
+ cmd: Document_command;
8
+ width_px?: number | undefined;
9
+ is_highlighted?: boolean | undefined;
10
+ active?: boolean | undefined;
11
+ scrollToView?: (() => void) | undefined;
12
+ };
13
+ events: {
14
+ click: MouseEvent;
15
+ mousemove: MouseEvent;
16
+ mousedown: MouseEvent;
17
+ } & {
18
+ [evt: string]: CustomEvent<any>;
19
+ };
20
+ slots: {};
21
+ };
22
+ export type PaletteProps = typeof __propDef.props;
23
+ export type PaletteEvents = typeof __propDef.events;
24
+ export type PaletteSlots = typeof __propDef.slots;
25
+ export default class Palette extends SvelteComponentTyped<PaletteProps, PaletteEvents, PaletteSlots> {
26
+ get scrollToView(): () => void;
27
+ get id(): string;
28
+ /**accessor*/
29
+ set id(_: string);
30
+ get cmd(): Document_command;
31
+ /**accessor*/
32
+ set cmd(_: Document_command);
33
+ get width_px(): number | undefined;
34
+ /**accessor*/
35
+ set width_px(_: number | undefined);
36
+ get is_highlighted(): boolean | undefined;
37
+ /**accessor*/
38
+ set is_highlighted(_: boolean | undefined);
39
+ get active(): boolean | undefined;
40
+ /**accessor*/
41
+ set active(_: boolean | undefined);
42
+ get undefined(): any;
43
+ /**accessor*/
44
+ set undefined(_: any);
45
+ }
46
+ export {};
@@ -5,8 +5,8 @@ export let cmd;
5
5
  export let width_px = 400;
6
6
  export let is_highlighted = false;
7
7
  export let active = false;
8
- let icon_placeholder_size = cmd.description ? 12 : 6;
9
- let icon_size = cmd.icon_size ? cmd.icon_size : icon_placeholder_size - 6;
8
+ let icon_size = cmd.icon_size ? cmd.icon_size : 4;
9
+ let icon_placeholder_size = icon_size + 4;
10
10
  let cl = $$props.class ?? "";
11
11
  $:
12
12
  active_class = calculateBackground(is_highlighted, active);
@@ -33,27 +33,17 @@ export function scrollToView() {
33
33
  </script>
34
34
 
35
35
  <!-- svelte-ignore a11y-click-events-have-key-events -->
36
- <div id={id} class="font-medium m-0 p-0 text-sm w-full text-left flex flew-row cursor-context-menu {active_class} {cl}"
36
+ <div id={id} class="w-full text-left flex flew-row cursor-context-menu {active_class} {cl}"
37
37
  on:click
38
38
  on:mousemove
39
39
  on:mousedown
40
40
  bind:this={element}>
41
- <div class="flex items-center justify-center" style:width={`${icon_placeholder_size*0.25}rem`}>
41
+ <div class="flex items-center justify-center space-x-10 px-4 py-2" >
42
42
  {#if cmd.icon}
43
43
  <Icon size={icon_size} component={cmd.icon}/>
44
44
  {/if}
45
45
  </div>
46
- <div class ="">
47
- <p>{cmd.caption}</p>
48
- {#if cmd.description}
49
- {@const shortcut_width_px = cmd.shortcut ? 80 : 0}
50
- <p class="text-sm font-normal text-stone-400 dark:text-stone-500 truncate inline-block"
51
- style:max-width={`calc(${width_px-shortcut_width_px} - 3rem)`} >{cmd.description}</p>
52
- {/if}
53
- </div>
54
- {#if cmd.shortcut}
55
- <div class="pr-1 text-sm font-mono text-stone-500"
56
- style:width={"80px"} >{cmd.shortcut}</div>
57
- {/if}
46
+
47
+ <h4>{cmd.caption}</h4>
58
48
  </div>
59
49
 
@@ -28,6 +28,7 @@ export function showAsToolbox(rect) {
28
28
  toolboxY = rect.bottom + margin;
29
29
  toolboxY += window.scrollY;
30
30
  css_style = `position: fixed; left:${toolboxX}px; top:${toolboxY}px;`;
31
+ console.log("toolbox: ", css_style);
31
32
  dispatch("palette_shown");
32
33
  }
33
34
  let paletteElement;
@@ -220,7 +221,7 @@ function isRowActive(cmd) {
220
221
  </script>
221
222
 
222
223
  {#if isToolbox}
223
- <menu class=" not-prose 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
224
+ <menu 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
224
225
  z-30
225
226
  flex flex-row flex-nowrap"
226
227
  style={css_style}
@@ -259,7 +260,7 @@ function isRowActive(cmd) {
259
260
  </menu>
260
261
  {:else}
261
262
  <div id="__hd_FormattingPalette"
262
- class="not-prose 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"
263
+ 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"
263
264
  hidden={!visible}
264
265
  style={css_style}
265
266
  bind:this={paletteElement}>
package/index.d.ts CHANGED
@@ -54,7 +54,7 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
54
54
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
55
55
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
56
56
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
57
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible } from './utils';
57
+ export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
58
58
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
59
59
  export { data_tick_store, // tmp
60
60
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/index.js CHANGED
@@ -60,7 +60,7 @@ export { default as KanbanComboProperty } from './components/kanban/kanban.combo
60
60
  export { default as KanbanTagsProperty } from './components/kanban/kanban.tags.svelte';
61
61
  export { default as KanbanCallbacks } from './components/kanban/kanban.callbacks.svelte';
62
62
  export { KanbanColumnTop, KanbanColumnBottom } from './components/kanban/Kanban';
63
- export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible } from './utils';
63
+ export { selectItem, activateItem, clearActiveItem, isActive, isSelected, getActive, editable, startEditing, saveCurrentEditable, selectable, handleSelect, isDeviceSmallerThan, resizeImage, refreshToolbarOperations, isOnScreenKeyboardVisible, randomString, } from './utils';
64
64
  export { mainContentPageReloader, reloadMainContentPage, reloadWholeApp, alerts, addAlert, onErrorShowAlert, main_sidebar_visible_store } from './stores.js';
65
65
  export { data_tick_store, // tmp
66
66
  hasSelectedItem, hasDataItem, setNavigatorTitle } from "./stores";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -82,6 +82,7 @@
82
82
  "./components/document/internal/h2.icon.svelte": "./components/document/internal/h2.icon.svelte",
83
83
  "./components/document/internal/h3.icon.svelte": "./components/document/internal/h3.icon.svelte",
84
84
  "./components/document/internal/h4.icon.svelte": "./components/document/internal/h4.icon.svelte",
85
+ "./components/document/internal/palette.row.big.svelte": "./components/document/internal/palette.row.big.svelte",
85
86
  "./components/document/internal/palette.row.svelte": "./components/document/internal/palette.row.svelte",
86
87
  "./components/document/internal/palette.svelte": "./components/document/internal/palette.svelte",
87
88
  "./components/document/internal/Selection_helper": "./components/document/internal/Selection_helper.js",
package/utils.d.ts CHANGED
@@ -31,6 +31,8 @@ export function isOnScreenKeyboardVisible(): boolean;
31
31
  export function isOnNavigationPage(): boolean;
32
32
  export function pushNavigationPage(): void;
33
33
  export function popNavigationPage(): void;
34
+ export function dec2hex(dec: any): any;
35
+ export function randomString(len: any): string;
34
36
  export namespace icons {
35
37
  const symbols: null;
36
38
  }
package/utils.js CHANGED
@@ -643,4 +643,17 @@ export function popNavigationPage()
643
643
  {
644
644
  if(isOnNavigationPage())
645
645
  pop();
646
+ }
647
+
648
+ export function dec2hex (dec)
649
+ {
650
+ return dec.toString(16).padStart(2, "0")
651
+ }
652
+
653
+
654
+ export function randomString(len)
655
+ {
656
+ var arr = new Uint8Array((len || 16) / 2)
657
+ window.crypto.getRandomValues(arr)
658
+ return Array.from(arr, dec2hex).join('')
646
659
  }