@nil-/doc 0.2.20 → 0.2.22
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/CHANGELOG.md +14 -0
- package/components/Layout.svelte +1 -6
- package/components/block/Block.svelte +0 -6
- package/components/block/Template.svelte +19 -11
- package/components/block/Template.svelte.d.ts +1 -0
- package/components/block/controls/Range.svelte +2 -2
- package/components/block/controls/misc/Styler.svelte +11 -3
- package/components/etc/Container.svelte +21 -9
- package/components/etc/action.d.ts +2 -0
- package/components/etc/action.js +26 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @nil-/doc
|
|
2
2
|
|
|
3
|
+
## 0.2.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3ce0a62: [doc] support for touch event via pointerevent (draggable container)
|
|
8
|
+
|
|
9
|
+
## 0.2.21
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0398a72: [doc][fix] remove dependency on box-sizing
|
|
14
|
+
[doc][fix] control min width
|
|
15
|
+
[doc][feature] made template configurable by column prop
|
|
16
|
+
|
|
3
17
|
## 0.2.20
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/components/Layout.svelte
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
padding: 5px;
|
|
13
13
|
display: flex;
|
|
14
14
|
flex-direction: column;
|
|
15
|
+
box-sizing: border-box;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/* reset block */
|
|
@@ -27,12 +28,6 @@
|
|
|
27
28
|
font-family: "Fira Code", "Courier New", Courier, monospace;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
.reset :global(*),
|
|
31
|
-
.reset :global(*::before),
|
|
32
|
-
.reset :global(*::after) {
|
|
33
|
-
box-sizing: inherit;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
31
|
/* scrollable */
|
|
37
32
|
.scrollable {
|
|
38
33
|
overflow: scroll;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
<style>
|
|
2
2
|
.template {
|
|
3
|
-
display:
|
|
4
|
-
|
|
5
|
-
font-family: "Fira Code", "Courier New", Courier, monospace;
|
|
6
|
-
gap: 20px;
|
|
3
|
+
display: grid;
|
|
4
|
+
gap: 5px;
|
|
7
5
|
padding-bottom: 10px;
|
|
8
6
|
padding-top: 10px;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
.template:not(.column) {
|
|
10
|
+
grid-auto-rows: 1fr;
|
|
11
|
+
grid-auto-columns: auto;
|
|
12
|
+
grid-auto-flow: row;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.template.columns {
|
|
16
|
+
grid-auto-rows: auto;
|
|
17
|
+
grid-auto-columns: 1fr;
|
|
18
|
+
grid-auto-flow: column;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
.content {
|
|
17
|
-
padding: 3px;
|
|
18
22
|
min-height: 100px;
|
|
19
23
|
border-radius: 5px 5px 5px 5px;
|
|
20
24
|
border: rgb(100, 96, 96) solid 1px;
|
|
@@ -22,13 +26,16 @@
|
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
.misc {
|
|
25
|
-
margin-top: 2px;
|
|
26
29
|
outline: rgb(100, 96, 96) solid 1px;
|
|
27
30
|
border-bottom-left-radius: 5px;
|
|
28
31
|
border-bottom-right-radius: 5px;
|
|
29
32
|
user-select: none;
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
.template > div > div {
|
|
36
|
+
margin: 3px;
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
/* scrollable */
|
|
33
40
|
.scrollable {
|
|
34
41
|
overflow: scroll;
|
|
@@ -55,6 +62,7 @@ const controlsState = getControlsState();
|
|
|
55
62
|
const defaultsStore = getDefaults();
|
|
56
63
|
export let defaults = undefined;
|
|
57
64
|
export let noreset = false;
|
|
65
|
+
export let columns = false;
|
|
58
66
|
function reset() {
|
|
59
67
|
$params = [];
|
|
60
68
|
$defaultsStore = defaults;
|
|
@@ -76,10 +84,10 @@ let key = false;
|
|
|
76
84
|
beforeUpdate(() => (key = !key));
|
|
77
85
|
const resolveArgs = (resolve);
|
|
78
86
|
</script>
|
|
79
|
-
<div class="template">
|
|
87
|
+
<div class="template" class:columns>
|
|
80
88
|
{#each $params as param (param.id)}
|
|
81
89
|
<div
|
|
82
|
-
class="
|
|
90
|
+
class="scrollable"
|
|
83
91
|
on:click|stopPropagation={() => ($current = param.id)}
|
|
84
92
|
on:mouseenter={() => (hovered = param.id)}
|
|
85
93
|
on:mouseleave={() => (hovered = null)}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
<style>
|
|
2
2
|
div {
|
|
3
3
|
width: 100%;
|
|
4
|
+
min-width: 500px;
|
|
5
|
+
overflow: hidden;
|
|
4
6
|
display: grid;
|
|
5
7
|
grid-auto-rows: 30px;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
div :global(*) {
|
|
12
|
+
box-sizing: inherit;
|
|
6
13
|
}
|
|
7
14
|
|
|
8
15
|
div > :global(div) {
|
|
9
16
|
width: 100%;
|
|
10
17
|
display: grid;
|
|
11
18
|
padding: 2px 0px;
|
|
12
|
-
grid-template-columns: 1fr 200px
|
|
19
|
+
grid-template-columns: minmax(250px, 1fr) 200px 40px;
|
|
13
20
|
background-color: hsl(205, 50%, 5%);
|
|
14
21
|
}
|
|
15
22
|
|
|
@@ -17,8 +24,9 @@
|
|
|
17
24
|
background-color: hsl(205, 15%, 15%);
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
div > :global(div:hover)
|
|
21
|
-
|
|
27
|
+
div > :global(div:hover .tooltip),
|
|
28
|
+
div > :global(div:nth-child(n + 2):hover) {
|
|
29
|
+
background-color: hsl(203, 100%, 15%);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
div > :global(div > div) {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
width: 100%;
|
|
19
19
|
height: 100%;
|
|
20
20
|
overflow: hidden;
|
|
21
|
-
outline: rgb(100, 96, 96) solid 1px;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/* need higher specificity than above */
|
|
@@ -29,6 +28,11 @@
|
|
|
29
28
|
overflow: visible;
|
|
30
29
|
user-select: none;
|
|
31
30
|
grid-area: divider;
|
|
31
|
+
outline: rgb(100, 96, 96) solid 1px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.container > .divider.moving {
|
|
35
|
+
outline: rgb(255, 255, 255) solid 1px;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
.container > .divider.vertical {
|
|
@@ -38,20 +42,22 @@
|
|
|
38
42
|
|
|
39
43
|
.container > .divider > .overlay {
|
|
40
44
|
width: 100%;
|
|
41
|
-
height:
|
|
45
|
+
height: 20px;
|
|
42
46
|
cursor: row-resize;
|
|
43
|
-
|
|
47
|
+
transform: translateY(-50%);
|
|
48
|
+
touch-action: none;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
.container > .divider.vertical > .overlay {
|
|
47
|
-
width:
|
|
52
|
+
width: 20px;
|
|
48
53
|
height: 100%;
|
|
49
54
|
cursor: col-resize;
|
|
50
|
-
|
|
55
|
+
transform: translateX(-50%);
|
|
51
56
|
}
|
|
52
57
|
</style>
|
|
53
58
|
|
|
54
|
-
<script>import {
|
|
59
|
+
<script>import { writable } from "svelte/store";
|
|
60
|
+
import { createDraggable } from "./action";
|
|
55
61
|
// orientation of the layout
|
|
56
62
|
export let vertical = false;
|
|
57
63
|
// initial value where the divider is located
|
|
@@ -75,6 +81,7 @@ function update(w, h, limit, value) {
|
|
|
75
81
|
$: update(width, height, padding, $position);
|
|
76
82
|
$: offsetpx = collapse ? "10px" : `${offset}px`;
|
|
77
83
|
$: style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
|
|
84
|
+
const moving = writable(false);
|
|
78
85
|
</script>
|
|
79
86
|
<div
|
|
80
87
|
class="container"
|
|
@@ -90,11 +97,16 @@ $: style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
|
|
|
90
97
|
<slot name="primary" />
|
|
91
98
|
{/if}
|
|
92
99
|
</div>
|
|
93
|
-
<div class="divider" class:vertical>
|
|
100
|
+
<div class="divider" class:vertical class:moving={$moving}>
|
|
94
101
|
<div
|
|
95
102
|
class="overlay"
|
|
96
|
-
use:draggable={{
|
|
97
|
-
|
|
103
|
+
use:draggable={{
|
|
104
|
+
reset: () => offset,
|
|
105
|
+
reversed: !secondary,
|
|
106
|
+
vertical,
|
|
107
|
+
dbltap: () => (collapse = !collapse),
|
|
108
|
+
moving
|
|
109
|
+
}}
|
|
98
110
|
/>
|
|
99
111
|
</div>
|
|
100
112
|
<div style:grid-area="secondary">
|
package/components/etc/action.js
CHANGED
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
import { writable } from "svelte/store";
|
|
1
|
+
import { get, writable } from "svelte/store";
|
|
2
2
|
export const createDraggable = (offset) => {
|
|
3
3
|
const position = writable(offset);
|
|
4
4
|
function draggable(div, parameter) {
|
|
5
|
+
let tm = new Date().getTime();
|
|
5
6
|
let param = parameter ?? { reset: () => 0, vertical: true, reversed: false };
|
|
6
|
-
let moving = false;
|
|
7
7
|
position.set(param.reset());
|
|
8
8
|
let current_page = 0;
|
|
9
|
+
function disengage() {
|
|
10
|
+
param.moving.set(false);
|
|
11
|
+
}
|
|
12
|
+
function checkDoubleTap() {
|
|
13
|
+
const tm2 = new Date().getTime();
|
|
14
|
+
const diff = tm2 - tm;
|
|
15
|
+
tm = tm2;
|
|
16
|
+
return diff < 200;
|
|
17
|
+
}
|
|
9
18
|
function engage(e) {
|
|
10
|
-
|
|
19
|
+
if (checkDoubleTap()) {
|
|
20
|
+
param?.dbltap?.();
|
|
21
|
+
disengage();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
param.moving.set(true);
|
|
11
25
|
position.set(param.reset());
|
|
12
26
|
current_page = param.vertical ? e.pageX : e.pageY;
|
|
13
27
|
}
|
|
14
|
-
function disengage() {
|
|
15
|
-
moving = false;
|
|
16
|
-
}
|
|
17
28
|
function move(e) {
|
|
18
|
-
if (moving) {
|
|
29
|
+
if (get(param.moving)) {
|
|
19
30
|
const page = param.vertical ? e.pageX : e.pageY;
|
|
20
31
|
position.update((v) => v + (page - current_page) * (param.reversed ? -1 : 1));
|
|
21
32
|
current_page = page;
|
|
22
33
|
}
|
|
23
34
|
}
|
|
24
|
-
div.addEventListener("
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
div.addEventListener("pointerdown", engage);
|
|
36
|
+
window.addEventListener("pointerup", disengage);
|
|
37
|
+
window.addEventListener("pointercancel", disengage);
|
|
38
|
+
window.addEventListener("pointermove", move);
|
|
28
39
|
return {
|
|
29
40
|
update: (parameter) => {
|
|
30
|
-
if (param.reversed !== parameter.reversed ||
|
|
31
|
-
param.vertical !== parameter.vertical) {
|
|
32
|
-
moving = false;
|
|
33
|
-
}
|
|
34
41
|
param = parameter;
|
|
35
42
|
},
|
|
36
43
|
destroy: () => {
|
|
37
|
-
div.removeEventListener("
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
div.removeEventListener("pointerdown", engage);
|
|
45
|
+
window.removeEventListener("pointerup", disengage);
|
|
46
|
+
window.removeEventListener("pointercancel", disengage);
|
|
47
|
+
window.removeEventListener("pointermove", move);
|
|
41
48
|
}
|
|
42
49
|
};
|
|
43
50
|
}
|