@semcore/d3-chart 3.36.0 → 3.37.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 +6 -0
- package/lib/cjs/Area.js +11 -11
- package/lib/cjs/Axis.js +14 -14
- package/lib/cjs/Bar.js +10 -10
- package/lib/cjs/Bubble.js +12 -12
- package/lib/cjs/Donut.js +9 -9
- package/lib/cjs/Dots.js +8 -8
- package/lib/cjs/HorizontalBar.js +10 -10
- package/lib/cjs/Hover.js +3 -3
- package/lib/cjs/Line.js +9 -9
- package/lib/cjs/Plot.js +3 -3
- package/lib/cjs/Radar.js +19 -19
- package/lib/cjs/RadialTree.js +11 -11
- package/lib/cjs/ReferenceLine.js +9 -9
- package/lib/cjs/ScatterPlot.js +9 -9
- package/lib/cjs/Tooltip.js +9 -9
- package/lib/cjs/Venn.js +9 -9
- package/lib/cjs/a11y/DataAccessibilityTable.js +116 -0
- package/lib/cjs/a11y/DataAccessibilityTable.js.map +1 -0
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +11 -90
- package/lib/cjs/a11y/PlotA11yView.js.map +1 -1
- package/lib/cjs/a11y/hints.js.map +1 -1
- package/lib/cjs/a11y/serialize.js +43 -30
- package/lib/cjs/a11y/serialize.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +17 -17
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +6 -6
- package/lib/cjs/types/Plot.d.js.map +1 -1
- package/lib/es6/Area.js +11 -11
- package/lib/es6/Axis.js +14 -14
- package/lib/es6/Bar.js +10 -10
- package/lib/es6/Bubble.js +12 -12
- package/lib/es6/Donut.js +9 -9
- package/lib/es6/Dots.js +8 -8
- package/lib/es6/HorizontalBar.js +10 -10
- package/lib/es6/Hover.js +3 -3
- package/lib/es6/Line.js +9 -9
- package/lib/es6/Plot.js +3 -3
- package/lib/es6/Radar.js +19 -19
- package/lib/es6/RadialTree.js +11 -11
- package/lib/es6/ReferenceLine.js +9 -9
- package/lib/es6/ScatterPlot.js +9 -9
- package/lib/es6/Tooltip.js +9 -9
- package/lib/es6/Venn.js +9 -9
- package/lib/es6/a11y/DataAccessibilityTable.js +108 -0
- package/lib/es6/a11y/DataAccessibilityTable.js.map +1 -0
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +11 -90
- package/lib/es6/a11y/PlotA11yView.js.map +1 -1
- package/lib/es6/a11y/hints.js.map +1 -1
- package/lib/es6/a11y/serialize.js +41 -28
- package/lib/es6/a11y/serialize.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +17 -17
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +6 -6
- package/lib/es6/types/Plot.d.js.map +1 -1
- package/lib/types/Plot.d.ts +4 -0
- package/lib/types/a11y/DataAccessibilityTable.d.ts +11 -0
- package/lib/types/a11y/hints.d.ts +6 -1
- package/lib/types/a11y/serialize.d.ts +2 -2
- package/package.json +6 -6
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
5
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
6
3
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
7
4
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
8
5
|
import React from 'react';
|
|
9
6
|
import { heavyFindNextFocusableElement } from './focus';
|
|
10
7
|
import { makeDataSummarizationConfig } from './hints';
|
|
11
|
-
import { formatValue } from './serialize';
|
|
12
8
|
import { getIntl } from './intl';
|
|
13
9
|
import { summarize } from './summarize';
|
|
14
10
|
import { Root, sstyled } from '@semcore/core';
|
|
15
11
|
/*__reshadow-styles__:"../style/plotA11yView.shadow.css"*/
|
|
16
|
-
var styles = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
17
|
-
"__SPlotA11yView": "
|
|
12
|
+
var styles = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPlotA11yView_1q4lm_gg_{-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none;opacity:0;background-color:var(--intergalactic-bg-primary-neutral, #ffffff);color:var(--intergalactic-text-primary, #191b23);border:3px solid var(--intergalactic-border-primary, #c4c7cf);font-size:var(--intergalactic-fs-50, 10px);padding:2px;width:200px;height:200px;max-width:80%;max-height:80%;overflow:auto}.___SPlotA11yView_1q4lm_gg_:focus,.___SPlotA11yView_1q4lm_gg_:focus-within{-webkit-user-select:all;-moz-user-select:all;user-select:all;pointer-events:all;opacity:1;z-index:var(--intergalactic-z-index-overlay, 500);position:relative;display:block}.___SPlotA11yView_1q4lm_gg_ a{cursor:pointer;-webkit-text-decoration:underline;text-decoration:underline;margin-bottom:var(--intergalactic-spacing-2x, 8px);display:block}.___SPlotA11yView_1q4lm_gg_ table,.___SPlotA11yView_1q4lm_gg_ td,.___SPlotA11yView_1q4lm_gg_ th{border:1px solid var(--intergalactic-border-primary, #c4c7cf)}" /*__inner_css_end__*/, "1q4lm_gg_") /*__reshadow_css_end__*/, {
|
|
13
|
+
"__SPlotA11yView": "___SPlotA11yView_1q4lm_gg_"
|
|
18
14
|
});
|
|
19
15
|
import { Box } from '@semcore/flex-box';
|
|
20
16
|
import { useAsyncI18nMessages } from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
21
17
|
import { localizedMessages } from './translations/view/__intergalactic-dynamic-locales';
|
|
18
|
+
import { DataAccessibilityTable } from './DataAccessibilityTable';
|
|
22
19
|
export var PlotA11yView = function PlotA11yView(_ref3) {
|
|
23
20
|
var _ref = arguments[0],
|
|
24
21
|
_ref2;
|
|
@@ -40,66 +37,6 @@ export var PlotA11yView = function PlotA11yView(_ref3) {
|
|
|
40
37
|
var data = React.useMemo(function () {
|
|
41
38
|
return Array.isArray(providedData) ? providedData : [providedData];
|
|
42
39
|
}, [providedData]);
|
|
43
|
-
var keys = React.useMemo(function () {
|
|
44
|
-
var _fromHints, _fromHints2, _fromHints3, _fromHints4, _fromHints5;
|
|
45
|
-
var fromHints = [];
|
|
46
|
-
(_fromHints = fromHints).push.apply(_fromHints, _toConsumableArray(hints.fields.verticalAxes));
|
|
47
|
-
(_fromHints2 = fromHints).push.apply(_fromHints2, _toConsumableArray(hints.fields.horizontalAxes));
|
|
48
|
-
(_fromHints3 = fromHints).push.apply(_fromHints3, _toConsumableArray(hints.fields.valueAxes));
|
|
49
|
-
(_fromHints4 = fromHints).push.apply(_fromHints4, _toConsumableArray(config.additionalFields));
|
|
50
|
-
(_fromHints5 = fromHints).push.apply(_fromHints5, _toConsumableArray(Object.keys(hints.fields.values)));
|
|
51
|
-
fromHints = _toConsumableArray(new Set(fromHints)).filter(function (key) {
|
|
52
|
-
return key in data[0];
|
|
53
|
-
});
|
|
54
|
-
if (fromHints.length === 0) {
|
|
55
|
-
data.forEach(function (row) {
|
|
56
|
-
var _fromHints6;
|
|
57
|
-
return (_fromHints6 = fromHints).push.apply(_fromHints6, _toConsumableArray(Object.keys(row)));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return _toConsumableArray(new Set(fromHints));
|
|
61
|
-
}, [data, hints]);
|
|
62
|
-
var duplicatedBaseKeys = React.useMemo(function () {
|
|
63
|
-
var baseKeys = keys.filter(function (key) {
|
|
64
|
-
return !hints.titles.valuesAxes[key];
|
|
65
|
-
}).map(function (key) {
|
|
66
|
-
if (hints.fields.verticalAxes.has(key) && hints.axesTitle.vertical) return [key, hints.axesTitle.vertical];
|
|
67
|
-
if (hints.fields.horizontalAxes.has(key) && hints.axesTitle.horizontal) return [key, hints.axesTitle.horizontal];
|
|
68
|
-
}).filter(function (entry) {
|
|
69
|
-
return entry !== undefined;
|
|
70
|
-
}).map(function (entry) {
|
|
71
|
-
return entry;
|
|
72
|
-
});
|
|
73
|
-
var doublicated = {};
|
|
74
|
-
var handled = {};
|
|
75
|
-
var _iterator = _createForOfIteratorHelper(baseKeys),
|
|
76
|
-
_step;
|
|
77
|
-
try {
|
|
78
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
79
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
80
|
-
key = _step$value[0],
|
|
81
|
-
label = _step$value[1];
|
|
82
|
-
if (handled[label]) {
|
|
83
|
-
doublicated[key] = true;
|
|
84
|
-
doublicated[handled[label]] = true;
|
|
85
|
-
}
|
|
86
|
-
handled[label] = key;
|
|
87
|
-
}
|
|
88
|
-
} catch (err) {
|
|
89
|
-
_iterator.e(err);
|
|
90
|
-
} finally {
|
|
91
|
-
_iterator.f();
|
|
92
|
-
}
|
|
93
|
-
return doublicated;
|
|
94
|
-
}, [keys, hints]);
|
|
95
|
-
var renderTitle = React.useCallback(function (dataKey) {
|
|
96
|
-
if (hints.titles.valuesAxes[dataKey]) return hints.titles.valuesAxes[dataKey];
|
|
97
|
-
if (!duplicatedBaseKeys[dataKey]) {
|
|
98
|
-
if (hints.fields.verticalAxes.has(dataKey) && hints.axesTitle.vertical) return hints.axesTitle.vertical;
|
|
99
|
-
if (hints.fields.horizontalAxes.has(dataKey) && hints.axesTitle.horizontal) return hints.axesTitle.horizontal;
|
|
100
|
-
}
|
|
101
|
-
return dataKey;
|
|
102
|
-
}, [data, hints, duplicatedBaseKeys]);
|
|
103
40
|
var _React$useState = React.useState(null),
|
|
104
41
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
105
42
|
summary = _React$useState2[0],
|
|
@@ -197,29 +134,13 @@ export var PlotA11yView = function PlotA11yView(_ref3) {
|
|
|
197
134
|
"tabIndex": 0
|
|
198
135
|
}), generatingSummary ? texts.summaryPlaceholder : summary), /*#__PURE__*/React.createElement("strong", _ref2.cn("strong", {}), /*#__PURE__*/React.createElement("label", _ref2.cn("label", {
|
|
199
136
|
"htmlFor": "".concat(id, "-data-table")
|
|
200
|
-
}), texts.table)), /*#__PURE__*/React.createElement(
|
|
201
|
-
"id":
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}))), /*#__PURE__*/React.createElement("tbody", _ref2.cn("tbody", {}), data.map(function (row, index) {
|
|
209
|
-
return /*#__PURE__*/React.createElement("tr", {
|
|
210
|
-
key: "".concat(Object.values(row).filter(function (item) {
|
|
211
|
-
return _typeof(item) !== 'symbol';
|
|
212
|
-
}).join('-'), "-").concat(index)
|
|
213
|
-
}, keys.map(function (key) {
|
|
214
|
-
return _typeof(row[key]) !== 'symbol' ? [key, row[key]] : [key, ''];
|
|
215
|
-
}).map(function (_ref4, index) {
|
|
216
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
217
|
-
key = _ref5[0],
|
|
218
|
-
value = _ref5[1];
|
|
219
|
-
return /*#__PURE__*/React.createElement("td", {
|
|
220
|
-
key: "".concat(key, "-").concat(index)
|
|
221
|
-
}, formatValue(intl, value));
|
|
222
|
-
}));
|
|
223
|
-
}))));
|
|
137
|
+
}), texts.table)), /*#__PURE__*/React.createElement(DataAccessibilityTable, _ref2.cn("DataAccessibilityTable", {
|
|
138
|
+
"id": id,
|
|
139
|
+
"dataTableRef": dataTableRef,
|
|
140
|
+
"data": data,
|
|
141
|
+
"hints": hints,
|
|
142
|
+
"config": config,
|
|
143
|
+
"intl": intl
|
|
144
|
+
})));
|
|
224
145
|
};
|
|
225
146
|
//# sourceMappingURL=PlotA11yView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlotA11yView.js","names":["React","heavyFindNextFocusableElement","makeDataSummarizationConfig","formatValue","getIntl","summarize","Root","sstyled","styles","_sstyled","insert","Box","useAsyncI18nMessages","localizedMessages","PlotA11yView","_ref3","_ref","arguments[0]","_ref2","id","providedData","data","hints","plotLabel","plotRef","providedConfig","config","locale","SPlotA11yView","translations","intl","useMemo","Array","isArray","keys","_fromHints","_fromHints2","_fromHints3","_fromHints4","_fromHints5","fromHints","push","apply","_toConsumableArray","fields","verticalAxes","horizontalAxes","valueAxes","additionalFields","Object","values","Set","filter","key","length","forEach","row","_fromHints6","duplicatedBaseKeys","baseKeys","titles","valuesAxes","map","has","axesTitle","vertical","horizontal","entry","undefined","doublicated","handled","_iterator","_createForOfIteratorHelper","_step","s","n","done","_step$value","_slicedToArray","value","label","err","e","f","renderTitle","useCallback","dataKey","_React$useState","useState","_React$useState2","summary","setSummary","_React$useState3","_React$useState4","generatingSummary","setGeneratingSummary","useEffect","disable","override","setTimeout","handleSkip","_heavyFindNextFocusab","current","focus","handleSkipKeyboard","event","preventDefault","handleGoToTable","_dataTableRef$current","dataTableRef","handleGoToTableKeyboard","texts","formatMessage","close","skipPlot","goToTable","summaryPlaceholder","table","useRef","createElement","cn","_objectSpread","_assignProps","concat","index","item","_typeof","join","_ref4","_ref5"],"sources":["../../../src/a11y/PlotA11yView.tsx"],"sourcesContent":["import React from 'react';\nimport { heavyFindNextFocusableElement } from './focus';\nimport { makeDataSummarizationConfig } from './hints';\nimport type { A11yViewProps } from './PlotA11yModule';\nimport { formatValue } from './serialize';\nimport { getIntl } from './intl';\nimport { summarize } from './summarize';\nimport { Root, sstyled } from '@semcore/core';\nimport styles from '../style/plotA11yView.shadow.css';\nimport { Box } from '@semcore/flex-box';\nimport { useAsyncI18nMessages } from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { localizedMessages } from './translations/view/__intergalactic-dynamic-locales';\n\nexport const PlotA11yView: React.FC<A11yViewProps> = ({\n id,\n data: providedData,\n hints,\n plotLabel,\n plotRef,\n config: providedConfig,\n locale,\n}) => {\n const SPlotA11yView = Root;\n const translations = useAsyncI18nMessages(localizedMessages, locale);\n const intl = React.useMemo(\n () => getIntl(locale, translations, localizedMessages),\n [locale, translations, localizedMessages],\n );\n const config = React.useMemo(() => makeDataSummarizationConfig(providedConfig), [providedConfig]);\n const data = React.useMemo(\n () => (Array.isArray(providedData) ? providedData : [providedData]),\n [providedData],\n );\n const keys = React.useMemo(() => {\n let fromHints: (string | number)[] = [];\n fromHints.push(...hints.fields.verticalAxes);\n fromHints.push(...hints.fields.horizontalAxes);\n fromHints.push(...hints.fields.valueAxes);\n fromHints.push(...config.additionalFields);\n fromHints.push(...Object.keys(hints.fields.values));\n\n fromHints = [...new Set(fromHints)].filter((key) => key in data[0]);\n\n if (fromHints.length === 0) {\n data.forEach((row) => fromHints.push(...Object.keys(row)));\n }\n\n return [...new Set(fromHints)];\n }, [data, hints]);\n const duplicatedBaseKeys = React.useMemo(() => {\n const baseKeys = keys\n .filter((key) => !hints.titles.valuesAxes[key])\n .map((key) => {\n if (hints.fields.verticalAxes.has(key) && hints.axesTitle.vertical)\n return [key, hints.axesTitle.vertical];\n if (hints.fields.horizontalAxes.has(key) && hints.axesTitle.horizontal)\n return [key, hints.axesTitle.horizontal];\n })\n .filter((entry) => entry !== undefined)\n .map((entry) => entry!);\n const doublicated: Record<string, true> = {};\n const handled: Record<string, string | number> = {};\n for (const [key, label] of baseKeys) {\n if (handled[label]) {\n doublicated[key] = true;\n doublicated[handled[label]] = true;\n }\n handled[label] = key;\n }\n return doublicated;\n }, [keys, hints]);\n const renderTitle = React.useCallback(\n (dataKey: string | number) => {\n if (hints.titles.valuesAxes[dataKey]) return hints.titles.valuesAxes[dataKey];\n if (!duplicatedBaseKeys[dataKey]) {\n if (hints.fields.verticalAxes.has(dataKey) && hints.axesTitle.vertical)\n return hints.axesTitle.vertical;\n if (hints.fields.horizontalAxes.has(dataKey) && hints.axesTitle.horizontal)\n return hints.axesTitle.horizontal;\n }\n\n return dataKey;\n },\n [data, hints, duplicatedBaseKeys],\n );\n\n const [summary, setSummary] = React.useState<string | null>(null);\n const [generatingSummary, setGeneratingSummary] = React.useState(true);\n\n React.useEffect(() => {\n if (config.disable) {\n setSummary('');\n setGeneratingSummary(false);\n return;\n }\n if (config.override) {\n setSummary(config.override);\n setGeneratingSummary(false);\n return;\n }\n setTimeout(() => {\n setSummary(summarize(providedData, hints, config, locale, translations, localizedMessages));\n setGeneratingSummary(false);\n }, 0);\n }, [providedData, hints, config, locale, translations, localizedMessages]);\n\n const handleSkip = React.useCallback(() => {\n if (!plotRef.current) return;\n\n heavyFindNextFocusableElement(plotRef.current)?.focus();\n }, []);\n const handleSkipKeyboard = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (!(event.key === 'Enter' || event.key === ' ')) return;\n\n event.preventDefault();\n handleSkip();\n },\n [handleSkip],\n );\n const handleGoToTable = React.useCallback(() => {\n dataTableRef.current?.focus();\n }, []);\n const handleGoToTableKeyboard = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (!(event.key === 'Enter' || event.key === ' ')) return;\n\n event.preventDefault();\n handleGoToTable();\n },\n [handleGoToTable],\n );\n\n const texts = React.useMemo(\n () => ({\n label: intl.formatMessage(\n { id: 'view-label' },\n { plotLabel: plotLabel ?? intl.formatMessage({ id: 'view-default-plot-label' }) },\n ),\n close: intl.formatMessage({ id: 'view-close' }),\n skipPlot: intl.formatMessage({ id: 'view-skip-plot' }),\n goToTable: intl.formatMessage({ id: 'view-go-to-table' }),\n summary: intl.formatMessage({ id: 'view-data-summary' }),\n summaryPlaceholder: intl.formatMessage({ id: 'view-summary-placeholder' }),\n table: intl.formatMessage({ id: 'view-table' }),\n }),\n [intl, plotLabel],\n );\n\n const dataTableRef = React.useRef<HTMLTableElement>(null);\n\n return sstyled(styles)(\n <SPlotA11yView render={Box} tabIndex={0} aria-label={texts.label}>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a aria-hidden onClick={handleSkip}>\n {texts.close}\n </a>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a role='link' tabIndex={0} onKeyDown={handleSkipKeyboard} onClick={handleSkip}>\n {texts.skipPlot}\n </a>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a role='link' tabIndex={0} onKeyDown={handleGoToTableKeyboard} onClick={handleGoToTable}>\n {texts.goToTable}\n </a>\n <strong>\n <label htmlFor={`${id}-data-summary`}>{texts.summary}</label>\n </strong>\n <div id={`${id}-data-summary`} aria-busy={generatingSummary} tabIndex={0}>\n {generatingSummary ? texts.summaryPlaceholder : summary}\n </div>\n <strong>\n <label htmlFor={`${id}-data-table`}>{texts.table}</label>\n </strong>\n <table id={`${id}-data-table`} tabIndex={0} ref={dataTableRef}>\n <thead>\n <tr>\n {keys.map((key, index) => (\n <th key={`${key}-${index}`}>{renderTitle(key)}</th>\n ))}\n </tr>\n </thead>\n <tbody>\n {data.map((row, index) => (\n <tr\n key={`${Object.values(row)\n .filter((item) => typeof item !== 'symbol')\n .join('-')}-${index}`}\n >\n {keys\n .map((key) => (typeof row[key] !== 'symbol' ? [key, row[key]] : [key, '']))\n .map(([key, value], index) => (\n <td key={`${key}-${index}`}>{formatValue(intl, value)}</td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </SPlotA11yView>,\n ) as React.ReactElement;\n};\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,6BAA6B,QAAQ,SAAS;AACvD,SAASC,2BAA2B,QAAQ,SAAS;AAErD,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAAC;AAAA,IAAAC,MAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;AAAA;AAE9C,SAASC,GAAG,QAAQ,mBAAmB;AACvC,SAASC,oBAAoB,QAAQ,yCAAyC;AAC9E,SAASC,iBAAiB,QAAQ,qDAAqD;AAEvF,OAAO,IAAMC,YAAqC,GAAG,SAAxC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AAC,CAC1ES,GAAG,CAAC,UAAAkE,KAAA,EAAeJ,KAAK;MAAA,IAAAK,KAAA,GAAAnD,cAAA,CAAAkD,KAAA;QAAlB3E,GAAG,GAAA4E,KAAA;QAAElD,KAAK,GAAAkD,KAAA;MAAA,oBACfjI,KAAA,CAAAuH,aAAA;QAAIlE,GAAG,KAAAsE,MAAA,CAAKtE,GAAG,OAAAsE,MAAA,CAAIC,KAAK;MAAG,GAAEzH,WAAW,CAAC2B,IAAI,EAAEiD,KAAK,CAAC,CAAM;IAAA,CAC5D,CAAC,CACD;EAAA,CACN,CAAC,CACI,CACF,CACM;AAEpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"PlotA11yView.js","names":["React","heavyFindNextFocusableElement","makeDataSummarizationConfig","getIntl","summarize","Root","sstyled","styles","_sstyled","insert","Box","useAsyncI18nMessages","localizedMessages","DataAccessibilityTable","PlotA11yView","_ref3","_ref","arguments[0]","_ref2","id","providedData","data","hints","plotLabel","plotRef","providedConfig","config","locale","SPlotA11yView","translations","intl","useMemo","Array","isArray","_React$useState","useState","_React$useState2","_slicedToArray","summary","setSummary","_React$useState3","_React$useState4","generatingSummary","setGeneratingSummary","useEffect","disable","override","setTimeout","handleSkip","useCallback","_heavyFindNextFocusab","current","focus","handleSkipKeyboard","event","key","preventDefault","handleGoToTable","_dataTableRef$current","dataTableRef","handleGoToTableKeyboard","texts","label","formatMessage","close","skipPlot","goToTable","summaryPlaceholder","table","useRef","createElement","cn","_objectSpread","_assignProps","concat"],"sources":["../../../src/a11y/PlotA11yView.tsx"],"sourcesContent":["import React from 'react';\nimport { heavyFindNextFocusableElement } from './focus';\nimport { makeDataSummarizationConfig } from './hints';\nimport type { A11yViewProps } from './PlotA11yModule';\nimport { getIntl } from './intl';\nimport { summarize } from './summarize';\nimport { Root, sstyled } from '@semcore/core';\nimport styles from '../style/plotA11yView.shadow.css';\nimport { Box } from '@semcore/flex-box';\nimport { useAsyncI18nMessages } from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { localizedMessages } from './translations/view/__intergalactic-dynamic-locales';\nimport { DataAccessibilityTable } from './DataAccessibilityTable';\n\nexport const PlotA11yView: React.FC<A11yViewProps> = ({\n id,\n data: providedData,\n hints,\n plotLabel,\n plotRef,\n config: providedConfig,\n locale,\n}) => {\n const SPlotA11yView = Root;\n const translations = useAsyncI18nMessages(localizedMessages, locale);\n const intl = React.useMemo(\n () => getIntl(locale, translations, localizedMessages),\n [locale, translations, localizedMessages],\n );\n const config = React.useMemo(() => makeDataSummarizationConfig(providedConfig), [providedConfig]);\n const data = React.useMemo(\n () => (Array.isArray(providedData) ? providedData : [providedData]),\n [providedData],\n );\n\n const [summary, setSummary] = React.useState<string | null>(null);\n const [generatingSummary, setGeneratingSummary] = React.useState(true);\n\n React.useEffect(() => {\n if (config.disable) {\n setSummary('');\n setGeneratingSummary(false);\n return;\n }\n if (config.override) {\n setSummary(config.override);\n setGeneratingSummary(false);\n return;\n }\n setTimeout(() => {\n setSummary(summarize(providedData, hints, config, locale, translations, localizedMessages));\n setGeneratingSummary(false);\n }, 0);\n }, [providedData, hints, config, locale, translations, localizedMessages]);\n\n const handleSkip = React.useCallback(() => {\n if (!plotRef.current) return;\n\n heavyFindNextFocusableElement(plotRef.current)?.focus();\n }, []);\n const handleSkipKeyboard = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (!(event.key === 'Enter' || event.key === ' ')) return;\n\n event.preventDefault();\n handleSkip();\n },\n [handleSkip],\n );\n const handleGoToTable = React.useCallback(() => {\n dataTableRef.current?.focus();\n }, []);\n const handleGoToTableKeyboard = React.useCallback(\n (event: React.KeyboardEvent) => {\n if (!(event.key === 'Enter' || event.key === ' ')) return;\n\n event.preventDefault();\n handleGoToTable();\n },\n [handleGoToTable],\n );\n\n const texts = React.useMemo(\n () => ({\n label: intl.formatMessage(\n { id: 'view-label' },\n { plotLabel: plotLabel ?? intl.formatMessage({ id: 'view-default-plot-label' }) },\n ),\n close: intl.formatMessage({ id: 'view-close' }),\n skipPlot: intl.formatMessage({ id: 'view-skip-plot' }),\n goToTable: intl.formatMessage({ id: 'view-go-to-table' }),\n summary: intl.formatMessage({ id: 'view-data-summary' }),\n summaryPlaceholder: intl.formatMessage({ id: 'view-summary-placeholder' }),\n table: intl.formatMessage({ id: 'view-table' }),\n }),\n [intl, plotLabel],\n );\n\n const dataTableRef = React.useRef<HTMLTableElement>(null);\n\n return sstyled(styles)(\n <SPlotA11yView render={Box} tabIndex={0} aria-label={texts.label}>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a aria-hidden onClick={handleSkip}>\n {texts.close}\n </a>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a role='link' tabIndex={0} onKeyDown={handleSkipKeyboard} onClick={handleSkip}>\n {texts.skipPlot}\n </a>\n {/* biome-ignore lint/a11y/useValidAnchor: */}\n <a role='link' tabIndex={0} onKeyDown={handleGoToTableKeyboard} onClick={handleGoToTable}>\n {texts.goToTable}\n </a>\n <strong>\n <label htmlFor={`${id}-data-summary`}>{texts.summary}</label>\n </strong>\n <div id={`${id}-data-summary`} aria-busy={generatingSummary} tabIndex={0}>\n {generatingSummary ? texts.summaryPlaceholder : summary}\n </div>\n <strong>\n <label htmlFor={`${id}-data-table`}>{texts.table}</label>\n </strong>\n <DataAccessibilityTable\n id={id}\n dataTableRef={dataTableRef}\n data={data}\n hints={hints}\n config={config}\n intl={intl}\n />\n </SPlotA11yView>,\n ) as React.ReactElement;\n};\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,6BAA6B,QAAQ,SAAS;AACvD,SAASC,2BAA2B,QAAQ,SAAS;AAErD,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,IAAI,EAAEC,OAAO,QAAQ,eAAe;AAAC;AAAA,IAAAC,MAAA,+BAAAC,QAAA,CAAAC,MAAA;EAAA;AAAA;AAE9C,SAASC,GAAG,QAAQ,mBAAmB;AACvC,SAASC,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D,EAAA;IAAA,SAAAG,MAAA,CAAYvD,EAAE;IAAA,aAA4BuB,iBAAiB;IAAA,YAAY;EAAC,IACrEA,iBAAiB,GAAGmB,KAAK,CAACM,kBAAkB,GAAG7B,OAAO,CACnD,eACNtC,KAAA,CAAAsE,aAAA,WAAApD,KAAA,CAAAqD,EAAA,6BACEvE,KAAA,CAAAsE,aAAA,UAAApD,KAAA,CAAAqD,EAAA;IAAA,cAAAG,MAAA,CAAmBvD,EAAE;EAAA,IAAgB0C,KAAK,CAACO,KAAK,CAAS,CAClD,eACTpE,KAAA,CAAAsE,aAAA,CAACzD,sBAAsB,EAAAK,KAAA,CAAAqD,EAAA;IAAA,MACjBpD,EAAE;IAAA,gBACQwC,YAAY;IAAA,QACpBtC,IAAI;IAAA,SACHC,KAAK;IAAA,UACJI,MAAM;IAAA,QACRI;EAAI,GACV,CACY;AAEpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hints.js","names":["reactToText","makeDataHintsContainer","fields","verticalAxes","Set","horizontalAxes","valueAxes","values","groups","axesTitle","vertical","horizontal","titles","getVerticalAxesTitle","getHorizontalAxesTitle","valuesAxes","getValueAxesTitle","grid","dataType","pointsDensity","makeDataHintsHandlers","mutableContainer","handler","specifyDataRowFields","x","y","value","add","setupGrid","direction","size","establishDataType","describeValueEntity","dataKey","readableName","labelKey","describeGroupedValues","groupKey","axes","label","addKeyLabelGetter","getter","setTitle","describedDataAxes","title","_typeof","Date","String","setPointsDensity","makeDataSummarizationConfig","config","_config$trendTangens","_config$movingAverage","_config$additionalFie","_objectSpread","clustersGridSize","undefined","maxListSymbols","datesWithTime","clustersLimit","valuesLimit","groupsLimit","disable","override","trendTangens","weak","medium","strong","Infinity","movingAverage","longSize","shortSize","notableDiff","additionalFields","_toConsumableArray"],"sources":["../../../src/a11y/hints.ts"],"sourcesContent":["import { SerializableDataType } from './insights';\nimport reactToText from '@semcore/utils/lib/reactToText';\n\ntype DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>;\n }\n : T;\n\nexport type DataStructureHints = {\n fields: {\n verticalAxes: Set<string | number>;\n horizontalAxes: Set<string | number>;\n valueAxes: Set<string | number>;\n values: Set<string | number>;\n };\n groups: Set<string | number>;\n axesTitle: {\n vertical: string | null;\n horizontal: string | null;\n };\n titles: {\n verticalAxes: {\n [dataKey: string | number]: string;\n };\n getVerticalAxesTitle: null | ((dataKey: string | number) => string);\n horizontalAxes: {\n [dataKey: string | number]: string;\n };\n getHorizontalAxesTitle: null | ((dataKey: string | number) => string);\n valuesAxes: {\n [dataKey: string | number]: string;\n };\n getValueAxesTitle: null | ((dataKey: string | number) => string);\n };\n grid: {\n verticalAxes: number | null;\n horizontalAxes: number | null;\n };\n pointsDensity: {\n verticalAxes: number;\n horizontalAxes: number;\n } | null;\n dataType: SerializableDataType | null;\n};\nexport type DataSummarizationConfig = {\n trendTangens: {\n static: number;\n weak: number;\n medium: number;\n strong: number;\n };\n movingAverage: {\n longSize: number | undefined;\n shortSize: number | undefined;\n notableDiff: number | undefined;\n };\n dataType: SerializableDataType | undefined;\n clustersGridSize: number | undefined;\n maxListSymbols: number;\n datesWithTime: boolean | undefined;\n clustersLimit: number;\n valuesLimit: number;\n groupsLimit: number;\n disable: boolean;\n override: string | undefined;\n additionalFields: string[];\n};\nexport type PartialDataSummarizationConfig = DeepPartial<DataSummarizationConfig>;\n\nexport const makeDataHintsContainer = (): DataStructureHints => ({\n fields: {\n verticalAxes: new Set(),\n horizontalAxes: new Set(),\n valueAxes: new Set(),\n values: new Set(),\n },\n groups: new Set(),\n axesTitle: {\n vertical: null,\n horizontal: null,\n },\n titles: {\n verticalAxes: {},\n getVerticalAxesTitle: null,\n horizontalAxes: {},\n getHorizontalAxesTitle: null,\n valuesAxes: {},\n getValueAxesTitle: null,\n },\n grid: {\n verticalAxes: null,\n horizontalAxes: null,\n },\n dataType: null,\n pointsDensity: null,\n});\n\nexport const makeDataHintsHandlers = (mutableContainer: DataStructureHints) => {\n const handler = {\n specifyDataRowFields: (x?: string, y?: string, value?: string) => {\n if (y) mutableContainer.fields.verticalAxes.add(y);\n if (x) mutableContainer.fields.horizontalAxes.add(x);\n if (value) mutableContainer.fields.valueAxes.add(value);\n },\n setupGrid: (direction: 'vertical' | 'horizontal', size: number) => {\n if (direction === 'horizontal') {\n mutableContainer.grid.horizontalAxes = size;\n } else if (direction === 'vertical') {\n mutableContainer.grid.verticalAxes = size;\n }\n },\n establishDataType: (dataType: SerializableDataType) => {\n mutableContainer.dataType = dataType;\n },\n describeValueEntity: (dataKey: string | number, readableName: string) => {\n mutableContainer.fields.values.add(dataKey);\n handler.labelKey('value', dataKey, readableName);\n },\n describeGroupedValues: (groupKey: string | number, dataKey: string | number) => {\n mutableContainer.groups.add(groupKey);\n mutableContainer.fields.values.add(dataKey);\n },\n labelKey: (\n axes: 'vertical' | 'horizontal' | 'value',\n dataKey: string | number,\n label: string,\n ) => {\n if (axes === 'vertical') mutableContainer.titles.verticalAxes[dataKey] = label;\n if (axes === 'horizontal') mutableContainer.titles.horizontalAxes[dataKey] = label;\n if (axes === 'value') mutableContainer.titles.valuesAxes[dataKey] = label;\n },\n addKeyLabelGetter: (\n axes: 'vertical' | 'horizontal' | 'value',\n getter: (dataKey: string | number) => string,\n ) => {\n if (axes === 'vertical') mutableContainer.titles.getVerticalAxesTitle = getter;\n if (axes === 'horizontal') mutableContainer.titles.getHorizontalAxesTitle = getter;\n if (axes === 'value') mutableContainer.titles.getValueAxesTitle = getter;\n },\n setTitle: (describedDataAxes: 'vertical' | 'horizontal', title: string) => {\n if (\n typeof title === 'number' ||\n typeof title === 'bigint' ||\n (typeof title === 'object' && (title as any) instanceof Date)\n ) {\n title = String(title);\n }\n if (typeof title !== 'string') {\n title = reactToText(title);\n }\n if (describedDataAxes === 'horizontal') {\n mutableContainer.axesTitle.horizontal = title;\n } else if (describedDataAxes === 'vertical') {\n mutableContainer.axesTitle.vertical = title;\n }\n },\n setPointsDensity: (horizontalAxes: number, verticalAxes: number) => {\n mutableContainer.pointsDensity = { verticalAxes, horizontalAxes };\n },\n };\n return handler;\n};\n\nexport type DataHintsHandler = ReturnType<typeof makeDataHintsHandlers>;\n\nexport const makeDataSummarizationConfig = (\n config?: PartialDataSummarizationConfig,\n): DataSummarizationConfig => ({\n clustersGridSize: undefined,\n maxListSymbols: 100,\n datesWithTime: undefined,\n clustersLimit: 5,\n valuesLimit: 5,\n groupsLimit: 5,\n dataType: undefined,\n disable: false,\n override: undefined,\n ...(config ?? {}),\n trendTangens: {\n static: 1 / 15,\n weak: 1 / 10,\n medium: 1 / 5,\n strong: Infinity,\n ...(config?.trendTangens ?? {}),\n },\n movingAverage: {\n longSize: undefined,\n shortSize: undefined,\n notableDiff: undefined,\n ...(config?.movingAverage ?? {}),\n },\n additionalFields: [...(config?.additionalFields ?? [])] as string[],\n});\n"],"mappings":";;;AACA,OAAOA,WAAW,MAAM,gCAAgC;AAqExD,OAAO,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAA;EAAA,OAA8B;IAC/DC,MAAM,EAAE;MACNC,YAAY,EAAE,IAAIC,GAAG,EAAE;MACvBC,cAAc,EAAE,IAAID,GAAG,EAAE;MACzBE,SAAS,EAAE,IAAIF,GAAG,EAAE;MACpBG,MAAM,EAAE,IAAIH,GAAG;IACjB,CAAC;IACDI,MAAM,EAAE,IAAIJ,GAAG,EAAE;IACjBK,SAAS,EAAE;MACTC,QAAQ,EAAE,IAAI;MACdC,UAAU,EAAE;IACd,CAAC;IACDC,MAAM,EAAE;MACNT,YAAY,EAAE,CAAC,CAAC;MAChBU,oBAAoB,EAAE,IAAI;MAC1BR,cAAc,EAAE,CAAC,CAAC;MAClBS,sBAAsB,EAAE,IAAI;MAC5BC,UAAU,EAAE,CAAC,CAAC;MACdC,iBAAiB,EAAE;IACrB,CAAC;IACDC,IAAI,EAAE;MACJd,YAAY,EAAE,IAAI;MAClBE,cAAc,EAAE;IAClB,CAAC;IACDa,QAAQ,EA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AM,aAANA,MAAM,uBAANA,MAAM,CAAEmB,aAAa,cAAAjB,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,CAChC;IACDqB,gBAAgB,EAAAC,kBAAA,EAAArB,qBAAA,GAAOH,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEuB,gBAAgB,cAAApB,qBAAA,cAAAA,qBAAA,GAAI,EAAE;EAAc;AAAA,CACnE"}
|
|
1
|
+
{"version":3,"file":"hints.js","names":["reactToText","makeDataHintsContainer","fields","verticalAxes","Set","horizontalAxes","valueAxes","values","groups","axesTitle","vertical","horizontal","titles","getVerticalAxesTitle","getHorizontalAxesTitle","valuesAxes","getValueAxesTitle","grid","dataType","pointsDensity","makeDataHintsHandlers","mutableContainer","handler","specifyDataRowFields","x","y","value","add","setupGrid","direction","size","establishDataType","describeValueEntity","dataKey","readableName","labelKey","describeGroupedValues","groupKey","axes","label","addKeyLabelGetter","getter","setTitle","describedDataAxes","title","_typeof","Date","String","setPointsDensity","makeDataSummarizationConfig","config","_config$trendTangens","_config$movingAverage","_config$additionalFie","_objectSpread","clustersGridSize","undefined","maxListSymbols","datesWithTime","clustersLimit","valuesLimit","groupsLimit","disable","override","trendTangens","weak","medium","strong","Infinity","movingAverage","longSize","shortSize","notableDiff","additionalFields","_toConsumableArray"],"sources":["../../../src/a11y/hints.ts"],"sourcesContent":["import { SerializableDataType } from './insights';\nimport reactToText from '@semcore/utils/lib/reactToText';\n\ntype DeepPartial<T> = T extends object\n ? {\n [P in keyof T]?: DeepPartial<T[P]>;\n }\n : T;\n\nexport type DataStructureHints = {\n fields: {\n verticalAxes: Set<string | number>;\n horizontalAxes: Set<string | number>;\n valueAxes: Set<string | number>;\n values: Set<string | number>;\n };\n groups: Set<string | number>;\n axesTitle: {\n vertical: string | null;\n horizontal: string | null;\n };\n titles: {\n verticalAxes: {\n [dataKey: string | number]: string;\n };\n getVerticalAxesTitle: null | ((dataKey: string | number) => string);\n horizontalAxes: {\n [dataKey: string | number]: string;\n };\n getHorizontalAxesTitle: null | ((dataKey: string | number) => string);\n valuesAxes: {\n [dataKey: string | number]: string;\n };\n getValueAxesTitle: null | ((dataKey: string | number) => string);\n };\n grid: {\n verticalAxes: number | null;\n horizontalAxes: number | null;\n };\n pointsDensity: {\n verticalAxes: number;\n horizontalAxes: number;\n } | null;\n dataType: SerializableDataType | null;\n};\nexport type DataSummarizationConfig = {\n trendTangens: {\n static: number;\n weak: number;\n medium: number;\n strong: number;\n };\n movingAverage: {\n longSize: number | undefined;\n shortSize: number | undefined;\n notableDiff: number | undefined;\n };\n dataType: SerializableDataType | undefined;\n clustersGridSize: number | undefined;\n maxListSymbols: number;\n datesWithTime: boolean | undefined;\n clustersLimit: number;\n valuesLimit: number;\n groupsLimit: number;\n disable: boolean;\n override: string | undefined;\n additionalFields: string[];\n titlesFormatter?: (key: string | number | null) => string | undefined;\n valuesFormatter?: (value: unknown, key: string | number | null) => string | undefined;\n};\nexport type PartialDataSummarizationConfig = DeepPartial<\n Omit<DataSummarizationConfig, 'titlesFormatter' | 'valuesFormatter'>\n> & {\n titlesFormatter?: (key: string | number | null) => string | undefined;\n valuesFormatter?: (value: unknown, key: string | number | null) => string | undefined;\n};\n\nexport const makeDataHintsContainer = (): DataStructureHints => ({\n fields: {\n verticalAxes: new Set(),\n horizontalAxes: new Set(),\n valueAxes: new Set(),\n values: new Set(),\n },\n groups: new Set(),\n axesTitle: {\n vertical: null,\n horizontal: null,\n },\n titles: {\n verticalAxes: {},\n getVerticalAxesTitle: null,\n horizontalAxes: {},\n getHorizontalAxesTitle: null,\n valuesAxes: {},\n getValueAxesTitle: null,\n },\n grid: {\n verticalAxes: null,\n horizontalAxes: null,\n },\n dataType: null,\n pointsDensity: null,\n});\n\nexport const makeDataHintsHandlers = (mutableContainer: DataStructureHints) => {\n const handler = {\n specifyDataRowFields: (x?: string, y?: string, value?: string) => {\n if (y) mutableContainer.fields.verticalAxes.add(y);\n if (x) mutableContainer.fields.horizontalAxes.add(x);\n if (value) mutableContainer.fields.valueAxes.add(value);\n },\n setupGrid: (direction: 'vertical' | 'horizontal', size: number) => {\n if (direction === 'horizontal') {\n mutableContainer.grid.horizontalAxes = size;\n } else if (direction === 'vertical') {\n mutableContainer.grid.verticalAxes = size;\n }\n },\n establishDataType: (dataType: SerializableDataType) => {\n mutableContainer.dataType = dataType;\n },\n describeValueEntity: (dataKey: string | number, readableName: string) => {\n mutableContainer.fields.values.add(dataKey);\n handler.labelKey('value', dataKey, readableName);\n },\n describeGroupedValues: (groupKey: string | number, dataKey: string | number) => {\n mutableContainer.groups.add(groupKey);\n mutableContainer.fields.values.add(dataKey);\n },\n labelKey: (\n axes: 'vertical' | 'horizontal' | 'value',\n dataKey: string | number,\n label: string,\n ) => {\n if (axes === 'vertical') mutableContainer.titles.verticalAxes[dataKey] = label;\n if (axes === 'horizontal') mutableContainer.titles.horizontalAxes[dataKey] = label;\n if (axes === 'value') mutableContainer.titles.valuesAxes[dataKey] = label;\n },\n addKeyLabelGetter: (\n axes: 'vertical' | 'horizontal' | 'value',\n getter: (dataKey: string | number) => string,\n ) => {\n if (axes === 'vertical') mutableContainer.titles.getVerticalAxesTitle = getter;\n if (axes === 'horizontal') mutableContainer.titles.getHorizontalAxesTitle = getter;\n if (axes === 'value') mutableContainer.titles.getValueAxesTitle = getter;\n },\n setTitle: (describedDataAxes: 'vertical' | 'horizontal', title: string) => {\n if (\n typeof title === 'number' ||\n typeof title === 'bigint' ||\n (typeof title === 'object' && (title as any) instanceof Date)\n ) {\n title = String(title);\n }\n if (typeof title !== 'string') {\n title = reactToText(title);\n }\n if (describedDataAxes === 'horizontal') {\n mutableContainer.axesTitle.horizontal = title;\n } else if (describedDataAxes === 'vertical') {\n mutableContainer.axesTitle.vertical = title;\n }\n },\n setPointsDensity: (horizontalAxes: number, verticalAxes: number) => {\n mutableContainer.pointsDensity = { verticalAxes, horizontalAxes };\n },\n };\n return handler;\n};\n\nexport type DataHintsHandler = ReturnType<typeof makeDataHintsHandlers>;\n\nexport const makeDataSummarizationConfig = (\n config?: PartialDataSummarizationConfig,\n): DataSummarizationConfig => ({\n clustersGridSize: undefined,\n maxListSymbols: 100,\n datesWithTime: undefined,\n clustersLimit: 5,\n valuesLimit: 5,\n groupsLimit: 5,\n dataType: undefined,\n disable: false,\n override: undefined,\n ...(config ?? {}),\n trendTangens: {\n static: 1 / 15,\n weak: 1 / 10,\n medium: 1 / 5,\n strong: Infinity,\n ...(config?.trendTangens ?? {}),\n },\n movingAverage: {\n longSize: undefined,\n shortSize: undefined,\n notableDiff: undefined,\n ...(config?.movingAverage ?? {}),\n },\n additionalFields: [...(config?.additionalFields ?? [])] as string[],\n});\n"],"mappings":";;;AACA,OAAOA,WAAW,MAAM,gCAAgC;AA4ExD,OAAO,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAA;EAAA,OAA8B;IAC/DC,MAAM,EAAE;MACNC,YAAY,EAAE,IAAIC,GAAG,EAAE;MACvBC,cAAc,EAAE,IAAID,GAAG,EAAE;MACzBE,SAAS,EAAE,IAAIF,GAAG,EAAE;MACpBG,MAAM,EAAE,IAAIH,GAAG;IACjB,CAAC;IACDI,MAAM,EAAE,IAAIJ,GAAG,EAAE;IACjBK,SAAS,EAAE;MACTC,QAAQ,EAAE,IAAI;MACdC,UAAU,EAAE;IACd,CAAC;IACDC,MAAM,EAAE;MACNT,YAAY,EAAE,CAAC,CAAC;MAChBU,oBAAoB,EAAE,IAAI;MAC1BR,cAAc,EAAE,CAAC,CAAC;MAClBS,sBAAsB,EAAE,IAAI;MAC5BC,UAAU,EAAE,CAAC,CAAC;MACdC,iBAAiB,EAAE;IACrB,CAAC;IACDC,IAAI,EAAE;MACJd,YAAY,EAAE,IAAI;MAClBE,cAAc,EAAE;IAClB,CAAC;IACDa,QAAQ,EAAE,IAAI;IACdC,aAAa,EAAE;EACjB,CAAC;AAAA,CAAC;AAEF,OAAO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIC,gBAAoC,EAAK;EAC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AAArB,qBAAA,GAAOH,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEuB,gBAAgB,cAAApB,qBAAA,cAAAA,qBAAA,GAAI,EAAE;EAAc;AAAA,CACnE"}
|
|
@@ -44,14 +44,14 @@ var isReactComponent = function isReactComponent(obj) {
|
|
|
44
44
|
return _typeof(obj) === 'object' && obj && 'displayName' in obj && typeof obj.displayName === 'string';
|
|
45
45
|
};
|
|
46
46
|
var guessNumberAsTimestampMinDate = new Date('1975').getTime();
|
|
47
|
-
export var
|
|
47
|
+
export var defaultValueFormatter = function defaultValueFormatter(intl, value) {
|
|
48
48
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
49
49
|
siblingsTimeMark = _ref.siblingsTimeMark,
|
|
50
50
|
maxListSymbols = _ref.maxListSymbols,
|
|
51
51
|
datesWithTime = _ref.datesWithTime;
|
|
52
52
|
if (typeof value === 'number') {
|
|
53
53
|
if (value >= guessNumberAsTimestampMinDate) {
|
|
54
|
-
return
|
|
54
|
+
return defaultValueFormatter(intl, new Date(value), {
|
|
55
55
|
siblingsTimeMark: siblingsTimeMark,
|
|
56
56
|
maxListSymbols: maxListSymbols,
|
|
57
57
|
datesWithTime: datesWithTime
|
|
@@ -72,7 +72,7 @@ export var formatValue = function formatValue(intl, value) {
|
|
|
72
72
|
}
|
|
73
73
|
if (Array.isArray(value)) {
|
|
74
74
|
var formattedValues = value.map(function (subValue) {
|
|
75
|
-
return
|
|
75
|
+
return defaultValueFormatter(intl, subValue, {
|
|
76
76
|
siblingsTimeMark: siblingsTimeMark,
|
|
77
77
|
maxListSymbols: maxListSymbols,
|
|
78
78
|
datesWithTime: datesWithTime
|
|
@@ -99,7 +99,7 @@ var formatValuesList = function formatValuesList(values, _ref2) {
|
|
|
99
99
|
var rawValue = _ref3.value,
|
|
100
100
|
label = _ref3.label;
|
|
101
101
|
if (rawValue === undefined) return label;
|
|
102
|
-
var value =
|
|
102
|
+
var value = defaultValueFormatter(intl, rawValue, {
|
|
103
103
|
datesWithTime: datesWithTime,
|
|
104
104
|
maxListSymbols: maxListSymbols
|
|
105
105
|
});
|
|
@@ -130,19 +130,22 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
130
130
|
maxListSymbols = _ref5.maxListSymbols,
|
|
131
131
|
clustersLimit = _ref5.clustersLimit,
|
|
132
132
|
valuesLimit = _ref5.valuesLimit,
|
|
133
|
-
groupsLimit = _ref5.groupsLimit
|
|
133
|
+
groupsLimit = _ref5.groupsLimit,
|
|
134
|
+
titlesFormatter = _ref5.titlesFormatter,
|
|
135
|
+
valuesFormatter = _ref5.valuesFormatter;
|
|
134
136
|
var locale = _ref6.locale,
|
|
135
137
|
translations = _ref6.translations,
|
|
136
138
|
availableLocales = _ref6.availableLocales;
|
|
137
139
|
if (insights.length === 0) return null;
|
|
138
140
|
var intl = getIntl(locale, translations, availableLocales);
|
|
139
141
|
var dataRangeSummary = intl.formatList(dataRange.map(function (range) {
|
|
140
|
-
var
|
|
142
|
+
var _valuesFormatter, _valuesFormatter2, _titlesFormatter;
|
|
143
|
+
var from = (_valuesFormatter = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(range.from, range.label)) !== null && _valuesFormatter !== void 0 ? _valuesFormatter : defaultValueFormatter(intl, range.from, {
|
|
141
144
|
siblingsTimeMark: range.to,
|
|
142
145
|
datesWithTime: datesWithTime,
|
|
143
146
|
maxListSymbols: maxListSymbols
|
|
144
147
|
});
|
|
145
|
-
var to =
|
|
148
|
+
var to = (_valuesFormatter2 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(range.to, range.label)) !== null && _valuesFormatter2 !== void 0 ? _valuesFormatter2 : defaultValueFormatter(intl, range.to, {
|
|
146
149
|
siblingsTimeMark: range.from,
|
|
147
150
|
datesWithTime: datesWithTime,
|
|
148
151
|
maxListSymbols: maxListSymbols
|
|
@@ -152,10 +155,11 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
152
155
|
}, {
|
|
153
156
|
from: from,
|
|
154
157
|
to: to,
|
|
155
|
-
label: range.label
|
|
158
|
+
label: (_titlesFormatter = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(range.label)) !== null && _titlesFormatter !== void 0 ? _titlesFormatter : range.label
|
|
156
159
|
});
|
|
157
160
|
}));
|
|
158
161
|
if (dataType === 'time-series') {
|
|
162
|
+
var _titlesFormatter3;
|
|
159
163
|
var trendsInsights = insights;
|
|
160
164
|
var trendsByDataKey = {};
|
|
161
165
|
var _iterator = _createForOfIteratorHelper(trendsInsights),
|
|
@@ -178,7 +182,7 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
178
182
|
count: entitiesCount
|
|
179
183
|
});
|
|
180
184
|
var entitiesList = Object.entries(trendsByDataKey).map(function (_ref7) {
|
|
181
|
-
var _primaryTrend$label;
|
|
185
|
+
var _primaryTrend$label, _titlesFormatter2, _valuesFormatter3, _valuesFormatter4;
|
|
182
186
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
183
187
|
dataKey = _ref8[0],
|
|
184
188
|
insights = _ref8[1];
|
|
@@ -192,43 +196,45 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
192
196
|
var secondaryTrends = insights.filter(function (insight) {
|
|
193
197
|
return insight !== primaryTrend;
|
|
194
198
|
});
|
|
199
|
+
var summaryDataKey = entitiesCount !== 1 ? (_primaryTrend$label = primaryTrend.label) !== null && _primaryTrend$label !== void 0 ? _primaryTrend$label : dataKey : '';
|
|
195
200
|
var mainSummary = intl.formatMessage({
|
|
196
201
|
id: 'time-series-general-trend'
|
|
197
202
|
}, {
|
|
198
|
-
dataKey:
|
|
203
|
+
dataKey: (_titlesFormatter2 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(summaryDataKey)) !== null && _titlesFormatter2 !== void 0 ? _titlesFormatter2 : summaryDataKey,
|
|
199
204
|
trend: intl.formatMessage({
|
|
200
205
|
id: "trend-".concat(primaryTrend.change.strength)
|
|
201
206
|
}),
|
|
202
|
-
from: intl.formatNumber(primaryTrend.change.from),
|
|
203
|
-
to: intl.formatNumber(primaryTrend.change.to)
|
|
207
|
+
from: (_valuesFormatter3 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(primaryTrend.change.from, dataKey)) !== null && _valuesFormatter3 !== void 0 ? _valuesFormatter3 : intl.formatNumber(primaryTrend.change.from),
|
|
208
|
+
to: (_valuesFormatter4 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(primaryTrend.change.to, dataKey)) !== null && _valuesFormatter4 !== void 0 ? _valuesFormatter4 : intl.formatNumber(primaryTrend.change.to)
|
|
204
209
|
});
|
|
205
|
-
var
|
|
210
|
+
var secondarySummaries = secondaryTrends.map(function (trend) {
|
|
211
|
+
var _valuesFormatter5, _valuesFormatter6;
|
|
206
212
|
return intl.formatMessage({
|
|
207
213
|
id: 'time-series-local-trend'
|
|
208
214
|
}, {
|
|
209
215
|
trend: intl.formatMessage({
|
|
210
216
|
id: "trend-".concat(trend.change.strength)
|
|
211
217
|
}),
|
|
212
|
-
from:
|
|
218
|
+
from: (_valuesFormatter5 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(trend.from, trend.dataKey)) !== null && _valuesFormatter5 !== void 0 ? _valuesFormatter5 : defaultValueFormatter(intl, trend.from, {
|
|
213
219
|
siblingsTimeMark: trend.to,
|
|
214
220
|
datesWithTime: datesWithTime,
|
|
215
221
|
maxListSymbols: maxListSymbols
|
|
216
222
|
}),
|
|
217
|
-
to:
|
|
223
|
+
to: (_valuesFormatter6 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(trend.to, trend.dataKey)) !== null && _valuesFormatter6 !== void 0 ? _valuesFormatter6 : defaultValueFormatter(intl, trend.to, {
|
|
218
224
|
siblingsTimeMark: trend.from,
|
|
219
225
|
datesWithTime: datesWithTime,
|
|
220
226
|
maxListSymbols: maxListSymbols
|
|
221
227
|
})
|
|
222
228
|
});
|
|
223
229
|
});
|
|
224
|
-
if (
|
|
230
|
+
if (secondarySummaries.length === 0) {
|
|
225
231
|
return mainSummary;
|
|
226
232
|
}
|
|
227
233
|
return intl.formatMessage({
|
|
228
234
|
id: 'time-series-detailed-trend'
|
|
229
235
|
}, {
|
|
230
236
|
general: mainSummary,
|
|
231
|
-
locals: formatLimitedSizeList(
|
|
237
|
+
locals: formatLimitedSizeList(secondarySummaries, intl, 400, false)
|
|
232
238
|
});
|
|
233
239
|
});
|
|
234
240
|
var summary = intl.formatMessage({
|
|
@@ -236,13 +242,14 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
236
242
|
}, {
|
|
237
243
|
entities: entities,
|
|
238
244
|
entitiesList: intl.formatList(entitiesList),
|
|
239
|
-
label: dataTitle
|
|
245
|
+
label: (_titlesFormatter3 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(dataTitle)) !== null && _titlesFormatter3 !== void 0 ? _titlesFormatter3 : dataTitle
|
|
240
246
|
});
|
|
241
247
|
if (dataRangeSummary.length > 0) {
|
|
242
248
|
return "".concat(summary, "\n").concat(dataRangeSummary);
|
|
243
249
|
}
|
|
244
250
|
return summary;
|
|
245
251
|
} else if (dataType === 'points-cloud') {
|
|
252
|
+
var _titlesFormatter7;
|
|
246
253
|
var clustersInsights = insights;
|
|
247
254
|
var biggestClusters = clustersInsights.slice(0, clustersLimit);
|
|
248
255
|
var maxSize = clustersInsights[0].size;
|
|
@@ -260,7 +267,11 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
260
267
|
minSize: minSize
|
|
261
268
|
});
|
|
262
269
|
var _entitiesList = biggestClusters.map(function (clusterInsight) {
|
|
263
|
-
var
|
|
270
|
+
var _valuesFormatter7, _titlesFormatter5, _valuesFormatter8, _titlesFormatter6;
|
|
271
|
+
var labels = formatLimitedSizeList(clusterInsight.labels.map(function (label) {
|
|
272
|
+
var _titlesFormatter4;
|
|
273
|
+
return (_titlesFormatter4 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(label)) !== null && _titlesFormatter4 !== void 0 ? _titlesFormatter4 : label;
|
|
274
|
+
}), intl, maxListSymbols);
|
|
264
275
|
var anonymous = clusterInsight.labels.length === 0 || labels === String(clusterInsight.size);
|
|
265
276
|
return intl.formatMessage({
|
|
266
277
|
id: anonymous ? 'entity-type-clusters-label-anonymous' : 'entity-type-clusters-label'
|
|
@@ -270,10 +281,10 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
270
281
|
}),
|
|
271
282
|
labels: labels,
|
|
272
283
|
size: clusterInsight.size,
|
|
273
|
-
x: intl.formatNumber(clusterInsight.center.x),
|
|
274
|
-
xLabel: clusterInsight.center.xLabel,
|
|
275
|
-
y: intl.formatNumber(clusterInsight.center.y),
|
|
276
|
-
yLabel: clusterInsight.center.yLabel
|
|
284
|
+
x: (_valuesFormatter7 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(clusterInsight.center.x, clusterInsight.labels)) !== null && _valuesFormatter7 !== void 0 ? _valuesFormatter7 : intl.formatNumber(clusterInsight.center.x),
|
|
285
|
+
xLabel: (_titlesFormatter5 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(clusterInsight.center.xLabel)) !== null && _titlesFormatter5 !== void 0 ? _titlesFormatter5 : clusterInsight.center.xLabel,
|
|
286
|
+
y: (_valuesFormatter8 = valuesFormatter === null || valuesFormatter === void 0 ? void 0 : valuesFormatter(clusterInsight.center.y, clusterInsight.labels)) !== null && _valuesFormatter8 !== void 0 ? _valuesFormatter8 : intl.formatNumber(clusterInsight.center.y),
|
|
287
|
+
yLabel: (_titlesFormatter6 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(clusterInsight.center.yLabel)) !== null && _titlesFormatter6 !== void 0 ? _titlesFormatter6 : clusterInsight.center.yLabel
|
|
277
288
|
});
|
|
278
289
|
});
|
|
279
290
|
if (insights.length > clustersLimit) {
|
|
@@ -288,13 +299,14 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
288
299
|
}, {
|
|
289
300
|
entities: _entities,
|
|
290
301
|
entitiesList: intl.formatList(_entitiesList),
|
|
291
|
-
label: dataTitle
|
|
302
|
+
label: (_titlesFormatter7 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(dataTitle)) !== null && _titlesFormatter7 !== void 0 ? _titlesFormatter7 : dataTitle
|
|
292
303
|
});
|
|
293
304
|
if (dataRangeSummary.length > 0) {
|
|
294
305
|
return "".concat(_summary, "\n").concat(dataRangeSummary);
|
|
295
306
|
}
|
|
296
307
|
return _summary;
|
|
297
308
|
} else if (dataType === 'values-set') {
|
|
309
|
+
var _titlesFormatter8;
|
|
298
310
|
var _ref9 = insights,
|
|
299
311
|
_ref10 = _slicedToArray(_ref9, 1),
|
|
300
312
|
valuesInsight = _ref10[0];
|
|
@@ -314,9 +326,10 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
314
326
|
}, {
|
|
315
327
|
entities: _entities2,
|
|
316
328
|
entitiesList: _entitiesList2,
|
|
317
|
-
label: dataTitle
|
|
329
|
+
label: (_titlesFormatter8 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(dataTitle)) !== null && _titlesFormatter8 !== void 0 ? _titlesFormatter8 : dataTitle
|
|
318
330
|
});
|
|
319
331
|
} else if (dataType === 'grouped-values' || dataType === 'indexed-groups') {
|
|
332
|
+
var _titlesFormatter9;
|
|
320
333
|
var groupInsights = insights;
|
|
321
334
|
var valueCounts = groupInsights.map(function (group) {
|
|
322
335
|
return group.values.length;
|
|
@@ -358,14 +371,14 @@ export var serialize = function serialize(_ref4, _ref5, _ref6) {
|
|
|
358
371
|
leftCount: groupInsights.values.length - groupsLimit
|
|
359
372
|
}));
|
|
360
373
|
}
|
|
361
|
-
var
|
|
374
|
+
var _summary2 = intl.formatMessage({
|
|
362
375
|
id: dataTitle ? 'chart-summary' : 'chart-summary-no-label'
|
|
363
376
|
}, {
|
|
364
377
|
entities: _entities3,
|
|
365
378
|
entitiesList: intl.formatList(_entitiesList3),
|
|
366
|
-
label: dataTitle
|
|
379
|
+
label: (_titlesFormatter9 = titlesFormatter === null || titlesFormatter === void 0 ? void 0 : titlesFormatter(dataTitle)) !== null && _titlesFormatter9 !== void 0 ? _titlesFormatter9 : dataTitle
|
|
367
380
|
});
|
|
368
|
-
return
|
|
381
|
+
return _summary2;
|
|
369
382
|
}
|
|
370
383
|
return null;
|
|
371
384
|
};
|