@nil-/doc 0.3.4 → 1.0.0

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 (29) hide show
  1. package/components/block/Instance.svelte +9 -13
  2. package/components/block/Params.svelte +2 -2
  3. package/components/block/Template.svelte +1 -2
  4. package/components/block/Template.svelte.d.ts +1 -1
  5. package/components/block/controls/Controls.svelte +4 -4
  6. package/components/block/controls/Styler.svelte +1 -1
  7. package/components/block/controls/props/Color.svelte +3 -2
  8. package/components/block/controls/props/Component.svelte +27 -31
  9. package/components/block/controls/props/Object.svelte +1 -1
  10. package/components/block/controls/props/Tuple.svelte +1 -1
  11. package/components/block/controls/props/misc/GroupHeader.svelte +1 -1
  12. package/components/block/controls/props/misc/Name.svelte +2 -2
  13. package/components/block/controls/props/misc/Toggle.svelte +1 -0
  14. package/components/block/controls/types.d.ts +1 -1
  15. package/components/block/icons/Button.svelte +1 -1
  16. package/components/block/icons/ControlView.svelte +1 -1
  17. package/components/block/icons/Position.svelte +2 -2
  18. package/components/layout/Container.svelte +11 -5
  19. package/components/layout/DocLayout.svelte.d.ts +6 -6
  20. package/components/layout/Layout.svelte +2 -2
  21. package/components/layout/Layout.svelte.d.ts +2 -2
  22. package/components/layout/ThemeToggle.svelte +2 -2
  23. package/components/layout/icons/Icon.svelte +1 -1
  24. package/components/navigation/Nav.svelte +1 -1
  25. package/components/navigation/Nav.svelte.d.ts +1 -1
  26. package/components/navigation/Node.svelte +2 -1
  27. package/components/navigation/Node.svelte.d.ts +1 -1
  28. package/components/navigation/Tree.svelte.d.ts +1 -1
  29. package/package.json +2 -2
@@ -9,7 +9,6 @@ export let defaults = void 0;
9
9
  export let noreset = false;
10
10
  let key = false;
11
11
  beforeUpdate(() => key = !key);
12
- const resolveArgs = resolve;
13
12
  const values = writable({ props: {}, events: [] });
14
13
  const updateBound = (d) => $values.props = resolve(d ?? {}, {});
15
14
  $:
@@ -31,14 +30,14 @@ const populate = (ext) => {
31
30
  const obj = {};
32
31
  const stringify = (detail) => {
33
32
  if (detail) {
34
- if (typeof detail === "string") {
33
+ if ("string" === typeof detail) {
35
34
  return detail;
36
35
  }
37
36
  return JSON.stringify(detail);
38
37
  }
39
38
  return "";
40
39
  };
41
- if (ext != null) {
40
+ if (null != ext) {
42
41
  for (const name of ext) {
43
42
  obj[name] = (ev) => {
44
43
  const detail = stringify(ev.detail);
@@ -60,6 +59,10 @@ const populate = (ext) => {
60
59
  }
61
60
  return obj;
62
61
  };
62
+ $:
63
+ props = resolve(defaults ?? {}, $values.props);
64
+ $:
65
+ events = populate($controls.events);
63
66
  </script>
64
67
 
65
68
  <!--
@@ -71,23 +74,16 @@ const populate = (ext) => {
71
74
  class="instance"
72
75
  class:selected={$vv === values}
73
76
  class:controls={$controls.events.length > 0 || $controls.props.length > 0}
77
+ role="none"
74
78
  on:click={focus}
75
79
  on:keypress={null}
76
80
  >
77
81
  <div class="content">
78
82
  {#if noreset}
79
- <slot
80
- props={resolveArgs(defaults ?? {}, $values.props)}
81
- events={populate($controls.events)}
82
- {key}
83
- />
83
+ <slot {props} {events} {key} />
84
84
  {:else}
85
85
  {#key key}
86
- <slot
87
- props={resolveArgs(defaults ?? {}, $values.props)}
88
- events={populate($controls.events)}
89
- {key}
90
- />
86
+ <slot {props} {events} {key} />
91
87
  {/key}
92
88
  {/if}
93
89
  </div>
@@ -6,8 +6,8 @@ const params = getParams();
6
6
  const id = $params.length;
7
7
  $params.push({
8
8
  id,
9
- tag: tag ?? `${id}`,
10
- values: resolve(props, {})
9
+ tag: `${id}`,
10
+ values: {}
11
11
  });
12
12
  $:
13
13
  $params[id].tag = tag ?? `${id}`;
@@ -15,7 +15,6 @@ $:
15
15
  let key = false;
16
16
  beforeUpdate(() => key = !key);
17
17
  const resolveArgs = resolve;
18
- const cast = (t) => t;
19
18
  </script>
20
19
 
21
20
  <!--
@@ -31,6 +30,6 @@ const cast = (t) => t;
31
30
  let:props
32
31
  let:events
33
32
  >
34
- <slot id={param.id} tag={param.tag} props={cast(props)} {events} {key} />
33
+ <slot id={param.id} tag={param.tag} {props} {events} {key} />
35
34
  </Instance>
36
35
  {/each}
@@ -12,7 +12,7 @@ declare class __sveltets_Render<Args> {
12
12
  default: {
13
13
  id: number;
14
14
  tag: string;
15
- props: Args;
15
+ props: unknown;
16
16
  events: Record<string, (ev: CustomEvent<unknown>) => void>;
17
17
  key: boolean;
18
18
  };
@@ -45,19 +45,19 @@ const cycleMode = () => {
45
45
  <ControlView {mode} />
46
46
  </Button>
47
47
  </div>
48
- {#if mode === "props"}
48
+ {#if "props" === mode}
49
49
  <div>Name</div>
50
50
  <div>Value</div>
51
51
  <div>Use</div>
52
- {:else if mode === "events"}
52
+ {:else if "events" === mode}
53
53
  <div>Events</div>
54
54
  <div>Detail</div>
55
55
  {/if}
56
56
  </div>
57
57
  {#key $values && $controls}
58
58
  {#if cc != null && $cc != null && vv != null && $vv != null}
59
- <Props infos={$cc.props} visible={mode === "props"} bind:values={$vv.props} />
60
- <Events events={$vv.events} visible={mode === "events"} />
59
+ <Props infos={$cc.props} visible={"props" === mode} bind:values={$vv.props} />
60
+ <Events events={$vv.events} visible={"events" === mode} />
61
61
  {/if}
62
62
  {/key}
63
63
  </Styler>
@@ -1,7 +1,7 @@
1
1
  <script>export let type;
2
2
  </script>
3
3
 
4
- <div class:props={type === "props"} class:events={type === "events"}>
4
+ <div class:props={"props" === type} class:events={"events" === type}>
5
5
  <slot />
6
6
  </div>
7
7
 
@@ -11,6 +11,7 @@
11
11
  case "rgb":
12
12
  return color.rgbString;
13
13
  case "rgba":
14
+ default:
14
15
  return color.rgbaString;
15
16
  }
16
17
  };
@@ -34,7 +35,7 @@ const action = (d, { format, P }) => {
34
35
  popup: "left",
35
36
  editorFormat: format.substring(0, 3),
36
37
  editor: true,
37
- alpha: format.length === 4,
38
+ alpha: 4 === format.length,
38
39
  onChange: (color) => {
39
40
  ivalue = colorSetter(getFormat(info), color);
40
41
  d.style.borderColor = ivalue;
@@ -44,7 +45,7 @@ const action = (d, { format, P }) => {
44
45
  return {
45
46
  update: (format2) => {
46
47
  picker.setOptions({
47
- alpha: format2.length === 4,
48
+ alpha: 4 === format2.length,
48
49
  editorFormat: format2.substring(0, 3)
49
50
  });
50
51
  },
@@ -15,45 +15,41 @@ export let visible = false;
15
15
  </script>
16
16
 
17
17
  {#if info instanceof Array}
18
- {@const type = info[1]}
19
- {#if "object" === type}
18
+ {#if "object" === info[1]}
20
19
  <Object {info} bind:value {depth} {disabled} {visible} />
21
- {:else if "tuple" === type}
20
+ {:else if "tuple" === info[1]}
22
21
  <Tuple {info} bind:value {depth} {disabled} {visible} />
23
- {:else if "text" === type}
22
+ {:else if "text" === info[1]}
24
23
  <Text {info} bind:value {depth} {disabled} {visible} />
25
- {:else if "color" === type}
24
+ {:else if "color" === info[1]}
26
25
  <Color {info} bind:value {depth} {disabled} {visible} />
27
- {:else if "number" === type}
26
+ {:else if "number" === info[1]}
28
27
  <Number {info} bind:value {depth} {disabled} {visible} />
29
- {:else if "range" === type}
28
+ {:else if "range" === info[1]}
30
29
  <Range {info} bind:value {depth} {disabled} {visible} />
31
- {:else if "select" === type}
30
+ {:else if "select" === info[1]}
32
31
  <Select {info} bind:value {depth} {disabled} {visible} />
33
- {:else if "toggle" === type}
32
+ {:else if "toggle" === info[1]}
34
33
  <Toggle {info} bind:value {depth} {disabled} {visible} />
35
- {:else if "button" === type}
36
- <Button {info} {visible} />
37
- {/if}
38
- {:else}
39
- {@const type = info.type}
40
- {#if "object" === type}
41
- <Object {info} bind:value {depth} {disabled} {visible} />
42
- {:else if "tuple" === type}
43
- <Tuple {info} bind:value {depth} {disabled} {visible} />
44
- {:else if "text" === type}
45
- <Text {info} bind:value {depth} {disabled} {visible} />
46
- {:else if "color" === type}
47
- <Color {info} bind:value {depth} {disabled} {visible} />
48
- {:else if "number" === type}
49
- <Number {info} bind:value {depth} {disabled} {visible} />
50
- {:else if "range" === type}
51
- <Range {info} bind:value {depth} {disabled} {visible} />
52
- {:else if "select" === type}
53
- <Select {info} bind:value {depth} {disabled} {visible} />
54
- {:else if "toggle" === type}
55
- <Toggle {info} bind:value {depth} {disabled} {visible} />
56
- {:else if "button" === type}
34
+ {:else if "button" === info[1]}
57
35
  <Button {info} {visible} />
58
36
  {/if}
37
+ {:else if "object" === info.type}
38
+ <Object {info} bind:value {depth} {disabled} {visible} />
39
+ {:else if "tuple" === info.type}
40
+ <Tuple {info} bind:value {depth} {disabled} {visible} />
41
+ {:else if "text" === info.type}
42
+ <Text {info} bind:value {depth} {disabled} {visible} />
43
+ {:else if "color" === info.type}
44
+ <Color {info} bind:value {depth} {disabled} {visible} />
45
+ {:else if "number" === info.type}
46
+ <Number {info} bind:value {depth} {disabled} {visible} />
47
+ {:else if "range" === info.type}
48
+ <Range {info} bind:value {depth} {disabled} {visible} />
49
+ {:else if "select" === info.type}
50
+ <Select {info} bind:value {depth} {disabled} {visible} />
51
+ {:else if "toggle" === info.type}
52
+ <Toggle {info} bind:value {depth} {disabled} {visible} />
53
+ {:else if "button" === info.type}
54
+ <Button {info} {visible} />
59
55
  {/if}
@@ -7,7 +7,7 @@ export let info;
7
7
  export let depth;
8
8
  export let disabled = false;
9
9
  export let visible = false;
10
- let ivalue = value ?? defaulter(info);
10
+ const ivalue = value ?? defaulter(info);
11
11
  let enabled = value !== void 0;
12
12
  let expand = getValues(info).length > 0 ? true : void 0;
13
13
  $:
@@ -7,7 +7,7 @@ export let info;
7
7
  export let depth;
8
8
  export let disabled = false;
9
9
  export let visible = false;
10
- let ivalue = value ?? defaulter(info);
10
+ const ivalue = value ?? defaulter(info);
11
11
  let enabled = value !== void 0;
12
12
  let expand = getValues(info).length > 0 ? true : void 0;
13
13
  $:
@@ -16,7 +16,7 @@ const flip = () => {
16
16
  </script>
17
17
 
18
18
  {#if visible}
19
- <div on:click={flip} on:keypress={null}>
19
+ <div on:click={flip} on:keypress={null} role="none">
20
20
  <Name
21
21
  expand={expand === undefined ? undefined : expand && checked && !disabled}
22
22
  {name}
@@ -4,9 +4,9 @@ export let expand = void 0;
4
4
  </script>
5
5
 
6
6
  <div class="override" style:padding-left={`${depth}rem`} title={name}>
7
- <div class="icon" class:expand={expand === true}>
7
+ <div class="icon" class:expand={true === expand}>
8
8
  <div>
9
- {expand === undefined ? "-" : ">"}
9
+ {undefined === expand ? "-" : ">"}
10
10
  </div>
11
11
  </div>
12
12
  <span>{name}</span>
@@ -14,6 +14,7 @@ const dark = getTheme();
14
14
  viewBox="-30 -30 60 60"
15
15
  on:click|stopPropagation={click}
16
16
  on:keypress
17
+ role="none"
17
18
  class:disabled
18
19
  class:dark={$dark}
19
20
  >
@@ -34,7 +34,7 @@ export type PropType<T extends Types> =
34
34
  ]
35
35
  : T extends "range" ? [
36
36
  [ name: string, type: T, min: number, max: number, step: number ],
37
- { name: string; type: T; min: number; max: number, step: number; }
37
+ { name: string; type: T; min: number; max: number; step: number; }
38
38
  ]
39
39
  : T extends "tuple" ? [
40
40
  // eslint-disable-next-line no-use-before-define
@@ -3,7 +3,7 @@
3
3
  export let scale = false;
4
4
  </script>
5
5
 
6
- <div on:click on:keypress {title} class:scale>
6
+ <div on:click on:keypress role="none" {title} class:scale>
7
7
  <slot />
8
8
  </div>
9
9
 
@@ -4,7 +4,7 @@
4
4
  <svg viewBox="-50 -50 100 100">
5
5
  <rect width="60" height="60" x="-30" y="-30" fill="transparent" />
6
6
  <rect
7
- x={mode === "props" ? 0 : -20}
7
+ x={"props" === mode ? 0 : -20}
8
8
  class="mv"
9
9
  height="40"
10
10
  width="20"
@@ -1,8 +1,8 @@
1
1
  <script>export let position = "hidden";
2
2
  $:
3
- bottom = position === "bottom";
3
+ bottom = "bottom" === position;
4
4
  $:
5
- right = position === "right";
5
+ right = "right" === position;
6
6
  </script>
7
7
 
8
8
  <svg viewBox="-50 -50 100 100">
@@ -5,8 +5,8 @@ export let vertical = false;
5
5
  export let offset = 4;
6
6
  export let b = false;
7
7
  export let persistent = false;
8
- let width;
9
- let height;
8
+ let width = null;
9
+ let height = null;
10
10
  const { position, draggable } = createDraggable(offset);
11
11
  $:
12
12
  span = vertical ? width : height;
@@ -50,6 +50,12 @@ const check = (v, flag, s) => {
50
50
  return v > min;
51
51
  }
52
52
  };
53
+ const title = (v, b2) => {
54
+ if (v) {
55
+ return b2 ? "left" : "right";
56
+ }
57
+ return b2 ? "top" : "bottom";
58
+ };
53
59
  </script>
54
60
 
55
61
  <div
@@ -66,14 +72,14 @@ const check = (v, flag, s) => {
66
72
  >
67
73
  {#if width != null && height != null}
68
74
  <div style:grid-area="A">
69
- {#if persistent || check($off, !b, span)}
75
+ {#if persistent || check($off, !b, span ?? 0)}
70
76
  <slot name="A" />
71
77
  {/if}
72
78
  </div>
73
79
  <div class="divider">
74
80
  <div
75
81
  class="overlay"
76
- title={`Collapse ${vertical ? (b ? "left" : "right") : b ? "top" : "bottom"}`}
82
+ title={`Collapse ${title(vertical, b)}`}
77
83
  use:draggable={{
78
84
  reset: () => offset,
79
85
  reversed: !b,
@@ -85,7 +91,7 @@ const check = (v, flag, s) => {
85
91
  />
86
92
  </div>
87
93
  <div style:grid-area="B">
88
- {#if persistent || check($off, b, span)}
94
+ {#if persistent || check($off, b, span ?? 0)}
89
95
  <slot name="B" />
90
96
  {/if}
91
97
  </div>
@@ -1,12 +1,12 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { Readable, Writable } from "svelte/store";
3
3
  type Settings = {
4
- data: string[];
5
- current: Readable<string | null>;
6
- offset: Writable<number>;
7
- theme: Writable<"dark" | "light">;
8
- panel: Writable<"bottom" | "right">;
9
- navigate: (e: {
4
+ readonly data: readonly string[];
5
+ readonly current: Readable<string | null>;
6
+ readonly offset: Writable<number>;
7
+ readonly theme: Writable<"dark" | "light">;
8
+ readonly panel: Writable<"bottom" | "right">;
9
+ readonly navigate: (e: {
10
10
  detail: string;
11
11
  }) => Promise<void>;
12
12
  };
@@ -34,7 +34,7 @@ $:
34
34
  const panelChange = (info) => {
35
35
  if (info != null) {
36
36
  const i = get(info);
37
- if (panelOffset == 4) {
37
+ if (4 === panelOffset) {
38
38
  if (i.props.length > 0) {
39
39
  panelOffset = 250;
40
40
  mode = "props";
@@ -81,7 +81,7 @@ $:
81
81
  </Scrollable>
82
82
  </svelte:fragment>
83
83
  <svelte:fragment slot="B">
84
- <Container vertical={panel === "right"} persistent bind:offset={panelOffset}>
84
+ <Container vertical={"right" === panel} persistent bind:offset={panelOffset}>
85
85
  <svelte:fragment slot="A">
86
86
  <Scrollable>
87
87
  <Content>
@@ -3,7 +3,7 @@ import type { Sorter, Renamer } from "../navigation/types";
3
3
  import { type Theme } from "../context";
4
4
  declare const __propDef: {
5
5
  props: {
6
- data: string[];
6
+ data: readonly string[];
7
7
  current?: string | null | undefined;
8
8
  sorter?: Sorter | null | undefined;
9
9
  renamer?: Renamer | null | undefined;
@@ -12,7 +12,7 @@ declare const __propDef: {
12
12
  panel?: "right" | "bottom" | undefined;
13
13
  };
14
14
  events: {
15
- navigate: CustomEvent<any>;
15
+ navigate: CustomEvent<string>;
16
16
  } & {
17
17
  [evt: string]: CustomEvent<any>;
18
18
  };
@@ -4,7 +4,7 @@ import ThemeIcon from "./icons/Theme.svelte";
4
4
  export let theme;
5
5
  const dark = getTheme();
6
6
  const toggle = () => {
7
- if (theme !== void 0) {
7
+ if (void 0 !== theme) {
8
8
  theme = $dark ? "light" : "dark";
9
9
  } else {
10
10
  $dark = !$dark;
@@ -13,5 +13,5 @@ const toggle = () => {
13
13
  </script>
14
14
 
15
15
  <Icon on:click={toggle}>
16
- <ThemeIcon dark={theme === undefined ? $dark : theme === "dark"} />
16
+ <ThemeIcon dark={undefined === theme ? $dark : "dark" === theme} />
17
17
  </Icon>
@@ -1,7 +1,7 @@
1
1
  <script>export let title = void 0;
2
2
  </script>
3
3
 
4
- <div class="icon" on:click on:keypress {title}>
4
+ <div class="icon" on:click on:keypress {title} role="none">
5
5
  <slot />
6
6
  </div>
7
7
 
@@ -9,7 +9,7 @@ const apply = (paths, init, pre, next, post) => {
9
9
  let t = retval;
10
10
  for (let i = 1; i < parts.length; ++i) {
11
11
  const part = parts[i];
12
- if (null == t[part]) {
12
+ if (!(part in t)) {
13
13
  t[part] = init();
14
14
  }
15
15
  if (i !== parts.length - 1) {
@@ -8,7 +8,7 @@ declare const __propDef: {
8
8
  renamer: Renamer;
9
9
  };
10
10
  events: {
11
- navigate: CustomEvent<any>;
11
+ navigate: CustomEvent<string>;
12
12
  } & {
13
13
  [evt: string]: CustomEvent<any>;
14
14
  };
@@ -31,6 +31,7 @@ const click = (link) => {
31
31
  class="header"
32
32
  on:click={() => click(value.url)}
33
33
  on:keypress={null}
34
+ role="none"
34
35
  {style}
35
36
  class:selected={selected === value.url}
36
37
  class:paged={value.url != null}
@@ -41,7 +42,7 @@ const click = (link) => {
41
42
  <span>{renamer(key)}</span>
42
43
  </div>
43
44
  {#if expand || states.expanded}
44
- <div class="sub" transition:slide|local>
45
+ <div class="sub" transition:slide>
45
46
  {#each sort(value.sub, sorter) as [k, v] (k)}
46
47
  <svelte:self
47
48
  key={k}
@@ -12,7 +12,7 @@ declare const __propDef: {
12
12
  renamer: Renamer;
13
13
  };
14
14
  events: {
15
- navigate: CustomEvent<any>;
15
+ navigate: CustomEvent<string>;
16
16
  } & {
17
17
  [evt: string]: CustomEvent<any>;
18
18
  };
@@ -10,7 +10,7 @@ declare const __propDef: {
10
10
  selected: string;
11
11
  };
12
12
  events: {
13
- navigate: CustomEvent<any>;
13
+ navigate: CustomEvent<string>;
14
14
  } & {
15
15
  [evt: string]: CustomEvent<any>;
16
16
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.3.4",
3
+ "version": "1.0.0",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
7
7
  },
8
8
  "license": "ISC",
9
9
  "peerDependencies": {
10
- "svelte": "^3.58.0"
10
+ "svelte": "^4.0.3"
11
11
  },
12
12
  "keywords": [
13
13
  "svelte",