@nil-/doc 0.2.47 → 0.2.48
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 +6 -0
- 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 +38 -20
- package/components/block/controls/props/Range.svelte.d.ts +2 -2
- 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/defaulter.d.ts +8 -10
- package/components/block/controls/props/misc/defaulter.js +2 -2
- 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,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: 50px 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,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.tooltip {
|
|
22
|
-
padding-right: 10px;
|
|
23
22
|
width: 100%;
|
|
24
23
|
height: 100%;
|
|
25
24
|
left: -110%;
|
|
26
25
|
position: absolute;
|
|
27
26
|
visibility: hidden;
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: 85px 1fr;
|
|
29
|
+
padding: 0px 5px;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
.input:hover > .tooltip:not(.disabled) {
|
|
@@ -44,31 +46,47 @@ 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
|
+
};
|
|
60
|
+
const format = (v, base, digits) => {
|
|
61
|
+
const n = v.toExponential().split("e");
|
|
62
|
+
const ex = parseInt(n[1]);
|
|
63
|
+
const absex = Math.abs(ex);
|
|
64
|
+
const rest = base + (absex >= 10 ? 0 : 1) - (ex >= 0 ? 0 : 1);
|
|
65
|
+
return v.toLocaleString(void 0, {
|
|
66
|
+
signDisplay: "always",
|
|
67
|
+
useGrouping: false,
|
|
68
|
+
notation: absex > 2 + digits ? "scientific" : "standard",
|
|
69
|
+
maximumFractionDigits: rest,
|
|
70
|
+
minimumFractionDigits: rest
|
|
71
|
+
});
|
|
72
|
+
};
|
|
56
73
|
</script>
|
|
57
74
|
{#if visible}
|
|
58
75
|
<div>
|
|
59
|
-
<NameHeader {name} {depth} />
|
|
76
|
+
<NameHeader name={i.name} {depth} />
|
|
60
77
|
<div class="input">
|
|
61
|
-
<div class="tooltip" class:disabled={
|
|
62
|
-
Current Value
|
|
78
|
+
<div class="tooltip" class:disabled={!enabled || disabled}>
|
|
79
|
+
<div>Current Value:</div>
|
|
80
|
+
<div>{format(ivalue, 6, 3)}</div>
|
|
63
81
|
</div>
|
|
64
|
-
<div>{ivalue
|
|
82
|
+
<div>{format(ivalue, 1, 1)}</div>
|
|
65
83
|
<input
|
|
66
84
|
type="range"
|
|
67
85
|
bind:value={ivalue}
|
|
68
|
-
{min}
|
|
69
|
-
{max}
|
|
70
|
-
{step}
|
|
71
|
-
disabled={
|
|
86
|
+
min={i.min}
|
|
87
|
+
max={i.max}
|
|
88
|
+
step={i.step}
|
|
89
|
+
disabled={!enabled || disabled}
|
|
72
90
|
/>
|
|
73
91
|
</div>
|
|
74
92
|
<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,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;
|
|
@@ -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
|
};
|
|
@@ -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";
|