@nil-/doc 0.2.46 → 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.
Files changed (30) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/components/block/Instance.svelte +4 -0
  3. package/components/block/Instance.svelte.d.ts +1 -0
  4. package/components/block/controls/props/Component.svelte +34 -14
  5. package/components/block/controls/props/Number.svelte +4 -2
  6. package/components/block/controls/props/Number.svelte.d.ts +2 -2
  7. package/components/block/controls/props/Object.svelte +5 -3
  8. package/components/block/controls/props/Object.svelte.d.ts +2 -2
  9. package/components/block/controls/props/Props.svelte +5 -1
  10. package/components/block/controls/props/Range.svelte +39 -13
  11. package/components/block/controls/props/Range.svelte.d.ts +2 -2
  12. package/components/block/controls/props/Select.svelte +8 -4
  13. package/components/block/controls/props/Select.svelte.d.ts +2 -2
  14. package/components/block/controls/props/Switch.svelte +4 -2
  15. package/components/block/controls/props/Switch.svelte.d.ts +2 -2
  16. package/components/block/controls/props/Text.svelte +4 -2
  17. package/components/block/controls/props/Text.svelte.d.ts +2 -2
  18. package/components/block/controls/props/Tuple.svelte +22 -10
  19. package/components/block/controls/props/Tuple.svelte.d.ts +2 -2
  20. package/components/block/controls/props/misc/defaulter.d.ts +8 -8
  21. package/components/block/controls/props/misc/defaulter.js +58 -23
  22. package/components/block/controls/types.d.ts +71 -54
  23. package/components/etc/Container.svelte +4 -0
  24. package/components/navigation/types.d.ts +1 -1
  25. package/components/navigation/utils/renamer.d.ts +1 -5
  26. package/components/navigation/utils/renamer.js +2 -5
  27. package/components/navigation/utils/sorter.d.ts +1 -6
  28. package/components/navigation/utils/sorter.js +2 -6
  29. package/index.d.ts +1 -1
  30. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,10 +1,24 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.48
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc][fix] Fix type support ([#81](https://github.com/njaldea/mono/pull/81))
8
+
9
+ ## 0.2.47
10
+
11
+ ### Patch Changes
12
+
13
+ - [doc][docu] minor adjustments to documentation ([#79](https://github.com/njaldea/mono/pull/79))
14
+
15
+ - [doc][new] added support for flattened prop schema ([#79](https://github.com/njaldea/mono/pull/79))
16
+
3
17
  ## 0.2.46
4
18
 
5
19
  ### Patch Changes
6
20
 
7
- - [doc][new] added event control support ([#77](https://github.com/njaldea/mono/pull/77))
21
+ - [doc][break] added event control support ([#77](https://github.com/njaldea/mono/pull/77))
8
22
 
9
23
  ## 0.2.45
10
24
 
@@ -107,6 +107,10 @@ $:
107
107
  updateBound(defaults);
108
108
  let handlers;
109
109
  </script>
110
+ <!--
111
+ @component
112
+ See [documentation](https://mono-doc.vercel.app/3-Components/2-Block/1-Content/1-Instance) for more details.
113
+ -->
110
114
  <div
111
115
  class="instance"
112
116
  class:scale
@@ -19,6 +19,7 @@ declare class __sveltets_Render<PropArgs> {
19
19
  export type InstanceProps<PropArgs> = ReturnType<__sveltets_Render<PropArgs>['props']>;
20
20
  export type InstanceEvents<PropArgs> = ReturnType<__sveltets_Render<PropArgs>['events']>;
21
21
  export type InstanceSlots<PropArgs> = ReturnType<__sveltets_Render<PropArgs>['slots']>;
22
+ /** See [documentation](https://mono-doc.vercel.app/3-Components/2-Block/1-Content/1-Instance) for more details. */
22
23
  export default class Instance<PropArgs> extends SvelteComponentTyped<InstanceProps<PropArgs>, InstanceEvents<PropArgs>, InstanceSlots<PropArgs>> {
23
24
  }
24
25
  export {};
@@ -12,18 +12,38 @@ export let depth;
12
12
  export let disabled = false;
13
13
  export let visible = false;
14
14
  </script>
15
- {#if "object" === info.type}
16
- <Object {info} bind:value {depth} {disabled} {visible} />
17
- {:else if "tuple" === info.type}
18
- <Tuple {info} bind:value {depth} {disabled} {visible} />
19
- {:else if "text" === info.type}
20
- <Text {info} bind:value {depth} {disabled} {visible} />
21
- {:else if "number" === info.type}
22
- <Number {info} bind:value {depth} {disabled} {visible} />
23
- {:else if "range" === info.type}
24
- <Range {info} bind:value {depth} {disabled} {visible} />
25
- {:else if "select" === info.type}
26
- <Select {info} bind:value {depth} {disabled} {visible} />
27
- {:else if "switch" === info.type}
28
- <Switch {info} bind:value {depth} {disabled} {visible} />
15
+ {#if info instanceof Array}
16
+ {@const type = info[1]}
17
+ {#if "object" === type}
18
+ <Object {info} bind:value {depth} {disabled} {visible} />
19
+ {:else if "tuple" === type}
20
+ <Tuple {info} bind:value {depth} {disabled} {visible} />
21
+ {:else if "text" === type}
22
+ <Text {info} bind:value {depth} {disabled} {visible} />
23
+ {:else if "number" === type}
24
+ <Number {info} bind:value {depth} {disabled} {visible} />
25
+ {:else if "range" === type}
26
+ <Range {info} bind:value {depth} {disabled} {visible} />
27
+ {:else if "select" === type}
28
+ <Select {info} bind:value {depth} {disabled} {visible} />
29
+ {:else if "switch" === type}
30
+ <Switch {info} bind:value {depth} {disabled} {visible} />
31
+ {/if}
32
+ {:else}
33
+ {@const type = info.type}
34
+ {#if "object" === type}
35
+ <Object {info} bind:value {depth} {disabled} {visible} />
36
+ {:else if "tuple" === type}
37
+ <Tuple {info} bind:value {depth} {disabled} {visible} />
38
+ {:else if "text" === type}
39
+ <Text {info} bind:value {depth} {disabled} {visible} />
40
+ {:else if "number" === type}
41
+ <Number {info} bind:value {depth} {disabled} {visible} />
42
+ {:else if "range" === type}
43
+ <Range {info} bind:value {depth} {disabled} {visible} />
44
+ {:else if "select" === type}
45
+ <Select {info} bind:value {depth} {disabled} {visible} />
46
+ {:else if "switch" === type}
47
+ <Switch {info} bind:value {depth} {disabled} {visible} />
48
+ {/if}
29
49
  {/if}
@@ -1,6 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
- import Name from "./misc/Name.svelte";
3
+ import NameHeader from "./misc/Name.svelte";
4
4
  export let value;
5
5
  export let info;
6
6
  export let depth;
@@ -10,10 +10,12 @@ let ivalue = value ?? getDefault(info);
10
10
  let enabled = value !== void 0;
11
11
  $:
12
12
  value = enabled && !disabled ? ivalue : void 0;
13
+ $:
14
+ name = info instanceof Array ? info[0] : info.name;
13
15
  </script>
14
16
  {#if visible}
15
17
  <div>
16
- <Name name={info.name} {depth} />
18
+ <NameHeader {name} {depth} />
17
19
  <div><input type="number" bind:value={ivalue} disabled={!enabled || disabled} /></div>
18
20
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
19
21
  </div>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { PropNumber } from "../types";
2
+ import type { Unionized, PropType } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  value: number | undefined;
6
- info: PropNumber;
6
+ info: Unionized<PropType<"number">>;
7
7
  depth: number;
8
8
  disabled?: boolean | undefined;
9
9
  visible?: boolean | undefined;
@@ -13,13 +13,15 @@ let expand = info.values.length > 0 ? true : void 0;
13
13
  $:
14
14
  value = !disabled && enabled ? ivalue : void 0;
15
15
  $:
16
- values = info.values;
16
+ values = info instanceof Array ? info[2] : info.values;
17
+ $:
18
+ name = info instanceof Array ? info[0] : info.name;
17
19
  </script>
18
- <Header name={info.name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
20
+ <Header {name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
19
21
  {#each values as info, i (i)}
20
22
  <Component
21
23
  {info}
22
- bind:value={ivalue[info.name]}
24
+ bind:value={ivalue[name]}
23
25
  depth={depth + 10}
24
26
  disabled={!enabled || disabled}
25
27
  visible={visible && expand && enabled && !disabled}
@@ -1,10 +1,10 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { ValueType } from "../../types";
3
- import type { PropObject } from "../types";
3
+ import type { Unionized, PropType } from "../types";
4
4
  declare const __propDef: {
5
5
  props: {
6
6
  value: Record<string, ValueType> | undefined;
7
- info: PropObject;
7
+ info: Unionized<PropType<"object">>;
8
8
  depth: number;
9
9
  disabled?: boolean | undefined;
10
10
  visible?: boolean | undefined;
@@ -10,6 +10,10 @@ export let visible;
10
10
  <slot />
11
11
  {/if}
12
12
  {#each infos as info}
13
- <Component {info} bind:value={values[info.name]} depth={10} {visible} />
13
+ {#if info instanceof Array}
14
+ <Component {info} bind:value={values[info[0]]} depth={10} {visible} />
15
+ {:else}
16
+ <Component {info} bind:value={values[info.name]} depth={10} {visible} />
17
+ {/if}
14
18
  {/each}
15
19
  </Styler>
@@ -2,7 +2,7 @@
2
2
  .input {
3
3
  width: 100%;
4
4
  display: grid;
5
- grid-template-columns: 40px 1fr;
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: right;
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) {
@@ -33,7 +35,7 @@
33
35
  </style>
34
36
 
35
37
  <script>import { getDefault } from "./misc/defaulter";
36
- import Name from "./misc/Name.svelte";
38
+ import NameHeader from "./misc/Name.svelte";
37
39
  export let value;
38
40
  export let info;
39
41
  export let depth;
@@ -44,23 +46,47 @@ let enabled = value !== void 0;
44
46
  $:
45
47
  value = enabled && !disabled ? ivalue : void 0;
46
48
  $:
47
- flag = !enabled || disabled;
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
+ };
48
73
  </script>
49
74
  {#if visible}
50
75
  <div>
51
- <Name name={info.name} {depth} />
76
+ <NameHeader name={i.name} {depth} />
52
77
  <div class="input">
53
- <div class="tooltip" class:disabled={flag}>
54
- Current Value: {ivalue}
78
+ <div class="tooltip" class:disabled={!enabled || disabled}>
79
+ <div>Current Value:</div>
80
+ <div>{format(ivalue, 6, 3)}</div>
55
81
  </div>
56
- <div>{ivalue.toFixed(2)}</div>
82
+ <div>{format(ivalue, 1, 1)}</div>
57
83
  <input
58
84
  type="range"
59
85
  bind:value={ivalue}
60
- min={info.min}
61
- max={info.max}
62
- step={info.step}
63
- disabled={flag}
86
+ min={i.min}
87
+ max={i.max}
88
+ step={i.step}
89
+ disabled={!enabled || disabled}
64
90
  />
65
91
  </div>
66
92
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { PropRange } from "../types";
2
+ import type { Unionized, PropType } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  value: number | undefined;
6
- info: PropRange;
6
+ info: Unionized<PropType<"range">>;
7
7
  depth: number;
8
8
  disabled?: boolean | undefined;
9
9
  visible?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
- import Name from "./misc/Name.svelte";
3
+ import NameHeader from "./misc/Name.svelte";
4
4
  export let value;
5
5
  export let info;
6
6
  export let depth;
@@ -10,14 +10,18 @@ let ivalue = value ?? getDefault(info);
10
10
  let enabled = value !== void 0;
11
11
  $:
12
12
  value = enabled && !disabled ? ivalue : void 0;
13
+ $:
14
+ name = info instanceof Array ? info[0] : info.name;
15
+ $:
16
+ values = info instanceof Array ? info[2] : info.values;
13
17
  </script>
14
18
  {#if visible}
15
19
  <div>
16
- <Name name={info.name} {depth} />
20
+ <NameHeader {name} {depth} />
17
21
  <div>
18
22
  <select bind:value={ivalue} disabled={!enabled || disabled}>
19
- {#each info.values as value}
20
- <option {value}>{value}</option>
23
+ {#each values as v}
24
+ <option value={v}>{v}</option>
21
25
  {/each}
22
26
  </select>
23
27
  </div>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { PropSelect } from "../types";
2
+ import type { Unionized, PropType } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  value: string | undefined;
6
- info: PropSelect;
6
+ info: Unionized<PropType<"select">>;
7
7
  depth: number;
8
8
  disabled?: boolean | undefined;
9
9
  visible?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
- import Name from "./misc/Name.svelte";
3
+ import NameHeader from "./misc/Name.svelte";
4
4
  export let value;
5
5
  export let info;
6
6
  export let depth;
@@ -10,10 +10,12 @@ let ivalue = value ?? getDefault(info);
10
10
  let enabled = value !== void 0;
11
11
  $:
12
12
  value = enabled && !disabled ? ivalue : void 0;
13
+ $:
14
+ name = info instanceof Array ? info[0] : info.name;
13
15
  </script>
14
16
  {#if visible}
15
17
  <div>
16
- <Name name={info.name} {depth} />
18
+ <NameHeader {name} {depth} />
17
19
  <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled || disabled} /></div>
18
20
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
19
21
  </div>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { PropSwitch } from "../types";
2
+ import type { Unionized, PropType } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  value: boolean | undefined;
6
- info: PropSwitch;
6
+ info: Unionized<PropType<"switch">>;
7
7
  depth: number;
8
8
  disabled?: boolean | undefined;
9
9
  visible?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
- import Name from "./misc/Name.svelte";
3
+ import NameHeader from "./misc/Name.svelte";
4
4
  export let value;
5
5
  export let info;
6
6
  export let depth;
@@ -10,10 +10,12 @@ let ivalue = value ?? getDefault(info);
10
10
  let ienabled = value !== void 0;
11
11
  $:
12
12
  value = ienabled && !disabled ? ivalue : void 0;
13
+ $:
14
+ name = info instanceof Array ? info[0] : info.name;
13
15
  </script>
14
16
  {#if visible}
15
17
  <div>
16
- <Name name={info.name} {depth} />
18
+ <NameHeader {name} {depth} />
17
19
  <div><input type="text" bind:value={ivalue} disabled={!ienabled || disabled} /></div>
18
20
  <div><input type="checkbox" bind:checked={ienabled} {disabled} /></div>
19
21
  </div>
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { PropText } from "../types";
2
+ import type { Unionized, PropType } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  value: string | undefined;
6
- info: PropText;
6
+ info: Unionized<PropType<"text">>;
7
7
  depth: number;
8
8
  disabled?: boolean | undefined;
9
9
  visible?: boolean | undefined;
@@ -12,16 +12,28 @@ let enabled = value !== void 0;
12
12
  $:
13
13
  value = !disabled && enabled ? ivalue : void 0;
14
14
  $:
15
- values = info.values;
15
+ values = info instanceof Array ? info[2] : info.values;
16
+ $:
17
+ name = info instanceof Array ? info[0] : info.name;
16
18
  let expand = info.values.length > 0 ? true : void 0;
17
19
  </script>
18
- <Header name={info.name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
19
- {#each values as info, i (i)}
20
- <Component
21
- info={{ ...info, name: `${i}` }}
22
- bind:value={ivalue[i]}
23
- depth={depth + 10}
24
- disabled={!enabled || disabled}
25
- visible={visible && expand && enabled && !disabled}
26
- />
20
+ <Header {name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
21
+ {#each values as v, i (i)}
22
+ {#if v instanceof Array}
23
+ <Component
24
+ info={[`${i}`, ...v]}
25
+ bind:value={ivalue[i]}
26
+ depth={depth + 10}
27
+ disabled={!enabled || disabled}
28
+ visible={visible && expand && enabled && !disabled}
29
+ />
30
+ {:else}
31
+ <Component
32
+ info={{ ...v, name: `${i}` }}
33
+ bind:value={ivalue[i]}
34
+ depth={depth + 10}
35
+ disabled={!enabled || disabled}
36
+ visible={visible && expand && enabled && !disabled}
37
+ />
38
+ {/if}
27
39
  {/each}
@@ -1,10 +1,10 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { ValueType } from "../../types";
3
- import type { PropTuple } from "../types";
3
+ import type { Unionized, PropType } from "../types";
4
4
  declare const __propDef: {
5
5
  props: {
6
6
  value: ValueType[] | undefined;
7
- info: PropTuple;
7
+ info: Unionized<PropType<"tuple">>;
8
8
  depth: number;
9
9
  disabled?: boolean | undefined;
10
10
  visible?: boolean | undefined;
@@ -1,10 +1,10 @@
1
1
  import type { ValueType } from "../../../types";
2
- import type { Prop, PropNumber, PropRange, PropSelect, PropSwitch, PropText, PropTuple, PropObject } from "../../types";
3
- export declare function getDefault(i: PropTuple): ValueType[];
4
- export declare function getDefault(i: PropObject): Record<string, ValueType>;
5
- export declare function getDefault(i: PropNumber): number;
6
- export declare function getDefault(i: PropRange): number;
7
- export declare function getDefault(i: PropSelect): string;
8
- export declare function getDefault(i: PropText): string;
9
- export declare function getDefault(i: PropSwitch): 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;
10
10
  export declare function getDefault(i: Prop): ValueType;
@@ -1,36 +1,71 @@
1
1
  // eslint-disable-next-line func-style
2
2
  export function getDefault(i) {
3
- switch (i.type) {
4
- case "object":
5
- // eslint-disable-next-line no-use-before-define
6
- return getObjectDefaults(i);
7
- case "tuple":
8
- // eslint-disable-next-line no-use-before-define
9
- return getTupleDefaults(i);
10
- case "text":
11
- return "";
12
- case "select":
13
- return i.values.length > 0 ? i.values[0] : "";
14
- case "number":
15
- return 0;
16
- case "range":
17
- return i.min;
18
- case "switch":
19
- default:
20
- return false;
3
+ if (i instanceof Array) {
4
+ switch (i[1]) {
5
+ case "object":
6
+ // eslint-disable-next-line no-use-before-define
7
+ return getObjectDefaults(i);
8
+ case "tuple":
9
+ // eslint-disable-next-line no-use-before-define
10
+ return getTupleDefaults(i);
11
+ case "text":
12
+ return "";
13
+ case "select":
14
+ return i[2].length > 0 ? i[2][0] : "";
15
+ case "number":
16
+ return 0;
17
+ case "range":
18
+ return i[2];
19
+ case "switch":
20
+ default:
21
+ return false;
22
+ }
23
+ }
24
+ else {
25
+ switch (i.type) {
26
+ case "object":
27
+ // eslint-disable-next-line no-use-before-define
28
+ return getObjectDefaults(i);
29
+ case "tuple":
30
+ // eslint-disable-next-line no-use-before-define
31
+ return getTupleDefaults(i);
32
+ case "text":
33
+ return "";
34
+ case "select":
35
+ return i.values.length > 0 ? i.values[0] : "";
36
+ case "number":
37
+ return 0;
38
+ case "range":
39
+ return i.min;
40
+ case "switch":
41
+ default:
42
+ return false;
43
+ }
21
44
  }
22
45
  }
23
46
  const getObjectDefaults = (info) => {
24
47
  const ret = {};
25
- for (const i of info.values) {
26
- ret[i.name] = getDefault(i);
48
+ const values = info instanceof Array ? info[2] : info.values;
49
+ for (const v of values) {
50
+ if (v instanceof Array) {
51
+ ret[v[0]] = getDefault(v);
52
+ }
53
+ else {
54
+ ret[v.name] = getDefault(v);
55
+ }
27
56
  }
28
57
  return ret;
29
58
  };
30
- const getTupleDefaults = (i) => {
59
+ const getTupleDefaults = (info) => {
31
60
  const ret = [];
32
- for (const info of i.values) {
33
- ret.push(getDefault(info));
61
+ const values = info instanceof Array ? info[2] : info.values;
62
+ for (const [i, v] of values.entries()) {
63
+ if (v instanceof Array) {
64
+ ret.push(getDefault([`${i}`, ...v]));
65
+ }
66
+ else {
67
+ ret.push(getDefault({ name: `${i}`, ...v }));
68
+ }
34
69
  }
35
70
  return ret;
36
71
  };
@@ -1,62 +1,79 @@
1
- export type PropTuple = {
2
- name: string;
3
- type: "tuple";
4
- // eslint-disable-next-line no-use-before-define
5
- values: NonNamedProp[];
6
- };
7
-
8
- export type PropObject = {
9
- name: string;
10
- type: "object";
11
- // eslint-disable-next-line no-use-before-define
12
- values: Prop[];
13
- };
14
-
15
- export type PropText = {
16
- name: string;
17
- type: "text";
18
- };
1
+ type Types = "text" | "number" | "select" | "range" | "switch" | "tuple" | "object";
19
2
 
20
- export type PropNumber = {
21
- name: string;
22
- type: "number";
23
- };
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;
24
38
 
25
- export type PropRange = {
26
- name: string;
27
- type: "range";
28
- min: number;
29
- max: number;
30
- step: number;
31
- };
32
-
33
- export type PropSelect = {
34
- name: string;
35
- type: "select";
36
- values: string[];
37
- };
38
-
39
- export type PropSwitch = {
40
- name: string;
41
- type: "switch";
42
- };
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];
43
42
 
43
+ // prettier-ignore
44
44
  export type Prop =
45
- | PropTuple
46
- | PropObject
47
- | PropText
48
- | PropNumber
49
- | PropRange
50
- | PropSelect
51
- | PropSwitch;
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[]; };
52
61
 
62
+ // prettier-ignore
53
63
  type NonNamedProp =
54
- | Omit<PropTuple, "name">
55
- | Omit<PropObject, "name">
56
- | Omit<PropText, "name">
57
- | Omit<PropNumber, "name">
58
- | Omit<PropRange, "name">
59
- | Omit<PropSelect, "name">
60
- | Omit<PropSwitch, "name">;
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[]; };
61
78
 
62
79
  export type Event = string;
@@ -76,18 +76,22 @@
76
76
  background-color: var(--color-p);
77
77
  }
78
78
 
79
+ .container:not(.b):not(.vertical) > .divider:hover,
79
80
  .container.moving:not(.b):not(.vertical) > .divider {
80
81
  border-bottom: var(--color-s) solid 2.5px;
81
82
  }
82
83
 
84
+ .container.b:not(.vertical) > .divider:hover,
83
85
  .container.moving.b:not(.vertical) > .divider {
84
86
  border-top: var(--color-s) solid 2.5px;
85
87
  }
86
88
 
89
+ .container:not(.b).vertical > .divider:hover,
87
90
  .container.moving:not(.b).vertical > .divider {
88
91
  border-right: var(--color-s) solid 2.5px;
89
92
  }
90
93
 
94
+ .container.vertical.b > .divider:hover,
91
95
  .container.moving.vertical.b > .divider {
92
96
  border-left: var(--color-s) solid 2.5px;
93
97
  }
@@ -8,5 +8,5 @@ export type States = {
8
8
  sub: Record<string, States>;
9
9
  };
10
10
 
11
- export type Sorter = (l: string, r: string) => 1 | 0 | -1;
11
+ export type Sorter = (l: string, r: string) => -1 | 0 | 1;
12
12
  export type Renamer = (s: string) => string;
@@ -1,9 +1,5 @@
1
- import type { Renamer } from "../types";
2
1
  /**
3
2
  * If a text follows `<I>-<Name>` format,
4
3
  * this method simply removes the Prefix.
5
- *
6
- * @param text
7
- * @returns `<Name>`
8
4
  */
9
- export declare const renamer: Renamer;
5
+ export declare const renamer: (text: string) => string;
@@ -2,14 +2,11 @@ const match = /(\d+)-(.+)/;
2
2
  /**
3
3
  * If a text follows `<I>-<Name>` format,
4
4
  * this method simply removes the Prefix.
5
- *
6
- * @param text
7
- * @returns `<Name>`
8
5
  */
9
- export const renamer = (text) => {
6
+ export const renamer = ((text) => {
10
7
  const m = match.exec(text);
11
8
  if (m) {
12
9
  return m[2];
13
10
  }
14
11
  return text;
15
- };
12
+ });
@@ -1,4 +1,3 @@
1
- import type { Sorter } from "../types";
2
1
  /**
3
2
  * Compares two texts for sorting.
4
3
  *
@@ -9,9 +8,5 @@ import type { Sorter } from "../types";
9
8
  * the text that follows the format is considered as higher in order.
10
9
  *
11
10
  * Else comparison is done using built-in `string` comparison.
12
- *
13
- * @param l - left operand
14
- * @param r - right operand
15
- * @returns `-1 | 0 | +1`
16
11
  */
17
- export declare const sorter: Sorter;
12
+ export declare const sorter: (l: string, r: string) => -1 | 0 | 1;
@@ -18,12 +18,8 @@ const sorterT = (l, r) => {
18
18
  * the text that follows the format is considered as higher in order.
19
19
  *
20
20
  * Else comparison is done using built-in `string` comparison.
21
- *
22
- * @param l - left operand
23
- * @param r - right operand
24
- * @returns `-1 | 0 | +1`
25
21
  */
26
- export const sorter = (l, r) => {
22
+ export const sorter = ((l, r) => {
27
23
  const lmatch = match.exec(l);
28
24
  const rmatch = match.exec(r);
29
25
  if (null == lmatch && null == rmatch) {
@@ -36,4 +32,4 @@ export const sorter = (l, r) => {
36
32
  return -1;
37
33
  }
38
34
  return sorterT(parseInt(lmatch[1]), parseInt(rmatch[1])) || sorterT(lmatch[2], rmatch[2]);
39
- };
35
+ });
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";
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.46",
3
+ "version": "0.2.48",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
7
7
  },
8
8
  "license": "ISC",
9
9
  "devDependencies": {
10
- "@sveltejs/adapter-vercel": "^1.0.0",
11
- "@sveltejs/kit": "^1.0.5",
10
+ "@sveltejs/adapter-vercel": "^1.0.5",
11
+ "@sveltejs/kit": "^1.3.2",
12
12
  "@sveltejs/package": "^1.0.2",
13
13
  "@vitest/coverage-c8": "^0.26.3",
14
14
  "mdsvex": "^0.10.6",
15
15
  "remark-admonitions": "^1.2.1",
16
16
  "svelte-check": "^2.10.3",
17
- "tslib": "^2.4.1",
17
+ "tslib": "^2.5.0",
18
18
  "typescript": "^4.9.4",
19
19
  "vite": "^4.0.4",
20
20
  "vitest": "^0.26.3"
21
21
  },
22
22
  "peerDependencies": {
23
- "svelte": "^3.55.0"
23
+ "svelte": "^3.55.1"
24
24
  },
25
25
  "publishConfig": {
26
26
  "linkDirectory": true