@workday/canvas-kit-react 9.1.33 → 9.1.35
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/elements.ts +10 -1
- package/dist/commonjs/common/lib/utils/elements.d.ts +3 -1
- package/dist/commonjs/common/lib/utils/elements.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/elements.js +6 -0
- package/dist/commonjs/popup/lib/hooks/useCloseOnOutsideClick.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/useCloseOnOutsideClick.js +2 -0
- package/dist/es6/common/lib/utils/elements.d.ts +3 -1
- package/dist/es6/common/lib/utils/elements.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/elements.js +6 -0
- package/dist/es6/popup/lib/hooks/useCloseOnOutsideClick.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/useCloseOnOutsideClick.js +2 -0
- package/package.json +3 -3
- package/popup/lib/hooks/useCloseOnOutsideClick.ts +2 -0
|
@@ -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 = (
|
|
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
|
|
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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloseOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useCloseOnOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useCloseOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useCloseOnOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;MAwCjC,CAAC"}
|
|
@@ -28,6 +28,8 @@ exports.useCloseOnOutsideClick = common_1.createElemPropsHook(usePopupModel_1.us
|
|
|
28
28
|
.sort((a, b) => Number(a.style.zIndex) - Number(b.style.zIndex));
|
|
29
29
|
if (elements.length &&
|
|
30
30
|
elements[elements.length - 1] === model.state.stackRef.current &&
|
|
31
|
+
// Only consider event targets that are currently in the DOM as valid
|
|
32
|
+
document.contains(event.target) &&
|
|
31
33
|
// Use `PopupStack.contains` instead of `ref.current.contains` so that the application can
|
|
32
34
|
// decide if clicking the target should toggle the popup rather than it toggling implicitly
|
|
33
35
|
// because the target is outside `ref.current`
|
|
@@ -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
|
|
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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCloseOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useCloseOnOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useCloseOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../../popup/lib/hooks/useCloseOnOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;MAwCjC,CAAC"}
|
|
@@ -22,6 +22,8 @@ export const useCloseOnOutsideClick = createElemPropsHook(usePopupModel)(model =
|
|
|
22
22
|
.sort((a, b) => Number(a.style.zIndex) - Number(b.style.zIndex));
|
|
23
23
|
if (elements.length &&
|
|
24
24
|
elements[elements.length - 1] === model.state.stackRef.current &&
|
|
25
|
+
// Only consider event targets that are currently in the DOM as valid
|
|
26
|
+
document.contains(event.target) &&
|
|
25
27
|
// Use `PopupStack.contains` instead of `ref.current.contains` so that the application can
|
|
26
28
|
// decide if clicking the target should toggle the popup rather than it toggling implicitly
|
|
27
29
|
// because the target is outside `ref.current`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.35",
|
|
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.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^9.1.35",
|
|
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": "ed62cb5cd886db87f0c0e2a74d7afe4df6cb5e61"
|
|
70
70
|
}
|
|
@@ -27,6 +27,8 @@ export const useCloseOnOutsideClick = createElemPropsHook(usePopupModel)(model =
|
|
|
27
27
|
if (
|
|
28
28
|
elements.length &&
|
|
29
29
|
elements[elements.length - 1] === model.state.stackRef.current &&
|
|
30
|
+
// Only consider event targets that are currently in the DOM as valid
|
|
31
|
+
document.contains(event.target as HTMLElement) &&
|
|
30
32
|
// Use `PopupStack.contains` instead of `ref.current.contains` so that the application can
|
|
31
33
|
// decide if clicking the target should toggle the popup rather than it toggling implicitly
|
|
32
34
|
// because the target is outside `ref.current`
|