@nil-/doc 0.2.48 → 0.2.50

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/components/Layout.svelte +78 -81
  3. package/components/Layout.svelte.d.ts +1 -0
  4. package/components/block/Block.svelte +29 -28
  5. package/components/block/Controls.svelte +1 -1
  6. package/components/block/Instance.svelte +73 -72
  7. package/components/block/Params.svelte +1 -1
  8. package/components/block/Template.svelte +2 -1
  9. package/components/block/controls/events/Events.svelte +9 -9
  10. package/components/block/controls/events/misc/Styler.svelte +18 -19
  11. package/components/block/controls/props/Component.svelte +1 -1
  12. package/components/block/controls/props/Number.svelte +1 -1
  13. package/components/block/controls/props/Object.svelte +2 -1
  14. package/components/block/controls/props/Props.svelte +1 -1
  15. package/components/block/controls/props/Range.svelte +38 -52
  16. package/components/block/controls/props/Select.svelte +7 -1
  17. package/components/block/controls/props/Switch.svelte +1 -1
  18. package/components/block/controls/props/Text.svelte +1 -1
  19. package/components/block/controls/props/Tuple.svelte +2 -1
  20. package/components/block/controls/props/misc/GroupHeader.svelte +6 -6
  21. package/components/block/controls/props/misc/Name.svelte +14 -14
  22. package/components/block/controls/props/misc/Styler.svelte +22 -21
  23. package/components/block/controls/props/misc/nformat.d.ts +1 -0
  24. package/components/block/controls/props/misc/nformat.js +16 -0
  25. package/components/etc/Container.svelte +92 -92
  26. package/components/{etc/NilIcon.svelte → icons/NilDoc.svelte} +17 -16
  27. package/components/icons/NilDoc.svelte.d.ts +14 -0
  28. package/components/{etc/ThemeIcon.svelte → icons/Theme.svelte} +34 -31
  29. package/components/icons/Theme.svelte.d.ts +17 -0
  30. package/components/navigation/Nav.svelte +31 -30
  31. package/components/navigation/Node.svelte +47 -47
  32. package/components/navigation/Tree.svelte +1 -1
  33. package/components/title/Icon.svelte +19 -0
  34. package/components/title/Icon.svelte.d.ts +21 -0
  35. package/index.d.ts +3 -0
  36. package/index.js +3 -0
  37. package/package.json +1 -1
  38. package/components/etc/NilIcon.svelte.d.ts +0 -14
  39. package/components/etc/ThemeIcon.svelte.d.ts +0 -16
@@ -1,41 +1,6 @@
1
- <style>
2
- .input {
3
- width: 100%;
4
- display: grid;
5
- grid-template-columns: 50px 1fr;
6
- gap: 5px;
7
- position: relative;
8
- }
9
-
10
- .input > div {
11
- width: 100%;
12
- height: 100%;
13
- display: grid;
14
- text-align: left;
15
- align-items: center;
16
- font-size: 0.8rem;
17
- user-select: none;
18
- margin: auto;
19
- }
20
-
21
- .tooltip {
22
- width: 100%;
23
- height: 100%;
24
- left: -110%;
25
- position: absolute;
26
- visibility: hidden;
27
- display: grid;
28
- grid-template-columns: 85px 1fr;
29
- padding: 0px 5px;
30
- }
31
-
32
- .input:hover > .tooltip:not(.disabled) {
33
- visibility: visible;
34
- }
35
- </style>
36
-
37
1
  <script>import { getDefault } from "./misc/defaulter";
38
2
  import NameHeader from "./misc/Name.svelte";
3
+ import { nformat } from "./misc/nformat";
39
4
  export let value;
40
5
  export let info;
41
6
  export let depth;
@@ -57,29 +22,16 @@ $:
57
22
  max: info.max,
58
23
  step: info.step
59
24
  };
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
- };
73
25
  </script>
26
+
74
27
  {#if visible}
75
28
  <div>
76
29
  <NameHeader name={i.name} {depth} />
77
30
  <div class="input">
78
31
  <div class="tooltip" class:disabled={!enabled || disabled}>
79
- <div>Current Value:</div>
80
- <div>{format(ivalue, 6, 3)}</div>
32
+ Value: {nformat(ivalue, 6, 11)}
81
33
  </div>
82
- <div>{format(ivalue, 1, 1)}</div>
34
+ <div>{nformat(ivalue, 3, 5)}</div>
83
35
  <input
84
36
  type="range"
85
37
  bind:value={ivalue}
@@ -93,3 +45,37 @@ const format = (v, base, digits) => {
93
45
  </div>
94
46
  {/if}
95
47
 
48
+ <style>
49
+ .input {
50
+ width: 100%;
51
+ display: grid;
52
+ grid-template-columns: 65px 1fr;
53
+ gap: 5px;
54
+ position: relative;
55
+ }
56
+
57
+ .input > div {
58
+ width: 100%;
59
+ height: 100%;
60
+ display: grid;
61
+ text-align: left;
62
+ align-items: center;
63
+ font-size: 0.8rem;
64
+ user-select: none;
65
+ margin: auto;
66
+ }
67
+
68
+ .tooltip {
69
+ left: -110%;
70
+ width: 100%;
71
+ height: 100%;
72
+ display: grid;
73
+ visibility: hidden;
74
+ position: absolute;
75
+ place-items: center;
76
+ }
77
+
78
+ .input:hover > .tooltip:not(.disabled) {
79
+ visibility: visible;
80
+ }
81
+ </style>
@@ -1,4 +1,3 @@
1
-
2
1
  <script>import { getDefault } from "./misc/defaulter";
3
2
  import NameHeader from "./misc/Name.svelte";
4
3
  export let value;
@@ -15,6 +14,7 @@ $:
15
14
  $:
16
15
  values = info instanceof Array ? info[2] : info.values;
17
16
  </script>
17
+
18
18
  {#if visible}
19
19
  <div>
20
20
  <NameHeader {name} {depth} />
@@ -28,3 +28,9 @@ $:
28
28
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
29
29
  </div>
30
30
  {/if}
31
+
32
+ <style>
33
+ select {
34
+ text-align: center;
35
+ }
36
+ </style>
@@ -1,4 +1,3 @@
1
-
2
1
  <script>import { getDefault } from "./misc/defaulter";
3
2
  import NameHeader from "./misc/Name.svelte";
4
3
  export let value;
@@ -13,6 +12,7 @@ $:
13
12
  $:
14
13
  name = info instanceof Array ? info[0] : info.name;
15
14
  </script>
15
+
16
16
  {#if visible}
17
17
  <div>
18
18
  <NameHeader {name} {depth} />
@@ -1,4 +1,3 @@
1
-
2
1
  <script>import { getDefault } from "./misc/defaulter";
3
2
  import NameHeader from "./misc/Name.svelte";
4
3
  export let value;
@@ -13,6 +12,7 @@ $:
13
12
  $:
14
13
  name = info instanceof Array ? info[0] : info.name;
15
14
  </script>
15
+
16
16
  {#if visible}
17
17
  <div>
18
18
  <NameHeader {name} {depth} />
@@ -1,4 +1,3 @@
1
-
2
1
  <script>import Component from "./Component.svelte";
3
2
  import Header from "./misc/GroupHeader.svelte";
4
3
  import { getDefault } from "./misc/defaulter";
@@ -17,7 +16,9 @@ $:
17
16
  name = info instanceof Array ? info[0] : info.name;
18
17
  let expand = info.values.length > 0 ? true : void 0;
19
18
  </script>
19
+
20
20
  <Header {name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
21
+
21
22
  {#each values as v, i (i)}
22
23
  {#if v instanceof Array}
23
24
  <Component
@@ -1,9 +1,3 @@
1
- <style>
2
- .value {
3
- text-align: center;
4
- }
5
- </style>
6
-
7
1
  <script>import Name from "./Name.svelte";
8
2
  export let name;
9
3
  export let depth;
@@ -19,6 +13,7 @@ const flip = () => {
19
13
  }
20
14
  };
21
15
  </script>
16
+
22
17
  {#if visible}
23
18
  <div class="root" on:click={flip} on:keypress={null}>
24
19
  <Name
@@ -33,3 +28,8 @@ const flip = () => {
33
28
  </div>
34
29
  {/if}
35
30
 
31
+ <style>
32
+ .value {
33
+ text-align: center;
34
+ }
35
+ </style>
@@ -1,3 +1,17 @@
1
+ <script>export let depth;
2
+ export let name;
3
+ export let expand = void 0;
4
+ </script>
5
+
6
+ <div class="override" style:padding-left={`${depth}px`} title={name}>
7
+ <div class="icon" class:expand={expand === true}>
8
+ <div>
9
+ {expand === undefined ? "-" : ">"}
10
+ </div>
11
+ </div>
12
+ <span>{name}</span>
13
+ </div>
14
+
1
15
  <style>
2
16
  .override {
3
17
  overflow: hidden;
@@ -28,17 +42,3 @@
28
42
  margin: auto;
29
43
  }
30
44
  </style>
31
-
32
- <script>export let depth;
33
- export let name;
34
- export let expand = void 0;
35
- </script>
36
- <div class="override" style:padding-left={`${depth}px`} title={name}>
37
- <div class="icon" class:expand={expand === true}>
38
- <div>
39
- {expand === undefined ? "-" : ">"}
40
- </div>
41
- </div>
42
- <span>{name}</span>
43
- </div>
44
-
@@ -1,6 +1,26 @@
1
1
  <script>import { getTheme } from "../../../../context";
2
2
  const dark = getTheme();
3
3
  </script>
4
+
5
+ <!--
6
+ <div> this component
7
+ <div> Header
8
+ <div></div>
9
+ <div></div>
10
+ <div></div>
11
+ </div>
12
+ <div> Controls
13
+ <div></div>
14
+ <div></div>
15
+ <div></div>
16
+ </div>
17
+ ...
18
+ </div>
19
+ -->
20
+ <div class:dark={$dark}>
21
+ <slot />
22
+ </div>
23
+
4
24
  <style>
5
25
  div {
6
26
  width: 100%;
@@ -15,6 +35,7 @@ const dark = getTheme();
15
35
  div :global(*::before),
16
36
  div :global(*::after) {
17
37
  box-sizing: inherit;
38
+ font-family: inherit;
18
39
  }
19
40
 
20
41
  div > :global(div) {
@@ -26,6 +47,7 @@ const dark = getTheme();
26
47
 
27
48
  div > :global(div:first-child) {
28
49
  text-align: center;
50
+ font-weight: bold;
29
51
  }
30
52
 
31
53
  div > :global(div > div:not(:first-child) > *) {
@@ -64,24 +86,3 @@ const dark = getTheme();
64
86
  outline: var(--outline-color) 1px solid;
65
87
  }
66
88
  </style>
67
-
68
-
69
- <!--
70
- <div> this component
71
- <div> Header
72
- <div></div>
73
- <div></div>
74
- <div></div>
75
- </div>
76
- <div> Controls
77
- <div></div>
78
- <div></div>
79
- <div></div>
80
- </div>
81
- ...
82
- </div>
83
- -->
84
- <div class:dark={$dark}>
85
- <slot />
86
- </div>
87
-
@@ -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,3 +1,95 @@
1
+ <script>import { writable } from "svelte/store";
2
+ import { tweened } from "svelte/motion";
3
+ import { createDraggable } from "./action";
4
+ import { getTheme } from "../context";
5
+ const dark = getTheme();
6
+ export let vertical = false;
7
+ export let offset = 0;
8
+ export let b = false;
9
+ let width;
10
+ let height;
11
+ const { position, draggable } = createDraggable(offset);
12
+ $:
13
+ span = vertical ? width : height;
14
+ const update = (limit, value) => {
15
+ if (null == span) {
16
+ return;
17
+ }
18
+ offset = Math.max(Math.min(value, span - limit), limit);
19
+ };
20
+ const off = tweened(offset, { duration: 50 });
21
+ let last = [];
22
+ $:
23
+ update(10, $position);
24
+ $:
25
+ $off = offset;
26
+ $:
27
+ style = !b ? `auto 5px ${$off}px` : `${$off}px 5px auto`;
28
+ const moving = writable(false);
29
+ const addLast = (v) => {
30
+ if (v > 10) {
31
+ if (last.length < 2) {
32
+ last = [...last, v];
33
+ } else {
34
+ last = [last[1], v];
35
+ }
36
+ }
37
+ };
38
+ const dbltap = () => {
39
+ if ($off > 10) {
40
+ addLast(offset);
41
+ offset = 10;
42
+ } else if (last.length > 0) {
43
+ offset = last.pop();
44
+ }
45
+ };
46
+ const check = (v, flag, s) => {
47
+ if (flag) {
48
+ return v < s - 10;
49
+ } else {
50
+ return v > 10;
51
+ }
52
+ };
53
+ </script>
54
+
55
+ <div
56
+ class="container"
57
+ class:vertical
58
+ class:b
59
+ class:dark={$dark}
60
+ class:moving={$moving}
61
+ bind:clientWidth={width}
62
+ bind:clientHeight={height}
63
+ style:grid-template-columns={vertical ? style : null}
64
+ style:grid-template-rows={!vertical ? style : null}
65
+ >
66
+ {#if width != null && height != null}
67
+ <div style:grid-area="A">
68
+ {#if check($off, !b, span)}
69
+ <slot name="A" />
70
+ {/if}
71
+ </div>
72
+ <div class="divider">
73
+ <div
74
+ class="overlay"
75
+ use:draggable={{
76
+ reset: () => offset,
77
+ reversed: !b,
78
+ vertical,
79
+ dbltap: dbltap,
80
+ tap: () => addLast($off),
81
+ moving
82
+ }}
83
+ />
84
+ </div>
85
+ <div style:grid-area="B">
86
+ {#if check($off, b, span)}
87
+ <slot name="B" />
88
+ {/if}
89
+ </div>
90
+ {/if}
91
+ </div>
92
+
1
93
  <style>
2
94
  div {
3
95
  box-sizing: border-box;
@@ -96,95 +188,3 @@
96
188
  border-left: var(--color-s) solid 2.5px;
97
189
  }
98
190
  </style>
99
-
100
- <script>import { writable } from "svelte/store";
101
- import { tweened } from "svelte/motion";
102
- import { createDraggable } from "./action";
103
- import { getTheme } from "../context";
104
- const dark = getTheme();
105
- export let vertical = false;
106
- export let offset = 0;
107
- export let b = false;
108
- let width;
109
- let height;
110
- const { position, draggable } = createDraggable(offset);
111
- $:
112
- span = vertical ? width : height;
113
- const update = (limit, value) => {
114
- if (null == span) {
115
- return;
116
- }
117
- offset = Math.max(Math.min(value, span - limit), limit);
118
- };
119
- const off = tweened(offset, { duration: 50 });
120
- let last = [];
121
- $:
122
- update(10, $position);
123
- $:
124
- $off = offset;
125
- $:
126
- style = !b ? `auto 5px ${$off}px` : `${$off}px 5px auto`;
127
- const moving = writable(false);
128
- const addLast = (v) => {
129
- if (v > 10) {
130
- if (last.length < 2) {
131
- last = [...last, v];
132
- } else {
133
- last = [last[1], v];
134
- }
135
- }
136
- };
137
- const dbltap = () => {
138
- if ($off > 10) {
139
- addLast(offset);
140
- offset = 10;
141
- } else if (last.length > 0) {
142
- offset = last.pop();
143
- }
144
- };
145
- const check = (v, flag, s) => {
146
- if (flag) {
147
- return v < s - 10;
148
- } else {
149
- return v > 10;
150
- }
151
- };
152
- </script>
153
- <div
154
- class="container"
155
- class:vertical
156
- class:b
157
- class:dark={$dark}
158
- class:moving={$moving}
159
- bind:clientWidth={width}
160
- bind:clientHeight={height}
161
- style:grid-template-columns={vertical ? style : null}
162
- style:grid-template-rows={!vertical ? style : null}
163
- >
164
- {#if width != null && height != null}
165
- <div style:grid-area="A">
166
- {#if check($off, !b, span)}
167
- <slot name="A" />
168
- {/if}
169
- </div>
170
- <div class="divider">
171
- <div
172
- class="overlay"
173
- use:draggable={{
174
- reset: () => offset,
175
- reversed: !b,
176
- vertical,
177
- dbltap: dbltap,
178
- tap: () => addLast($off),
179
- moving
180
- }}
181
- />
182
- </div>
183
- <div style:grid-area="B">
184
- {#if check($off, b, span)}
185
- <slot name="B" />
186
- {/if}
187
- </div>
188
- {/if}
189
- </div>
190
-
@@ -1,3 +1,10 @@
1
+ <script context="module">const action = (p, length) => {
2
+ const update = (length2) => p.style.strokeDasharray = `${length2} 100`;
3
+ update(length);
4
+ return { update };
5
+ };
6
+ </script>
7
+
1
8
  <script>import { tweened } from "svelte/motion";
2
9
  const d = "M 0 -15 L 15 -15 L 15 0 L 0 0 -9 0 A 6 8 135 0 1 9 0";
3
10
  const length = tweened(100);
@@ -11,23 +18,7 @@ const trigger = () => {
11
18
  $:
12
19
  0 === $length && trigger();
13
20
  </script>
14
- <style>
15
- svg {
16
- width: 100%;
17
- height: 100%;
18
- stroke-width: 4;
19
- stroke-linejoin: miter;
20
- stroke: currentColor;
21
- fill: transparent;
22
- }
23
- </style>
24
21
 
25
- <script context="module">const action = (p, length) => {
26
- const update = (length2) => p.style.strokeDasharray = `${length2} 100`;
27
- update(length);
28
- return { update };
29
- };
30
- </script>
31
22
  <svg viewBox="-35 -35 70 70" on:pointerenter={trigger}>
32
23
  <g transform="rotate(45 0 0)">
33
24
  <path {d} use:action={$length} />
@@ -37,3 +28,13 @@ $:
37
28
  </g>
38
29
  </svg>
39
30
 
31
+ <style>
32
+ svg {
33
+ width: 100%;
34
+ height: 100%;
35
+ stroke-width: 4;
36
+ stroke-linejoin: miter;
37
+ stroke: currentColor;
38
+ fill: transparent;
39
+ }
40
+ </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 NilDocProps = typeof __propDef.props;
10
+ export type NilDocEvents = typeof __propDef.events;
11
+ export type NilDocSlots = typeof __propDef.slots;
12
+ export default class NilDoc extends SvelteComponentTyped<NilDocProps, NilDocEvents, NilDocSlots> {
13
+ }
14
+ export {};
@@ -1,34 +1,3 @@
1
- <script>import { tweened } from "svelte/motion";
2
- export let dark = true;
3
- const values = tweened(dark ? vdark : vlight);
4
- $:
5
- $values = dark ? vdark : vlight;
6
- const index = indexer++;
7
- </script>
8
- <style>
9
- svg {
10
- fill: currentColor;
11
- stroke: currentColor;
12
-
13
- -webkit-tap-highlight-color: transparent;
14
- -moz-tap-highlight-color: transparent;
15
- -o-tap-highlight-color: transparent;
16
- /* tap-highlight-color: transparent; */
17
- }
18
-
19
- svg,
20
- rect {
21
- width: 100%;
22
- height: 100%;
23
- }
24
-
25
- line {
26
- stroke-width: 2;
27
- stroke-linecap: round;
28
- stroke-linejoin: round;
29
- }
30
- </style>
31
-
32
1
  <script context="module">let indexer = 0;
33
2
  const vlight = {
34
3
  rotate: 40,
@@ -43,6 +12,17 @@ const vdark = {
43
12
  v: 1
44
13
  };
45
14
  </script>
15
+
16
+ <script>import { tweened } from "svelte/motion";
17
+ export let theme = "dark";
18
+ $:
19
+ dark = theme === "dark";
20
+ const values = tweened(dark ? vdark : vlight);
21
+ $:
22
+ $values = dark ? vdark : vlight;
23
+ const index = indexer++;
24
+ </script>
25
+
46
26
  <svg class:dark viewBox="-25 -25 50 50" transform={`rotate(${$values.rotate})`}>
47
27
  <mask id={`nil_doc_theme_icon_${index}`}>
48
28
  <rect x="-25" y="-25" fill="white" />
@@ -65,3 +45,26 @@ const vdark = {
65
45
  </g>
66
46
  </svg>
67
47
 
48
+ <style>
49
+ svg {
50
+ fill: currentColor;
51
+ stroke: currentColor;
52
+
53
+ -webkit-tap-highlight-color: transparent;
54
+ -moz-tap-highlight-color: transparent;
55
+ -o-tap-highlight-color: transparent;
56
+ /* tap-highlight-color: transparent; */
57
+ }
58
+
59
+ svg,
60
+ rect {
61
+ width: 100%;
62
+ height: 100%;
63
+ }
64
+
65
+ line {
66
+ stroke-width: 2;
67
+ stroke-linecap: round;
68
+ stroke-linejoin: round;
69
+ }
70
+ </style>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Theme } from "../context";
3
+ declare const __propDef: {
4
+ props: {
5
+ theme?: Theme;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type ThemeProps = typeof __propDef.props;
13
+ export type ThemeEvents = typeof __propDef.events;
14
+ export type ThemeSlots = typeof __propDef.slots;
15
+ export default class Theme extends SvelteComponentTyped<ThemeProps, ThemeEvents, ThemeSlots> {
16
+ }
17
+ export {};