@workday/canvas-kit-react 8.6.6 → 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/common/lib/utils/changeFocus.ts +15 -3
- 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/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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
}
|