@nil-/doc 0.2.47 → 0.2.49
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 +12 -0
- package/components/Layout.svelte +1 -1
- package/components/block/controls/props/Number.svelte.d.ts +2 -2
- package/components/block/controls/props/Object.svelte.d.ts +2 -2
- package/components/block/controls/props/Range.svelte +26 -22
- package/components/block/controls/props/Range.svelte.d.ts +2 -2
- package/components/block/controls/props/Select.svelte +6 -0
- package/components/block/controls/props/Select.svelte.d.ts +2 -2
- package/components/block/controls/props/Switch.svelte.d.ts +2 -2
- package/components/block/controls/props/Text.svelte.d.ts +2 -2
- package/components/block/controls/props/Tuple.svelte.d.ts +2 -2
- package/components/block/controls/props/misc/Styler.svelte +2 -0
- package/components/block/controls/props/misc/defaulter.d.ts +8 -10
- package/components/block/controls/props/misc/defaulter.js +2 -2
- package/components/block/controls/props/misc/nformat.d.ts +1 -0
- package/components/block/controls/props/misc/nformat.js +16 -0
- package/components/block/controls/types.d.ts +71 -47
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @nil-/doc
|
|
2
2
|
|
|
3
|
+
## 0.2.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [doc][fix] fix range number formatting ([#83](https://github.com/njaldea/mono/pull/83))
|
|
8
|
+
|
|
9
|
+
## 0.2.48
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [doc][fix] Fix type support ([#81](https://github.com/njaldea/mono/pull/81))
|
|
14
|
+
|
|
3
15
|
## 0.2.47
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/components/Layout.svelte
CHANGED
|
@@ -121,7 +121,7 @@ const toggle = () => {
|
|
|
121
121
|
</div>
|
|
122
122
|
<div
|
|
123
123
|
class="icon"
|
|
124
|
-
title="
|
|
124
|
+
title="Open @nil-/mono repo: https://github.com/njaldea/mono"
|
|
125
125
|
on:click={() => window.open("https://github.com/njaldea/mono", "_blank")}
|
|
126
126
|
on:keypress={null}
|
|
127
127
|
>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: number | undefined;
|
|
6
|
-
info:
|
|
6
|
+
info: Unionized<PropType<"number">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { ValueType } from "../../types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Unionized, PropType } from "../types";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
value: Record<string, ValueType> | undefined;
|
|
7
|
-
info:
|
|
7
|
+
info: Unionized<PropType<"object">>;
|
|
8
8
|
depth: number;
|
|
9
9
|
disabled?: boolean | undefined;
|
|
10
10
|
visible?: boolean | undefined;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
.input {
|
|
3
3
|
width: 100%;
|
|
4
4
|
display: grid;
|
|
5
|
-
grid-template-columns:
|
|
5
|
+
grid-template-columns: 65px 1fr;
|
|
6
6
|
gap: 5px;
|
|
7
7
|
position: relative;
|
|
8
8
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
width: 100%;
|
|
12
12
|
height: 100%;
|
|
13
13
|
display: grid;
|
|
14
|
-
text-align:
|
|
14
|
+
text-align: left;
|
|
15
15
|
align-items: center;
|
|
16
16
|
font-size: 0.8rem;
|
|
17
17
|
user-select: none;
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.tooltip {
|
|
22
|
-
|
|
22
|
+
left: -110%;
|
|
23
23
|
width: 100%;
|
|
24
24
|
height: 100%;
|
|
25
|
-
|
|
26
|
-
position: absolute;
|
|
25
|
+
display: grid;
|
|
27
26
|
visibility: hidden;
|
|
27
|
+
position: absolute;
|
|
28
|
+
place-items: center;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.input:hover > .tooltip:not(.disabled) {
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
|
|
35
36
|
<script>import { getDefault } from "./misc/defaulter";
|
|
36
37
|
import NameHeader from "./misc/Name.svelte";
|
|
38
|
+
import { nformat } from "./misc/nformat";
|
|
37
39
|
export let value;
|
|
38
40
|
export let info;
|
|
39
41
|
export let depth;
|
|
@@ -44,31 +46,33 @@ let enabled = value !== void 0;
|
|
|
44
46
|
$:
|
|
45
47
|
value = enabled && !disabled ? ivalue : void 0;
|
|
46
48
|
$:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
i = info instanceof Array ? {
|
|
50
|
+
name: info[0],
|
|
51
|
+
min: info[2],
|
|
52
|
+
max: info[3],
|
|
53
|
+
step: info[4]
|
|
54
|
+
} : {
|
|
55
|
+
name: info.name,
|
|
56
|
+
min: info.min,
|
|
57
|
+
max: info.max,
|
|
58
|
+
step: info.step
|
|
59
|
+
};
|
|
56
60
|
</script>
|
|
57
61
|
{#if visible}
|
|
58
62
|
<div>
|
|
59
|
-
<NameHeader {name} {depth} />
|
|
63
|
+
<NameHeader name={i.name} {depth} />
|
|
60
64
|
<div class="input">
|
|
61
|
-
<div class="tooltip" class:disabled={
|
|
62
|
-
|
|
65
|
+
<div class="tooltip" class:disabled={!enabled || disabled}>
|
|
66
|
+
Value: {nformat(ivalue, 6, 11)}
|
|
63
67
|
</div>
|
|
64
|
-
<div>{ivalue
|
|
68
|
+
<div>{nformat(ivalue, 3, 5)}</div>
|
|
65
69
|
<input
|
|
66
70
|
type="range"
|
|
67
71
|
bind:value={ivalue}
|
|
68
|
-
{min}
|
|
69
|
-
{max}
|
|
70
|
-
{step}
|
|
71
|
-
disabled={
|
|
72
|
+
min={i.min}
|
|
73
|
+
max={i.max}
|
|
74
|
+
step={i.step}
|
|
75
|
+
disabled={!enabled || disabled}
|
|
72
76
|
/>
|
|
73
77
|
</div>
|
|
74
78
|
<div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: number | undefined;
|
|
6
|
-
info:
|
|
6
|
+
info: Unionized<PropType<"range">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
select {
|
|
3
|
+
text-align: center;
|
|
4
|
+
}
|
|
5
|
+
</style>
|
|
1
6
|
|
|
2
7
|
<script>import { getDefault } from "./misc/defaulter";
|
|
3
8
|
import NameHeader from "./misc/Name.svelte";
|
|
@@ -28,3 +33,4 @@ $:
|
|
|
28
33
|
<div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
|
|
29
34
|
</div>
|
|
30
35
|
{/if}
|
|
36
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: string | undefined;
|
|
6
|
-
info:
|
|
6
|
+
info: Unionized<PropType<"select">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: boolean | undefined;
|
|
6
|
-
info:
|
|
6
|
+
info: Unionized<PropType<"switch">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Unionized, PropType } from "../types";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
value: string | undefined;
|
|
6
|
-
info:
|
|
6
|
+
info: Unionized<PropType<"text">>;
|
|
7
7
|
depth: number;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
visible?: boolean | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
import type { ValueType } from "../../types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Unionized, PropType } from "../types";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
6
|
value: ValueType[] | undefined;
|
|
7
|
-
info:
|
|
7
|
+
info: Unionized<PropType<"tuple">>;
|
|
8
8
|
depth: number;
|
|
9
9
|
disabled?: boolean | undefined;
|
|
10
10
|
visible?: boolean | undefined;
|
|
@@ -15,6 +15,7 @@ const dark = getTheme();
|
|
|
15
15
|
div :global(*::before),
|
|
16
16
|
div :global(*::after) {
|
|
17
17
|
box-sizing: inherit;
|
|
18
|
+
font-family: inherit;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
div > :global(div) {
|
|
@@ -26,6 +27,7 @@ const dark = getTheme();
|
|
|
26
27
|
|
|
27
28
|
div > :global(div:first-child) {
|
|
28
29
|
text-align: center;
|
|
30
|
+
font-weight: bold;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
div > :global(div > div:not(:first-child) > *) {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { ValueType } from "../../../types";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function getDefault(i:
|
|
6
|
-
export declare function getDefault(i:
|
|
7
|
-
export declare function getDefault(i:
|
|
8
|
-
export declare function getDefault(i:
|
|
9
|
-
export declare function getDefault(i:
|
|
10
|
-
export declare function getDefault(i: (Name & PropText) | [string, ...FlatPropText]): string;
|
|
11
|
-
export declare function getDefault(i: (Name & PropSwitch) | [string, ...FlatPropSwitch]): boolean;
|
|
2
|
+
import type { Unionized, PropType, Prop } from "../../types";
|
|
3
|
+
export declare function getDefault(i: Unionized<PropType<"tuple">>): ValueType[];
|
|
4
|
+
export declare function getDefault(i: Unionized<PropType<"object">>): Record<string, ValueType>;
|
|
5
|
+
export declare function getDefault(i: Unionized<PropType<"number">>): number;
|
|
6
|
+
export declare function getDefault(i: Unionized<PropType<"range">>): number;
|
|
7
|
+
export declare function getDefault(i: Unionized<PropType<"select">>): string;
|
|
8
|
+
export declare function getDefault(i: Unionized<PropType<"text">>): string;
|
|
9
|
+
export declare function getDefault(i: Unionized<PropType<"switch">>): boolean;
|
|
12
10
|
export declare function getDefault(i: Prop): ValueType;
|
|
@@ -59,13 +59,13 @@ const getObjectDefaults = (info) => {
|
|
|
59
59
|
const getTupleDefaults = (info) => {
|
|
60
60
|
const ret = [];
|
|
61
61
|
const values = info instanceof Array ? info[2] : info.values;
|
|
62
|
-
values.
|
|
62
|
+
for (const [i, v] of values.entries()) {
|
|
63
63
|
if (v instanceof Array) {
|
|
64
64
|
ret.push(getDefault([`${i}`, ...v]));
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
67
|
ret.push(getDefault({ name: `${i}`, ...v }));
|
|
68
68
|
}
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
return ret;
|
|
71
71
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const nformat: (v: number, fdigits: number, width: number) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const nformat = (v, fdigits, width) => {
|
|
2
|
+
const n = v.toExponential().split("e");
|
|
3
|
+
const ex = parseInt(n[1]);
|
|
4
|
+
const absex = Math.abs(ex);
|
|
5
|
+
const short = absex >= fdigits;
|
|
6
|
+
const rest = short
|
|
7
|
+
? width - 3 + (absex >= 10 ? 0 : 1) - (ex < 0 ? 1 : 0)
|
|
8
|
+
: width - absex + (ex < 0 ? -ex : 0);
|
|
9
|
+
return v.toLocaleString(undefined, {
|
|
10
|
+
signDisplay: "always",
|
|
11
|
+
useGrouping: false,
|
|
12
|
+
notation: short ? "scientific" : "standard",
|
|
13
|
+
maximumFractionDigits: rest,
|
|
14
|
+
minimumFractionDigits: rest
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -1,55 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
export type FlatPropTuple = ["tuple", NonNamedProp[]];
|
|
3
|
-
// eslint-disable-next-line no-use-before-define
|
|
4
|
-
export type FlatPropObject = ["object", Prop[]];
|
|
5
|
-
export type FlatPropText = ["text"];
|
|
6
|
-
export type FlatPropNumber = ["number"];
|
|
7
|
-
export type FlatPropRange = ["range", number, number, number];
|
|
8
|
-
export type FlatPropSelect = ["select", string[]];
|
|
9
|
-
export type FlatPropSwitch = ["switch"];
|
|
1
|
+
type Types = "text" | "number" | "select" | "range" | "switch" | "tuple" | "object";
|
|
10
2
|
|
|
11
|
-
//
|
|
12
|
-
export type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
// prettier-ignore
|
|
4
|
+
export type PropType<T extends Types> =
|
|
5
|
+
T extends "text" ? [
|
|
6
|
+
[ name: string, type: T ],
|
|
7
|
+
{ name: string; type: T; }
|
|
8
|
+
]
|
|
9
|
+
: T extends "number" ? [
|
|
10
|
+
[ name: string, type: T ],
|
|
11
|
+
{ name: string; type: T; }
|
|
12
|
+
]
|
|
13
|
+
: T extends "switch" ? [
|
|
14
|
+
[ name: string, type: T ],
|
|
15
|
+
{ name: string; type: T; }
|
|
16
|
+
]
|
|
17
|
+
: T extends "select" ? [
|
|
18
|
+
[ name: string, type: T, values: string[] ],
|
|
19
|
+
{ name: string; type: T; values: string[]; }
|
|
20
|
+
]
|
|
21
|
+
: T extends "range" ? [
|
|
22
|
+
[ name: string, type: T, min: number, max: number, step: number ],
|
|
23
|
+
{ name: string; type: T; min: number; max: number, step: number; }
|
|
24
|
+
]
|
|
25
|
+
: T extends "tuple" ? [
|
|
26
|
+
// eslint-disable-next-line no-use-before-define
|
|
27
|
+
[ name: string, type: T, values: NonNamedProp[] ],
|
|
28
|
+
// eslint-disable-next-line no-use-before-define
|
|
29
|
+
{ name: string; type: T; values: NonNamedProp[]; }
|
|
30
|
+
]
|
|
31
|
+
: T extends "object" ? [
|
|
32
|
+
// eslint-disable-next-line no-use-before-define
|
|
33
|
+
[ name: string, type: T, values: Prop[] ],
|
|
34
|
+
// eslint-disable-next-line no-use-before-define
|
|
35
|
+
{ name: string; type: T; values: Prop[]; }
|
|
36
|
+
]
|
|
37
|
+
: never;
|
|
20
38
|
|
|
21
|
-
export type
|
|
39
|
+
export type Flattened<T extends PropType> = T[0];
|
|
40
|
+
export type Detailed<T extends PropType> = T[1];
|
|
41
|
+
export type Unionized<T extends PropTyoe> = T[number];
|
|
22
42
|
|
|
43
|
+
// prettier-ignore
|
|
23
44
|
export type Prop =
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
| [string,
|
|
33
|
-
|
|
|
34
|
-
|
|
35
|
-
| [string,
|
|
36
|
-
|
|
37
|
-
|
|
|
45
|
+
| [ name: string, type: "text" ]
|
|
46
|
+
| { name: string; type: "text"; }
|
|
47
|
+
| [ name: string, type: "number" ]
|
|
48
|
+
| { name: string; type: "number"; }
|
|
49
|
+
| [ name: string, type: "switch" ]
|
|
50
|
+
| { name: string; type: "switch"; }
|
|
51
|
+
| [ name: string, type: "select", values: string[] ]
|
|
52
|
+
| { name: string; type: "select"; values: string[]; }
|
|
53
|
+
| [ name: string, type: "range", min: number, max: number, step: number ]
|
|
54
|
+
| { name: string; type: "range"; min: number; max: number; step: number; }
|
|
55
|
+
// eslint-disable-next-line no-use-before-define
|
|
56
|
+
| [ name: string, type: "tuple", values: NonNamedProp[] ]
|
|
57
|
+
// eslint-disable-next-line no-use-before-define
|
|
58
|
+
| { name: string; type: "tuple"; values: NonNamedProp[]; }
|
|
59
|
+
| [ name: string, type: "object", values: Prop[] ]
|
|
60
|
+
| { name: string; type: "object"; values: Prop[]; };
|
|
38
61
|
|
|
62
|
+
// prettier-ignore
|
|
39
63
|
type NonNamedProp =
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
64
|
+
| [ type: "text" ]
|
|
65
|
+
| { type: "text"; }
|
|
66
|
+
| [ type: "number" ]
|
|
67
|
+
| { type: "number"; }
|
|
68
|
+
| [ type: "switch" ]
|
|
69
|
+
| { type: "switch"; }
|
|
70
|
+
| [ type: "select", values: string[] ]
|
|
71
|
+
| { type: "select"; values: string[]; }
|
|
72
|
+
| [ type: "range", min: number, max: number, step: number ]
|
|
73
|
+
| { type: "range"; min: number; max: number; step: number; }
|
|
74
|
+
| [ type: "tuple", values: NonNamedProp[] ]
|
|
75
|
+
| { type: "tuple"; values: NonNamedProp[]; }
|
|
76
|
+
| [ type: "object", values: Prop[] ]
|
|
77
|
+
| { type: "object"; values: Prop[]; };
|
|
54
78
|
|
|
55
79
|
export type Event = string;
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { renamer } from "./components/navigation/utils/renamer";
|
|
2
2
|
export { sorter } from "./components/navigation/utils/sorter";
|
|
3
|
-
export type { Prop, Event } from "./components/block/controls/types";
|
|
3
|
+
export type { Prop, Event, PropType, Detailed, Flattened, Unionized } from "./components/block/controls/types";
|
|
4
4
|
export { default as Layout } from "./components/Layout.svelte";
|
|
5
5
|
export { default as Instance } from "./components/block/Instance.svelte";
|
|
6
6
|
export { default as Block } from "./components/block/Block.svelte";
|