@humandialog/forms.svelte 0.4.12 → 0.4.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.
- package/components/Floating_container.svelte +43 -10
- package/components/Floating_container.svelte.d.ts +4 -2
- package/components/Grid.menu.svelte +3 -3
- package/components/Grid.menu.svelte.d.ts +2 -2
- package/components/combo/combo.svelte +6 -8
- package/components/contextmenu.svelte +23 -9
- package/components/contextmenu.svelte.d.ts +4 -2
- package/components/date.svelte +130 -22
- package/components/date.svelte.d.ts +7 -0
- package/components/menu.d.ts +3 -3
- package/components/menu.js +20 -10
- package/components/sidebar/sidebar.brand.svelte +16 -0
- package/components/sidebar/sidebar.brand.svelte.d.ts +29 -0
- package/components/sidebar/sidebar.group.svelte +21 -0
- package/components/sidebar/sidebar.group.svelte.d.ts +31 -0
- package/components/sidebar/sidebar.item.svelte +60 -0
- package/components/sidebar/sidebar.item.svelte.d.ts +25 -0
- package/components/sidebar/sidebar.svelte +9 -0
- package/components/sidebar/sidebar.svelte.d.ts +27 -0
- package/components/simple.table.svelte.d.ts +2 -2
- package/components/table/_template.table.svelte.d.ts +2 -2
- package/components/table/table.svelte +1 -1
- package/desk.svelte +57 -33
- package/horizontal.toolbar.svelte +11 -5
- package/index.d.ts +6 -1
- package/index.js +6 -1
- package/operations.svelte +11 -5
- package/operations.svelte.d.ts +3 -1
- package/package.json +6 -2
- package/utils.d.ts +20 -0
- package/utils.js +224 -1
- package/vertical.toolbar.svelte +11 -4
|
@@ -1,45 +1,78 @@
|
|
|
1
|
-
<script>import { tick } from "svelte";
|
|
1
|
+
<script>import { tick, afterUpdate } from "svelte";
|
|
2
|
+
import { is_device_smaller_than } from "../utils";
|
|
2
3
|
let x;
|
|
3
4
|
let y;
|
|
4
5
|
let visible = false;
|
|
5
6
|
let toolbar;
|
|
6
7
|
let props = {};
|
|
8
|
+
let around_rect;
|
|
7
9
|
let root_element;
|
|
8
10
|
let invisible_button;
|
|
9
11
|
$:
|
|
10
12
|
display = visible ? "fixed" : "hidden";
|
|
11
|
-
export async function show(
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
export async function show(around, _toolbar, _props = {}) {
|
|
14
|
+
if (around instanceof DOMRect) {
|
|
15
|
+
x = around.left;
|
|
16
|
+
y = around.bottom;
|
|
17
|
+
around_rect = around;
|
|
18
|
+
} else if (around instanceof DOMPoint) {
|
|
19
|
+
x = around.x;
|
|
20
|
+
y = around.y;
|
|
21
|
+
around_rect = new DOMRect(x, y, 0, 0);
|
|
22
|
+
}
|
|
14
23
|
visible = true;
|
|
15
24
|
toolbar = _toolbar;
|
|
16
25
|
props = _props;
|
|
26
|
+
props.onhide = () => {
|
|
27
|
+
hide();
|
|
28
|
+
};
|
|
17
29
|
await tick();
|
|
18
30
|
focus_first_element();
|
|
19
31
|
}
|
|
32
|
+
export function is_visible() {
|
|
33
|
+
return visible;
|
|
34
|
+
}
|
|
20
35
|
export function hide() {
|
|
21
36
|
visible = false;
|
|
22
37
|
}
|
|
38
|
+
afterUpdate(() => {
|
|
39
|
+
if (!root_element)
|
|
40
|
+
return;
|
|
41
|
+
let rect = root_element.getBoundingClientRect();
|
|
42
|
+
if (rect.height == 0)
|
|
43
|
+
return;
|
|
44
|
+
let container_rect = new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
45
|
+
if (rect.right > container_rect.right)
|
|
46
|
+
x = container_rect.right - rect.width;
|
|
47
|
+
if (rect.bottom > container_rect.bottom)
|
|
48
|
+
y = container_rect.bottom - rect.height - around_rect.height;
|
|
49
|
+
if (rect.left < container_rect.left)
|
|
50
|
+
x = container_rect.left;
|
|
51
|
+
if (rect.top < container_rect.top)
|
|
52
|
+
y = container_rect.top;
|
|
53
|
+
});
|
|
23
54
|
function focus_first_element() {
|
|
24
55
|
invisible_button.focus();
|
|
25
56
|
return;
|
|
26
57
|
let focusable = root_element.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
27
|
-
console.log(focusable);
|
|
28
58
|
focusable.focus();
|
|
29
59
|
}
|
|
30
60
|
function on_focus_out(e) {
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
if (!is_device_smaller_than("sm")) {
|
|
62
|
+
if (e.relatedTarget && root_element?.contains(e.relatedTarget)) {
|
|
63
|
+
} else
|
|
64
|
+
hide();
|
|
65
|
+
} else {
|
|
66
|
+
}
|
|
34
67
|
}
|
|
35
68
|
</script>
|
|
36
69
|
|
|
37
70
|
<div id="__hd_svelte_floating_container"
|
|
38
71
|
class="p-2 bg-slate-100 dark:bg-slate-800 rounded-lg shadow {display}"
|
|
39
|
-
style="left:{x}px; top:{y}px"
|
|
72
|
+
style="left:{x}px; top:{y}px; width: max-content; height:max-content"
|
|
40
73
|
on:focusout={on_focus_out}
|
|
41
74
|
bind:this={root_element}>
|
|
42
75
|
<button class="w-0 h-0 fixed bg-transparent " bind:this={invisible_button}></button>
|
|
43
|
-
<svelte:component this={toolbar} {...props}
|
|
76
|
+
<svelte:component this={toolbar} {...props} />
|
|
44
77
|
</div>
|
|
45
78
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
show?: ((
|
|
4
|
+
show?: ((around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>) | undefined;
|
|
5
|
+
is_visible?: (() => boolean) | undefined;
|
|
5
6
|
hide?: (() => void) | undefined;
|
|
6
7
|
};
|
|
7
8
|
events: {
|
|
@@ -13,7 +14,8 @@ export type FloatingContainerProps = typeof __propDef.props;
|
|
|
13
14
|
export type FloatingContainerEvents = typeof __propDef.events;
|
|
14
15
|
export type FloatingContainerSlots = typeof __propDef.slots;
|
|
15
16
|
export default class FloatingContainer extends SvelteComponentTyped<FloatingContainerProps, FloatingContainerEvents, FloatingContainerSlots> {
|
|
16
|
-
get show(): (
|
|
17
|
+
get show(): (around: DOMRect | DOMPoint, _toolbar: any, _props?: {}) => Promise<void>;
|
|
18
|
+
get is_visible(): () => boolean;
|
|
17
19
|
get hide(): () => void;
|
|
18
20
|
}
|
|
19
21
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {context_items_store} from '../stores.js'
|
|
3
3
|
|
|
4
4
|
export let operations = []
|
|
5
|
-
export let
|
|
5
|
+
export let onhide = undefined;
|
|
6
6
|
|
|
7
7
|
$: grid_cols = init(operations);
|
|
8
8
|
|
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
|
|
95
95
|
function execute_action(e, operation)
|
|
96
96
|
{
|
|
97
|
-
if(
|
|
98
|
-
|
|
97
|
+
if(!!onhide)
|
|
98
|
+
onhide();
|
|
99
99
|
|
|
100
100
|
if(!operation)
|
|
101
101
|
return;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} GridEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} GridSlots */
|
|
4
4
|
export default class Grid extends SvelteComponentTyped<{
|
|
5
|
-
|
|
5
|
+
onhide?: any;
|
|
6
6
|
operations?: any[] | undefined;
|
|
7
7
|
}, {
|
|
8
8
|
[evt: string]: CustomEvent<any>;
|
|
@@ -14,7 +14,7 @@ export type GridSlots = typeof __propDef.slots;
|
|
|
14
14
|
import { SvelteComponentTyped } from "svelte";
|
|
15
15
|
declare const __propDef: {
|
|
16
16
|
props: {
|
|
17
|
-
|
|
17
|
+
onhide?: any;
|
|
18
18
|
operations?: any[] | undefined;
|
|
19
19
|
};
|
|
20
20
|
events: {
|
|
@@ -56,9 +56,7 @@ switch (s) {
|
|
|
56
56
|
let background_class = is_compact && !icon ? "bg-slate-900/10 dark:bg-slate-100/10 rounded-lg" : "";
|
|
57
57
|
let appearance_class;
|
|
58
58
|
if (is_compact)
|
|
59
|
-
appearance_class =
|
|
60
|
-
focus:ring-primary-600 block w-full ${input_pb} ${input_pt} px-2.5 dark:bg-gray-700
|
|
61
|
-
dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 ${background_class}`;
|
|
59
|
+
appearance_class = `${font_size}`;
|
|
62
60
|
else
|
|
63
61
|
appearance_class = ` bg-gray-50 border border-gray-300 text-gray-900 ${font_size} rounded-lg
|
|
64
62
|
focus:ring-primary-600 focus:border-primary-600 block w-full ${input_pb} ${input_pt} px-2.5 dark:bg-gray-700
|
|
@@ -454,7 +452,7 @@ function on_focus_out(e) {
|
|
|
454
452
|
{#if true}
|
|
455
453
|
{@const c = setup_view(item, a, tick_request_internal) }
|
|
456
454
|
|
|
457
|
-
<div class={cs}
|
|
455
|
+
<div class="{cs} max-w-full inline-block"
|
|
458
456
|
on:focusout={on_focus_out}
|
|
459
457
|
bind:this={root_element}>
|
|
460
458
|
{#if !is_compact}
|
|
@@ -462,12 +460,12 @@ function on_focus_out(e) {
|
|
|
462
460
|
{/if}
|
|
463
461
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
464
462
|
<div bind:this={combo}
|
|
465
|
-
on:click={show}
|
|
466
|
-
class="{appearance_class} flex flex-row content-between items-center"
|
|
463
|
+
on:click={(e) => { show(e, undefined) }}
|
|
467
464
|
class:cursor-pointer={can_be_activated && is_compact}
|
|
465
|
+
class="max-w-full {appearance_class} flex flex-row content-between items-center"
|
|
468
466
|
>
|
|
469
467
|
|
|
470
|
-
<div class="flex-1 flex flex-row items-center">
|
|
468
|
+
<div class="max-w-full flex-1 flex flex-row items-center">
|
|
471
469
|
{#if !is_dropdown_open}
|
|
472
470
|
{#if icon && sel_item}
|
|
473
471
|
{#if sel_item.Color}
|
|
@@ -480,7 +478,7 @@ function on_focus_out(e) {
|
|
|
480
478
|
|
|
481
479
|
|
|
482
480
|
<p bind:this={textbox}
|
|
483
|
-
class="dark:text-white {line_h}"
|
|
481
|
+
class="dark:text-white {line_h} truncate px-2.5 {background_class}"
|
|
484
482
|
class:ml-2={icon}
|
|
485
483
|
class:text-gray-400={ (!is_dropdown_open) && (!sel_item)}
|
|
486
484
|
class:text-gray-700={ is_dropdown_open || sel_item }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { afterUpdate, tick } from "svelte";
|
|
2
2
|
import Icon from "./icon.svelte";
|
|
3
3
|
import { context_items_store } from "../stores";
|
|
4
|
+
import { is_device_smaller_than } from "../utils";
|
|
4
5
|
export let width_px = 400;
|
|
5
6
|
export let menu_items_id_prefix = "__hd_svelte_menuitem_";
|
|
6
7
|
export let owner_menu_item = void 0;
|
|
@@ -13,6 +14,7 @@ let min_width_px = 200;
|
|
|
13
14
|
let focused_index = 0;
|
|
14
15
|
let menu_items = [];
|
|
15
16
|
let submenus = [];
|
|
17
|
+
let around_rect;
|
|
16
18
|
$:
|
|
17
19
|
display = visible ? "block" : "none";
|
|
18
20
|
afterUpdate(() => {
|
|
@@ -23,15 +25,22 @@ afterUpdate(() => {
|
|
|
23
25
|
if (rect.right > container_rect.right)
|
|
24
26
|
x = container_rect.right - rect.width;
|
|
25
27
|
if (rect.bottom > container_rect.bottom)
|
|
26
|
-
y = container_rect.bottom - rect.height;
|
|
28
|
+
y = container_rect.bottom - rect.height - around_rect.height;
|
|
27
29
|
if (rect.left < container_rect.left)
|
|
28
30
|
x = container_rect.left;
|
|
29
31
|
if (rect.top < container_rect.top)
|
|
30
32
|
y = container_rect.top;
|
|
31
33
|
});
|
|
32
|
-
export async function show(
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
export async function show(around, _operations) {
|
|
35
|
+
if (around instanceof DOMRect) {
|
|
36
|
+
x = around.left;
|
|
37
|
+
y = around.bottom;
|
|
38
|
+
around_rect = around;
|
|
39
|
+
} else if (around instanceof DOMPoint) {
|
|
40
|
+
x = around.x;
|
|
41
|
+
y = around.y;
|
|
42
|
+
around_rect = new DOMRect(x, y, 0, 0);
|
|
43
|
+
}
|
|
35
44
|
visible = true;
|
|
36
45
|
operations = [..._operations];
|
|
37
46
|
focused_index = 0;
|
|
@@ -39,6 +48,9 @@ export async function show(_x, _y, _operations) {
|
|
|
39
48
|
if (menu_items.length)
|
|
40
49
|
focus_menu_item(focused_index);
|
|
41
50
|
}
|
|
51
|
+
export function is_visible() {
|
|
52
|
+
return visible;
|
|
53
|
+
}
|
|
42
54
|
export function hide() {
|
|
43
55
|
visible = false;
|
|
44
56
|
}
|
|
@@ -91,10 +103,12 @@ function navigate_down() {
|
|
|
91
103
|
}
|
|
92
104
|
}
|
|
93
105
|
function on_change_focus(e) {
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
if (!is_device_smaller_than("sm")) {
|
|
107
|
+
if (e.relatedTarget && e.relatedTarget.id.startsWith(menu_items_id_prefix))
|
|
108
|
+
return;
|
|
109
|
+
else
|
|
110
|
+
hide();
|
|
111
|
+
}
|
|
98
112
|
}
|
|
99
113
|
function on_mouse_move(index) {
|
|
100
114
|
focus_menu_item(index);
|
|
@@ -142,7 +156,7 @@ function hide_submenu() {
|
|
|
142
156
|
</script>
|
|
143
157
|
|
|
144
158
|
<div id="__hd_svelte_contextmenu"
|
|
145
|
-
class="bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded-lg border border-gray-200 dark:border-gray-700 shadow-md z-20 fixed min-w-[{min_width_px}px]"
|
|
159
|
+
class="bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400 rounded-lg border border-gray-200 dark:border-gray-700 shadow-md z-20 fixed min-w-[{min_width_px}px] w-max"
|
|
146
160
|
style={`left:${x}px; top:${y}px; display:${display}`}
|
|
147
161
|
bind:this={menu_root}
|
|
148
162
|
on:focusout={on_change_focus}>
|
|
@@ -4,7 +4,8 @@ declare const __propDef: {
|
|
|
4
4
|
width_px?: number | undefined;
|
|
5
5
|
menu_items_id_prefix?: string | undefined;
|
|
6
6
|
owner_menu_item?: HTMLElement | undefined;
|
|
7
|
-
show?: ((
|
|
7
|
+
show?: ((around: DOMRect | DOMPoint, _operations: any) => Promise<void>) | undefined;
|
|
8
|
+
is_visible?: (() => boolean) | undefined;
|
|
8
9
|
hide?: (() => void) | undefined;
|
|
9
10
|
get_rendered_rect?: (() => DOMRect | undefined) | undefined;
|
|
10
11
|
};
|
|
@@ -17,7 +18,8 @@ export type ContextmenuProps = typeof __propDef.props;
|
|
|
17
18
|
export type ContextmenuEvents = typeof __propDef.events;
|
|
18
19
|
export type ContextmenuSlots = typeof __propDef.slots;
|
|
19
20
|
export default class Contextmenu extends SvelteComponentTyped<ContextmenuProps, ContextmenuEvents, ContextmenuSlots> {
|
|
20
|
-
get show(): (
|
|
21
|
+
get show(): (around: DOMRect | DOMPoint, _operations: any) => Promise<void>;
|
|
22
|
+
get is_visible(): () => boolean;
|
|
21
23
|
get hide(): () => void;
|
|
22
24
|
get get_rendered_rect(): () => DOMRect | undefined;
|
|
23
25
|
}
|
package/components/date.svelte
CHANGED
|
@@ -1,45 +1,80 @@
|
|
|
1
1
|
<script>import { getContext } from "svelte";
|
|
2
2
|
import { data_tick_store, context_items_store, context_types_store } from "../stores.js";
|
|
3
3
|
import { inform_modification, push_changes } from "../updates.js";
|
|
4
|
-
import { parse_width_directive } from "../utils.js";
|
|
4
|
+
import { parse_width_directive, is_device_smaller_than } from "../utils.js";
|
|
5
5
|
export let self = null;
|
|
6
6
|
export let a = "";
|
|
7
7
|
export let context = "";
|
|
8
8
|
export let typename = "";
|
|
9
9
|
export let date = null;
|
|
10
|
+
export let on_select = void 0;
|
|
11
|
+
export let type = "date";
|
|
12
|
+
export let changed = void 0;
|
|
10
13
|
export let s = "sm";
|
|
11
14
|
export let c = "";
|
|
12
|
-
let
|
|
15
|
+
export let compact = false;
|
|
16
|
+
export let in_context = "sel";
|
|
17
|
+
let on_hide_callback = void 0;
|
|
18
|
+
export function show(event, hide_callback) {
|
|
19
|
+
if (event) {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
}
|
|
23
|
+
if (!!hide_callback)
|
|
24
|
+
on_hide_callback = hide_callback;
|
|
25
|
+
else
|
|
26
|
+
on_hide_callback = void 0;
|
|
27
|
+
if (input_element) {
|
|
28
|
+
input_element.focus();
|
|
29
|
+
if (is_device_smaller_than("sm")) {
|
|
30
|
+
input_element.click();
|
|
31
|
+
}
|
|
32
|
+
if ("showPicker" in HTMLInputElement.prototype) {
|
|
33
|
+
input_element.showPicker();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let is_compact = getContext("rIs-table-component") || compact;
|
|
13
38
|
let input_pt = "pt-0.5";
|
|
14
39
|
let input_pb = "pb-1";
|
|
40
|
+
let font_size = "text-sm";
|
|
41
|
+
let line_h = "h-4";
|
|
15
42
|
switch (s) {
|
|
16
43
|
case "md":
|
|
17
44
|
input_pt = "pt-2.5";
|
|
18
45
|
input_pb = "pb-2.5";
|
|
46
|
+
font_size = "text-sm";
|
|
47
|
+
line_h = "h-5";
|
|
48
|
+
break;
|
|
49
|
+
case "xs":
|
|
50
|
+
input_pt = "pt-0.5";
|
|
51
|
+
input_pb = "pb-0.5";
|
|
52
|
+
font_size = "text-xs";
|
|
53
|
+
line_h = "h-4";
|
|
19
54
|
break;
|
|
20
55
|
}
|
|
21
56
|
let item = null;
|
|
22
|
-
let
|
|
57
|
+
let user_class = $$restProps.class ?? "";
|
|
23
58
|
let value = null;
|
|
24
59
|
let rValue = "";
|
|
25
60
|
let ctx = context ? context : getContext("ctx");
|
|
26
61
|
let cs = parse_width_directive(c);
|
|
27
62
|
let style;
|
|
28
|
-
|
|
63
|
+
let input_element = void 0;
|
|
64
|
+
let background_class = is_compact ? "bg-slate-900/10 dark:bg-slate-100/10 rounded-lg" : "";
|
|
65
|
+
if (!is_compact) {
|
|
29
66
|
style = `bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg
|
|
30
67
|
focus:ring-primary-600 focus:border-primary-600 block w-full ${input_pb} ${input_pt} px-2.5 dark:bg-gray-700
|
|
31
68
|
dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500`;
|
|
32
69
|
} else {
|
|
33
|
-
style =
|
|
70
|
+
style = `${font_size}`;
|
|
34
71
|
}
|
|
35
72
|
let can_be_activated = true;
|
|
36
73
|
let last_tick = -1;
|
|
37
74
|
$:
|
|
38
|
-
setup($data_tick_store);
|
|
39
|
-
function setup(
|
|
40
|
-
|
|
41
|
-
return;
|
|
42
|
-
last_tick = data_tick_store2;
|
|
75
|
+
setup($data_tick_store, $context_items_store);
|
|
76
|
+
function setup(...args) {
|
|
77
|
+
last_tick = data_tick_store;
|
|
43
78
|
if (!date) {
|
|
44
79
|
item = self ?? $context_items_store[ctx];
|
|
45
80
|
if (!typename)
|
|
@@ -50,8 +85,8 @@ function setup(data_tick_store2) {
|
|
|
50
85
|
value = new Date(item[a]);
|
|
51
86
|
} else
|
|
52
87
|
value = date;
|
|
53
|
-
if (
|
|
54
|
-
if ($context_items_store[
|
|
88
|
+
if (is_compact) {
|
|
89
|
+
if ($context_items_store[in_context] != self)
|
|
55
90
|
can_be_activated = false;
|
|
56
91
|
else
|
|
57
92
|
can_be_activated = true;
|
|
@@ -75,14 +110,20 @@ function get_formatted_date(d) {
|
|
|
75
110
|
hour = "0" + hour;
|
|
76
111
|
if (minutes.length < 2)
|
|
77
112
|
minutes = "0" + minutes;
|
|
78
|
-
|
|
113
|
+
if (type == "datetime-local")
|
|
114
|
+
return `${year}-${month}-${day} ${hour}:${minutes}`;
|
|
115
|
+
else
|
|
116
|
+
return `${year}-${month}-${day}`;
|
|
79
117
|
}
|
|
80
|
-
function on_changed() {
|
|
118
|
+
async function on_changed() {
|
|
81
119
|
if (!rValue)
|
|
82
120
|
value = null;
|
|
83
121
|
else
|
|
84
122
|
value = new Date(rValue);
|
|
85
|
-
|
|
123
|
+
console.log("rValue", rValue, "value", value);
|
|
124
|
+
if (on_select) {
|
|
125
|
+
await on_select(value);
|
|
126
|
+
} else if (item != null) {
|
|
86
127
|
if (value)
|
|
87
128
|
item[a] = value.toISOString();
|
|
88
129
|
else
|
|
@@ -92,22 +133,89 @@ function on_changed() {
|
|
|
92
133
|
$data_tick_store = $data_tick_store + 1;
|
|
93
134
|
push_changes();
|
|
94
135
|
}
|
|
136
|
+
if (!!changed)
|
|
137
|
+
changed(value);
|
|
95
138
|
}
|
|
96
139
|
}
|
|
140
|
+
function blur(e) {
|
|
141
|
+
if (!!on_hide_callback)
|
|
142
|
+
on_hide_callback();
|
|
143
|
+
}
|
|
97
144
|
</script>
|
|
98
145
|
|
|
99
|
-
{#if
|
|
100
|
-
<
|
|
146
|
+
{#if is_compact}
|
|
147
|
+
<div class="inline-block relative {line_h}">
|
|
148
|
+
<span class="dark:text-white {font_size} truncate px-2.5 {background_class}
|
|
149
|
+
absolute left-0 top-0 h-full" >
|
|
150
|
+
{rValue}
|
|
151
|
+
|
|
152
|
+
{#if can_be_activated}
|
|
153
|
+
{#if type == "datetime-local"}
|
|
154
|
+
<input type="datetime-local"
|
|
155
|
+
class="datepicker-input"
|
|
156
|
+
on:change={on_changed}
|
|
157
|
+
bind:value={rValue}
|
|
158
|
+
bind:this={input_element}>
|
|
159
|
+
{:else}
|
|
160
|
+
<input type="date"
|
|
161
|
+
class="datepicker-input"
|
|
162
|
+
on:change={on_changed}
|
|
163
|
+
bind:value={rValue}
|
|
164
|
+
bind:this={input_element}
|
|
165
|
+
on:blur={blur}>
|
|
166
|
+
{/if}
|
|
167
|
+
{/if}
|
|
168
|
+
</span>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
101
171
|
{:else}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
172
|
+
{#if type == "datetime-local"}
|
|
173
|
+
<input class=" dark:text-white {cs} {style} {line_h} px-2.5 {background_class} {user_class}"
|
|
174
|
+
type="datetime-local"
|
|
175
|
+
on:change={on_changed}
|
|
176
|
+
bind:value={rValue}
|
|
177
|
+
bind:this={input_element}
|
|
178
|
+
/>
|
|
179
|
+
{:else}
|
|
180
|
+
<input class=" dark:text-white {cs} {style} {line_h} px-2.5 {background_class} {user_class}"
|
|
181
|
+
type="date"
|
|
182
|
+
on:change={on_changed}
|
|
183
|
+
bind:value={rValue}
|
|
184
|
+
bind:this={input_element}
|
|
185
|
+
/>
|
|
186
|
+
{/if}
|
|
106
187
|
{/if}
|
|
107
188
|
|
|
108
189
|
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
109
193
|
<style>
|
|
110
194
|
input:focus {
|
|
111
195
|
outline: 0px solid transparent;
|
|
112
196
|
}
|
|
113
|
-
|
|
197
|
+
|
|
198
|
+
.datepicker-input{
|
|
199
|
+
position: absolute;
|
|
200
|
+
left: 0;
|
|
201
|
+
top: 0;
|
|
202
|
+
width: 100%;
|
|
203
|
+
height: 100%;
|
|
204
|
+
opacity: 0;
|
|
205
|
+
cursor: pointer;
|
|
206
|
+
box-sizing: border-box;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.datepicker-input::-webkit-calendar-picker-indicator {
|
|
210
|
+
position: absolute;
|
|
211
|
+
left: 0;
|
|
212
|
+
top: 0;
|
|
213
|
+
width: 100%;
|
|
214
|
+
height: 100%;
|
|
215
|
+
margin: 0;
|
|
216
|
+
padding: 0;
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
</style>
|
|
221
|
+
|
|
@@ -7,8 +7,14 @@ declare const __propDef: {
|
|
|
7
7
|
context?: string | undefined;
|
|
8
8
|
typename?: string | undefined;
|
|
9
9
|
date?: Date | undefined;
|
|
10
|
+
on_select?: undefined;
|
|
11
|
+
type?: string | undefined;
|
|
12
|
+
changed?: undefined;
|
|
10
13
|
s?: string | undefined;
|
|
11
14
|
c?: string | undefined;
|
|
15
|
+
compact?: boolean | undefined;
|
|
16
|
+
in_context?: string | undefined;
|
|
17
|
+
show?: ((event: any, hide_callback: any) => void) | undefined;
|
|
12
18
|
};
|
|
13
19
|
events: {
|
|
14
20
|
[evt: string]: CustomEvent<any>;
|
|
@@ -19,5 +25,6 @@ export type DateProps = typeof __propDef.props;
|
|
|
19
25
|
export type DateEvents = typeof __propDef.events;
|
|
20
26
|
export type DateSlots = typeof __propDef.slots;
|
|
21
27
|
export default class Date extends SvelteComponentTyped<DateProps, DateEvents, DateSlots> {
|
|
28
|
+
get show(): (event: any, hide_callback: any) => void;
|
|
22
29
|
}
|
|
23
30
|
export {};
|
package/components/menu.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function show_menu(
|
|
2
|
-
export declare function show_floating_toolbar(
|
|
3
|
-
export declare function show_grid_menu(
|
|
1
|
+
export declare function show_menu(around: DOMRect | DOMPoint, operations: any): void;
|
|
2
|
+
export declare function show_floating_toolbar(around: DOMRect | DOMPoint, toolbar: any, props?: {}): void;
|
|
3
|
+
export declare function show_grid_menu(around: DOMRect | DOMPoint, operations: any): void;
|
package/components/menu.js
CHANGED
|
@@ -3,7 +3,7 @@ import Floating_container from './Floating_container.svelte';
|
|
|
3
3
|
import Grid from './Grid.menu.svelte';
|
|
4
4
|
let menu_comopnent = null;
|
|
5
5
|
let toolbar_component = null;
|
|
6
|
-
export function show_menu(
|
|
6
|
+
export function show_menu(around, operations) {
|
|
7
7
|
let menu_element = document.getElementById("__hd_svelte_contextmenu");
|
|
8
8
|
if (!!!menu_element) {
|
|
9
9
|
let app_div = document.getElementById("__hd_svelte_layout_root");
|
|
@@ -11,14 +11,18 @@ export function show_menu(x, y, operations) {
|
|
|
11
11
|
target: app_div,
|
|
12
12
|
props: {}
|
|
13
13
|
});
|
|
14
|
-
menu_comopnent.show(
|
|
14
|
+
menu_comopnent.show(around, operations);
|
|
15
|
+
}
|
|
16
|
+
else if (menu_comopnent) {
|
|
17
|
+
if (menu_comopnent.is_visible())
|
|
18
|
+
menu_comopnent.hide();
|
|
19
|
+
else
|
|
20
|
+
menu_comopnent.show(around, operations);
|
|
15
21
|
}
|
|
16
|
-
else if (menu_comopnent)
|
|
17
|
-
menu_comopnent.show(x, y, operations);
|
|
18
22
|
else
|
|
19
23
|
console.error('what now?');
|
|
20
24
|
}
|
|
21
|
-
export function show_floating_toolbar(
|
|
25
|
+
export function show_floating_toolbar(around, toolbar, props = {}) {
|
|
22
26
|
let floating_container = document.getElementById("__hd_svelte_floating_container");
|
|
23
27
|
if (!!!floating_container) {
|
|
24
28
|
let app_div = document.getElementById("__hd_svelte_layout_root");
|
|
@@ -26,13 +30,19 @@ export function show_floating_toolbar(x, y, toolbar, props = {}) {
|
|
|
26
30
|
target: app_div,
|
|
27
31
|
props: {}
|
|
28
32
|
});
|
|
29
|
-
toolbar_component.show(
|
|
33
|
+
toolbar_component.show(around, toolbar, props);
|
|
34
|
+
}
|
|
35
|
+
else if (toolbar_component) {
|
|
36
|
+
if (toolbar_component.is_visible()) {
|
|
37
|
+
toolbar_component.hide();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
toolbar_component.show(around, toolbar, props);
|
|
41
|
+
}
|
|
30
42
|
}
|
|
31
|
-
else if (toolbar_component)
|
|
32
|
-
toolbar_component.show(x, y, toolbar, props);
|
|
33
43
|
else
|
|
34
44
|
console.error('what now?');
|
|
35
45
|
}
|
|
36
|
-
export function show_grid_menu(
|
|
37
|
-
show_floating_toolbar(
|
|
46
|
+
export function show_grid_menu(around, operations) {
|
|
47
|
+
show_floating_toolbar(around, Grid, { operations: operations });
|
|
38
48
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
export let href = "/";
|
|
4
|
+
export let img = "";
|
|
5
|
+
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<a href={href} class="flex items-center pl-2.5 mb-5">
|
|
9
|
+
{#if img}
|
|
10
|
+
<img src={img} class="h-6 mr-3 sm:h-7" alt="" />
|
|
11
|
+
{/if}
|
|
12
|
+
|
|
13
|
+
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">
|
|
14
|
+
<slot/>
|
|
15
|
+
</span>
|
|
16
|
+
</a>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} SidebarProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} SidebarEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} SidebarSlots */
|
|
4
|
+
export default class Sidebar extends SvelteComponentTyped<{
|
|
5
|
+
img?: string | undefined;
|
|
6
|
+
href?: string | undefined;
|
|
7
|
+
}, {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
}, {
|
|
10
|
+
default: {};
|
|
11
|
+
}> {
|
|
12
|
+
}
|
|
13
|
+
export type SidebarProps = typeof __propDef.props;
|
|
14
|
+
export type SidebarEvents = typeof __propDef.events;
|
|
15
|
+
export type SidebarSlots = typeof __propDef.slots;
|
|
16
|
+
import { SvelteComponentTyped } from "svelte";
|
|
17
|
+
declare const __propDef: {
|
|
18
|
+
props: {
|
|
19
|
+
img?: string | undefined;
|
|
20
|
+
href?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
events: {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {
|
|
26
|
+
default: {};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Icon from '../icon.svelte'
|
|
3
|
+
import Edit from '../edit.field.svelte'
|
|
4
|
+
import {FaPlus} from 'svelte-icons/fa'
|
|
5
|
+
|
|
6
|
+
export let border = false;
|
|
7
|
+
export let inserter = undefined;
|
|
8
|
+
export let inserter_placeholder = 'New'
|
|
9
|
+
|
|
10
|
+
let border_class = border ? " pt-4 mt-4 border-t border-gray-200 dark:border-gray-700" : ""
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<ul class="space-y-2 {border_class}">
|
|
14
|
+
<slot/>
|
|
15
|
+
|
|
16
|
+
{#if inserter}
|
|
17
|
+
<Edit class="p-2 text-base font-normal text-gray-500 rounded-lg dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700" on_enter={inserter} placeholder={inserter_placeholder} inserter={true}>
|
|
18
|
+
<Icon size={5} component={FaPlus} class="mr-3"/>
|
|
19
|
+
</Edit>
|
|
20
|
+
{/if}
|
|
21
|
+
</ul>
|