@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.151 → 2.0.0-next.152
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/.storybook/vitest.setup.ts +12 -1
- package/bundle/openbridge-webcomponents.bundle.js +989 -319
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1514 -77
- package/dist/alert-severity.d.ts +12 -9
- package/dist/alert-severity.d.ts.map +1 -1
- package/dist/alert-severity.js +30 -38
- package/dist/alert-severity.js.map +1 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts +6 -0
- package/dist/building-blocks/bar-horizontal/bar-horizontal.d.ts.map +1 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js +6 -1
- package/dist/building-blocks/bar-horizontal/bar-horizontal.js.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts +6 -0
- package/dist/building-blocks/bar-vertical/bar-vertical.d.ts.map +1 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.js +6 -1
- package/dist/building-blocks/bar-vertical/bar-vertical.js.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.d.ts +129 -0
- package/dist/building-blocks/chart-line/chart-line-base.d.ts.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.js +464 -79
- package/dist/building-blocks/chart-line/chart-line-base.js.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.d.ts +11 -0
- package/dist/building-blocks/external-scale/external-scale.d.ts.map +1 -1
- package/dist/building-blocks/external-scale/external-scale.js +45 -12
- package/dist/building-blocks/external-scale/external-scale.js.map +1 -1
- package/dist/charthelpers/index.d.ts +1 -0
- package/dist/charthelpers/index.d.ts.map +1 -1
- package/dist/charthelpers/index.js +7 -1
- package/dist/charthelpers/index.js.map +1 -1
- package/dist/charthelpers/range-labels.d.ts +55 -0
- package/dist/charthelpers/range-labels.d.ts.map +1 -0
- package/dist/charthelpers/range-labels.js +36 -0
- package/dist/charthelpers/range-labels.js.map +1 -0
- package/dist/components/alert-button/alert-button.css.js +13 -21
- package/dist/components/alert-button/alert-button.css.js.map +1 -1
- package/dist/components/alert-button/alert-button.d.ts +9 -4
- package/dist/components/alert-button/alert-button.d.ts.map +1 -1
- package/dist/components/alert-button/alert-button.js +24 -15
- package/dist/components/alert-button/alert-button.js.map +1 -1
- package/dist/components/alert-frame/alert-frame.css.js +109 -33
- package/dist/components/alert-frame/alert-frame.css.js.map +1 -1
- package/dist/components/alert-frame/alert-frame.d.ts +34 -7
- package/dist/components/alert-frame/alert-frame.d.ts.map +1 -1
- package/dist/components/alert-frame/alert-frame.js +134 -30
- package/dist/components/alert-frame/alert-frame.js.map +1 -1
- package/dist/components/alert-icon/alert-icon.d.ts +10 -7
- package/dist/components/alert-icon/alert-icon.d.ts.map +1 -1
- package/dist/components/alert-icon/alert-icon.js +37 -60
- package/dist/components/alert-icon/alert-icon.js.map +1 -1
- package/dist/components/alert-menu-item/alert-menu-item.css.js +1 -4
- package/dist/components/alert-menu-item/alert-menu-item.css.js.map +1 -1
- package/dist/components/date-item/date-item.css.js +3 -3
- package/dist/components/keyboard-full/keyboard-full.css.js +4 -4
- package/dist/components/message-menu-item/message-menu-item.css.js +2 -6
- package/dist/components/message-menu-item/message-menu-item.css.js.map +1 -1
- package/dist/components/sequence-toolbar/sequence-toolbar.css.js +1 -2
- package/dist/components/sequence-toolbar/sequence-toolbar.css.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts +6 -0
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.js +8 -0
- package/dist/navigation-instruments/gauge-trend/gauge-trend.js.map +1 -1
- package/dist/navigation-instruments/instrument-field/instrument-field.css.js +2 -2
- package/dist/navigation-instruments/readout/readout.d.ts.map +1 -1
- package/dist/navigation-instruments/readout/readout.js +2 -1
- package/dist/navigation-instruments/readout/readout.js.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.d.ts.map +1 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js +2 -1
- package/dist/navigation-instruments/readout-list-item/readout-list-item.js.map +1 -1
- package/dist/openbridge.css +19 -4
- package/dist/palettes/blinking.d.ts +14 -4
- package/dist/palettes/blinking.d.ts.map +1 -1
- package/dist/palettes/blinking.js +41 -35
- package/dist/palettes/blinking.js.map +1 -1
- package/dist/palettes/flashing-controller.d.ts +21 -0
- package/dist/palettes/flashing-controller.d.ts.map +1 -0
- package/dist/palettes/flashing-controller.js +45 -0
- package/dist/palettes/flashing-controller.js.map +1 -0
- package/dist/svghelpers/index.d.ts +1 -0
- package/dist/svghelpers/index.d.ts.map +1 -1
- package/dist/svghelpers/index.js +2 -0
- package/dist/svghelpers/index.js.map +1 -1
- package/dist/svghelpers/rounded-rect.d.ts +15 -0
- package/dist/svghelpers/rounded-rect.d.ts.map +1 -0
- package/dist/svghelpers/rounded-rect.js +29 -0
- package/dist/svghelpers/rounded-rect.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/script/check-css-variables.ts +2 -15
- package/src/alert-severity.spec.ts +56 -0
- package/src/alert-severity.ts +45 -43
- package/src/bars-graphs/area-graph/area-graph.stories.ts +235 -1
- package/src/bars-graphs/line-graph/line-graph.stories.ts +24 -0
- package/src/building-blocks/bar-horizontal/bar-horizontal.ts +7 -0
- package/src/building-blocks/bar-vertical/bar-vertical.ts +7 -0
- package/src/building-blocks/chart-line/chart-line-base.spec.ts +767 -0
- package/src/building-blocks/chart-line/chart-line-base.stories.ts +124 -0
- package/src/building-blocks/chart-line/chart-line-base.ts +671 -97
- package/src/building-blocks/chart-line/chart-sizing-battleground.stories.ts +17 -0
- package/src/building-blocks/external-scale/external-scale.spec.ts +154 -0
- package/src/building-blocks/external-scale/external-scale.ts +78 -20
- package/src/charthelpers/index.ts +1 -0
- package/src/charthelpers/range-labels.spec.ts +46 -0
- package/src/charthelpers/range-labels.ts +93 -0
- package/src/components/alert-button/alert-button.css +10 -23
- package/src/components/alert-button/alert-button.spec.ts +56 -15
- package/src/components/alert-button/alert-button.stories.ts +5 -1
- package/src/components/alert-button/alert-button.ts +33 -24
- package/src/components/alert-frame/alert-flash-scenario.stories.ts +669 -0
- package/src/components/alert-frame/alert-frame.css +106 -33
- package/src/components/alert-frame/alert-frame.spec.ts +176 -17
- package/src/components/alert-frame/alert-frame.stories.ts +61 -0
- package/src/components/alert-frame/alert-frame.ts +179 -41
- package/src/components/alert-icon/alert-icon.spec.ts +82 -27
- package/src/components/alert-icon/alert-icon.stories.ts +7 -1
- package/src/components/alert-icon/alert-icon.ts +48 -74
- package/src/components/alert-menu-item/alert-menu-item.css +1 -4
- package/src/components/date-item/date-item.css +3 -3
- package/src/components/keyboard-full/keyboard-full.css +4 -4
- package/src/components/message-menu-item/message-menu-item.css +2 -6
- package/src/components/sequence-toolbar/sequence-toolbar.css +1 -2
- package/src/navigation-instruments/gauge-trend/gauge-trend.stories.ts +29 -0
- package/src/navigation-instruments/gauge-trend/gauge-trend.ts +11 -0
- package/src/navigation-instruments/instrument-field/instrument-field.css +2 -2
- package/src/navigation-instruments/readout/readout.ts +2 -1
- package/src/navigation-instruments/readout-list-item/readout-list-item.ts +2 -1
- package/src/palettes/blinking.spec.ts +83 -0
- package/src/palettes/blinking.ts +47 -35
- package/src/palettes/flashing-controller.ts +62 -0
- package/src/palettes/manual.css +18 -4
- package/src/svghelpers/index.ts +1 -0
- package/src/svghelpers/rounded-rect.spec.ts +47 -0
- package/src/svghelpers/rounded-rect.ts +42 -0
- package/src/types.ts +20 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface RoundedRect {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** Corner radii in CSS order: top-left, top-right, bottom-right, bottom-left. */
|
|
7
|
+
radii: [number, number, number, number];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* SVG path of a rectangle with per-corner radii, so a stroke can follow a
|
|
11
|
+
* box whose corners are individually sharp (the alert frame's
|
|
12
|
+
* `sharpEdge*` flags). Radii are clamped to half the shorter side.
|
|
13
|
+
*/
|
|
14
|
+
export declare function roundedRectPath({ x, y, width, height, radii, }: RoundedRect): string;
|
|
15
|
+
//# sourceMappingURL=rounded-rect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rounded-rect.d.ts","sourceRoot":"","sources":["../../src/svghelpers/rounded-rect.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,CAAC,EACD,CAAC,EACD,KAAK,EACL,MAAM,EACN,KAAK,GACN,EAAE,WAAW,GAAG,MAAM,CAqBtB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function roundedRectPath({
|
|
2
|
+
x,
|
|
3
|
+
y,
|
|
4
|
+
width,
|
|
5
|
+
height,
|
|
6
|
+
radii
|
|
7
|
+
}) {
|
|
8
|
+
const max = Math.min(width, height) / 2;
|
|
9
|
+
const [tl, tr, br, bl] = radii.map((r) => Math.max(0, Math.min(r, max)));
|
|
10
|
+
const right = x + width;
|
|
11
|
+
const bottom = y + height;
|
|
12
|
+
const arc = (r, endX, endY) => r > 0 ? `A${r} ${r} 0 0 1 ${endX} ${endY}` : "";
|
|
13
|
+
return [
|
|
14
|
+
`M${x + tl} ${y}`,
|
|
15
|
+
`H${right - tr}`,
|
|
16
|
+
arc(tr, right, y + tr),
|
|
17
|
+
`V${bottom - br}`,
|
|
18
|
+
arc(br, right - br, bottom),
|
|
19
|
+
`H${x + bl}`,
|
|
20
|
+
arc(bl, x, bottom - bl),
|
|
21
|
+
`V${y + tl}`,
|
|
22
|
+
arc(tl, x + tl, y),
|
|
23
|
+
"Z"
|
|
24
|
+
].filter(Boolean).join(" ");
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
roundedRectPath
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=rounded-rect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rounded-rect.js","sources":["../../src/svghelpers/rounded-rect.ts"],"sourcesContent":["export interface RoundedRect {\n x: number;\n y: number;\n width: number;\n height: number;\n /** Corner radii in CSS order: top-left, top-right, bottom-right, bottom-left. */\n radii: [number, number, number, number];\n}\n\n/**\n * SVG path of a rectangle with per-corner radii, so a stroke can follow a\n * box whose corners are individually sharp (the alert frame's\n * `sharpEdge*` flags). Radii are clamped to half the shorter side.\n */\nexport function roundedRectPath({\n x,\n y,\n width,\n height,\n radii,\n}: RoundedRect): string {\n const max = Math.min(width, height) / 2;\n const [tl, tr, br, bl] = radii.map((r) => Math.max(0, Math.min(r, max)));\n const right = x + width;\n const bottom = y + height;\n const arc = (r: number, endX: number, endY: number) =>\n r > 0 ? `A${r} ${r} 0 0 1 ${endX} ${endY}` : '';\n return [\n `M${x + tl} ${y}`,\n `H${right - tr}`,\n arc(tr, right, y + tr),\n `V${bottom - br}`,\n arc(br, right - br, bottom),\n `H${x + bl}`,\n arc(bl, x, bottom - bl),\n `V${y + tl}`,\n arc(tl, x + tl, y),\n 'Z',\n ]\n .filter(Boolean)\n .join(' ');\n}\n"],"names":[],"mappings":"AAcO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwB;AACtB,QAAM,MAAM,KAAK,IAAI,OAAO,MAAM,IAAI;AACtC,QAAM,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,MAAM,IAAI,CAAC,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,GAAG,CAAC,CAAC;AACvE,QAAM,QAAQ,IAAI;AAClB,QAAM,SAAS,IAAI;AACnB,QAAM,MAAM,CAAC,GAAW,MAAc,SACpC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,KAAK;AAC/C,SAAO;AAAA,IACL,IAAI,IAAI,EAAE,IAAI,CAAC;AAAA,IACf,IAAI,QAAQ,EAAE;AAAA,IACd,IAAI,IAAI,OAAO,IAAI,EAAE;AAAA,IACrB,IAAI,SAAS,EAAE;AAAA,IACf,IAAI,IAAI,QAAQ,IAAI,MAAM;AAAA,IAC1B,IAAI,IAAI,EAAE;AAAA,IACV,IAAI,IAAI,GAAG,SAAS,EAAE;AAAA,IACtB,IAAI,IAAI,EAAE;AAAA,IACV,IAAI,IAAI,IAAI,IAAI,CAAC;AAAA,IACjB;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AACb;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,20 @@ export declare enum AlertType {
|
|
|
14
14
|
LevelLow = "level-low",
|
|
15
15
|
LevelDiagnostic = "level-diagnostic"
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Flash tempo of an alert element. `default` resolves per alert type and
|
|
19
|
+
* phase (see `resolveFlashingSpeed` in `alert-severity.ts`); `fixed` never
|
|
20
|
+
* flashes.
|
|
21
|
+
*/
|
|
22
|
+
export declare enum FlashingSpeed {
|
|
23
|
+
Default = "default",
|
|
24
|
+
Fast = "fast",
|
|
25
|
+
Slow = "slow",
|
|
26
|
+
VerySlow = "very-slow",
|
|
27
|
+
Fixed = "fixed"
|
|
28
|
+
}
|
|
29
|
+
export type ResolvedFlashingSpeed = Exclude<FlashingSpeed, FlashingSpeed.Default>;
|
|
30
|
+
export type FlashTempo = Exclude<ResolvedFlashingSpeed, FlashingSpeed.Fixed>;
|
|
17
31
|
export declare const ALERT_SEVERITY_PRIORITY: AlertType[];
|
|
18
32
|
export declare enum AlertCategory {
|
|
19
33
|
a = "a",
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,aAAa,mBAAmB;IAChC,SAAS,eAAe;IACxB,WAAW,iBAAiB;IAC5B,QAAQ,cAAc;IACtB,eAAe,qBAAqB;CACrC;AAED,eAAO,MAAM,uBAAuB,aASnC,CAAC;AAEF,oBAAY,aAAa;IACvB,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;CACR;AAED,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,EACR,KAAK,GACL;QACE,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,IAAI,CAAC;KACtB,CAAC;IACN,MAAM,EACF,IAAI,GACJ;QACE,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,CAAC,E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AE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,WAEpC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,WAE1C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,WAErC;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,WAErC;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,UAgBvD;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;AAEjD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,UA0BzC"}
|
package/dist/types.js
CHANGED
|
@@ -16,6 +16,14 @@ var AlertType = /* @__PURE__ */ ((AlertType2) => {
|
|
|
16
16
|
AlertType2["LevelDiagnostic"] = "level-diagnostic";
|
|
17
17
|
return AlertType2;
|
|
18
18
|
})(AlertType || {});
|
|
19
|
+
var FlashingSpeed = /* @__PURE__ */ ((FlashingSpeed2) => {
|
|
20
|
+
FlashingSpeed2["Default"] = "default";
|
|
21
|
+
FlashingSpeed2["Fast"] = "fast";
|
|
22
|
+
FlashingSpeed2["Slow"] = "slow";
|
|
23
|
+
FlashingSpeed2["VerySlow"] = "very-slow";
|
|
24
|
+
FlashingSpeed2["Fixed"] = "fixed";
|
|
25
|
+
return FlashingSpeed2;
|
|
26
|
+
})(FlashingSpeed || {});
|
|
19
27
|
const ALERT_SEVERITY_PRIORITY = [
|
|
20
28
|
"level-critical",
|
|
21
29
|
"alarm",
|
|
@@ -83,6 +91,7 @@ export {
|
|
|
83
91
|
AlertCategory,
|
|
84
92
|
AlertType,
|
|
85
93
|
Direction,
|
|
94
|
+
FlashingSpeed,
|
|
86
95
|
comparePriorityAlerts,
|
|
87
96
|
formatTimeSince,
|
|
88
97
|
isAcknowledged,
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["export enum Direction {\n Up = 'up',\n Down = 'down',\n Left = 'left',\n Right = 'right',\n}\n\nexport enum AlertType {\n Alarm = 'alarm',\n Warning = 'warning',\n Caution = 'caution',\n LevelCritical = 'level-critical',\n LevelHigh = 'level-high',\n LevelMedium = 'level-medium',\n LevelLow = 'level-low',\n LevelDiagnostic = 'level-diagnostic',\n}\n\nexport const ALERT_SEVERITY_PRIORITY = [\n AlertType.LevelCritical,\n AlertType.Alarm,\n AlertType.LevelHigh,\n AlertType.Warning,\n AlertType.LevelMedium,\n AlertType.Caution,\n AlertType.LevelLow,\n AlertType.LevelDiagnostic,\n];\n\nexport enum AlertCategory {\n a = 'a',\n b = 'b',\n c = 'c',\n}\n\nexport interface Alert {\n id: string;\n tagId: string;\n source: string;\n text: string;\n note?: string;\n acknowledged:\n | false\n | {\n acknowledgedBy: string;\n acknowledgedAt: Date;\n };\n active:\n | true\n | {\n rectifiedTime: Date;\n };\n type: AlertType;\n time: Date;\n lastModified?: Date;\n shelved?:\n | false\n | {\n shelvedStartTime: Date;\n shelvedEndTime?: Date;\n shelvedBy?: string;\n };\n blocked?:\n | false\n | {\n blockedStartTime: Date;\n blockedEndTime?: Date;\n blockedBy?: string;\n };\n noAck?: boolean;\n noSilence?: boolean;\n category?: AlertCategory;\n memberOf?: string[];\n}\n\nexport function isActive(alert: Alert) {\n return alert.active === true;\n}\n\nexport function isAcknowledged(alert: Alert) {\n return alert.acknowledged !== false && alert.acknowledged !== undefined;\n}\n\nexport function isShelved(alert: Alert) {\n return alert.shelved !== false && alert.shelved !== undefined;\n}\n\nexport function isBlocked(alert: Alert) {\n return alert.blocked !== false && alert.blocked !== undefined;\n}\n\nexport function comparePriorityAlerts(a: Alert, b: Alert) {\n if (a.type !== b.type) {\n return (\n ALERT_SEVERITY_PRIORITY.indexOf(b.type) -\n ALERT_SEVERITY_PRIORITY.indexOf(a.type)\n );\n }\n\n if (isActive(a) !== isActive(b)) {\n return isActive(a) ? 1 : -1;\n }\n\n if (isAcknowledged(a) !== isAcknowledged(b)) {\n return isAcknowledged(a) ? -1 : 1;\n }\n return a.time.getTime() - b.time.getTime();\n}\n\nexport type TimeSinceFn = (time: Date) => string;\n\nexport function formatTimeSince(time: Date) {\n const now = new Date();\n const diff = now.getTime() - time.getTime();\n const diffInSeconds = diff / 1000;\n if (diffInSeconds < 60) {\n return Math.round(diffInSeconds) + 's';\n }\n const diffInMinutes = diffInSeconds / 60;\n if (diffInMinutes < 60) {\n return (\n Math.round(diffInMinutes) + 'm ' + Math.round(diffInSeconds % 60) + 's'\n );\n }\n const diffInHours = diffInMinutes / 60;\n if (diffInHours < 24) {\n return (\n Math.round(diffInHours) + 'h ' + Math.round(diffInMinutes % 60) + 'm'\n );\n }\n const diffInDays = diffInHours / 24;\n if (diffInDays < 365) {\n return Math.round(diffInDays) + 'd ' + Math.round(diffInHours % 24) + 'h';\n }\n return (\n Math.round(diffInDays / 365) + 'y ' + Math.round(diffInDays % 365) + 'd'\n );\n}\n"],"names":["Direction","AlertType","AlertCategory"],"mappings":"AAAO,IAAK,8BAAAA,eAAL;AACLA,aAAA,IAAA,IAAK;AACLA,aAAA,MAAA,IAAO;AACPA,aAAA,MAAA,IAAO;AACPA,aAAA,OAAA,IAAQ;AAJE,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAOL,IAAK,8BAAAC,eAAL;AACLA,aAAA,OAAA,IAAQ;AACRA,aAAA,SAAA,IAAU;AACVA,aAAA,SAAA,IAAU;AACVA,aAAA,eAAA,IAAgB;AAChBA,aAAA,WAAA,IAAY;AACZA,aAAA,aAAA,IAAc;AACdA,aAAA,UAAA,IAAW;AACXA,aAAA,iBAAA,IAAkB;AARR,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["export enum Direction {\n Up = 'up',\n Down = 'down',\n Left = 'left',\n Right = 'right',\n}\n\nexport enum AlertType {\n Alarm = 'alarm',\n Warning = 'warning',\n Caution = 'caution',\n LevelCritical = 'level-critical',\n LevelHigh = 'level-high',\n LevelMedium = 'level-medium',\n LevelLow = 'level-low',\n LevelDiagnostic = 'level-diagnostic',\n}\n\n/**\n * Flash tempo of an alert element. `default` resolves per alert type and\n * phase (see `resolveFlashingSpeed` in `alert-severity.ts`); `fixed` never\n * flashes.\n */\nexport enum FlashingSpeed {\n Default = 'default',\n Fast = 'fast',\n Slow = 'slow',\n VerySlow = 'very-slow',\n Fixed = 'fixed',\n}\n\nexport type ResolvedFlashingSpeed = Exclude<\n FlashingSpeed,\n FlashingSpeed.Default\n>;\n\nexport type FlashTempo = Exclude<ResolvedFlashingSpeed, FlashingSpeed.Fixed>;\n\nexport const ALERT_SEVERITY_PRIORITY = [\n AlertType.LevelCritical,\n AlertType.Alarm,\n AlertType.LevelHigh,\n AlertType.Warning,\n AlertType.LevelMedium,\n AlertType.Caution,\n AlertType.LevelLow,\n AlertType.LevelDiagnostic,\n];\n\nexport enum AlertCategory {\n a = 'a',\n b = 'b',\n c = 'c',\n}\n\nexport interface Alert {\n id: string;\n tagId: string;\n source: string;\n text: string;\n note?: string;\n acknowledged:\n | false\n | {\n acknowledgedBy: string;\n acknowledgedAt: Date;\n };\n active:\n | true\n | {\n rectifiedTime: Date;\n };\n type: AlertType;\n time: Date;\n lastModified?: Date;\n shelved?:\n | false\n | {\n shelvedStartTime: Date;\n shelvedEndTime?: Date;\n shelvedBy?: string;\n };\n blocked?:\n | false\n | {\n blockedStartTime: Date;\n blockedEndTime?: Date;\n blockedBy?: string;\n };\n noAck?: boolean;\n noSilence?: boolean;\n category?: AlertCategory;\n memberOf?: string[];\n}\n\nexport function isActive(alert: Alert) {\n return alert.active === true;\n}\n\nexport function isAcknowledged(alert: Alert) {\n return alert.acknowledged !== false && alert.acknowledged !== undefined;\n}\n\nexport function isShelved(alert: Alert) {\n return alert.shelved !== false && alert.shelved !== undefined;\n}\n\nexport function isBlocked(alert: Alert) {\n return alert.blocked !== false && alert.blocked !== undefined;\n}\n\nexport function comparePriorityAlerts(a: Alert, b: Alert) {\n if (a.type !== b.type) {\n return (\n ALERT_SEVERITY_PRIORITY.indexOf(b.type) -\n ALERT_SEVERITY_PRIORITY.indexOf(a.type)\n );\n }\n\n if (isActive(a) !== isActive(b)) {\n return isActive(a) ? 1 : -1;\n }\n\n if (isAcknowledged(a) !== isAcknowledged(b)) {\n return isAcknowledged(a) ? -1 : 1;\n }\n return a.time.getTime() - b.time.getTime();\n}\n\nexport type TimeSinceFn = (time: Date) => string;\n\nexport function formatTimeSince(time: Date) {\n const now = new Date();\n const diff = now.getTime() - time.getTime();\n const diffInSeconds = diff / 1000;\n if (diffInSeconds < 60) {\n return Math.round(diffInSeconds) + 's';\n }\n const diffInMinutes = diffInSeconds / 60;\n if (diffInMinutes < 60) {\n return (\n Math.round(diffInMinutes) + 'm ' + Math.round(diffInSeconds % 60) + 's'\n );\n }\n const diffInHours = diffInMinutes / 60;\n if (diffInHours < 24) {\n return (\n Math.round(diffInHours) + 'h ' + Math.round(diffInMinutes % 60) + 'm'\n );\n }\n const diffInDays = diffInHours / 24;\n if (diffInDays < 365) {\n return Math.round(diffInDays) + 'd ' + Math.round(diffInHours % 24) + 'h';\n }\n return (\n Math.round(diffInDays / 365) + 'y ' + Math.round(diffInDays % 365) + 'd'\n );\n}\n"],"names":["Direction","AlertType","FlashingSpeed","AlertCategory"],"mappings":"AAAO,IAAK,8BAAAA,eAAL;AACLA,aAAA,IAAA,IAAK;AACLA,aAAA,MAAA,IAAO;AACPA,aAAA,MAAA,IAAO;AACPA,aAAA,OAAA,IAAQ;AAJE,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAOL,IAAK,8BAAAC,eAAL;AACLA,aAAA,OAAA,IAAQ;AACRA,aAAA,SAAA,IAAU;AACVA,aAAA,SAAA,IAAU;AACVA,aAAA,eAAA,IAAgB;AAChBA,aAAA,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AO,EAAE,KAAK,QAAA,IAAY,EAAE,KAAK,QAAA;AACnC;AAIO,SAAS,gBAAgB,MAAY;AAC1C,QAAM,0BAAU,KAAA;AAChB,QAAM,OAAO,IAAI,QAAA,IAAY,KAAK,QAAA;AAClC,QAAM,gBAAgB,OAAO;AAC7B,MAAI,gBAAgB,IAAI;AACtB,WAAO,KAAK,MAAM,aAAa,IAAI;AAAA,EACrC;AACA,QAAM,gBAAgB,gBAAgB;AACtC,MAAI,gBAAgB,IAAI;AACtB,WACE,KAAK,MAAM,aAAa,IAAI,OAAO,KAAK,MAAM,gBAAgB,EAAE,IAAI;AAAA,EAExE;AACA,QAAM,cAAc,gBAAgB;AACpC,MAAI,cAAc,IAAI;AACpB,WACE,KAAK,MAAM,WAAW,IAAI,OAAO,KAAK,MAAM,gBAAgB,EAAE,IAAI;AAAA,EAEtE;AACA,QAAM,aAAa,cAAc;AACjC,MAAI,aAAa,KAAK;AACpB,WAAO,KAAK,MAAM,UAAU,IAAI,OAAO,KAAK,MAAM,cAAc,EAAE,IAAI;AAAA,EACxE;AACA,SACE,KAAK,MAAM,aAAa,GAAG,IAAI,OAAO,KAAK,MAAM,aAAa,GAAG,IAAI;AAEzE;"}
|
package/package.json
CHANGED
|
@@ -44,22 +44,9 @@ import fs from 'fs';
|
|
|
44
44
|
import path from 'path';
|
|
45
45
|
import {globby} from 'globby';
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
// decision (token value, rename target, or removal). Tracked for follow-up.
|
|
49
|
-
// See https://github.com/Ocean-Industries-Concept-Lab/openbridge-webcomponents/issues/916
|
|
47
|
+
// Undefined CSS variables that only a fix in Figma can resolve (#929).
|
|
50
48
|
const allowedUndefinedVariables = new Set([
|
|
51
|
-
// B-
|
|
52
|
-
'--app-components-alert-components-general-notification-item-icon-size-large',
|
|
53
|
-
// B-2: alert counter spacing (alert-button.css)
|
|
54
|
-
'--app-components-global-alert-item-counter-spacing',
|
|
55
|
-
// B-3: likely typo for --normal-enabled-background-color (sequence-toolbar.css)
|
|
56
|
-
'--enabled-background-color',
|
|
57
|
-
// B-4: date-item vertical padding (date-item.css) — sibling tokens exist
|
|
58
|
-
'--menu-navigation-components-date-item-padding-vertical',
|
|
59
|
-
// B-5/B-6: instrument-field internal widths — unusual --obc- prefix
|
|
60
|
-
'--obc-instrument-field-source-width',
|
|
61
|
-
'--obc-instrument-field-tag-width',
|
|
62
|
-
// B-7: keyboard "numeric" tokens missing from the (misspelled) family
|
|
49
|
+
// B-7: Figma binds both to variables missing from Component-size
|
|
63
50
|
'--ui-components-keyboard-numeric-component-height-min',
|
|
64
51
|
'--ui-components-keyboard-numeric-touch-target-size',
|
|
65
52
|
]);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {AlertFlashPhase, resolveFlashingSpeed} from './alert-severity.js';
|
|
3
|
+
import {AlertType, FlashingSpeed} from './types.js';
|
|
4
|
+
|
|
5
|
+
describe('resolveFlashingSpeed', () => {
|
|
6
|
+
it.each([
|
|
7
|
+
[AlertType.LevelCritical, FlashingSpeed.Fast],
|
|
8
|
+
[AlertType.Alarm, FlashingSpeed.Fast],
|
|
9
|
+
[AlertType.LevelHigh, FlashingSpeed.Fast],
|
|
10
|
+
[AlertType.Warning, FlashingSpeed.Slow],
|
|
11
|
+
[AlertType.LevelMedium, FlashingSpeed.Slow],
|
|
12
|
+
[AlertType.LevelLow, FlashingSpeed.VerySlow],
|
|
13
|
+
[AlertType.Caution, FlashingSpeed.Fixed],
|
|
14
|
+
[AlertType.LevelDiagnostic, FlashingSpeed.Fixed],
|
|
15
|
+
])('default active %s → %s', (type, expected) => {
|
|
16
|
+
expect(resolveFlashingSpeed(FlashingSpeed.Default, type)).toBe(expected);
|
|
17
|
+
expect(
|
|
18
|
+
resolveFlashingSpeed(FlashingSpeed.Default, type, AlertFlashPhase.Active)
|
|
19
|
+
).toBe(expected);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it.each([
|
|
23
|
+
[AlertType.LevelCritical, FlashingSpeed.VerySlow],
|
|
24
|
+
[AlertType.Alarm, FlashingSpeed.VerySlow],
|
|
25
|
+
[AlertType.LevelHigh, FlashingSpeed.VerySlow],
|
|
26
|
+
[AlertType.Warning, FlashingSpeed.VerySlow],
|
|
27
|
+
[AlertType.LevelMedium, FlashingSpeed.VerySlow],
|
|
28
|
+
[AlertType.LevelLow, FlashingSpeed.VerySlow],
|
|
29
|
+
[AlertType.Caution, FlashingSpeed.Fixed],
|
|
30
|
+
[AlertType.LevelDiagnostic, FlashingSpeed.Fixed],
|
|
31
|
+
])('default rectified %s → %s', (type, expected) => {
|
|
32
|
+
expect(
|
|
33
|
+
resolveFlashingSpeed(
|
|
34
|
+
FlashingSpeed.Default,
|
|
35
|
+
type,
|
|
36
|
+
AlertFlashPhase.Rectified
|
|
37
|
+
)
|
|
38
|
+
).toBe(expected);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('returns an explicit speed unchanged', () => {
|
|
42
|
+
expect(resolveFlashingSpeed(FlashingSpeed.Slow, AlertType.Alarm)).toBe(
|
|
43
|
+
FlashingSpeed.Slow
|
|
44
|
+
);
|
|
45
|
+
expect(
|
|
46
|
+
resolveFlashingSpeed(
|
|
47
|
+
FlashingSpeed.Fast,
|
|
48
|
+
AlertType.Caution,
|
|
49
|
+
AlertFlashPhase.Rectified
|
|
50
|
+
)
|
|
51
|
+
).toBe(FlashingSpeed.Fast);
|
|
52
|
+
expect(resolveFlashingSpeed(FlashingSpeed.Fixed, AlertType.Alarm)).toBe(
|
|
53
|
+
FlashingSpeed.Fixed
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
});
|
package/src/alert-severity.ts
CHANGED
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
* - Component selectors: `getAlertBadgeComponent` and
|
|
17
17
|
* `getAlertTwotoneComponent` resolve the badge/icon element tag for a
|
|
18
18
|
* severity.
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* by the bridge alert management (BAM) blink machinery.
|
|
19
|
+
* - Flashing: `resolveFlashingSpeed` maps a severity and phase onto the
|
|
20
|
+
* design tempo table, and `getBamAlertTypeForBlinking` maps level
|
|
21
|
+
* severities onto the legacy type that selects the icon glyphs.
|
|
23
22
|
* - Acknowledgement & filtering: `requiresAcknowledgement` reports whether a
|
|
24
23
|
* severity needs an ACK action, `excludedFromUnackedFilter` reports whether
|
|
25
24
|
* it is hidden from the "unacked" view, and `usesAlarmNoAckIcon` selects the
|
|
@@ -45,7 +44,12 @@
|
|
|
45
44
|
* );
|
|
46
45
|
* ```
|
|
47
46
|
*/
|
|
48
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
AlertType,
|
|
49
|
+
ALERT_SEVERITY_PRIORITY,
|
|
50
|
+
FlashingSpeed,
|
|
51
|
+
type ResolvedFlashingSpeed,
|
|
52
|
+
} from './types.js';
|
|
49
53
|
|
|
50
54
|
export {ALERT_SEVERITY_PRIORITY};
|
|
51
55
|
|
|
@@ -74,22 +78,44 @@ export function requiresAcknowledgement(type: AlertType): boolean {
|
|
|
74
78
|
].includes(type);
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
export
|
|
81
|
+
export enum AlertFlashPhase {
|
|
82
|
+
Active = 'active',
|
|
83
|
+
Rectified = 'rectified',
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resolves the `default` flashing speed from the design tempo table (#1224):
|
|
88
|
+
* active critical/alarm/high flash fast, warning/medium slow, low very slow;
|
|
89
|
+
* every rectified alert flashes very slow; caution and diagnostic never
|
|
90
|
+
* flash. Callers map acknowledged alerts to `fixed` before asking.
|
|
91
|
+
*/
|
|
92
|
+
export function resolveFlashingSpeed(
|
|
93
|
+
speed: FlashingSpeed,
|
|
78
94
|
type: AlertType,
|
|
79
|
-
|
|
80
|
-
):
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
95
|
+
phase: AlertFlashPhase = AlertFlashPhase.Active
|
|
96
|
+
): ResolvedFlashingSpeed {
|
|
97
|
+
if (speed !== FlashingSpeed.Default) {
|
|
98
|
+
return speed;
|
|
99
|
+
}
|
|
100
|
+
if (type === AlertType.Caution || type === AlertType.LevelDiagnostic) {
|
|
101
|
+
return FlashingSpeed.Fixed;
|
|
102
|
+
}
|
|
103
|
+
if (phase === AlertFlashPhase.Rectified) {
|
|
104
|
+
return FlashingSpeed.VerySlow;
|
|
105
|
+
}
|
|
106
|
+
switch (type) {
|
|
107
|
+
case AlertType.LevelCritical:
|
|
108
|
+
case AlertType.Alarm:
|
|
109
|
+
case AlertType.LevelHigh:
|
|
110
|
+
return FlashingSpeed.Fast;
|
|
111
|
+
case AlertType.Warning:
|
|
112
|
+
case AlertType.LevelMedium:
|
|
113
|
+
return FlashingSpeed.Slow;
|
|
114
|
+
case AlertType.LevelLow:
|
|
115
|
+
return FlashingSpeed.VerySlow;
|
|
116
|
+
default:
|
|
117
|
+
return FlashingSpeed.Fixed;
|
|
83
118
|
}
|
|
84
|
-
|
|
85
|
-
return [
|
|
86
|
-
AlertType.Alarm,
|
|
87
|
-
AlertType.Warning,
|
|
88
|
-
AlertType.LevelCritical,
|
|
89
|
-
AlertType.LevelHigh,
|
|
90
|
-
AlertType.LevelMedium,
|
|
91
|
-
AlertType.LevelLow,
|
|
92
|
-
].includes(type);
|
|
93
119
|
}
|
|
94
120
|
|
|
95
121
|
export function getAlertSeverityCssClass(type: AlertType): string {
|
|
@@ -183,30 +209,6 @@ export function getAlertTwotoneComponent(
|
|
|
183
209
|
}
|
|
184
210
|
}
|
|
185
211
|
|
|
186
|
-
export enum AlertBlinkMode {
|
|
187
|
-
Critical = 'critical',
|
|
188
|
-
Alarm = 'alarm',
|
|
189
|
-
Warning = 'warning',
|
|
190
|
-
Low = 'low',
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function getAlertBlinkMode(type: AlertType): AlertBlinkMode {
|
|
194
|
-
switch (type) {
|
|
195
|
-
case AlertType.LevelCritical:
|
|
196
|
-
return AlertBlinkMode.Critical;
|
|
197
|
-
case AlertType.Warning:
|
|
198
|
-
case AlertType.LevelMedium:
|
|
199
|
-
return AlertBlinkMode.Warning;
|
|
200
|
-
case AlertType.Caution:
|
|
201
|
-
case AlertType.LevelLow:
|
|
202
|
-
return AlertBlinkMode.Low;
|
|
203
|
-
case AlertType.Alarm:
|
|
204
|
-
case AlertType.LevelHigh:
|
|
205
|
-
default:
|
|
206
|
-
return AlertBlinkMode.Alarm;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
212
|
export function getBamAlertTypeForBlinking(type: AlertType): AlertType {
|
|
211
213
|
switch (type) {
|
|
212
214
|
case AlertType.LevelCritical:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Meta, StoryObj} from '@storybook/web-components-vite';
|
|
1
|
+
import type {Args, Meta, StoryObj} from '@storybook/web-components-vite';
|
|
2
2
|
import {html} from 'lit';
|
|
3
3
|
import type {ObcAreaGraph} from './area-graph.js';
|
|
4
4
|
import './area-graph.js';
|
|
@@ -91,6 +91,7 @@ const meta: Meta = {
|
|
|
91
91
|
.showGridX=${_args.showGridX}
|
|
92
92
|
.showGridY=${_args.showGridY}
|
|
93
93
|
.showTickMarks=${_args.showTickMarks}
|
|
94
|
+
.rangeLabels=${_args.rangeLabels}
|
|
94
95
|
.xTicksLimit=${_args.xTicksLimit}
|
|
95
96
|
.xStepSize=${_args.xStepSize}
|
|
96
97
|
.yTicksLimit=${_args.yTicksLimit}
|
|
@@ -121,6 +122,10 @@ const meta: Meta = {
|
|
|
121
122
|
showGridX: {control: 'boolean'},
|
|
122
123
|
showGridY: {control: 'boolean'},
|
|
123
124
|
showTickMarks: {control: 'boolean'},
|
|
125
|
+
rangeLabels: {
|
|
126
|
+
control: {type: 'radio'},
|
|
127
|
+
options: ['none', 'y', 'x', 'xy'],
|
|
128
|
+
},
|
|
124
129
|
xTicksLimit: {control: {type: 'number'}},
|
|
125
130
|
xStepSize: {control: {type: 'number'}},
|
|
126
131
|
yTicksLimit: {control: {type: 'number'}},
|
|
@@ -154,6 +159,7 @@ const meta: Meta = {
|
|
|
154
159
|
showGridX: true, // Component defaults to false, but stories show grid by default
|
|
155
160
|
showGridY: true, // Component defaults to false, but stories show grid by default
|
|
156
161
|
showTickMarks: true, // Component defaults to false, but stories show tick marks by default
|
|
162
|
+
rangeLabels: 'none',
|
|
157
163
|
xTicksLimit: undefined,
|
|
158
164
|
xStepSize: undefined,
|
|
159
165
|
yTicksLimit: undefined,
|
|
@@ -259,6 +265,67 @@ export const NumberAxis: Story = {
|
|
|
259
265
|
`,
|
|
260
266
|
};
|
|
261
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Five of the twelve minutes have arrived. Without `xAxis` the trace would
|
|
270
|
+
* stretch across the full width; pinned, it occupies the right-hand slice
|
|
271
|
+
* and grows leftwards as the buffer fills (#1218).
|
|
272
|
+
*/
|
|
273
|
+
const PINNED_X_RANGE_DATA = [-4, -3, -2, -1, 0].map((x, i) => ({
|
|
274
|
+
x,
|
|
275
|
+
value: SAMPLE_DATA[i].value,
|
|
276
|
+
}));
|
|
277
|
+
|
|
278
|
+
export const PinnedXRange: Story = {
|
|
279
|
+
name: 'Pinned X Range (Filling Buffer)',
|
|
280
|
+
args: {
|
|
281
|
+
xAxisType: 'number',
|
|
282
|
+
height: 220,
|
|
283
|
+
},
|
|
284
|
+
play: async ({canvasElement}) => {
|
|
285
|
+
await document.fonts.ready;
|
|
286
|
+
const chart = canvasElement.querySelector('obc-area-graph') as
|
|
287
|
+
| (HTMLElement & {chart?: {update(): void}})
|
|
288
|
+
| null;
|
|
289
|
+
chart?.chart?.update();
|
|
290
|
+
},
|
|
291
|
+
render: (_args) => html`
|
|
292
|
+
<obc-area-graph
|
|
293
|
+
.data=${PINNED_X_RANGE_DATA}
|
|
294
|
+
.xAxisType=${_args.xAxisType}
|
|
295
|
+
.xAxis=${{min: -12, max: 0}}
|
|
296
|
+
.yAxes=${[{id: 'y', position: 'left' as const, min: 0, max: 8}]}
|
|
297
|
+
.fillMode=${_args.fillMode}
|
|
298
|
+
.lineMode=${_args.lineMode}
|
|
299
|
+
.showGrid=${_args.showGrid}
|
|
300
|
+
.showGridX=${_args.showGridX}
|
|
301
|
+
.showGridY=${_args.showGridY}
|
|
302
|
+
.priority=${_args.priority}
|
|
303
|
+
.showDebugOverlay=${_args.showDebugOverlay}
|
|
304
|
+
.width=${_args.width}
|
|
305
|
+
.height=${_args.height}
|
|
306
|
+
>
|
|
307
|
+
<obc-bar-vertical
|
|
308
|
+
slot="left-scale"
|
|
309
|
+
side="left"
|
|
310
|
+
.height=${_args.height}
|
|
311
|
+
.primaryTickmarkInterval=${2}
|
|
312
|
+
.secondaryTickmarkInterval=${1}
|
|
313
|
+
.hasBar=${false}
|
|
314
|
+
.priority=${_args.priority}
|
|
315
|
+
></obc-bar-vertical>
|
|
316
|
+
<obc-bar-horizontal
|
|
317
|
+
slot="bottom-scale"
|
|
318
|
+
side="bottom"
|
|
319
|
+
.width=${_args.width}
|
|
320
|
+
.primaryTickmarkInterval=${2}
|
|
321
|
+
.secondaryTickmarkInterval=${1}
|
|
322
|
+
.hasBar=${false}
|
|
323
|
+
.priority=${_args.priority}
|
|
324
|
+
></obc-bar-horizontal>
|
|
325
|
+
</obc-area-graph>
|
|
326
|
+
`,
|
|
327
|
+
};
|
|
328
|
+
|
|
262
329
|
export const SemitransparentExternalScales: Story = {
|
|
263
330
|
name: 'Semitransparent Area Graph (with external scales)',
|
|
264
331
|
tags: ['skip-test'],
|
|
@@ -452,6 +519,79 @@ export const SemitransparentExternalScales: Story = {
|
|
|
452
519
|
`,
|
|
453
520
|
};
|
|
454
521
|
|
|
522
|
+
/**
|
|
523
|
+
* Two identical configurations fed data forty times apart. Their
|
|
524
|
+
* frames must line up exactly — a drift between them means the plot rectangle
|
|
525
|
+
* has started following the data again (#1214).
|
|
526
|
+
*/
|
|
527
|
+
const FIXED_FRAME_SHALLOW = SAMPLE_DATA.map((p, i) => ({x: i, value: p.value}));
|
|
528
|
+
const FIXED_FRAME_DEEP = SAMPLE_DATA.map((p, i) => ({
|
|
529
|
+
x: i,
|
|
530
|
+
value: p.value * 40,
|
|
531
|
+
}));
|
|
532
|
+
|
|
533
|
+
const renderFixedFrameChart = (
|
|
534
|
+
_args: Args,
|
|
535
|
+
data: {x: number; value: number}[]
|
|
536
|
+
) => html`
|
|
537
|
+
<obc-area-graph
|
|
538
|
+
.data=${data}
|
|
539
|
+
.xAxisType=${'number'}
|
|
540
|
+
.yAxes=${[{id: 'y', position: 'left' as const, min: 0, max: 300}]}
|
|
541
|
+
.fillMode=${_args.fillMode}
|
|
542
|
+
.lineMode=${_args.lineMode}
|
|
543
|
+
.showGrid=${_args.showGrid}
|
|
544
|
+
.showGridX=${_args.showGridX}
|
|
545
|
+
.showGridY=${_args.showGridY}
|
|
546
|
+
.priority=${_args.priority}
|
|
547
|
+
.rangeLabels=${_args.rangeLabels}
|
|
548
|
+
.showDebugOverlay=${_args.showDebugOverlay}
|
|
549
|
+
.width=${_args.width}
|
|
550
|
+
.height=${_args.height}
|
|
551
|
+
>
|
|
552
|
+
<obc-bar-vertical
|
|
553
|
+
slot="left-scale"
|
|
554
|
+
side="left"
|
|
555
|
+
.height=${_args.height}
|
|
556
|
+
.primaryTickmarkInterval=${100}
|
|
557
|
+
.secondaryTickmarkInterval=${50}
|
|
558
|
+
.hasBar=${false}
|
|
559
|
+
.priority=${_args.priority}
|
|
560
|
+
></obc-bar-vertical>
|
|
561
|
+
<obc-bar-horizontal
|
|
562
|
+
slot="bottom-scale"
|
|
563
|
+
side="bottom"
|
|
564
|
+
.width=${_args.width}
|
|
565
|
+
.primaryTickmarkInterval=${2}
|
|
566
|
+
.secondaryTickmarkInterval=${1}
|
|
567
|
+
.hasBar=${false}
|
|
568
|
+
.priority=${_args.priority}
|
|
569
|
+
></obc-bar-horizontal>
|
|
570
|
+
</obc-area-graph>
|
|
571
|
+
`;
|
|
572
|
+
|
|
573
|
+
export const FixedFrame: Story = {
|
|
574
|
+
name: 'Fixed Frame (Pinned Range With External Scales)',
|
|
575
|
+
args: {
|
|
576
|
+
width: 480,
|
|
577
|
+
height: 220,
|
|
578
|
+
},
|
|
579
|
+
play: async ({canvasElement}) => {
|
|
580
|
+
await document.fonts.ready;
|
|
581
|
+
canvasElement
|
|
582
|
+
.querySelectorAll('obc-area-graph')
|
|
583
|
+
.forEach((chart) =>
|
|
584
|
+
(chart as HTMLElement & {chart?: {update(): void}}).chart?.update()
|
|
585
|
+
);
|
|
586
|
+
},
|
|
587
|
+
render: (_args) => html`
|
|
588
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
589
|
+
${renderFixedFrameChart(_args, FIXED_FRAME_SHALLOW)}
|
|
590
|
+
${renderFixedFrameChart(_args, FIXED_FRAME_DEEP)}
|
|
591
|
+
</div>
|
|
592
|
+
`,
|
|
593
|
+
};
|
|
594
|
+
|
|
455
595
|
export const WithPoints: Story = {
|
|
456
596
|
name: 'With Points Area Graph',
|
|
457
597
|
args: {
|
|
@@ -515,6 +655,24 @@ export const MinHeight: Story = {
|
|
|
515
655
|
},
|
|
516
656
|
};
|
|
517
657
|
|
|
658
|
+
export const MinHeightRangeLabels: Story = {
|
|
659
|
+
name: 'Minimal Height With Range Labels (48px)',
|
|
660
|
+
args: {
|
|
661
|
+
width: 120,
|
|
662
|
+
height: 48,
|
|
663
|
+
rangeLabels: 'xy',
|
|
664
|
+
},
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
export const BelowThresholdRangeLabels: Story = {
|
|
668
|
+
name: 'Below Threshold With Range Labels (191px, Y Only)',
|
|
669
|
+
args: {
|
|
670
|
+
width: 288,
|
|
671
|
+
height: 191,
|
|
672
|
+
rangeLabels: 'y',
|
|
673
|
+
},
|
|
674
|
+
};
|
|
675
|
+
|
|
518
676
|
export const ThresholdHeightSize: Story = {
|
|
519
677
|
name: 'Threshold Height Area Graph (192px, where labels appear)',
|
|
520
678
|
args: {
|
|
@@ -702,3 +860,79 @@ export const RealtimeShifting: Story = {
|
|
|
702
860
|
return chart;
|
|
703
861
|
},
|
|
704
862
|
};
|
|
863
|
+
|
|
864
|
+
export const RealtimeFixedFrame: Story = {
|
|
865
|
+
name: 'Realtime (Fixed Frame)',
|
|
866
|
+
tags: ['skip-test'],
|
|
867
|
+
render: (_args) => {
|
|
868
|
+
const chart = document.createElement('obc-area-graph');
|
|
869
|
+
chart.showDebugOverlay = _args.showDebugOverlay;
|
|
870
|
+
chart.width = _args.width;
|
|
871
|
+
chart.height = _args.height;
|
|
872
|
+
chart.priority = _args.priority;
|
|
873
|
+
chart.rangeLabels = _args.rangeLabels;
|
|
874
|
+
|
|
875
|
+
// A slotted horizontal scale labels raw axis values, so the x axis carries
|
|
876
|
+
// minutes-ago rather than epoch milliseconds (#1219).
|
|
877
|
+
chart.xAxisType = 'number';
|
|
878
|
+
|
|
879
|
+
// The pinned range is what holds the frame still: fixed labels give the
|
|
880
|
+
// scale a fixed thickness, so the plot rectangle stops following the data.
|
|
881
|
+
chart.yAxes = [{id: 'y', position: 'left', min: 0, max: 10}];
|
|
882
|
+
|
|
883
|
+
const verticalScale = document.createElement('obc-bar-vertical');
|
|
884
|
+
verticalScale.slot = 'left-scale';
|
|
885
|
+
verticalScale.side = 'left';
|
|
886
|
+
verticalScale.height = _args.height;
|
|
887
|
+
verticalScale.primaryTickmarkInterval = 2;
|
|
888
|
+
verticalScale.secondaryTickmarkInterval = 1;
|
|
889
|
+
verticalScale.hasBar = false;
|
|
890
|
+
verticalScale.priority = _args.priority;
|
|
891
|
+
chart.appendChild(verticalScale);
|
|
892
|
+
|
|
893
|
+
const horizontalScale = document.createElement('obc-bar-horizontal');
|
|
894
|
+
horizontalScale.slot = 'bottom-scale';
|
|
895
|
+
horizontalScale.side = 'bottom';
|
|
896
|
+
horizontalScale.width = _args.width;
|
|
897
|
+
horizontalScale.primaryTickmarkInterval = 2;
|
|
898
|
+
horizontalScale.secondaryTickmarkInterval = 1;
|
|
899
|
+
horizontalScale.hasBar = false;
|
|
900
|
+
horizontalScale.priority = _args.priority;
|
|
901
|
+
chart.appendChild(horizontalScale);
|
|
902
|
+
|
|
903
|
+
const windowMinutes = 12;
|
|
904
|
+
|
|
905
|
+
// The window is declared rather than inferred from the data, so the buffer
|
|
906
|
+
// starts empty and fills into the right-hand slice instead of stretching
|
|
907
|
+
// across the full width (#1218).
|
|
908
|
+
chart.xAxis = {min: -(windowMinutes - 1), max: 0};
|
|
909
|
+
|
|
910
|
+
// Values roam the whole range, unlike Realtime (Shifting) which repeats a
|
|
911
|
+
// fixed set: here the frame holds because both ranges are pinned.
|
|
912
|
+
const nextValue = () => Math.random() * 10;
|
|
913
|
+
|
|
914
|
+
let values: number[] = [];
|
|
915
|
+
const publish = () => {
|
|
916
|
+
chart.data = values.map((value, i) => ({
|
|
917
|
+
x: i - (values.length - 1),
|
|
918
|
+
value,
|
|
919
|
+
}));
|
|
920
|
+
};
|
|
921
|
+
publish();
|
|
922
|
+
|
|
923
|
+
const interval = setInterval(() => {
|
|
924
|
+
values = [...values, nextValue()].slice(-windowMinutes);
|
|
925
|
+
publish();
|
|
926
|
+
}, 2000);
|
|
927
|
+
|
|
928
|
+
const mo = new MutationObserver(() => {
|
|
929
|
+
if (!document.body.contains(chart)) {
|
|
930
|
+
clearInterval(interval);
|
|
931
|
+
mo.disconnect();
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
mo.observe(document.body, {childList: true, subtree: true});
|
|
935
|
+
|
|
936
|
+
return chart;
|
|
937
|
+
},
|
|
938
|
+
};
|