@semcore/d3-chart 2.2.6 → 2.3.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/CHANGELOG.md +12 -0
- package/lib/cjs/Area.js +16 -9
- package/lib/cjs/Area.js.map +1 -1
- package/lib/cjs/Axis.js +56 -17
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +20 -9
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/Bubble.js +20 -11
- package/lib/cjs/Bubble.js.map +1 -1
- package/lib/cjs/ClipPath.js +1 -0
- package/lib/cjs/ClipPath.js.map +1 -1
- package/lib/cjs/Donut.js +22 -12
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +10 -9
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/GroupBar.js +12 -8
- package/lib/cjs/GroupBar.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +20 -9
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +8 -4
- package/lib/cjs/Hover.js.map +1 -1
- package/lib/cjs/Line.js +15 -9
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +46 -8
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/RadialTree.js +25 -13
- package/lib/cjs/RadialTree.js.map +1 -1
- package/lib/cjs/ReferenceLine.js +10 -10
- package/lib/cjs/ScatterPlot.js +17 -8
- package/lib/cjs/ScatterPlot.js.map +1 -1
- package/lib/cjs/StackBar.js +12 -8
- package/lib/cjs/StackBar.js.map +1 -1
- package/lib/cjs/StackedArea.js +8 -7
- package/lib/cjs/StackedArea.js.map +1 -1
- package/lib/cjs/Tooltip.js +8 -8
- package/lib/cjs/Venn.js +25 -9
- package/lib/cjs/Venn.js.map +1 -1
- package/lib/cjs/a11y/PlotA11yModule.js +197 -0
- package/lib/cjs/a11y/PlotA11yModule.js.map +1 -0
- package/lib/cjs/a11y/PlotA11yView.js +287 -0
- package/lib/cjs/a11y/PlotA11yView.js.map +1 -0
- package/lib/cjs/a11y/bezier.js +44 -0
- package/lib/cjs/a11y/bezier.js.map +1 -0
- package/lib/cjs/a11y/focus.js +57 -0
- package/lib/cjs/a11y/focus.js.map +1 -0
- package/lib/cjs/a11y/hints.js +141 -0
- package/lib/cjs/a11y/hints.js.map +1 -0
- package/lib/cjs/a11y/insights.js +785 -0
- package/lib/cjs/a11y/insights.js.map +1 -0
- package/lib/cjs/a11y/intl.js +31 -0
- package/lib/cjs/a11y/intl.js.map +1 -0
- package/lib/cjs/a11y/locale.js +52 -0
- package/lib/cjs/a11y/locale.js.map +1 -0
- package/lib/cjs/a11y/serialize.js +439 -0
- package/lib/cjs/a11y/serialize.js.map +1 -0
- package/lib/cjs/a11y/summarize.js +21 -0
- package/lib/cjs/a11y/summarize.js.map +1 -0
- package/lib/cjs/a11y/translations/module/de.json +5 -0
- package/lib/cjs/a11y/translations/module/en.json +5 -0
- package/lib/cjs/a11y/translations/module/es.json +5 -0
- package/lib/cjs/a11y/translations/module/fr.json +5 -0
- package/lib/cjs/a11y/translations/module/it.json +5 -0
- package/lib/cjs/a11y/translations/module/ja.json +5 -0
- package/lib/cjs/a11y/translations/module/ko.json +5 -0
- package/lib/cjs/a11y/translations/module/pt.json +5 -0
- package/lib/cjs/a11y/translations/module/tr.json +5 -0
- package/lib/cjs/a11y/translations/module/translations.js +46 -0
- package/lib/cjs/a11y/translations/module/translations.js.map +1 -0
- package/lib/cjs/a11y/translations/module/vi.json +5 -0
- package/lib/cjs/a11y/translations/module/zh.json +5 -0
- package/lib/cjs/a11y/translations/view/de.json +42 -0
- package/lib/cjs/a11y/translations/view/en.csv +41 -0
- package/lib/cjs/a11y/translations/view/en.json +42 -0
- package/lib/cjs/a11y/translations/view/es.json +42 -0
- package/lib/cjs/a11y/translations/view/fr.json +42 -0
- package/lib/cjs/a11y/translations/view/it.json +42 -0
- package/lib/cjs/a11y/translations/view/ja.json +42 -0
- package/lib/cjs/a11y/translations/view/ko.json +42 -0
- package/lib/cjs/a11y/translations/view/pt.json +42 -0
- package/lib/cjs/a11y/translations/view/tr.json +42 -0
- package/lib/cjs/a11y/translations/view/translations.js +46 -0
- package/lib/cjs/a11y/translations/view/translations.js.map +1 -0
- package/lib/cjs/a11y/translations/view/vi.json +42 -0
- package/lib/cjs/a11y/translations/view/zh.json +42 -0
- package/lib/cjs/createElement.js +3 -1
- package/lib/cjs/createElement.js.map +1 -1
- package/lib/cjs/style/plot.shadow.css +10 -0
- package/lib/cjs/style/plotA11yModule.shadow.css +13 -0
- package/lib/cjs/style/plotA11yView.shadow.css +39 -0
- package/lib/cjs/types/Plot.d.ts +75 -0
- package/lib/cjs/utils.js +9 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +16 -9
- package/lib/es6/Area.js.map +1 -1
- package/lib/es6/Axis.js +56 -17
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +20 -9
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/Bubble.js +20 -11
- package/lib/es6/Bubble.js.map +1 -1
- package/lib/es6/ClipPath.js +1 -0
- package/lib/es6/ClipPath.js.map +1 -1
- package/lib/es6/Donut.js +22 -12
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +10 -9
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/GroupBar.js +12 -8
- package/lib/es6/GroupBar.js.map +1 -1
- package/lib/es6/HorizontalBar.js +20 -9
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +8 -4
- package/lib/es6/Hover.js.map +1 -1
- package/lib/es6/Line.js +15 -9
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +48 -9
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/RadialTree.js +25 -13
- package/lib/es6/RadialTree.js.map +1 -1
- package/lib/es6/ReferenceLine.js +10 -10
- package/lib/es6/ScatterPlot.js +17 -8
- package/lib/es6/ScatterPlot.js.map +1 -1
- package/lib/es6/StackBar.js +12 -8
- package/lib/es6/StackBar.js.map +1 -1
- package/lib/es6/StackedArea.js +8 -7
- package/lib/es6/StackedArea.js.map +1 -1
- package/lib/es6/Tooltip.js +8 -8
- package/lib/es6/Venn.js +25 -9
- package/lib/es6/Venn.js.map +1 -1
- package/lib/es6/a11y/PlotA11yModule.js +168 -0
- package/lib/es6/a11y/PlotA11yModule.js.map +1 -0
- package/lib/es6/a11y/PlotA11yView.js +255 -0
- package/lib/es6/a11y/PlotA11yView.js.map +1 -0
- package/lib/es6/a11y/bezier.js +35 -0
- package/lib/es6/a11y/bezier.js.map +1 -0
- package/lib/es6/a11y/focus.js +48 -0
- package/lib/es6/a11y/focus.js.map +1 -0
- package/lib/es6/a11y/hints.js +123 -0
- package/lib/es6/a11y/hints.js.map +1 -0
- package/lib/es6/a11y/insights.js +779 -0
- package/lib/es6/a11y/insights.js.map +1 -0
- package/lib/es6/a11y/intl.js +18 -0
- package/lib/es6/a11y/intl.js.map +1 -0
- package/lib/es6/a11y/locale.js +40 -0
- package/lib/es6/a11y/locale.js.map +1 -0
- package/lib/es6/a11y/serialize.js +423 -0
- package/lib/es6/a11y/serialize.js.map +1 -0
- package/lib/es6/a11y/summarize.js +10 -0
- package/lib/es6/a11y/summarize.js.map +1 -0
- package/lib/es6/a11y/translations/module/de.json +5 -0
- package/lib/es6/a11y/translations/module/en.json +5 -0
- package/lib/es6/a11y/translations/module/es.json +5 -0
- package/lib/es6/a11y/translations/module/fr.json +5 -0
- package/lib/es6/a11y/translations/module/it.json +5 -0
- package/lib/es6/a11y/translations/module/ja.json +5 -0
- package/lib/es6/a11y/translations/module/ko.json +5 -0
- package/lib/es6/a11y/translations/module/pt.json +5 -0
- package/lib/es6/a11y/translations/module/tr.json +5 -0
- package/lib/es6/a11y/translations/module/translations.js +25 -0
- package/lib/es6/a11y/translations/module/translations.js.map +1 -0
- package/lib/es6/a11y/translations/module/vi.json +5 -0
- package/lib/es6/a11y/translations/module/zh.json +5 -0
- package/lib/es6/a11y/translations/view/de.json +42 -0
- package/lib/es6/a11y/translations/view/en.csv +41 -0
- package/lib/es6/a11y/translations/view/en.json +42 -0
- package/lib/es6/a11y/translations/view/es.json +42 -0
- package/lib/es6/a11y/translations/view/fr.json +42 -0
- package/lib/es6/a11y/translations/view/it.json +42 -0
- package/lib/es6/a11y/translations/view/ja.json +42 -0
- package/lib/es6/a11y/translations/view/ko.json +42 -0
- package/lib/es6/a11y/translations/view/pt.json +42 -0
- package/lib/es6/a11y/translations/view/tr.json +42 -0
- package/lib/es6/a11y/translations/view/translations.js +25 -0
- package/lib/es6/a11y/translations/view/translations.js.map +1 -0
- package/lib/es6/a11y/translations/view/vi.json +42 -0
- package/lib/es6/a11y/translations/view/zh.json +42 -0
- package/lib/es6/createElement.js +3 -1
- package/lib/es6/createElement.js.map +1 -1
- package/lib/es6/style/plot.shadow.css +10 -0
- package/lib/es6/style/plotA11yModule.shadow.css +13 -0
- package/lib/es6/style/plotA11yView.shadow.css +39 -0
- package/lib/es6/types/Plot.d.ts +75 -0
- package/lib/es6/utils.js +5 -0
- package/lib/es6/utils.js.map +1 -1
- package/lib/types/Plot.d.ts +75 -0
- package/lib/types/a11y/PlotA11yModule.d.ts +12 -0
- package/lib/types/a11y/PlotA11yView.d.ts +3 -0
- package/lib/types/a11y/bezier.d.ts +8 -0
- package/lib/types/a11y/focus.d.ts +5 -0
- package/lib/types/a11y/hints.d.ts +78 -0
- package/lib/types/a11y/insights.d.ts +54 -0
- package/lib/types/a11y/intl.d.ts +8 -0
- package/lib/types/a11y/locale.d.ts +3 -0
- package/lib/types/a11y/serialize.d.ts +16 -0
- package/lib/types/a11y/summarize.d.ts +2 -0
- package/lib/types/a11y/translations/module/translations.d.ts +5 -0
- package/lib/types/a11y/translations/view/translations.d.ts +5 -0
- package/lib/types/utils.d.ts +5 -4
- package/package.json +2 -1
package/lib/cjs/Venn.js
CHANGED
|
@@ -48,16 +48,16 @@ var style = (
|
|
|
48
48
|
/*__reshadow_css_start__*/
|
|
49
49
|
_core.sstyled.insert(
|
|
50
50
|
/*__inner_css_start__*/
|
|
51
|
-
".
|
|
51
|
+
".___SCircle_4ydmq_gg_{fill:#59ddaa;stroke:#fff;stroke-width:2px;fill-opacity:.5;transition-property:cx,cy;transition-duration:var(--duration_4ydmq);transition-timing-function:ease-in-out}.___SCircle_4ydmq_gg_:hover{fill-opacity:.7}.___SCircle_4ydmq_gg_.__color_4ydmq_gg_{fill:var(--color_4ydmq)}.___SIntersection_4ydmq_gg_{stroke:#fff;stroke-width:2px;fill-opacity:0}.___SIntersection_4ydmq_gg_:hover{fill-opacity:.1}"
|
|
52
52
|
/*__inner_css_end__*/
|
|
53
|
-
, "
|
|
53
|
+
, "4ydmq_gg_")
|
|
54
54
|
/*__reshadow_css_end__*/
|
|
55
55
|
, {
|
|
56
|
-
"__SCircle": "
|
|
57
|
-
"--duration": "--
|
|
58
|
-
"_color": "
|
|
59
|
-
"--color": "--
|
|
60
|
-
"__SIntersection": "
|
|
56
|
+
"__SCircle": "___SCircle_4ydmq_gg_",
|
|
57
|
+
"--duration": "--duration_4ydmq",
|
|
58
|
+
"_color": "__color_4ydmq_gg_",
|
|
59
|
+
"--color": "--color_4ydmq",
|
|
60
|
+
"__SIntersection": "___SIntersection_4ydmq_gg_"
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
var VennRoot = /*#__PURE__*/function (_Component) {
|
|
@@ -88,6 +88,7 @@ var VennRoot = /*#__PURE__*/function (_Component) {
|
|
|
88
88
|
});
|
|
89
89
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderElement", /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
90
90
|
return /*#__PURE__*/_react["default"].createElement(_animation.FadeInOut, (0, _extends2["default"])({
|
|
91
|
+
"aria-hidden": true,
|
|
91
92
|
ref: ref,
|
|
92
93
|
tag: "g",
|
|
93
94
|
visible: true
|
|
@@ -143,6 +144,7 @@ var VennRoot = /*#__PURE__*/function (_Component) {
|
|
|
143
144
|
return {
|
|
144
145
|
duration: this.asProps.duration,
|
|
145
146
|
data: this.vennData[props.dataKey],
|
|
147
|
+
originalData: this.asProps.data[props.dataKey],
|
|
146
148
|
onMouseMove: this.bindHandlerTooltip(true, props),
|
|
147
149
|
onMouseLeave: this.bindHandlerTooltip(false, props)
|
|
148
150
|
};
|
|
@@ -158,6 +160,7 @@ var VennRoot = /*#__PURE__*/function (_Component) {
|
|
|
158
160
|
data: Object.values(this.vennData).filter(function (d) {
|
|
159
161
|
return dataKeys.includes(d.setid);
|
|
160
162
|
}),
|
|
163
|
+
originalData: this.asProps.data[props.dataKey],
|
|
161
164
|
onMouseMove: this.bindHandlerTooltip(true, props),
|
|
162
165
|
onMouseLeave: this.bindHandlerTooltip(false, props)
|
|
163
166
|
};
|
|
@@ -166,8 +169,10 @@ var VennRoot = /*#__PURE__*/function (_Component) {
|
|
|
166
169
|
key: "render",
|
|
167
170
|
value: function render() {
|
|
168
171
|
var Element = this.Element;
|
|
172
|
+
this.asProps.dataHintsHandler.establishDataType('values-set');
|
|
169
173
|
this.vennData = this.getVennData();
|
|
170
174
|
return /*#__PURE__*/_react["default"].createElement(Element, {
|
|
175
|
+
"aria-hidden": true,
|
|
171
176
|
render: this.renderElement,
|
|
172
177
|
childrenPosition: "inside",
|
|
173
178
|
vennData: this.vennData
|
|
@@ -194,8 +199,13 @@ function Circle(_ref6) {
|
|
|
194
199
|
styles = _ref6.styles,
|
|
195
200
|
color = _ref6.color,
|
|
196
201
|
data = _ref6.data,
|
|
197
|
-
duration = _ref6.duration
|
|
202
|
+
duration = _ref6.duration,
|
|
203
|
+
name = _ref6.name,
|
|
204
|
+
dataKey = _ref6.dataKey,
|
|
205
|
+
dataHintsHandler = _ref6.dataHintsHandler;
|
|
206
|
+
dataHintsHandler.describeValueEntity(dataKey, name);
|
|
198
207
|
return _ref = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SCircle, _ref.cn("SCircle", {
|
|
208
|
+
"aria-hidden": true,
|
|
199
209
|
"render": "circle",
|
|
200
210
|
"color": color,
|
|
201
211
|
"cx": data.x,
|
|
@@ -210,10 +220,15 @@ function Intersection(props) {
|
|
|
210
220
|
|
|
211
221
|
var SIntersection = props.Element,
|
|
212
222
|
styles = props.styles,
|
|
213
|
-
data = props.data
|
|
223
|
+
data = props.data,
|
|
224
|
+
name = props.name,
|
|
225
|
+
dataKey = props.dataKey,
|
|
226
|
+
dataHintsHandler = props.dataHintsHandler;
|
|
227
|
+
dataHintsHandler.describeValueEntity(dataKey, name);
|
|
214
228
|
|
|
215
229
|
var renderIntersection = _react["default"].useCallback( /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
216
230
|
return /*#__PURE__*/_react["default"].createElement(_animation.FadeInOut, (0, _extends2["default"])({
|
|
231
|
+
"aria-hidden": true,
|
|
217
232
|
ref: ref,
|
|
218
233
|
tag: "path",
|
|
219
234
|
visible: true
|
|
@@ -221,6 +236,7 @@ function Intersection(props) {
|
|
|
221
236
|
}), [props]);
|
|
222
237
|
|
|
223
238
|
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SIntersection, _ref2.cn("SIntersection", {
|
|
239
|
+
"aria-hidden": true,
|
|
224
240
|
"render": renderIntersection,
|
|
225
241
|
"d": (0, _venn.intersectionAreaPath)(data)
|
|
226
242
|
}));
|
package/lib/cjs/Venn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Venn.js","names":["VennRoot","canUseDOM","document","createElement","visible","props","x","clientX","y","clientY","eventEmitter","asProps","virtualElement","getBoundingClientRect","generateGetBoundingClientRect","CONSTANT","VIRTUAL_ELEMENT","emit","React","forwardRef","ref","width","height","top","right","bottom","left","data","orientation","orientationOrder","size","vennData","Object","entries","map","dataKey","sets","split","scaleSolution","normalizeSolution","venn","duration","onMouseMove","bindHandlerTooltip","onMouseLeave","dataKeys","delay","values","filter","d","includes","setid","Element","getVennData","renderElement","Component","style","Math","PI","c1","c2","radius","Circle","SCircle","styles","color","sstyled","Intersection","SIntersection","renderIntersection","useCallback","intersectionAreaPath","Venn"],"sources":["../../src/Venn.jsx"],"sourcesContent":["import React from 'react';\nimport { venn, normalizeSolution, scaleSolution, intersectionAreaPath } from '@upsetjs/venn.js';\nimport { Component, sstyled } from '@semcore/core';\nimport canUseDOM from '@semcore/utils/lib/canUseDOM';\nimport { FadeInOut } from '@semcore/animation';\n\nimport createElement from './createElement';\nimport { CONSTANT } from './utils';\n\nimport style from './style/venn.shadow.css';\n\nclass VennRoot extends Component {\n static displayName = 'Venn';\n static style = style;\n\n static defaultProps = {\n orientation: Math.PI / 2,\n orientationOrder: (c1, c2) => c2.radius - c1.radius,\n duration: 500,\n };\n\n virtualElement = canUseDOM() ? document.createElement('div') : {};\n\n generateGetBoundingClientRect(x = 0, y = 0) {\n return () => ({ width: 0, height: 0, top: y, right: x, bottom: y, left: x });\n }\n\n bindHandlerTooltip =\n (visible, props) =>\n ({ clientX: x, clientY: y }) => {\n const { eventEmitter } = this.asProps;\n this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);\n this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;\n eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);\n };\n\n getVennData() {\n const { data, orientation, orientationOrder, size } = this.asProps;\n const [width, height] = size;\n const vennData = Object.entries(data).map(([dataKey, size]) => ({\n sets: dataKey.split('/'),\n size,\n }));\n return scaleSolution(\n normalizeSolution(venn(vennData), orientation, orientationOrder),\n width,\n height,\n 10,\n );\n }\n\n getCircleProps(props) {\n return {\n duration: this.asProps.duration,\n data: this.vennData[props.dataKey],\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n getIntersectionProps(props) {\n const { duration } = this.asProps;\n const dataKeys = props.dataKey.split('/');\n return {\n duration,\n delay: duration,\n data: Object.values(this.vennData).filter((d) => dataKeys.includes(d.setid)),\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n renderElement = React.forwardRef((props, ref) => {\n return <FadeInOut ref={ref} tag=\"g\" visible {...props} />;\n });\n\n render() {\n const Element = this.Element;\n this.vennData = this.getVennData();\n return (\n <Element
|
|
1
|
+
{"version":3,"file":"Venn.js","names":["VennRoot","canUseDOM","document","createElement","visible","props","x","clientX","y","clientY","eventEmitter","asProps","virtualElement","getBoundingClientRect","generateGetBoundingClientRect","CONSTANT","VIRTUAL_ELEMENT","emit","React","forwardRef","ref","width","height","top","right","bottom","left","data","orientation","orientationOrder","size","vennData","Object","entries","map","dataKey","sets","split","scaleSolution","normalizeSolution","venn","duration","originalData","onMouseMove","bindHandlerTooltip","onMouseLeave","dataKeys","delay","values","filter","d","includes","setid","Element","dataHintsHandler","establishDataType","getVennData","renderElement","Component","style","Math","PI","c1","c2","radius","Circle","SCircle","styles","color","name","describeValueEntity","sstyled","Intersection","SIntersection","renderIntersection","useCallback","intersectionAreaPath","Venn"],"sources":["../../src/Venn.jsx"],"sourcesContent":["import React from 'react';\nimport { venn, normalizeSolution, scaleSolution, intersectionAreaPath } from '@upsetjs/venn.js';\nimport { Component, sstyled } from '@semcore/core';\nimport canUseDOM from '@semcore/utils/lib/canUseDOM';\nimport { FadeInOut } from '@semcore/animation';\n\nimport createElement from './createElement';\nimport { CONSTANT } from './utils';\n\nimport style from './style/venn.shadow.css';\n\nclass VennRoot extends Component {\n static displayName = 'Venn';\n static style = style;\n\n static defaultProps = {\n orientation: Math.PI / 2,\n orientationOrder: (c1, c2) => c2.radius - c1.radius,\n duration: 500,\n };\n\n virtualElement = canUseDOM() ? document.createElement('div') : {};\n\n generateGetBoundingClientRect(x = 0, y = 0) {\n return () => ({ width: 0, height: 0, top: y, right: x, bottom: y, left: x });\n }\n\n bindHandlerTooltip =\n (visible, props) =>\n ({ clientX: x, clientY: y }) => {\n const { eventEmitter } = this.asProps;\n this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);\n this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;\n eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);\n };\n\n getVennData() {\n const { data, orientation, orientationOrder, size } = this.asProps;\n const [width, height] = size;\n const vennData = Object.entries(data).map(([dataKey, size]) => ({\n sets: dataKey.split('/'),\n size,\n }));\n return scaleSolution(\n normalizeSolution(venn(vennData), orientation, orientationOrder),\n width,\n height,\n 10,\n );\n }\n\n getCircleProps(props) {\n return {\n duration: this.asProps.duration,\n data: this.vennData[props.dataKey],\n originalData: this.asProps.data[props.dataKey],\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n getIntersectionProps(props) {\n const { duration } = this.asProps;\n const dataKeys = props.dataKey.split('/');\n return {\n duration,\n delay: duration,\n data: Object.values(this.vennData).filter((d) => dataKeys.includes(d.setid)),\n originalData: this.asProps.data[props.dataKey],\n onMouseMove: this.bindHandlerTooltip(true, props),\n onMouseLeave: this.bindHandlerTooltip(false, props),\n };\n }\n\n renderElement = React.forwardRef((props, ref) => {\n return <FadeInOut aria-hidden ref={ref} tag=\"g\" visible {...props} />;\n });\n\n render() {\n const Element = this.Element;\n this.asProps.dataHintsHandler.establishDataType('values-set');\n this.vennData = this.getVennData();\n return (\n <Element\n aria-hidden\n render={this.renderElement}\n childrenPosition=\"inside\"\n vennData={this.vennData}\n />\n );\n }\n}\n\nfunction Circle({\n Element: SCircle,\n styles,\n color,\n data,\n duration,\n name,\n dataKey,\n dataHintsHandler,\n}) {\n dataHintsHandler.describeValueEntity(dataKey, name);\n\n return sstyled(styles)(\n <SCircle\n aria-hidden\n render=\"circle\"\n color={color}\n cx={data.x}\n cy={data.y}\n r={data.radius}\n use:duration={`${duration}ms`}\n />,\n );\n}\n\nfunction Intersection(props) {\n const { Element: SIntersection, styles, data, name, dataKey, dataHintsHandler } = props;\n dataHintsHandler.describeValueEntity(dataKey, name);\n\n const renderIntersection = React.useCallback(\n React.forwardRef((props, ref) => {\n return <FadeInOut aria-hidden ref={ref} tag=\"path\" visible {...props} />;\n }),\n [props],\n );\n return sstyled(styles)(\n <SIntersection aria-hidden render={renderIntersection} d={intersectionAreaPath(data)} />,\n );\n}\n\nconst Venn = createElement(VennRoot, { Circle, Intersection });\n\nexport default Venn;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AAFA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;IAIMA,Q;;;;;;;;;;;;;;;uGAUa,IAAAC,qBAAA,MAAcC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAd,GAA8C,E;2GAO7D,UAACC,OAAD,EAAUC,KAAV;MAAA,OACA,iBAAgC;QAAA,IAApBC,CAAoB,SAA7BC,OAA6B;QAAA,IAARC,CAAQ,SAAjBC,OAAiB;QAC9B,IAAQC,YAAR,GAAyB,MAAKC,OAA9B,CAAQD,YAAR;QACA,MAAKE,cAAL,CAAoBC,qBAApB,GAA4C,MAAKC,6BAAL,CAAmCR,CAAnC,EAAsCE,CAAtC,CAA5C;QACA,MAAKI,cAAL,CAAoBG,eAAA,CAASC,eAA7B,IAAgD,IAAhD;QACAN,YAAY,CAACO,IAAb,CAAkB,kBAAlB,EAAsCb,OAAtC,EAA+CC,KAA/C,EAAsD,MAAKO,cAA3D;MACD,CAND;IAAA,C;mHA8CcM,iBAAA,CAAMC,UAAN,CAAiB,UAACd,KAAD,EAAQe,GAAR,EAAgB;MAC/C,oBAAO,gCAAC,oBAAD;QAAW,mBAAX;QAAuB,GAAG,EAAEA,GAA5B;QAAiC,GAAG,EAAC,GAArC;QAAyC,OAAO;MAAhD,GAAqDf,KAArD,EAAP;IACD,CAFe,C;;;;;;WAnDhB,yCAA4C;MAAA,IAAdC,CAAc,uEAAV,CAAU;MAAA,IAAPE,CAAO,uEAAH,CAAG;MAC1C,OAAO;QAAA,O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AC/B,oBAAO,gCAAC,oBAAD;MAAW,mBAAX;MAAuB,GAAG,EAAEA,GAA5B;MAAiC,GAAG,EAAC,MAArC;MAA4C,OAAO;IAAnD,GAAwDf,KAAxD,EAAP;EACD,CAFD,CADyB,EAIzB,CAACA,KAAD,CAJyB,CAA3B;;EAMA,eAAO,IAAAkE,aAAA,EAAQJ,MAAR,CAAP,eACE,gCAAC,aAAD;IAAA;IAAA,UAAmCO,kBAAnC;IAAA,KAA0D,IAAAE,0BAAA,EAAqBjD,IAArB;EAA1D,GADF;AAGD;;AAED,IAAMkD,IAAI,GAAG,IAAA1E,yBAAA,EAAcH,QAAd,EAAwB;EAAEiE,MAAM,EAANA,MAAF;EAAUO,YAAY,EAAZA;AAAV,CAAxB,CAAb;eAEeK,I"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.PlotA11yModule = void 0;
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
16
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
+
|
|
18
|
+
var _core = require("@semcore/core");
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireDefault(require("react"));
|
|
21
|
+
|
|
22
|
+
var _locale = require("./locale");
|
|
23
|
+
|
|
24
|
+
var _translations = require("./translations/module/translations");
|
|
25
|
+
|
|
26
|
+
var _WithI18n = require("@semcore/utils/lib/enhances/WithI18n");
|
|
27
|
+
|
|
28
|
+
var _flexBox = require("@semcore/flex-box");
|
|
29
|
+
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
+
|
|
34
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
+
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
+
|
|
38
|
+
/*__reshadow-styles__:"../style/plotA11yModule.shadow.css"*/
|
|
39
|
+
var styles = (
|
|
40
|
+
/*__reshadow_css_start__*/
|
|
41
|
+
_core.sstyled.insert(
|
|
42
|
+
/*__inner_css_start__*/
|
|
43
|
+
".___SPlotA11yModule_kb32z_gg_{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;opacity:0}.___SPlotA11yModule_kb32z_gg_:focus{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;pointer-events:all;opacity:1}"
|
|
44
|
+
/*__inner_css_end__*/
|
|
45
|
+
, "kb32z_gg_")
|
|
46
|
+
/*__reshadow_css_end__*/
|
|
47
|
+
, {
|
|
48
|
+
"__SPlotA11yModule": "___SPlotA11yModule_kb32z_gg_"
|
|
49
|
+
});
|
|
50
|
+
var globalWasFocused = false;
|
|
51
|
+
var globalNavWithKeyboard = false;
|
|
52
|
+
|
|
53
|
+
var PlotA11yModule = function PlotA11yModule(props) {
|
|
54
|
+
var _ref = arguments[0],
|
|
55
|
+
_ref5;
|
|
56
|
+
|
|
57
|
+
var SPlotA11yModule = _flexBox.Box;
|
|
58
|
+
|
|
59
|
+
var _React$useState = _react["default"].useState(globalWasFocused),
|
|
60
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
61
|
+
wasFocused = _React$useState2[0],
|
|
62
|
+
setWasFocused = _React$useState2[1];
|
|
63
|
+
|
|
64
|
+
var _React$useState3 = _react["default"].useState(globalNavWithKeyboard),
|
|
65
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
66
|
+
navWithKeyboard = _React$useState4[0],
|
|
67
|
+
setNavWithKeyboard = _React$useState4[1];
|
|
68
|
+
|
|
69
|
+
var _React$useState5 = _react["default"].useState(null),
|
|
70
|
+
_React$useState6 = (0, _slicedToArray2["default"])(_React$useState5, 2),
|
|
71
|
+
plotA11yView = _React$useState6[0],
|
|
72
|
+
setPlotA11yView = _React$useState6[1];
|
|
73
|
+
|
|
74
|
+
var hadnleHiddenElementsFocus = _react["default"].useCallback(function () {
|
|
75
|
+
setWasFocused(true);
|
|
76
|
+
setNavWithKeyboard(true);
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
var _React$useState7 = _react["default"].useState(false),
|
|
80
|
+
_React$useState8 = (0, _slicedToArray2["default"])(_React$useState7, 2),
|
|
81
|
+
loading = _React$useState8[0],
|
|
82
|
+
setLoading = _React$useState8[1];
|
|
83
|
+
|
|
84
|
+
var _React$useState9 = _react["default"].useState(null),
|
|
85
|
+
_React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
|
|
86
|
+
error = _React$useState10[0],
|
|
87
|
+
setError = _React$useState10[1];
|
|
88
|
+
|
|
89
|
+
var contextLocale = _react["default"].useContext(_WithI18n.Context);
|
|
90
|
+
|
|
91
|
+
var locale = _react["default"].useMemo(function () {
|
|
92
|
+
var _props$locale;
|
|
93
|
+
|
|
94
|
+
return (0, _locale.normalizeLocale)((_props$locale = props.locale) !== null && _props$locale !== void 0 ? _props$locale : contextLocale, _translations.translations);
|
|
95
|
+
}, [props.locale]);
|
|
96
|
+
|
|
97
|
+
var texts = _react["default"].useMemo(function () {
|
|
98
|
+
return locale ? _translations.translations[locale] : {};
|
|
99
|
+
}, [locale]);
|
|
100
|
+
|
|
101
|
+
_react["default"].useEffect(function () {
|
|
102
|
+
var _props$plotRef$curren;
|
|
103
|
+
|
|
104
|
+
if (wasFocused) return;
|
|
105
|
+
|
|
106
|
+
var focusListener = function focusListener() {
|
|
107
|
+
globalWasFocused = true;
|
|
108
|
+
setWasFocused(true);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
(_props$plotRef$curren = props.plotRef.current) === null || _props$plotRef$curren === void 0 ? void 0 : _props$plotRef$curren.addEventListener('focus', focusListener);
|
|
112
|
+
return function () {
|
|
113
|
+
var _props$plotRef$curren2;
|
|
114
|
+
|
|
115
|
+
return (_props$plotRef$curren2 = props.plotRef.current) === null || _props$plotRef$curren2 === void 0 ? void 0 : _props$plotRef$curren2.removeEventListener('focus', focusListener);
|
|
116
|
+
};
|
|
117
|
+
}, [wasFocused, props.plotRef]);
|
|
118
|
+
|
|
119
|
+
_react["default"].useEffect(function () {
|
|
120
|
+
var _document$body;
|
|
121
|
+
|
|
122
|
+
if (navWithKeyboard) return;
|
|
123
|
+
|
|
124
|
+
var keyboardListener = function keyboardListener(event) {
|
|
125
|
+
var navigationKeys = ['Tab', 'ArrowUp', 'ArrowLeft', 'ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
126
|
+
|
|
127
|
+
if ('key' in event && navigationKeys.includes(event.key)) {
|
|
128
|
+
setNavWithKeyboard(true);
|
|
129
|
+
globalNavWithKeyboard = true;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
(_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.addEventListener('keydown', keyboardListener);
|
|
134
|
+
return function () {
|
|
135
|
+
var _document$body2;
|
|
136
|
+
|
|
137
|
+
return (_document$body2 = document.body) === null || _document$body2 === void 0 ? void 0 : _document$body2.removeEventListener('keydown', keyboardListener);
|
|
138
|
+
};
|
|
139
|
+
}, [navWithKeyboard]);
|
|
140
|
+
|
|
141
|
+
var shouldDisplayView = wasFocused && navWithKeyboard;
|
|
142
|
+
|
|
143
|
+
_react["default"].useEffect(function () {
|
|
144
|
+
if (!shouldDisplayView) return;
|
|
145
|
+
if (plotA11yView) return;
|
|
146
|
+
if (loading) return;
|
|
147
|
+
setLoading(true);
|
|
148
|
+
Promise.resolve().then(function () {
|
|
149
|
+
return _interopRequireWildcard(require('./PlotA11yView'));
|
|
150
|
+
}).then(function (_ref6) {
|
|
151
|
+
var PlotA11yView = _ref6.PlotA11yView;
|
|
152
|
+
setPlotA11yView({
|
|
153
|
+
Component: PlotA11yView
|
|
154
|
+
});
|
|
155
|
+
setLoading(false);
|
|
156
|
+
setError(null);
|
|
157
|
+
})["catch"](function (error) {
|
|
158
|
+
// eslint-disable-next-line no-console
|
|
159
|
+
console.error(error);
|
|
160
|
+
setError(error);
|
|
161
|
+
});
|
|
162
|
+
}, [plotA11yView, shouldDisplayView, loading, setLoading]);
|
|
163
|
+
|
|
164
|
+
if (plotA11yView) {
|
|
165
|
+
var _ref2;
|
|
166
|
+
|
|
167
|
+
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(plotA11yView.Component, (0, _extends2["default"])({}, props, {
|
|
168
|
+
locale: locale
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (error) {
|
|
173
|
+
var _ref3;
|
|
174
|
+
|
|
175
|
+
return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPlotA11yModule, _ref3.cn("SPlotA11yModule", _objectSpread({}, (0, _core.assignProps)({
|
|
176
|
+
"tabIndex": 0,
|
|
177
|
+
"aria-live": "assertive"
|
|
178
|
+
}, _ref))), texts.failed);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (loading) {
|
|
182
|
+
var _ref4;
|
|
183
|
+
|
|
184
|
+
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPlotA11yModule, _ref4.cn("SPlotA11yModule", _objectSpread({}, (0, _core.assignProps)({
|
|
185
|
+
"tabIndex": 0,
|
|
186
|
+
"aria-live": "polite"
|
|
187
|
+
}, _ref))), texts.loading);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPlotA11yModule, _ref5.cn("SPlotA11yModule", _objectSpread({}, (0, _core.assignProps)({
|
|
191
|
+
"tabIndex": 0,
|
|
192
|
+
"onFocus": hadnleHiddenElementsFocus
|
|
193
|
+
}, _ref))), texts.disabled);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
exports.PlotA11yModule = PlotA11yModule;
|
|
197
|
+
//# sourceMappingURL=PlotA11yModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotA11yModule.js","names":["globalWasFocused","globalNavWithKeyboard","PlotA11yModule","props","SPlotA11yModule","Box","React","useState","wasFocused","setWasFocused","navWithKeyboard","setNavWithKeyboard","plotA11yView","setPlotA11yView","hadnleHiddenElementsFocus","useCallback","loading","setLoading","error","setError","contextLocale","useContext","I18nContext","locale","useMemo","normalizeLocale","translations","texts","useEffect","focusListener","plotRef","current","addEventListener","removeEventListener","keyboardListener","event","navigationKeys","includes","key","document","body","shouldDisplayView","then","PlotA11yView","Component","console","sstyled","styles","failed","disabled"],"sources":["../../../src/a11y/PlotA11yModule.tsx"],"sourcesContent":["import React from 'react';\nimport { DataStructureHints, PartialDataSummarizationConfig } from './hints';\nimport { normalizeLocale } from './locale';\nimport { translations } from './translations/module/translations';\nimport { Root, sstyled } from '@semcore/core';\nimport styles from '../style/plotA11yModule.shadow.css';\nimport { Context as I18nContext } from '@semcore/utils/lib/enhances/WithI18n';\nimport { Box } from '@semcore/flex-box';\n\nlet globalWasFocused = false;\nlet globalNavWithKeyboard = false;\n\nexport type A11yViewProps = {\n id: string;\n data: Record<string, unknown>[];\n hints: DataStructureHints;\n plotLabel: string;\n locale: NavigatorLanguage['language'];\n config: PartialDataSummarizationConfig;\n // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope\n plotRef: React.RefObject<Element>;\n};\n\nexport const PlotA11yModule: React.FC<A11yViewProps> = (props) => {\n const SPlotA11yModule = Root;\n const [wasFocused, setWasFocused] = React.useState(globalWasFocused);\n const [navWithKeyboard, setNavWithKeyboard] = React.useState(globalNavWithKeyboard);\n const [plotA11yView, setPlotA11yView] = React.useState<{\n Component: React.FC<A11yViewProps>;\n } | null>(null);\n\n const hadnleHiddenElementsFocus = React.useCallback(() => {\n setWasFocused(true);\n setNavWithKeyboard(true);\n }, []);\n\n const [loading, setLoading] = React.useState(false);\n const [error, setError] = React.useState<Error | null>(null);\n\n const contextLocale = React.useContext(I18nContext);\n const locale = React.useMemo(\n () => normalizeLocale(props.locale ?? contextLocale, translations),\n [props.locale],\n );\n const texts = React.useMemo(() => (locale ? translations[locale] : {}), [locale]);\n\n React.useEffect(() => {\n if (wasFocused) return;\n const focusListener = () => {\n globalWasFocused = true;\n setWasFocused(true);\n };\n\n props.plotRef.current?.addEventListener('focus', focusListener);\n return () => props.plotRef.current?.removeEventListener('focus', focusListener);\n }, [wasFocused, props.plotRef]);\n React.useEffect(() => {\n if (navWithKeyboard) return;\n const keyboardListener = (event: Event) => {\n const navigationKeys = [\n 'Tab',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowDown',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowLeft',\n ];\n if ('key' in event && navigationKeys.includes((event as KeyboardEvent).key)) {\n setNavWithKeyboard(true);\n globalNavWithKeyboard = true;\n }\n };\n document.body?.addEventListener('keydown', keyboardListener);\n return () => document.body?.removeEventListener('keydown', keyboardListener);\n }, [navWithKeyboard]);\n\n const shouldDisplayView = wasFocused && navWithKeyboard;\n\n React.useEffect(() => {\n if (!shouldDisplayView) return;\n if (plotA11yView) return;\n if (loading) return;\n\n setLoading(true);\n\n import('./PlotA11yView')\n .then(({ PlotA11yView }) => {\n setPlotA11yView({ Component: PlotA11yView });\n setLoading(false);\n setError(null);\n })\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.error(error);\n setError(error);\n });\n }, [plotA11yView, shouldDisplayView, loading, setLoading]);\n\n if (plotA11yView) {\n return sstyled(styles)(\n <plotA11yView.Component {...props} locale={locale!} />,\n ) as React.ReactElement;\n }\n\n if (error) {\n return sstyled(styles)(\n <SPlotA11yModule render={Box} tabIndex={0} aria-live=\"assertive\">\n {texts.failed}\n </SPlotA11yModule>,\n ) as React.ReactElement;\n }\n if (loading) {\n return sstyled(styles)(\n <SPlotA11yModule render={Box} tabIndex={0} aria-live=\"polite\">\n {texts.loading}\n </SPlotA11yModule>,\n ) as React.ReactElement;\n }\n\n return sstyled(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,CADF;EAKD;;EACD,IAAIhC,OAAJ,EAAa;IAAA;;IACX,eAAO,IAAA8B,aAAA,EAAQC,MAAR,CAAP,eACE,gCAAC,eAAD;MAAA,YAAwC,CAAxC;MAAA,aAAqD;IAArD,YACGpB,KAAK,CAACX,OADT,CADF;EAKD;;EAED,eAAO,IAAA8B,aAAA,EAAQC,MAAR,CAAP,eACE,gCAAC,eAAD;IAAA,YAAwC,CAAxC;IAAA,WAAoDjC;EAApD,YACGa,KAAK,CAACsB,QADT,CADF;AAKD,CAtGM"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.PlotA11yView = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@semcore/core");
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
|
+
|
|
20
|
+
var _focus = require("./focus");
|
|
21
|
+
|
|
22
|
+
var _hints = require("./hints");
|
|
23
|
+
|
|
24
|
+
var _serialize = require("./serialize");
|
|
25
|
+
|
|
26
|
+
var _intl = require("./intl");
|
|
27
|
+
|
|
28
|
+
var _summarize = require("./summarize");
|
|
29
|
+
|
|
30
|
+
var _flexBox = require("@semcore/flex-box");
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
+
|
|
36
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
37
|
+
|
|
38
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
39
|
+
|
|
40
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
41
|
+
|
|
42
|
+
/*__reshadow-styles__:"../style/plotA11yView.shadow.css"*/
|
|
43
|
+
var styles = (
|
|
44
|
+
/*__reshadow_css_start__*/
|
|
45
|
+
_core.sstyled.insert(
|
|
46
|
+
/*__inner_css_start__*/
|
|
47
|
+
".___SPlotA11yView_68w71_gg_{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;opacity:0;background-color:#fff;color:#000;border:3px solid #000;font-size:10px;padding:2px;width:200px;height:200px;max-width:80%;max-height:80%;overflow:auto}.___SPlotA11yView_68w71_gg_:focus,.___SPlotA11yView_68w71_gg_.__focus-within_68w71_gg_{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;pointer-events:all;opacity:1;z-index:100;position:relative;display:block}.___SPlotA11yView_68w71_gg_:focus,.___SPlotA11yView_68w71_gg_:focus-within{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all;pointer-events:all;opacity:1;z-index:100;position:relative;display:block}.___SPlotA11yView_68w71_gg_ a{cursor:pointer;text-decoration:underline;margin-bottom:8px;display:block}.___SPlotA11yView_68w71_gg_ table,.___SPlotA11yView_68w71_gg_ td,.___SPlotA11yView_68w71_gg_ th{border:1px solid #000}"
|
|
48
|
+
/*__inner_css_end__*/
|
|
49
|
+
, "68w71_gg_")
|
|
50
|
+
/*__reshadow_css_end__*/
|
|
51
|
+
, {
|
|
52
|
+
"__SPlotA11yView": "___SPlotA11yView_68w71_gg_",
|
|
53
|
+
"_focus-within": "__focus-within_68w71_gg_"
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var PlotA11yView = function PlotA11yView(_ref3) {
|
|
57
|
+
var _ref = arguments[0],
|
|
58
|
+
_ref2;
|
|
59
|
+
|
|
60
|
+
var id = _ref3.id,
|
|
61
|
+
providedData = _ref3.data,
|
|
62
|
+
hints = _ref3.hints,
|
|
63
|
+
plotLabel = _ref3.plotLabel,
|
|
64
|
+
plotRef = _ref3.plotRef,
|
|
65
|
+
providedConfig = _ref3.config,
|
|
66
|
+
locale = _ref3.locale;
|
|
67
|
+
var SPlotA11yView = _flexBox.Box;
|
|
68
|
+
|
|
69
|
+
var intl = _react["default"].useMemo(function () {
|
|
70
|
+
return (0, _intl.getIntl)(locale);
|
|
71
|
+
}, [locale]);
|
|
72
|
+
|
|
73
|
+
var config = _react["default"].useMemo(function () {
|
|
74
|
+
return (0, _hints.makeDataSummarizationConfig)(providedConfig);
|
|
75
|
+
}, [providedConfig]);
|
|
76
|
+
|
|
77
|
+
var data = _react["default"].useMemo(function () {
|
|
78
|
+
return Array.isArray(providedData) ? providedData : [providedData];
|
|
79
|
+
}, [providedData]);
|
|
80
|
+
|
|
81
|
+
var keys = _react["default"].useMemo(function () {
|
|
82
|
+
var _fromHints, _fromHints2, _fromHints3, _fromHints4;
|
|
83
|
+
|
|
84
|
+
var fromHints = [];
|
|
85
|
+
|
|
86
|
+
(_fromHints = fromHints).push.apply(_fromHints, (0, _toConsumableArray2["default"])(hints.fields.verticalAxes));
|
|
87
|
+
|
|
88
|
+
(_fromHints2 = fromHints).push.apply(_fromHints2, (0, _toConsumableArray2["default"])(hints.fields.horizontalAxes));
|
|
89
|
+
|
|
90
|
+
(_fromHints3 = fromHints).push.apply(_fromHints3, (0, _toConsumableArray2["default"])(hints.fields.valueAxes));
|
|
91
|
+
|
|
92
|
+
(_fromHints4 = fromHints).push.apply(_fromHints4, (0, _toConsumableArray2["default"])(Object.keys(hints.fields.values)));
|
|
93
|
+
|
|
94
|
+
fromHints = (0, _toConsumableArray2["default"])(new Set(fromHints)).filter(function (key) {
|
|
95
|
+
return key in data[0];
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if (fromHints.length === 0) {
|
|
99
|
+
data.forEach(function (row) {
|
|
100
|
+
var _fromHints5;
|
|
101
|
+
|
|
102
|
+
return (_fromHints5 = fromHints).push.apply(_fromHints5, (0, _toConsumableArray2["default"])(Object.keys(row)));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (0, _toConsumableArray2["default"])(new Set(fromHints));
|
|
107
|
+
}, [data, hints]);
|
|
108
|
+
|
|
109
|
+
var duplicatedBaseKeys = _react["default"].useMemo(function () {
|
|
110
|
+
var baseKeys = keys.filter(function (key) {
|
|
111
|
+
return !hints.titles.valuesAxes[key];
|
|
112
|
+
}).map(function (key) {
|
|
113
|
+
if (hints.fields.verticalAxes.has(key) && hints.axesTitle.vertical) return [key, hints.axesTitle.vertical];
|
|
114
|
+
if (hints.fields.horizontalAxes.has(key) && hints.axesTitle.horizontal) return [key, hints.axesTitle.horizontal];
|
|
115
|
+
}).filter(function (entry) {
|
|
116
|
+
return entry !== undefined;
|
|
117
|
+
}).map(function (entry) {
|
|
118
|
+
return entry;
|
|
119
|
+
});
|
|
120
|
+
var doublicated = {};
|
|
121
|
+
var handled = {};
|
|
122
|
+
|
|
123
|
+
var _iterator = _createForOfIteratorHelper(baseKeys),
|
|
124
|
+
_step;
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
128
|
+
var _step$value = (0, _slicedToArray2["default"])(_step.value, 2),
|
|
129
|
+
key = _step$value[0],
|
|
130
|
+
label = _step$value[1];
|
|
131
|
+
|
|
132
|
+
if (handled[label]) {
|
|
133
|
+
doublicated[key] = true;
|
|
134
|
+
doublicated[handled[label]] = true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
handled[label] = key;
|
|
138
|
+
}
|
|
139
|
+
} catch (err) {
|
|
140
|
+
_iterator.e(err);
|
|
141
|
+
} finally {
|
|
142
|
+
_iterator.f();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return doublicated;
|
|
146
|
+
}, [keys, hints]);
|
|
147
|
+
|
|
148
|
+
var renderTitle = _react["default"].useCallback(function (dataKey) {
|
|
149
|
+
if (hints.titles.valuesAxes[dataKey]) return hints.titles.valuesAxes[dataKey];
|
|
150
|
+
|
|
151
|
+
if (!duplicatedBaseKeys[dataKey]) {
|
|
152
|
+
if (hints.fields.verticalAxes.has(dataKey) && hints.axesTitle.vertical) return hints.axesTitle.vertical;
|
|
153
|
+
if (hints.fields.horizontalAxes.has(dataKey) && hints.axesTitle.horizontal) return hints.axesTitle.horizontal;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return dataKey;
|
|
157
|
+
}, [data, hints, duplicatedBaseKeys]);
|
|
158
|
+
|
|
159
|
+
var _React$useState = _react["default"].useState(null),
|
|
160
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
161
|
+
summary = _React$useState2[0],
|
|
162
|
+
setSummary = _React$useState2[1];
|
|
163
|
+
|
|
164
|
+
var _React$useState3 = _react["default"].useState(true),
|
|
165
|
+
_React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
|
|
166
|
+
generatingSummary = _React$useState4[0],
|
|
167
|
+
setGeneratingSummary = _React$useState4[1];
|
|
168
|
+
|
|
169
|
+
_react["default"].useEffect(function () {
|
|
170
|
+
if (config.disable) {
|
|
171
|
+
setSummary('');
|
|
172
|
+
setGeneratingSummary(false);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (config.override) {
|
|
177
|
+
setSummary(config.override);
|
|
178
|
+
setGeneratingSummary(false);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
setTimeout(function () {
|
|
183
|
+
setSummary((0, _summarize.summarize)(providedData, hints, config, locale));
|
|
184
|
+
setGeneratingSummary(false);
|
|
185
|
+
}, 0);
|
|
186
|
+
}, [providedData, hints, config, locale]);
|
|
187
|
+
|
|
188
|
+
var handleSkip = _react["default"].useCallback(function () {
|
|
189
|
+
var _heavyFindNextFocusab;
|
|
190
|
+
|
|
191
|
+
if (!plotRef.current) return;
|
|
192
|
+
(_heavyFindNextFocusab = (0, _focus.heavyFindNextFocusableElement)(plotRef.current)) === null || _heavyFindNextFocusab === void 0 ? void 0 : _heavyFindNextFocusab.focus();
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
var handleSkipKeyboard = _react["default"].useCallback(function (event) {
|
|
196
|
+
if (event.code !== 'Enter') return;
|
|
197
|
+
handleSkip();
|
|
198
|
+
}, [handleSkip]);
|
|
199
|
+
|
|
200
|
+
var handleGoToTable = _react["default"].useCallback(function () {
|
|
201
|
+
var _dataTableRef$current;
|
|
202
|
+
|
|
203
|
+
(_dataTableRef$current = dataTableRef.current) === null || _dataTableRef$current === void 0 ? void 0 : _dataTableRef$current.focus();
|
|
204
|
+
}, []);
|
|
205
|
+
|
|
206
|
+
var handleGoToTableKeyboard = _react["default"].useCallback(function (event) {
|
|
207
|
+
if (event.code !== 'Enter') return;
|
|
208
|
+
handleGoToTable();
|
|
209
|
+
}, [handleGoToTable]);
|
|
210
|
+
|
|
211
|
+
var texts = _react["default"].useMemo(function () {
|
|
212
|
+
return {
|
|
213
|
+
label: intl.formatMessage({
|
|
214
|
+
id: 'view-label'
|
|
215
|
+
}, {
|
|
216
|
+
plotLabel: plotLabel !== null && plotLabel !== void 0 ? plotLabel : intl.formatMessage({
|
|
217
|
+
id: 'view-default-plot-label'
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
close: intl.formatMessage({
|
|
221
|
+
id: 'view-close'
|
|
222
|
+
}),
|
|
223
|
+
skipPlot: intl.formatMessage({
|
|
224
|
+
id: 'view-skip-plot'
|
|
225
|
+
}),
|
|
226
|
+
goToTable: intl.formatMessage({
|
|
227
|
+
id: 'view-go-to-table'
|
|
228
|
+
}),
|
|
229
|
+
summary: intl.formatMessage({
|
|
230
|
+
id: 'view-data-summary'
|
|
231
|
+
}),
|
|
232
|
+
summaryPlaceholder: intl.formatMessage({
|
|
233
|
+
id: 'view-summary-placeholder'
|
|
234
|
+
}),
|
|
235
|
+
table: intl.formatMessage({
|
|
236
|
+
id: 'view-table'
|
|
237
|
+
})
|
|
238
|
+
};
|
|
239
|
+
}, [intl, plotLabel]);
|
|
240
|
+
|
|
241
|
+
var dataTableRef = _react["default"].useRef(null);
|
|
242
|
+
|
|
243
|
+
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SPlotA11yView, _ref2.cn("SPlotA11yView", _objectSpread({}, (0, _core.assignProps)({
|
|
244
|
+
"tabIndex": 0,
|
|
245
|
+
"aria-label": texts.label
|
|
246
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement("a", _ref2.cn("a", {
|
|
247
|
+
"aria-hidden": true,
|
|
248
|
+
"onClick": handleSkip
|
|
249
|
+
}), texts.close), /*#__PURE__*/_react["default"].createElement("a", _ref2.cn("a", {
|
|
250
|
+
"role": "link",
|
|
251
|
+
"tabIndex": 0,
|
|
252
|
+
"onKeyDown": handleSkipKeyboard,
|
|
253
|
+
"onClick": handleSkip
|
|
254
|
+
}), texts.skipPlot), /*#__PURE__*/_react["default"].createElement("a", _ref2.cn("a", {
|
|
255
|
+
"role": "link",
|
|
256
|
+
"tabIndex": 0,
|
|
257
|
+
"onKeyDown": handleGoToTableKeyboard,
|
|
258
|
+
"onClick": handleGoToTable
|
|
259
|
+
}), texts.goToTable), /*#__PURE__*/_react["default"].createElement("strong", _ref2.cn("strong", {}), /*#__PURE__*/_react["default"].createElement("label", _ref2.cn("label", {
|
|
260
|
+
"htmlFor": "".concat(id, "-data-summary")
|
|
261
|
+
}), texts.summary)), /*#__PURE__*/_react["default"].createElement("div", _ref2.cn("div", {
|
|
262
|
+
"id": "".concat(id, "-data-summary"),
|
|
263
|
+
"aria-busy": generatingSummary,
|
|
264
|
+
"tabIndex": 0
|
|
265
|
+
}), generatingSummary ? texts.summaryPlaceholder : summary), /*#__PURE__*/_react["default"].createElement("strong", _ref2.cn("strong", {}), /*#__PURE__*/_react["default"].createElement("label", _ref2.cn("label", {
|
|
266
|
+
"htmlFor": "".concat(id, "-data-table")
|
|
267
|
+
}), texts.table)), /*#__PURE__*/_react["default"].createElement("table", _ref2.cn("table", {
|
|
268
|
+
"id": "".concat(id, "-data-table"),
|
|
269
|
+
"tabIndex": 0,
|
|
270
|
+
"ref": dataTableRef
|
|
271
|
+
}), /*#__PURE__*/_react["default"].createElement("thead", _ref2.cn("thead", {}), /*#__PURE__*/_react["default"].createElement("tr", _ref2.cn("tr", {}), keys.map(function (key, index) {
|
|
272
|
+
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
273
|
+
key: "".concat(key, "-").concat(index)
|
|
274
|
+
}, renderTitle(key));
|
|
275
|
+
}))), /*#__PURE__*/_react["default"].createElement("tbody", _ref2.cn("tbody", {}), data.map(function (row, index) {
|
|
276
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
277
|
+
key: Object.values(row).join('-') + '-' + index
|
|
278
|
+
}, keys.map(function (key, index) {
|
|
279
|
+
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
280
|
+
key: "".concat(key, "-").concat(index)
|
|
281
|
+
}, (0, _serialize.formatValue)(intl, row[key]));
|
|
282
|
+
}));
|
|
283
|
+
}))));
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
exports.PlotA11yView = PlotA11yView;
|
|
287
|
+
//# sourceMappingURL=PlotA11yView.js.map
|