@htmlbricks/hb-gauge 0.71.36 → 0.71.37
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/README.md +26 -82
- package/manifest.json +14 -6
- package/package.json +1 -1
- package/types/webcomponent.type.d.json +13 -5
- package/types/webcomponent.type.d.ts +5 -1
package/README.md
CHANGED
|
@@ -1,109 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
# hb-gauge
|
|
2
2
|
|
|
3
|
-
**Category:** data
|
|
4
|
-
**Tags:** data, chart
|
|
3
|
+
**Category:** data · **Tags:** data, chart
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Summary
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
**JustGage** SVG gauge inside the shadow root: pass **`options`** as JSON (or object from JS). Created on mount, destroyed on teardown, recreated on window **resize** (200 ms debounce) and when **`options`** is reparsed from a string.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
There are **no custom events** on this element (`Events` is empty in the public typings).
|
|
13
|
-
|
|
14
|
-
### Custom element
|
|
9
|
+
## Custom element
|
|
15
10
|
|
|
16
11
|
`hb-gauge`
|
|
17
12
|
|
|
18
|
-
|
|
13
|
+
## Attributes
|
|
19
14
|
|
|
20
|
-
| Attribute |
|
|
15
|
+
| Attribute | Type (logical) | HTML / notes |
|
|
21
16
|
| --- | --- | --- |
|
|
22
|
-
| `options` |
|
|
23
|
-
| `id` |
|
|
24
|
-
|
|
25
|
-
From HTML, **`options` is always a string**: pass a serialized JSON object (see examples below). The implementation may parse that string when it runs as a web component.
|
|
26
|
-
|
|
27
|
-
The authoring TypeScript type `Component` also lists optional `style`; the current Svelte implementation does not wire a dedicated `style` prop—you can still apply ordinary host styling (for example `width`, `height`, or `min-height`) on `<hb-gauge>` itself, and use **`--hb-gauge-min-height`** for layout reserve before paint.
|
|
28
|
-
|
|
29
|
-
### TypeScript shape (`Component`)
|
|
30
|
-
|
|
31
|
-
For editors and wrappers that import `Component` from `types/webcomponent.type.d.ts`:
|
|
32
|
-
|
|
33
|
-
- **`options`** — in typings this is modeled as `IGauge` (`value`, `min`, `max`). At runtime the same object is spread into JustGage, so real configs are often richer than `IGauge`; treat the type as a **minimum** contract and refer to JustGage for the full option surface.
|
|
34
|
-
- **`id`** — optional string.
|
|
35
|
-
- **`style`** — optional string in the type file only; see note above for styling the host.
|
|
36
|
-
|
|
37
|
-
### Events
|
|
17
|
+
| `options` | `string` \| `GaugeOptions` | **Required** for a useful chart. Merged with `{ element: #gauge }` before JustGage. Minimum: **`value`**, **`min`**, **`max`**; extra keys follow JustGage. |
|
|
18
|
+
| `id` | `string` (optional) | |
|
|
19
|
+
| `style` | `string` (optional) | Typings only; host `style` still applies to `<hb-gauge>`. |
|
|
38
20
|
|
|
39
|
-
|
|
21
|
+
## Custom events
|
|
40
22
|
|
|
41
|
-
|
|
23
|
+
**None** — `Events` is `{}`.
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
## Styling
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
### CSS custom properties (`extra/docs.ts`)
|
|
46
28
|
|
|
47
|
-
| Variable |
|
|
29
|
+
| Variable | Role |
|
|
48
30
|
| --- | --- |
|
|
49
|
-
| `--hb-gauge-min-height` |
|
|
31
|
+
| `--hb-gauge-min-height` | Reserved vertical space on `:host` before paint. |
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
### CSS parts (`extra/docs.ts`)
|
|
52
34
|
|
|
53
|
-
| Part |
|
|
35
|
+
| Part | Role |
|
|
54
36
|
| --- | --- |
|
|
55
|
-
| `gauge` |
|
|
56
|
-
|
|
57
|
-
#### Slots
|
|
58
|
-
|
|
59
|
-
None.
|
|
60
|
-
|
|
61
|
-
### Examples
|
|
62
|
-
|
|
63
|
-
**Minimal 0–100 gauge**
|
|
64
|
-
|
|
65
|
-
```html
|
|
66
|
-
<hb-gauge options='{"value":50,"min":0,"max":100}'></hb-gauge>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**Quarter of the scale**
|
|
37
|
+
| `gauge` | Mount node `#gauge` (`width: 100%`). |
|
|
70
38
|
|
|
71
|
-
|
|
72
|
-
<hb-gauge options='{"value":25,"min":0,"max":100}'></hb-gauge>
|
|
73
|
-
```
|
|
39
|
+
### Slots
|
|
74
40
|
|
|
75
|
-
**
|
|
41
|
+
**None.**
|
|
76
42
|
|
|
77
|
-
|
|
78
|
-
<hb-gauge options='{"value":250,"min":0,"max":500}'></hb-gauge>
|
|
79
|
-
```
|
|
43
|
+
Bulma is bundled for consistency; the visible dial is SVG from JustGage.
|
|
80
44
|
|
|
81
|
-
|
|
45
|
+
## TypeScript
|
|
82
46
|
|
|
83
|
-
|
|
84
|
-
<hb-gauge options='{"value":100,"min":0,"max":100}'></hb-gauge>
|
|
85
|
-
```
|
|
47
|
+
`types/webcomponent.type.d.ts` — `Component`, `IGauge`, `GaugeOptions`, `Events`.
|
|
86
48
|
|
|
87
|
-
|
|
49
|
+
## Minimal HTML example
|
|
88
50
|
|
|
89
51
|
```html
|
|
90
|
-
<hb-gauge
|
|
91
|
-
style="width: 280px; height: 200px;"
|
|
92
|
-
options='{"value":72,"min":0,"max":100}'
|
|
93
|
-
></hb-gauge>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
```html
|
|
97
|
-
<hb-gauge
|
|
98
|
-
style="width: 100%;"
|
|
99
|
-
options='{"value":10,"min":0,"max":100}'
|
|
100
|
-
></hb-gauge>
|
|
52
|
+
<hb-gauge options='{"value":50,"min":0,"max":100}'></hb-gauge>
|
|
101
53
|
```
|
|
102
|
-
|
|
103
|
-
(Combine `style` on the custom element with `--hb-gauge-min-height` in your page CSS if you need a stable block size before the gauge renders.)
|
|
104
|
-
|
|
105
|
-
### Implementation notes
|
|
106
|
-
|
|
107
|
-
- The mount target is `<div part="gauge" id="gauge" style="width:100%">` inside the shadow tree; JustGage receives `Object.assign({ element: gaugeEl }, options)`.
|
|
108
|
-
- If `options` arrives as a string, it is `JSON.parse`’d in an effect; when both the mount node and an existing instance exist, the gauge is **recreated** to pick up the new config.
|
|
109
|
-
- Console logging is present in the source around mount for debugging (`gaugeEl`); remove or silence in production builds if that matters for your environment.
|
package/manifest.json
CHANGED
|
@@ -21,7 +21,15 @@
|
|
|
21
21
|
"type": "string"
|
|
22
22
|
},
|
|
23
23
|
"options": {
|
|
24
|
-
"
|
|
24
|
+
"anyOf": [
|
|
25
|
+
{
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"$ref": "#/definitions/GaugeOptions"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"description": "JSON string from HTML, or an object when set from JavaScript."
|
|
25
33
|
},
|
|
26
34
|
"style": {
|
|
27
35
|
"type": "string"
|
|
@@ -32,8 +40,8 @@
|
|
|
32
40
|
],
|
|
33
41
|
"type": "object"
|
|
34
42
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
43
|
+
"GaugeOptions": {
|
|
44
|
+
"description": "JustGage constructor options merged with `{ element }` in the component.",
|
|
37
45
|
"properties": {
|
|
38
46
|
"max": {
|
|
39
47
|
"type": "number"
|
|
@@ -46,9 +54,9 @@
|
|
|
46
54
|
}
|
|
47
55
|
},
|
|
48
56
|
"required": [
|
|
49
|
-
"
|
|
57
|
+
"max",
|
|
50
58
|
"min",
|
|
51
|
-
"
|
|
59
|
+
"value"
|
|
52
60
|
],
|
|
53
61
|
"type": "object"
|
|
54
62
|
}
|
|
@@ -148,5 +156,5 @@
|
|
|
148
156
|
"size": {},
|
|
149
157
|
"iifePath": "main.iife.js",
|
|
150
158
|
"repoName": "@htmlbricks/hb-gauge",
|
|
151
|
-
"version": "0.71.
|
|
159
|
+
"version": "0.71.37"
|
|
152
160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-gauge",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.37",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "SVG gauge wrapper around JustGage: pass JustGage-compatible options as JSON (`value`, min/max, labels, colors, etc.). The gauge is created on the shadow host after mount, destroyed on teardown, and recreated when `options` changes or the window resizes (debounced) so it stays sized correctly.",
|
|
6
6
|
"licenses": [
|
|
@@ -9,7 +9,15 @@
|
|
|
9
9
|
"type": "string"
|
|
10
10
|
},
|
|
11
11
|
"options": {
|
|
12
|
-
"
|
|
12
|
+
"anyOf": [
|
|
13
|
+
{
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"$ref": "#/definitions/GaugeOptions"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"description": "JSON string from HTML, or an object when set from JavaScript."
|
|
13
21
|
},
|
|
14
22
|
"style": {
|
|
15
23
|
"type": "string"
|
|
@@ -20,8 +28,8 @@
|
|
|
20
28
|
],
|
|
21
29
|
"type": "object"
|
|
22
30
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
31
|
+
"GaugeOptions": {
|
|
32
|
+
"description": "JustGage constructor options merged with `{ element }` in the component.",
|
|
25
33
|
"properties": {
|
|
26
34
|
"max": {
|
|
27
35
|
"type": "number"
|
|
@@ -34,9 +42,9 @@
|
|
|
34
42
|
}
|
|
35
43
|
},
|
|
36
44
|
"required": [
|
|
37
|
-
"
|
|
45
|
+
"max",
|
|
38
46
|
"min",
|
|
39
|
-
"
|
|
47
|
+
"value"
|
|
40
48
|
],
|
|
41
49
|
"type": "object"
|
|
42
50
|
}
|
|
@@ -4,10 +4,14 @@ export type IGauge = {
|
|
|
4
4
|
max: number;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
/** JustGage constructor options merged with `{ element }` in the component. */
|
|
8
|
+
export type GaugeOptions = IGauge & Record<string, unknown>;
|
|
9
|
+
|
|
7
10
|
export type Component = {
|
|
8
11
|
id?: string;
|
|
9
12
|
style?: string;
|
|
10
|
-
|
|
13
|
+
/** JSON string from HTML, or an object when set from JavaScript. */
|
|
14
|
+
options: string | GaugeOptions;
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
export type Events = {};
|