@nil-/doc 0.2.48 → 0.2.49

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.49
4
+
5
+ ### Patch Changes
6
+
7
+ - [doc][fix] fix range number formatting ([#83](https://github.com/njaldea/mono/pull/83))
8
+
3
9
  ## 0.2.48
4
10
 
5
11
  ### Patch Changes
@@ -121,7 +121,7 @@ const toggle = () => {
121
121
  </div>
122
122
  <div
123
123
  class="icon"
124
- title="Double click to open repo: https://github.com/njaldea/mono"
124
+ title="Open @nil-/mono repo: https://github.com/njaldea/mono"
125
125
  on:click={() => window.open("https://github.com/njaldea/mono", "_blank")}
126
126
  on:keypress={null}
127
127
  >
@@ -2,7 +2,7 @@
2
2
  .input {
3
3
  width: 100%;
4
4
  display: grid;
5
- grid-template-columns: 50px 1fr;
5
+ grid-template-columns: 65px 1fr;
6
6
  gap: 5px;
7
7
  position: relative;
8
8
  }
@@ -19,14 +19,13 @@
19
19
  }
20
20
 
21
21
  .tooltip {
22
+ left: -110%;
22
23
  width: 100%;
23
24
  height: 100%;
24
- left: -110%;
25
- position: absolute;
26
- visibility: hidden;
27
25
  display: grid;
28
- grid-template-columns: 85px 1fr;
29
- padding: 0px 5px;
26
+ visibility: hidden;
27
+ position: absolute;
28
+ place-items: center;
30
29
  }
31
30
 
32
31
  .input:hover > .tooltip:not(.disabled) {
@@ -36,6 +35,7 @@
36
35
 
37
36
  <script>import { getDefault } from "./misc/defaulter";
38
37
  import NameHeader from "./misc/Name.svelte";
38
+ import { nformat } from "./misc/nformat";
39
39
  export let value;
40
40
  export let info;
41
41
  export let depth;
@@ -57,29 +57,15 @@ $:
57
57
  max: info.max,
58
58
  step: info.step
59
59
  };
60
- const format = (v, base, digits) => {
61
- const n = v.toExponential().split("e");
62
- const ex = parseInt(n[1]);
63
- const absex = Math.abs(ex);
64
- const rest = base + (absex >= 10 ? 0 : 1) - (ex >= 0 ? 0 : 1);
65
- return v.toLocaleString(void 0, {
66
- signDisplay: "always",
67
- useGrouping: false,
68
- notation: absex > 2 + digits ? "scientific" : "standard",
69
- maximumFractionDigits: rest,
70
- minimumFractionDigits: rest
71
- });
72
- };
73
60
  </script>
74
61
  {#if visible}
75
62
  <div>
76
63
  <NameHeader name={i.name} {depth} />
77
64
  <div class="input">
78
65
  <div class="tooltip" class:disabled={!enabled || disabled}>
79
- <div>Current Value:</div>
80
- <div>{format(ivalue, 6, 3)}</div>
66
+ Value: {nformat(ivalue, 6, 11)}
81
67
  </div>
82
- <div>{format(ivalue, 1, 1)}</div>
68
+ <div>{nformat(ivalue, 3, 5)}</div>
83
69
  <input
84
70
  type="range"
85
71
  bind:value={ivalue}
@@ -1,3 +1,8 @@
1
+ <style>
2
+ select {
3
+ text-align: center;
4
+ }
5
+ </style>
1
6
 
2
7
  <script>import { getDefault } from "./misc/defaulter";
3
8
  import NameHeader from "./misc/Name.svelte";
@@ -28,3 +33,4 @@ $:
28
33
  <div><input type="checkbox" bind:checked={enabled} {disabled} /></div>
29
34
  </div>
30
35
  {/if}
36
+
@@ -15,6 +15,7 @@ const dark = getTheme();
15
15
  div :global(*::before),
16
16
  div :global(*::after) {
17
17
  box-sizing: inherit;
18
+ font-family: inherit;
18
19
  }
19
20
 
20
21
  div > :global(div) {
@@ -26,6 +27,7 @@ const dark = getTheme();
26
27
 
27
28
  div > :global(div:first-child) {
28
29
  text-align: center;
30
+ font-weight: bold;
29
31
  }
30
32
 
31
33
  div > :global(div > div:not(:first-child) > *) {
@@ -0,0 +1 @@
1
+ export declare const nformat: (v: number, fdigits: number, width: number) => string;
@@ -0,0 +1,16 @@
1
+ export const nformat = (v, fdigits, width) => {
2
+ const n = v.toExponential().split("e");
3
+ const ex = parseInt(n[1]);
4
+ const absex = Math.abs(ex);
5
+ const short = absex >= fdigits;
6
+ const rest = short
7
+ ? width - 3 + (absex >= 10 ? 0 : 1) - (ex < 0 ? 1 : 0)
8
+ : width - absex + (ex < 0 ? -ex : 0);
9
+ return v.toLocaleString(undefined, {
10
+ signDisplay: "always",
11
+ useGrouping: false,
12
+ notation: short ? "scientific" : "standard",
13
+ maximumFractionDigits: rest,
14
+ minimumFractionDigits: rest
15
+ });
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nil-/doc",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "author": {
5
5
  "email": "njaldea@gmail.com",
6
6
  "name": "Neil Aldea"