genesys-spark-chart-components 4.12.1-beta.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/cjs/genesys-chart-webcomponents.cjs.js +23 -0
- package/dist/cjs/gux-chart-column-beta.cjs.entry.js +140 -0
- package/dist/cjs/gux-chart-donut-beta.cjs.entry.js +229 -0
- package/dist/cjs/gux-chart-line-beta.cjs.entry.js +135 -0
- package/dist/cjs/gux-chart-pie-beta.cjs.entry.js +113 -0
- package/dist/cjs/gux-chart-scatter-plot-beta.cjs.entry.js +143 -0
- package/dist/cjs/gux-visualization-beta.cjs.entry.js +71953 -0
- package/dist/cjs/index-1e13a15f.js +1647 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/log-error-c46b4b4c.js +21 -0
- package/dist/cjs/usage-30f04ec3.js +208 -0
- package/dist/collection/collection-manifest.json +17 -0
- package/dist/collection/components/beta/gux-chart-column/gux-chart-column.css +13 -0
- package/dist/collection/components/beta/gux-chart-column/gux-chart-column.js +343 -0
- package/dist/collection/components/beta/gux-chart-column/gux-chart-column.locale.js +92 -0
- package/dist/collection/components/beta/gux-chart-column/tests/gux-column-chart.spec.js +22 -0
- package/dist/collection/components/beta/gux-chart-donut/gux-chart-donut.css +4 -0
- package/dist/collection/components/beta/gux-chart-donut/gux-chart-donut.js +575 -0
- package/dist/collection/components/beta/gux-chart-donut/tests/gux-chart-donut.spec.js +11 -0
- package/dist/collection/components/beta/gux-chart-line/gux-chart-line.css +4 -0
- package/dist/collection/components/beta/gux-chart-line/gux-chart-line.js +391 -0
- package/dist/collection/components/beta/gux-chart-line/gux-chart-line.locale.js +92 -0
- package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.e2e.js +17 -0
- package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.spec.js +22 -0
- package/dist/collection/components/beta/gux-chart-pie/gux-chart-pie.css +4 -0
- package/dist/collection/components/beta/gux-chart-pie/gux-chart-pie.js +284 -0
- package/dist/collection/components/beta/gux-chart-pie/tests/gux-chart-pie.spec.js +11 -0
- package/dist/collection/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.css +4 -0
- package/dist/collection/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.js +365 -0
- package/dist/collection/components/beta/gux-chart-scatter-plot/tests/gux-chart-scatter-plot.spec.js +33 -0
- package/dist/collection/components/beta/gux-visualization/gux-visualization.css +19 -0
- package/dist/collection/components/beta/gux-visualization/gux-visualization.js +143 -0
- package/dist/collection/components/beta/gux-visualization/gux-visualization.locale.js +92 -0
- package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.e2e.js +31 -0
- package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.spec.js +35 -0
- package/dist/collection/i18n/fetchResources.js +12 -0
- package/dist/collection/i18n/index.js +73 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/test/axeConfig.js +7 -0
- package/dist/collection/test/e2eTestUtils.js +20 -0
- package/dist/collection/test/jestMatcherUtils.js +1 -0
- package/dist/collection/test/setupAxeTests.js +75 -0
- package/dist/collection/test/setupTests.js +9 -0
- package/dist/collection/test/specTestUtils.js +10 -0
- package/dist/collection/utils/dom/get-closest-element.js +15 -0
- package/dist/collection/utils/error/log-error.js +6 -0
- package/dist/collection/utils/theme/color-palette.js +12 -0
- package/dist/collection/utils/tracking/usage.js +81 -0
- package/dist/collection/utils/tracking/usage.spec.js +121 -0
- package/dist/component-specs.json +187 -0
- package/dist/esm/genesys-chart-webcomponents.js +18 -0
- package/dist/esm/gux-chart-column-beta.entry.js +136 -0
- package/dist/esm/gux-chart-donut-beta.entry.js +225 -0
- package/dist/esm/gux-chart-line-beta.entry.js +131 -0
- package/dist/esm/gux-chart-pie-beta.entry.js +109 -0
- package/dist/esm/gux-chart-scatter-plot-beta.entry.js +139 -0
- package/dist/esm/gux-visualization-beta.entry.js +71949 -0
- package/dist/esm/index-701d93cf.js +1619 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +9 -0
- package/dist/esm/log-error-0fc61f6f.js +18 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/usage-61eee3bd.js +206 -0
- package/dist/genesys-chart-webcomponents/genesys-chart-webcomponents.css +1 -0
- package/dist/genesys-chart-webcomponents/genesys-chart-webcomponents.esm.js +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ar.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.cs.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.da.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.de.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.en.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.es-es.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.es.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fi.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fr-ca.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fr.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.he.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.it.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ja.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ko.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.nl.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.no.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pl.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pt-br.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pt-pt.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ru.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.sv.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.th.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.tr.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.uk.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.zh-cn.json +1 -0
- package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.zh-tw.json +1 -0
- package/dist/genesys-chart-webcomponents/index.esm.js +0 -0
- package/dist/genesys-chart-webcomponents/p-137f5b8f.entry.js +1 -0
- package/dist/genesys-chart-webcomponents/p-3e4b3dbc.js +2 -0
- package/dist/genesys-chart-webcomponents/p-82f0ea01.js +1 -0
- package/dist/genesys-chart-webcomponents/p-97c45977.js +1 -0
- package/dist/genesys-chart-webcomponents/p-b5179379.entry.js +1 -0
- package/dist/genesys-chart-webcomponents/p-b901e9e0.entry.js +11 -0
- package/dist/genesys-chart-webcomponents/p-c3aa8578.entry.js +1 -0
- package/dist/genesys-chart-webcomponents/p-d4a346df.entry.js +1 -0
- package/dist/genesys-chart-webcomponents/p-d9928f8c.entry.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +21 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +11 -0
- package/dist/stencil-wrapper.js +58 -0
- package/dist/types/components/beta/gux-chart-column/gux-chart-column.d.ts +49 -0
- package/dist/types/components/beta/gux-chart-column/gux-chart-column.locale.d.ts +22 -0
- package/dist/types/components/beta/gux-chart-donut/gux-chart-donut.d.ts +34 -0
- package/dist/types/components/beta/gux-chart-line/gux-chart-line.d.ts +48 -0
- package/dist/types/components/beta/gux-chart-line/gux-chart-line.locale.d.ts +22 -0
- package/dist/types/components/beta/gux-chart-pie/gux-chart-pie.d.ts +23 -0
- package/dist/types/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.d.ts +52 -0
- package/dist/types/components/beta/gux-visualization/gux-visualization.d.ts +17 -0
- package/dist/types/components/beta/gux-visualization/gux-visualization.locale.d.ts +22 -0
- package/dist/types/components.d.ts +480 -0
- package/dist/types/i18n/fetchResources.d.ts +11 -0
- package/dist/types/i18n/index.d.ts +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stencil-public-runtime.d.ts +1671 -0
- package/dist/types/stencil-wrapper.d.ts +2 -0
- package/dist/types/test/axeConfig.d.ts +6 -0
- package/dist/types/test/e2eTestUtils.d.ts +9 -0
- package/dist/types/test/jestMatcherUtils.d.ts +8 -0
- package/dist/types/test/specTestUtils.d.ts +2 -0
- package/dist/types/typings.d.ts +4 -0
- package/dist/types/utils/dom/get-closest-element.d.ts +1 -0
- package/dist/types/utils/error/log-error.d.ts +2 -0
- package/dist/types/utils/theme/color-palette.d.ts +1 -0
- package/dist/types/utils/tracking/usage.d.ts +27 -0
- package/package.json +118 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
+
import { h } from "@stencil/core";
|
|
3
|
+
import embed from "vega-embed";
|
|
4
|
+
import { getDesiredLocale } from "../../../i18n";
|
|
5
|
+
import { trackComponent } from "../../../utils/tracking/usage";
|
|
6
|
+
import { timeFormatLocale } from "./gux-visualization.locale";
|
|
7
|
+
export class GuxVisualization {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.defaultVisualizationSpec = {};
|
|
10
|
+
this.defaultEmbedOptions = {
|
|
11
|
+
actions: false,
|
|
12
|
+
renderer: 'svg'
|
|
13
|
+
};
|
|
14
|
+
this.visualizationSpec = undefined;
|
|
15
|
+
this.embedOptions = undefined;
|
|
16
|
+
}
|
|
17
|
+
componentWillLoad() {
|
|
18
|
+
trackComponent(this.root);
|
|
19
|
+
}
|
|
20
|
+
handleChartClick(_name, value) {
|
|
21
|
+
this.chartClicked.emit(value);
|
|
22
|
+
}
|
|
23
|
+
async componentDidRender() {
|
|
24
|
+
const locale = getDesiredLocale(this.root);
|
|
25
|
+
const patchOption = {
|
|
26
|
+
patch: (visSpec) => {
|
|
27
|
+
if (!(visSpec === null || visSpec === void 0 ? void 0 : visSpec.signals)) {
|
|
28
|
+
visSpec.signals = [];
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
31
|
+
visSpec.signals.push({
|
|
32
|
+
name: 'chartClick',
|
|
33
|
+
value: 0,
|
|
34
|
+
on: [{ events: 'rect:mousedown', update: 'datum' }]
|
|
35
|
+
});
|
|
36
|
+
return visSpec;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
await embed(this.chartContainer, Object.assign({}, this.defaultVisualizationSpec, this.visualizationSpec), Object.assign({
|
|
40
|
+
timeFormatLocale: timeFormatLocale[locale]
|
|
41
|
+
}, this.defaultEmbedOptions, this.embedOptions, patchOption)).then(result => {
|
|
42
|
+
result.view.addSignalListener('chartClick', (name, value) => this.handleChartClick(name, value));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
componentDidLoad() {
|
|
46
|
+
this.chartComponentReady.emit();
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
return (h("div", { ref: el => (this.chartContainer = el) }));
|
|
50
|
+
}
|
|
51
|
+
static get is() { return "gux-visualization-beta"; }
|
|
52
|
+
static get encapsulation() { return "shadow"; }
|
|
53
|
+
static get originalStyleUrls() {
|
|
54
|
+
return {
|
|
55
|
+
"$": ["gux-visualization.scss"]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static get styleUrls() {
|
|
59
|
+
return {
|
|
60
|
+
"$": ["gux-visualization.css"]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
static get properties() {
|
|
64
|
+
return {
|
|
65
|
+
"visualizationSpec": {
|
|
66
|
+
"type": "unknown",
|
|
67
|
+
"mutable": false,
|
|
68
|
+
"complexType": {
|
|
69
|
+
"original": "VisualizationSpec",
|
|
70
|
+
"resolved": "GenericConcatSpec<NonNormalizedSpec> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | GenericFacetSpec<UnitSpecWithFrame<Field>, LayerSpec<Field>, Field> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } & DataMixins | GenericHConcatSpec<NonNormalizedSpec> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | GenericUnitSpec<FacetedCompositeEncoding<Field>, AnyMark, TopLevelParameter> & ResolveMixins & GenericCompositionLayout & FrameMixins<ExprRef | SignalRef> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } & DataMixins | GenericVConcatSpec<NonNormalizedSpec> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | LayerRepeatSpec & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | LayerSpec<Field> & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | NonLayerRepeatSpec & TopLevelProperties<ExprRef | SignalRef> & { $schema?: string; config?: Config<ExprRef | SignalRef>; datasets?: Datasets; usermeta?: Dict<unknown>; } | Spec",
|
|
71
|
+
"references": {
|
|
72
|
+
"VisualizationSpec": {
|
|
73
|
+
"location": "import",
|
|
74
|
+
"path": "vega-embed",
|
|
75
|
+
"id": "../../node_modules/vega-embed/build/vega-embed.module.d.ts::VisualizationSpec"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": false,
|
|
80
|
+
"optional": false,
|
|
81
|
+
"docs": {
|
|
82
|
+
"tags": [],
|
|
83
|
+
"text": ""
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"embedOptions": {
|
|
87
|
+
"type": "unknown",
|
|
88
|
+
"mutable": false,
|
|
89
|
+
"complexType": {
|
|
90
|
+
"original": "EmbedOptions",
|
|
91
|
+
"resolved": "EmbedOptions<string, Renderers>",
|
|
92
|
+
"references": {
|
|
93
|
+
"EmbedOptions": {
|
|
94
|
+
"location": "import",
|
|
95
|
+
"path": "vega-embed",
|
|
96
|
+
"id": "../../node_modules/vega-embed/build/vega-embed.module.d.ts::EmbedOptions"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"required": false,
|
|
101
|
+
"optional": false,
|
|
102
|
+
"docs": {
|
|
103
|
+
"tags": [],
|
|
104
|
+
"text": ""
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
static get events() {
|
|
110
|
+
return [{
|
|
111
|
+
"method": "chartComponentReady",
|
|
112
|
+
"name": "chartComponentReady",
|
|
113
|
+
"bubbles": true,
|
|
114
|
+
"cancelable": true,
|
|
115
|
+
"composed": true,
|
|
116
|
+
"docs": {
|
|
117
|
+
"tags": [],
|
|
118
|
+
"text": ""
|
|
119
|
+
},
|
|
120
|
+
"complexType": {
|
|
121
|
+
"original": "any",
|
|
122
|
+
"resolved": "any",
|
|
123
|
+
"references": {}
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
"method": "chartClicked",
|
|
127
|
+
"name": "chartClicked",
|
|
128
|
+
"bubbles": true,
|
|
129
|
+
"cancelable": true,
|
|
130
|
+
"composed": true,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [],
|
|
133
|
+
"text": ""
|
|
134
|
+
},
|
|
135
|
+
"complexType": {
|
|
136
|
+
"original": "any",
|
|
137
|
+
"resolved": "any",
|
|
138
|
+
"references": {}
|
|
139
|
+
}
|
|
140
|
+
}];
|
|
141
|
+
}
|
|
142
|
+
static get elementRef() { return "root"; }
|
|
143
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// https://github.com/d3/d3-time-format/tree/master/locale
|
|
2
|
+
// This is just a POC I would structure the files differently when implementing for production.
|
|
3
|
+
export const timeFormatLocale = {
|
|
4
|
+
en: {
|
|
5
|
+
dateTime: '%x, %X',
|
|
6
|
+
date: '%-m/%-d/%Y',
|
|
7
|
+
time: '%-I:%M:%S %p',
|
|
8
|
+
periods: ['AM', 'PM'],
|
|
9
|
+
days: [
|
|
10
|
+
'Sunday',
|
|
11
|
+
'Monday',
|
|
12
|
+
'Tuesday',
|
|
13
|
+
'Wednesday',
|
|
14
|
+
'Thursday',
|
|
15
|
+
'Friday',
|
|
16
|
+
'Saturday'
|
|
17
|
+
],
|
|
18
|
+
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
19
|
+
months: [
|
|
20
|
+
'January',
|
|
21
|
+
'February',
|
|
22
|
+
'March',
|
|
23
|
+
'April',
|
|
24
|
+
'May',
|
|
25
|
+
'June',
|
|
26
|
+
'July',
|
|
27
|
+
'August',
|
|
28
|
+
'September',
|
|
29
|
+
'October',
|
|
30
|
+
'November',
|
|
31
|
+
'December'
|
|
32
|
+
],
|
|
33
|
+
shortMonths: [
|
|
34
|
+
'Jan',
|
|
35
|
+
'Feb',
|
|
36
|
+
'Mar',
|
|
37
|
+
'Apr',
|
|
38
|
+
'May',
|
|
39
|
+
'Jun',
|
|
40
|
+
'Jul',
|
|
41
|
+
'Aug',
|
|
42
|
+
'Sep',
|
|
43
|
+
'Oct',
|
|
44
|
+
'Nov',
|
|
45
|
+
'Dec'
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
de: {
|
|
49
|
+
dateTime: '%A, der %e. %B %Y, %X',
|
|
50
|
+
date: '%d.%m.%Y',
|
|
51
|
+
time: '%H:%M:%S',
|
|
52
|
+
periods: ['AM', 'PM'],
|
|
53
|
+
days: [
|
|
54
|
+
'Sonntag',
|
|
55
|
+
'Montag',
|
|
56
|
+
'Dienstag',
|
|
57
|
+
'Mittwoch',
|
|
58
|
+
'Donnerstag',
|
|
59
|
+
'Freitag',
|
|
60
|
+
'Samstag'
|
|
61
|
+
],
|
|
62
|
+
shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
|
63
|
+
months: [
|
|
64
|
+
'Januar',
|
|
65
|
+
'Februar',
|
|
66
|
+
'März',
|
|
67
|
+
'April',
|
|
68
|
+
'Mai',
|
|
69
|
+
'Juni',
|
|
70
|
+
'Juli',
|
|
71
|
+
'August',
|
|
72
|
+
'September',
|
|
73
|
+
'Oktober',
|
|
74
|
+
'November',
|
|
75
|
+
'Dezember'
|
|
76
|
+
],
|
|
77
|
+
shortMonths: [
|
|
78
|
+
'Jan',
|
|
79
|
+
'Feb',
|
|
80
|
+
'Mrz',
|
|
81
|
+
'Apr',
|
|
82
|
+
'Mai',
|
|
83
|
+
'Jun',
|
|
84
|
+
'Jul',
|
|
85
|
+
'Aug',
|
|
86
|
+
'Sep',
|
|
87
|
+
'Okt',
|
|
88
|
+
'Nov',
|
|
89
|
+
'Dez'
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { newE2EPage } from "@stencil/core/testing";
|
|
2
|
+
const visualizationSpecLine = {
|
|
3
|
+
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
|
|
4
|
+
data: { url: 'https://vega.github.io/editor/data/seattle-weather.csv' },
|
|
5
|
+
mark: {
|
|
6
|
+
type: 'line',
|
|
7
|
+
interpolate: 'monotone'
|
|
8
|
+
},
|
|
9
|
+
encoding: {
|
|
10
|
+
x: { timeUnit: 'month', field: 'date', bandPosition: 0.5 },
|
|
11
|
+
y: { aggregate: 'mean', field: 'temp_max' }
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
describe('gux-visualization-beta', () => {
|
|
15
|
+
describe('#render', () => {
|
|
16
|
+
[
|
|
17
|
+
{
|
|
18
|
+
description: 'should render default button',
|
|
19
|
+
html: '<gux-visualization-beta lang="en" id="visualization-1"></gux-visualization-beta>'
|
|
20
|
+
}
|
|
21
|
+
].forEach(({ description, html }) => {
|
|
22
|
+
it(description, async () => {
|
|
23
|
+
const page = await newE2EPage({ html });
|
|
24
|
+
const element = (await page.find('gux-visualization-beta'));
|
|
25
|
+
element.visualizationSpec = visualizationSpecLine;
|
|
26
|
+
await page.waitForChanges();
|
|
27
|
+
expect(element.outerHTML).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { newSpecPage } from "../../../../test/specTestUtils";
|
|
2
|
+
import { GuxVisualization } from "../gux-visualization";
|
|
3
|
+
const components = [GuxVisualization];
|
|
4
|
+
const language = 'en';
|
|
5
|
+
const visualizationSpecLine = {
|
|
6
|
+
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
|
|
7
|
+
data: { url: 'https://vega.github.io/editor/data/seattle-weather.csv' },
|
|
8
|
+
mark: {
|
|
9
|
+
type: 'line',
|
|
10
|
+
interpolate: 'monotone'
|
|
11
|
+
},
|
|
12
|
+
encoding: {
|
|
13
|
+
x: { timeUnit: 'month', field: 'date', bandPosition: 0.5 },
|
|
14
|
+
y: { aggregate: 'mean', field: 'temp_max' }
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
describe.skip('gux-visualization-beta', () => {
|
|
18
|
+
describe('#render', () => {
|
|
19
|
+
[
|
|
20
|
+
{
|
|
21
|
+
description: 'should render default button',
|
|
22
|
+
html: '<gux-visualization-beta></gux-visualization-beta>'
|
|
23
|
+
}
|
|
24
|
+
].forEach(({ description, html }) => {
|
|
25
|
+
it(description, async () => {
|
|
26
|
+
const page = await newSpecPage({ components, html, language });
|
|
27
|
+
const element = page.root;
|
|
28
|
+
element.visualizationSpec = visualizationSpecLine;
|
|
29
|
+
await page.waitForChanges();
|
|
30
|
+
expect(page.rootInstance).toBeInstanceOf(GuxVisualization);
|
|
31
|
+
expect(page.root).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getAssetPath } from "@stencil/core";
|
|
2
|
+
const resourceCache = {};
|
|
3
|
+
export const determineFetchUrl = (locale = 'en') => getAssetPath(`i18n/genesys-webcomponents.i18n.${locale}.json`);
|
|
4
|
+
export const fetchResources = async (componentName, locale) => {
|
|
5
|
+
if (!resourceCache[locale]) {
|
|
6
|
+
const url = determineFetchUrl(locale);
|
|
7
|
+
const response = await fetch(url);
|
|
8
|
+
const resources = await response.json();
|
|
9
|
+
resourceCache[locale] = resources;
|
|
10
|
+
}
|
|
11
|
+
return resourceCache[locale][componentName];
|
|
12
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import IntlMessageFormat from "intl-messageformat";
|
|
2
|
+
import { fetchResources } from "./fetchResources";
|
|
3
|
+
// If this import is failing, you should run the i18n script to generate the list of locales
|
|
4
|
+
import locales from "./locales.json";
|
|
5
|
+
import { getClosestElement } from "../utils/dom/get-closest-element";
|
|
6
|
+
const DEFAULT_LOCALE = 'en';
|
|
7
|
+
export async function buildI18nForComponent(component, defaultResources, parentComponent) {
|
|
8
|
+
let resources = defaultResources;
|
|
9
|
+
let locale = 'en';
|
|
10
|
+
if (component !== undefined) {
|
|
11
|
+
locale = getDesiredLocale(component);
|
|
12
|
+
resources = await getComponentI18nResources(component, defaultResources, locale, parentComponent);
|
|
13
|
+
}
|
|
14
|
+
const intlFormats = Object.entries(resources).reduce((map, [key, val]) => {
|
|
15
|
+
map.set(key, new IntlMessageFormat(val, locale));
|
|
16
|
+
return map;
|
|
17
|
+
}, new Map());
|
|
18
|
+
const defaultFormats = Object.entries(defaultResources).reduce((map, [key, val]) => {
|
|
19
|
+
map.set(key, new IntlMessageFormat(val, DEFAULT_LOCALE));
|
|
20
|
+
return map;
|
|
21
|
+
}, new Map());
|
|
22
|
+
return (resourceKey, context) => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
let i18nString = (_a = intlFormats.get(resourceKey)) === null || _a === void 0 ? void 0 : _a.format(context);
|
|
25
|
+
if (!i18nString) {
|
|
26
|
+
i18nString = (_b = defaultFormats.get(resourceKey)) === null || _b === void 0 ? void 0 : _b.format(context);
|
|
27
|
+
console.warn(`No localized string available for "${resourceKey}-${i18nString}" for "${locale}" locale. Falling back to English translation.`);
|
|
28
|
+
}
|
|
29
|
+
return i18nString;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function getComponentI18nResources(component, defaultResources, locale, parentComponent) {
|
|
33
|
+
const componentName = parentComponent ||
|
|
34
|
+
component.tagName.toLocaleLowerCase().replace(/-beta$/, '');
|
|
35
|
+
let resources;
|
|
36
|
+
if (component['i18n-resources']) {
|
|
37
|
+
resources = component['i18n-resources'];
|
|
38
|
+
}
|
|
39
|
+
else if (locale !== DEFAULT_LOCALE) {
|
|
40
|
+
try {
|
|
41
|
+
resources = await fetchResources(componentName, locale);
|
|
42
|
+
}
|
|
43
|
+
catch (_) {
|
|
44
|
+
resources = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!resources) {
|
|
48
|
+
resources = defaultResources;
|
|
49
|
+
}
|
|
50
|
+
return resources;
|
|
51
|
+
}
|
|
52
|
+
export function getDesiredLocale(element) {
|
|
53
|
+
const locale = findLocaleInDom(element);
|
|
54
|
+
const lang = locale.split(/[_-]/)[0];
|
|
55
|
+
if (locales.indexOf(locale) >= 0) {
|
|
56
|
+
return locale;
|
|
57
|
+
}
|
|
58
|
+
else if (locales.indexOf(lang) >= 0) {
|
|
59
|
+
return lang;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return DEFAULT_LOCALE;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function findLocaleInDom(element) {
|
|
66
|
+
const closestElement = getClosestElement('[lang]', element);
|
|
67
|
+
if (closestElement && closestElement.lang) {
|
|
68
|
+
return closestElement.lang.toLowerCase();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return DEFAULT_LOCALE;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { newE2EPage } from "@stencil/core/testing";
|
|
2
|
+
import { axeConfig } from "./axeConfig";
|
|
3
|
+
export async function a11yCheck(page, axeExclusions = [], axeScanContext = '') {
|
|
4
|
+
const axeScanDetails = {
|
|
5
|
+
axeExclusions,
|
|
6
|
+
axeScanContext
|
|
7
|
+
};
|
|
8
|
+
const axeResults = await page.evaluate(`window.axe.run('body > *', ${JSON.stringify(axeConfig)})`);
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
expect(axeResults.violations).toHaveNoViolations(axeScanDetails);
|
|
11
|
+
}
|
|
12
|
+
export async function newSparkE2EPage({ html }, lang = 'en') {
|
|
13
|
+
const page = await newE2EPage();
|
|
14
|
+
await page.setContent(`<div lang=${lang}>${html}</div>`);
|
|
15
|
+
await page.addScriptTag({
|
|
16
|
+
path: '../../node_modules/axe-core/axe.min.js'
|
|
17
|
+
});
|
|
18
|
+
await page.waitForChanges();
|
|
19
|
+
return page;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-env jest, node */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
7
|
+
/* eslint-disable @typescript-eslint/typedef */
|
|
8
|
+
|
|
9
|
+
global.beforeEach(() => {
|
|
10
|
+
expect.extend({
|
|
11
|
+
toHaveNoViolations(axeViolations, axeScanDetails) {
|
|
12
|
+
return toHaveNoViolations(axeViolations, axeScanDetails);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
function toHaveNoViolations(axeViolations, axeScanDetails) {
|
|
18
|
+
let violations = [];
|
|
19
|
+
|
|
20
|
+
axeViolations.forEach(violation => {
|
|
21
|
+
let violationTargets = [];
|
|
22
|
+
violation.nodes.forEach(violationInstance => {
|
|
23
|
+
let excludedElement = false;
|
|
24
|
+
axeScanDetails.axeExclusions.forEach(exclusion => {
|
|
25
|
+
if (
|
|
26
|
+
exclusion.issueId === violation.id &&
|
|
27
|
+
(!exclusion.target ||
|
|
28
|
+
exclusion.target === violationInstance.target[0].toString())
|
|
29
|
+
) {
|
|
30
|
+
excludedElement = true;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (excludedElement === false) {
|
|
34
|
+
violationTargets.push(violationInstance);
|
|
35
|
+
violation.violationInstance = violationTargets;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (violation.violationInstance) {
|
|
39
|
+
violations.push(violation);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const violationMessage = createViolationMessage(violations, axeScanDetails);
|
|
43
|
+
return returnPassOrFail(violations, violationMessage);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function createViolationMessage(violations, axeScanDetails) {
|
|
47
|
+
let violationMessage = '';
|
|
48
|
+
let elementMessage = '';
|
|
49
|
+
let axeContextMessage = axeScanDetails.axeScanContext
|
|
50
|
+
? `Axe scan context:\n${axeScanDetails.axeScanContext}\n`
|
|
51
|
+
: '';
|
|
52
|
+
violations.forEach(violation => {
|
|
53
|
+
violation.violationInstance.forEach(element => {
|
|
54
|
+
elementMessage += `\n${element.target}\n${element.failureSummary}`;
|
|
55
|
+
});
|
|
56
|
+
violationMessage += `${axeContextMessage}Violation id:\n${violation.id}\nViolation description:\n${violation.description}
|
|
57
|
+
\nAffected Elements (${violation.violationInstance.length}):${elementMessage}\n
|
|
58
|
+
`;
|
|
59
|
+
});
|
|
60
|
+
return violationMessage;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function returnPassOrFail(violations, violationMessage) {
|
|
64
|
+
if (violations.length === 0) {
|
|
65
|
+
return {
|
|
66
|
+
message: () => `No violations found`,
|
|
67
|
+
pass: true
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
return {
|
|
71
|
+
message: () => violationMessage,
|
|
72
|
+
pass: false
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { newSpecPage as stencilSpecPage } from "@stencil/core/testing";
|
|
2
|
+
import MutationObserver from "mutation-observer";
|
|
3
|
+
import ResizeObserver from "resize-observer-polyfill";
|
|
4
|
+
export async function newSpecPage(opts) {
|
|
5
|
+
global.MutationObserver = MutationObserver;
|
|
6
|
+
global.ResizeObserver = ResizeObserver;
|
|
7
|
+
global.InputEvent = Event;
|
|
8
|
+
const page = await stencilSpecPage(opts);
|
|
9
|
+
return page;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getClosestElement(selector, baseElement = this) {
|
|
2
|
+
function closest(element) {
|
|
3
|
+
if (!element || element === document || element === window) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
if (element.assignedSlot) {
|
|
7
|
+
element = element.assignedSlot;
|
|
8
|
+
}
|
|
9
|
+
const found = element.closest(selector);
|
|
10
|
+
return found
|
|
11
|
+
? found
|
|
12
|
+
: closest(element.getRootNode().host);
|
|
13
|
+
}
|
|
14
|
+
return closest(baseElement);
|
|
15
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import packageInfo from "../../../package.json";
|
|
2
|
+
// The number of actions to process every interval
|
|
3
|
+
const ACTION_BATCH_SIZE = 20;
|
|
4
|
+
const NR_LIMIT_INTERVAL = 30000; // 30s
|
|
5
|
+
/**
|
|
6
|
+
* A queue of events that should be tracked by NewRelic.
|
|
7
|
+
* We initialize it with the library version to make sure that's always reported.
|
|
8
|
+
*/
|
|
9
|
+
const actionQueue = [
|
|
10
|
+
getVersionEvent(packageInfo.version)
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Process the next batch items in the queue, set a timeout to recur.
|
|
14
|
+
* We use a recurring timeout instead of an interval because it guarantees
|
|
15
|
+
* a minimum of NR_LMIT_INTERVAL between batches, even if the browser is
|
|
16
|
+
* held up by processing elsewhere.
|
|
17
|
+
*/
|
|
18
|
+
function processActionQueue() {
|
|
19
|
+
const newrelic = window.newrelic;
|
|
20
|
+
if (!newrelic) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (let i = 0; i < ACTION_BATCH_SIZE; i++) {
|
|
24
|
+
if (actionQueue.length == 0) {
|
|
25
|
+
setTimeout(processActionQueue, NR_LIMIT_INTERVAL);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const action = actionQueue.shift();
|
|
29
|
+
newrelic.addPageAction(action.name, Object.assign(Object.assign({}, action.metadata), { queueDepth: actionQueue.length }));
|
|
30
|
+
}
|
|
31
|
+
setTimeout(processActionQueue, NR_LIMIT_INTERVAL);
|
|
32
|
+
}
|
|
33
|
+
let trackingStarted = false;
|
|
34
|
+
/**
|
|
35
|
+
* Begin action processing loop if it hasn't started.
|
|
36
|
+
*/
|
|
37
|
+
function ensureTracking() {
|
|
38
|
+
if (!trackingStarted) {
|
|
39
|
+
trackingStarted = true;
|
|
40
|
+
processActionQueue();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Submits a component for tracking by NewRelic.
|
|
45
|
+
*/
|
|
46
|
+
export function trackComponent(element, metadata) {
|
|
47
|
+
if (!window.newrelic) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
ensureTracking();
|
|
51
|
+
// Ignore components in the shadow DOM of another component
|
|
52
|
+
// e.g. Only track components used directly by the app
|
|
53
|
+
if (!document.contains(element)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
actionQueue.push({
|
|
57
|
+
name: 'spark-component',
|
|
58
|
+
metadata: Object.assign(Object.assign({}, metadata), { component: element.tagName.toLowerCase(), version: packageInfo.version })
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function trackAction(element, action, actionMetadata) {
|
|
62
|
+
if (!window.newrelic) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
ensureTracking();
|
|
66
|
+
actionQueue.push({
|
|
67
|
+
name: 'spark-action',
|
|
68
|
+
metadata: Object.assign(Object.assign({}, actionMetadata), { action, component: element.tagName.toLowerCase() })
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export function getVersionEvent(packageInfoVersion) {
|
|
72
|
+
const [major, minor, ...patch] = packageInfoVersion.split('.');
|
|
73
|
+
return {
|
|
74
|
+
name: 'spark-library',
|
|
75
|
+
metadata: {
|
|
76
|
+
fullVersion: `${major}.${minor}.${patch.join('.')}`,
|
|
77
|
+
majorVersion: major,
|
|
78
|
+
minorVersion: `${major}.${minor}`
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|