@nil-/doc 0.2.32 → 0.2.34
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/block/Block.svelte +1 -8
- package/components/block/Controls.svelte +5 -2
- package/components/block/Controls.svelte.d.ts +2 -1
- package/components/block/Template.svelte +18 -18
- package/components/block/context.d.ts +2 -2
- package/components/block/context.js +2 -2
- package/components/block/utils.js +3 -1
- package/components/etc/action.js +4 -4
- package/components/navigation/Nav.svelte +1 -1
- package/components/navigation/Node.svelte +6 -6
- package/components/navigation/Node.svelte.d.ts +1 -1
- package/components/navigation/Tree.svelte +2 -2
- package/components/navigation/Tree.svelte.d.ts +1 -1
- package/package.json +1 -1
- package/sveltekit/index.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @nil-/doc
|
|
2
2
|
|
|
3
|
+
## 0.2.34
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [doc][new] added Control hide property ([#51](https://github.com/njaldea/mono/pull/51))
|
|
8
|
+
[doc][break] renamed Control expand property to hide
|
|
9
|
+
[doc][break] Control now defaults to show
|
|
10
|
+
|
|
11
|
+
## 0.2.33
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [doc] update formatting (camel case use) ([#49](https://github.com/njaldea/mono/pull/49))
|
|
16
|
+
|
|
3
17
|
## 0.2.32
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -27,16 +27,9 @@
|
|
|
27
27
|
}
|
|
28
28
|
</style>
|
|
29
29
|
|
|
30
|
-
<script>import {
|
|
31
|
-
initParams,
|
|
32
|
-
initCurrent,
|
|
33
|
-
initDefaults,
|
|
34
|
-
initControls,
|
|
35
|
-
initControlsState
|
|
36
|
-
} from "./context";
|
|
30
|
+
<script>import { initParams, initDefaults, initControls, initControlsState } from "./context";
|
|
37
31
|
import { inRoot, getTheme, initTheme, evalTheme } from "../context";
|
|
38
32
|
initParams();
|
|
39
|
-
initCurrent();
|
|
40
33
|
initDefaults();
|
|
41
34
|
initControls();
|
|
42
35
|
initControlsState();
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
<script>import { getControls, getControlsState } from "./context";
|
|
3
3
|
export let props = [];
|
|
4
|
-
export let
|
|
4
|
+
export let hide = false;
|
|
5
|
+
export let side = false;
|
|
5
6
|
const controls = getControls();
|
|
6
7
|
$controls = props;
|
|
7
8
|
const state = getControlsState();
|
|
8
9
|
$:
|
|
9
|
-
$state.
|
|
10
|
+
$state.hide = hide;
|
|
11
|
+
$:
|
|
12
|
+
$state.side = side;
|
|
10
13
|
</script>
|
|
@@ -3,7 +3,8 @@ import type { Control } from "./controls/types";
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
props?: Control[] | undefined;
|
|
6
|
-
|
|
6
|
+
hide?: boolean | undefined;
|
|
7
|
+
side?: boolean | undefined;
|
|
7
8
|
};
|
|
8
9
|
events: {
|
|
9
10
|
[evt: string]: CustomEvent<any>;
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
gap: 5px;
|
|
5
5
|
padding-bottom: 10px;
|
|
6
6
|
padding-top: 10px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.template:not(.column) {
|
|
10
7
|
grid-auto-rows: 1fr;
|
|
11
8
|
grid-auto-columns: auto;
|
|
12
9
|
grid-auto-flow: row;
|
|
@@ -18,17 +15,28 @@
|
|
|
18
15
|
grid-auto-flow: column;
|
|
19
16
|
}
|
|
20
17
|
|
|
18
|
+
.template > .cside {
|
|
19
|
+
display: grid;
|
|
20
|
+
grid-template-columns: 1fr 550px;
|
|
21
|
+
}
|
|
22
|
+
|
|
21
23
|
.content {
|
|
22
24
|
min-height: 100px;
|
|
23
25
|
border-radius: 5px 5px 5px 5px;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
.misc {
|
|
28
|
+
div:not(.cside) > .misc {
|
|
27
29
|
border-bottom-left-radius: 5px;
|
|
28
30
|
border-bottom-right-radius: 5px;
|
|
29
31
|
user-select: none;
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
.cside > .misc {
|
|
35
|
+
border-top-right-radius: 5px;
|
|
36
|
+
border-bottom-right-radius: 5px;
|
|
37
|
+
user-select: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
.template > div > div {
|
|
33
41
|
margin: 3px;
|
|
34
42
|
}
|
|
@@ -63,17 +71,14 @@
|
|
|
63
71
|
outline: hsl(0, 2%, 40%) solid 1px;
|
|
64
72
|
}
|
|
65
73
|
</style>
|
|
66
|
-
<svelte:window on:click={() => ($current = null)} />
|
|
67
74
|
|
|
68
|
-
<script>import { getParams,
|
|
75
|
+
<script>import { getParams, getDefaults } from "./context";
|
|
69
76
|
import { getControls, getControlsState } from "./context";
|
|
70
77
|
import { resolve } from "./utils";
|
|
71
78
|
import { getTheme } from "../context";
|
|
72
79
|
import Controls from "./controls/Controls.svelte";
|
|
73
80
|
import { beforeUpdate } from "svelte";
|
|
74
|
-
import { slide } from "svelte/transition";
|
|
75
81
|
const params = getParams();
|
|
76
|
-
const current = getCurrent();
|
|
77
82
|
const controls = getControls();
|
|
78
83
|
const controlsState = getControlsState();
|
|
79
84
|
const defaultsStore = getDefaults();
|
|
@@ -87,20 +92,15 @@ const reset = () => {
|
|
|
87
92
|
};
|
|
88
93
|
$:
|
|
89
94
|
$defaultsStore, reset();
|
|
90
|
-
let hovered = null;
|
|
91
95
|
let key = false;
|
|
92
96
|
beforeUpdate(() => key = !key);
|
|
93
97
|
const resolveArgs = resolve;
|
|
98
|
+
$:
|
|
99
|
+
expanded = $controls.length > 0 && !$controlsState.hide;
|
|
94
100
|
</script>
|
|
95
101
|
<div class="template" class:columns>
|
|
96
102
|
{#each $params as param (param.id)}
|
|
97
|
-
<div
|
|
98
|
-
class="scrollable"
|
|
99
|
-
on:click|stopPropagation={() => ($current = param.id)}
|
|
100
|
-
on:mouseenter={() => (hovered = param.id)}
|
|
101
|
-
on:mouseleave={() => (hovered = null)}
|
|
102
|
-
on:keypress={null}
|
|
103
|
-
>
|
|
103
|
+
<div class="scrollable" class:cside={$controlsState.side && expanded}>
|
|
104
104
|
{#if noreset}
|
|
105
105
|
<div class="content scrollable" class:dark={$isDark}>
|
|
106
106
|
<slot
|
|
@@ -122,8 +122,8 @@ const resolveArgs = resolve;
|
|
|
122
122
|
</div>
|
|
123
123
|
{/key}
|
|
124
124
|
{/if}
|
|
125
|
-
{#if
|
|
126
|
-
<div class="misc scrollable" class:dark={$isDark}
|
|
125
|
+
{#if expanded}
|
|
126
|
+
<div class="misc scrollable" class:dark={$isDark}>
|
|
127
127
|
<Controls infos={$controls} bind:values={param.values} />
|
|
128
128
|
</div>
|
|
129
129
|
{/if}
|
|
@@ -10,9 +10,9 @@ export type Params = {
|
|
|
10
10
|
defaults: Record<string, ValueType>;
|
|
11
11
|
};
|
|
12
12
|
export type ControlState = {
|
|
13
|
-
|
|
13
|
+
hide: boolean;
|
|
14
|
+
side: boolean;
|
|
14
15
|
};
|
|
15
|
-
export declare const initCurrent: () => Writable<number | null>, getCurrent: () => Writable<number | null>;
|
|
16
16
|
export declare const initParams: () => Writable<Params[]>, getParams: () => Writable<Params[]>;
|
|
17
17
|
export declare const initControls: () => Writable<Control[]>, getControls: () => Writable<Control[]>;
|
|
18
18
|
export declare const initDefaults: () => Writable<Record<string, ValueType> | null>, getDefaults: () => Writable<Record<string, ValueType> | null>;
|
|
@@ -7,10 +7,10 @@ const create = (defaulter) => {
|
|
|
7
7
|
get: () => getContext(symbol)
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export const { init: initCurrent, get: getCurrent } = create(() => null);
|
|
11
10
|
export const { init: initParams, get: getParams } = create(() => []);
|
|
12
11
|
export const { init: initControls, get: getControls } = create(() => []);
|
|
13
12
|
export const { init: initDefaults, get: getDefaults } = create(() => null);
|
|
14
13
|
export const { init: initControlsState, get: getControlsState } = create(() => ({
|
|
15
|
-
|
|
14
|
+
hide: false,
|
|
15
|
+
side: false
|
|
16
16
|
}));
|
package/components/etc/action.js
CHANGED
|
@@ -5,7 +5,7 @@ export const createDraggable = (offset) => {
|
|
|
5
5
|
let tm = new Date().getTime();
|
|
6
6
|
let param = parameter ?? { reset: () => 0, vertical: true, reversed: false };
|
|
7
7
|
position.set(param.reset());
|
|
8
|
-
let
|
|
8
|
+
let refPage = 0;
|
|
9
9
|
const disengage = () => param.moving.set(false);
|
|
10
10
|
const checkDoubleTap = () => {
|
|
11
11
|
const tm2 = new Date().getTime();
|
|
@@ -21,14 +21,14 @@ export const createDraggable = (offset) => {
|
|
|
21
21
|
}
|
|
22
22
|
param.moving.set(true);
|
|
23
23
|
position.set(param.reset());
|
|
24
|
-
|
|
24
|
+
refPage = param.vertical ? e.pageX : e.pageY;
|
|
25
25
|
param?.tap?.();
|
|
26
26
|
};
|
|
27
27
|
const move = (e) => {
|
|
28
28
|
if (get(param.moving)) {
|
|
29
29
|
const page = param.vertical ? e.pageX : e.pageY;
|
|
30
|
-
position.update((v) => v + (page -
|
|
31
|
-
|
|
30
|
+
position.update((v) => v + (page - refPage) * (param.reversed ? -1 : 1));
|
|
31
|
+
refPage = page;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
div.addEventListener("pointerdown", engage);
|
|
@@ -49,7 +49,7 @@ export let key;
|
|
|
49
49
|
export let value;
|
|
50
50
|
export let depth;
|
|
51
51
|
export let selected;
|
|
52
|
-
export let
|
|
52
|
+
export let expand;
|
|
53
53
|
export let states;
|
|
54
54
|
export let sorter;
|
|
55
55
|
export let renamer;
|
|
@@ -57,11 +57,11 @@ const dispatch = createEventDispatcher();
|
|
|
57
57
|
$:
|
|
58
58
|
style = `padding-left: ${10 + depth * 10}px;`;
|
|
59
59
|
$:
|
|
60
|
-
|
|
60
|
+
hasChildren = Object.keys(value.sub).length > 0;
|
|
61
61
|
const click = (link) => {
|
|
62
62
|
if (link != null && selected !== link) {
|
|
63
63
|
dispatch("navigate", link);
|
|
64
|
-
} else if (
|
|
64
|
+
} else if (hasChildren) {
|
|
65
65
|
states.expanded = !states.expanded;
|
|
66
66
|
}
|
|
67
67
|
};
|
|
@@ -74,12 +74,12 @@ const click = (link) => {
|
|
|
74
74
|
{style}
|
|
75
75
|
class:selected={selected === value.url}
|
|
76
76
|
>
|
|
77
|
-
<div class="icon" class:expanded={
|
|
77
|
+
<div class="icon" class:expanded={hasChildren && states.expanded}>
|
|
78
78
|
<div>{Object.keys(value.sub).length > 0 ? ">" : "-"}</div>
|
|
79
79
|
</div>
|
|
80
80
|
<span>{renamer(key)}</span>
|
|
81
81
|
</div>
|
|
82
|
-
{#if
|
|
82
|
+
{#if expand || states.expanded}
|
|
83
83
|
<div class="sub" transition:slide|local>
|
|
84
84
|
{#each sort(value.sub, sorter) as [k, v] (k)}
|
|
85
85
|
<svelte:self
|
|
@@ -89,7 +89,7 @@ const click = (link) => {
|
|
|
89
89
|
{selected}
|
|
90
90
|
{renamer}
|
|
91
91
|
{sorter}
|
|
92
|
-
{
|
|
92
|
+
{expand}
|
|
93
93
|
bind:states={states.sub[k]}
|
|
94
94
|
on:navigate
|
|
95
95
|
/>
|
|
@@ -5,7 +5,7 @@ export let tree;
|
|
|
5
5
|
export let states;
|
|
6
6
|
export let sorter;
|
|
7
7
|
export let renamer;
|
|
8
|
-
export let
|
|
8
|
+
export let expand;
|
|
9
9
|
export let selected;
|
|
10
10
|
</script>
|
|
11
11
|
{#each sort(tree, sorter) as [key, value] (key)}
|
|
@@ -16,7 +16,7 @@ export let selected;
|
|
|
16
16
|
{selected}
|
|
17
17
|
{sorter}
|
|
18
18
|
{renamer}
|
|
19
|
-
{
|
|
19
|
+
{expand}
|
|
20
20
|
bind:states={states[key]}
|
|
21
21
|
on:navigate
|
|
22
22
|
/>
|
package/package.json
CHANGED
package/sveltekit/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { derived } from "svelte/store";
|
|
|
2
2
|
import { page } from "$app/stores";
|
|
3
3
|
import { goto } from "$app/navigation";
|
|
4
4
|
const toRoute = (p) => p.substring(1, p.lastIndexOf("/"));
|
|
5
|
-
const
|
|
5
|
+
const routeHasLayoutGroup = /\(.*\)/;
|
|
6
6
|
const collapseLayout = (p) => p
|
|
7
7
|
.split("/")
|
|
8
|
-
.filter((p) => null ==
|
|
8
|
+
.filter((p) => null == routeHasLayoutGroup.exec(p))
|
|
9
9
|
.join("/");
|
|
10
10
|
const isNotRoot = (p) => p !== "/";
|
|
11
|
-
const
|
|
12
|
-
const isRouteDynamic = (p) => null ==
|
|
11
|
+
const routeIsDynamic = /.*\[.*\].*/;
|
|
12
|
+
const isRouteDynamic = (p) => null == routeIsDynamic.exec(p);
|
|
13
13
|
/**
|
|
14
14
|
* Dedicated helper method to be used for sveltekit
|
|
15
15
|
* @param detail - vite's `import.meta.glob(..., { eager: true })`
|