@nil-/doc 0.2.24 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @nil-/doc
2
2
 
3
+ ## 0.2.26
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc] removed fallback page in documentation ([#30](https://github.com/njaldea/mono/pull/30))
8
+
9
+ ## 0.2.25
10
+
11
+ ### Patch Changes
12
+
13
+ - 186187c: [doc][breaking] removed layout slot prop for content. all unnamed slots will be part of the default slot
14
+ - 186187c: [doc] fix range tooltip styling
15
+ - a82c0de: [doc] support dark/light mode
16
+
3
17
  ## 0.2.24
4
18
 
5
19
  ### Patch Changes
@@ -2,8 +2,6 @@
2
2
  .layout {
3
3
  width: 100%;
4
4
  height: 100%;
5
- color: rgb(201, 205, 207);
6
- background-color: rgb(34, 36, 37);
7
5
  font-family: "Fira Code", "Courier New", Courier, monospace;
8
6
  }
9
7
 
@@ -38,18 +36,36 @@
38
36
  .scrollable::-webkit-scrollbar {
39
37
  display: none;
40
38
  }
39
+
40
+ /* colors */
41
+ .layout {
42
+ background-color: hsl(0, 0%, 100%);
43
+ color: hsl(0, 100%, 0%);
44
+ color-scheme: light;
45
+ }
46
+
47
+ .layout.dark {
48
+ background-color: hsl(200, 4%, 14%);
49
+ color: hsl(200, 6%, 80%);
50
+ color-scheme: dark;
51
+ }
41
52
  </style>
42
53
 
43
54
  <script>import Container from "./etc/Container.svelte";
44
55
  import Nav from "./navigation/Nav.svelte";
45
- import { inRoot } from "./context";
56
+ import { inRoot, getTheme, initTheme, evalTheme } from "./context";
46
57
  export let data;
47
58
  export let current = null;
48
59
  export let sorter = null;
49
60
  export let renamer = null;
61
+ export let theme = void 0;
50
62
  const r = inRoot();
63
+ const parentTheme = getTheme();
64
+ const isDark = initTheme();
65
+ $:
66
+ $isDark = evalTheme(parentTheme ? $parentTheme : true, theme);
51
67
  </script>
52
- <div class="layout" class:reset={r}>
68
+ <div class="layout" class:reset={r} class:dark={$isDark}>
53
69
  <Container offset={250} padding={250} vertical secondary>
54
70
  <svelte:fragment slot="primary">
55
71
  <div class="content scrollable">
@@ -67,7 +83,7 @@ const r = inRoot();
67
83
  <svelte:fragment slot="secondary">
68
84
  <div class="content scrollable">
69
85
  {#key current}
70
- <slot name="content" />
86
+ <slot />
71
87
  {/key}
72
88
  </div>
73
89
  </svelte:fragment>
@@ -1,11 +1,13 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  import type { Sorter, Renamer } from "./navigation/types";
3
+ import { type Theme } from "./context";
3
4
  declare const __propDef: {
4
5
  props: {
5
6
  data: string[];
6
7
  current?: string | null | undefined;
7
8
  sorter?: Sorter | null | undefined;
8
9
  renamer?: Renamer | null | undefined;
10
+ theme?: Theme;
9
11
  };
10
12
  events: {
11
13
  navigate: CustomEvent<any>;
@@ -14,7 +16,7 @@ declare const __propDef: {
14
16
  };
15
17
  slots: {
16
18
  title: {};
17
- content: {};
19
+ default: {};
18
20
  };
19
21
  };
20
22
  export type LayoutProps = typeof __propDef.props;
@@ -1,12 +1,3 @@
1
- <script>import { initParams, initCurrent, initDefaults, initControls, initControlsState } from "./context";
2
- import { inRoot } from "../context";
3
- initParams();
4
- initCurrent();
5
- initDefaults();
6
- initControls();
7
- initControlsState();
8
- const r = inRoot();
9
- </script>
10
1
  <style>
11
2
  div {
12
3
  display: flex;
@@ -26,10 +17,40 @@ const r = inRoot();
26
17
  box-sizing: border-box;
27
18
  font-family: "Fira Code", "Courier New", Courier, monospace;
28
19
  }
29
- </style>
30
20
 
21
+ /* colors */
22
+ div {
23
+ color-scheme: light;
24
+ color: hsl(0, 100%, 0%);
25
+ }
26
+
27
+ div.dark {
28
+ color-scheme: dark;
29
+ color: hsl(200, 6%, 80%);
30
+ }
31
+ </style>
31
32
 
32
- <div class:reset={r}>
33
+ <script>import {
34
+ initParams,
35
+ initCurrent,
36
+ initDefaults,
37
+ initControls,
38
+ initControlsState
39
+ } from "./context";
40
+ import { inRoot, getTheme, initTheme, evalTheme } from "../context";
41
+ initParams();
42
+ initCurrent();
43
+ initDefaults();
44
+ initControls();
45
+ initControlsState();
46
+ const r = inRoot();
47
+ export let theme = void 0;
48
+ const parentTheme = getTheme();
49
+ const isDark = initTheme();
50
+ $:
51
+ $isDark = evalTheme(parentTheme ? $parentTheme : false, theme);
52
+ </script>
53
+ <div class:reset={r} class:dark={$isDark}>
33
54
  <slot />
34
55
  </div>
35
56
 
@@ -1,6 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import { type Theme } from "../context";
2
3
  declare const __propDef: {
3
- props: Record<string, never>;
4
+ props: {
5
+ theme?: Theme;
6
+ };
4
7
  events: {
5
8
  [evt: string]: CustomEvent<any>;
6
9
  };
@@ -5,5 +5,6 @@ export let expand = false;
5
5
  const controls = getControls();
6
6
  $controls = props;
7
7
  const state = getControlsState();
8
- $: $state.expand = expand;
8
+ $:
9
+ $state.expand = expand;
9
10
  </script>
@@ -2,21 +2,23 @@
2
2
  <script>import { onMount } from "svelte";
3
3
  import { getParams, getDefaults } from "./context";
4
4
  import { resolve } from "./utils";
5
- export let tag = undefined;
5
+ export let tag = void 0;
6
6
  export let props = {};
7
7
  const defaults = getDefaults();
8
8
  const params = getParams();
9
- onMount(() => defaults.subscribe((d) => {
9
+ onMount(
10
+ () => defaults.subscribe((d) => {
10
11
  if (d != null) {
11
- params.update((p) => [
12
- ...p,
13
- {
14
- id: p.length,
15
- tag: tag ?? `${p.length}`,
16
- values: resolve(d, props),
17
- defaults: resolve(d, props)
18
- }
19
- ]);
12
+ params.update((p) => [
13
+ ...p,
14
+ {
15
+ id: p.length,
16
+ tag: tag ?? `${p.length}`,
17
+ values: resolve(d, props),
18
+ defaults: resolve(d, props)
19
+ }
20
+ ]);
20
21
  }
21
- }));
22
+ })
23
+ );
22
24
  </script>
@@ -21,12 +21,9 @@
21
21
  .content {
22
22
  min-height: 100px;
23
23
  border-radius: 5px 5px 5px 5px;
24
- border: rgb(100, 96, 96) solid 1px;
25
- background-color: rgb(33, 36, 37);
26
24
  }
27
25
 
28
26
  .misc {
29
- outline: rgb(100, 96, 96) solid 1px;
30
27
  border-bottom-left-radius: 5px;
31
28
  border-bottom-right-radius: 5px;
32
29
  user-select: none;
@@ -46,12 +43,32 @@
46
43
  .scrollable::-webkit-scrollbar {
47
44
  display: none;
48
45
  }
46
+
47
+ /* colors */
48
+ .content {
49
+ border: hsl(0, 2%, 60%) solid 1px;
50
+ background-color: hsl(0, 0%, 100%);
51
+ }
52
+
53
+ .misc {
54
+ border: hsl(0, 2%, 60%) solid 1px;
55
+ }
56
+
57
+ .content.dark {
58
+ border: hsl(0, 2%, 40%) solid 1px;
59
+ background-color: hsl(200, 4%, 14%);
60
+ }
61
+
62
+ .misc.dark {
63
+ outline: hsl(0, 2%, 40%) solid 1px;
64
+ }
49
65
  </style>
50
66
  <svelte:window on:click={() => ($current = null)} />
51
67
 
52
68
  <script>import { getParams, getCurrent, getDefaults } from "./context";
53
69
  import { getControls, getControlsState } from "./context";
54
70
  import { resolve } from "./utils";
71
+ import { getTheme } from "../context";
55
72
  import Controls from "./controls/Controls.svelte";
56
73
  import { beforeUpdate } from "svelte";
57
74
  import { slide } from "svelte/transition";
@@ -60,29 +77,20 @@ const current = getCurrent();
60
77
  const controls = getControls();
61
78
  const controlsState = getControlsState();
62
79
  const defaultsStore = getDefaults();
63
- export let defaults = undefined;
80
+ const isDark = getTheme();
81
+ export let defaults = void 0;
64
82
  export let noreset = false;
65
83
  export let columns = false;
66
84
  function reset() {
67
- $params = [];
68
- $defaultsStore = defaults;
85
+ $params = [];
86
+ $defaultsStore = defaults;
69
87
  }
70
- $: $defaultsStore, reset();
88
+ $:
89
+ $defaultsStore, reset();
71
90
  let hovered = null;
72
- /**
73
- * This flag is to rerender the whole slot component.
74
- * If the control is disabled, we use the default value provided from the defaults field.
75
- * If the value of a prop is undefined, we will have to forward this value to the slot.
76
- * Problem is, if the slot component has a default value set, it is only
77
- * evaluated during component creation, not in subsequent updates.
78
- *
79
- * The solution is to rerender the whole slot whenever there is an control update.
80
- *
81
- * Similar case to: https://github.com/sveltejs/svelte/issues/4442
82
- */
83
91
  let key = false;
84
- beforeUpdate(() => (key = !key));
85
- const resolveArgs = (resolve);
92
+ beforeUpdate(() => key = !key);
93
+ const resolveArgs = resolve;
86
94
  </script>
87
95
  <div class="template" class:columns>
88
96
  {#each $params as param (param.id)}
@@ -94,7 +102,7 @@ const resolveArgs = (resolve);
94
102
  on:keypress={null}
95
103
  >
96
104
  {#if noreset}
97
- <div class="content scrollable">
105
+ <div class="content scrollable" class:dark={$isDark}>
98
106
  <slot
99
107
  id={param.id}
100
108
  tag={param.tag}
@@ -104,7 +112,7 @@ const resolveArgs = (resolve);
104
112
  </div>
105
113
  {:else}
106
114
  {#key key}
107
- <div class="content scrollable">
115
+ <div class="content scrollable" class:dark={$isDark}>
108
116
  <slot
109
117
  id={param.id}
110
118
  tag={param.tag}
@@ -115,7 +123,7 @@ const resolveArgs = (resolve);
115
123
  {/key}
116
124
  {/if}
117
125
  {#if $controls.length > 0 && ($controlsState.expand || $current === param.id || hovered === param.id)}
118
- <div class="misc scrollable" transition:slide|local>
126
+ <div class="misc scrollable" class:dark={$isDark} transition:slide|local>
119
127
  <Controls infos={$controls} bind:values={param.values} />
120
128
  </div>
121
129
  {/if}
@@ -6,9 +6,6 @@ import Switch from "./Switch.svelte";
6
6
  import Select from "./Select.svelte";
7
7
  import Tuple from "./Tuple.svelte";
8
8
  import Object from "./Object.svelte";
9
- // by use, info type is mapped to the value type
10
- // unfortunately i can't use typescript in the markup part of svelte
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
9
  export let value;
13
10
  export let info;
14
11
  export let depth;
@@ -5,8 +5,9 @@ export let info;
5
5
  export let depth;
6
6
  export let disabled = false;
7
7
  let ivalue = value ?? getDefault(info);
8
- let enabled = value !== undefined;
9
- $: value = enabled && !disabled ? ivalue : undefined;
8
+ let enabled = value !== void 0;
9
+ $:
10
+ value = enabled && !disabled ? ivalue : void 0;
10
11
  </script>
11
12
  <div>
12
13
  <div style:padding-left={`${depth}px`}>- {info.name}</div>
@@ -7,8 +7,9 @@ export let info;
7
7
  export let depth;
8
8
  export let disabled = false;
9
9
  let ivalue = value ?? getObjectDefaults(info);
10
- let enabled = value !== undefined;
11
- $: value = !disabled && enabled ? ivalue : undefined;
10
+ let enabled = value !== void 0;
11
+ $:
12
+ value = !disabled && enabled ? ivalue : void 0;
12
13
  </script>
13
14
  <Header name={info.name} bind:checked={enabled} {depth} {disabled} />
14
15
  {#if enabled && !disabled}
@@ -38,8 +38,9 @@ export let info;
38
38
  export let depth;
39
39
  export let disabled = false;
40
40
  let ivalue = value ?? getDefault(info);
41
- let enabled = value !== undefined;
42
- $: value = enabled && !disabled ? ivalue : undefined;
41
+ let enabled = value !== void 0;
42
+ $:
43
+ value = enabled && !disabled ? ivalue : void 0;
43
44
  </script>
44
45
  <div>
45
46
  <div style:padding-left={`${depth}px`}>- {info.name}</div>
@@ -5,8 +5,9 @@ export let info;
5
5
  export let depth;
6
6
  export let disabled = false;
7
7
  let ivalue = value ?? getDefault(info);
8
- let enabled = value !== undefined;
9
- $: value = enabled && !disabled ? ivalue : undefined;
8
+ let enabled = value !== void 0;
9
+ $:
10
+ value = enabled && !disabled ? ivalue : void 0;
10
11
  </script>
11
12
  <div>
12
13
  <div style:padding-left={`${depth}px`}>- {info.name}</div>
@@ -5,8 +5,9 @@ export let info;
5
5
  export let depth;
6
6
  export let disabled = false;
7
7
  let ivalue = value ?? getDefault(info);
8
- let enabled = value !== undefined;
9
- $: value = enabled && !disabled ? ivalue : undefined;
8
+ let enabled = value !== void 0;
9
+ $:
10
+ value = enabled && !disabled ? ivalue : void 0;
10
11
  </script>
11
12
  <div>
12
13
  <div style:padding-left={`${depth}px`}>- {info.name}</div>
@@ -5,8 +5,9 @@ export let info;
5
5
  export let depth;
6
6
  export let disabled = false;
7
7
  let ivalue = value ?? getDefault(info);
8
- let ienabled = value !== undefined;
9
- $: value = ienabled && !disabled ? ivalue : undefined;
8
+ let ienabled = value !== void 0;
9
+ $:
10
+ value = ienabled && !disabled ? ivalue : void 0;
10
11
  </script>
11
12
  <div>
12
13
  <div style:padding-left={`${depth}px`}>- {info.name}</div>
@@ -7,8 +7,9 @@ export let info;
7
7
  export let depth;
8
8
  export let disabled = false;
9
9
  let ivalue = value ?? getTupleDefaults(info);
10
- let enabled = value !== undefined;
11
- $: value = !disabled && enabled ? ivalue : undefined;
10
+ let enabled = value !== void 0;
11
+ $:
12
+ value = !disabled && enabled ? ivalue : void 0;
12
13
  </script>
13
14
  <Header name={info.name} bind:checked={enabled} {depth} {disabled} />
14
15
  {#if enabled && !disabled}
@@ -1,3 +1,6 @@
1
+ <script>import { getTheme } from "../../../context";
2
+ const isDark = getTheme();
3
+ </script>
1
4
  <style>
2
5
  div {
3
6
  width: 100%;
@@ -8,7 +11,9 @@
8
11
  box-sizing: border-box;
9
12
  }
10
13
 
11
- div :global(*) {
14
+ div :global(*),
15
+ div :global(*::before),
16
+ div :global(*::after) {
12
17
  box-sizing: inherit;
13
18
  }
14
19
 
@@ -17,16 +22,6 @@
17
22
  display: grid;
18
23
  padding: 2px 0px;
19
24
  grid-template-columns: minmax(250px, 1fr) 200px 40px;
20
- background-color: hsl(205, 50%, 5%);
21
- }
22
-
23
- div > :global(div:nth-child(even)) {
24
- background-color: hsl(205, 15%, 15%);
25
- }
26
-
27
- div > :global(div:hover .tooltip),
28
- div > :global(div:nth-child(n + 2):hover) {
29
- background-color: hsl(203, 100%, 15%);
30
25
  }
31
26
 
32
27
  div > :global(div > div) {
@@ -38,9 +33,45 @@
38
33
  width: 100%;
39
34
  height: 100%;
40
35
  }
36
+
37
+ /* colors */
38
+ div > :global(div) {
39
+ background-color: hsl(0, 0%, 100%);
40
+ }
41
+
42
+ div > :global(div:nth-child(even)) {
43
+ background-color: hsl(210, 29%, 97%);
44
+ }
45
+
46
+ div > :global(div:nth-child(n + 2):hover) {
47
+ background-color: hsl(210, 100%, 90%);
48
+ }
49
+
50
+ div > :global(div:hover .tooltip) {
51
+ background-color: hsl(0, 0%, 100%);
52
+ outline: hsl(0, 100%, 0%) 1px solid;
53
+ }
54
+
55
+ div.dark > :global(div) {
56
+ background-color: hsl(213, 26%, 7%);
57
+ }
58
+
59
+ div.dark > :global(div:nth-child(even)) {
60
+ background-color: hsl(213, 26%, 11%);
61
+ }
62
+
63
+ div.dark > :global(div:nth-child(n + 2):hover) {
64
+ background-color: hsl(203, 100%, 15%);
65
+ }
66
+
67
+ div.dark > :global(div:hover .tooltip) {
68
+ background-color: hsl(213, 26%, 7%);
69
+ outline: hsl(200, 6%, 80%) 1px solid;
70
+ }
41
71
  </style>
42
72
 
43
- <div>
73
+
74
+ <div class:dark={$isDark}>
44
75
  <slot />
45
76
  </div>
46
77
 
@@ -1,22 +1,6 @@
1
- /** @typedef {typeof __propDef.props} StylerProps */
2
- /** @typedef {typeof __propDef.events} StylerEvents */
3
- /** @typedef {typeof __propDef.slots} StylerSlots */
4
- export default class Styler extends SvelteComponentTyped<{
5
- [x: string]: never;
6
- }, {
7
- [evt: string]: CustomEvent<any>;
8
- }, {
9
- default: {};
10
- }> {
11
- }
12
- export type StylerProps = typeof __propDef.props;
13
- export type StylerEvents = typeof __propDef.events;
14
- export type StylerSlots = typeof __propDef.slots;
15
1
  import { SvelteComponentTyped } from "svelte";
16
2
  declare const __propDef: {
17
- props: {
18
- [x: string]: never;
19
- };
3
+ props: Record<string, never>;
20
4
  events: {
21
5
  [evt: string]: CustomEvent<any>;
22
6
  };
@@ -24,4 +8,9 @@ declare const __propDef: {
24
8
  default: {};
25
9
  };
26
10
  };
11
+ export type StylerProps = typeof __propDef.props;
12
+ export type StylerEvents = typeof __propDef.events;
13
+ export type StylerSlots = typeof __propDef.slots;
14
+ export default class Styler extends SvelteComponentTyped<StylerProps, StylerEvents, StylerSlots> {
15
+ }
27
16
  export {};
@@ -1 +1,6 @@
1
+ import type { Writable } from "svelte/store";
1
2
  export declare function inRoot(): boolean;
3
+ export type Theme = undefined | "light" | "dark";
4
+ export declare function getTheme(): Writable<boolean>;
5
+ export declare function initTheme(): Writable<boolean>;
6
+ export declare function evalTheme(parent: boolean, theme: Theme): boolean;
@@ -1,7 +1,18 @@
1
1
  import { setContext, getContext } from "svelte";
2
+ import { writable } from "svelte/store";
2
3
  const root = Symbol();
3
4
  export function inRoot() {
4
5
  const value = getContext(root);
5
6
  setContext(root, false);
6
7
  return value !== false;
7
8
  }
9
+ const theme = Symbol();
10
+ export function getTheme() {
11
+ return getContext(theme);
12
+ }
13
+ export function initTheme() {
14
+ return setContext(theme, writable(true));
15
+ }
16
+ export function evalTheme(parent, theme) {
17
+ return theme === undefined ? parent : theme === "dark";
18
+ }
@@ -28,11 +28,6 @@
28
28
  overflow: visible;
29
29
  user-select: none;
30
30
  grid-area: divider;
31
- outline: rgb(100, 96, 96) solid 1px;
32
- }
33
-
34
- .container > .divider.moving {
35
- outline: rgb(255, 255, 255) solid 1px;
36
31
  }
37
32
 
38
33
  .container > .divider.vertical {
@@ -54,38 +49,56 @@
54
49
  cursor: col-resize;
55
50
  transform: translateX(-50%);
56
51
  }
52
+
53
+ /* colors */
54
+ .container > .divider {
55
+ outline: hsl(0, 2%, 70%) solid 1px;
56
+ }
57
+
58
+ .container > .divider.moving {
59
+ outline: hsl(0, 0%, 0%) solid 1px;
60
+ }
61
+
62
+ .container.dark > .divider {
63
+ outline: hsl(0, 2%, 38%) solid 1px;
64
+ }
65
+
66
+ .container.dark > .divider.moving {
67
+ outline: hsl(0, 0%, 100%) solid 1px;
68
+ }
57
69
  </style>
58
70
 
59
71
  <script>import { writable } from "svelte/store";
60
72
  import { createDraggable } from "./action";
61
- // orientation of the layout
73
+ import { getTheme } from "../context";
74
+ const isDark = getTheme();
62
75
  export let vertical = false;
63
- // initial value where the divider is located
64
76
  export let offset = 0;
65
- // when secondary is enabled, main focus will be the secondary slot
66
- // collapsing will hide the primary slot
67
77
  export let secondary = false;
68
- // min distance of divider to the edges
69
78
  export let padding = 0;
70
79
  let width;
71
80
  let height;
72
81
  let collapse = false;
73
82
  const { position, draggable } = createDraggable(offset);
74
83
  function update(w, h, limit, value) {
75
- if (w == null || h == null || collapse) {
76
- return;
77
- }
78
- const span = vertical ? w : h;
79
- offset = Math.max(Math.min(value, span - limit), limit);
84
+ if (w == null || h == null || collapse) {
85
+ return;
86
+ }
87
+ const span = vertical ? w : h;
88
+ offset = Math.max(Math.min(value, span - limit), limit);
80
89
  }
81
- $: update(width, height, padding, $position);
82
- $: offsetpx = collapse ? "10px" : `${offset}px`;
83
- $: style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
90
+ $:
91
+ update(width, height, padding, $position);
92
+ $:
93
+ offsetpx = collapse ? "10px" : `${offset}px`;
94
+ $:
95
+ style = !secondary ? `auto 0px ${offsetpx}` : `${offsetpx} 0px auto`;
84
96
  const moving = writable(false);
85
97
  </script>
86
98
  <div
87
99
  class="container"
88
100
  class:vertical
101
+ class:dark={$isDark}
89
102
  bind:clientHeight={height}
90
103
  bind:clientWidth={width}
91
104
  style:grid-template-columns={vertical ? style : null}
@@ -21,40 +21,44 @@
21
21
  </style>
22
22
 
23
23
  <script context="module">function apply(paths, init, pre, next, post) {
24
- const retval = {};
25
- for (const path of paths) {
26
- const parts = path.split("/");
27
- if (parts.length <= 1) {
28
- continue;
29
- }
30
- let t = retval;
31
- for (let i = 1; i < parts.length; ++i) {
32
- const part = parts[i];
33
- if (t[part] == null) {
34
- t[part] = init();
35
- }
36
- if (i !== parts.length - 1) {
37
- t[part] = pre(t[part], path);
38
- }
39
- if (i !== parts.length - 1) {
40
- t = next(t[part]);
41
- }
42
- else if (post) {
43
- post(t[part], path);
44
- }
45
- }
24
+ const retval = {};
25
+ for (const path of paths) {
26
+ const parts = path.split("/");
27
+ if (parts.length <= 1) {
28
+ continue;
46
29
  }
47
- return retval;
30
+ let t = retval;
31
+ for (let i = 1; i < parts.length; ++i) {
32
+ const part = parts[i];
33
+ if (t[part] == null) {
34
+ t[part] = init();
35
+ }
36
+ if (i !== parts.length - 1) {
37
+ t[part] = pre(t[part], path);
38
+ }
39
+ if (i !== parts.length - 1) {
40
+ t = next(t[part]);
41
+ } else if (post) {
42
+ post(t[part], path);
43
+ }
44
+ }
45
+ }
46
+ return retval;
48
47
  }
49
48
  function filt(path, filter, renamer) {
50
- return path.includes(filter) || path.split("/").map(renamer).join("/").includes(filter);
49
+ return path.includes(filter) || path.split("/").map(renamer).join("/").includes(filter);
51
50
  }
52
51
  function populate(filter, info, renamer) {
53
- return apply(filter.length > 0 ? info.filter((path) => filt(path, filter, renamer)) : info, () => ({ url: null, sub: {} }), (t) => t, (t) => t.sub, (t, p) => {
54
- t.url = p;
55
- });
52
+ return apply(
53
+ filter.length > 0 ? info.filter((path) => filt(path, filter, renamer)) : info,
54
+ () => ({ url: null, sub: {} }),
55
+ (t) => t,
56
+ (t) => t.sub,
57
+ (t, p) => {
58
+ t.url = p;
59
+ }
60
+ );
56
61
  }
57
- export {};
58
62
  </script>
59
63
  <script>import Tree from "./Tree.svelte";
60
64
  export let info;
@@ -62,21 +66,27 @@ export let selected;
62
66
  export let sorter;
63
67
  export let renamer;
64
68
  let filter = "";
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;
69
+ let states = apply(
70
+ info,
71
+ () => ({ expanded: false, sub: {} }),
72
+ (t, path) => ({ expanded: t.expanded || selected === path, sub: t.sub }),
73
+ (t) => t.sub
74
+ );
75
+ function update(selected2) {
76
+ if (!info.includes(selected2)) {
77
+ return;
78
+ }
79
+ let node = states;
80
+ const paths = selected2.split("/").slice(1);
81
+ for (const [i, p] of paths.entries()) {
82
+ if (i < paths.length - 1) {
83
+ node[p].expanded = true;
77
84
  }
85
+ node = node[p].sub;
86
+ }
78
87
  }
79
- $: update(selected);
88
+ $:
89
+ update(selected);
80
90
  </script>
81
91
  <div class="nav">
82
92
  <div class="logo"><slot /></div>
@@ -54,15 +54,16 @@ export let states;
54
54
  export let sorter;
55
55
  export let renamer;
56
56
  const dispatch = createEventDispatcher();
57
- $: style = `padding-left: ${10 + depth * 10}px;`;
58
- $: has_children = Object.keys(value.sub).length > 0;
57
+ $:
58
+ style = `padding-left: ${10 + depth * 10}px;`;
59
+ $:
60
+ has_children = Object.keys(value.sub).length > 0;
59
61
  function click(link) {
60
- if (link != null && selected !== link) {
61
- dispatch("navigate", link);
62
- }
63
- else if (has_children) {
64
- states.expanded = !states.expanded;
65
- }
62
+ if (link != null && selected !== link) {
63
+ dispatch("navigate", link);
64
+ } else if (has_children) {
65
+ states.expanded = !states.expanded;
66
+ }
66
67
  }
67
68
  </script>
68
69
  <div class="wrapper">
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
7
7
  },
8
- "peerDependencies": {
9
- "svelte": "^3.55.0"
10
- },
8
+ "license": "ISC",
11
9
  "devDependencies": {
12
10
  "@sveltejs/adapter-vercel": "^1.0.0",
13
11
  "@sveltejs/kit": "^1.0.1",
@@ -15,12 +13,13 @@
15
13
  "mdsvex": "^0.10.6",
16
14
  "svelte-check": "^2.10.2",
17
15
  "svelte-markdown": "^0.2.3",
18
- "svelte-preprocess": "^4.10.7",
19
16
  "tslib": "^2.4.1",
20
17
  "typescript": "^4.9.4",
21
- "vite": "^4.0.1"
18
+ "vite": "^4.0.2"
19
+ },
20
+ "peerDependencies": {
21
+ "svelte": "^3.55.0"
22
22
  },
23
- "type": "module",
24
23
  "publishConfig": {
25
24
  "linkDirectory": true
26
25
  },
@@ -29,7 +28,7 @@
29
28
  "documentation",
30
29
  "component"
31
30
  ],
32
- "license": "ISC",
31
+ "type": "module",
33
32
  "exports": {
34
33
  "./package.json": "./package.json",
35
34
  ".": "./index.js",