@nil-/doc 0.2.50 → 0.2.51

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 (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/components/Layout.svelte +37 -71
  3. package/components/block/Block.svelte +67 -25
  4. package/components/block/Controls.svelte +3 -5
  5. package/components/block/Controls.svelte.d.ts +2 -2
  6. package/components/block/Instance.svelte +41 -74
  7. package/components/block/context.d.ts +2 -2
  8. package/components/block/context.js +2 -1
  9. package/components/block/controls/events/Events.svelte +14 -5
  10. package/components/block/controls/events/misc/Styler.svelte +16 -41
  11. package/components/block/controls/props/Color.svelte +21 -0
  12. package/components/block/controls/props/Color.svelte.d.ts +21 -0
  13. package/components/block/controls/props/Component.svelte +5 -0
  14. package/components/block/controls/props/Number.svelte +4 -5
  15. package/components/block/controls/props/Object.svelte +8 -11
  16. package/components/block/controls/props/Props.svelte +2 -5
  17. package/components/block/controls/props/Range.svelte +5 -4
  18. package/components/block/controls/props/Select.svelte +5 -8
  19. package/components/block/controls/props/Switch.svelte +4 -5
  20. package/components/block/controls/props/Text.svelte +8 -9
  21. package/components/block/controls/props/Tuple.svelte +13 -26
  22. package/components/block/controls/props/misc/Name.svelte +1 -2
  23. package/components/block/controls/props/misc/Styler.svelte +22 -29
  24. package/components/block/controls/props/misc/defaulter.d.ts +8 -8
  25. package/components/block/controls/props/misc/defaulter.js +28 -48
  26. package/components/block/controls/props/misc/utils.d.ts +11 -0
  27. package/components/block/controls/props/misc/utils.js +31 -0
  28. package/components/block/controls/types.d.ts +10 -2
  29. package/components/block/icons/Button.svelte +30 -0
  30. package/components/block/icons/Button.svelte.d.ts +35 -0
  31. package/components/block/icons/ControlView.svelte +14 -0
  32. package/components/block/icons/ControlView.svelte.d.ts +16 -0
  33. package/components/block/icons/Position.svelte +50 -0
  34. package/components/block/icons/Position.svelte.d.ts +16 -0
  35. package/components/etc/Base.svelte +58 -0
  36. package/components/etc/Base.svelte.d.ts +18 -0
  37. package/components/etc/Container.svelte +24 -37
  38. package/components/etc/Content.svelte +45 -0
  39. package/components/etc/Content.svelte.d.ts +18 -0
  40. package/components/icons/NilDoc.svelte +1 -1
  41. package/components/icons/Theme.svelte +0 -5
  42. package/components/navigation/Nav.svelte +6 -10
  43. package/components/navigation/Node.svelte +9 -10
  44. package/components/title/Icon.svelte +3 -3
  45. package/package.json +1 -1
@@ -0,0 +1,21 @@
1
+ <script>import { getName } from "./misc/utils";
2
+ import { defaulter } from "./misc/defaulter";
3
+ import NameHeader from "./misc/Name.svelte";
4
+ export let value;
5
+ export let info;
6
+ export let depth;
7
+ export let disabled = false;
8
+ export let visible = false;
9
+ let ivalue = value ?? defaulter(info);
10
+ let enabled = value !== void 0;
11
+ $:
12
+ value = enabled && !disabled ? ivalue : void 0;
13
+ </script>
14
+
15
+ {#if visible}
16
+ <div>
17
+ <NameHeader name={getName(info)} {depth} />
18
+ <div><input type="color" bind:value={ivalue} disabled={!enabled || disabled} /></div>
19
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
20
+ </div>
21
+ {/if}
@@ -0,0 +1,21 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { Unionized, PropType } from "../types";
3
+ declare const __propDef: {
4
+ props: {
5
+ value: string | undefined;
6
+ info: Unionized<PropType<"color">>;
7
+ depth: number;
8
+ disabled?: boolean | undefined;
9
+ visible?: boolean | undefined;
10
+ };
11
+ events: {
12
+ [evt: string]: CustomEvent<any>;
13
+ };
14
+ slots: {};
15
+ };
16
+ export type ColorProps = typeof __propDef.props;
17
+ export type ColorEvents = typeof __propDef.events;
18
+ export type ColorSlots = typeof __propDef.slots;
19
+ export default class Color extends SvelteComponentTyped<ColorProps, ColorEvents, ColorSlots> {
20
+ }
21
+ export {};
@@ -5,6 +5,7 @@ import Switch from "./Switch.svelte";
5
5
  import Select from "./Select.svelte";
6
6
  import Tuple from "./Tuple.svelte";
7
7
  import Object from "./Object.svelte";
8
+ import Color from "./Color.svelte";
8
9
  export let value;
9
10
  export let info;
10
11
  export let depth;
@@ -20,6 +21,8 @@ export let visible = false;
20
21
  <Tuple {info} bind:value {depth} {disabled} {visible} />
21
22
  {:else if "text" === type}
22
23
  <Text {info} bind:value {depth} {disabled} {visible} />
24
+ {:else if "color" === type}
25
+ <Color {info} bind:value {depth} {disabled} {visible} />
23
26
  {:else if "number" === type}
24
27
  <Number {info} bind:value {depth} {disabled} {visible} />
25
28
  {:else if "range" === type}
@@ -37,6 +40,8 @@ export let visible = false;
37
40
  <Tuple {info} bind:value {depth} {disabled} {visible} />
38
41
  {:else if "text" === type}
39
42
  <Text {info} bind:value {depth} {disabled} {visible} />
43
+ {:else if "color" === type}
44
+ <Color {info} bind:value {depth} {disabled} {visible} />
40
45
  {:else if "number" === type}
41
46
  <Number {info} bind:value {depth} {disabled} {visible} />
42
47
  {:else if "range" === type}
@@ -1,21 +1,20 @@
1
- <script>import { getDefault } from "./misc/defaulter";
1
+ <script>import { getName } from "./misc/utils";
2
+ import { defaulter } from "./misc/defaulter";
2
3
  import NameHeader from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
6
7
  export let disabled = false;
7
8
  export let visible = false;
8
- let ivalue = value ?? getDefault(info);
9
+ let ivalue = value ?? defaulter(info);
9
10
  let enabled = value !== void 0;
10
11
  $:
11
12
  value = enabled && !disabled ? ivalue : void 0;
12
- $:
13
- name = info instanceof Array ? info[0] : info.name;
14
13
  </script>
15
14
 
16
15
  {#if visible}
17
16
  <div>
18
- <NameHeader {name} {depth} />
17
+ <NameHeader name={getName(info)} {depth} />
19
18
  <div><input type="number" bind:value={ivalue} disabled={!enabled || disabled} /></div>
20
19
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
21
20
  </div>
@@ -1,28 +1,25 @@
1
1
  <script>import Component from "./Component.svelte";
2
2
  import Header from "./misc/GroupHeader.svelte";
3
- import { getDefault } from "./misc/defaulter";
3
+ import { defaulter } from "./misc/defaulter";
4
+ import { getValues, getName } from "./misc/utils";
4
5
  export let value;
5
6
  export let info;
6
7
  export let depth;
7
8
  export let disabled = false;
8
9
  export let visible = false;
9
- let ivalue = value ?? getDefault(info);
10
+ let ivalue = value ?? defaulter(info);
10
11
  let enabled = value !== void 0;
11
- let expand = info.values.length > 0 ? true : void 0;
12
+ let expand = getValues(info).length > 0 ? true : void 0;
12
13
  $:
13
14
  value = !disabled && enabled ? ivalue : void 0;
14
- $:
15
- values = info instanceof Array ? info[2] : info.values;
16
- $:
17
- name = info instanceof Array ? info[0] : info.name;
18
15
  </script>
19
16
 
20
- <Header {name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
17
+ <Header name={getName(info)} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
21
18
 
22
- {#each values as info, i (i)}
19
+ {#each getValues(info) as v, i (i)}
23
20
  <Component
24
- {info}
25
- bind:value={ivalue[name]}
21
+ info={v}
22
+ bind:value={ivalue[getName(v)]}
26
23
  depth={depth + 10}
27
24
  disabled={!enabled || disabled}
28
25
  visible={visible && expand && enabled && !disabled}
@@ -1,5 +1,6 @@
1
1
  <script>import Component from "./Component.svelte";
2
2
  import Styler from "./misc/Styler.svelte";
3
+ import { getName } from "./misc/utils";
3
4
  export let infos;
4
5
  export let values;
5
6
  export let visible;
@@ -10,10 +11,6 @@ export let visible;
10
11
  <slot />
11
12
  {/if}
12
13
  {#each infos as info}
13
- {#if info instanceof Array}
14
- <Component {info} bind:value={values[info[0]]} depth={10} {visible} />
15
- {:else}
16
- <Component {info} bind:value={values[info.name]} depth={10} {visible} />
17
- {/if}
14
+ <Component {info} bind:value={values[getName(info)]} depth={10} {visible} />
18
15
  {/each}
19
16
  </Styler>
@@ -1,4 +1,4 @@
1
- <script>import { getDefault } from "./misc/defaulter";
1
+ <script>import { defaulter } from "./misc/defaulter";
2
2
  import NameHeader from "./misc/Name.svelte";
3
3
  import { nformat } from "./misc/nformat";
4
4
  export let value;
@@ -6,7 +6,7 @@ export let info;
6
6
  export let depth;
7
7
  export let disabled = false;
8
8
  export let visible = false;
9
- let ivalue = value ?? getDefault(info);
9
+ let ivalue = value ?? defaulter(info);
10
10
  let enabled = value !== void 0;
11
11
  $:
12
12
  value = enabled && !disabled ? ivalue : void 0;
@@ -49,9 +49,10 @@ $:
49
49
  .input {
50
50
  width: 100%;
51
51
  display: grid;
52
- grid-template-columns: 65px 1fr;
53
- gap: 5px;
52
+ grid-template-columns: 4rem 1fr;
53
+ gap: 0.3125rem;
54
54
  position: relative;
55
+ box-sizing: border-box;
55
56
  }
56
57
 
57
58
  .input > div {
@@ -1,26 +1,23 @@
1
- <script>import { getDefault } from "./misc/defaulter";
1
+ <script>import { defaulter } from "./misc/defaulter";
2
+ import { getValues, getName } from "./misc/utils";
2
3
  import NameHeader from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
6
7
  export let disabled = false;
7
8
  export let visible = false;
8
- let ivalue = value ?? getDefault(info);
9
+ let ivalue = value ?? defaulter(info);
9
10
  let enabled = value !== void 0;
10
11
  $:
11
12
  value = enabled && !disabled ? ivalue : void 0;
12
- $:
13
- name = info instanceof Array ? info[0] : info.name;
14
- $:
15
- values = info instanceof Array ? info[2] : info.values;
16
13
  </script>
17
14
 
18
15
  {#if visible}
19
16
  <div>
20
- <NameHeader {name} {depth} />
17
+ <NameHeader name={getName(info)} {depth} />
21
18
  <div>
22
19
  <select bind:value={ivalue} disabled={!enabled || disabled}>
23
- {#each values as v}
20
+ {#each getValues(info) as v}
24
21
  <option value={v}>{v}</option>
25
22
  {/each}
26
23
  </select>
@@ -1,21 +1,20 @@
1
- <script>import { getDefault } from "./misc/defaulter";
1
+ <script>import { getName } from "./misc/utils";
2
+ import { defaulter } from "./misc/defaulter";
2
3
  import NameHeader from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
6
7
  export let disabled = false;
7
8
  export let visible = false;
8
- let ivalue = value ?? getDefault(info);
9
+ let ivalue = value ?? defaulter(info);
9
10
  let enabled = value !== void 0;
10
11
  $:
11
12
  value = enabled && !disabled ? ivalue : void 0;
12
- $:
13
- name = info instanceof Array ? info[0] : info.name;
14
13
  </script>
15
14
 
16
15
  {#if visible}
17
16
  <div>
18
- <NameHeader {name} {depth} />
17
+ <NameHeader name={getName(info)} {depth} />
19
18
  <div><input type="checkbox" bind:checked={ivalue} disabled={!enabled || disabled} /></div>
20
19
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
21
20
  </div>
@@ -1,22 +1,21 @@
1
- <script>import { getDefault } from "./misc/defaulter";
1
+ <script>import { getName } from "./misc/utils";
2
+ import { defaulter } from "./misc/defaulter";
2
3
  import NameHeader from "./misc/Name.svelte";
3
4
  export let value;
4
5
  export let info;
5
6
  export let depth;
6
7
  export let disabled = false;
7
8
  export let visible = false;
8
- let ivalue = value ?? getDefault(info);
9
- let ienabled = value !== void 0;
9
+ let ivalue = value ?? defaulter(info);
10
+ let enabled = value !== void 0;
10
11
  $:
11
- value = ienabled && !disabled ? ivalue : void 0;
12
- $:
13
- name = info instanceof Array ? info[0] : info.name;
12
+ value = enabled && !disabled ? ivalue : void 0;
14
13
  </script>
15
14
 
16
15
  {#if visible}
17
16
  <div>
18
- <NameHeader {name} {depth} />
19
- <div><input type="text" bind:value={ivalue} disabled={!ienabled || disabled} /></div>
20
- <div><input type="checkbox" bind:checked={ienabled} {disabled} /></div>
17
+ <NameHeader name={getName(info)} {depth} />
18
+ <div><input type="text" bind:value={ivalue} disabled={!enabled || disabled} /></div>
19
+ <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
21
20
  </div>
22
21
  {/if}
@@ -1,40 +1,27 @@
1
1
  <script>import Component from "./Component.svelte";
2
2
  import Header from "./misc/GroupHeader.svelte";
3
- import { getDefault } from "./misc/defaulter";
3
+ import { defaulter } from "./misc/defaulter";
4
+ import { getValues, getName, addName } from "./misc/utils";
4
5
  export let value;
5
6
  export let info;
6
7
  export let depth;
7
8
  export let disabled = false;
8
9
  export let visible = false;
9
- let ivalue = value ?? getDefault(info);
10
+ let ivalue = value ?? defaulter(info);
10
11
  let enabled = value !== void 0;
12
+ let expand = getValues(info).length > 0 ? true : void 0;
11
13
  $:
12
14
  value = !disabled && enabled ? ivalue : void 0;
13
- $:
14
- values = info instanceof Array ? info[2] : info.values;
15
- $:
16
- name = info instanceof Array ? info[0] : info.name;
17
- let expand = info.values.length > 0 ? true : void 0;
18
15
  </script>
19
16
 
20
- <Header {name} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
17
+ <Header name={getName(info)} bind:expand bind:checked={enabled} {depth} {disabled} {visible} />
21
18
 
22
- {#each values as v, i (i)}
23
- {#if v instanceof Array}
24
- <Component
25
- info={[`${i}`, ...v]}
26
- bind:value={ivalue[i]}
27
- depth={depth + 10}
28
- disabled={!enabled || disabled}
29
- visible={visible && expand && enabled && !disabled}
30
- />
31
- {:else}
32
- <Component
33
- info={{ ...v, name: `${i}` }}
34
- bind:value={ivalue[i]}
35
- depth={depth + 10}
36
- disabled={!enabled || disabled}
37
- visible={visible && expand && enabled && !disabled}
38
- />
39
- {/if}
19
+ {#each getValues(info) as v, i (i)}
20
+ <Component
21
+ info={addName(`${i}`, v)}
22
+ bind:value={ivalue[i]}
23
+ depth={depth + 10}
24
+ disabled={!enabled || disabled}
25
+ visible={visible && expand && enabled && !disabled}
26
+ />
40
27
  {/each}
@@ -22,7 +22,6 @@ export let expand = void 0;
22
22
  display: grid;
23
23
  grid-template-columns: 20px 1fr;
24
24
  align-items: center;
25
- box-sizing: border-box;
26
25
  }
27
26
 
28
27
  .icon {
@@ -31,7 +30,7 @@ export let expand = void 0;
31
30
  justify-content: center;
32
31
  height: 15px;
33
32
  width: 15px;
34
- transition: transform 350ms;
33
+ transition: transform var(--i-nil-doc-transition-time);
35
34
  }
36
35
 
37
36
  .icon.expand {
@@ -23,11 +23,10 @@ const dark = getTheme();
23
23
 
24
24
  <style>
25
25
  div {
26
- width: 100%;
27
- min-width: 500px;
28
- overflow: hidden;
29
26
  display: grid;
30
- grid-auto-rows: 30px;
27
+ overflow: hidden;
28
+ min-width: 31.25rem;
29
+ grid-auto-rows: 2rem;
31
30
  box-sizing: border-box;
32
31
  }
33
32
 
@@ -40,49 +39,43 @@ const dark = getTheme();
40
39
 
41
40
  div > :global(div) {
42
41
  display: grid;
43
- width: 100%;
44
- padding: 2px 0px;
45
- grid-template-columns: minmax(250px, 1fr) 200px 40px;
42
+ grid-template-columns: minmax(15rem, 1fr) 12.5rem 2.5rem;
46
43
  }
47
44
 
48
45
  div > :global(div:first-child) {
49
- text-align: center;
50
46
  font-weight: bold;
47
+ place-items: center;
48
+ }
49
+
50
+ div > :global(div > div:not(:first-child)) {
51
+ display: grid;
52
+ place-items: center;
51
53
  }
52
54
 
53
55
  div > :global(div > div:not(:first-child) > *) {
54
56
  width: 100%;
55
- height: 100%;
57
+ height: 80%;
58
+ font-size: 1rem;
56
59
  }
57
60
 
58
61
  /* colors */
59
62
  div {
60
- --pri-color: hsl(0, 0%, 100%);
61
- --sec-color: hsl(210, 29%, 97%);
62
- --hover-color: hsl(210, 100%, 90%);
63
- --outline-color: hsl(0, 0%, 0%);
64
- }
65
-
66
- div.dark {
67
- --pri-color: hsl(213, 26%, 7%);
68
- --sec-color: hsl(213, 26%, 11%);
69
- --hover-color: hsl(203, 100%, 15%);
70
- --outline-color: hsl(200, 6%, 80%);
71
- }
72
-
73
- div {
74
- transition: background-color 150ms;
63
+ transition: background-color var(--i-nil-doc-transition-time);
75
64
  background-repeat: repeat;
76
- background-size: 100% 60px;
77
- background-image: linear-gradient(to bottom, var(--pri-color) 30px, var(--sec-color) 30px);
65
+ background-size: 100% 4rem;
66
+ background-image: linear-gradient(
67
+ to bottom,
68
+ var(--i-nil-doc-controls-p) 2rem,
69
+ var(--i-nil-doc-controls-s) 2rem
70
+ );
78
71
  }
79
72
 
80
73
  div > :global(div:nth-child(n + 2):hover) {
81
- background-color: var(--hover-color);
74
+ background-color: var(--i-nil-doc-controls-hover);
82
75
  }
83
76
 
84
77
  div > :global(div:hover .tooltip) {
85
- background-color: var(--pri-color);
86
- outline: var(--outline-color) 1px solid;
78
+ background-color: var(--i-nil-doc-controls-p);
79
+ outline: 1px solid var(--i-nil-doc-block-outline-color);
87
80
  }
88
81
  </style>
@@ -1,10 +1,10 @@
1
1
  import type { ValueType } from "../../../types";
2
2
  import type { Unionized, PropType, Prop } from "../../types";
3
- export declare function getDefault(i: Unionized<PropType<"tuple">>): ValueType[];
4
- export declare function getDefault(i: Unionized<PropType<"object">>): Record<string, ValueType>;
5
- export declare function getDefault(i: Unionized<PropType<"number">>): number;
6
- export declare function getDefault(i: Unionized<PropType<"range">>): number;
7
- export declare function getDefault(i: Unionized<PropType<"select">>): string;
8
- export declare function getDefault(i: Unionized<PropType<"text">>): string;
9
- export declare function getDefault(i: Unionized<PropType<"switch">>): boolean;
10
- export declare function getDefault(i: Prop): ValueType;
3
+ export declare function defaulter(i: Unionized<PropType<"tuple">>): ValueType[];
4
+ export declare function defaulter(i: Unionized<PropType<"object">>): Record<string, ValueType>;
5
+ export declare function defaulter(i: Unionized<PropType<"number">>): number;
6
+ export declare function defaulter(i: Unionized<PropType<"range">>): number;
7
+ export declare function defaulter(i: Unionized<PropType<"select">>): string;
8
+ export declare function defaulter(i: Unionized<PropType<"text">>): string;
9
+ export declare function defaulter(i: Unionized<PropType<"switch">>): boolean;
10
+ export declare function defaulter(i: Prop): ValueType;
@@ -1,70 +1,50 @@
1
+ import { getType, getValues, getMin } from "./utils";
1
2
  // eslint-disable-next-line func-style
2
- export function getDefault(i) {
3
- if (i instanceof Array) {
4
- switch (i[1]) {
5
- case "object":
6
- // eslint-disable-next-line no-use-before-define
7
- return getObjectDefaults(i);
8
- case "tuple":
9
- // eslint-disable-next-line no-use-before-define
10
- return getTupleDefaults(i);
11
- case "text":
12
- return "";
13
- case "select":
14
- return i[2].length > 0 ? i[2][0] : "";
15
- case "number":
16
- return 0;
17
- case "range":
18
- return i[2];
19
- case "switch":
20
- default:
21
- return false;
22
- }
23
- }
24
- else {
25
- switch (i.type) {
26
- case "object":
27
- // eslint-disable-next-line no-use-before-define
28
- return getObjectDefaults(i);
29
- case "tuple":
30
- // eslint-disable-next-line no-use-before-define
31
- return getTupleDefaults(i);
32
- case "text":
33
- return "";
34
- case "select":
35
- return i.values.length > 0 ? i.values[0] : "";
36
- case "number":
37
- return 0;
38
- case "range":
39
- return i.min;
40
- case "switch":
41
- default:
42
- return false;
43
- }
3
+ export function defaulter(i) {
4
+ switch (getType(i)) {
5
+ case "object":
6
+ // eslint-disable-next-line no-use-before-define
7
+ return defaulterO(i);
8
+ case "tuple":
9
+ // eslint-disable-next-line no-use-before-define
10
+ return defaulterT(i);
11
+ case "text":
12
+ return "";
13
+ case "color":
14
+ return "";
15
+ case "select":
16
+ return getValues(i)[0] ?? "";
17
+ case "number":
18
+ return 0;
19
+ case "range":
20
+ return getMin(i);
21
+ case "switch":
22
+ default:
23
+ return false;
44
24
  }
45
25
  }
46
- const getObjectDefaults = (info) => {
26
+ const defaulterO = (info) => {
47
27
  const ret = {};
48
28
  const values = info instanceof Array ? info[2] : info.values;
49
29
  for (const v of values) {
50
30
  if (v instanceof Array) {
51
- ret[v[0]] = getDefault(v);
31
+ ret[v[0]] = defaulter(v);
52
32
  }
53
33
  else {
54
- ret[v.name] = getDefault(v);
34
+ ret[v.name] = defaulter(v);
55
35
  }
56
36
  }
57
37
  return ret;
58
38
  };
59
- const getTupleDefaults = (info) => {
39
+ const defaulterT = (info) => {
60
40
  const ret = [];
61
41
  const values = info instanceof Array ? info[2] : info.values;
62
42
  for (const [i, v] of values.entries()) {
63
43
  if (v instanceof Array) {
64
- ret.push(getDefault([`${i}`, ...v]));
44
+ ret.push(defaulter([`${i}`, ...v]));
65
45
  }
66
46
  else {
67
- ret.push(getDefault({ name: `${i}`, ...v }));
47
+ ret.push(defaulter({ name: `${i}`, ...v }));
68
48
  }
69
49
  }
70
50
  return ret;
@@ -0,0 +1,11 @@
1
+ import type { Detailed, Unionized, PropType, Prop, NonNamedProp } from "../../types";
2
+ type TypesWithValue = "object" | "tuple" | "select";
3
+ type Values<T extends TypesWithValue> = Detailed<PropType<T>>["values"];
4
+ export declare function getValues(info: Unionized<PropType<"select">>): Values<"select">;
5
+ export declare function getValues(info: Unionized<PropType<"object">>): Values<"object">;
6
+ export declare function getValues(info: Unionized<PropType<"tuple">>): Values<"tuple">;
7
+ export declare const getMin: (info: Unionized<PropType<"range">>) => number;
8
+ export declare const getType: (info: Prop) => "number" | "object" | "select" | "text" | "color" | "switch" | "range" | "tuple";
9
+ export declare const getName: (info: Prop) => string;
10
+ export declare const addName: (name: string, info: NonNamedProp) => Prop;
11
+ export {};
@@ -0,0 +1,31 @@
1
+ // eslint-disable-next-line func-style
2
+ export function getValues(info) {
3
+ if (info instanceof Array) {
4
+ return info[2];
5
+ }
6
+ return info.values;
7
+ }
8
+ export const getMin = (info) => {
9
+ if (info instanceof Array) {
10
+ return info[2];
11
+ }
12
+ return info.min;
13
+ };
14
+ export const getType = (info) => {
15
+ if (info instanceof Array) {
16
+ return info[1];
17
+ }
18
+ return info.type;
19
+ };
20
+ export const getName = (info) => {
21
+ if (info instanceof Array) {
22
+ return info[0];
23
+ }
24
+ return info.name;
25
+ };
26
+ export const addName = (name, info) => {
27
+ if (info instanceof Array) {
28
+ return [name, ...info];
29
+ }
30
+ return { ...info, name };
31
+ };
@@ -1,4 +1,4 @@
1
- type Types = "text" | "number" | "select" | "range" | "switch" | "tuple" | "object";
1
+ type Types = "text" | "color" | "number" | "select" | "range" | "switch" | "tuple" | "object";
2
2
 
3
3
  // prettier-ignore
4
4
  export type PropType<T extends Types> =
@@ -6,6 +6,10 @@ export type PropType<T extends Types> =
6
6
  [ name: string, type: T ],
7
7
  { name: string; type: T; }
8
8
  ]
9
+ : T extends "color" ? [
10
+ [ name: string, type: T ],
11
+ { name: string; type: T; }
12
+ ]
9
13
  : T extends "number" ? [
10
14
  [ name: string, type: T ],
11
15
  { name: string; type: T; }
@@ -44,6 +48,8 @@ export type Unionized<T extends PropTyoe> = T[number];
44
48
  export type Prop =
45
49
  | [ name: string, type: "text" ]
46
50
  | { name: string; type: "text"; }
51
+ | [ name: string, type: "color" ]
52
+ | { name: string; type: "color"; }
47
53
  | [ name: string, type: "number" ]
48
54
  | { name: string; type: "number"; }
49
55
  | [ name: string, type: "switch" ]
@@ -60,9 +66,11 @@ export type Prop =
60
66
  | { name: string; type: "object"; values: Prop[]; };
61
67
 
62
68
  // prettier-ignore
63
- type NonNamedProp =
69
+ export type NonNamedProp =
64
70
  | [ type: "text" ]
65
71
  | { type: "text"; }
72
+ | [ type: "color" ]
73
+ | { type: "color"; }
66
74
  | [ type: "number" ]
67
75
  | { type: "number"; }
68
76
  | [ type: "switch" ]
@@ -0,0 +1,30 @@
1
+ <script>
2
+ export let title = "";
3
+ export let scale = false;
4
+ </script>
5
+
6
+ <div on:click on:keypress {title} class:scale>
7
+ <slot />
8
+ </div>
9
+
10
+ <style>
11
+ div {
12
+ width: 100%;
13
+ height: 100%;
14
+ display: grid;
15
+ place-items: center;
16
+ transition: transform var(--i-nil-doc-transition-time);
17
+ }
18
+
19
+ div.scale:hover {
20
+ transform: scale(1.5);
21
+ }
22
+
23
+ div > :global(svg) {
24
+ width: 100%;
25
+ height: 100%;
26
+ stroke-width: 3;
27
+ stroke: currentColor;
28
+ fill: currentColor;
29
+ }
30
+ </style>