@nil-/doc 0.2.12 → 0.2.14

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 (35) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/components/block/Block.svelte +2 -1
  3. package/components/block/Params.svelte +9 -2
  4. package/components/block/Template.svelte +10 -13
  5. package/components/block/context.d.ts +4 -8
  6. package/components/block/context.js +2 -1
  7. package/components/block/controls/Component.svelte +22 -64
  8. package/components/block/controls/Component.svelte.d.ts +4 -3
  9. package/components/block/controls/Controls.svelte +42 -0
  10. package/components/block/controls/Controls.svelte.d.ts +19 -0
  11. package/components/block/controls/Header.svelte +12 -0
  12. package/components/block/controls/Header.svelte.d.ts +23 -0
  13. package/components/block/controls/Number.svelte +8 -4
  14. package/components/block/controls/Number.svelte.d.ts +2 -0
  15. package/components/block/controls/Object.svelte +29 -0
  16. package/components/block/controls/Object.svelte.d.ts +20 -0
  17. package/components/block/controls/Range.svelte +24 -14
  18. package/components/block/controls/Range.svelte.d.ts +2 -0
  19. package/components/block/controls/Select.svelte +12 -8
  20. package/components/block/controls/Select.svelte.d.ts +2 -0
  21. package/components/block/controls/Switch.svelte +8 -4
  22. package/components/block/controls/Switch.svelte.d.ts +2 -0
  23. package/components/block/controls/Text.svelte +9 -5
  24. package/components/block/controls/Text.svelte.d.ts +2 -0
  25. package/components/block/controls/Tuple.svelte +29 -0
  26. package/components/block/controls/Tuple.svelte.d.ts +20 -0
  27. package/components/block/controls/defaulter.d.ts +4 -0
  28. package/components/block/controls/defaulter.js +35 -0
  29. package/components/block/controls/types.d.ts +30 -1
  30. package/components/load.js +23 -6
  31. package/components/navigation/Nav.svelte +14 -0
  32. package/components/navigation/Node.svelte +13 -19
  33. package/package.json +5 -5
  34. package/components/etc/Font.svelte +0 -5
  35. package/components/etc/Font.svelte.d.ts +0 -23
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 6265fa6: [doc] added Tuple and Object Controls
8
+ [doc] added temporary internal doc
9
+
10
+ ## 0.2.13
11
+
12
+ ### Patch Changes
13
+
14
+ - 39dbce9: [doc] navigation now automatically opens when redirected to a route that is still collapsed
15
+
3
16
  ## 0.2.12
4
17
 
5
18
  ### Patch Changes
@@ -1,8 +1,9 @@
1
- <script>import { initCurrent, initParams, initControls } from "./context";
1
+ <script>import { initCurrent, initParams, initControls, initDefaults } from "./context";
2
2
  import { inRoot } from "../context";
3
3
  initParams();
4
4
  initCurrent();
5
5
  initControls();
6
+ initDefaults();
6
7
  const r = inRoot();
7
8
  </script>
8
9
  <style>
@@ -1,6 +1,13 @@
1
1
 
2
- <script>import { getParams } from "./context";
2
+ <script>import { getParams, getDefaults } from "./context";
3
3
  export let tag;
4
4
  export let props = {};
5
- getParams().update((v) => [...v, { id: v.length, tag, values: props }]);
5
+ const defaults = getDefaults();
6
+ const params = getParams();
7
+ function set(tag, props) {
8
+ if ($defaults != null) {
9
+ $params[tag] = { ...$defaults, ...props };
10
+ }
11
+ }
12
+ $: set(tag, props);
6
13
  </script>
@@ -23,10 +23,6 @@
23
23
  background-color: rgb(33, 36, 37);
24
24
  }
25
25
 
26
- .content > :global(*) {
27
- all: initial;
28
- }
29
-
30
26
  .misc {
31
27
  margin-top: 2px;
32
28
  outline: rgb(100, 96, 96) solid 1px;
@@ -38,13 +34,14 @@
38
34
  <svelte:window on:click={() => ($current = null)} />
39
35
 
40
36
  <script>import { beforeUpdate } from "svelte";
41
- import { getParams, getCurrent, getControls } from "./context";
42
- import Controls from "./controls/Component.svelte";
37
+ import { getParams, getCurrent, getControls, getDefaults } from "./context";
38
+ import Controls from "./controls/Controls.svelte";
43
39
  import { slide } from "svelte/transition";
44
40
  const params = getParams();
45
41
  const current = getCurrent();
46
42
  const controls = getControls();
47
43
  export let defaults;
44
+ getDefaults().set(defaults);
48
45
  $: keys = Object.keys(defaults);
49
46
  function resolve(d, p) {
50
47
  if (d === undefined) {
@@ -75,28 +72,28 @@ let key = false;
75
72
  beforeUpdate(() => (key = !key));
76
73
  </script>
77
74
  <div class="template">
78
- {#each $params as { id, tag, values } (id)}
75
+ {#each Object.keys($params) as tag (tag)}
79
76
  <div
80
77
  class="instance"
81
- on:click|stopPropagation={() => ($current = id)}
82
- on:mouseenter={() => (hovered = id)}
78
+ on:click|stopPropagation={() => ($current = tag)}
79
+ on:mouseenter={() => (hovered = tag)}
83
80
  on:mouseleave={() => (hovered = null)}
84
81
  on:keypress={null}
85
82
  >
86
83
  {#if noreset}
87
84
  <div class="content nil-doc-scrollable">
88
- <slot {tag} props={resolve(defaults, values)} />
85
+ <slot {tag} props={resolve(defaults, $params[tag])} />
89
86
  </div>
90
87
  {:else}
91
88
  {#key key}
92
89
  <div class="content nil-doc-scrollable">
93
- <slot {tag} props={resolve(defaults, values)} />
90
+ <slot {tag} props={resolve(defaults, $params[tag])} />
94
91
  </div>
95
92
  {/key}
96
93
  {/if}
97
- {#if $controls.length > 0 && ($current === id || hovered === id)}
94
+ {#if $controls.length > 0 && ($current === tag || hovered === tag)}
98
95
  <div class="misc nil-doc-scrollable" transition:slide>
99
- <Controls infos={$controls} bind:values />
96
+ <Controls infos={$controls} bind:values={$params[tag]} />
100
97
  </div>
101
98
  {/if}
102
99
  </div>
@@ -1,11 +1,7 @@
1
1
  import type { Control } from "./controls/types";
2
2
  import type { Writable } from "svelte/store";
3
- export type ParamValues = Record<string, any>;
4
- export type Params = {
5
- id: number;
6
- tag: string;
7
- values: ParamValues;
8
- };
9
- export declare const initCurrent: () => Writable<number | null>, getCurrent: () => Writable<number | null>;
10
- export declare const initParams: () => Writable<Params[]>, getParams: () => Writable<Params[]>;
3
+ export type Params = Record<string, any>;
4
+ export declare const initCurrent: () => Writable<string | null>, getCurrent: () => Writable<string | null>;
5
+ export declare const initParams: () => Writable<Params>, getParams: () => Writable<Params>;
11
6
  export declare const initControls: () => Writable<Control[]>, getControls: () => Writable<Control[]>;
7
+ export declare const initDefaults: () => Writable<Params | null>, getDefaults: () => Writable<Params | null>;
@@ -8,5 +8,6 @@ function create(defaulter) {
8
8
  };
9
9
  }
10
10
  export const { init: initCurrent, get: getCurrent } = create(() => null);
11
- export const { init: initParams, get: getParams } = create(() => []);
11
+ export const { init: initParams, get: getParams } = create(() => ({}));
12
12
  export const { init: initControls, get: getControls } = create(() => []);
13
+ export const { init: initDefaults, get: getDefaults } = create(() => null);
@@ -1,71 +1,29 @@
1
- <style>
2
- .controls {
3
- width: 100%;
4
- display: grid;
5
- grid-auto-rows: 1fr;
6
- }
7
-
8
- .header {
9
- text-align: center;
10
- }
11
-
12
- .row {
13
- width: 100%;
14
- display: grid;
15
- padding: 2px 0px;
16
- grid-template-columns: 1fr 200px 75px;
17
- background-color: hsl(205, 50%, 5%);
18
- }
19
-
20
- .row:nth-child(even) {
21
- background-color: hsl(205, 15%, 15%);
22
- }
23
-
24
- .row > :global(div:nth-child(1)) {
25
- padding-left: 10px;
26
- }
27
-
28
- .row > :global(div) {
29
- display: grid;
30
- align-items: center;
31
- }
32
-
33
- .row > :global(div > *) {
34
- width: 100%;
35
- height: 100%;
36
- }
37
- </style>
38
1
 
39
2
  <script>import Text from "./Text.svelte";
40
3
  import Number from "./Number.svelte";
41
4
  import Range from "./Range.svelte";
42
5
  import Switch from "./Switch.svelte";
43
6
  import Select from "./Select.svelte";
44
- export let infos;
45
- export let values;
7
+ import Tuple from "./Tuple.svelte";
8
+ import Object from "./Object.svelte";
9
+ export let info;
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ export let value;
12
+ export let depth = 10;
13
+ export let disabled = false;
46
14
  </script>
47
- <div class="controls">
48
- <div class="row">
49
- <div class="header">Name</div>
50
- <div class="header">Value</div>
51
- <div class="header">Use</div>
52
- </div>
53
- {#each infos as info}
54
- {@const type = info.type}
55
- {@const name = info.name}
56
- <div class="row">
57
- {#if type === "text"}
58
- <Text {info} bind:value={values[name]} />
59
- {:else if type === "number"}
60
- <Number {info} bind:value={values[name]} />
61
- {:else if type === "range"}
62
- <Range {info} bind:value={values[name]} />
63
- {:else if type === "select"}
64
- <Select {info} bind:value={values[name]} />
65
- {:else if type === "switch"}
66
- <Switch {info} bind:value={values[name]} />
67
- {/if}
68
- </div>
69
- {/each}
70
- </div>
71
-
15
+ {#if info.type === "object"}
16
+ <Object {info} bind:value {depth} {disabled} />
17
+ {:else if info.type === "tuple"}
18
+ <Tuple {info} bind:value {depth} {disabled} />
19
+ {:else if info.type === "text"}
20
+ <Text {info} bind:value {depth} {disabled} />
21
+ {:else if info.type === "number"}
22
+ <Number {info} bind:value {depth} {disabled} />
23
+ {:else if info.type === "range"}
24
+ <Range {info} bind:value {depth} {disabled} />
25
+ {:else if info.type === "select"}
26
+ <Select {info} bind:value {depth} {disabled} />
27
+ {:else if info.type === "switch"}
28
+ <Switch {info} bind:value {depth} {disabled} />
29
+ {/if}
@@ -1,10 +1,11 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { Control } from "./types";
3
- import type { ParamValues } from "../context";
4
3
  declare const __propDef: {
5
4
  props: {
6
- infos: Control[];
7
- values: ParamValues;
5
+ info: Control;
6
+ value: any;
7
+ depth?: number | undefined;
8
+ disabled?: boolean | undefined;
8
9
  };
9
10
  events: {
10
11
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,42 @@
1
+ <style>
2
+ .controls {
3
+ width: 100%;
4
+ display: grid;
5
+ grid-auto-rows: 1fr;
6
+ }
7
+
8
+ .controls > :global(div) {
9
+ width: 100%;
10
+ display: grid;
11
+ padding: 2px 0px;
12
+ grid-template-columns: 1fr 200px 75px;
13
+ background-color: hsl(205, 50%, 5%);
14
+ }
15
+
16
+ .controls > :global(div:nth-child(even)) {
17
+ background-color: hsl(205, 15%, 15%);
18
+ }
19
+
20
+ .controls > :global(div > div) {
21
+ display: grid;
22
+ align-items: center;
23
+ }
24
+
25
+ .controls > :global(div > div > *) {
26
+ width: 100%;
27
+ height: 100%;
28
+ }
29
+ </style>
30
+
31
+ <script>import Header from "./Header.svelte";
32
+ import Component from "./Component.svelte";
33
+ export let infos;
34
+ export let values;
35
+ </script>
36
+ <div class="controls">
37
+ <Header />
38
+ {#each infos as info}
39
+ <Component {info} bind:value={values[info.name]} />
40
+ {/each}
41
+ </div>
42
+
@@ -0,0 +1,19 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Control } from "./types";
3
+ import type { Params } from "../context";
4
+ declare const __propDef: {
5
+ props: {
6
+ infos: Control[];
7
+ values: Params;
8
+ };
9
+ events: {
10
+ [evt: string]: CustomEvent<any>;
11
+ };
12
+ slots: {};
13
+ };
14
+ export type ControlsProps = typeof __propDef.props;
15
+ export type ControlsEvents = typeof __propDef.events;
16
+ export type ControlsSlots = typeof __propDef.slots;
17
+ export default class Controls extends SvelteComponentTyped<ControlsProps, ControlsEvents, ControlsSlots> {
18
+ }
19
+ export {};
@@ -0,0 +1,12 @@
1
+ <style>
2
+ div > div {
3
+ text-align: center;
4
+ }
5
+ </style>
6
+
7
+ <div>
8
+ <div>Name</div>
9
+ <div>Value</div>
10
+ <div>Use</div>
11
+ </div>
12
+
@@ -0,0 +1,23 @@
1
+ /** @typedef {typeof __propDef.props} HeaderProps */
2
+ /** @typedef {typeof __propDef.events} HeaderEvents */
3
+ /** @typedef {typeof __propDef.slots} HeaderSlots */
4
+ export default class Header extends SvelteComponentTyped<{
5
+ [x: string]: never;
6
+ }, {
7
+ [evt: string]: CustomEvent<any>;
8
+ }, {}> {
9
+ }
10
+ export type HeaderProps = typeof __propDef.props;
11
+ export type HeaderEvents = typeof __propDef.events;
12
+ export type HeaderSlots = typeof __propDef.slots;
13
+ import { SvelteComponentTyped } from "svelte";
14
+ declare const __propDef: {
15
+ props: {
16
+ [x: string]: never;
17
+ };
18
+ events: {
19
+ [evt: string]: CustomEvent<any>;
20
+ };
21
+ slots: {};
22
+ };
23
+ export {};
@@ -1,10 +1,14 @@
1
1
 
2
2
  <script>export let value;
3
3
  export let info;
4
+ export let depth;
5
+ export let disabled = false;
4
6
  let ivalue = value ?? 0;
5
7
  let enabled = value !== undefined;
6
- $: value = enabled ? ivalue : undefined;
8
+ $: value = enabled && !disabled ? ivalue : undefined;
7
9
  </script>
8
- <div>{info.name}</div>
9
- <div><input type="number" bind:value={ivalue} disabled={!enabled} /></div>
10
- <div><input type="checkbox" bind:checked={enabled} /></div>
10
+ <div>
11
+ <div style:padding-left={`${depth}px`}>- {info.name}</div>
12
+ <div><input type="number" bind:value={ivalue} disabled={!enabled || disabled} /></div>
13
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
14
+ </div>
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: number | undefined;
6
6
  info: ControlNumber;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
7
9
  };
8
10
  events: {
9
11
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,29 @@
1
+
2
+ <script>import Component from "./Component.svelte";
3
+ import { getObjectDefaults } from "./defaulter";
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ export let value;
6
+ export let info;
7
+ export let depth;
8
+ export let disabled = false;
9
+ let ivalue = value ?? getObjectDefaults(info);
10
+ let enabled = value !== undefined;
11
+ $: value = !disabled && enabled ? ivalue : undefined;
12
+ </script>
13
+ <div>
14
+ <div style:padding-left={`${depth}px`}>
15
+ > {info.name}
16
+ </div>
17
+ <div>-</div>
18
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
19
+ </div>
20
+ {#if enabled && !disabled}
21
+ {#each info.values as info, i (i)}
22
+ <Component
23
+ {info}
24
+ bind:value={ivalue[info.name]}
25
+ depth={depth + 10}
26
+ disabled={!enabled || disabled}
27
+ />
28
+ {/each}
29
+ {/if}
@@ -0,0 +1,20 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ControlObject } from "./types";
3
+ declare const __propDef: {
4
+ props: {
5
+ value: Record<string, any> | undefined;
6
+ info: ControlObject;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type ObjectProps = typeof __propDef.props;
16
+ export type ObjectEvents = typeof __propDef.events;
17
+ export type ObjectSlots = typeof __propDef.slots;
18
+ export default class Object extends SvelteComponentTyped<ObjectProps, ObjectEvents, ObjectSlots> {
19
+ }
20
+ export {};
@@ -5,28 +5,38 @@
5
5
  grid-template-columns: 40px 1fr;
6
6
  }
7
7
 
8
- .input > span {
8
+ .input > div {
9
+ width: 100%;
10
+ height: 100%;
11
+ display: grid;
9
12
  text-align: center;
13
+ align-items: center;
14
+ font-size: 0.8rem;
15
+ margin: auto;
10
16
  }
11
17
  </style>
12
18
 
13
19
  <script>export let value;
14
20
  export let info;
21
+ export let depth;
22
+ export let disabled = false;
15
23
  let ivalue = value ?? info.min;
16
24
  let enabled = value !== undefined;
17
- $: value = enabled ? ivalue : undefined;
25
+ $: value = enabled && !disabled ? ivalue : undefined;
18
26
  </script>
19
- <div>{info.name}</div>
20
- <div class="input">
21
- <span>{ivalue}</span>
22
- <input
23
- type="range"
24
- bind:value={ivalue}
25
- min={info.min}
26
- max={info.max}
27
- step={info.step}
28
- disabled={!enabled}
29
- />
27
+ <div>
28
+ <div style:padding-left={`${depth}px`}>- {info.name}</div>
29
+ <div class="input">
30
+ <div>{ivalue}</div>
31
+ <input
32
+ type="range"
33
+ bind:value={ivalue}
34
+ min={info.min}
35
+ max={info.max}
36
+ step={info.step}
37
+ disabled={!enabled || disabled}
38
+ />
39
+ </div>
40
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
30
41
  </div>
31
- <div><input type="checkbox" bind:checked={enabled} /></div>
32
42
 
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: number | undefined;
6
6
  info: ControlRange;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
7
9
  };
8
10
  events: {
9
11
  [evt: string]: CustomEvent<any>;
@@ -1,16 +1,20 @@
1
1
 
2
2
  <script>export let value;
3
3
  export let info;
4
+ export let depth;
5
+ export let disabled = false;
4
6
  let ivalue = value ?? (info.values.length > 0 ? info.values[0] : undefined);
5
7
  let enabled = value !== undefined;
6
- $: value = enabled ? ivalue : undefined;
8
+ $: value = enabled && !disabled ? ivalue : undefined;
7
9
  </script>
8
- <div>{info.name}</div>
9
10
  <div>
10
- <select bind:value={ivalue} disabled={!enabled}>
11
- {#each info.values as value}
12
- <option {value}>{value}</option>
13
- {/each}
14
- </select>
11
+ <div style:padding-left={`${depth}px`}>- {info.name}</div>
12
+ <div>
13
+ <select bind:value={ivalue} disabled={!enabled || disabled}>
14
+ {#each info.values as value}
15
+ <option {value}>{value}</option>
16
+ {/each}
17
+ </select>
18
+ </div>
19
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
15
20
  </div>
16
- <div><input type="checkbox" bind:checked={enabled} /></div>
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: string | undefined;
6
6
  info: ControlSelect;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
7
9
  };
8
10
  events: {
9
11
  [evt: string]: CustomEvent<any>;
@@ -1,10 +1,14 @@
1
1
 
2
2
  <script>export let value;
3
3
  export let info;
4
+ export let depth;
5
+ export let disabled = false;
4
6
  let ivalue = value ?? false;
5
7
  let enabled = value !== undefined;
6
- $: value = enabled ? ivalue : undefined;
8
+ $: value = enabled && !disabled ? ivalue : undefined;
7
9
  </script>
8
- <div>{info.name}</div>
9
- <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled} /></div>
10
- <div><input type="checkbox" bind:checked={enabled} /></div>
10
+ <div>
11
+ <div style:padding-left={`${depth}px`}>- {info.name}</div>
12
+ <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled || disabled} /></div>
13
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
14
+ </div>
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: boolean | undefined;
6
6
  info: ControlSwitch;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
7
9
  };
8
10
  events: {
9
11
  [evt: string]: CustomEvent<any>;
@@ -1,10 +1,14 @@
1
1
 
2
2
  <script>export let value;
3
3
  export let info;
4
+ export let depth;
5
+ export let disabled = false;
4
6
  let ivalue = value ?? "";
5
- let enabled = value !== undefined;
6
- $: value = enabled ? ivalue : undefined;
7
+ let ienabled = value !== undefined;
8
+ $: value = ienabled && !disabled ? ivalue : undefined;
7
9
  </script>
8
- <div>{info.name}</div>
9
- <div><input type="text" bind:value={ivalue} disabled={!enabled} /></div>
10
- <div><input type="checkbox" bind:checked={enabled} /></div>
10
+ <div>
11
+ <div style:padding-left={`${depth}px`}>- {info.name}</div>
12
+ <div><input type="text" bind:value={ivalue} disabled={!ienabled || disabled} /></div>
13
+ <div><input type="checkbox" bind:checked={ienabled} {disabled} /></div>
14
+ </div>
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  value: string | undefined;
6
6
  info: ControlText;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
7
9
  };
8
10
  events: {
9
11
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,29 @@
1
+
2
+ <script>import Component from "./Component.svelte";
3
+ import { getTupleDefaults } from "./defaulter";
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ export let value;
6
+ export let info;
7
+ export let depth;
8
+ export let disabled = false;
9
+ let ivalue = value ?? getTupleDefaults(info);
10
+ let enabled = value !== undefined;
11
+ $: value = !disabled && enabled ? ivalue : undefined;
12
+ </script>
13
+ <div>
14
+ <div style:padding-left={`${depth}px`}>
15
+ > {info.name}
16
+ </div>
17
+ <div>-</div>
18
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
19
+ </div>
20
+ {#if enabled && !disabled}
21
+ {#each info.values as info, i (i)}
22
+ <Component
23
+ info={{ ...info, name: `${i}` }}
24
+ bind:value={ivalue[i]}
25
+ depth={depth + 10}
26
+ disabled={!enabled || disabled}
27
+ />
28
+ {/each}
29
+ {/if}
@@ -0,0 +1,20 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ControlTuple } from "./types";
3
+ declare const __propDef: {
4
+ props: {
5
+ value: any[] | undefined;
6
+ info: ControlTuple;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
9
+ };
10
+ events: {
11
+ [evt: string]: CustomEvent<any>;
12
+ };
13
+ slots: {};
14
+ };
15
+ export type TupleProps = typeof __propDef.props;
16
+ export type TupleEvents = typeof __propDef.events;
17
+ export type TupleSlots = typeof __propDef.slots;
18
+ export default class Tuple extends SvelteComponentTyped<TupleProps, TupleEvents, TupleSlots> {
19
+ }
20
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { Control, ControlTuple, ControlObject } from "./types";
2
+ export declare function getObjectDefaults(info: ControlObject): Record<string, any>;
3
+ export declare function getTupleDefaults(i: ControlTuple): any[];
4
+ export declare function getDefault(i: Control): any;
@@ -0,0 +1,35 @@
1
+ export function getObjectDefaults(info) {
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ const ret = {};
4
+ for (const i of info.values) {
5
+ ret[i.name] = getDefault(i);
6
+ }
7
+ return ret;
8
+ }
9
+ export function getTupleDefaults(i) {
10
+ const ret = [];
11
+ for (const info of i.values) {
12
+ ret.push(getDefault(info));
13
+ }
14
+ return ret;
15
+ }
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ export function getDefault(i) {
18
+ if (i.type === "number") {
19
+ return 0;
20
+ }
21
+ if (i.type === "range") {
22
+ return i.min;
23
+ }
24
+ if (i.type === "switch") {
25
+ return false;
26
+ }
27
+ if (i.type === "tuple") {
28
+ return [...getTupleDefaults(i)];
29
+ }
30
+ if (i.type === "object") {
31
+ return getObjectDefaults(i);
32
+ }
33
+ // "select" | "text"
34
+ return "";
35
+ }
@@ -1,3 +1,25 @@
1
+ export type NonNamed<T> = Omit<T, "name">;
2
+ export type NonNamedControl =
3
+ | NonNamed<ControlTuple>
4
+ | NonNamed<ControlObject>
5
+ | NonNamed<ControlText>
6
+ | NonNamed<ControlNumber>
7
+ | NonNamed<ControlRange>
8
+ | NonNamed<ControlSelect>
9
+ | NonNamed<ControlSwitch>;
10
+
11
+ export type ControlTuple = {
12
+ name: string;
13
+ type: "tuple";
14
+ values: NonNamedControl[];
15
+ };
16
+
17
+ export type ControlObject = {
18
+ name: string;
19
+ type: "object";
20
+ values: Control[];
21
+ };
22
+
1
23
  export type ControlText = {
2
24
  name: string;
3
25
  type: "text";
@@ -27,4 +49,11 @@ export type ControlSwitch = {
27
49
  type: "switch";
28
50
  };
29
51
 
30
- export type Control = ControlText | ControlNumber | ControlRange | ControlSelect | ControlSwitch;
52
+ export type Control =
53
+ | ControlTuple
54
+ | ControlObject
55
+ | ControlText
56
+ | ControlNumber
57
+ | ControlRange
58
+ | ControlSelect
59
+ | ControlSwitch;
@@ -1,9 +1,26 @@
1
+ const prefix = ".".length;
2
+ const suffix = "/+page.svelte".length;
3
+ function toRoute(p) {
4
+ return p.substring(prefix, p.length - suffix);
5
+ }
6
+ const route_advanced_layout_match = /\(.*\)/;
7
+ function collapseLayout(p) {
8
+ return p
9
+ .split("/")
10
+ .filter((p) => route_advanced_layout_match.exec(p) == null)
11
+ .join("/");
12
+ }
13
+ function isNotRoot(p) {
14
+ return p !== "/";
15
+ }
16
+ const route_rest_match = /.*\[.*\].*/;
17
+ function isRouteDynamic(p) {
18
+ return route_rest_match.exec(p) == null;
19
+ }
1
20
  export function load(files_from_import_meta) {
2
- const prefix = ".".length;
3
- const suffix = "/+page.svelte".length;
4
- const rootlen = "./+page.svelte".length;
5
21
  return Object.keys(files_from_import_meta)
6
- .filter((p) => p.length > rootlen) // remove root page
7
- .filter((p) => /.*\[.*\].*/.exec(p) == null)
8
- .map((p) => p.substring(prefix, p.length - suffix));
22
+ .map(toRoute)
23
+ .map(collapseLayout)
24
+ .filter(isNotRoot)
25
+ .filter(isRouteDynamic);
9
26
  }
@@ -63,6 +63,20 @@ export let sorter;
63
63
  export let renamer;
64
64
  let filter = "";
65
65
  let states = apply(info, () => ({ expanded: false, sub: {} }), (t, path) => ({ expanded: t.expanded || selected === path, sub: t.sub }), (t) => t.sub);
66
+ function update(selected) {
67
+ if (!info.includes(selected)) {
68
+ return;
69
+ }
70
+ let node = states;
71
+ const paths = selected.split("/").slice(1);
72
+ for (const [i, p] of paths.entries()) {
73
+ if (i < paths.length - 1) {
74
+ node[p].expanded = true;
75
+ }
76
+ node = node[p].sub;
77
+ }
78
+ }
79
+ $: update(selected);
66
80
  </script>
67
81
  <div class="nav">
68
82
  <div class="logo"><slot /></div>
@@ -18,28 +18,28 @@
18
18
  cursor: pointer;
19
19
  }
20
20
 
21
- .header > div {
21
+ .header:hover {
22
+ background-color: rgba(2, 156, 253, 0.07);
23
+ }
24
+
25
+ .header.selected {
26
+ background-color: rgba(2, 157, 253, 0.822);
27
+ color: black;
28
+ }
29
+
30
+ .icon {
22
31
  justify-content: center;
23
32
  height: 15px;
24
33
  width: 15px;
25
34
  }
26
35
 
27
- .header > div.expanded {
36
+ .icon.expanded {
28
37
  transform: rotate(90deg);
29
38
  }
30
39
 
31
- .header > div > div {
40
+ .icon > div {
32
41
  margin: auto;
33
42
  }
34
-
35
- .header:hover {
36
- background-color: rgba(2, 156, 253, 0.07);
37
- }
38
-
39
- .header.selected {
40
- background-color: rgba(2, 157, 253, 0.822);
41
- color: black;
42
- }
43
43
  </style>
44
44
 
45
45
  <script>import { slide } from "svelte/transition";
@@ -74,13 +74,7 @@ function click(link) {
74
74
  class:selected={selected === value.url}
75
75
  >
76
76
  <div class="icon" class:expanded={has_children && states.expanded}>
77
- <div>
78
- {#if Object.keys(value.sub).length > 0}
79
- >
80
- {:else}
81
- -
82
- {/if}
83
- </div>
77
+ <div>{Object.keys(value.sub).length > 0 ? ">" : "-"}</div>
84
78
  </div>
85
79
  <span>{renamer(key)}</span>
86
80
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
@@ -10,13 +10,13 @@
10
10
  "@sveltejs/kit": "next",
11
11
  "@sveltejs/package": "next",
12
12
  "mdsvex": "^0.10.6",
13
- "svelte": "^3.53.1",
14
- "svelte-check": "^2.10.0",
13
+ "svelte": "^3.54.0",
14
+ "svelte-check": "^2.10.2",
15
15
  "svelte-markdown": "^0.2.3",
16
16
  "svelte-preprocess": "^4.10.7",
17
17
  "tslib": "^2.4.1",
18
- "typescript": "^4.9.3",
19
- "vite": "^3.2.4"
18
+ "typescript": "^4.9.4",
19
+ "vite": "^4.0.0"
20
20
  },
21
21
  "type": "module",
22
22
  "publishConfig": {
@@ -1,5 +0,0 @@
1
- <svelte:head>
2
- <link href="https://fonts.googleapis.com/css?family=Fira Code" rel="stylesheet" />
3
- </svelte:head>
4
-
5
-
@@ -1,23 +0,0 @@
1
- /** @typedef {typeof __propDef.props} FontProps */
2
- /** @typedef {typeof __propDef.events} FontEvents */
3
- /** @typedef {typeof __propDef.slots} FontSlots */
4
- export default class Font extends SvelteComponentTyped<{
5
- [x: string]: never;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {}> {
9
- }
10
- export type FontProps = typeof __propDef.props;
11
- export type FontEvents = typeof __propDef.events;
12
- export type FontSlots = typeof __propDef.slots;
13
- import { SvelteComponentTyped } from "svelte";
14
- declare const __propDef: {
15
- props: {
16
- [x: string]: never;
17
- };
18
- events: {
19
- [evt: string]: CustomEvent<any>;
20
- };
21
- slots: {};
22
- };
23
- export {};