gaugeit.js 0.1.0
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/CONTRIBUTING.md +36 -0
- package/LICENSE +21 -0
- package/NOTICE.md +5 -0
- package/README.md +894 -0
- package/SECURITY.md +24 -0
- package/adapters/react/Gaugeit.d.ts +11 -0
- package/adapters/react/Gaugeit.js +66 -0
- package/adapters/react/Gaugeit.jsx +1 -0
- package/dist/gaugeit.cjs +4686 -0
- package/dist/gaugeit.cjs.map +7 -0
- package/dist/gaugeit.css +300 -0
- package/dist/gaugeit.d.ts +442 -0
- package/dist/gaugeit.esm.js +4683 -0
- package/dist/gaugeit.esm.js.map +7 -0
- package/dist/gaugeit.esm.min.js +2 -0
- package/dist/gaugeit.esm.min.js.map +7 -0
- package/dist/gaugeit.min.cjs +2 -0
- package/dist/gaugeit.min.cjs.map +7 -0
- package/dist/gaugeit.min.css +1 -0
- package/dist/gaugeit.standalone.js +4720 -0
- package/dist/gaugeit.standalone.js.map +7 -0
- package/dist/gaugeit.standalone.min.js +302 -0
- package/dist/gaugeit.standalone.min.js.map +7 -0
- package/dist/gaugeit.umd.js +4713 -0
- package/dist/gaugeit.umd.js.map +7 -0
- package/dist/gaugeit.umd.min.js +4 -0
- package/dist/gaugeit.umd.min.js.map +7 -0
- package/dist/manifest.json +24 -0
- package/docs/api.md +456 -0
- package/docs/architecture.md +224 -0
- package/docs/assets/arc_zones.png +0 -0
- package/docs/assets/center_zero.png +0 -0
- package/docs/assets/classic_instrument.png +0 -0
- package/docs/assets/classic_linear_center_zero.png +0 -0
- package/docs/assets/classic_linear_instrument.png +0 -0
- package/docs/assets/heritage_rolling_tape.png +0 -0
- package/docs/assets/heritage_round.png +0 -0
- package/docs/assets/line_scale.png +0 -0
- package/docs/assets/rose_balance.png +0 -0
- package/docs/creating-gauge-types.md +286 -0
- package/docs/development.md +56 -0
- package/docs/framework-integration.md +84 -0
- package/package.json +114 -0
package/SECURITY.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Security updates are provided for the latest published Gaugeit.js release.
|
|
6
|
+
|
|
7
|
+
| Version | Supported |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| 0.1.x | Yes |
|
|
10
|
+
|
|
11
|
+
## Reporting a vulnerability
|
|
12
|
+
|
|
13
|
+
Do not disclose a suspected vulnerability in a public issue. Use GitHub's private
|
|
14
|
+
**Report a vulnerability** form in the repository Security section. Include:
|
|
15
|
+
|
|
16
|
+
- the affected version and distribution format;
|
|
17
|
+
- a minimal reproduction or proof of concept;
|
|
18
|
+
- the expected and observed behavior;
|
|
19
|
+
- the practical security impact;
|
|
20
|
+
- any suggested mitigation.
|
|
21
|
+
|
|
22
|
+
The maintainer will acknowledge a complete report, investigate it, and coordinate a
|
|
23
|
+
fix and disclosure when the issue is confirmed. Reports that concern an upstream
|
|
24
|
+
browser, framework, or package should also be sent to the responsible upstream project.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
import type { Gauge, GaugeOptions } from 'gaugeit.js';
|
|
3
|
+
|
|
4
|
+
export interface GaugeitProps {
|
|
5
|
+
value?: number;
|
|
6
|
+
options?: GaugeOptions;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Gaugeit: ForwardRefExoticComponent<GaugeitProps & RefAttributes<Gauge>>;
|
|
11
|
+
export default Gaugeit;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
|
+
import { createGauge } from '../../dist/gaugeit.esm.js';
|
|
3
|
+
|
|
4
|
+
const EMPTY_OPTIONS = Object.freeze({});
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Thin React adapter. The Gaugeit core remains framework-independent.
|
|
8
|
+
* Import Gaugeit CSS once in the application entry point.
|
|
9
|
+
*/
|
|
10
|
+
export const Gaugeit = forwardRef(function Gaugeit({ value, options = EMPTY_OPTIONS, className = '' }, forwardedRef) {
|
|
11
|
+
const hostRef = useRef(null);
|
|
12
|
+
const gaugeRef = useRef(null);
|
|
13
|
+
const skipOptionsGaugeRef = useRef(null);
|
|
14
|
+
const skipValueGaugeRef = useRef(null);
|
|
15
|
+
const [instance, setInstance] = useState(null);
|
|
16
|
+
|
|
17
|
+
useImperativeHandle(forwardedRef, () => instance, [instance]);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const gauge = createGauge(hostRef.current, withControlledValue(options, value));
|
|
21
|
+
gaugeRef.current = gauge;
|
|
22
|
+
skipOptionsGaugeRef.current = gauge;
|
|
23
|
+
skipValueGaugeRef.current = gauge;
|
|
24
|
+
setInstance(gauge);
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
gauge.destroy();
|
|
28
|
+
if (gaugeRef.current === gauge) gaugeRef.current = null;
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const gauge = gaugeRef.current;
|
|
34
|
+
if (!gauge) return;
|
|
35
|
+
if (skipOptionsGaugeRef.current === gauge) {
|
|
36
|
+
skipOptionsGaugeRef.current = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
gauge.replaceOptions(withoutControlledValue(options, value));
|
|
40
|
+
}, [options]);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const gauge = gaugeRef.current;
|
|
44
|
+
if (!gauge) return;
|
|
45
|
+
if (skipValueGaugeRef.current === gauge) {
|
|
46
|
+
skipValueGaugeRef.current = null;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (value === undefined) return;
|
|
50
|
+
gauge.setValue(value);
|
|
51
|
+
}, [value]);
|
|
52
|
+
|
|
53
|
+
return React.createElement('div', { ref: hostRef, className });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function withControlledValue(options, value) {
|
|
57
|
+
return value === undefined ? options : { ...options, value };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function withoutControlledValue(options, value) {
|
|
61
|
+
if (value === undefined || !options || !Object.prototype.hasOwnProperty.call(options, 'value')) return options;
|
|
62
|
+
const { value: _ignoredValue, ...rest } = options;
|
|
63
|
+
return rest;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default Gaugeit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Gaugeit, default } from './Gaugeit.js';
|