@workday/canvas-kit-react 8.6.5 → 8.6.7
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/checkbox/lib/Checkbox.tsx +1 -1
- package/common/lib/utils/changeFocus.ts +15 -3
- package/dist/commonjs/checkbox/lib/Checkbox.js +1 -1
- package/dist/commonjs/common/lib/utils/changeFocus.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/changeFocus.js +8 -2
- package/dist/es6/checkbox/lib/Checkbox.js +1 -1
- package/dist/es6/common/lib/utils/changeFocus.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/changeFocus.js +8 -2
- package/package.json +3 -3
|
@@ -10,15 +10,27 @@ export const changeFocus = (element: unknown) => {
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (element
|
|
13
|
+
if (hasCallableProperty(element, 'focus')) {
|
|
14
14
|
// Dispatch an unidentified keyboard event for an input provider prior to a focus change so that
|
|
15
15
|
// the ring will appear.
|
|
16
|
-
if (typeof KeyboardEvent === 'function') {
|
|
16
|
+
if (typeof KeyboardEvent === 'function' && hasCallableProperty(element, 'dispatchEvent')) {
|
|
17
17
|
const event = new KeyboardEvent('keydown', {bubbles: true, key: 'Unidentified'});
|
|
18
|
-
|
|
19
18
|
element.dispatchEvent(event);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
element.focus();
|
|
23
22
|
}
|
|
24
23
|
};
|
|
24
|
+
|
|
25
|
+
type Callable<K extends string> = {
|
|
26
|
+
[P in K]: Function;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function hasCallableProperty<K extends string>(input: unknown, method: K): input is Callable<K> {
|
|
30
|
+
return (
|
|
31
|
+
!!input &&
|
|
32
|
+
typeof input === 'object' &&
|
|
33
|
+
method in input! &&
|
|
34
|
+
typeof (input as any)[method] === 'function'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -251,7 +251,7 @@ exports.Checkbox = common_1.createComponent('input')({
|
|
|
251
251
|
React.createElement(CheckboxCheck, { checked: checked }, indeterminate ? (React.createElement(IndeterminateBox, { variant: variant })) : (React.createElement(icon_1.SystemIcon, { icon: canvas_system_icons_web_1.checkSmallIcon, color: variant === 'inverse'
|
|
252
252
|
? theme.canvas.palette.primary.main
|
|
253
253
|
: theme.canvas.palette.primary.contrast }))))),
|
|
254
|
-
label && (React.createElement(text_1.LabelText, { htmlFor: inputId, disabled: disabled, variant: variant,
|
|
254
|
+
label && (React.createElement(text_1.LabelText, { htmlFor: inputId, disabled: disabled, variant: variant, paddingInlineStart: checkboxLabelDistance }, label))));
|
|
255
255
|
},
|
|
256
256
|
subComponents: {
|
|
257
257
|
ErrorType: common_1.ErrorType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFocus.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/changeFocus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,
|
|
1
|
+
{"version":3,"file":"changeFocus.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/changeFocus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,SAkB3C,CAAC"}
|
|
@@ -12,10 +12,10 @@ var changeFocus = function (element) {
|
|
|
12
12
|
if (document.activeElement === element || !element) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
if (element
|
|
15
|
+
if (hasCallableProperty(element, 'focus')) {
|
|
16
16
|
// Dispatch an unidentified keyboard event for an input provider prior to a focus change so that
|
|
17
17
|
// the ring will appear.
|
|
18
|
-
if (typeof KeyboardEvent === 'function') {
|
|
18
|
+
if (typeof KeyboardEvent === 'function' && hasCallableProperty(element, 'dispatchEvent')) {
|
|
19
19
|
var event_1 = new KeyboardEvent('keydown', { bubbles: true, key: 'Unidentified' });
|
|
20
20
|
element.dispatchEvent(event_1);
|
|
21
21
|
}
|
|
@@ -23,3 +23,9 @@ var changeFocus = function (element) {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
exports.changeFocus = changeFocus;
|
|
26
|
+
function hasCallableProperty(input, method) {
|
|
27
|
+
return (!!input &&
|
|
28
|
+
typeof input === 'object' &&
|
|
29
|
+
method in input &&
|
|
30
|
+
typeof input[method] === 'function');
|
|
31
|
+
}
|
|
@@ -229,7 +229,7 @@ export var Checkbox = createComponent('input')({
|
|
|
229
229
|
React.createElement(CheckboxCheck, { checked: checked }, indeterminate ? (React.createElement(IndeterminateBox, { variant: variant })) : (React.createElement(SystemIcon, { icon: checkSmallIcon, color: variant === 'inverse'
|
|
230
230
|
? theme.canvas.palette.primary.main
|
|
231
231
|
: theme.canvas.palette.primary.contrast }))))),
|
|
232
|
-
label && (React.createElement(LabelText, { htmlFor: inputId, disabled: disabled, variant: variant,
|
|
232
|
+
label && (React.createElement(LabelText, { htmlFor: inputId, disabled: disabled, variant: variant, paddingInlineStart: checkboxLabelDistance }, label))));
|
|
233
233
|
},
|
|
234
234
|
subComponents: {
|
|
235
235
|
ErrorType: ErrorType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changeFocus.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/changeFocus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,
|
|
1
|
+
{"version":3,"file":"changeFocus.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/changeFocus.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,SAkB3C,CAAC"}
|
|
@@ -9,13 +9,19 @@ export var changeFocus = function (element) {
|
|
|
9
9
|
if (document.activeElement === element || !element) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
if (element
|
|
12
|
+
if (hasCallableProperty(element, 'focus')) {
|
|
13
13
|
// Dispatch an unidentified keyboard event for an input provider prior to a focus change so that
|
|
14
14
|
// the ring will appear.
|
|
15
|
-
if (typeof KeyboardEvent === 'function') {
|
|
15
|
+
if (typeof KeyboardEvent === 'function' && hasCallableProperty(element, 'dispatchEvent')) {
|
|
16
16
|
var event_1 = new KeyboardEvent('keydown', { bubbles: true, key: 'Unidentified' });
|
|
17
17
|
element.dispatchEvent(event_1);
|
|
18
18
|
}
|
|
19
19
|
element.focus();
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
function hasCallableProperty(input, method) {
|
|
23
|
+
return (!!input &&
|
|
24
|
+
typeof input === 'object' &&
|
|
25
|
+
method in input &&
|
|
26
|
+
typeof input[method] === 'function');
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.7",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^8.6.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^8.6.7",
|
|
53
53
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
54
54
|
"@workday/design-assets-types": "^0.2.8",
|
|
55
55
|
"chroma-js": "^2.1.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
68
68
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "cae5b94c10ae3ad205cf7d298e1c574b30f304a1"
|
|
71
71
|
}
|