@nil-/doc 0.2.53 → 0.2.55
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 +26 -25
- package/components/Base.svelte +1 -3
- package/components/block/Controls.svelte.d.ts +3 -3
- package/components/block/Instance.svelte +1 -1
- package/components/block/context.d.ts +2 -2
- package/components/block/controls/Styler.svelte +5 -1
- package/components/block/controls/props/Button.svelte +17 -0
- package/components/block/controls/props/Button.svelte.d.ts +17 -0
- package/components/block/controls/props/Color.svelte +11 -9
- package/components/block/controls/props/Component.svelte +9 -5
- package/components/block/controls/props/Component.svelte.d.ts +2 -2
- package/components/block/controls/props/Number.svelte +2 -1
- package/components/block/controls/props/Props.svelte.d.ts +2 -2
- package/components/block/controls/props/Range.svelte +11 -4
- package/components/block/controls/props/Select.svelte +2 -1
- package/components/block/controls/props/Text.svelte +2 -1
- package/components/block/controls/props/{Switch.svelte → Toggle.svelte} +5 -2
- package/components/block/controls/props/{Switch.svelte.d.ts → Toggle.svelte.d.ts} +5 -5
- package/components/block/controls/props/misc/GroupHeader.svelte +8 -1
- package/components/block/controls/props/misc/defaulter.d.ts +1 -1
- package/components/block/controls/props/misc/defaulter.js +0 -1
- package/components/block/controls/props/misc/utils.d.ts +4 -3
- package/components/block/controls/props/misc/utils.js +6 -0
- package/components/block/controls/types.d.ts +23 -7
- package/components/block/icons/Position.svelte.d.ts +1 -1
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
# @nil-/doc
|
|
2
2
|
|
|
3
|
+
## 0.2.55
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [all][fix] separate eslint configuration ([#96](https://github.com/njaldea/mono/pull/96))
|
|
8
|
+
|
|
9
|
+
- [doc][docu] fix switch -> toggle ([#96](https://github.com/njaldea/mono/pull/96))
|
|
10
|
+
|
|
11
|
+
- [all][patch] update deps ([#96](https://github.com/njaldea/mono/pull/96))
|
|
12
|
+
|
|
13
|
+
- [doc][new] added special prop control "button" ([#96](https://github.com/njaldea/mono/pull/96))
|
|
14
|
+
|
|
15
|
+
## 0.2.54
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [doc][fix] dynamic import of vanilla-picker to avoid ssr document access ([#94](https://github.com/njaldea/mono/pull/94))
|
|
20
|
+
- [doc][patch] temporarily used svelte-toggle for checkbox/toggle ([#94](https://github.com/njaldea/mono/pull/94))
|
|
21
|
+
|
|
3
22
|
## 0.2.53
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
6
25
|
|
|
7
26
|
- [doc][break] removed "scale" prop ([#92](https://github.com/njaldea/mono/pull/92))
|
|
8
|
-
|
|
9
|
-
|
|
27
|
+
- [doc][fix] better block scrollable handling ([#92](https://github.com/njaldea/mono/pull/92))
|
|
28
|
+
- [doc][fix] better style to vanilla-color popup ([#92](https://github.com/njaldea/mono/pull/92))
|
|
10
29
|
|
|
11
30
|
## 0.2.52
|
|
12
31
|
|
|
13
32
|
### Patch Changes
|
|
14
33
|
|
|
15
34
|
- [doc][fix] fix layout scrollable sections ([#90](https://github.com/njaldea/mono/pull/90))
|
|
16
|
-
|
|
17
35
|
- [doc][patch] restructure code ([#90](https://github.com/njaldea/mono/pull/90))
|
|
18
|
-
|
|
19
36
|
- [doc][patch] use vannilla-color library for color picker ([#90](https://github.com/njaldea/mono/pull/90))
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
- [doc][fix] removed position relative and overflow scroll for misc (controls) ([#90](https://github.com/njaldea/mono/pull/90))
|
|
22
38
|
- [doc][fix] content fill width/height ([#90](https://github.com/njaldea/mono/pull/90))
|
|
23
|
-
|
|
24
39
|
- [doc][new] added offset Layout.svelte and sveltekit for keeping state ([#90](https://github.com/njaldea/mono/pull/90))
|
|
25
40
|
|
|
26
41
|
## 0.2.51
|
|
@@ -28,21 +43,18 @@
|
|
|
28
43
|
### Patch Changes
|
|
29
44
|
|
|
30
45
|
- [doc][fix] components now rely on root font-size ([#88](https://github.com/njaldea/mono/pull/88))
|
|
31
|
-
|
|
32
46
|
- [doc][fix] fix object prop control ([#88](https://github.com/njaldea/mono/pull/88))
|
|
33
|
-
|
|
34
47
|
- [doc][new] block button controls ([#88](https://github.com/njaldea/mono/pull/88))
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
- [doc][new] centralized custom css ([#88](https://github.com/njaldea/mono/pull/88))
|
|
37
49
|
- [doc][misc] change styling ([#88](https://github.com/njaldea/mono/pull/88))
|
|
38
|
-
|
|
50
|
+
- [doc][fix] scrolling content of container ([#88](https://github.com/njaldea/mono/pull/88))
|
|
39
51
|
|
|
40
52
|
## 0.2.50
|
|
41
53
|
|
|
42
54
|
### Patch Changes
|
|
43
55
|
|
|
44
56
|
- [doc][new] removed default nil icon ([#86](https://github.com/njaldea/mono/pull/86))
|
|
45
|
-
|
|
57
|
+
- [doc][new] allow override of theme icon ([#86](https://github.com/njaldea/mono/pull/86))
|
|
46
58
|
|
|
47
59
|
## 0.2.49
|
|
48
60
|
|
|
@@ -61,7 +73,6 @@
|
|
|
61
73
|
### Patch Changes
|
|
62
74
|
|
|
63
75
|
- [doc][docu] minor adjustments to documentation ([#79](https://github.com/njaldea/mono/pull/79))
|
|
64
|
-
|
|
65
76
|
- [doc][new] added support for flattened prop schema ([#79](https://github.com/njaldea/mono/pull/79))
|
|
66
77
|
|
|
67
78
|
## 0.2.46
|
|
@@ -87,7 +98,6 @@
|
|
|
87
98
|
### Patch Changes
|
|
88
99
|
|
|
89
100
|
- [doc][fix] disable Range.svelte tooltip when disabled ([#70](https://github.com/njaldea/mono/pull/70))
|
|
90
|
-
|
|
91
101
|
- [doc][new] added auto scroll when content of layout is only one component ([#70](https://github.com/njaldea/mono/pull/70))
|
|
92
102
|
|
|
93
103
|
## 0.2.42
|
|
@@ -107,13 +117,9 @@
|
|
|
107
117
|
### Patch Changes
|
|
108
118
|
|
|
109
119
|
- [doc][new] added scale flag prop for Instance/Template componen ([#63](https://github.com/njaldea/mono/pull/63))
|
|
110
|
-
|
|
111
120
|
- [doc][patch] fixed jsdoc link for public components ([#63](https://github.com/njaldea/mono/pull/63))
|
|
112
|
-
|
|
113
121
|
- [doc][docu] moved Sorting and Renaming section to their own pages ([#63](https://github.com/njaldea/mono/pull/63))
|
|
114
|
-
|
|
115
122
|
- [doc][new] added placeholder to search bar ([#63](https://github.com/njaldea/mono/pull/63))
|
|
116
|
-
|
|
117
123
|
- [doc][docu] added admonitions plugin ([#63](https://github.com/njaldea/mono/pull/63))
|
|
118
124
|
|
|
119
125
|
## 0.2.39
|
|
@@ -121,13 +127,9 @@
|
|
|
121
127
|
### Patch Changes
|
|
122
128
|
|
|
123
129
|
- [doc][fix] force state of navigation expand icon when filtering ([#61](https://github.com/njaldea/mono/pull/61))
|
|
124
|
-
|
|
125
130
|
- [doc][patch] tighter eslint ([#61](https://github.com/njaldea/mono/pull/61))
|
|
126
|
-
|
|
127
131
|
- [doc][patch] added tests for non-UI related code ([#61](https://github.com/njaldea/mono/pull/61))
|
|
128
|
-
|
|
129
132
|
- [doc][patch] moved type definition ([#61](https://github.com/njaldea/mono/pull/61))
|
|
130
|
-
|
|
131
133
|
- [doc][patch] enabled typescript eslint rules ([#61](https://github.com/njaldea/mono/pull/61))
|
|
132
134
|
|
|
133
135
|
## 0.2.38
|
|
@@ -191,7 +193,6 @@
|
|
|
191
193
|
### Patch Changes
|
|
192
194
|
|
|
193
195
|
- [doc] Added color transition in Layout ([#43](https://github.com/njaldea/mono/pull/43))
|
|
194
|
-
|
|
195
196
|
- [doc] added Instance component ([#43](https://github.com/njaldea/mono/pull/43))
|
|
196
197
|
|
|
197
198
|
## 0.2.29
|
|
@@ -199,7 +200,7 @@
|
|
|
199
200
|
### Patch Changes
|
|
200
201
|
|
|
201
202
|
- [doc][feature] ThemeIcon ([#41](https://github.com/njaldea/mono/pull/41))
|
|
202
|
-
|
|
203
|
+
- [doc][feature] added top bar to separate title and other controls ([#41](https://github.com/njaldea/mono/pull/41))
|
|
203
204
|
|
|
204
205
|
## 0.2.28
|
|
205
206
|
|
package/components/Base.svelte
CHANGED
|
@@ -8,10 +8,8 @@ export let fill = false;
|
|
|
8
8
|
|
|
9
9
|
<!-- prettier-ignore -->
|
|
10
10
|
<style>
|
|
11
|
-
@import url("https://fonts.googleapis.com/css?family=Fira%20Code");
|
|
12
|
-
|
|
13
11
|
div {
|
|
14
|
-
font-family:
|
|
12
|
+
font-family: var(--nil-doc-font-family, ""), Verdana, Geneva, Tahoma, sans-serif;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
.fill {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Prop } from "./controls/types";
|
|
2
|
+
import type { SpecialProp, Prop } from "./controls/types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
props?: Prop[] | undefined;
|
|
5
|
+
props?: (Prop | SpecialProp)[] | undefined;
|
|
6
6
|
events?: string[] | undefined;
|
|
7
|
-
position?: "
|
|
7
|
+
position?: "right" | "bottom" | "hidden" | undefined;
|
|
8
8
|
mode?: "prop" | "event" | undefined;
|
|
9
9
|
};
|
|
10
10
|
events: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Writable } from "svelte/store";
|
|
2
|
-
import type { Prop, Event } from "./controls/types";
|
|
2
|
+
import type { SpecialProp, Prop, Event } from "./controls/types";
|
|
3
3
|
import type { ValueType } from "./types";
|
|
4
4
|
export type Params = {
|
|
5
5
|
id: number;
|
|
@@ -12,7 +12,7 @@ export type ControlState = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare const initParams: () => Writable<Params[]>, getParams: () => Writable<Params[]>;
|
|
14
14
|
type Controls = {
|
|
15
|
-
props: Prop[];
|
|
15
|
+
props: (Prop | SpecialProp)[];
|
|
16
16
|
events: Event[];
|
|
17
17
|
};
|
|
18
18
|
export declare const initControls: () => Writable<Controls>, getControls: () => Writable<Controls>;
|
|
@@ -42,11 +42,15 @@
|
|
|
42
42
|
place-items: center;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
div.props > :global(div > div:
|
|
45
|
+
div.props > :global(div > div:nth-child(2)) {
|
|
46
46
|
display: grid;
|
|
47
47
|
place-items: center;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
div.props > :global(div > div:nth-child(3)) {
|
|
51
|
+
margin: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
div > :global(div > div:not(:first-child) > *) {
|
|
51
55
|
width: 100%;
|
|
52
56
|
height: 80%;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>import { getClick, getName } from "./misc/utils";
|
|
2
|
+
export let info;
|
|
3
|
+
$:
|
|
4
|
+
click = getClick(info)();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div>
|
|
8
|
+
<button on:click={click}>{getName(info)}</button>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
button {
|
|
13
|
+
grid-column: 1 / 4;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
margin: 0.15rem 0.3rem;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
info: Unionized<PropType<"button">>;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type ButtonProps = typeof __propDef.props;
|
|
13
|
+
export type ButtonEvents = typeof __propDef.events;
|
|
14
|
+
export type ButtonSlots = typeof __propDef.slots;
|
|
15
|
+
export default class Button extends SvelteComponentTyped<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
const colorSetter = (format, color) => {
|
|
1
|
+
<script context="module">const colorSetter = (format, color) => {
|
|
3
2
|
switch (format) {
|
|
4
3
|
case "hex":
|
|
5
4
|
return color.hex.substring(0, 7);
|
|
@@ -20,6 +19,7 @@ const colorSetter = (format, color) => {
|
|
|
20
19
|
<script>import { getName, getFormat } from "./misc/utils";
|
|
21
20
|
import { defaulter } from "./misc/defaulter";
|
|
22
21
|
import NameHeader from "./misc/Name.svelte";
|
|
22
|
+
import Toggle from "svelte-toggle";
|
|
23
23
|
export let value;
|
|
24
24
|
export let info;
|
|
25
25
|
export let depth;
|
|
@@ -27,13 +27,13 @@ export let disabled = false;
|
|
|
27
27
|
export let visible = false;
|
|
28
28
|
let ivalue = value ?? defaulter(info);
|
|
29
29
|
let enabled = value !== void 0;
|
|
30
|
-
const action = (d, format) => {
|
|
30
|
+
const action = (d, { format, P }) => {
|
|
31
31
|
d.style.borderColor = ivalue;
|
|
32
|
-
const picker = new
|
|
32
|
+
const picker = new P({
|
|
33
33
|
parent: d,
|
|
34
34
|
popup: "left",
|
|
35
35
|
editorFormat: format.substring(0, 3),
|
|
36
|
-
editor:
|
|
36
|
+
editor: true,
|
|
37
37
|
alpha: format.length === 4,
|
|
38
38
|
onChange: (color) => {
|
|
39
39
|
ivalue = colorSetter(getFormat(info), color);
|
|
@@ -58,10 +58,12 @@ $:
|
|
|
58
58
|
{#if visible}
|
|
59
59
|
<div>
|
|
60
60
|
<NameHeader name={getName(info)} {depth} />
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
{#await import("vanilla-picker") then { default: P }}
|
|
62
|
+
<button use:action={{ format: getFormat(info), P }} disabled={!enabled || disabled}>
|
|
63
|
+
{ivalue}
|
|
64
|
+
</button>
|
|
65
|
+
{/await}
|
|
66
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
65
67
|
</div>
|
|
66
68
|
{/if}
|
|
67
69
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import Text from "./Text.svelte";
|
|
2
2
|
import Number from "./Number.svelte";
|
|
3
3
|
import Range from "./Range.svelte";
|
|
4
|
-
import
|
|
4
|
+
import Toggle from "./Toggle.svelte";
|
|
5
5
|
import Select from "./Select.svelte";
|
|
6
6
|
import Tuple from "./Tuple.svelte";
|
|
7
7
|
import Object from "./Object.svelte";
|
|
@@ -29,8 +29,10 @@ export let visible = false;
|
|
|
29
29
|
<Range {info} bind:value {depth} {disabled} {visible} />
|
|
30
30
|
{:else if "select" === type}
|
|
31
31
|
<Select {info} bind:value {depth} {disabled} {visible} />
|
|
32
|
-
{:else if "
|
|
33
|
-
<
|
|
32
|
+
{:else if "toggle" === type}
|
|
33
|
+
<Toggle {info} bind:value {depth} {disabled} {visible} />
|
|
34
|
+
{:else if "button" === type}
|
|
35
|
+
button
|
|
34
36
|
{/if}
|
|
35
37
|
{:else}
|
|
36
38
|
{@const type = info.type}
|
|
@@ -48,7 +50,9 @@ export let visible = false;
|
|
|
48
50
|
<Range {info} bind:value {depth} {disabled} {visible} />
|
|
49
51
|
{:else if "select" === type}
|
|
50
52
|
<Select {info} bind:value {depth} {disabled} {visible} />
|
|
51
|
-
{:else if "
|
|
52
|
-
<
|
|
53
|
+
{:else if "toggle" === type}
|
|
54
|
+
<Toggle {info} bind:value {depth} {disabled} {visible} />
|
|
55
|
+
{:else if "button" === type}
|
|
56
|
+
button
|
|
53
57
|
{/if}
|
|
54
58
|
{/if}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Prop } from "../types";
|
|
2
|
+
import type { SpecialProp, Prop } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: any;
|
|
6
|
-
info: Prop;
|
|
6
|
+
info: Prop | SpecialProp;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getName } from "./misc/utils";
|
|
2
2
|
import { defaulter } from "./misc/defaulter";
|
|
3
3
|
import NameHeader from "./misc/Name.svelte";
|
|
4
|
+
import Toggle from "svelte-toggle";
|
|
4
5
|
export let value;
|
|
5
6
|
export let info;
|
|
6
7
|
export let depth;
|
|
@@ -16,6 +17,6 @@ $:
|
|
|
16
17
|
<div>
|
|
17
18
|
<NameHeader name={getName(info)} {depth} />
|
|
18
19
|
<div><input type="number" bind:value={ivalue} disabled={!enabled || disabled} /></div>
|
|
19
|
-
<div><
|
|
20
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
20
21
|
</div>
|
|
21
22
|
{/if}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { ValueType } from "../../types";
|
|
3
|
-
import type { Prop } from "../types";
|
|
3
|
+
import type { SpecialProp, Prop } from "../types";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
|
-
infos: Prop[];
|
|
6
|
+
infos: (SpecialProp | Prop)[];
|
|
7
7
|
values: Record<string, ValueType>;
|
|
8
8
|
visible: boolean;
|
|
9
9
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { defaulter } from "./misc/defaulter";
|
|
2
2
|
import NameHeader from "./misc/Name.svelte";
|
|
3
3
|
import { nformat } from "./misc/nformat";
|
|
4
|
+
import Toggle from "svelte-toggle";
|
|
4
5
|
export let value;
|
|
5
6
|
export let info;
|
|
6
7
|
export let depth;
|
|
@@ -27,8 +28,8 @@ $:
|
|
|
27
28
|
{#if visible}
|
|
28
29
|
<div>
|
|
29
30
|
<NameHeader name={i.name} {depth} />
|
|
30
|
-
<div class="input">
|
|
31
|
-
<div class="tooltip"
|
|
31
|
+
<div class="input" class:disabled={!enabled || disabled}>
|
|
32
|
+
<div class="tooltip">
|
|
32
33
|
Value: {nformat(ivalue, 6, 11)}
|
|
33
34
|
</div>
|
|
34
35
|
<div>{nformat(ivalue, 3, 5)}</div>
|
|
@@ -41,12 +42,14 @@ $:
|
|
|
41
42
|
disabled={!enabled || disabled}
|
|
42
43
|
/>
|
|
43
44
|
</div>
|
|
44
|
-
<div><
|
|
45
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
45
46
|
</div>
|
|
46
47
|
{/if}
|
|
47
48
|
|
|
48
49
|
<style>
|
|
49
50
|
.input {
|
|
51
|
+
/* TODO: align color schema for toggle */
|
|
52
|
+
color-scheme: light;
|
|
50
53
|
width: 100%;
|
|
51
54
|
display: grid;
|
|
52
55
|
grid-template-columns: 4rem 1fr;
|
|
@@ -76,7 +79,11 @@ $:
|
|
|
76
79
|
place-items: center;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
.input
|
|
82
|
+
.input.disabled > div {
|
|
83
|
+
filter: contrast(0%);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.input:not(.disabled):hover > .tooltip {
|
|
80
87
|
visibility: visible;
|
|
81
88
|
}
|
|
82
89
|
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { defaulter } from "./misc/defaulter";
|
|
2
2
|
import { getValues, getName } from "./misc/utils";
|
|
3
3
|
import NameHeader from "./misc/Name.svelte";
|
|
4
|
+
import Toggle from "svelte-toggle";
|
|
4
5
|
export let value;
|
|
5
6
|
export let info;
|
|
6
7
|
export let depth;
|
|
@@ -22,7 +23,7 @@ $:
|
|
|
22
23
|
{/each}
|
|
23
24
|
</select>
|
|
24
25
|
</div>
|
|
25
|
-
<div><
|
|
26
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
26
27
|
</div>
|
|
27
28
|
{/if}
|
|
28
29
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getName } from "./misc/utils";
|
|
2
2
|
import { defaulter } from "./misc/defaulter";
|
|
3
3
|
import NameHeader from "./misc/Name.svelte";
|
|
4
|
+
import Toggle from "svelte-toggle";
|
|
4
5
|
export let value;
|
|
5
6
|
export let info;
|
|
6
7
|
export let depth;
|
|
@@ -16,6 +17,6 @@ $:
|
|
|
16
17
|
<div>
|
|
17
18
|
<NameHeader name={getName(info)} {depth} />
|
|
18
19
|
<div><input type="text" bind:value={ivalue} disabled={!enabled || disabled} /></div>
|
|
19
|
-
<div><
|
|
20
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
20
21
|
</div>
|
|
21
22
|
{/if}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>import { getName } from "./misc/utils";
|
|
2
2
|
import { defaulter } from "./misc/defaulter";
|
|
3
3
|
import NameHeader from "./misc/Name.svelte";
|
|
4
|
+
import Toggle from "svelte-toggle";
|
|
4
5
|
export let value;
|
|
5
6
|
export let info;
|
|
6
7
|
export let depth;
|
|
@@ -15,7 +16,9 @@ $:
|
|
|
15
16
|
{#if visible}
|
|
16
17
|
<div>
|
|
17
18
|
<NameHeader name={getName(info)} {depth} />
|
|
18
|
-
<div
|
|
19
|
-
|
|
19
|
+
<div style="margin: auto">
|
|
20
|
+
<Toggle bind:toggled={ivalue} disabled={!enabled || disabled} hideLabel small />
|
|
21
|
+
</div>
|
|
22
|
+
<div><Toggle bind:toggled={enabled} {disabled} hideLabel small /></div>
|
|
20
23
|
</div>
|
|
21
24
|
{/if}
|
|
@@ -3,7 +3,7 @@ import type { Unionized, PropType } from "../types";
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: boolean | undefined;
|
|
6
|
-
info: Unionized<PropType<"
|
|
6
|
+
info: Unionized<PropType<"toggle">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -13,9 +13,9 @@ declare const __propDef: {
|
|
|
13
13
|
};
|
|
14
14
|
slots: {};
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
18
|
-
export type
|
|
19
|
-
export default class
|
|
16
|
+
export type ToggleProps = typeof __propDef.props;
|
|
17
|
+
export type ToggleEvents = typeof __propDef.events;
|
|
18
|
+
export type ToggleSlots = typeof __propDef.slots;
|
|
19
|
+
export default class Toggle extends SvelteComponentTyped<ToggleProps, ToggleEvents, ToggleSlots> {
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>import Name from "./Name.svelte";
|
|
2
|
+
import Toggle from "svelte-toggle";
|
|
2
3
|
export let name;
|
|
3
4
|
export let depth;
|
|
4
5
|
export let checked;
|
|
@@ -23,7 +24,13 @@ const flip = () => {
|
|
|
23
24
|
/>
|
|
24
25
|
<div class="value">-</div>
|
|
25
26
|
<div>
|
|
26
|
-
<
|
|
27
|
+
<Toggle
|
|
28
|
+
bind:toggled={checked}
|
|
29
|
+
{disabled}
|
|
30
|
+
hideLabel
|
|
31
|
+
small
|
|
32
|
+
on:click={(e) => e.stopPropagation()}
|
|
33
|
+
/>
|
|
27
34
|
</div>
|
|
28
35
|
</div>
|
|
29
36
|
{/if}
|
|
@@ -6,6 +6,6 @@ export declare function defaulter(i: Unionized<PropType<"number">>): number;
|
|
|
6
6
|
export declare function defaulter(i: Unionized<PropType<"range">>): number;
|
|
7
7
|
export declare function defaulter(i: Unionized<PropType<"select">>): string;
|
|
8
8
|
export declare function defaulter(i: Unionized<PropType<"text">>): string;
|
|
9
|
-
export declare function defaulter(i: Unionized<PropType<"
|
|
9
|
+
export declare function defaulter(i: Unionized<PropType<"toggle">>): boolean;
|
|
10
10
|
export declare function defaulter(i: Unionized<PropType<"color">>): string;
|
|
11
11
|
export declare function defaulter(i: Prop): ValueType;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { Detailed, Unionized, PropType, Prop, NonNamedProp } from "../../types";
|
|
1
|
+
import type { Detailed, Unionized, PropType, Prop, NonNamedProp, SpecialProp } from "../../types";
|
|
2
2
|
type TypesWithValue = "object" | "tuple" | "select";
|
|
3
3
|
type Values<T extends TypesWithValue> = Detailed<PropType<T>>["values"];
|
|
4
4
|
export declare function getValues(info: Unionized<PropType<"select">>): Values<"select">;
|
|
5
5
|
export declare function getValues(info: Unionized<PropType<"object">>): Values<"object">;
|
|
6
6
|
export declare function getValues(info: Unionized<PropType<"tuple">>): Values<"tuple">;
|
|
7
7
|
export declare const getMin: (info: Unionized<PropType<"range">>) => number;
|
|
8
|
-
export declare const getType: (info: Prop) => "number" | "object" | "select" | "
|
|
8
|
+
export declare const getType: (info: Prop | SpecialProp) => "number" | "object" | "select" | "toggle" | "button" | "text" | "range" | "tuple" | "color";
|
|
9
9
|
export declare const getFormat: (info: Unionized<PropType<"color">>) => import("../../types").ColorFormat;
|
|
10
|
-
export declare const getName: (info: Prop) => string;
|
|
10
|
+
export declare const getName: (info: Prop | SpecialProp) => string;
|
|
11
|
+
export declare const getClick: (info: SpecialProp) => () => () => void;
|
|
11
12
|
export declare const addName: (name: string, info: NonNamedProp) => Prop;
|
|
12
13
|
export {};
|
|
@@ -29,6 +29,12 @@ export const getName = (info) => {
|
|
|
29
29
|
}
|
|
30
30
|
return info.name;
|
|
31
31
|
};
|
|
32
|
+
export const getClick = (info) => {
|
|
33
|
+
if (info instanceof Array) {
|
|
34
|
+
return info[2];
|
|
35
|
+
}
|
|
36
|
+
return info.click;
|
|
37
|
+
};
|
|
32
38
|
export const addName = (name, info) => {
|
|
33
39
|
if (info instanceof Array) {
|
|
34
40
|
return [name, ...info];
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
type Types =
|
|
2
|
-
|
|
1
|
+
type Types =
|
|
2
|
+
| "text"
|
|
3
|
+
| "color"
|
|
4
|
+
| "number"
|
|
5
|
+
| "select"
|
|
6
|
+
| "range"
|
|
7
|
+
| "toggle"
|
|
8
|
+
| "tuple"
|
|
9
|
+
| "object"
|
|
10
|
+
| "button";
|
|
3
11
|
type ColorFormat = "hsl" | "hsla" | "rgb" | "rgba" | "hex" | "hexa";
|
|
4
12
|
|
|
5
13
|
// prettier-ignore
|
|
@@ -16,7 +24,7 @@ export type PropType<T extends Types> =
|
|
|
16
24
|
[ name: string, type: T ],
|
|
17
25
|
{ name: string; type: T; }
|
|
18
26
|
]
|
|
19
|
-
: T extends "
|
|
27
|
+
: T extends "toggle" ? [
|
|
20
28
|
[ name: string, type: T ],
|
|
21
29
|
{ name: string; type: T; }
|
|
22
30
|
]
|
|
@@ -40,6 +48,10 @@ export type PropType<T extends Types> =
|
|
|
40
48
|
// eslint-disable-next-line no-use-before-define
|
|
41
49
|
{ name: string; type: T; values: Prop[]; }
|
|
42
50
|
]
|
|
51
|
+
: T extends "button" ? [
|
|
52
|
+
[ name: string, type: "button", click: () => (() => void) ],
|
|
53
|
+
{ name: string; type: "button"; click: () => (() => void); }
|
|
54
|
+
]
|
|
43
55
|
: never;
|
|
44
56
|
|
|
45
57
|
export type Flattened<T extends PropType> = T[0];
|
|
@@ -54,8 +66,8 @@ export type Prop =
|
|
|
54
66
|
| { name: string; type: "color"; format: ColorFormat; }
|
|
55
67
|
| [ name: string, type: "number" ]
|
|
56
68
|
| { name: string; type: "number"; }
|
|
57
|
-
| [ name: string, type: "
|
|
58
|
-
| { name: string; type: "
|
|
69
|
+
| [ name: string, type: "toggle" ]
|
|
70
|
+
| { name: string; type: "toggle"; }
|
|
59
71
|
| [ name: string, type: "select", values: string[] ]
|
|
60
72
|
| { name: string; type: "select"; values: string[]; }
|
|
61
73
|
| [ name: string, type: "range", min: number, max: number, step: number ]
|
|
@@ -67,6 +79,10 @@ export type Prop =
|
|
|
67
79
|
| [ name: string, type: "object", values: Prop[] ]
|
|
68
80
|
| { name: string; type: "object"; values: Prop[]; };
|
|
69
81
|
|
|
82
|
+
export type SpecialProp =
|
|
83
|
+
| [name: string, type: "button", click: () => () => void]
|
|
84
|
+
| { name: string; type: "button"; click: () => () => void };
|
|
85
|
+
|
|
70
86
|
// prettier-ignore
|
|
71
87
|
export type NonNamedProp =
|
|
72
88
|
| [ type: "text" ]
|
|
@@ -75,8 +91,8 @@ export type NonNamedProp =
|
|
|
75
91
|
| { type: "color"; format: ColorFormat; }
|
|
76
92
|
| [ type: "number" ]
|
|
77
93
|
| { type: "number"; }
|
|
78
|
-
| [ type: "
|
|
79
|
-
| { type: "
|
|
94
|
+
| [ type: "toggle" ]
|
|
95
|
+
| { type: "toggle"; }
|
|
80
96
|
| [ type: "select", values: string[] ]
|
|
81
97
|
| { type: "select"; values: string[]; }
|
|
82
98
|
| [ type: "range", min: number, max: number, step: number ]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nil-/doc",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.55",
|
|
4
4
|
"author": {
|
|
5
5
|
"email": "njaldea@gmail.com",
|
|
6
6
|
"name": "Neil Aldea"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@sveltejs/adapter-vercel": "^1.0.6",
|
|
11
|
-
"@sveltejs/kit": "^1.
|
|
11
|
+
"@sveltejs/kit": "^1.8.8",
|
|
12
12
|
"@sveltejs/package": "^1.0.2",
|
|
13
13
|
"@vitest/coverage-c8": "^0.26.3",
|
|
14
14
|
"mdsvex": "^0.10.6",
|
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
"svelte-check": "^2.10.3",
|
|
17
17
|
"tslib": "^2.5.0",
|
|
18
18
|
"typescript": "^4.9.5",
|
|
19
|
-
"vite": "^4.1.
|
|
20
|
-
"vitest": "^0.26.3"
|
|
19
|
+
"vite": "^4.1.4",
|
|
20
|
+
"vitest": "^0.26.3",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
|
22
|
+
"@typescript-eslint/parser": "^5.54.0",
|
|
23
|
+
"eslint": "^8.35.0",
|
|
24
|
+
"eslint-config-prettier": "^8.6.0",
|
|
25
|
+
"eslint-plugin-svelte3": "^4.0.0"
|
|
21
26
|
},
|
|
22
27
|
"peerDependencies": {
|
|
23
28
|
"svelte": "^3.55.1"
|
|
@@ -32,6 +37,7 @@
|
|
|
32
37
|
],
|
|
33
38
|
"type": "module",
|
|
34
39
|
"dependencies": {
|
|
40
|
+
"svelte-toggle": "^3.1.0",
|
|
35
41
|
"vanilla-picker": "^2.12.1"
|
|
36
42
|
},
|
|
37
43
|
"exports": {
|