@humandialog/forms.svelte 1.4.7 → 1.4.9
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.
- package/components/Fab.svelte +50 -20
- package/components/Fab.svelte.d.ts +1 -0
- package/components/Floating_container.svelte +19 -3
- package/components/breadcrumb.svelte +59 -0
- package/components/breadcrumb.svelte.d.ts +25 -0
- package/components/breadcrumb_utils.d.ts +4 -0
- package/components/breadcrumb_utils.js +45 -0
- package/components/combo/combo.svelte +115 -115
- package/components/contextmenu.svelte +19 -3
- package/components/document/editor.svelte +21 -13
- package/components/document/editor.svelte.d.ts +4 -3
- package/components/document/internal/palette.svelte +62 -35
- package/components/paginator.svelte +105 -0
- package/components/paginator.svelte.d.ts +35 -0
- package/components/sidebar/sidebar.item.svelte +5 -1
- package/components/sidebar/sidebar.item.svelte.d.ts +2 -0
- package/desk.svelte +32 -18
- package/horizontal.toolbar.svelte +7 -1
- package/index.d.ts +5 -2
- package/index.js +5 -2
- package/modal.svelte +3 -4
- package/operations.svelte +3 -3
- package/package.json +6 -2
- package/stores.d.ts +2 -0
- package/stores.js +8 -0
- package/updates.d.ts +2 -1
- package/updates.js +19 -1
- package/utils.js +24 -4
- package/vertical.toolbar.svelte +20 -2
package/components/Fab.svelte
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { contextToolbarOperations, pageToolbarOperations, contextItemsStore, toolsActionsOperations, fabCollapsed } from "../stores.js";
|
|
1
|
+
<script>import { contextToolbarOperations, pageToolbarOperations, leftHandedFAB, toolsActionsOperations, fabCollapsed, bottom_bar_visible_store, main_sidebar_visible_store } from "../stores.js";
|
|
3
2
|
import { showFloatingToolbar, showMenu, showGridMenu } from "./menu.js";
|
|
4
3
|
import { FaChevronUp, FaChevronDown, FaChevronLeft, FaChevronRight, FaCircle, FaEllipsisV, FaRegDotCircle, FaDotCircle } from "svelte-icons/fa/";
|
|
5
4
|
import { isDeviceSmallerThan } from "../utils.js";
|
|
5
|
+
import { tick } from "svelte";
|
|
6
|
+
export let mainPageCoords = void 0;
|
|
6
7
|
$:
|
|
7
|
-
setupCurrentContextOperations(
|
|
8
|
+
setupCurrentContextOperations(
|
|
9
|
+
$pageToolbarOperations,
|
|
10
|
+
$contextToolbarOperations,
|
|
11
|
+
$toolsActionsOperations,
|
|
12
|
+
$fabCollapsed,
|
|
13
|
+
$bottom_bar_visible_store,
|
|
14
|
+
$main_sidebar_visible_store,
|
|
15
|
+
$leftHandedFAB
|
|
16
|
+
);
|
|
8
17
|
let operations = [];
|
|
9
18
|
let mainOperation = null;
|
|
10
19
|
let secondaryOperation = null;
|
|
@@ -13,7 +22,8 @@ let isExpandable = false;
|
|
|
13
22
|
let vToolboxExpanded = false;
|
|
14
23
|
let hToolboxExpanded = false;
|
|
15
24
|
let isDirectPositioningMode = false;
|
|
16
|
-
function setupCurrentContextOperations(...args) {
|
|
25
|
+
async function setupCurrentContextOperations(...args) {
|
|
26
|
+
await tick();
|
|
17
27
|
let opVer = 0;
|
|
18
28
|
let main_FAB_position = "";
|
|
19
29
|
isDirectPositioningMode = false;
|
|
@@ -179,7 +189,6 @@ function getSelectionPos() {
|
|
|
179
189
|
return 0;
|
|
180
190
|
}
|
|
181
191
|
function calculatePosition(operation) {
|
|
182
|
-
const isLeftHanded = false;
|
|
183
192
|
let result = "";
|
|
184
193
|
const fab = operation.fab;
|
|
185
194
|
if (fab.length != 3)
|
|
@@ -192,46 +201,62 @@ function calculatePosition(operation) {
|
|
|
192
201
|
const width = 55;
|
|
193
202
|
const height = 55;
|
|
194
203
|
const margin = 10;
|
|
195
|
-
|
|
204
|
+
let lShift = 0;
|
|
205
|
+
let tShift = 0;
|
|
206
|
+
let rShift = 0;
|
|
207
|
+
let bShift = 0;
|
|
208
|
+
let vMiddle = "50vh";
|
|
209
|
+
if (!isDeviceSmallerThan("sm")) {
|
|
210
|
+
const container = document.getElementById("__hd_svelte_main_content_container");
|
|
211
|
+
if (container) {
|
|
212
|
+
const containerRect = container?.getBoundingClientRect();
|
|
213
|
+
lShift = containerRect.x;
|
|
214
|
+
tShift = containerRect.y;
|
|
215
|
+
bShift = window.innerHeight - containerRect.bottom;
|
|
216
|
+
rShift = window.innerWidth - containerRect.right;
|
|
217
|
+
vMiddle = `${containerRect.x + containerRect.width / 2}px`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!$leftHandedFAB) {
|
|
196
221
|
switch (section) {
|
|
197
222
|
case "M":
|
|
198
|
-
result = `right: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
|
|
223
|
+
result = `right: ${rShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
|
|
199
224
|
break;
|
|
200
225
|
case "S":
|
|
201
|
-
result = `left: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
|
|
226
|
+
result = `left: ${lShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
|
|
202
227
|
break;
|
|
203
228
|
case "A":
|
|
204
|
-
result = `right: ${margin + col_no * width}px; top: calc(
|
|
229
|
+
result = `right: ${rShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
|
|
205
230
|
break;
|
|
206
231
|
case "C":
|
|
207
|
-
result = `left: ${margin + col_no * width}px; top: calc(
|
|
232
|
+
result = `left: ${lShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
|
|
208
233
|
break;
|
|
209
234
|
case "T":
|
|
210
|
-
result = `right: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
|
|
235
|
+
result = `right: ${rShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
|
|
211
236
|
break;
|
|
212
237
|
case "F":
|
|
213
|
-
result = `left: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
|
|
238
|
+
result = `left: ${lShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
|
|
214
239
|
break;
|
|
215
240
|
}
|
|
216
241
|
} else {
|
|
217
242
|
switch (section) {
|
|
218
243
|
case "M":
|
|
219
|
-
result = `left: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
|
|
244
|
+
result = `left: ${lShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
|
|
220
245
|
break;
|
|
221
246
|
case "S":
|
|
222
|
-
result = `right: ${margin + col_no * width}px; bottom: ${margin + row_no * height}px`;
|
|
247
|
+
result = `right: ${rShift + margin + col_no * width}px; bottom: ${bShift + margin + row_no * height}px`;
|
|
223
248
|
break;
|
|
224
249
|
case "A":
|
|
225
|
-
result = `left: ${margin + col_no * width}px; top: calc(
|
|
250
|
+
result = `left: ${lShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
|
|
226
251
|
break;
|
|
227
252
|
case "C":
|
|
228
|
-
result = `right: ${margin + col_no * width}px; top: calc(
|
|
253
|
+
result = `right: ${rShift + margin + col_no * width}px; top: calc(${vMiddle} - ${row_no * height}px)`;
|
|
229
254
|
break;
|
|
230
255
|
case "T":
|
|
231
|
-
result = `left: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
|
|
256
|
+
result = `left: ${lShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
|
|
232
257
|
break;
|
|
233
258
|
case "F":
|
|
234
|
-
result = `right: ${margin + col_no * width}px; top: ${margin + row_no * height}px`;
|
|
259
|
+
result = `right: ${rShift + margin + col_no * width}px; top: ${tShift + margin + row_no * height}px`;
|
|
235
260
|
break;
|
|
236
261
|
}
|
|
237
262
|
}
|
|
@@ -246,8 +271,13 @@ function operationVisible(operation) {
|
|
|
246
271
|
if (operation.fab == "M10")
|
|
247
272
|
return true;
|
|
248
273
|
return false;
|
|
249
|
-
} else
|
|
274
|
+
} else {
|
|
275
|
+
if (operation.disabledFunc)
|
|
276
|
+
return !operation.disabledFunc();
|
|
277
|
+
else if (operation.disabled)
|
|
278
|
+
return false;
|
|
250
279
|
return true;
|
|
280
|
+
}
|
|
251
281
|
}
|
|
252
282
|
</script>
|
|
253
283
|
|
|
@@ -266,7 +296,7 @@ function operationVisible(operation) {
|
|
|
266
296
|
fixed m-0
|
|
267
297
|
flex items-center justify-center
|
|
268
298
|
disable-dbl-tap-zoom
|
|
269
|
-
cursor-pointer z-
|
|
299
|
+
cursor-pointer z-20"
|
|
270
300
|
style={position}
|
|
271
301
|
on:click|stopPropagation={(e) => {on_click(e, operation)}}
|
|
272
302
|
on:mousedown={mousedown} >
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { isDeviceSmallerThan } from "../utils";
|
|
3
3
|
import { pushToolsActionsOperations, popToolsActionsOperations } from "../stores";
|
|
4
4
|
import { FaTimes } from "svelte-icons/fa";
|
|
5
|
+
import Icon from "./icon.svelte";
|
|
5
6
|
let x;
|
|
6
7
|
let y;
|
|
7
8
|
let visible = false;
|
|
@@ -10,6 +11,7 @@ let props = {};
|
|
|
10
11
|
let around_rect;
|
|
11
12
|
let rootElement;
|
|
12
13
|
let internalElement;
|
|
14
|
+
let closeButtonPos = "";
|
|
13
15
|
export async function show(around, _toolbar, _props = {}) {
|
|
14
16
|
if (around instanceof DOMRect) {
|
|
15
17
|
x = around.left;
|
|
@@ -34,7 +36,7 @@ export async function show(around, _toolbar, _props = {}) {
|
|
|
34
36
|
props.onSizeChanged = () => onSizeChanged();
|
|
35
37
|
hide_window_indicator = 0;
|
|
36
38
|
window.addEventListener("click", on_before_window_click, true);
|
|
37
|
-
if (
|
|
39
|
+
if (false) {
|
|
38
40
|
pushToolsActionsOperations({
|
|
39
41
|
opver: 1,
|
|
40
42
|
operations: [
|
|
@@ -63,7 +65,7 @@ export function isVisible() {
|
|
|
63
65
|
return visible;
|
|
64
66
|
}
|
|
65
67
|
export function hide() {
|
|
66
|
-
if (
|
|
68
|
+
if (false)
|
|
67
69
|
popToolsActionsOperations();
|
|
68
70
|
visible = false;
|
|
69
71
|
cssPosition = calculatePosition(x, y, around_rect, false, false);
|
|
@@ -124,6 +126,7 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
|
|
|
124
126
|
y2 = screenRect.bottom - maxHeight - margin;
|
|
125
127
|
result = `left: ${x2}px; top: ${y2}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
|
|
126
128
|
}
|
|
129
|
+
closeButtonPos = `right: ${margin}px; top: calc(${y2}px - 1.75rem)`;
|
|
127
130
|
} else {
|
|
128
131
|
let myRect = null;
|
|
129
132
|
if (!fresh) {
|
|
@@ -144,15 +147,28 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
|
|
|
144
147
|
y2 = screenRect.top;
|
|
145
148
|
}
|
|
146
149
|
result = `left:${x2}px; top:${y2}px; width: max-content; height:max-content; display: block`;
|
|
150
|
+
closeButtonPos = ``;
|
|
147
151
|
}
|
|
148
152
|
return result;
|
|
149
153
|
}
|
|
150
154
|
</script>
|
|
151
155
|
|
|
152
156
|
<div id="__hd_svelte_floating_container"
|
|
153
|
-
class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black z-
|
|
157
|
+
class="p-2 bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black z-40 fixed "
|
|
154
158
|
style={cssPosition}
|
|
155
159
|
bind:this={rootElement}>
|
|
160
|
+
{#if closeButtonPos}
|
|
161
|
+
<button class=" fixed w-6 h-6 flex items-center justify-center
|
|
162
|
+
text-stone-500 bg-stone-200/70 hover:bg-stone-200
|
|
163
|
+
focus:outline-none font-medium rounded-full text-sm text-center
|
|
164
|
+
dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
|
|
165
|
+
focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800"
|
|
166
|
+
style={closeButtonPos}
|
|
167
|
+
on:click={ hide }>
|
|
168
|
+
<Icon component={FaTimes} s="md"/>
|
|
169
|
+
</button>
|
|
170
|
+
{/if}
|
|
171
|
+
|
|
156
172
|
<svelte:component this={toolbar} {...props} bind:this={internalElement} />
|
|
157
173
|
</div>
|
|
158
174
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {location, link, querystring} from 'svelte-spa-router'
|
|
3
|
+
import { breadcrumbParse, breadcrumbStringify } from './breadcrumb_utils';
|
|
4
|
+
|
|
5
|
+
export let path;
|
|
6
|
+
|
|
7
|
+
let segments = []
|
|
8
|
+
let userClass = $$props.class ?? ''
|
|
9
|
+
|
|
10
|
+
$: init($location, $querystring)
|
|
11
|
+
|
|
12
|
+
function init(...args)
|
|
13
|
+
{
|
|
14
|
+
segments = breadcrumbParse(path);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getSegmentHRef(href, idx)
|
|
18
|
+
{
|
|
19
|
+
let prevSegments = []
|
|
20
|
+
if(idx > 0)
|
|
21
|
+
prevSegments = segments.slice(0, idx)
|
|
22
|
+
|
|
23
|
+
const prevPath = breadcrumbStringify(prevSegments)
|
|
24
|
+
return `${href}?path=${prevPath}`
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<nav class="flex {userClass}" aria-label="Breadcrumb">
|
|
31
|
+
<ol class="inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse flex-wrap">
|
|
32
|
+
|
|
33
|
+
{#if (segments && segments.length > 1)}
|
|
34
|
+
{#each segments as segment, idx (segment.href)}
|
|
35
|
+
{@const isFirst = idx == 0}
|
|
36
|
+
{@const isLast = idx == segments.length-1}
|
|
37
|
+
<li>
|
|
38
|
+
<div class="flex items-center">
|
|
39
|
+
{#if !isFirst}
|
|
40
|
+
<svg class="rtl:rotate-180 w-3 h-3 text-stone-400 mx-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
41
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
42
|
+
</svg>
|
|
43
|
+
{/if}
|
|
44
|
+
{#if isLast}
|
|
45
|
+
<span class="ms-1 text-sm md:ms-2 font-semibold text-stone-900 dark:text-stone-100 whitespace-nowrap">
|
|
46
|
+
{segment.name}
|
|
47
|
+
</span>
|
|
48
|
+
{:else}
|
|
49
|
+
<a href={getSegmentHRef(segment.href, idx)} use:link class="ms-1 text-sm font-medium md:ms-2 text-stone-700 hover:text-stone-900 dark:text-stone-400 dark:hover:text-white whitespace-nowrap">
|
|
50
|
+
{segment.name}
|
|
51
|
+
</a>
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
54
|
+
</li>
|
|
55
|
+
{/each}
|
|
56
|
+
{/if}
|
|
57
|
+
|
|
58
|
+
</ol>
|
|
59
|
+
</nav>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} BreadcrumbProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} BreadcrumbEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} BreadcrumbSlots */
|
|
4
|
+
export default class Breadcrumb extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
path: any;
|
|
7
|
+
}, {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
}, {}> {
|
|
10
|
+
}
|
|
11
|
+
export type BreadcrumbProps = typeof __propDef.props;
|
|
12
|
+
export type BreadcrumbEvents = typeof __propDef.events;
|
|
13
|
+
export type BreadcrumbSlots = typeof __propDef.slots;
|
|
14
|
+
import { SvelteComponentTyped } from "svelte";
|
|
15
|
+
declare const __propDef: {
|
|
16
|
+
props: {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
path: any;
|
|
19
|
+
};
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {};
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
export function breadcrumbAdd(path, name, href)
|
|
3
|
+
{
|
|
4
|
+
if(path.length > 0)
|
|
5
|
+
path += ';'
|
|
6
|
+
path += `${encodeURIComponent(href)}!${encodeURIComponent(breadcrumbClipName(name))}`
|
|
7
|
+
return path
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function breadcrumbParse(path)
|
|
11
|
+
{
|
|
12
|
+
let segments = []
|
|
13
|
+
const segs = path.split(';')
|
|
14
|
+
segs.forEach(s => {
|
|
15
|
+
const nidx = s.indexOf('!')
|
|
16
|
+
segments.push({
|
|
17
|
+
href: decodeURIComponent( s.substring(0, nidx) ),
|
|
18
|
+
name: decodeURIComponent( s.substring(nidx+1))
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
return segments;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function breadcrumbStringify(segments)
|
|
26
|
+
{
|
|
27
|
+
let result = ''
|
|
28
|
+
segments.forEach(s => {
|
|
29
|
+
|
|
30
|
+
if(result.length > 0)
|
|
31
|
+
result += ";";
|
|
32
|
+
result += `${encodeURIComponent(s.href)}!${encodeURIComponent(breadcrumbClipName(s.name))}`
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function breadcrumbClipName(name)
|
|
39
|
+
{
|
|
40
|
+
const maxNameLen = 24;
|
|
41
|
+
if(name.length > maxNameLen)
|
|
42
|
+
return name.substr(0, maxNameLen-3) + "..."
|
|
43
|
+
else
|
|
44
|
+
return name;
|
|
45
|
+
}
|
|
@@ -6,6 +6,7 @@ import { rCombo_definition, rCombo_item, cached_sources } from "./combo";
|
|
|
6
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
|
+
import { showMenu } from "../menu.js";
|
|
9
10
|
export let label = "";
|
|
10
11
|
export let self = null;
|
|
11
12
|
export let a = "";
|
|
@@ -140,13 +141,19 @@ afterUpdate(() => {
|
|
|
140
141
|
if (is_dropdown_open && textbox && document.activeElement != textbox)
|
|
141
142
|
textbox.focus();
|
|
142
143
|
});
|
|
144
|
+
let closeButtonPos = "";
|
|
145
|
+
let dropdownElement;
|
|
143
146
|
function dropdown_action(node) {
|
|
144
|
-
if (is_dropdown_open)
|
|
145
|
-
|
|
147
|
+
if (is_dropdown_open) {
|
|
148
|
+
const rect = node.getBoundingClientRect();
|
|
149
|
+
dropdown_height = rect.height;
|
|
150
|
+
}
|
|
146
151
|
return {
|
|
147
152
|
update() {
|
|
148
|
-
if (is_dropdown_open)
|
|
149
|
-
|
|
153
|
+
if (is_dropdown_open) {
|
|
154
|
+
const rect = node.getBoundingClientRect();
|
|
155
|
+
dropdown_height = rect.height;
|
|
156
|
+
}
|
|
150
157
|
},
|
|
151
158
|
destroy() {
|
|
152
159
|
}
|
|
@@ -174,58 +181,7 @@ export function show(event, hide_callback) {
|
|
|
174
181
|
client_rect.y = 0;
|
|
175
182
|
client_rect.width = window.innerWidth;
|
|
176
183
|
client_rect.height = window.innerHeight;
|
|
177
|
-
|
|
178
|
-
if (is_compact)
|
|
179
|
-
rect = textbox.getBoundingClientRect();
|
|
180
|
-
else
|
|
181
|
-
rect = combo.getBoundingClientRect();
|
|
182
|
-
let top_space = rect.y;
|
|
183
|
-
let bottom_space = client_rect.height - (rect.y + rect.height);
|
|
184
|
-
let palette_max_height_px = 500;
|
|
185
|
-
let palette_width_px = rect.width;
|
|
186
|
-
if (palette_width_px < 120)
|
|
187
|
-
palette_width_px = 120;
|
|
188
|
-
let preferred_palette_height = dropdown_height > 0 ? dropdown_height : palette_max_height_px;
|
|
189
|
-
let preferred_palette_width = palette_width_px;
|
|
190
|
-
let x = 0, y = 0;
|
|
191
|
-
let show_above = false;
|
|
192
|
-
let show_fullscreen = false;
|
|
193
|
-
if (client_rect.width < preferred_palette_width)
|
|
194
|
-
show_fullscreen = true;
|
|
195
|
-
else if (rect.x + preferred_palette_width > client_rect.width)
|
|
196
|
-
x = client_rect.width - preferred_palette_width;
|
|
197
|
-
else
|
|
198
|
-
x = rect.x;
|
|
199
|
-
if (client_rect.height < preferred_palette_height)
|
|
200
|
-
show_fullscreen = true;
|
|
201
|
-
else if (bottom_space >= preferred_palette_height)
|
|
202
|
-
y = rect.y + rect.height;
|
|
203
|
-
else if (top_space >= preferred_palette_height) {
|
|
204
|
-
y = rect.y;
|
|
205
|
-
show_above = true;
|
|
206
|
-
} else
|
|
207
|
-
y = rect.y + rect.height;
|
|
208
|
-
if (isDeviceSmallerThan("sm")) {
|
|
209
|
-
let screenRect = new DOMRect();
|
|
210
|
-
screenRect.x = 0;
|
|
211
|
-
screenRect.y = 0;
|
|
212
|
-
screenRect.width = window.innerWidth;
|
|
213
|
-
screenRect.height = window.innerHeight;
|
|
214
|
-
const margin = 5;
|
|
215
|
-
const maxHeight = screenRect.height / 2 - margin;
|
|
216
|
-
const width = screenRect.width - 2 * margin;
|
|
217
|
-
x = margin;
|
|
218
|
-
y = screenRect.bottom - margin;
|
|
219
|
-
dropdown_position = `position: fixed; left: ${x}px; top: ${y}px; transform: translate(0, -100%); width: ${width}px; max-height: ${maxHeight}px; display: block`;
|
|
220
|
-
} else if (show_fullscreen) {
|
|
221
|
-
dropdown_position = `position: fixed; left: 0px; top: 0px; width: ${client_rect.width}px; height: ${client_rect.height}px;`;
|
|
222
|
-
} else {
|
|
223
|
-
dropdown_position = `min-width: ${palette_width_px}px; max-height:${palette_max_height_px}px; position: fixed; left:${x}px; top:${y}px;`;
|
|
224
|
-
if (show_above)
|
|
225
|
-
dropdown_position += " transform: translate(0, -100%);";
|
|
226
|
-
if (!is_compact)
|
|
227
|
-
dropdown_position += `width: ${preferred_palette_width}px`;
|
|
228
|
-
}
|
|
184
|
+
openDropdownAsMenu();
|
|
229
185
|
is_dropdown_open = true;
|
|
230
186
|
if (filtered) {
|
|
231
187
|
if (!textbox)
|
|
@@ -243,7 +199,7 @@ export function show(event, hide_callback) {
|
|
|
243
199
|
subtree: true
|
|
244
200
|
});
|
|
245
201
|
}
|
|
246
|
-
if (
|
|
202
|
+
if (false) {
|
|
247
203
|
pushToolsActionsOperations({
|
|
248
204
|
opver: 1,
|
|
249
205
|
operations: [
|
|
@@ -264,13 +220,37 @@ export function show(event, hide_callback) {
|
|
|
264
220
|
});
|
|
265
221
|
}
|
|
266
222
|
}
|
|
223
|
+
function openDropdownAsMenu() {
|
|
224
|
+
let rect;
|
|
225
|
+
if (is_compact)
|
|
226
|
+
rect = textbox.getBoundingClientRect();
|
|
227
|
+
else
|
|
228
|
+
rect = combo.getBoundingClientRect();
|
|
229
|
+
let operations = [];
|
|
230
|
+
if (hasNone)
|
|
231
|
+
operations.push({
|
|
232
|
+
caption: "<none>",
|
|
233
|
+
action: (f) => on_choose(null)
|
|
234
|
+
});
|
|
235
|
+
if (definition && definition.collection)
|
|
236
|
+
source_fetched(definition.collection);
|
|
237
|
+
const _filtered_source = filtered_source ? filtered_source : definition.source;
|
|
238
|
+
_filtered_source.forEach((i) => {
|
|
239
|
+
operations.push({
|
|
240
|
+
caption: i.Name ?? i.Key,
|
|
241
|
+
icon: i.Icon ?? void 0,
|
|
242
|
+
action: (f) => on_choose(i)
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
console.log("operations", operations);
|
|
246
|
+
showMenu(rect, operations);
|
|
247
|
+
}
|
|
267
248
|
export function hide() {
|
|
268
249
|
if (!is_dropdown_open)
|
|
269
250
|
return;
|
|
270
251
|
if (mutation_observer)
|
|
271
252
|
mutation_observer.disconnect();
|
|
272
253
|
is_dropdown_open = false;
|
|
273
|
-
popToolsActionsOperations();
|
|
274
254
|
dropdown_position = "display: none;";
|
|
275
255
|
combo_text = get_combo_text();
|
|
276
256
|
if (!!textbox)
|
|
@@ -464,7 +444,7 @@ function on_input_change() {
|
|
|
464
444
|
if (!is_dropdown_open)
|
|
465
445
|
return;
|
|
466
446
|
filtered_source = get_filtered_source();
|
|
467
|
-
|
|
447
|
+
openDropdownAsMenu();
|
|
468
448
|
}
|
|
469
449
|
let new_item_option;
|
|
470
450
|
function get_filtered_source() {
|
|
@@ -664,71 +644,91 @@ function on_focus_out(e) {
|
|
|
664
644
|
|
|
665
645
|
</div>
|
|
666
646
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
647
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
648
|
+
<!--div hidden={!is_dropdown_open}>
|
|
649
|
+
{#if closeButtonPos}
|
|
650
|
+
{#key closeButtonPos}
|
|
651
|
+
<button class=" fixed w-6 h-6 flex items-center justify-center
|
|
652
|
+
text-stone-500 bg-stone-200/70 hover:bg-stone-200
|
|
653
|
+
focus:outline-none font-medium rounded-full text-sm text-center
|
|
654
|
+
dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700
|
|
655
|
+
focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800"
|
|
656
|
+
style={closeButtonPos}
|
|
657
|
+
on:click={ hide }>
|
|
658
|
+
<Icon component={FaTimes} s="md"/>
|
|
659
|
+
</button>
|
|
660
|
+
{/key}
|
|
661
|
+
{/if}
|
|
672
662
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
class:dark:hover:bg-stone-700={highlighted_option == null}
|
|
681
|
-
on:mousemove={() => on_mouse_move(null)}
|
|
682
|
-
on:click|preventDefault|stopPropagation={async () => await on_choose(null)}
|
|
683
|
-
tabindex="-1">
|
|
663
|
+
<div class="not-prose {cs} 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 cursor-pointer z-40
|
|
664
|
+
fixed"
|
|
665
|
+
style={dropdown_position}
|
|
666
|
+
bind:this={dropdownElement}
|
|
667
|
+
use:dropdown_action>
|
|
668
|
+
|
|
669
|
+
|
|
684
670
|
|
|
685
|
-
|
|
686
|
-
<none>
|
|
687
|
-
</h4>
|
|
688
|
-
</li>
|
|
689
|
-
{/if}
|
|
671
|
+
<ul class="py-1">
|
|
690
672
|
|
|
691
|
-
{
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
{@const active=(highlighted_option == item) ? 'bg-stone-400/30 dark:bg-stone-400/30' : ''}
|
|
695
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
673
|
+
{#if definition.source && definition.source.length}
|
|
674
|
+
{#if hasNone}
|
|
675
|
+
|
|
696
676
|
<li class="rounded flex flex-row items-center {font_size}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
677
|
+
space-x-10 px-4 py-2 ml-12 sm:ml-0"
|
|
678
|
+
class:bg-stone-100={highlighted_option == null}
|
|
679
|
+
class:dark:bg-stone-700={highlighted_option == null}
|
|
680
|
+
class:dark:hover:bg-stone-700={highlighted_option == null}
|
|
681
|
+
on:mousemove={() => on_mouse_move(null)}
|
|
682
|
+
on:click|preventDefault|stopPropagation={async () => await on_choose(null)}
|
|
700
683
|
tabindex="-1">
|
|
701
684
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
<Icon s="md" circle={true} color={item.Color}/>
|
|
705
|
-
{:else if item.Avatar}
|
|
706
|
-
<Icon s="md" circle={true} symbol={item.Avatar}/>
|
|
707
|
-
{:else if item.Icon}
|
|
708
|
-
<Icon s="md" component={item.Icon}/>
|
|
709
|
-
{:else if item.Icon == null}
|
|
710
|
-
<div class="w-4 h-4"></div>
|
|
711
|
-
{:else if item.Name}
|
|
712
|
-
<Icon s="md" circle={true} label={item.Name}/>
|
|
713
|
-
{:else}
|
|
714
|
-
<Icon s="md" circle={true}/>
|
|
715
|
-
{/if}
|
|
716
|
-
{/if}
|
|
717
|
-
<h4 class="ml-2">
|
|
718
|
-
{#if item.Name}
|
|
719
|
-
{item.Name}
|
|
720
|
-
{:else if item.Key}
|
|
721
|
-
{item.Key}
|
|
722
|
-
{/if}
|
|
685
|
+
<h4 class="ml-2 text-stone-400 dark:text-stone-500">
|
|
686
|
+
<none>
|
|
723
687
|
</h4>
|
|
724
688
|
</li>
|
|
725
|
-
{/
|
|
726
|
-
|
|
727
|
-
|
|
689
|
+
{/if}
|
|
690
|
+
|
|
691
|
+
{@const _filtered_source = filtered_source ? filtered_source : definition.source}
|
|
692
|
+
{#if _filtered_source.length > 0}
|
|
693
|
+
{#each _filtered_source as item (item.Key)}
|
|
694
|
+
{@const active=(highlighted_option == item) ? 'bg-stone-400/30 dark:bg-stone-400/30' : ''}
|
|
695
|
+
<li class="rounded flex flex-row items-center {font_size}
|
|
696
|
+
space-x-10 px-4 py-2 pl-12 sm:pl-2 {active}"
|
|
697
|
+
on:mousemove={() => on_mouse_move(item)}
|
|
698
|
+
on:click|preventDefault|stopPropagation={async () => await on_choose(item)}
|
|
699
|
+
tabindex="-1">
|
|
700
|
+
|
|
701
|
+
{#if icon}
|
|
702
|
+
{#if item.Color}
|
|
703
|
+
<Icon s="md" circle={true} color={item.Color}/>
|
|
704
|
+
{:else if item.Avatar}
|
|
705
|
+
<Icon s="md" circle={true} symbol={item.Avatar}/>
|
|
706
|
+
{:else if item.Icon}
|
|
707
|
+
<Icon s="md" component={item.Icon}/>
|
|
708
|
+
{:else if item.Icon == null}
|
|
709
|
+
<div class="w-4 h-4"></div>
|
|
710
|
+
{:else if item.Name}
|
|
711
|
+
<Icon s="md" circle={true} label={item.Name}/>
|
|
712
|
+
{:else}
|
|
713
|
+
<Icon s="md" circle={true}/>
|
|
714
|
+
{/if}
|
|
715
|
+
{/if}
|
|
716
|
+
<h4 class="ml-2">
|
|
717
|
+
{#if item.Name}
|
|
718
|
+
{item.Name}
|
|
719
|
+
{:else if item.Key}
|
|
720
|
+
{item.Key}
|
|
721
|
+
{/if}
|
|
722
|
+
</h4>
|
|
723
|
+
</li>
|
|
724
|
+
{/each}
|
|
725
|
+
{:else}
|
|
726
|
+
<li class="rounded p-2">No options</li>
|
|
727
|
+
{/if}
|
|
728
728
|
{/if}
|
|
729
|
-
|
|
730
|
-
</
|
|
731
|
-
</div
|
|
729
|
+
</ul>
|
|
730
|
+
</div>
|
|
731
|
+
</div-->
|
|
732
732
|
</div>
|
|
733
733
|
{/if}
|
|
734
734
|
|