@workday/canvas-kit-react 9.0.0-alpha.420-next.22 → 9.0.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/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
|
+
}
|
|
@@ -242,7 +242,7 @@ exports.Checkbox = common_1.createComponent('input')({
|
|
|
242
242
|
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'
|
|
243
243
|
? theme.canvas.palette.primary.main
|
|
244
244
|
: theme.canvas.palette.primary.contrast }))))),
|
|
245
|
-
label && (React.createElement(text_1.LabelText, { htmlFor: inputId, disabled: disabled, variant: variant,
|
|
245
|
+
label && (React.createElement(text_1.LabelText, { htmlFor: inputId, disabled: disabled, variant: variant, paddingInlineStart: checkboxLabelDistance }, label))));
|
|
246
246
|
},
|
|
247
247
|
subComponents: {
|
|
248
248
|
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 @@ const changeFocus = (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
|
const event = new KeyboardEvent('keydown', { bubbles: true, key: 'Unidentified' });
|
|
20
20
|
element.dispatchEvent(event);
|
|
21
21
|
}
|
|
@@ -23,3 +23,9 @@ const changeFocus = (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
|
+
}
|
|
@@ -220,7 +220,7 @@ export const Checkbox = createComponent('input')({
|
|
|
220
220
|
React.createElement(CheckboxCheck, { checked: checked }, indeterminate ? (React.createElement(IndeterminateBox, { variant: variant })) : (React.createElement(SystemIcon, { icon: checkSmallIcon, color: variant === 'inverse'
|
|
221
221
|
? theme.canvas.palette.primary.main
|
|
222
222
|
: theme.canvas.palette.primary.contrast }))))),
|
|
223
|
-
label && (React.createElement(LabelText, { htmlFor: inputId, disabled: disabled, variant: variant,
|
|
223
|
+
label && (React.createElement(LabelText, { htmlFor: inputId, disabled: disabled, variant: variant, paddingInlineStart: checkboxLabelDistance }, label))));
|
|
224
224
|
},
|
|
225
225
|
subComponents: {
|
|
226
226
|
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 const changeFocus = (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
|
const event = new KeyboardEvent('keydown', { bubbles: true, key: 'Unidentified' });
|
|
17
17
|
element.dispatchEvent(event);
|
|
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": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
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": "^9.0.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^9.0.1",
|
|
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",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
67
67
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "dc49ff11c7d7597d8362cbf4fb796d9d143468b0"
|
|
70
70
|
}
|