@workday/canvas-kit-react 9.0.0 → 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.
@@ -359,7 +359,7 @@ export const Checkbox = createComponent('input')({
359
359
  htmlFor={inputId}
360
360
  disabled={disabled}
361
361
  variant={variant}
362
- paddingLeft={checkboxLabelDistance}
362
+ paddingInlineStart={checkboxLabelDistance}
363
363
  >
364
364
  {label}
365
365
  </LabelText>
@@ -10,15 +10,27 @@ export const changeFocus = (element: unknown) => {
10
10
  return;
11
11
  }
12
12
 
13
- if (element instanceof HTMLElement) {
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, paddingLeft: checkboxLabelDistance }, label))));
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,SAmB3C,CAAC"}
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 instanceof HTMLElement) {
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, paddingLeft: checkboxLabelDistance }, label))));
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,SAmB3C,CAAC"}
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 instanceof HTMLElement) {
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.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.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": "4e8110ad9758d19ef214fc6792f4803c2e25bac3"
69
+ "gitHead": "dc49ff11c7d7597d8362cbf4fb796d9d143468b0"
70
70
  }