@workday/canvas-kit-react 9.1.33 → 9.1.34

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.
@@ -29,13 +29,22 @@ export const isFocusable = (element: Element): boolean => {
29
29
 
30
30
  /**
31
31
  * Get the first focusable element in a container.
32
+ *
33
+ * Returns an array of elements if the first focusable element is a radio group
32
34
  */
33
- export const getFirstFocusableElement = (container: HTMLElement): HTMLElement | null => {
35
+ export const getFirstFocusableElement = (
36
+ container: HTMLElement
37
+ ): Element[] | HTMLElement | null => {
34
38
  const elements = container.querySelectorAll('*');
35
39
 
36
40
  for (let i = 0; i < elements.length; i++) {
37
41
  const element = elements.item(i);
38
42
  if (element && isFocusable(element) && element.getAttribute('tabindex') !== '-1') {
43
+ if (isRadioInput(element)) {
44
+ const radioGroup = getRadioGroup(container, element);
45
+
46
+ return radioGroup.length > 1 ? Array.from(radioGroup) : element;
47
+ }
39
48
  return element as HTMLElement;
40
49
  }
41
50
  }
@@ -5,8 +5,10 @@
5
5
  export declare const isFocusable: (element: Element) => boolean;
6
6
  /**
7
7
  * Get the first focusable element in a container.
8
+ *
9
+ * Returns an array of elements if the first focusable element is a radio group
8
10
  */
9
- export declare const getFirstFocusableElement: (container: HTMLElement) => HTMLElement | null;
11
+ export declare const getFirstFocusableElement: (container: HTMLElement) => Element[] | HTMLElement | null;
10
12
  /**
11
13
  * Get the last focusable element in a container.
12
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/elements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,OAuB9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,cAAe,WAAW,KAAG,WAAW,GAAG,IAW/E,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,cAAe,WAAW,KAAG,OAAO,EAAE,GAAG,OAAO,GAAG,IAgBtF,CAAC"}
1
+ {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/elements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,OAuB9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,cACxB,WAAW,KACrB,OAAO,EAAE,GAAG,WAAW,GAAG,IAgB5B,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,cAAe,WAAW,KAAG,OAAO,EAAE,GAAG,OAAO,GAAG,IAgBtF,CAAC"}
@@ -27,12 +27,18 @@ const isFocusable = (element) => {
27
27
  exports.isFocusable = isFocusable;
28
28
  /**
29
29
  * Get the first focusable element in a container.
30
+ *
31
+ * Returns an array of elements if the first focusable element is a radio group
30
32
  */
31
33
  const getFirstFocusableElement = (container) => {
32
34
  const elements = container.querySelectorAll('*');
33
35
  for (let i = 0; i < elements.length; i++) {
34
36
  const element = elements.item(i);
35
37
  if (element && exports.isFocusable(element) && element.getAttribute('tabindex') !== '-1') {
38
+ if (isRadioInput(element)) {
39
+ const radioGroup = getRadioGroup(container, element);
40
+ return radioGroup.length > 1 ? Array.from(radioGroup) : element;
41
+ }
36
42
  return element;
37
43
  }
38
44
  }
@@ -5,8 +5,10 @@
5
5
  export declare const isFocusable: (element: Element) => boolean;
6
6
  /**
7
7
  * Get the first focusable element in a container.
8
+ *
9
+ * Returns an array of elements if the first focusable element is a radio group
8
10
  */
9
- export declare const getFirstFocusableElement: (container: HTMLElement) => HTMLElement | null;
11
+ export declare const getFirstFocusableElement: (container: HTMLElement) => Element[] | HTMLElement | null;
10
12
  /**
11
13
  * Get the last focusable element in a container.
12
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/elements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,OAuB9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,cAAe,WAAW,KAAG,WAAW,GAAG,IAW/E,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,cAAe,WAAW,KAAG,OAAO,EAAE,GAAG,OAAO,GAAG,IAgBtF,CAAC"}
1
+ {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/elements.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,OAuB9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,cACxB,WAAW,KACrB,OAAO,EAAE,GAAG,WAAW,GAAG,IAgB5B,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,cAAe,WAAW,KAAG,OAAO,EAAE,GAAG,OAAO,GAAG,IAgBtF,CAAC"}
@@ -23,12 +23,18 @@ export const isFocusable = (element) => {
23
23
  };
24
24
  /**
25
25
  * Get the first focusable element in a container.
26
+ *
27
+ * Returns an array of elements if the first focusable element is a radio group
26
28
  */
27
29
  export const getFirstFocusableElement = (container) => {
28
30
  const elements = container.querySelectorAll('*');
29
31
  for (let i = 0; i < elements.length; i++) {
30
32
  const element = elements.item(i);
31
33
  if (element && isFocusable(element) && element.getAttribute('tabindex') !== '-1') {
34
+ if (isRadioInput(element)) {
35
+ const radioGroup = getRadioGroup(container, element);
36
+ return radioGroup.length > 1 ? Array.from(radioGroup) : element;
37
+ }
32
38
  return element;
33
39
  }
34
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "9.1.33",
3
+ "version": "9.1.34",
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.1.33",
52
+ "@workday/canvas-kit-popup-stack": "^9.1.34",
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": "074ade9a9f7158e9414d0435b8843ed46f4abec7"
69
+ "gitHead": "205ba18c9c321794966396db0534dbcd7b76fdcb"
70
70
  }