@workday/canvas-kit-react 10.3.50 → 10.3.52
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/dist/commonjs/modal/lib/Modal.d.ts +1 -1
- package/dist/commonjs/modal/lib/Modal.js +1 -1
- package/dist/commonjs/modal/lib/hooks/useModalCard.d.ts +7 -0
- package/dist/commonjs/modal/lib/hooks/useModalCard.d.ts.map +1 -1
- package/dist/commonjs/modal/lib/hooks/useModalCard.js +8 -1
- package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
- package/dist/commonjs/select/lib/Select.js +1 -15
- package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +1 -2
- package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts.map +1 -1
- package/dist/commonjs/select/lib/hooks/useSelectInput.js +20 -4
- package/dist/es6/modal/lib/Modal.d.ts +1 -1
- package/dist/es6/modal/lib/Modal.js +1 -1
- package/dist/es6/modal/lib/hooks/useModalCard.d.ts +7 -0
- package/dist/es6/modal/lib/hooks/useModalCard.d.ts.map +1 -1
- package/dist/es6/modal/lib/hooks/useModalCard.js +8 -1
- package/dist/es6/select/lib/Select.d.ts.map +1 -1
- package/dist/es6/select/lib/Select.js +2 -16
- package/dist/es6/select/lib/hooks/useSelectInput.d.ts +1 -2
- package/dist/es6/select/lib/hooks/useSelectInput.d.ts.map +1 -1
- package/dist/es6/select/lib/hooks/useSelectInput.js +20 -4
- package/modal/lib/Modal.tsx +1 -1
- package/modal/lib/hooks/useModalCard.ts +8 -1
- package/package.json +4 -4
- package/select/lib/Select.tsx +1 -23
- package/select/lib/hooks/useSelectInput.ts +29 -4
|
@@ -162,7 +162,7 @@ export declare const Modal: import("@workday/canvas-kit-react/common").Component
|
|
|
162
162
|
/**
|
|
163
163
|
* The `Modal.Card` is wraps a {@link PopupCard Popup.Card} which wraps a {@link Card}. It is
|
|
164
164
|
* the `role="dialog"` element and is uses `useModalCard` behavior hook which sets
|
|
165
|
-
* `aria-modal="
|
|
165
|
+
* `aria-modal="false"` and sets the `aria-labelledby` that points to the `id` of the
|
|
166
166
|
* {@link ModalHeading Modal.Heading}. If you don't use a `Modal.Heading`, add an `aria-label`
|
|
167
167
|
* instead. The default element is a `div` and can be changed via the `as` prop.
|
|
168
168
|
*/
|
|
@@ -62,7 +62,7 @@ exports.Modal = common_1.createContainer()({
|
|
|
62
62
|
/**
|
|
63
63
|
* The `Modal.Card` is wraps a {@link PopupCard Popup.Card} which wraps a {@link Card}. It is
|
|
64
64
|
* the `role="dialog"` element and is uses `useModalCard` behavior hook which sets
|
|
65
|
-
* `aria-modal="
|
|
65
|
+
* `aria-modal="false"` and sets the `aria-labelledby` that points to the `id` of the
|
|
66
66
|
* {@link ModalHeading Modal.Heading}. If you don't use a `Modal.Heading`, add an `aria-label`
|
|
67
67
|
* instead. The default element is a `div` and can be changed via the `as` prop.
|
|
68
68
|
*/
|
|
@@ -19,6 +19,13 @@ export declare const useModalCard: import("@workday/canvas-kit-react/common").Be
|
|
|
19
19
|
role: string;
|
|
20
20
|
'aria-labelledby': string;
|
|
21
21
|
} & {
|
|
22
|
+
/**
|
|
23
|
+
* `aria-modal` was added with the intent that screen readers would add support to properly define content within a modal,
|
|
24
|
+
* including popups like a Select. However, when aria-modal is true, it will hide other elements from screen readers,
|
|
25
|
+
* including popups owned by the modal because these popups are siblings to the modal and not ancestors. There is no defined time when Apple/VoiceOver
|
|
26
|
+
* might change this behavior and better support aria-owns, so for the time being we'll explicitly set this to false to provide a better
|
|
27
|
+
* VoiceOver experience.
|
|
28
|
+
*/
|
|
22
29
|
'aria-modal': boolean;
|
|
23
30
|
}>;
|
|
24
31
|
//# sourceMappingURL=useModalCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModalCard.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useModalCard.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"useModalCard.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useModalCard.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;IAInB;;;;;;OAMG;;EAIR,CAAC"}
|
|
@@ -5,6 +5,13 @@ const common_1 = require("@workday/canvas-kit-react/common");
|
|
|
5
5
|
const popup_1 = require("@workday/canvas-kit-react/popup");
|
|
6
6
|
exports.useModalCard = common_1.composeHooks(popup_1.usePopupCard, common_1.createElemPropsHook(popup_1.usePopupModel)(() => {
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `aria-modal` was added with the intent that screen readers would add support to properly define content within a modal,
|
|
10
|
+
* including popups like a Select. However, when aria-modal is true, it will hide other elements from screen readers,
|
|
11
|
+
* including popups owned by the modal because these popups are siblings to the modal and not ancestors. There is no defined time when Apple/VoiceOver
|
|
12
|
+
* might change this behavior and better support aria-owns, so for the time being we'll explicitly set this to false to provide a better
|
|
13
|
+
* VoiceOver experience.
|
|
14
|
+
*/
|
|
15
|
+
'aria-modal': false,
|
|
9
16
|
};
|
|
10
17
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../select/lib/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,YAAY,EAEZ,SAAS,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../select/lib/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,YAAY,EAEZ,SAAS,EACV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAAa,SAAS,EAAC,MAAM,sCAAsC,CAAC;AAO3E,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,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
|
21
21
|
modelHook: useSelectModel_1.useSelectModel,
|
|
22
22
|
elemPropsHook: useSelectInput_1.useSelectInput,
|
|
23
23
|
})(({ placeholder = 'Choose an option', inputStartIcon, error, textInputProps, disabled, ref, onChange, onInput, value, name, ...elemProps }, Element, model) => {
|
|
24
|
-
const { localRef, elementRef } = common_1.useLocalRef(ref);
|
|
25
|
-
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
26
|
-
// the visible input
|
|
27
|
-
react_1.default.useImperativeHandle(elementRef, () => {
|
|
28
|
-
if (localRef.current) {
|
|
29
|
-
localRef.current.focus = (options) => {
|
|
30
|
-
textInputProps.ref.current.focus(options);
|
|
31
|
-
};
|
|
32
|
-
localRef.current.blur = () => {
|
|
33
|
-
textInputProps.ref.current.blur();
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return localRef.current;
|
|
37
|
-
}, [textInputProps.ref, localRef]);
|
|
38
24
|
return (react_1.default.createElement(text_input_1.InputGroup, null,
|
|
39
25
|
inputStartIcon && model.state.selectedIds.length > 0 && (react_1.default.createElement(text_input_1.InputGroup.InnerStart, { pointerEvents: "none" },
|
|
40
26
|
react_1.default.createElement(icon_1.SystemIcon, { icon: inputStartIcon }))),
|
|
41
|
-
react_1.default.createElement(text_input_1.InputGroup.Input, { error: error, disabled: disabled, className: hiddenSelectStyles, tabIndex: -1, "aria-hidden": true, onChange: onChange, onInput: onInput, value: value, name: name, ref:
|
|
27
|
+
react_1.default.createElement(text_input_1.InputGroup.Input, { error: error, disabled: disabled, className: hiddenSelectStyles, tabIndex: -1, "aria-hidden": true, onChange: onChange, onInput: onInput, value: value, name: name, ref: ref }),
|
|
42
28
|
react_1.default.createElement(text_input_1.InputGroup.Input, Object.assign({ as: Element, disabled: disabled, placeholder: placeholder, error: error }, textInputProps, layout_1.mergeStyles(elemProps, [selectInputStyles]))),
|
|
43
29
|
react_1.default.createElement(text_input_1.InputGroup.InnerEnd, { position: "absolute", pointerEvents: "none" },
|
|
44
30
|
react_1.default.createElement(icon_1.SystemIcon, { icon: canvas_system_icons_web_1.caretDownSmallIcon }))));
|
|
@@ -111,11 +111,10 @@ export declare const useSelectInput: import("@workday/canvas-kit-react/common").
|
|
|
111
111
|
readonly autoComplete: "off";
|
|
112
112
|
readonly onFocus: () => void;
|
|
113
113
|
readonly textInputProps: {
|
|
114
|
-
readonly ref:
|
|
114
|
+
readonly ref: (instance: HTMLInputElement | null) => void;
|
|
115
115
|
readonly onChange: typeof noop;
|
|
116
116
|
readonly value: string;
|
|
117
117
|
};
|
|
118
|
-
readonly ref: (instance: HTMLInputElement | null) => void;
|
|
119
118
|
readonly 'aria-haspopup': "menu";
|
|
120
119
|
}>;
|
|
121
120
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectInput.d.ts","sourceRoot":"","sources":["../../../../../select/lib/hooks/useSelectInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,iBAAS,IAAI,SAEZ;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useSelectInput.d.ts","sourceRoot":"","sources":["../../../../../select/lib/hooks/useSelectInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,iBAAS,IAAI,SAEZ;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA0HF,mBAAmB;+BArFP,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;EAkIvE,CAAC"}
|
|
@@ -15,8 +15,25 @@ function noop() {
|
|
|
15
15
|
* `useSelectInput` extends {@link useComboboxInput useComboboxInput} and {@link useComboboxKeyboardTypeAhead useComboboxKeyboardTypeAhead} and adds type ahead functionality and Select-specific [keyboard support](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
|
|
16
16
|
*/
|
|
17
17
|
exports.useSelectInput = common_1.composeHooks(combobox_1.useComboboxInput, combobox_1.useComboboxKeyboardTypeAhead, combobox_1.useComboboxResetCursorToSelected, combobox_1.useComboboxMoveCursorToSelected, common_1.createElemPropsHook(useSelectModel_1.useSelectModel)((model, ref, elemProps = {}) => {
|
|
18
|
-
const
|
|
19
|
-
const textInputRef =
|
|
18
|
+
// const textInputRef = React.useRef<HTMLInputElement>(null);
|
|
19
|
+
const { elementRef: textInputElementRef, localRef: textInputRef } = common_1.useLocalRef(
|
|
20
|
+
// PopupModel says the targetRef is a `HTMLButtonElement`, but it is a `HTMLInputElement`
|
|
21
|
+
model.state.targetRef);
|
|
22
|
+
const { localRef, elementRef } = common_1.useLocalRef(ref);
|
|
23
|
+
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
24
|
+
// the visible input
|
|
25
|
+
react_1.default.useImperativeHandle(elementRef, () => {
|
|
26
|
+
if (localRef.current) {
|
|
27
|
+
localRef.current.focus = (options) => {
|
|
28
|
+
textInputRef.current.focus(options);
|
|
29
|
+
};
|
|
30
|
+
localRef.current.blur = () => {
|
|
31
|
+
textInputRef.current.blur();
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return localRef.current;
|
|
35
|
+
}, [textInputRef, localRef]);
|
|
36
|
+
// Remap the Popup model's targetRef to be the visible ref. `ref` and `model.state.targetRef` are already linked. We have to override that.
|
|
20
37
|
// Update the text value of the input
|
|
21
38
|
const handleOnChange = (event) => {
|
|
22
39
|
var _a;
|
|
@@ -117,13 +134,12 @@ exports.useSelectInput = common_1.composeHooks(combobox_1.useComboboxInput, comb
|
|
|
117
134
|
(_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
118
135
|
},
|
|
119
136
|
textInputProps: {
|
|
120
|
-
ref:
|
|
137
|
+
ref: textInputElementRef,
|
|
121
138
|
onChange: noop,
|
|
122
139
|
value: model.state.selectedIds.length > 0 && model.state.items.length > 0
|
|
123
140
|
? model.navigation.getItem(model.state.selectedIds[0], model).textValue
|
|
124
141
|
: '',
|
|
125
142
|
},
|
|
126
|
-
ref: elementRef,
|
|
127
143
|
'aria-haspopup': 'menu',
|
|
128
144
|
};
|
|
129
145
|
}));
|
|
@@ -162,7 +162,7 @@ export declare const Modal: import("@workday/canvas-kit-react/common").Component
|
|
|
162
162
|
/**
|
|
163
163
|
* The `Modal.Card` is wraps a {@link PopupCard Popup.Card} which wraps a {@link Card}. It is
|
|
164
164
|
* the `role="dialog"` element and is uses `useModalCard` behavior hook which sets
|
|
165
|
-
* `aria-modal="
|
|
165
|
+
* `aria-modal="false"` and sets the `aria-labelledby` that points to the `id` of the
|
|
166
166
|
* {@link ModalHeading Modal.Heading}. If you don't use a `Modal.Heading`, add an `aria-label`
|
|
167
167
|
* instead. The default element is a `div` and can be changed via the `as` prop.
|
|
168
168
|
*/
|
|
@@ -40,7 +40,7 @@ export const Modal = createContainer()({
|
|
|
40
40
|
/**
|
|
41
41
|
* The `Modal.Card` is wraps a {@link PopupCard Popup.Card} which wraps a {@link Card}. It is
|
|
42
42
|
* the `role="dialog"` element and is uses `useModalCard` behavior hook which sets
|
|
43
|
-
* `aria-modal="
|
|
43
|
+
* `aria-modal="false"` and sets the `aria-labelledby` that points to the `id` of the
|
|
44
44
|
* {@link ModalHeading Modal.Heading}. If you don't use a `Modal.Heading`, add an `aria-label`
|
|
45
45
|
* instead. The default element is a `div` and can be changed via the `as` prop.
|
|
46
46
|
*/
|
|
@@ -19,6 +19,13 @@ export declare const useModalCard: import("@workday/canvas-kit-react/common").Be
|
|
|
19
19
|
role: string;
|
|
20
20
|
'aria-labelledby': string;
|
|
21
21
|
} & {
|
|
22
|
+
/**
|
|
23
|
+
* `aria-modal` was added with the intent that screen readers would add support to properly define content within a modal,
|
|
24
|
+
* including popups like a Select. However, when aria-modal is true, it will hide other elements from screen readers,
|
|
25
|
+
* including popups owned by the modal because these popups are siblings to the modal and not ancestors. There is no defined time when Apple/VoiceOver
|
|
26
|
+
* might change this behavior and better support aria-owns, so for the time being we'll explicitly set this to false to provide a better
|
|
27
|
+
* VoiceOver experience.
|
|
28
|
+
*/
|
|
22
29
|
'aria-modal': boolean;
|
|
23
30
|
}>;
|
|
24
31
|
//# sourceMappingURL=useModalCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModalCard.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useModalCard.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"useModalCard.d.ts","sourceRoot":"","sources":["../../../../../modal/lib/hooks/useModalCard.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;IAInB;;;;;;OAMG;;EAIR,CAAC"}
|
|
@@ -2,6 +2,13 @@ import { composeHooks, createElemPropsHook } from '@workday/canvas-kit-react/com
|
|
|
2
2
|
import { usePopupCard, usePopupModel } from '@workday/canvas-kit-react/popup';
|
|
3
3
|
export const useModalCard = composeHooks(usePopupCard, createElemPropsHook(usePopupModel)(() => {
|
|
4
4
|
return {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `aria-modal` was added with the intent that screen readers would add support to properly define content within a modal,
|
|
7
|
+
* including popups like a Select. However, when aria-modal is true, it will hide other elements from screen readers,
|
|
8
|
+
* including popups owned by the modal because these popups are siblings to the modal and not ancestors. There is no defined time when Apple/VoiceOver
|
|
9
|
+
* might change this behavior and better support aria-owns, so for the time being we'll explicitly set this to false to provide a better
|
|
10
|
+
* VoiceOver experience.
|
|
11
|
+
*/
|
|
12
|
+
'aria-modal': false,
|
|
6
13
|
};
|
|
7
14
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../select/lib/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,YAAY,EAEZ,SAAS,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../select/lib/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAEL,YAAY,EAEZ,SAAS,EACV,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,oCAAoC,CAAC;AAE5D,OAAO,EAAa,SAAS,EAAC,MAAM,sCAAsC,CAAC;AAO3E,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAe,OAAO,EAAC,MAAM,6BAA6B,CAAC;AAElE,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,OAAO;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAqBD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDvB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWrB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;;;;;;;;;;;;;;OAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEH;;;;;;;;;;;;;;;;;OAiBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { createSubcomponent, createContainer,
|
|
2
|
+
import { createSubcomponent, createContainer, } from '@workday/canvas-kit-react/common';
|
|
3
3
|
import { Combobox } from '@workday/canvas-kit-react/combobox';
|
|
4
4
|
import { InputGroup, TextInput } from '@workday/canvas-kit-react/text-input';
|
|
5
5
|
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
@@ -15,24 +15,10 @@ export const SelectInput = createSubcomponent(TextInput)({
|
|
|
15
15
|
modelHook: useSelectModel,
|
|
16
16
|
elemPropsHook: useSelectInput,
|
|
17
17
|
})(({ placeholder = 'Choose an option', inputStartIcon, error, textInputProps, disabled, ref, onChange, onInput, value, name, ...elemProps }, Element, model) => {
|
|
18
|
-
const { localRef, elementRef } = useLocalRef(ref);
|
|
19
|
-
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
20
|
-
// the visible input
|
|
21
|
-
React.useImperativeHandle(elementRef, () => {
|
|
22
|
-
if (localRef.current) {
|
|
23
|
-
localRef.current.focus = (options) => {
|
|
24
|
-
textInputProps.ref.current.focus(options);
|
|
25
|
-
};
|
|
26
|
-
localRef.current.blur = () => {
|
|
27
|
-
textInputProps.ref.current.blur();
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return localRef.current;
|
|
31
|
-
}, [textInputProps.ref, localRef]);
|
|
32
18
|
return (React.createElement(InputGroup, null,
|
|
33
19
|
inputStartIcon && model.state.selectedIds.length > 0 && (React.createElement(InputGroup.InnerStart, { pointerEvents: "none" },
|
|
34
20
|
React.createElement(SystemIcon, { icon: inputStartIcon }))),
|
|
35
|
-
React.createElement(InputGroup.Input, { error: error, disabled: disabled, className: hiddenSelectStyles, tabIndex: -1, "aria-hidden": true, onChange: onChange, onInput: onInput, value: value, name: name, ref:
|
|
21
|
+
React.createElement(InputGroup.Input, { error: error, disabled: disabled, className: hiddenSelectStyles, tabIndex: -1, "aria-hidden": true, onChange: onChange, onInput: onInput, value: value, name: name, ref: ref }),
|
|
36
22
|
React.createElement(InputGroup.Input, Object.assign({ as: Element, disabled: disabled, placeholder: placeholder, error: error }, textInputProps, mergeStyles(elemProps, [selectInputStyles]))),
|
|
37
23
|
React.createElement(InputGroup.InnerEnd, { position: "absolute", pointerEvents: "none" },
|
|
38
24
|
React.createElement(SystemIcon, { icon: caretDownSmallIcon }))));
|
|
@@ -111,11 +111,10 @@ export declare const useSelectInput: import("@workday/canvas-kit-react/common").
|
|
|
111
111
|
readonly autoComplete: "off";
|
|
112
112
|
readonly onFocus: () => void;
|
|
113
113
|
readonly textInputProps: {
|
|
114
|
-
readonly ref:
|
|
114
|
+
readonly ref: (instance: HTMLInputElement | null) => void;
|
|
115
115
|
readonly onChange: typeof noop;
|
|
116
116
|
readonly value: string;
|
|
117
117
|
};
|
|
118
|
-
readonly ref: (instance: HTMLInputElement | null) => void;
|
|
119
118
|
readonly 'aria-haspopup': "menu";
|
|
120
119
|
}>;
|
|
121
120
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelectInput.d.ts","sourceRoot":"","sources":["../../../../../select/lib/hooks/useSelectInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,iBAAS,IAAI,SAEZ;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useSelectInput.d.ts","sourceRoot":"","sources":["../../../../../select/lib/hooks/useSelectInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,iBAAS,IAAI,SAEZ;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA0HF,mBAAmB;+BArFP,MAAM,WAAW,CAAC,gBAAgB,CAAC;;;;;;;;;EAkIvE,CAAC"}
|
|
@@ -9,8 +9,25 @@ function noop() {
|
|
|
9
9
|
* `useSelectInput` extends {@link useComboboxInput useComboboxInput} and {@link useComboboxKeyboardTypeAhead useComboboxKeyboardTypeAhead} and adds type ahead functionality and Select-specific [keyboard support](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
|
|
10
10
|
*/
|
|
11
11
|
export const useSelectInput = composeHooks(useComboboxInput, useComboboxKeyboardTypeAhead, useComboboxResetCursorToSelected, useComboboxMoveCursorToSelected, createElemPropsHook(useSelectModel)((model, ref, elemProps = {}) => {
|
|
12
|
-
const
|
|
13
|
-
const textInputRef =
|
|
12
|
+
// const textInputRef = React.useRef<HTMLInputElement>(null);
|
|
13
|
+
const { elementRef: textInputElementRef, localRef: textInputRef } = useLocalRef(
|
|
14
|
+
// PopupModel says the targetRef is a `HTMLButtonElement`, but it is a `HTMLInputElement`
|
|
15
|
+
model.state.targetRef);
|
|
16
|
+
const { localRef, elementRef } = useLocalRef(ref);
|
|
17
|
+
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
18
|
+
// the visible input
|
|
19
|
+
React.useImperativeHandle(elementRef, () => {
|
|
20
|
+
if (localRef.current) {
|
|
21
|
+
localRef.current.focus = (options) => {
|
|
22
|
+
textInputRef.current.focus(options);
|
|
23
|
+
};
|
|
24
|
+
localRef.current.blur = () => {
|
|
25
|
+
textInputRef.current.blur();
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return localRef.current;
|
|
29
|
+
}, [textInputRef, localRef]);
|
|
30
|
+
// Remap the Popup model's targetRef to be the visible ref. `ref` and `model.state.targetRef` are already linked. We have to override that.
|
|
14
31
|
// Update the text value of the input
|
|
15
32
|
const handleOnChange = (event) => {
|
|
16
33
|
var _a;
|
|
@@ -111,13 +128,12 @@ export const useSelectInput = composeHooks(useComboboxInput, useComboboxKeyboard
|
|
|
111
128
|
(_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
129
|
},
|
|
113
130
|
textInputProps: {
|
|
114
|
-
ref:
|
|
131
|
+
ref: textInputElementRef,
|
|
115
132
|
onChange: noop,
|
|
116
133
|
value: model.state.selectedIds.length > 0 && model.state.items.length > 0
|
|
117
134
|
? model.navigation.getItem(model.state.selectedIds[0], model).textValue
|
|
118
135
|
: '',
|
|
119
136
|
},
|
|
120
|
-
ref: elementRef,
|
|
121
137
|
'aria-haspopup': 'menu',
|
|
122
138
|
};
|
|
123
139
|
}));
|
package/modal/lib/Modal.tsx
CHANGED
|
@@ -42,7 +42,7 @@ export const Modal = createContainer()({
|
|
|
42
42
|
/**
|
|
43
43
|
* The `Modal.Card` is wraps a {@link PopupCard Popup.Card} which wraps a {@link Card}. It is
|
|
44
44
|
* the `role="dialog"` element and is uses `useModalCard` behavior hook which sets
|
|
45
|
-
* `aria-modal="
|
|
45
|
+
* `aria-modal="false"` and sets the `aria-labelledby` that points to the `id` of the
|
|
46
46
|
* {@link ModalHeading Modal.Heading}. If you don't use a `Modal.Heading`, add an `aria-label`
|
|
47
47
|
* instead. The default element is a `div` and can be changed via the `as` prop.
|
|
48
48
|
*/
|
|
@@ -5,7 +5,14 @@ export const useModalCard = composeHooks(
|
|
|
5
5
|
usePopupCard,
|
|
6
6
|
createElemPropsHook(usePopupModel)(() => {
|
|
7
7
|
return {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `aria-modal` was added with the intent that screen readers would add support to properly define content within a modal,
|
|
10
|
+
* including popups like a Select. However, when aria-modal is true, it will hide other elements from screen readers,
|
|
11
|
+
* including popups owned by the modal because these popups are siblings to the modal and not ancestors. There is no defined time when Apple/VoiceOver
|
|
12
|
+
* might change this behavior and better support aria-owns, so for the time being we'll explicitly set this to false to provide a better
|
|
13
|
+
* VoiceOver experience.
|
|
14
|
+
*/
|
|
15
|
+
'aria-modal': false,
|
|
9
16
|
};
|
|
10
17
|
})
|
|
11
18
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.52",
|
|
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,8 +49,8 @@
|
|
|
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": "^10.3.
|
|
53
|
-
"@workday/canvas-kit-styling": "^10.3.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^10.3.52",
|
|
53
|
+
"@workday/canvas-kit-styling": "^10.3.52",
|
|
54
54
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
55
55
|
"@workday/canvas-tokens-web": "^1.0.0",
|
|
56
56
|
"@workday/design-assets-types": "^0.2.8",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
69
69
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "3dbd98287262af9e8a614dcc1942652ead4cb2b5"
|
|
72
72
|
}
|
package/select/lib/Select.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
ExtractProps,
|
|
5
5
|
createContainer,
|
|
6
6
|
Themeable,
|
|
7
|
-
useLocalRef,
|
|
8
7
|
} from '@workday/canvas-kit-react/common';
|
|
9
8
|
import {Combobox} from '@workday/canvas-kit-react/combobox';
|
|
10
9
|
|
|
@@ -67,27 +66,6 @@ export const SelectInput = createSubcomponent(TextInput)({
|
|
|
67
66
|
Element,
|
|
68
67
|
model
|
|
69
68
|
) => {
|
|
70
|
-
const {localRef, elementRef} = useLocalRef(ref);
|
|
71
|
-
|
|
72
|
-
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
73
|
-
// the visible input
|
|
74
|
-
React.useImperativeHandle(
|
|
75
|
-
elementRef,
|
|
76
|
-
() => {
|
|
77
|
-
if (localRef.current) {
|
|
78
|
-
localRef.current.focus = (options?: FocusOptions) => {
|
|
79
|
-
textInputProps.ref.current!.focus(options);
|
|
80
|
-
};
|
|
81
|
-
localRef.current.blur = () => {
|
|
82
|
-
textInputProps.ref.current!.blur();
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return localRef.current!;
|
|
87
|
-
},
|
|
88
|
-
[textInputProps.ref, localRef]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
69
|
return (
|
|
92
70
|
<InputGroup>
|
|
93
71
|
{inputStartIcon && model.state.selectedIds.length > 0 && (
|
|
@@ -106,7 +84,7 @@ export const SelectInput = createSubcomponent(TextInput)({
|
|
|
106
84
|
onInput={onInput}
|
|
107
85
|
value={value}
|
|
108
86
|
name={name}
|
|
109
|
-
ref={
|
|
87
|
+
ref={ref}
|
|
110
88
|
/>
|
|
111
89
|
{/* Visual input */}
|
|
112
90
|
<InputGroup.Input
|
|
@@ -28,8 +28,34 @@ export const useSelectInput = composeHooks(
|
|
|
28
28
|
useComboboxMoveCursorToSelected,
|
|
29
29
|
createElemPropsHook(useSelectModel)(
|
|
30
30
|
(model, ref, elemProps: {keySofar?: string; placeholder?: string; value?: string} = {}) => {
|
|
31
|
-
const
|
|
32
|
-
const textInputRef =
|
|
31
|
+
// const textInputRef = React.useRef<HTMLInputElement>(null);
|
|
32
|
+
const {elementRef: textInputElementRef, localRef: textInputRef} = useLocalRef(
|
|
33
|
+
// PopupModel says the targetRef is a `HTMLButtonElement`, but it is a `HTMLInputElement`
|
|
34
|
+
model.state.targetRef as any as React.Ref<HTMLInputElement>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const {localRef, elementRef} = useLocalRef(ref as React.Ref<HTMLInputElement>);
|
|
38
|
+
|
|
39
|
+
// We need to create a proxy between the multiple inputs. We need to redirect a few methods to
|
|
40
|
+
// the visible input
|
|
41
|
+
React.useImperativeHandle(
|
|
42
|
+
elementRef,
|
|
43
|
+
() => {
|
|
44
|
+
if (localRef.current) {
|
|
45
|
+
localRef.current.focus = (options?: FocusOptions) => {
|
|
46
|
+
textInputRef.current!.focus(options);
|
|
47
|
+
};
|
|
48
|
+
localRef.current.blur = () => {
|
|
49
|
+
textInputRef.current!.blur();
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return localRef.current!;
|
|
54
|
+
},
|
|
55
|
+
[textInputRef, localRef]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// Remap the Popup model's targetRef to be the visible ref. `ref` and `model.state.targetRef` are already linked. We have to override that.
|
|
33
59
|
|
|
34
60
|
// Update the text value of the input
|
|
35
61
|
const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -151,14 +177,13 @@ export const useSelectInput = composeHooks(
|
|
|
151
177
|
textInputRef.current?.focus();
|
|
152
178
|
},
|
|
153
179
|
textInputProps: {
|
|
154
|
-
ref:
|
|
180
|
+
ref: textInputElementRef,
|
|
155
181
|
onChange: noop,
|
|
156
182
|
value:
|
|
157
183
|
model.state.selectedIds.length > 0 && model.state.items.length > 0
|
|
158
184
|
? model.navigation.getItem(model.state.selectedIds[0], model).textValue
|
|
159
185
|
: '',
|
|
160
186
|
},
|
|
161
|
-
ref: elementRef,
|
|
162
187
|
'aria-haspopup': 'menu',
|
|
163
188
|
} as const;
|
|
164
189
|
}
|