@nil-/doc 0.2.43 → 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,11 @@
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
+
3
9
  ## 0.2.43
4
10
 
5
11
  ### 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
 
@@ -120,7 +121,8 @@ const toggle = () => {
120
121
  <div
121
122
  class="icon"
122
123
  title="Double click to open repo: https://github.com/njaldea/mono"
123
- 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}
124
126
  >
125
127
  <NilIcon />
126
128
  </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><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}
@@ -33,6 +33,7 @@
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;
@@ -45,7 +46,7 @@ $:
45
46
  flag = !enabled || disabled;
46
47
  </script>
47
48
  <div>
48
- <div style:padding-left={`${depth}px`} title={info.name}>- {info.name}</div>
49
+ <Name name={info.name} {depth} />
49
50
  <div class="input">
50
51
  <div class="tooltip" class:disabled={flag}>
51
52
  Current Value: {ivalue}
@@ -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.43",
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
  };