@nil-/doc 0.2.57 → 0.3.0
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/Base.svelte +1 -0
- package/components/block/Block.svelte +12 -67
- package/components/block/Controls.svelte +1 -6
- package/components/block/Controls.svelte.d.ts +0 -2
- package/components/block/Instance.svelte +72 -51
- package/components/block/context.d.ts +12 -8
- package/components/block/context.js +8 -8
- package/components/block/controls/Controls.svelte +43 -0
- package/components/block/controls/Controls.svelte.d.ts +14 -0
- package/components/block/controls/Styler.svelte +9 -12
- package/components/block/controls/events/Events.svelte +14 -55
- package/components/block/controls/events/Events.svelte.d.ts +6 -6
- package/components/block/controls/props/Button.svelte +4 -3
- package/components/block/controls/props/Button.svelte.d.ts +1 -0
- package/components/block/controls/props/Color.svelte +33 -13
- package/components/block/controls/props/Component.svelte +3 -2
- package/components/block/controls/props/Number.svelte +10 -3
- package/components/block/controls/props/Props.svelte +3 -8
- package/components/block/controls/props/Props.svelte.d.ts +1 -3
- package/components/block/controls/props/Range.svelte +16 -30
- package/components/block/controls/props/Select.svelte +3 -3
- package/components/block/controls/props/Text.svelte +10 -3
- package/components/block/controls/props/Toggle.svelte +3 -5
- package/components/block/controls/props/misc/GroupHeader.svelte +6 -14
- package/components/block/controls/props/misc/Toggle.svelte +85 -0
- package/components/block/controls/props/misc/Toggle.svelte.d.ts +19 -0
- package/components/block/controls/props/misc/utils.d.ts +1 -1
- package/components/block/controls/props/misc/utils.js +7 -28
- package/components/block/icons/ControlView.svelte +1 -6
- package/components/block/icons/Position.svelte +14 -14
- package/components/layout/Container.svelte +10 -8
- package/components/layout/Layout.svelte +18 -7
- package/components/layout/icons/Theme.svelte +6 -24
- package/package.json +11 -29
- package/CHANGELOG.md +0 -376
package/components/Base.svelte
CHANGED
|
@@ -26,6 +26,7 @@ export let fill = false;
|
|
|
26
26
|
|
|
27
27
|
--i-nil-doc-block-bg-color: var(--nil-doc-block-bg-color, hsla(0, 0%, 98%, 0.3));
|
|
28
28
|
--i-nil-doc-block-outline-color: var(--nil-doc-block-outline-color, hsla(0, 0%, 0%, 0.3));
|
|
29
|
+
--i-nil-doc-instance-selected-color: var(--nil-doc-instance-selected-color, hsla(203, 98%, 50%, 0.85));
|
|
29
30
|
|
|
30
31
|
--i-nil-doc-container-p: var(--nil-doc-container-p, hsl(0, 2%, 70%));
|
|
31
32
|
--i-nil-doc-container-s: var(--nil-doc-container-s, hsl(0, 0%, 0%));
|
|
@@ -1,48 +1,15 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
initParams,
|
|
3
|
-
initDefaults,
|
|
4
|
-
initControls,
|
|
5
|
-
initControlsState,
|
|
6
|
-
initOrientation
|
|
7
|
-
} from "./context";
|
|
1
|
+
<script>import { initParams, initDefaults, initControls, initOrientation } from "./context";
|
|
8
2
|
import Base from "../Base.svelte";
|
|
9
3
|
import { getTheme, initTheme } from "../context";
|
|
10
|
-
import Button from "./icons/Button.svelte";
|
|
11
|
-
import Position from "./icons/Position.svelte";
|
|
12
|
-
import ControlView from "./icons/ControlView.svelte";
|
|
13
4
|
initParams();
|
|
14
5
|
initDefaults();
|
|
15
6
|
initControls();
|
|
16
|
-
const state = initControlsState();
|
|
17
7
|
const columns = initOrientation();
|
|
18
8
|
export let theme = void 0;
|
|
19
9
|
const parentTheme = getTheme();
|
|
20
10
|
const dark = initTheme();
|
|
21
11
|
$:
|
|
22
12
|
$dark = theme === void 0 ? $parentTheme : "dark" === theme;
|
|
23
|
-
const cyclePosition = () => {
|
|
24
|
-
switch ($state.position) {
|
|
25
|
-
case "hidden":
|
|
26
|
-
$state.position = "bottom";
|
|
27
|
-
break;
|
|
28
|
-
case "bottom":
|
|
29
|
-
$state.position = "right";
|
|
30
|
-
break;
|
|
31
|
-
case "right":
|
|
32
|
-
$state.position = "hidden";
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const cycleMode = () => {
|
|
37
|
-
switch ($state.mode) {
|
|
38
|
-
case "event":
|
|
39
|
-
$state.mode = "prop";
|
|
40
|
-
break;
|
|
41
|
-
case "prop":
|
|
42
|
-
$state.mode = "event";
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
13
|
</script>
|
|
47
14
|
|
|
48
15
|
<!--
|
|
@@ -50,17 +17,9 @@ const cycleMode = () => {
|
|
|
50
17
|
See [documentation](https://mono-doc.vercel.app/3-Components/2-Block) for more details.
|
|
51
18
|
-->
|
|
52
19
|
|
|
20
|
+
<!-- <svelte:body on:click={unfocus}/> -->
|
|
21
|
+
|
|
53
22
|
<Base dark={$dark}>
|
|
54
|
-
<div class="relative">
|
|
55
|
-
<div class="buttons">
|
|
56
|
-
<Button scale on:click={cycleMode} title={$state.mode}>
|
|
57
|
-
<ControlView mode={$state.mode} />
|
|
58
|
-
</Button>
|
|
59
|
-
<Button scale on:click={cyclePosition} title={$state.position}>
|
|
60
|
-
<Position position={$state.position} />
|
|
61
|
-
</Button>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
23
|
<div class="outer">
|
|
65
24
|
<div class="scrollable block" class:columns={$columns}>
|
|
66
25
|
<slot />
|
|
@@ -69,14 +28,8 @@ const cycleMode = () => {
|
|
|
69
28
|
</Base>
|
|
70
29
|
|
|
71
30
|
<style>
|
|
72
|
-
.block {
|
|
73
|
-
display: grid;
|
|
74
|
-
grid-auto-rows: 1fr;
|
|
75
|
-
grid-auto-columns: auto;
|
|
76
|
-
grid-auto-flow: row;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
31
|
.outer {
|
|
32
|
+
position: relative;
|
|
80
33
|
border-radius: 0.5rem;
|
|
81
34
|
padding: 1.75rem 0.2rem 0.75rem 0.2rem;
|
|
82
35
|
min-width: 10rem;
|
|
@@ -84,9 +37,16 @@ const cycleMode = () => {
|
|
|
84
37
|
outline: solid 1px white;
|
|
85
38
|
}
|
|
86
39
|
|
|
87
|
-
.
|
|
40
|
+
.block {
|
|
88
41
|
width: 100%;
|
|
89
42
|
height: 100%;
|
|
43
|
+
display: grid;
|
|
44
|
+
grid-auto-rows: 1fr;
|
|
45
|
+
grid-auto-columns: auto;
|
|
46
|
+
grid-auto-flow: row;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.scrollable {
|
|
90
50
|
overflow: scroll;
|
|
91
51
|
/* Firefox */
|
|
92
52
|
scrollbar-width: none;
|
|
@@ -98,21 +58,6 @@ const cycleMode = () => {
|
|
|
98
58
|
display: none;
|
|
99
59
|
}
|
|
100
60
|
|
|
101
|
-
.relative {
|
|
102
|
-
z-index: 10;
|
|
103
|
-
position: relative;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.buttons {
|
|
107
|
-
position: absolute;
|
|
108
|
-
width: 3.5rem;
|
|
109
|
-
height: 1.75rem;
|
|
110
|
-
right: 1rem;
|
|
111
|
-
top: 0rem;
|
|
112
|
-
display: flex;
|
|
113
|
-
cursor: pointer;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
61
|
.block.columns {
|
|
117
62
|
grid-auto-rows: auto;
|
|
118
63
|
grid-auto-columns: 1fr;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
<script>import { getControls
|
|
1
|
+
<script>import { getControls } from "./context";
|
|
2
2
|
export let props = [];
|
|
3
3
|
export let events = [];
|
|
4
|
-
export let position = "bottom";
|
|
5
|
-
export let mode = "prop";
|
|
6
4
|
const controls = getControls();
|
|
7
5
|
$:
|
|
8
6
|
$controls = { props, events };
|
|
9
|
-
const state = getControlsState();
|
|
10
|
-
$:
|
|
11
|
-
$state = { position, mode };
|
|
12
7
|
</script>
|
|
13
8
|
|
|
14
9
|
<!--
|
|
@@ -1,22 +1,65 @@
|
|
|
1
|
-
<script>import { beforeUpdate } from "svelte";
|
|
2
|
-
import {
|
|
3
|
-
import Props from "./controls/props/Props.svelte";
|
|
4
|
-
import Events from "./controls/events/Events.svelte";
|
|
1
|
+
<script>import { beforeUpdate, onDestroy } from "svelte";
|
|
2
|
+
import { writable } from "svelte/store";
|
|
5
3
|
import { resolve } from "./utils";
|
|
4
|
+
import { getControls, getControlInfo, getControlValue } from "./context";
|
|
6
5
|
const controls = getControls();
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
expanded = $controlsState.position !== "hidden";
|
|
6
|
+
const cc = getControlInfo();
|
|
7
|
+
const vv = getControlValue();
|
|
10
8
|
export let defaults = void 0;
|
|
11
9
|
export let noreset = false;
|
|
12
10
|
let key = false;
|
|
13
11
|
beforeUpdate(() => key = !key);
|
|
14
12
|
const resolveArgs = resolve;
|
|
15
|
-
|
|
16
|
-
const updateBound = (d) =>
|
|
13
|
+
const values = writable({ props: {}, events: [] });
|
|
14
|
+
const updateBound = (d) => $values.props = resolve(d ?? {}, {});
|
|
17
15
|
$:
|
|
18
16
|
updateBound(defaults);
|
|
19
|
-
|
|
17
|
+
const focus = () => {
|
|
18
|
+
if ($vv !== values) {
|
|
19
|
+
$cc = controls;
|
|
20
|
+
$vv = values;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const unfocus = () => {
|
|
24
|
+
if ($vv === values) {
|
|
25
|
+
$cc = null;
|
|
26
|
+
$vv = null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
onDestroy(unfocus);
|
|
30
|
+
const populate = (ext) => {
|
|
31
|
+
const obj = {};
|
|
32
|
+
const stringify = (detail) => {
|
|
33
|
+
if (detail) {
|
|
34
|
+
if (typeof detail === "string") {
|
|
35
|
+
return detail;
|
|
36
|
+
}
|
|
37
|
+
return JSON.stringify(detail);
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
};
|
|
41
|
+
if (ext != null) {
|
|
42
|
+
for (const name of ext) {
|
|
43
|
+
obj[name] = (ev) => {
|
|
44
|
+
const detail = stringify(ev.detail);
|
|
45
|
+
if ($values.events.length > 0) {
|
|
46
|
+
const last = $values.events[$values.events.length - 1];
|
|
47
|
+
if (last.name === name && last.detail === detail && last.count < 99) {
|
|
48
|
+
last.count += 1;
|
|
49
|
+
$values.events = $values.events;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
$values.events.push({ name, detail, count: 1 });
|
|
54
|
+
if ($values.events.length > 10) {
|
|
55
|
+
$values.events.shift();
|
|
56
|
+
}
|
|
57
|
+
$values.events = $values.events;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
62
|
+
};
|
|
20
63
|
</script>
|
|
21
64
|
|
|
22
65
|
<!--
|
|
@@ -24,41 +67,24 @@ let handlers = {};
|
|
|
24
67
|
See [documentation](https://mono-doc.vercel.app/3-Components/2-Block/1-Content/1-Instance) for more details.
|
|
25
68
|
-->
|
|
26
69
|
|
|
27
|
-
<div class="instance"
|
|
70
|
+
<div class="instance" on:click={focus} on:keypress={null} class:focused={$vv === values}>
|
|
28
71
|
<div class="content">
|
|
29
72
|
{#if noreset}
|
|
30
|
-
<slot
|
|
73
|
+
<slot
|
|
74
|
+
props={resolveArgs(defaults ?? {}, $values.props)}
|
|
75
|
+
events={populate($controls.events)}
|
|
76
|
+
{key}
|
|
77
|
+
/>
|
|
31
78
|
{:else}
|
|
32
79
|
{#key key}
|
|
33
|
-
<slot
|
|
80
|
+
<slot
|
|
81
|
+
props={resolveArgs(defaults ?? {}, $values.props)}
|
|
82
|
+
events={populate($controls.events)}
|
|
83
|
+
{key}
|
|
84
|
+
/>
|
|
34
85
|
{/key}
|
|
35
86
|
{/if}
|
|
36
87
|
</div>
|
|
37
|
-
{#if expanded}
|
|
38
|
-
<div class="misc">
|
|
39
|
-
<Props
|
|
40
|
-
infos={$controls.props}
|
|
41
|
-
bind:values={bound}
|
|
42
|
-
visible={$controlsState.mode === "prop"}
|
|
43
|
-
>
|
|
44
|
-
<div>
|
|
45
|
-
<div>Name</div>
|
|
46
|
-
<div>Value</div>
|
|
47
|
-
<div>Use</div>
|
|
48
|
-
</div>
|
|
49
|
-
</Props>
|
|
50
|
-
<Events
|
|
51
|
-
events={$controls.events}
|
|
52
|
-
bind:handlers
|
|
53
|
-
visible={$controlsState.mode === "event"}
|
|
54
|
-
>
|
|
55
|
-
<div>
|
|
56
|
-
<div>Events</div>
|
|
57
|
-
<div>Detail</div>
|
|
58
|
-
</div>
|
|
59
|
-
</Events>
|
|
60
|
-
</div>
|
|
61
|
-
{/if}
|
|
62
88
|
</div>
|
|
63
89
|
|
|
64
90
|
<style>
|
|
@@ -67,21 +93,8 @@ let handlers = {};
|
|
|
67
93
|
height: 100%;
|
|
68
94
|
}
|
|
69
95
|
|
|
70
|
-
.cside {
|
|
71
|
-
display: grid;
|
|
72
|
-
grid-template-columns: 1fr 35rem;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
96
|
.content {
|
|
76
97
|
min-height: 6.25rem;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.misc {
|
|
80
|
-
user-select: none;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.content,
|
|
84
|
-
.misc {
|
|
85
98
|
border: 1px solid var(--i-nil-doc-block-outline-color);
|
|
86
99
|
}
|
|
87
100
|
|
|
@@ -90,5 +103,13 @@ let handlers = {};
|
|
|
90
103
|
transition: background-color var(--i-nil-doc-transition-time);
|
|
91
104
|
color: var(--i-nil-doc-color);
|
|
92
105
|
background-color: var(--i-nil-doc-bg-color);
|
|
106
|
+
border-width: 2px;
|
|
107
|
+
border-style: solid;
|
|
108
|
+
border-color: transparent;
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.instance.focused {
|
|
113
|
+
border-color: var(--i-nil-doc-instance-selected-color);
|
|
93
114
|
}
|
|
94
115
|
</style>
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import type { Writable } from "svelte/store";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Prop, SpecialProp, Event } from "./controls/types";
|
|
3
3
|
import type { ValueType } from "./types";
|
|
4
4
|
export type Params = {
|
|
5
5
|
id: number;
|
|
6
6
|
tag: string;
|
|
7
7
|
values: Record<string, ValueType>;
|
|
8
8
|
};
|
|
9
|
-
export type ControlState = {
|
|
10
|
-
position: "bottom" | "right" | "hidden";
|
|
11
|
-
mode: "prop" | "event";
|
|
12
|
-
};
|
|
13
9
|
export declare const initParams: () => Writable<Params[]>, getParams: () => Writable<Params[]>;
|
|
14
|
-
type Controls = {
|
|
10
|
+
export type Controls = {
|
|
15
11
|
props: (Prop | SpecialProp)[];
|
|
16
12
|
events: Event[];
|
|
17
13
|
};
|
|
14
|
+
export type ControlValue = {
|
|
15
|
+
props: Record<string, any>;
|
|
16
|
+
events: {
|
|
17
|
+
name: string;
|
|
18
|
+
detail: string;
|
|
19
|
+
count: number;
|
|
20
|
+
}[];
|
|
21
|
+
};
|
|
18
22
|
export declare const initControls: () => Writable<Controls>, getControls: () => Writable<Controls>;
|
|
19
23
|
export declare const initDefaults: () => Writable<Record<string, ValueType>>, getDefaults: () => Writable<Record<string, ValueType>>;
|
|
20
|
-
export declare const initControlsState: () => Writable<ControlState>, getControlsState: () => Writable<ControlState>;
|
|
21
24
|
export declare const initOrientation: () => Writable<boolean>, getOrientation: () => Writable<boolean>;
|
|
22
|
-
export
|
|
25
|
+
export declare const initControlInfo: () => Writable<Writable<Controls> | null>, getControlInfo: () => Writable<Writable<Controls> | null>;
|
|
26
|
+
export declare const initControlValue: () => Writable<Writable<ControlValue> | null>, getControlValue: () => Writable<Writable<ControlValue> | null>;
|
|
@@ -8,13 +8,13 @@ const create = (defaulter) => {
|
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
export const { init: initParams, get: getParams } = create(() => []);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}));
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
export const { init: initControls, get: getControls } = create(() => ({ props: [], events: [] }));
|
|
13
|
+
// prettier-ignore
|
|
15
14
|
export const { init: initDefaults, get: getDefaults } = create(() => ({}));
|
|
16
|
-
|
|
17
|
-
position: "hidden",
|
|
18
|
-
mode: "prop"
|
|
19
|
-
}));
|
|
15
|
+
// prettier-ignore
|
|
20
16
|
export const { init: initOrientation, get: getOrientation } = create(() => false);
|
|
17
|
+
// prettier-ignore
|
|
18
|
+
export const { init: initControlInfo, get: getControlInfo } = create(() => writable());
|
|
19
|
+
// prettier-ignore
|
|
20
|
+
export const { init: initControlValue, get: getControlValue } = create(() => writable());
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>import Styler from "./Styler.svelte";
|
|
2
|
+
import Props from "./props/Props.svelte";
|
|
3
|
+
import Events from "./events/Events.svelte";
|
|
4
|
+
import { getControlInfo, getControlValue } from "../context";
|
|
5
|
+
const controls = getControlInfo();
|
|
6
|
+
const values = getControlValue();
|
|
7
|
+
$:
|
|
8
|
+
cc = $controls;
|
|
9
|
+
$:
|
|
10
|
+
vv = $values;
|
|
11
|
+
let style = "props";
|
|
12
|
+
const cycle = () => {
|
|
13
|
+
if (style === "props") {
|
|
14
|
+
style = "events";
|
|
15
|
+
} else {
|
|
16
|
+
style = "props";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Styler type={style}>
|
|
22
|
+
{#if style === "props"}
|
|
23
|
+
<div on:dblclick={cycle} on:keypress={null}>
|
|
24
|
+
<div>Name</div>
|
|
25
|
+
<div>Value</div>
|
|
26
|
+
<div>Use</div>
|
|
27
|
+
</div>
|
|
28
|
+
{:else if style === "events"}
|
|
29
|
+
<div on:dblclick={cycle} on:keypress={null}>
|
|
30
|
+
<div>Events</div>
|
|
31
|
+
<div>Detail</div>
|
|
32
|
+
</div>
|
|
33
|
+
{/if}
|
|
34
|
+
{#key $values && $controls}
|
|
35
|
+
{#if cc != null && $cc != null && vv != null && $vv != null}
|
|
36
|
+
<Props infos={$cc.props} visible={style === "props"} bind:values={$vv.props} />
|
|
37
|
+
<Events events={$vv.events} visible={style === "events"} />
|
|
38
|
+
{/if}
|
|
39
|
+
{/key}
|
|
40
|
+
</Styler>
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type ControlsProps = typeof __propDef.props;
|
|
10
|
+
export type ControlsEvents = typeof __propDef.events;
|
|
11
|
+
export type ControlsSlots = typeof __propDef.slots;
|
|
12
|
+
export default class Controls extends SvelteComponentTyped<ControlsProps, ControlsEvents, ControlsSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -9,19 +9,10 @@
|
|
|
9
9
|
div {
|
|
10
10
|
display: grid;
|
|
11
11
|
min-width: 31.25rem;
|
|
12
|
+
height: 100%;
|
|
12
13
|
grid-auto-rows: 2rem;
|
|
13
14
|
box-sizing: border-box;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
div.events {
|
|
17
|
-
height: 22rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
div :global(*),
|
|
21
|
-
div :global(*::before),
|
|
22
|
-
div :global(*::after) {
|
|
23
|
-
box-sizing: inherit;
|
|
24
|
-
font-family: inherit;
|
|
15
|
+
user-select: none;
|
|
25
16
|
}
|
|
26
17
|
|
|
27
18
|
div > :global(div) {
|
|
@@ -51,9 +42,15 @@
|
|
|
51
42
|
margin: auto;
|
|
52
43
|
}
|
|
53
44
|
|
|
54
|
-
div > :global(div > div
|
|
45
|
+
div > :global(div > div > .control) {
|
|
55
46
|
width: 100%;
|
|
56
47
|
height: 80%;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
div > :global(div > div > .control[disabled]) {
|
|
52
|
+
cursor: not-allowed;
|
|
53
|
+
filter: opacity(0.5);
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
/* colors */
|
|
@@ -1,62 +1,21 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let
|
|
3
|
-
export let events;
|
|
4
|
-
export let handlers;
|
|
5
|
-
let history = [];
|
|
6
|
-
const stringify = (detail) => {
|
|
7
|
-
if (detail) {
|
|
8
|
-
if (typeof detail === "string") {
|
|
9
|
-
return detail;
|
|
10
|
-
}
|
|
11
|
-
return JSON.stringify(detail);
|
|
12
|
-
}
|
|
13
|
-
return "";
|
|
14
|
-
};
|
|
15
|
-
const wrap = (ext) => {
|
|
16
|
-
const obj = {};
|
|
17
|
-
if (ext != null) {
|
|
18
|
-
for (const name of ext) {
|
|
19
|
-
obj[name] = (ev) => {
|
|
20
|
-
const detail = stringify(ev.detail);
|
|
21
|
-
if (history.length > 0) {
|
|
22
|
-
const last = history[history.length - 1];
|
|
23
|
-
if (last.name === name && last.detail === detail && last.count < 99) {
|
|
24
|
-
last.count += 1;
|
|
25
|
-
history = history;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
history.push({ name, detail, count: 1 });
|
|
30
|
-
if (history.length > 10) {
|
|
31
|
-
history.shift();
|
|
32
|
-
}
|
|
33
|
-
history = history;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
};
|
|
39
|
-
$:
|
|
40
|
-
handlers = wrap(events);
|
|
1
|
+
<script>export let visible;
|
|
2
|
+
export let events = [];
|
|
41
3
|
</script>
|
|
42
4
|
|
|
43
5
|
{#if visible}
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<div>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
{/if}
|
|
55
|
-
</div>
|
|
56
|
-
<div>{detail}</div>
|
|
6
|
+
{#each events as { count, detail, name }, i (i)}
|
|
7
|
+
<div>
|
|
8
|
+
<div class="name">
|
|
9
|
+
<div>{name}</div>
|
|
10
|
+
{#if count > 1}
|
|
11
|
+
<div class="count">
|
|
12
|
+
[{count.toString().padStart(2, "0")}]
|
|
13
|
+
</div>
|
|
14
|
+
{/if}
|
|
57
15
|
</div>
|
|
58
|
-
|
|
59
|
-
|
|
16
|
+
<div>{detail}</div>
|
|
17
|
+
</div>
|
|
18
|
+
{/each}
|
|
60
19
|
{/if}
|
|
61
20
|
|
|
62
21
|
<style>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Event } from "../types";
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
visible: boolean;
|
|
6
|
-
events
|
|
7
|
-
|
|
5
|
+
events?: {
|
|
6
|
+
name: string;
|
|
7
|
+
detail: string;
|
|
8
|
+
count: number;
|
|
9
|
+
}[] | undefined;
|
|
8
10
|
};
|
|
9
11
|
events: {
|
|
10
12
|
[evt: string]: CustomEvent<any>;
|
|
11
13
|
};
|
|
12
|
-
slots: {
|
|
13
|
-
default: {};
|
|
14
|
-
};
|
|
14
|
+
slots: {};
|
|
15
15
|
};
|
|
16
16
|
export type EventsProps = typeof __propDef.props;
|
|
17
17
|
export type EventsEvents = typeof __propDef.events;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script>import { getClick, getName } from "./misc/utils";
|
|
2
2
|
export let info;
|
|
3
|
+
export let visible = false;
|
|
3
4
|
$:
|
|
4
5
|
click = getClick(info)();
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
<button on:click={click}>{getName(info)}</button>
|
|
9
|
-
|
|
8
|
+
{#if visible}
|
|
9
|
+
<div><button on:click={click}>{getName(info)}</button></div>
|
|
10
|
+
{/if}
|
|
10
11
|
|
|
11
12
|
<style>
|
|
12
13
|
button {
|