@humandialog/forms.svelte 1.4.6 → 1.4.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.
@@ -1,10 +1,10 @@
1
1
  <script>import { each } from "svelte/internal";
2
- import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations } from "../stores.js";
2
+ import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations, fabCollapsed } from "../stores.js";
3
3
  import { showFloatingToolbar, showMenu, showGridMenu } from "./menu.js";
4
- import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV } from "svelte-icons/fa/";
4
+ import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV, FaRegDotCircle, FaDotCircle } from "svelte-icons/fa/";
5
5
  import { isDeviceSmallerThan } from "../utils.js";
6
6
  $:
7
- setupCurrentContextOperations($pageToolbarOperations, $contextToolbarOperations, $toolsActionsOperations);
7
+ setupCurrentContextOperations($pageToolbarOperations, $contextToolbarOperations, $toolsActionsOperations, $fabCollapsed);
8
8
  let operations = [];
9
9
  let mainOperation = null;
10
10
  let secondaryOperation = null;
@@ -83,6 +83,16 @@ function setupCurrentContextOperations(...args) {
83
83
  }
84
84
  });
85
85
  });
86
+ if (operations.length > 1) {
87
+ if (!operations.find((op) => op.fab == "M10")) {
88
+ const collapseFAB = {
89
+ icon: $fabCollapsed ? FaRegDotCircle : FaDotCircle,
90
+ fab: "M10",
91
+ action: (f) => toggleExpandAdditionalOperations()
92
+ };
93
+ operations = [...operations, collapseFAB];
94
+ }
95
+ }
86
96
  } else {
87
97
  if (operations.length > 0)
88
98
  mainOperation = operations[0];
@@ -105,6 +115,9 @@ function setupCurrentContextOperations(...args) {
105
115
  isExpandable = false;
106
116
  }
107
117
  }
118
+ function toggleExpandAdditionalOperations() {
119
+ $fabCollapsed = !$fabCollapsed;
120
+ }
108
121
  export function activateMainOperation() {
109
122
  const mainOperationButton = document.getElementById("__hd_fab_mainOperation");
110
123
  if (!mainOperationButton)
@@ -227,7 +240,14 @@ function calculatePosition(operation) {
227
240
  function operationVisible(operation) {
228
241
  if (!operation.fab)
229
242
  return false;
230
- return true;
243
+ if ($fabCollapsed) {
244
+ if (operation.fab == "M00")
245
+ return true;
246
+ if (operation.fab == "M10")
247
+ return true;
248
+ return false;
249
+ } else
250
+ return true;
231
251
  }
232
252
  </script>
233
253
 
@@ -238,12 +258,12 @@ function operationVisible(operation) {
238
258
  {@const position = calculatePosition(operation)}
239
259
  {#if position}
240
260
  <button
241
- class="text-stone-500 bg-stone-200/70 hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300
242
- font-medium rounded-full text-sm text-center
261
+ class=" text-stone-500 bg-stone-200/70 hover:bg-stone-200
262
+ focus:outline-none font-medium rounded-full text-sm text-center
263
+ dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
264
+ focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800
243
265
  w-[30px] h-[30px]
244
- fixed m-0
245
- dark:text-stone-500
246
- dark:bg-stone-700/80 dark:hover:bg-blue-700 dark:focus:ring-blue-800
266
+ fixed m-0
247
267
  flex items-center justify-center
248
268
  disable-dbl-tap-zoom
249
269
  cursor-pointer z-40"
@@ -22,7 +22,7 @@ export async function show(around, _toolbar, _props = {}) {
22
22
  }
23
23
  const was_visible = visible;
24
24
  if (!was_visible && toolbar == _toolbar && internalElement && internalElement.reload) {
25
- internalElement.reload();
25
+ internalElement.reload(_props);
26
26
  }
27
27
  visible = true;
28
28
  toolbar = _toolbar;
@@ -16,4 +16,7 @@ definition.element_key = key;
16
16
  definition.element_name = name;
17
17
  definition.element_avatar = avatar;
18
18
  definition.element_icon = icon;
19
+ export function updateObjects(objects2) {
20
+ definition.collection = objects2;
21
+ }
19
22
  </script>
@@ -9,6 +9,7 @@ declare const __propDef: {
9
9
  name?: string | undefined;
10
10
  avatar?: string | undefined;
11
11
  icon?: string | undefined;
12
+ updateObjects?: ((objects: object[]) => void) | undefined;
12
13
  };
13
14
  events: {
14
15
  [evt: string]: CustomEvent<any>;
@@ -19,5 +20,6 @@ export type ComboProps = typeof __propDef.props;
19
20
  export type ComboEvents = typeof __propDef.events;
20
21
  export type ComboSlots = typeof __propDef.slots;
21
22
  export default class Combo extends SvelteComponentTyped<ComboProps, ComboEvents, ComboSlots> {
23
+ get updateObjects(): (objects: object[]) => void;
22
24
  }
23
25
  export {};
@@ -630,13 +630,13 @@ function on_focus_out(e) {
630
630
  {#if true || !is_dropdown_open}
631
631
  {#if icon && sel_item}
632
632
  {#if sel_item.Color}
633
- <Icon size={5} circle={true} color={sel_item.Color}/>
633
+ <Icon s="xl" circle={true} color={sel_item.Color}/>
634
634
  {:else if sel_item.Icon}
635
- <Icon size={4} component={sel_item.Icon}/>
635
+ <Icon s="md" component={sel_item.Icon}/>
636
636
  {:else if sel_item.Icon == null}
637
637
  <div class="w-4 h-4"></div>
638
638
  {:else}
639
- <Icon size={5} circle={true} symbol={sel_item.Avatar} label={sel_item.Name}/>
639
+ <Icon s="xl" circle={true} symbol={sel_item.Avatar} label={sel_item.Name}/>
640
640
  {/if}
641
641
  {/if}
642
642
  {/if}
@@ -701,17 +701,17 @@ function on_focus_out(e) {
701
701
 
702
702
  {#if icon}
703
703
  {#if item.Color}
704
- <Icon size={4} circle={true} color={item.Color}/>
704
+ <Icon s="md" circle={true} color={item.Color}/>
705
705
  {:else if item.Avatar}
706
- <Icon size={4} circle={true} symbol={item.Avatar}/>
706
+ <Icon s="md" circle={true} symbol={item.Avatar}/>
707
707
  {:else if item.Icon}
708
- <Icon size={4} component={item.Icon}/>
708
+ <Icon s="md" component={item.Icon}/>
709
709
  {:else if item.Icon == null}
710
710
  <div class="w-4 h-4"></div>
711
711
  {:else if item.Name}
712
- <Icon size={4} circle={true} label={item.Name}/>
712
+ <Icon s="md" circle={true} label={item.Name}/>
713
713
  {:else}
714
- <Icon size={4} circle={true}/>
714
+ <Icon s="md" circle={true}/>
715
715
  {/if}
716
716
  {/if}
717
717
  <h4 class="ml-2">
@@ -365,14 +365,14 @@ function calculateBackground(is_highlighted, active) {
365
365
  {#if operation.icon}
366
366
  {@const cc = mobile ? 7 : 6}
367
367
  {@const icon_size = icon_placeholder_size - cc}
368
- <Icon size={icon_size} component={operation.icon}/>
368
+ <Icon s="md" component={operation.icon}/>
369
369
  {:else}
370
370
  {@const cc = mobile ? 7 : 6}
371
371
  {@const icon_size = icon_placeholder_size - cc}
372
- <div style="width: {icon_size*0.25}rem; height: {icon_size*0.25}rem;"></div>
372
+ <div class="w-4 h-4"></div>
373
373
  {/if}
374
374
  </div>
375
- <div class="">
375
+ <div class="flex items-center ">
376
376
  <p> {operation.caption}</p>
377
377
  {#if operation.description}
378
378
  {@const shortcut_width_px = operation.shortcut ? 80 : 0}
@@ -958,6 +958,18 @@ export function isActiveNormal() {
958
958
  export function isActiveHeading(level) {
959
959
  return editor?.isActive("heading", { level });
960
960
  }
961
+ export function isActiveH1() {
962
+ return editor?.isActive("heading", { level: 1 });
963
+ }
964
+ export function isActiveH2() {
965
+ return editor?.isActive("heading", { level: 2 });
966
+ }
967
+ export function isActiveH3() {
968
+ return editor?.isActive("heading", { level: 3 });
969
+ }
970
+ export function isActiveH4() {
971
+ return editor?.isActive("heading", { level: 4 });
972
+ }
961
973
  export function isActiveCode() {
962
974
  return editor?.isActive("CodeBlock");
963
975
  }
@@ -69,6 +69,10 @@ declare const __propDef: {
69
69
  isActiveStrikethrough?: (() => any) | undefined;
70
70
  isActiveNormal?: (() => any) | undefined;
71
71
  isActiveHeading?: ((level: any) => any) | undefined;
72
+ isActiveH1?: (() => any) | undefined;
73
+ isActiveH2?: (() => any) | undefined;
74
+ isActiveH3?: (() => any) | undefined;
75
+ isActiveH4?: (() => any) | undefined;
72
76
  isActiveCode?: (() => any) | undefined;
73
77
  isActiveComment?: (() => any) | undefined;
74
78
  isActiveQuote?: (() => any) | undefined;
@@ -138,6 +142,10 @@ export default class Editor extends SvelteComponentTyped<EditorProps, EditorEven
138
142
  get isActiveStrikethrough(): () => any;
139
143
  get isActiveNormal(): () => any;
140
144
  get isActiveHeading(): (level: any) => any;
145
+ get isActiveH1(): () => any;
146
+ get isActiveH2(): () => any;
147
+ get isActiveH3(): () => any;
148
+ get isActiveH4(): () => any;
141
149
  get isActiveCode(): () => any;
142
150
  get isActiveComment(): () => any;
143
151
  get isActiveQuote(): () => any;
@@ -5,8 +5,6 @@ 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_size = cmd.icon_size ? cmd.icon_size : 4;
9
- let icon_placeholder_size = icon_size + 4;
10
8
  let cl = $$props.class ?? "";
11
9
  $:
12
10
  active_class = calculateBackground(is_highlighted, active);
@@ -40,7 +38,7 @@ export function scrollToView() {
40
38
  bind:this={element}>
41
39
  <div class="flex items-center justify-center space-x-10 px-4 py-2 ml-12 sm:ml-0" >
42
40
  {#if cmd.icon}
43
- <Icon size={icon_size} component={cmd.icon}/>
41
+ <Icon s="md" component={cmd.icon}/>
44
42
  {/if}
45
43
  </div>
46
44
 
@@ -278,7 +278,7 @@ function isRowActive(cmd) {
278
278
  {@const cc = mobile ? 7 : 6}
279
279
  {@const default_icon_size = icon_placeholder_size - cc}
280
280
  {@const icon_size = cmd.icon_size ? cmd.icon_size : default_icon_size}
281
- <Icon size={icon_size} component={cmd.icon}/>
281
+ <Icon s="md" component={cmd.icon}/>
282
282
  {/if}
283
283
  </div>
284
284
  </button>
@@ -6,9 +6,42 @@ export let img = "";
6
6
  export let label = "";
7
7
  export let symbol = "";
8
8
  export let color = "";
9
- export let size = void 0;
9
+ export let s = "md";
10
10
  export let bg = "";
11
11
  export let circle = false;
12
+ let size = 4;
13
+ switch (s) {
14
+ case "5xl":
15
+ size = 12;
16
+ break;
17
+ case "4xl":
18
+ size = 9;
19
+ break;
20
+ case "3xl":
21
+ size = 7.5;
22
+ break;
23
+ case "2xl":
24
+ size = 6;
25
+ break;
26
+ case "xl":
27
+ size = 5;
28
+ break;
29
+ case "lg":
30
+ size = 4.5;
31
+ break;
32
+ case "md":
33
+ size = 4;
34
+ break;
35
+ case "base":
36
+ size = 4;
37
+ break;
38
+ case "sm":
39
+ size = 3.5;
40
+ break;
41
+ case "xs":
42
+ size = 3;
43
+ break;
44
+ }
12
45
  let additional_class = $$restProps.class ?? "";
13
46
  let id = $$restProps.id ?? "";
14
47
  let _bg;
@@ -58,16 +91,16 @@ $: {
58
91
  }
59
92
  let style;
60
93
  $: {
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 {
94
+ if (!additional_class) {
69
95
  let icon_size = `${size * 0.25}rem`;
70
96
  style = `width: ${icon_size}; height: ${icon_size}`;
97
+ } else {
98
+ if (additional_class.includes("w-") || additional_class.includes("h-"))
99
+ style = "";
100
+ else {
101
+ let icon_size = `${size * 0.25}rem`;
102
+ style = `width: ${icon_size}; height: ${icon_size}`;
103
+ }
71
104
  }
72
105
  }
73
106
  </script>
@@ -8,7 +8,7 @@ declare const __propDef: {
8
8
  label?: string | undefined;
9
9
  symbol?: string | undefined;
10
10
  color?: string | undefined;
11
- size?: number | undefined;
11
+ s?: string | undefined;
12
12
  bg?: string | undefined;
13
13
  circle?: boolean | undefined;
14
14
  };
@@ -49,9 +49,9 @@ export default class Icon extends SvelteComponentTyped<IconProps, IconEvents, Ic
49
49
  get color(): string | undefined;
50
50
  /**accessor*/
51
51
  set color(_: string | undefined);
52
- get size(): number | undefined;
52
+ get s(): string | undefined;
53
53
  /**accessor*/
54
- set size(_: number | undefined);
54
+ set s(_: string | undefined);
55
55
  get bg(): string | undefined;
56
56
  /**accessor*/
57
57
  set bg(_: string | undefined);
@@ -2,4 +2,5 @@ import Floating_container from './Floating_container.svelte';
2
2
  export declare function showMenu(around: DOMRect | DOMPoint, operations: any): void;
3
3
  export declare function hideWholeContextMenu(): void;
4
4
  export declare function showFloatingToolbar(around: DOMRect | DOMPoint, toolbar: any, props?: {}): Floating_container | null;
5
+ export declare function hideFloatingToolbar(): void;
5
6
  export declare function showGridMenu(around: DOMRect | DOMPoint, operations: any): void;
@@ -54,6 +54,12 @@ export function showFloatingToolbar(around, toolbar, props = {}) {
54
54
  console.error('what now?');
55
55
  return toolbar_component;
56
56
  }
57
+ export function hideFloatingToolbar() {
58
+ if (toolbar_component) {
59
+ if (toolbar_component.isVisible())
60
+ toolbar_component.hide();
61
+ }
62
+ }
57
63
  export function showGridMenu(around, operations) {
58
64
  showFloatingToolbar(around, Grid, { operations: operations });
59
65
  }
@@ -7,14 +7,7 @@ export let color;
7
7
  export let onRemove = void 0;
8
8
  export let onColor = void 0;
9
9
  export let s = "sm";
10
- onMount(() => {
11
- if (onColor && rootElement) {
12
- rootElement.addEventListener("click", showColorPicker);
13
- rootElement.classList.add("cursor-pointer");
14
- }
15
- return () => {
16
- };
17
- });
10
+ export let onCustomClick = void 0;
18
11
  let pr = onRemove ? "pr-1" : "pr-2";
19
12
  let font;
20
13
  let x_size;
@@ -47,11 +40,32 @@ function onSelectColor(color2) {
47
40
  onColor(name, color2);
48
41
  colorPicker?.hide();
49
42
  }
43
+ function conditionalClick(node, { condition, callback }) {
44
+ if (condition) {
45
+ node.addEventListener("click", callback);
46
+ return {
47
+ destroy() {
48
+ node.removeEventListener("click", callback);
49
+ }
50
+ };
51
+ }
52
+ }
53
+ const hasClick = onColor != void 0 || onCustomClick != void 0;
54
+ function handleClick(e) {
55
+ if (onColor)
56
+ showColorPicker(e);
57
+ else if (onCustomClick)
58
+ onCustomClick(e);
59
+ }
50
60
  </script>
51
61
 
52
62
  <span
53
63
  class=" pl-2 {pr} rounded text-white flex flex-row {color} items-center"
54
-
64
+ class:cursor-pointer={hasClick}
65
+ use:conditionalClick={{
66
+ condition: hasClick,
67
+ callback: handleClick
68
+ }}
55
69
  bind:this={rootElement}>
56
70
  <span class={font}>{name}</span>
57
71
  {#if onRemove}
@@ -6,6 +6,7 @@ declare const __propDef: {
6
6
  onRemove?: any | undefined;
7
7
  onColor?: any | undefined;
8
8
  s?: string | undefined;
9
+ onCustomClick?: any | undefined;
9
10
  };
10
11
  events: {
11
12
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,237 @@
1
+ <script>
2
+ import Tag from './tag.svelte'
3
+ import {FaPlus} from 'svelte-icons/fa'
4
+ import TagColorsPalette from './tag.colors.svelte'
5
+ import { tick } from 'svelte';
6
+ import { isDeviceSmallerThan } from '../utils';
7
+
8
+ export let usedTags = []
9
+ export let allTags = []
10
+
11
+ export let onSelect;
12
+ export let onNewTag = undefined;
13
+
14
+ export let onHide = undefined
15
+ export let onSizeChanged = undefined
16
+
17
+ let allowNewTags = onNewTag != undefined;
18
+
19
+ let userClass = $$props.class ?? '';
20
+
21
+ const TAGS_PALETTE = 0
22
+ const COLORS_PALETTE = 1
23
+ let view = TAGS_PALETTE;
24
+
25
+ $: notUsedTags = getNotUsedTags()
26
+ $: filteredTags = filterTags(notUsedTags, '')
27
+
28
+ export function reload(props)
29
+ {
30
+ if(props && props.usedTags)
31
+ usedTags = props.usedTags
32
+
33
+ if(props && props.allTags)
34
+ allTags = props.allTags
35
+
36
+ if(props && props.onSelect)
37
+ onSelect = props.onSelect
38
+
39
+ if(props && props.onNewTag)
40
+ onNewTag = props.onNewTag
41
+
42
+ allowNewTags = onNewTag != undefined;
43
+
44
+ view = TAGS_PALETTE;
45
+ inputText = ''
46
+
47
+ notUsedTags = getNotUsedTags()
48
+ filteredTags = filterTags(notUsedTags, '')
49
+ }
50
+
51
+ let gap = 'gap-2';
52
+ let s = "md"
53
+ switch(s)
54
+ {
55
+ case 'md':
56
+ gap = 'gap-3 sm:gap-2'
57
+ break;
58
+
59
+ case 'sm':
60
+ gap = 'gap-2 sm:gap-2'
61
+ break;
62
+
63
+ case 'xs':
64
+ gap = 'gap-2 sm:gap-1'
65
+ break;
66
+ }
67
+
68
+ function getNotUsedTags()
69
+ {
70
+ let result = allTags.filter(e => {
71
+ const label = e.label;
72
+ let idx = usedTags.findIndex(f => f.label == label)
73
+ if(idx < 0)
74
+ return true;
75
+ else
76
+ return false;
77
+ });
78
+
79
+ return result;
80
+ }
81
+
82
+ function onTagSelected(tag)
83
+ {
84
+ if(onSelect)
85
+ onSelect(tag, tag.label, tag.label)
86
+ }
87
+
88
+ let inputText = '';
89
+ function onTextInput(e)
90
+ {
91
+ filteredTags = filterTags(notUsedTags, inputText)
92
+
93
+ // don't know if needed. we'll see
94
+ //await tick();
95
+ //if(onSizeChanged)
96
+ // onSizeChanged();
97
+ }
98
+
99
+ function filterTags(tags, inputText)
100
+ {
101
+ if(!inputText)
102
+ return [...tags];
103
+ else
104
+ {
105
+ const filterText = inputText.toLowerCase()
106
+ return tags.filter(e => e.label && e.label.toLowerCase().includes( filterText ))
107
+ }
108
+ }
109
+
110
+ function onKeyDown(e)
111
+ {
112
+ switch(e.key)
113
+ {
114
+ case 'Enter':
115
+ if(filteredTags.length > 0)
116
+ {
117
+ inputText = ''
118
+ onTagSelected(filteredTags[0])
119
+ if(onHide)
120
+ onHide()
121
+ }
122
+ else if(allowNewTags)
123
+ {
124
+ onAddTag(undefined)
125
+ }
126
+ break;
127
+
128
+ case 'Escape':
129
+ if(inputText)
130
+ {
131
+ inputText = ''
132
+ filteredTags = filterTags(notUsedTags, inputText)
133
+ }
134
+ else
135
+ {
136
+ if(onHide)
137
+ onHide()
138
+ }
139
+ break;
140
+
141
+ }
142
+ }
143
+
144
+
145
+
146
+ function onTextBlur(e)
147
+ {
148
+ if(isDeviceSmallerThan("sm")) // blur when virtual keyboard is visible means 'OK' button pressed
149
+ {
150
+ if((filteredTags.length == 0) && allowNewTags)
151
+ {
152
+ onAddTag(undefined)
153
+ }
154
+ }
155
+ else
156
+ {
157
+
158
+ }
159
+ }
160
+
161
+ async function onAddTag(e)
162
+ {
163
+ if(inputText && onNewTag)
164
+ {
165
+ view = COLORS_PALETTE
166
+ await tick();
167
+ if(onSizeChanged)
168
+ onSizeChanged();
169
+ }
170
+ else if(onHide)
171
+ onHide();
172
+ }
173
+
174
+ function onNewTagColorSelected(color)
175
+ {
176
+ if(inputText && onNewTag)
177
+ onNewTag(inputText, inputText, color)
178
+
179
+ inputText = ''
180
+
181
+ if(onHide)
182
+ onHide();
183
+ }
184
+
185
+ </script>
186
+
187
+ {#if view==TAGS_PALETTE}
188
+ <menu class="{userClass} flex flex-column {gap} flex-wrap mr-1 sm:mr-0 sm:w-72">
189
+ <p class="flex flex-row {gap} flex-wrap ">
190
+ {#key filteredTags}
191
+ {#if filteredTags.length > 0}
192
+ {#each filteredTags as tag (tag.label)}
193
+ <Tag name={tag.label} color={tag.color} {s}
194
+ onCustomClick={(e) => onTagSelected(tag)}/>
195
+ {/each}
196
+ {:else if allowNewTags}
197
+ <p>Create tag:</p>
198
+ {:else}
199
+ <p>No tags</p>
200
+ {/if}
201
+
202
+ {/key}
203
+ </p>
204
+
205
+ <section class="flex flex-row {gap} w-full">
206
+
207
+ <input type="text" name="text" id="text"
208
+ autocomplete="off"
209
+ class="block bg-stone-100 dark:bg-stone-800 flex-1"
210
+ bind:value={inputText}
211
+ on:input={onTextInput}
212
+ on:blur={onTextBlur}
213
+ on:keydown={onKeyDown}
214
+ placeholder="Type to filter or create tag">
215
+ {#if allowNewTags}
216
+ <button class="block w-5 h-5 mt-0.5 ml-auto mr-2
217
+ text-stone-600 hover:text-stone-800 hover:bg-stone-200 active:bg-stone-200 border-stone-200
218
+ dark:text-stone-300 dark:hover:text-white dark:hover:bg-stone-800 dark:active:bg-stone-600 dark:border-stone-600"
219
+ class:hidden={inputText.length == 0}
220
+ on:click={onAddTag}>
221
+ <FaPlus/>
222
+ </button>
223
+ {/if}
224
+ </section>
225
+ </menu>
226
+
227
+ {:else if view == COLORS_PALETTE}
228
+ <TagColorsPalette onSelect={onNewTagColorSelected}/>
229
+ {/if}
230
+
231
+ <style>
232
+
233
+ input:focus {
234
+ outline: 0px solid transparent;
235
+ }
236
+
237
+ </style>
@@ -0,0 +1,38 @@
1
+ /** @typedef {typeof __propDef.props} TagsProps */
2
+ /** @typedef {typeof __propDef.events} TagsEvents */
3
+ /** @typedef {typeof __propDef.slots} TagsSlots */
4
+ export default class Tags extends SvelteComponentTyped<{
5
+ [x: string]: any;
6
+ onSelect: any;
7
+ onHide?: any;
8
+ onSizeChanged?: any;
9
+ reload?: ((props: any) => void) | undefined;
10
+ usedTags?: any[] | undefined;
11
+ allTags?: any[] | undefined;
12
+ onNewTag?: any;
13
+ }, {
14
+ [evt: string]: CustomEvent<any>;
15
+ }, {}> {
16
+ get reload(): (props: any) => void;
17
+ }
18
+ export type TagsProps = typeof __propDef.props;
19
+ export type TagsEvents = typeof __propDef.events;
20
+ export type TagsSlots = typeof __propDef.slots;
21
+ import { SvelteComponentTyped } from "svelte";
22
+ declare const __propDef: {
23
+ props: {
24
+ [x: string]: any;
25
+ onSelect: any;
26
+ onHide?: any;
27
+ onSizeChanged?: any;
28
+ reload?: ((props: any) => void) | undefined;
29
+ usedTags?: any[] | undefined;
30
+ allTags?: any[] | undefined;
31
+ onNewTag?: any;
32
+ };
33
+ events: {
34
+ [evt: string]: CustomEvent<any>;
35
+ };
36
+ slots: {};
37
+ };
38
+ export {};
@@ -3,8 +3,10 @@ import Tag from "./tag.svelte";
3
3
  import FaPlus from "svelte-icons/fa/FaPlus.svelte";
4
4
  import Combo from "./combo/combo.svelte";
5
5
  import ComboItem from "./combo/combo.item.svelte";
6
+ import TagsPalette from "./tags.palette.svelte";
6
7
  import { contextItemsStore, data_tick_store, contextTypesStore, tagsReloader } from "../stores.js";
7
8
  import { informModification, pushChanges } from "../updates.js";
9
+ import { showFloatingToolbar } from "./menu";
8
10
  export let tags = "";
9
11
  export let getGlobalTags;
10
12
  export let self = null;
@@ -67,6 +69,7 @@ function setup(...args) {
67
69
  }
68
70
  let addComboVisible = false;
69
71
  let addCombo;
72
+ let rootElement;
70
73
  export async function show(event, hideCallback) {
71
74
  if (event) {
72
75
  event.stopPropagation();
@@ -79,7 +82,25 @@ export async function show(event, hideCallback) {
79
82
  if (hideCallback)
80
83
  hideCallback();
81
84
  };
82
- addCombo?.show(void 0, onAfterCloseCombo);
85
+ let owner = rootElement;
86
+ let rect = owner.getBoundingClientRect();
87
+ if (tagsTable.length == 0) {
88
+ const m = 15;
89
+ rect.x -= m;
90
+ rect.width += 2 * m;
91
+ rect.y -= m;
92
+ rect.height += 2 * m;
93
+ }
94
+ showFloatingToolbar(
95
+ rect,
96
+ TagsPalette,
97
+ {
98
+ usedTags: tagsTable,
99
+ allTags: globalTagsTable,
100
+ onSelect: onSelectTag,
101
+ onNewTag: getCreateTagCallback()
102
+ }
103
+ );
83
104
  }
84
105
  function applyChange() {
85
106
  if (onSelect)
@@ -97,6 +118,9 @@ function applyChange() {
97
118
  changed(value);
98
119
  }
99
120
  function onSelectTag(itm, key, name) {
121
+ const idx = tagsTable.findIndex((e) => e.label == key);
122
+ if (idx >= 0)
123
+ return;
100
124
  tags += `#${key} `;
101
125
  tagsTable = decomposeTags(tags, globalTagsTable);
102
126
  applyChange();
@@ -106,10 +130,13 @@ function onRemoveTag(tag) {
106
130
  tagsTable = decomposeTags(tags, globalTagsTable);
107
131
  applyChange();
108
132
  }
109
- function onNewTagCreated(key, name) {
133
+ function onNewTagCreated(key, name, color = "") {
110
134
  tags += `#${key} `;
111
135
  let globalTags = getGlobalTags();
112
- globalTags += `#${key} `;
136
+ if (color)
137
+ globalTags += `#${key}:${color} `;
138
+ else
139
+ globalTags += `#${key} `;
113
140
  globalTagsTable = decomposeTags(globalTags);
114
141
  tagsTable = decomposeTags(tags, globalTagsTable);
115
142
  applyChange();
@@ -201,17 +228,21 @@ switch (s) {
201
228
  }
202
229
  </script>
203
230
 
204
- <section class="{userClass} flex flex-row {gap} flex-wrap mr-1 sm:mr-0">
231
+ <section class="{userClass} flex flex-row {gap} flex-wrap mr-1 sm:mr-0" bind:this={rootElement}>
205
232
  <p class="flex flex-row {gap} flex-wrap ">
206
- {#each tagsTable as tag}
207
- {#if isEditable}
208
- <Tag name={tag.label} color={tag.color} {s}
209
- onRemove={(e) => {onRemoveTag(tag.label)}}
210
- onColor={canChangeColor ? onColorizeTag : null}/>
211
- {:else}
212
- <Tag name={tag.label} color={tag.color} {s}/>
213
- {/if}
214
- {/each}
233
+ {#if tagsTable.length > 0}
234
+ {#each tagsTable as tag}
235
+ {#if isEditable}
236
+ <Tag name={tag.label} color={tag.color} {s}
237
+ onRemove={(e) => {onRemoveTag(tag.label)}}
238
+ onColor={canChangeColor ? onColorizeTag : null}/>
239
+ {:else}
240
+ <Tag name={tag.label} color={tag.color} {s}/>
241
+ {/if}
242
+ {/each}
243
+ {:else}
244
+ <!--p>&ZeroWidthSpace;</p-->
245
+ {/if}
215
246
  </p>
216
247
 
217
248
  {#if isEditable}
@@ -223,7 +254,7 @@ switch (s) {
223
254
  </button>
224
255
  {/if}
225
256
  {:else}
226
- <Combo compact={true}
257
+ <!--Combo compact={true}
227
258
  inContext='data'
228
259
  onSelect={onSelectTag}
229
260
  onNewItemCreated={getCreateTagCallback()}
@@ -234,7 +265,7 @@ switch (s) {
234
265
  {#each not_used_tags as tag}
235
266
  <ComboItem key={tag.label}/>
236
267
  {/each}
237
- </Combo>
268
+ </Combo-->
238
269
  {/if}
239
270
  {/if}
240
271
  </section>
package/console.svelte CHANGED
@@ -9,6 +9,8 @@
9
9
  let inputElement;
10
10
  let protocol = 'cons';
11
11
  let protoButtonBorderClass = ''
12
+ let history = []
13
+ let currentHistoryElementIdx = -1
12
14
 
13
15
  async function onKeyDown(e)
14
16
  {
@@ -32,18 +34,74 @@
32
34
  input = input.replace('self', navItem)
33
35
  }
34
36
 
37
+ const req = input;
38
+ input = "";
39
+
35
40
  const apiVer = $session.configuration.api_version;
36
- const result = await reef.fetch(`/${protocol}/${apiVer}/${input}`)
41
+ const result = await reef.fetch(`/${protocol}/${apiVer}/${req}`)
37
42
  const res = await result.text();
38
43
  prevLines = [...prevLines, res]
39
-
40
44
 
41
- input = "";
45
+ updateHistory(req)
42
46
  }
43
47
  else if(e.key == 'Esc' || e.key == 'Escape')
44
48
  {
45
49
  input = "";
46
50
  }
51
+ else if(e.key == 'ArrowUp')
52
+ {
53
+ if(history.length > 0)
54
+ {
55
+ if(currentHistoryElementIdx < 0)
56
+ {
57
+ currentHistoryElementIdx = history.length-1
58
+ input = history[currentHistoryElementIdx]
59
+ }
60
+ else if(currentHistoryElementIdx > 0)
61
+ {
62
+ currentHistoryElementIdx--;
63
+ input = history[currentHistoryElementIdx]
64
+ }
65
+ else
66
+ {
67
+
68
+ }
69
+ moveCursorAtEnd()
70
+ }
71
+ }
72
+ else if(e.key == 'ArrowDown')
73
+ {
74
+ if(history.length > 0)
75
+ {
76
+ if(currentHistoryElementIdx >= 0)
77
+ {
78
+ currentHistoryElementIdx++
79
+ if(currentHistoryElementIdx >= history.length)
80
+ {
81
+ currentHistoryElementIdx = -1
82
+ input = ''
83
+ }
84
+ else
85
+ input = history[currentHistoryElementIdx]
86
+ }
87
+ moveCursorAtEnd()
88
+ }
89
+ }
90
+ }
91
+
92
+
93
+ function updateHistory(command)
94
+ {
95
+ const idx = history.findIndex(c => c == command)
96
+ if(idx < 0)
97
+ history.push(command)
98
+ else
99
+ {
100
+ history.splice(idx, 1)
101
+ history.push(command)
102
+ }
103
+
104
+ currentHistoryElementIdx = -1
47
105
  }
48
106
 
49
107
  function getNav(contextLevel)
@@ -67,9 +125,30 @@
67
125
  return navItem;
68
126
  }
69
127
 
128
+ function moveCursorAtEnd()
129
+ {
130
+ return;
131
+ setTimeout( () =>
132
+ {
133
+ const sel = window.getSelection();
134
+ if(!sel)
135
+ return;
136
+ if(sel.focusNode == inputElement)
137
+ console.log(sel.focusOffset)
138
+ //sel.setPosition(inputElement, input.length)
139
+ }, 100)
140
+ }
141
+
70
142
  afterUpdate(() =>
71
143
  {
72
144
  inputElement?.scrollIntoView();
145
+
146
+ //const selection = window.getSelection()
147
+ //if(selection?.focusNode == inputElement)
148
+ //{
149
+ // selection?.setPosition(inputElement, input.length-1)
150
+ //}
151
+
73
152
  })
74
153
 
75
154
 
package/desk.svelte CHANGED
@@ -23,6 +23,7 @@
23
23
  import { handleSelect, isDeviceSmallerThan, isOnNavigationPage, isOnScreenKeyboardVisible, removeAt, UI } from './utils'
24
24
  import { afterUpdate, onMount } from 'svelte';
25
25
  import {location} from 'svelte-spa-router'
26
+ import {FaCopy, FaTimes} from 'svelte-icons/fa'
26
27
 
27
28
  export let layout;
28
29
 
@@ -457,17 +458,19 @@
457
458
  <section class="fixed left-2 sm:left-auto sm:right-2 bottom-2 flex flex-col gap-2">
458
459
  {#if $alerts && $alerts.length > 0}
459
460
  {#each $alerts as alert, idx}
460
- <Alert class="bg-red-900/40 shadow-lg shadow-stone-400 dark:shadow-black flex flex-row">
461
- <button class="sm:hidden font-bold ml-auto"
462
- on:click={() => {removeAlert(alert)}}>
463
- x
464
- </button>
465
- <p>
461
+ <Alert class="bg-red-900/40 shadow-lg shadow-stone-400 dark:shadow-black flex flex-row-reverse sm:flex-row">
462
+ {@const text_max_width = is_small ? '60vw' : '75vw'}
463
+
464
+ <p class="flex-none truncate" style="max-width: {text_max_width}">
466
465
  {alert.msg}
467
466
  </p>
468
- <button class="hidden sm:block font-bold ml-auto"
467
+ <button class="block sm:ml-auto w-3 mx-1"
468
+ on:click={() => {navigator.clipboard.writeText(alert.msg)}}>
469
+ <FaCopy/>
470
+ </button>
471
+ <button class="block w-3 mx-1"
469
472
  on:click={() => {removeAlert(alert)}}>
470
- x
473
+ <FaTimes/>
471
474
  </button>
472
475
  </Alert>
473
476
  {/each}
@@ -305,12 +305,12 @@
305
305
  {#if definedTabs && definedTabs.length > 0}
306
306
  {#each definedTabs as tab}
307
307
  <button class="w-12 sm:w-10 h-full flex justify-center items-center text-stone-300 hover:text-stone-100" on:click={tab.onclick}>
308
- <Icon class="w-5 h-5" component={tab.icon}/>
308
+ <Icon s="xl" component={tab.icon}/>
309
309
  </button>
310
310
  {/each}
311
311
  {:else}
312
312
  <button class="w-12 sm:w-10 h-full flex justify-center items-center text-stone-300 hover:text-stone-100" on:click|stopPropagation={toggle_navigator}>
313
- <Icon class="w-5 h-5" component={icon}/>
313
+ <Icon s="xl" component={icon}/>
314
314
  </button>
315
315
  {/if}
316
316
  </div>
@@ -324,7 +324,7 @@
324
324
  {#if user_is_in_multiple_groups}
325
325
  <button class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
326
326
  on:click|stopPropagation={show_groups}>
327
- <Icon class="w-5 h-5 " component={FaUsers} />
327
+ <Icon s="xl" component={FaUsers} />
328
328
  </button>
329
329
  {/if}
330
330
 
@@ -332,7 +332,7 @@
332
332
  class="h-full w-12 sm:w-10 px-0 flex justify-center items-center text-stone-300 hover:text-stone-100"
333
333
  on:click|stopPropagation={show_options}>
334
334
 
335
- <Icon class="w-5 h-5 " component={FaCog} />
335
+ <Icon s="xl" component={FaCog} />
336
336
  </button>
337
337
  </div>
338
338
 
package/modal.svelte CHANGED
@@ -107,7 +107,7 @@ function on_cancel(event) {
107
107
  <div class="sm:flex sm:items-start">
108
108
  <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">
109
109
  {#if icon}
110
- <Icon component={icon} size={6} class="text-stone-700"/>
110
+ <Icon component={icon} s="2xl" class="text-stone-700"/>
111
111
  {/if}
112
112
  </div>
113
113
  <div class="grow mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
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.10",
29
+ "@humandialog/auth.svelte": "^1.8.12",
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",
@@ -143,6 +143,7 @@
143
143
  "./components/table/table": "./components/table/table.js",
144
144
  "./components/tag.colors.svelte": "./components/tag.colors.svelte",
145
145
  "./components/tag.svelte": "./components/tag.svelte",
146
+ "./components/tags.palette.svelte": "./components/tags.palette.svelte",
146
147
  "./components/tags.svelte": "./components/tags.svelte",
147
148
  "./components/textarea.ltop.svelte": "./components/textarea.ltop.svelte",
148
149
  "./components/tile.title.svelte": "./components/tile.title.svelte",
package/stores.d.ts CHANGED
@@ -48,3 +48,4 @@ export const tools_visible_store: import("svelte/store").Writable<any>;
48
48
  export const bottom_bar_visible_store: import("svelte/store").Writable<any>;
49
49
  export const right_sidebar_visible_store: import("svelte/store").Writable<boolean>;
50
50
  export const visible_property_tab_store: import("svelte/store").Writable<string>;
51
+ export const fabCollapsed: import("svelte/store").Writable<any>;
package/stores.js CHANGED
@@ -157,6 +157,9 @@ bottom_bar_visible_store.subscribe( (value) => { localStorage.bottom_bar_visible
157
157
  export const right_sidebar_visible_store = writable(false)
158
158
  export const visible_property_tab_store = writable('');
159
159
 
160
+ export const fabCollapsed = writable( (localStorage.fabCollapsed && localStorage.fabCollapsed == 'true') || false )
161
+ fabCollapsed.subscribe( (value) => { localStorage.fabCollapsed = (value ? 'true' : '') } );
162
+
160
163
  export function restore_defults()
161
164
  {
162
165
 
@@ -165,6 +168,7 @@ export function restore_defults()
165
168
  bottom_bar_visible_store.set(false);
166
169
  right_sidebar_visible_store.set(false);
167
170
  visible_property_tab_store.set('');
171
+ fabCollapsed.set(false)
168
172
  }
169
173
 
170
174
  export function toggle_sidebar(index)
@@ -776,7 +776,7 @@
776
776
  <!--Checkbox class="mt-2 text-xs font-normal" self={new_user} a="maintainer">
777
777
  <div class="flex flex-row items-center">
778
778
  <span class="">Maintainer</span>
779
- <Icon id="b1" size={4} component={FaInfoCircle} class="text-stone-400 ml-5 pt-0 mt-1"/>
779
+ <Icon id="b1" s="md" component={FaInfoCircle} class="text-stone-400 ml-5 pt-0 mt-1"/>
780
780
  <Popover class="w-64 text-sm font-light text-stone-500 bg-white dark:bg-stone-800 dark:border-stone-600 dark:text-stone-400" triggeredBy="#b1" color="dropdown">
781
781
  Means that the invited user will be able to add/remove others and manage permissions in this organization.
782
782
  </Popover>
@@ -361,7 +361,7 @@
361
361
  class:bg-orange-500={isSelected}
362
362
  on:click={tab.onclick}>
363
363
 
364
- <Icon class="w-5 h-5" component={tab.icon}/>
364
+ <Icon s="xl" component={tab.icon}/>
365
365
  </button>
366
366
  {/each}
367
367
  </div>
@@ -373,7 +373,7 @@
373
373
  {#if show_groups_switch_menu}
374
374
  <button class="h-12 px-0 flex justify-center items-center w-full text-stone-300 hover:text-stone-100"
375
375
  on:click|stopPropagation={show_groups}>
376
- <Icon size={4} component={FaUsers} />
376
+ <Icon s="md" component={FaUsers} />
377
377
  </button>
378
378
  {/if}
379
379
 
@@ -381,7 +381,7 @@
381
381
  class="h-12 px-0 flex justify-center items-center w-full text-stone-300 hover:text-stone-100"
382
382
  on:click|stopPropagation={show_options}>
383
383
 
384
- <Icon size={4} component={FaCog} />
384
+ <Icon s="md" component={FaCog} />
385
385
  </button>
386
386
 
387
387
  </div>