@htmlbricks/hb-gauge 0.71.34 → 0.71.36

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 (3) hide show
  1. package/README.md +86 -11
  2. package/manifest.json +10 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,32 +3,107 @@
3
3
  **Category:** data
4
4
  **Tags:** data, chart
5
5
 
6
- ### What it does
6
+ ### Overview
7
7
 
8
- 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.
8
+ `hb-gauge` is a web component that embeds **JustGage** (SVG gauges via Raphael; vendored as `libs/justgage.js` in this package) inside the shadow root. You pass a single JSON payload that mirrors JustGage’s configuration object. After mount, the library instantiates the gauge on an internal mount node; on destroy it tears the instance down cleanly.
9
+
10
+ The gauge is **recreated** when the window is resized (handled with a **200 ms debounce**) so the SVG keeps a sensible size relative to the host. When `options` is supplied as a **string**, the component parses it with `JSON.parse`; if a gauge instance already exists, that parse path triggers a **rebuild** so the new JSON takes effect. (If you bind `options` as an object in a Svelte host, rely on resize or remount for full redraw unless your integration matches the string-based update path.)
11
+
12
+ There are **no custom events** on this element (`Events` is empty in the public typings).
9
13
 
10
14
  ### Custom element
11
15
 
12
16
  `hb-gauge`
13
17
 
14
- ### Attributes (snake_case; use string values in HTML)
18
+ ### Attributes (snake_case; string values from HTML)
19
+
20
+ | Attribute | Required | Description |
21
+ | --- | --- | --- |
22
+ | `options` | yes | JSON string describing the gauge. Merged with `{ element }` pointing at the internal `#gauge` node before constructing JustGage. You must include at least **`value`**, **`min`**, and **`max`** for a sensible dial; any additional keys supported by your bundled JustGage build (labels, colors, `gaugeWidthScale`, donut mode, etc.) can be added in the same object. |
23
+ | `id` | no | Optional string identifier (forwarded through the component props). |
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.
15
28
 
16
- - `id` — optional string
17
- - `style` — optional string
18
- - `options` required string (JSON object; at minimum `value`, `min`, `max`; additional keys follow JustGage)
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.
19
36
 
20
37
  ### Events
21
38
 
22
- None declared on the component type.
39
+ None declared for this component.
40
+
41
+ ### Styling
42
+
43
+ Bulma styles are included in the shadow bundle for consistency with other HTML Bricks components, but the visible gauge is drawn by JustGage (SVG), not Bulma layout primitives. Theme your app with **`--bulma-*`** tokens on the document if you want host-level consistency with the rest of the library.
44
+
45
+ #### CSS custom properties
46
+
47
+ | Variable | Description |
48
+ | --- | --- |
49
+ | `--hb-gauge-min-height` | Minimum height of the `:host` element (default `0` in `styles/webcomponent.scss`). Use it when you need reserved vertical space before the gauge finishes laying out. |
50
+
51
+ #### CSS parts
52
+
53
+ | Part | Description |
54
+ | --- | --- |
55
+ | `gauge` | The JustGage mount node (`#gauge`). It is `width: 100%` by default; you can target this part to adjust width, height, or overflow behavior around the SVG. |
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**
70
+
71
+ ```html
72
+ <hb-gauge options='{"value":25,"min":0,"max":100}'></hb-gauge>
73
+ ```
23
74
 
24
- ### Usage notes
75
+ **Wider numeric range**
25
76
 
26
- CSS part: `gauge`. `options` may be passed as a JSON string; the component parses it when needed.
77
+ ```html
78
+ <hb-gauge options='{"value":250,"min":0,"max":500}'></hb-gauge>
79
+ ```
27
80
 
28
- ### Minimal HTML example
81
+ **Value at the upper bound**
82
+
83
+ ```html
84
+ <hb-gauge options='{"value":100,"min":0,"max":100}'></hb-gauge>
85
+ ```
86
+
87
+ **Host sizing and minimum height**
29
88
 
30
89
  ```html
31
90
  <hb-gauge
32
- options="{&quot;value&quot;:50,&quot;min&quot;:0,&quot;max&quot;:100}"
91
+ style="width: 280px; height: 200px;"
92
+ options='{"value":72,"min":0,"max":100}'
33
93
  ></hb-gauge>
34
94
  ```
95
+
96
+ ```html
97
+ <hb-gauge
98
+ style="width: 100%;"
99
+ options='{"value":10,"min":0,"max":100}'
100
+ ></hb-gauge>
101
+ ```
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
@@ -64,11 +64,18 @@
64
64
  }
65
65
  },
66
66
  "styleSetup": {
67
- "vars": [],
67
+ "vars": [
68
+ {
69
+ "name": "--hb-gauge-min-height",
70
+ "valueType": "number",
71
+ "defaultValue": "0",
72
+ "description": "Minimum height of the host element before JustGage draws."
73
+ }
74
+ ],
68
75
  "parts": [
69
76
  {
70
77
  "name": "gauge",
71
- "description": ""
78
+ "description": "JustGage mount node (`#gauge`); style width/height or overflow for the SVG gauge."
72
79
  }
73
80
  ]
74
81
  },
@@ -141,5 +148,5 @@
141
148
  "size": {},
142
149
  "iifePath": "main.iife.js",
143
150
  "repoName": "@htmlbricks/hb-gauge",
144
- "version": "0.71.34"
151
+ "version": "0.71.36"
145
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-gauge",
3
- "version": "0.71.34",
3
+ "version": "0.71.36",
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": [