@nil-/doc 0.2.42 → 0.2.44

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.44
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc][new] tuple and object controls now collapsible without disabling ([#72](https://github.com/njaldea/mono/pull/72))
8
+
9
+ ## 0.2.43
10
+
11
+ ### Patch Changes
12
+
13
+ - [doc][fix] disable Range.svelte tooltip when disabled ([#70](https://github.com/njaldea/mono/pull/70))
14
+
15
+ - [doc][new] added auto scroll when content of layout is only one component ([#70](https://github.com/njaldea/mono/pull/70))
16
+
3
17
  ## 0.2.42
4
18
 
5
19
  ### Patch Changes
@@ -31,6 +31,7 @@
31
31
  .icon {
32
32
  width: 100%;
33
33
  height: 100%;
34
+ cursor: pointer;
34
35
  transition: transform 350ms;
35
36
  }
36
37
 
@@ -47,13 +48,15 @@
47
48
  }
48
49
 
49
50
  /* scrollable */
50
- .scrollable {
51
+ .scrollable,
52
+ .page > :global(*:only-child) {
51
53
  overflow: scroll;
52
54
  scrollbar-width: none; /* Firefox */
53
55
  -ms-overflow-style: none; /* IE and Edge */
54
56
  }
55
57
 
56
- .scrollable::-webkit-scrollbar {
58
+ .scrollable::-webkit-scrollbar,
59
+ .page > :global(*:only-child::-webkit-scrollbar) {
57
60
  display: none;
58
61
  }
59
62
 
@@ -118,7 +121,8 @@ const toggle = () => {
118
121
  <div
119
122
  class="icon"
120
123
  title="Double click to open repo: https://github.com/njaldea/mono"
121
- on:dblclick={() => window.open("https://github.com/njaldea/mono", "_blank")}
124
+ on:click={() => window.open("https://github.com/njaldea/mono", "_blank")}
125
+ on:keypress={null}
122
126
  >
123
127
  <NilIcon />
124
128
  </div>
@@ -137,7 +141,7 @@ const toggle = () => {
137
141
  </div>
138
142
  </svelte:fragment>
139
143
  <svelte:fragment slot="B">
140
- <div class="content scrollable">
144
+ <div class="content page">
141
145
  {#key current}
142
146
  <slot />
143
147
  {/key}
@@ -1,5 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
+ import Name from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
@@ -10,7 +11,7 @@ $:
10
11
  value = enabled && !disabled ? ivalue : void 0;
11
12
  </script>
12
13
  <div>
13
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
14
+ <Name name={info.name} {depth} />
14
15
  <div><input type="number" bind:value={ivalue} disabled={!enabled || disabled} /></div>
15
16
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
16
17
  </div>
@@ -12,9 +12,10 @@ $:
12
12
  value = !disabled && enabled ? ivalue : void 0;
13
13
  $:
14
14
  values = info.values;
15
+ let expand = info.values.length > 0 ? true : void 0;
15
16
  </script>
16
- <Header name={info.name} bind:checked={enabled} {depth} {disabled} />
17
- {#if enabled && !disabled}
17
+ <Header name={info.name} bind:expand bind:checked={enabled} {depth} {disabled} />
18
+ {#if expand && enabled && !disabled}
18
19
  {#each values as info, i (i)}
19
20
  <Component
20
21
  {info}
@@ -27,12 +27,13 @@
27
27
  visibility: hidden;
28
28
  }
29
29
 
30
- .input:hover > .tooltip {
30
+ .input:hover > .tooltip:not(.disabled) {
31
31
  visibility: visible;
32
32
  }
33
33
  </style>
34
34
 
35
35
  <script>import { getDefault } from "./misc/defaulter";
36
+ import Name from "./misc/Name.svelte";
36
37
  export let value;
37
38
  export let info;
38
39
  export let depth;
@@ -41,11 +42,13 @@ let ivalue = value ?? getDefault(info);
41
42
  let enabled = value !== void 0;
42
43
  $:
43
44
  value = enabled && !disabled ? ivalue : void 0;
45
+ $:
46
+ flag = !enabled || disabled;
44
47
  </script>
45
48
  <div>
46
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
49
+ <Name name={info.name} {depth} />
47
50
  <div class="input">
48
- <div class="tooltip">
51
+ <div class="tooltip" class:disabled={flag}>
49
52
  Current Value: {ivalue}
50
53
  </div>
51
54
  <div>{ivalue.toFixed(2)}</div>
@@ -55,7 +58,7 @@ $:
55
58
  min={info.min}
56
59
  max={info.max}
57
60
  step={info.step}
58
- disabled={!enabled || disabled}
61
+ disabled={flag}
59
62
  />
60
63
  </div>
61
64
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
@@ -1,5 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
+ import Name from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
@@ -10,7 +11,7 @@ $:
10
11
  value = enabled && !disabled ? ivalue : void 0;
11
12
  </script>
12
13
  <div>
13
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
14
+ <Name name={info.name} {depth} />
14
15
  <div>
15
16
  <select bind:value={ivalue} disabled={!enabled || disabled}>
16
17
  {#each info.values as value}
@@ -1,5 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
+ import Name from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
@@ -10,7 +11,7 @@ $:
10
11
  value = enabled && !disabled ? ivalue : void 0;
11
12
  </script>
12
13
  <div>
13
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
14
+ <Name name={info.name} {depth} />
14
15
  <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled || disabled} /></div>
15
16
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
16
17
  </div>
@@ -1,5 +1,6 @@
1
1
 
2
2
  <script>import { getDefault } from "./misc/defaulter";
3
+ import Name from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
@@ -10,7 +11,7 @@ $:
10
11
  value = ienabled && !disabled ? ivalue : void 0;
11
12
  </script>
12
13
  <div>
13
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
14
+ <Name name={info.name} {depth} />
14
15
  <div><input type="text" bind:value={ivalue} disabled={!ienabled || disabled} /></div>
15
16
  <div><input type="checkbox" bind:checked={ienabled} {disabled} /></div>
16
17
  </div>
@@ -12,9 +12,10 @@ $:
12
12
  value = !disabled && enabled ? ivalue : void 0;
13
13
  $:
14
14
  values = info.values;
15
+ let expand = info.values.length > 0 ? true : void 0;
15
16
  </script>
16
- <Header name={info.name} bind:checked={enabled} {depth} {disabled} />
17
- {#if enabled && !disabled}
17
+ <Header name={info.name} bind:expand bind:checked={enabled} {depth} {disabled} />
18
+ {#if expand && enabled && !disabled}
18
19
  {#each values as info, i (i)}
19
20
  <Component
20
21
  info={{ ...info, name: `${i}` }}
@@ -4,16 +4,29 @@
4
4
  }
5
5
  </style>
6
6
 
7
- <script>export let name;
7
+ <script>import Name from "./Name.svelte";
8
+ export let name;
8
9
  export let depth;
9
10
  export let checked;
10
11
  export let disabled = false;
12
+ export let expand = void 0;
13
+ const flip = () => {
14
+ if (!disabled && checked) {
15
+ if (expand !== void 0) {
16
+ expand = !expand;
17
+ }
18
+ }
19
+ };
11
20
  </script>
12
- <div>
13
- <div style:padding-left={`${depth}px`} title={name}>
14
- {`> ${name}`}
15
- </div>
21
+ <div on:click={flip} on:keypress={null}>
22
+ <Name
23
+ expand={expand === undefined ? undefined : expand && checked && !disabled}
24
+ {name}
25
+ {depth}
26
+ />
16
27
  <div class="value">-</div>
17
- <div><input type="checkbox" bind:checked {disabled} /></div>
28
+ <div>
29
+ <input type="checkbox" {disabled} bind:checked on:click={(e) => e.stopPropagation()} />
30
+ </div>
18
31
  </div>
19
32
 
@@ -5,6 +5,7 @@ declare const __propDef: {
5
5
  depth: number;
6
6
  checked: boolean;
7
7
  disabled?: boolean | undefined;
8
+ expand?: boolean | undefined;
8
9
  };
9
10
  events: {
10
11
  [evt: string]: CustomEvent<any>;
@@ -0,0 +1,44 @@
1
+ <style>
2
+ .override {
3
+ overflow: hidden;
4
+ white-space: nowrap;
5
+ text-overflow: ellipsis;
6
+ padding-right: 10px;
7
+
8
+ display: grid;
9
+ grid-template-columns: 20px 1fr;
10
+ align-items: center;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ .icon {
15
+ display: flex;
16
+ flex-direction: column;
17
+ justify-content: center;
18
+ height: 15px;
19
+ width: 15px;
20
+ transition: transform 350ms;
21
+ }
22
+
23
+ .icon.expand {
24
+ transform: rotate(90deg);
25
+ }
26
+
27
+ .icon > div {
28
+ margin: auto;
29
+ }
30
+ </style>
31
+
32
+ <script>export let depth;
33
+ export let name;
34
+ export let expand = void 0;
35
+ </script>
36
+ <div class="override" style:padding-left={`${depth}px`} title={name}>
37
+ <div class="icon" class:expand={expand === true}>
38
+ <div>
39
+ {expand === undefined ? "-" : ">"}
40
+ </div>
41
+ </div>
42
+ <span>{name}</span>
43
+ </div>
44
+
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ depth: number;
5
+ name: string;
6
+ expand?: boolean | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type NameProps = typeof __propDef.props;
14
+ export type NameEvents = typeof __propDef.events;
15
+ export type NameSlots = typeof __propDef.slots;
16
+ export default class Name extends SvelteComponentTyped<NameProps, NameEvents, NameSlots> {
17
+ }
18
+ export {};
@@ -24,12 +24,7 @@ const dark = getTheme();
24
24
  grid-template-columns: minmax(250px, 1fr) 200px 40px;
25
25
  }
26
26
 
27
- div > :global(div > div) {
28
- display: grid;
29
- align-items: center;
30
- }
31
-
32
- div > :global(div > div > *) {
27
+ div > :global(div > div:not(:first-child) > *) {
33
28
  width: 100%;
34
29
  height: 100%;
35
30
  }
@@ -48,14 +43,6 @@ const dark = getTheme();
48
43
  background-color: hsl(210, 100%, 90%);
49
44
  }
50
45
 
51
- div > :global(div:nth-child(n + 2) > div:first-child) {
52
- overflow: hidden;
53
- white-space: nowrap;
54
- text-overflow: ellipsis;
55
- padding-right: 10px;
56
- display: block;
57
- }
58
-
59
46
  div > :global(div:hover .tooltip) {
60
47
  background-color: hsl(0, 0%, 100%);
61
48
  outline: hsl(0, 100%, 0%) 1px solid;
@@ -1,47 +1,39 @@
1
+ <script>import { tweened } from "svelte/motion";
2
+ const d = "M 0 -15 L 15 -15 L 15 0 L 0 0 -9 0 A 6 8 135 0 1 9 0";
3
+ const length = tweened(100);
4
+ const trigger = () => {
5
+ if (0 === $length) {
6
+ $length = 100;
7
+ } else if (100 === $length) {
8
+ $length = 0;
9
+ }
10
+ };
11
+ $:
12
+ 0 === $length && trigger();
13
+ </script>
1
14
  <style>
2
15
  svg {
3
16
  width: 100%;
4
17
  height: 100%;
5
- fill: transparent;
6
- stroke: currentColor;
7
18
  stroke-width: 4;
8
19
  stroke-linejoin: miter;
9
- cursor: pointer;
20
+ stroke: currentColor;
21
+ fill: transparent;
10
22
  }
11
23
  </style>
12
24
 
13
- <script>import { tweened } from "svelte/motion";
14
- const action = (p, options) => {
15
- const total = p.getTotalLength();
16
- p.style.strokeDasharray = `${total * options.length} ${total}`;
17
- return {
18
- update: (options2) => {
19
- const total2 = p.getTotalLength();
20
- p.style.strokeDasharray = `${total2 * options2.length} ${total2}`;
21
- }
22
- };
23
- };
24
- const d = "M 0 -15 L 15 -15 L 15 0 L 0 0 -9 0 A 6 8 135 0 1 9 0";
25
- const length = tweened(1);
26
- let out = false;
27
- const click = () => {
28
- if (0 === $length) {
29
- $length = 1;
30
- out = false;
31
- } else if (!out) {
32
- $length = 0;
33
- out = true;
34
- }
25
+ <script context="module">const action = (p, length) => {
26
+ const update = (length2) => p.style.strokeDasharray = `${length2} 100`;
27
+ update(length);
28
+ return { update };
35
29
  };
36
- $:
37
- 0 === $length && click();
38
30
  </script>
39
- <svg viewBox="-35 -35 70 70" on:click={click} on:keypress={null}>
31
+ <svg viewBox="-35 -35 70 70" on:pointerenter={trigger}>
40
32
  <g transform="rotate(45 0 0)">
41
- <path {d} use:action={{ length: $length }} />
33
+ <path {d} use:action={$length} />
42
34
  </g>
43
35
  <g transform="rotate(225 0 0)">
44
- <path {d} use:action={{ length: $length }} />
36
+ <path {d} use:action={$length} />
45
37
  </g>
46
38
  </svg>
47
39
 
@@ -7,7 +7,6 @@ const index = indexer++;
7
7
  </script>
8
8
  <style>
9
9
  svg {
10
- cursor: pointer;
11
10
  fill: currentColor;
12
11
  stroke: currentColor;
13
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.42",
3
+ "version": "0.2.44",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"
@@ -20,8 +20,6 @@ const isRouteDynamic = (p) => null == routeIsDynamic.exec(p);
20
20
  export const sveltekit = (detail, prefix = null) => {
21
21
  const key = "@nil-/doc/theme";
22
22
  const initialValue = browser && "light" === localStorage.getItem(key) ? "light" : "dark";
23
- const theme = writable(initialValue);
24
- theme.subscribe((v) => browser && localStorage.setItem(key, v));
25
23
  const result = {
26
24
  data: Object.keys(detail)
27
25
  .map(toRoute)
@@ -38,7 +36,8 @@ export const sveltekit = (detail, prefix = null) => {
38
36
  return null;
39
37
  }),
40
38
  navigate: prefix ? (e) => goto(`${prefix}${e.detail}`) : (e) => goto(e.detail),
41
- theme
39
+ theme: writable(initialValue)
42
40
  };
41
+ browser && result.theme.subscribe((v) => localStorage.setItem(key, v));
43
42
  return result;
44
43
  };