@react-magma/charts 13.3.0 → 13.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.js +114 -76
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +114 -76
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +278 -105
- package/dist/charts.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CarbonChart/CarbonChart.test.js +27 -19
- package/src/components/CarbonChart/CarbonChart.tsx +138 -84
package/dist/charts.js
CHANGED
|
@@ -3080,86 +3080,16 @@ var CarbonChart = React__namespace.forwardRef(function (props, ref) {
|
|
|
3080
3080
|
});
|
|
3081
3081
|
return function () { return cancelAnimationFrame(rafId); };
|
|
3082
3082
|
}, [ariaLabel]);
|
|
3083
|
-
// Make Carbon Charts data points keyboard-focusable.
|
|
3084
|
-
React__namespace.useEffect(function () {
|
|
3085
|
-
var wrapper = internalRef.current;
|
|
3086
|
-
if (!wrapper)
|
|
3087
|
-
return;
|
|
3088
|
-
var isDot = function (el) {
|
|
3089
|
-
return el instanceof Element &&
|
|
3090
|
-
el.nodeName.toLowerCase() === 'circle' &&
|
|
3091
|
-
el.classList.contains('dot');
|
|
3092
|
-
};
|
|
3093
|
-
var onFocusIn = function (e) {
|
|
3094
|
-
if (!isDot(e.target))
|
|
3095
|
-
return;
|
|
3096
|
-
var dot = e.target;
|
|
3097
|
-
dot.style.opacity = '1';
|
|
3098
|
-
var _a = dot.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;
|
|
3099
|
-
var cx = left + width / 2;
|
|
3100
|
-
var cy = top + height / 2;
|
|
3101
|
-
dot.dispatchEvent(new MouseEvent('mouseover', {
|
|
3102
|
-
bubbles: true,
|
|
3103
|
-
clientX: cx,
|
|
3104
|
-
clientY: cy,
|
|
3105
|
-
screenX: cx,
|
|
3106
|
-
screenY: cy,
|
|
3107
|
-
}));
|
|
3108
|
-
dot.dispatchEvent(new MouseEvent('mousemove', {
|
|
3109
|
-
bubbles: true,
|
|
3110
|
-
clientX: cx,
|
|
3111
|
-
clientY: cy,
|
|
3112
|
-
screenX: cx,
|
|
3113
|
-
screenY: cy,
|
|
3114
|
-
}));
|
|
3115
|
-
};
|
|
3116
|
-
var onFocusOut = function (e) {
|
|
3117
|
-
if (!isDot(e.target))
|
|
3118
|
-
return;
|
|
3119
|
-
var dot = e.target;
|
|
3120
|
-
dot.style.opacity = '';
|
|
3121
|
-
dot.dispatchEvent(new MouseEvent('mouseout', { bubbles: true }));
|
|
3122
|
-
};
|
|
3123
|
-
var onKeyDown = function (e) {
|
|
3124
|
-
if (!isDot(e.target))
|
|
3125
|
-
return;
|
|
3126
|
-
if (e.key !== 'Enter' && e.key !== ' ')
|
|
3127
|
-
return;
|
|
3128
|
-
e.preventDefault();
|
|
3129
|
-
var dot = e.target;
|
|
3130
|
-
var _a = dot.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;
|
|
3131
|
-
var cx = left + width / 2;
|
|
3132
|
-
var cy = top + height / 2;
|
|
3133
|
-
dot.dispatchEvent(new MouseEvent('click', {
|
|
3134
|
-
bubbles: true,
|
|
3135
|
-
clientX: cx,
|
|
3136
|
-
clientY: cy,
|
|
3137
|
-
}));
|
|
3138
|
-
};
|
|
3139
|
-
var rafId = requestAnimationFrame(function () {
|
|
3140
|
-
wrapper
|
|
3141
|
-
.querySelectorAll('circle.dot')
|
|
3142
|
-
.forEach(function (dot) {
|
|
3143
|
-
if (!dot.hasAttribute('tabindex')) {
|
|
3144
|
-
dot.setAttribute('tabindex', '0');
|
|
3145
|
-
}
|
|
3146
|
-
});
|
|
3147
|
-
});
|
|
3148
|
-
wrapper.addEventListener('focusin', onFocusIn);
|
|
3149
|
-
wrapper.addEventListener('focusout', onFocusOut);
|
|
3150
|
-
wrapper.addEventListener('keydown', onKeyDown);
|
|
3151
|
-
return function () {
|
|
3152
|
-
cancelAnimationFrame(rafId);
|
|
3153
|
-
wrapper.removeEventListener('focusin', onFocusIn);
|
|
3154
|
-
wrapper.removeEventListener('focusout', onFocusOut);
|
|
3155
|
-
wrapper.removeEventListener('keydown', onKeyDown);
|
|
3156
|
-
};
|
|
3157
|
-
}, [type]);
|
|
3158
3083
|
React__namespace.useEffect(function () {
|
|
3159
3084
|
var timer = setTimeout(function () {
|
|
3160
3085
|
if (internalRef.current) {
|
|
3161
3086
|
internalRef.current
|
|
3162
|
-
.querySelectorAll('g[aria-label]')
|
|
3087
|
+
.querySelectorAll('g.ruler[aria-label]')
|
|
3088
|
+
.forEach(function (g) {
|
|
3089
|
+
g.setAttribute('aria-hidden', 'true');
|
|
3090
|
+
});
|
|
3091
|
+
internalRef.current
|
|
3092
|
+
.querySelectorAll('g[aria-label]:not(.ruler)')
|
|
3163
3093
|
.forEach(function (g) {
|
|
3164
3094
|
var role = g.getAttribute('role');
|
|
3165
3095
|
if (!role) {
|
|
@@ -3173,6 +3103,24 @@ var CarbonChart = React__namespace.forwardRef(function (props, ref) {
|
|
|
3173
3103
|
}, 0);
|
|
3174
3104
|
return function () { return clearTimeout(timer); };
|
|
3175
3105
|
}, [type, dataSet]);
|
|
3106
|
+
React__namespace.useEffect(function () {
|
|
3107
|
+
var container = internalRef.current;
|
|
3108
|
+
if (!container)
|
|
3109
|
+
return;
|
|
3110
|
+
var hideRulerFromAT = function () {
|
|
3111
|
+
container
|
|
3112
|
+
.querySelectorAll('g.ruler[aria-label]')
|
|
3113
|
+
.forEach(function (g) {
|
|
3114
|
+
if (!g.hasAttribute('aria-hidden')) {
|
|
3115
|
+
g.setAttribute('aria-hidden', 'true');
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
};
|
|
3119
|
+
hideRulerFromAT();
|
|
3120
|
+
var observer = new MutationObserver(hideRulerFromAT);
|
|
3121
|
+
observer.observe(container, { childList: true, subtree: true });
|
|
3122
|
+
return function () { return observer.disconnect(); };
|
|
3123
|
+
}, [type, dataSet]);
|
|
3176
3124
|
React__namespace.useEffect(function () {
|
|
3177
3125
|
var wrapper = internalRef.current;
|
|
3178
3126
|
if (!wrapper)
|
|
@@ -3224,6 +3172,96 @@ var CarbonChart = React__namespace.forwardRef(function (props, ref) {
|
|
|
3224
3172
|
});
|
|
3225
3173
|
return function () { return observer.disconnect(); };
|
|
3226
3174
|
}, [type, dataSet]);
|
|
3175
|
+
// Make Carbon Charts data points keyboard-focusable.
|
|
3176
|
+
React__namespace.useEffect(function () {
|
|
3177
|
+
var wrapper = internalRef.current;
|
|
3178
|
+
if (!wrapper)
|
|
3179
|
+
return;
|
|
3180
|
+
var stampDotTabIndex = function () {
|
|
3181
|
+
wrapper
|
|
3182
|
+
.querySelectorAll('circle.dot')
|
|
3183
|
+
.forEach(function (dot) {
|
|
3184
|
+
if (!dot.hasAttribute('tabindex')) {
|
|
3185
|
+
dot.setAttribute('tabindex', '0');
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
};
|
|
3189
|
+
var isDot = function (el) {
|
|
3190
|
+
return el instanceof Element &&
|
|
3191
|
+
el.nodeName.toLowerCase() === 'circle' &&
|
|
3192
|
+
el.classList.contains('dot');
|
|
3193
|
+
};
|
|
3194
|
+
var onFocusIn = function (e) {
|
|
3195
|
+
if (!isDot(e.target))
|
|
3196
|
+
return;
|
|
3197
|
+
var dot = e.target;
|
|
3198
|
+
var _a = dot.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;
|
|
3199
|
+
var cx = left + width / 2;
|
|
3200
|
+
var cy = top + height / 2;
|
|
3201
|
+
dot.dispatchEvent(new MouseEvent('mouseover', {
|
|
3202
|
+
bubbles: true,
|
|
3203
|
+
clientX: cx,
|
|
3204
|
+
clientY: cy,
|
|
3205
|
+
screenX: cx,
|
|
3206
|
+
screenY: cy,
|
|
3207
|
+
}));
|
|
3208
|
+
dot.dispatchEvent(new MouseEvent('mousemove', {
|
|
3209
|
+
bubbles: true,
|
|
3210
|
+
clientX: cx,
|
|
3211
|
+
clientY: cy,
|
|
3212
|
+
screenX: cx,
|
|
3213
|
+
screenY: cy,
|
|
3214
|
+
}));
|
|
3215
|
+
};
|
|
3216
|
+
var onFocusOut = function (e) {
|
|
3217
|
+
if (!isDot(e.target))
|
|
3218
|
+
return;
|
|
3219
|
+
var dot = e.target;
|
|
3220
|
+
// Keep tooltip context while Tab focus moves between chart points.
|
|
3221
|
+
if (isDot(e.relatedTarget)) {
|
|
3222
|
+
return;
|
|
3223
|
+
}
|
|
3224
|
+
dot.dispatchEvent(new MouseEvent('mouseout', { bubbles: true }));
|
|
3225
|
+
};
|
|
3226
|
+
var onKeyDown = function (e) {
|
|
3227
|
+
if (!isDot(e.target))
|
|
3228
|
+
return;
|
|
3229
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
3230
|
+
return;
|
|
3231
|
+
e.preventDefault();
|
|
3232
|
+
var dot = e.target;
|
|
3233
|
+
var _a = dot.getBoundingClientRect(), left = _a.left, top = _a.top, width = _a.width, height = _a.height;
|
|
3234
|
+
var cx = left + width / 2;
|
|
3235
|
+
var cy = top + height / 2;
|
|
3236
|
+
dot.dispatchEvent(new MouseEvent('click', {
|
|
3237
|
+
bubbles: true,
|
|
3238
|
+
clientX: cx,
|
|
3239
|
+
clientY: cy,
|
|
3240
|
+
}));
|
|
3241
|
+
};
|
|
3242
|
+
var rafId = requestAnimationFrame(function () {
|
|
3243
|
+
stampDotTabIndex();
|
|
3244
|
+
});
|
|
3245
|
+
var dotObserver = new MutationObserver(function () {
|
|
3246
|
+
stampDotTabIndex();
|
|
3247
|
+
});
|
|
3248
|
+
dotObserver.observe(wrapper, {
|
|
3249
|
+
childList: true,
|
|
3250
|
+
subtree: true,
|
|
3251
|
+
attributes: true,
|
|
3252
|
+
attributeFilter: ['class', 'style', 'tabindex'],
|
|
3253
|
+
});
|
|
3254
|
+
wrapper.addEventListener('focusin', onFocusIn);
|
|
3255
|
+
wrapper.addEventListener('focusout', onFocusOut);
|
|
3256
|
+
wrapper.addEventListener('keydown', onKeyDown);
|
|
3257
|
+
return function () {
|
|
3258
|
+
cancelAnimationFrame(rafId);
|
|
3259
|
+
dotObserver.disconnect();
|
|
3260
|
+
wrapper.removeEventListener('focusin', onFocusIn);
|
|
3261
|
+
wrapper.removeEventListener('focusout', onFocusOut);
|
|
3262
|
+
wrapper.removeEventListener('keydown', onKeyDown);
|
|
3263
|
+
};
|
|
3264
|
+
}, [type, dataSet]);
|
|
3227
3265
|
var groupsLength = Object.keys(colorScale).length;
|
|
3228
3266
|
var showTable = (chartToolbar === null || chartToolbar === void 0 ? void 0 : chartToolbar.showAsTable) !== false;
|
|
3229
3267
|
if (!ChartType)
|