carbon-react 107.1.4 → 107.1.7
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/esm/__internal__/input/input.component.js +3 -0
- package/esm/__internal__/label/icon-wrapper.style.d.ts +2 -0
- package/esm/__internal__/label/icon-wrapper.style.js +4 -4
- package/esm/__internal__/label/index.d.ts +2 -1
- package/esm/__internal__/label/label.component.d.ts +27 -0
- package/esm/__internal__/label/label.component.js +42 -80
- package/esm/__internal__/label/label.style.d.ts +23 -3
- package/esm/__internal__/label/label.style.js +4 -19
- package/esm/__internal__/utils/helpers/events/events.d.ts +0 -58
- package/esm/__internal__/utils/helpers/events/events.js +12 -128
- package/esm/__spec_helper__/test-utils.d.ts +4 -25
- package/esm/__spec_helper__/test-utils.js +12 -25
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -4
- package/esm/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
- package/esm/components/anchor-navigation/anchor-navigation.component.js +55 -72
- package/esm/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
- package/esm/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
- package/esm/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
- package/esm/components/anchor-navigation/index.d.ts +5 -3
- package/esm/components/anchor-navigation/index.js +1 -1
- package/esm/components/date/__internal__/date-picker/date-picker.component.js +10 -1
- package/esm/components/date/__internal__/weekday/weekday.style.js +1 -1
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +3 -3
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
- package/esm/components/help/help.style.d.ts +2 -0
- package/esm/components/menu/__internal__/spec-helper/index.js +1 -2
- package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +3 -0
- package/esm/components/numeral-date/numeral-date.component.js +1 -1
- package/esm/components/search/search.component.js +1 -2
- package/lib/__internal__/input/input.component.js +3 -0
- package/lib/__internal__/label/icon-wrapper.style.d.ts +2 -0
- package/lib/__internal__/label/icon-wrapper.style.js +2 -2
- package/lib/__internal__/label/index.d.ts +2 -1
- package/lib/__internal__/label/label.component.d.ts +27 -0
- package/lib/__internal__/label/label.component.js +40 -78
- package/lib/__internal__/label/label.style.d.ts +23 -3
- package/lib/__internal__/label/label.style.js +4 -22
- package/lib/__internal__/utils/helpers/events/events.d.ts +0 -58
- package/lib/__internal__/utils/helpers/events/events.js +12 -128
- package/lib/__spec_helper__/test-utils.d.ts +4 -25
- package/lib/__spec_helper__/test-utils.js +12 -25
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +2 -2
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.d.ts +19 -0
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.component.js +14 -21
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.d.ts +5 -0
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.style.js +0 -7
- package/lib/components/anchor-navigation/anchor-navigation.component.d.ts +14 -0
- package/lib/components/anchor-navigation/anchor-navigation.component.js +57 -73
- package/lib/components/anchor-navigation/anchor-navigation.style.d.ts +4 -0
- package/lib/components/anchor-navigation/anchor-section-divider.component.d.ts +4 -0
- package/lib/components/anchor-navigation/{anchor-section-divider/anchor-section-divider.style.js → anchor-section-divider.component.js} +3 -2
- package/lib/components/anchor-navigation/index.d.ts +5 -3
- package/lib/components/anchor-navigation/index.js +1 -1
- package/lib/components/date/__internal__/date-picker/date-picker.component.js +10 -1
- package/lib/components/date/__internal__/weekday/weekday.style.js +1 -1
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +1 -0
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +1 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +2 -4
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +1 -0
- package/lib/components/help/help.style.d.ts +2 -0
- package/lib/components/menu/__internal__/spec-helper/index.js +1 -2
- package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +3 -0
- package/lib/components/numeral-date/numeral-date.component.js +1 -1
- package/lib/components/search/search.component.js +1 -3
- package/package.json +1 -1
- package/esm/__internal__/label/label.d.ts +0 -43
- package/esm/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
- package/esm/components/anchor-navigation/anchor-navigation.d.ts +0 -11
- package/esm/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
- package/lib/__internal__/label/label.d.ts +0 -43
- package/lib/components/anchor-navigation/anchor-navigation-item/anchor-navigation-item.d.ts +0 -23
- package/lib/components/anchor-navigation/anchor-navigation.d.ts +0 -11
- package/lib/components/anchor-navigation/anchor-section-divider/anchor-section-divider.d.ts +0 -12
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.Label = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -41,30 +41,30 @@ const tooltipPosition = ({
|
|
|
41
41
|
info,
|
|
42
42
|
inline
|
|
43
43
|
}) => {
|
|
44
|
-
return (error || warning || info) && inline
|
|
44
|
+
return (error || warning || info) && inline ? "top" : "right";
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
const Label = ({
|
|
48
|
-
disabled,
|
|
49
|
-
inline,
|
|
50
48
|
align = "right",
|
|
51
|
-
width,
|
|
52
|
-
optional,
|
|
53
|
-
labelId,
|
|
54
|
-
tooltipId,
|
|
55
49
|
children,
|
|
50
|
+
disabled,
|
|
56
51
|
error,
|
|
57
|
-
warning,
|
|
58
|
-
info,
|
|
59
52
|
help,
|
|
60
53
|
helpIcon,
|
|
61
54
|
helpTabIndex,
|
|
62
|
-
useValidationIcon = true,
|
|
63
55
|
htmlFor,
|
|
56
|
+
info,
|
|
57
|
+
inline,
|
|
58
|
+
isRequired,
|
|
59
|
+
labelId,
|
|
60
|
+
optional,
|
|
64
61
|
pr,
|
|
65
62
|
pl,
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
tooltipId,
|
|
64
|
+
useValidationIcon = true,
|
|
65
|
+
validationIconId,
|
|
66
|
+
warning,
|
|
67
|
+
width = 30
|
|
68
68
|
}) => {
|
|
69
69
|
const [isFocused, setFocus] = (0, _react.useState)(false);
|
|
70
70
|
const {
|
|
@@ -76,14 +76,14 @@ const Label = ({
|
|
|
76
76
|
onMouseLeave: onGroupMouseLeave
|
|
77
77
|
} = (0, _react.useContext)(_inputBehaviour.InputGroupContext);
|
|
78
78
|
|
|
79
|
-
const handleMouseEnter =
|
|
80
|
-
if (onMouseEnter) onMouseEnter(
|
|
81
|
-
if (onGroupMouseEnter) onGroupMouseEnter(
|
|
79
|
+
const handleMouseEnter = () => {
|
|
80
|
+
if (onMouseEnter) onMouseEnter();
|
|
81
|
+
if (onGroupMouseEnter) onGroupMouseEnter();
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
const handleMouseLeave =
|
|
85
|
-
if (onMouseLeave) onMouseLeave(
|
|
86
|
-
if (onGroupMouseLeave) onGroupMouseLeave(
|
|
84
|
+
const handleMouseLeave = () => {
|
|
85
|
+
if (onMouseLeave) onMouseLeave();
|
|
86
|
+
if (onGroupMouseLeave) onGroupMouseLeave();
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
const icon = () => {
|
|
@@ -141,66 +141,28 @@ const Label = ({
|
|
|
141
141
|
}, children), icon());
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
exports.Label = Label;
|
|
144
145
|
Label.propTypes = {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
/** Children elements */
|
|
167
|
-
children: _propTypes.default.node,
|
|
168
|
-
|
|
169
|
-
/** Status of error validations */
|
|
170
|
-
error: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
171
|
-
|
|
172
|
-
/** Status of warnings */
|
|
173
|
-
warning: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
174
|
-
|
|
175
|
-
/** Status of info */
|
|
176
|
-
info: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
177
|
-
|
|
178
|
-
/** A message that the Help component will display */
|
|
179
|
-
help: _propTypes.default.node,
|
|
180
|
-
|
|
181
|
-
/** Icon type */
|
|
182
|
-
helpIcon: _propTypes.default.string,
|
|
183
|
-
|
|
184
|
-
/** Overrides the default tabindex of the Help component */
|
|
185
|
-
helpTabIndex: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
186
|
-
|
|
187
|
-
/** Whether to show the validation icon */
|
|
188
|
-
useValidationIcon: _propTypes.default.bool,
|
|
189
|
-
|
|
190
|
-
/** A string that represents the ID of another form element */
|
|
191
|
-
htmlFor: _propTypes.default.string,
|
|
192
|
-
|
|
193
|
-
/** Padding right, integer multiplied by base spacing constant (8) */
|
|
194
|
-
pr: _propTypes.default.oneOf([1, 2]),
|
|
195
|
-
|
|
196
|
-
/** Padding left, integer multiplied by base spacing constant (8) */
|
|
197
|
-
pl: _propTypes.default.oneOf([1, 2]),
|
|
198
|
-
|
|
199
|
-
/** Flag to configure component as mandatory */
|
|
200
|
-
isRequired: _propTypes.default.bool,
|
|
201
|
-
|
|
202
|
-
/** Id of the validation icon */
|
|
203
|
-
validationIconId: _propTypes.default.string
|
|
146
|
+
"align": _propTypes.default.oneOf(["left", "right"]),
|
|
147
|
+
"children": _propTypes.default.node,
|
|
148
|
+
"disabled": _propTypes.default.bool,
|
|
149
|
+
"error": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
150
|
+
"help": _propTypes.default.node,
|
|
151
|
+
"helpIcon": _propTypes.default.oneOf(["add", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "copy", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "messages", "minus_large", "minus", "mobile", "money_bag", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "three_boxes", "tick_circle", "tick", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
152
|
+
"helpTabIndex": _propTypes.default.string,
|
|
153
|
+
"htmlFor": _propTypes.default.string,
|
|
154
|
+
"info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
155
|
+
"inline": _propTypes.default.bool,
|
|
156
|
+
"isRequired": _propTypes.default.bool,
|
|
157
|
+
"labelId": _propTypes.default.string,
|
|
158
|
+
"optional": _propTypes.default.bool,
|
|
159
|
+
"pl": _propTypes.default.oneOf([1, 2]),
|
|
160
|
+
"pr": _propTypes.default.oneOf([1, 2]),
|
|
161
|
+
"tooltipId": _propTypes.default.string,
|
|
162
|
+
"useValidationIcon": _propTypes.default.bool,
|
|
163
|
+
"validationIconId": _propTypes.default.string,
|
|
164
|
+
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
165
|
+
"width": _propTypes.default.number
|
|
204
166
|
};
|
|
205
167
|
|
|
206
168
|
var _default = /*#__PURE__*/_react.default.memo(Label);
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface StyledLabelProps {
|
|
2
|
+
/** If true, the component will be disabled */
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
/** Flag to configure component as mandatory */
|
|
5
|
+
isRequired?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const StyledLabel: import("styled-components").StyledComponent<"label", any, StyledLabelProps, never>;
|
|
8
|
+
export interface StyledLabelContainerProps {
|
|
9
|
+
/** Label alignment */
|
|
10
|
+
align?: "left" | "right";
|
|
11
|
+
/** When true, label is placed in line an input */
|
|
12
|
+
inline?: boolean;
|
|
13
|
+
/** Flag to configure component as optional in Form */
|
|
14
|
+
optional?: boolean;
|
|
15
|
+
/** Padding right, integer multiplied by base spacing constant (8) */
|
|
16
|
+
pr?: 1 | 2;
|
|
17
|
+
/** Padding left, integer multiplied by base spacing constant (8) */
|
|
18
|
+
pl?: 1 | 2;
|
|
19
|
+
/** Label width */
|
|
20
|
+
width?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const StyledLabelContainer: import("styled-components").StyledComponent<"div", any, StyledLabelContainerProps, never>;
|
|
23
|
+
export default StyledLabel;
|
|
@@ -7,15 +7,11 @@ exports.default = exports.StyledLabelContainer = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
15
11
|
|
|
16
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
13
|
|
|
18
|
-
const
|
|
14
|
+
const StyledLabel = _styledComponents.default.label`
|
|
19
15
|
color: var(--colorsUtilityYin090);
|
|
20
16
|
display: block;
|
|
21
17
|
font-weight: 600; //TODO: (tokens) use token var(--fontWeights500)
|
|
@@ -37,10 +33,7 @@ const LabelStyle = _styledComponents.default.label`
|
|
|
37
33
|
color: var(--colorsUtilityYin030);
|
|
38
34
|
`}
|
|
39
35
|
`;
|
|
40
|
-
|
|
41
|
-
disabled: _propTypes.default.bool,
|
|
42
|
-
isRequired: _propTypes.default.bool
|
|
43
|
-
};
|
|
36
|
+
const DEFAULT_CONTAINER_WIDTH = 30;
|
|
44
37
|
const StyledLabelContainer = _styledComponents.default.div`
|
|
45
38
|
display: flex;
|
|
46
39
|
align-items: center;
|
|
@@ -62,7 +55,7 @@ const StyledLabelContainer = _styledComponents.default.div`
|
|
|
62
55
|
padding-left: var(${pl === 1 ? "--spacing100" : "--spacing200"});
|
|
63
56
|
`};
|
|
64
57
|
justify-content: ${align === "right" ? "flex-end" : "flex-start"};
|
|
65
|
-
width: ${width
|
|
58
|
+
width: ${width || DEFAULT_CONTAINER_WIDTH}%;
|
|
66
59
|
`}
|
|
67
60
|
|
|
68
61
|
${({
|
|
@@ -76,16 +69,5 @@ const StyledLabelContainer = _styledComponents.default.div`
|
|
|
76
69
|
`}
|
|
77
70
|
`;
|
|
78
71
|
exports.StyledLabelContainer = StyledLabelContainer;
|
|
79
|
-
|
|
80
|
-
align: "right",
|
|
81
|
-
width: 30
|
|
82
|
-
};
|
|
83
|
-
StyledLabelContainer.propTypes = {
|
|
84
|
-
align: _propTypes.default.oneOf(["left", "right"]),
|
|
85
|
-
inline: _propTypes.default.bool,
|
|
86
|
-
width: _propTypes.default.number,
|
|
87
|
-
pr: _propTypes.default.number,
|
|
88
|
-
pl: _propTypes.default.number
|
|
89
|
-
};
|
|
90
|
-
var _default = LabelStyle;
|
|
72
|
+
var _default = StyledLabel;
|
|
91
73
|
exports.default = _default;
|
|
@@ -13,41 +13,11 @@ declare const Events: {
|
|
|
13
13
|
* A method to determine if an event is of a particular type
|
|
14
14
|
* */
|
|
15
15
|
isEventType: (ev: React.SyntheticEvent | Event, type: string) => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* A method to determine whether a key down event was an arrow key
|
|
18
|
-
* */
|
|
19
|
-
isNavigationKeyup: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* A method to determine whether a key down event was an enter key
|
|
22
|
-
* */
|
|
23
|
-
isEnterKeyup: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
24
|
-
/**
|
|
25
|
-
* A method to determine whether a key up event is allowed or not.
|
|
26
|
-
* */
|
|
27
|
-
isValidKeypress: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
28
16
|
/**
|
|
29
17
|
* Determines if a number key along the top of the keyboard or a number key on the
|
|
30
18
|
* keypad is pressed
|
|
31
19
|
* */
|
|
32
20
|
isNumberKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Determines if the key pressed is part of the numpad
|
|
35
|
-
* includes symbols
|
|
36
|
-
* */
|
|
37
|
-
isNumpadKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Determines if the key pressed is a alphabet key
|
|
40
|
-
* Case insensitive
|
|
41
|
-
* */
|
|
42
|
-
isAlphabetKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Determines if the key pressed is a valid symbol
|
|
45
|
-
* */
|
|
46
|
-
isSymbolKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Determines if the key pressed is a navigation key
|
|
49
|
-
* */
|
|
50
|
-
isNavigationKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
51
21
|
/**
|
|
52
22
|
* Determines if the key pressed is a navigation left key
|
|
53
23
|
* */
|
|
@@ -64,10 +34,6 @@ declare const Events: {
|
|
|
64
34
|
* Determines if the key pressed is a navigation down key
|
|
65
35
|
* */
|
|
66
36
|
isDownKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Determines if the key pressed is a meta key
|
|
69
|
-
* */
|
|
70
|
-
isMetaKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
71
37
|
/**
|
|
72
38
|
* Determines if the key pressed is the escape key
|
|
73
39
|
* */
|
|
@@ -80,18 +46,6 @@ declare const Events: {
|
|
|
80
46
|
* Determines if the key pressed is the tab key
|
|
81
47
|
* */
|
|
82
48
|
isTabKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Determines if the key pressed is the backspace key
|
|
85
|
-
* */
|
|
86
|
-
isBackspaceKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Determines if the key pressed is the delete key
|
|
89
|
-
* */
|
|
90
|
-
isDeleteKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Determines if the key pressed is the backspace or delete key
|
|
93
|
-
* */
|
|
94
|
-
isDeletingKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
95
49
|
/**
|
|
96
50
|
* Determines if the key pressed is the shift key
|
|
97
51
|
* */
|
|
@@ -104,18 +58,6 @@ declare const Events: {
|
|
|
104
58
|
* Determines if the key pressed is the space key or enter key
|
|
105
59
|
* */
|
|
106
60
|
isEnterOrSpaceKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Determines if the key pressed is the period key
|
|
109
|
-
* */
|
|
110
|
-
isPeriodKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Determines if the key pressed is the comma key
|
|
113
|
-
* */
|
|
114
|
-
isCommaKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Determines if the key pressed is the minus key
|
|
117
|
-
* */
|
|
118
|
-
isMinusKey: (ev: React.KeyboardEvent | KeyboardEvent) => boolean;
|
|
119
61
|
/**
|
|
120
62
|
* Determines if the key pressed is the home key
|
|
121
63
|
* */
|
|
@@ -27,43 +27,6 @@ const Events = {
|
|
|
27
27
|
return ev.type === type;
|
|
28
28
|
},
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* A method to determine whether a key down event was an arrow key
|
|
32
|
-
* */
|
|
33
|
-
isNavigationKeyup: ev => {
|
|
34
|
-
if (!Events.isEventType(ev, "keyup")) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return Events.isNavigationKey(ev);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A method to determine whether a key down event was an enter key
|
|
43
|
-
* */
|
|
44
|
-
isEnterKeyup: ev => {
|
|
45
|
-
if (!Events.isEventType(ev, "keyup")) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return Events.isEnterKey(ev);
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A method to determine whether a key up event is allowed or not.
|
|
54
|
-
* */
|
|
55
|
-
isValidKeypress: ev => {
|
|
56
|
-
if (!Events.isEventType(ev, "keyup")) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (Events.isNumberKey(ev) || Events.isAlphabetKey(ev) || Events.isNumpadKey(ev) || Events.isSymbolKey(ev) || Events.isSpaceKey(ev) || Events.isDeletingKey(ev) || Events.isBackspaceKey(ev)) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return false;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
30
|
/**
|
|
68
31
|
* Determines if a number key along the top of the keyboard or a number key on the
|
|
69
32
|
* keypad is pressed
|
|
@@ -75,167 +38,88 @@ const Events = {
|
|
|
75
38
|
return charCode !== undefined && charCode >= 48 && charCode <= 57;
|
|
76
39
|
},
|
|
77
40
|
|
|
78
|
-
/**
|
|
79
|
-
* Determines if the key pressed is part of the numpad
|
|
80
|
-
* includes symbols
|
|
81
|
-
* */
|
|
82
|
-
isNumpadKey: ev => {
|
|
83
|
-
return ev.which !== undefined && ev.which >= 96 && ev.which <= 111;
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Determines if the key pressed is a alphabet key
|
|
88
|
-
* Case insensitive
|
|
89
|
-
* */
|
|
90
|
-
isAlphabetKey: ev => {
|
|
91
|
-
return ev.which !== undefined && ev.which >= 65 && ev.which <= 90;
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Determines if the key pressed is a valid symbol
|
|
96
|
-
* */
|
|
97
|
-
isSymbolKey: ev => {
|
|
98
|
-
return ev.which !== undefined && (ev.which >= 58 && ev.which <= 64 || ev.which >= 106 && ev.which <= 107 || ev.which >= 186 && ev.which <= 192 || ev.which >= 219 && ev.which <= 222);
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Determines if the key pressed is a navigation key
|
|
103
|
-
* */
|
|
104
|
-
isNavigationKey: ev => {
|
|
105
|
-
return ev.which !== undefined && ev.which >= 37 && ev.which <= 40;
|
|
106
|
-
},
|
|
107
|
-
|
|
108
41
|
/**
|
|
109
42
|
* Determines if the key pressed is a navigation left key
|
|
110
43
|
* */
|
|
111
44
|
isLeftKey: ev => {
|
|
112
|
-
return ev.
|
|
45
|
+
return ev.key === "ArrowLeft";
|
|
113
46
|
},
|
|
114
47
|
|
|
115
48
|
/**
|
|
116
49
|
* Determines if the key pressed is a navigation up key
|
|
117
50
|
* */
|
|
118
51
|
isUpKey: ev => {
|
|
119
|
-
return ev.
|
|
52
|
+
return ev.key === "ArrowUp";
|
|
120
53
|
},
|
|
121
54
|
|
|
122
55
|
/**
|
|
123
56
|
* Determines if the key pressed is a navigation right key
|
|
124
57
|
* */
|
|
125
58
|
isRightKey: ev => {
|
|
126
|
-
return ev.
|
|
59
|
+
return ev.key === "ArrowRight";
|
|
127
60
|
},
|
|
128
61
|
|
|
129
62
|
/**
|
|
130
63
|
* Determines if the key pressed is a navigation down key
|
|
131
64
|
* */
|
|
132
65
|
isDownKey: ev => {
|
|
133
|
-
return ev.
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Determines if the key pressed is a meta key
|
|
138
|
-
* */
|
|
139
|
-
isMetaKey: ev => {
|
|
140
|
-
return !!ev.metaKey;
|
|
66
|
+
return ev.key === "ArrowDown";
|
|
141
67
|
},
|
|
142
68
|
|
|
143
69
|
/**
|
|
144
70
|
* Determines if the key pressed is the escape key
|
|
145
71
|
* */
|
|
146
72
|
isEscKey: ev => {
|
|
147
|
-
return ev.
|
|
73
|
+
return ev.key === "Escape";
|
|
148
74
|
},
|
|
149
75
|
|
|
150
76
|
/**
|
|
151
77
|
* Determines if the key pressed is the enter key
|
|
152
78
|
* */
|
|
153
79
|
isEnterKey: ev => {
|
|
154
|
-
return ev.
|
|
80
|
+
return ev.key === "Enter";
|
|
155
81
|
},
|
|
156
82
|
|
|
157
83
|
/**
|
|
158
84
|
* Determines if the key pressed is the tab key
|
|
159
85
|
* */
|
|
160
86
|
isTabKey: ev => {
|
|
161
|
-
return ev.
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Determines if the key pressed is the backspace key
|
|
166
|
-
* */
|
|
167
|
-
isBackspaceKey: ev => {
|
|
168
|
-
return ev.key === "Backspace";
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Determines if the key pressed is the delete key
|
|
173
|
-
* */
|
|
174
|
-
isDeleteKey: ev => {
|
|
175
|
-
return ev.key === "Delete";
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Determines if the key pressed is the backspace or delete key
|
|
180
|
-
* */
|
|
181
|
-
isDeletingKey: ev => {
|
|
182
|
-
return Events.isDeleteKey(ev) || Events.isBackspaceKey(ev);
|
|
87
|
+
return ev.key === "Tab";
|
|
183
88
|
},
|
|
184
89
|
|
|
185
90
|
/**
|
|
186
91
|
* Determines if the key pressed is the shift key
|
|
187
92
|
* */
|
|
188
93
|
isShiftKey: ev => {
|
|
189
|
-
return ev.shiftKey
|
|
94
|
+
return ev.shiftKey;
|
|
190
95
|
},
|
|
191
96
|
|
|
192
97
|
/**
|
|
193
98
|
* Determines if the key pressed is the space key
|
|
194
99
|
* */
|
|
195
100
|
isSpaceKey: ev => {
|
|
196
|
-
return ev.
|
|
101
|
+
return ev.key === " ";
|
|
197
102
|
},
|
|
198
103
|
|
|
199
104
|
/**
|
|
200
105
|
* Determines if the key pressed is the space key or enter key
|
|
201
106
|
* */
|
|
202
107
|
isEnterOrSpaceKey: ev => {
|
|
203
|
-
return ev.
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Determines if the key pressed is the period key
|
|
208
|
-
* */
|
|
209
|
-
isPeriodKey: ev => {
|
|
210
|
-
return ev.which === 190;
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Determines if the key pressed is the comma key
|
|
215
|
-
* */
|
|
216
|
-
isCommaKey: ev => {
|
|
217
|
-
return ev.which === 188;
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Determines if the key pressed is the minus key
|
|
222
|
-
* */
|
|
223
|
-
isMinusKey: ev => {
|
|
224
|
-
return ev.key === "-" || ev.key === "Subtract";
|
|
108
|
+
return ev.key === "Enter" || ev.key === " ";
|
|
225
109
|
},
|
|
226
110
|
|
|
227
111
|
/**
|
|
228
112
|
* Determines if the key pressed is the home key
|
|
229
113
|
* */
|
|
230
114
|
isHomeKey: ev => {
|
|
231
|
-
return ev.
|
|
115
|
+
return ev.key === "Home";
|
|
232
116
|
},
|
|
233
117
|
|
|
234
118
|
/**
|
|
235
119
|
* Determines if the key pressed is the end key
|
|
236
120
|
* */
|
|
237
121
|
isEndKey: ev => {
|
|
238
|
-
return ev.
|
|
122
|
+
return ev.key === "End";
|
|
239
123
|
},
|
|
240
124
|
|
|
241
125
|
/**
|
|
@@ -8,32 +8,11 @@ declare const assertStyleMatch: <Props>(styleSpec: {
|
|
|
8
8
|
[key: string]: string | number | undefined;
|
|
9
9
|
}, component: ReactWrapper<Props, {}, import("react").Component<{}, {}, any>> | ShallowWrapper<Props, {}, import("react").Component<{}, {}, any>> | ReactTestRendererJSON | ReactTestRendererJSON[] | null, opts?: jest.Options | undefined) => void;
|
|
10
10
|
declare const makeArrayKeys: (n: number) => number[];
|
|
11
|
-
declare const
|
|
12
|
-
readonly UpArrow: 38;
|
|
13
|
-
readonly DownArrow: 40;
|
|
14
|
-
readonly RightArrow: 39;
|
|
15
|
-
readonly LeftArrow: 37;
|
|
16
|
-
readonly Enter: 13;
|
|
17
|
-
readonly Tab: 9;
|
|
18
|
-
readonly Space: 32;
|
|
19
|
-
readonly Escape: 27;
|
|
20
|
-
readonly End: 35;
|
|
21
|
-
readonly Home: 36;
|
|
22
|
-
readonly D: 68;
|
|
23
|
-
readonly E: 69;
|
|
24
|
-
readonly P: 80;
|
|
25
|
-
readonly Z: 90;
|
|
26
|
-
readonly 1: 49;
|
|
27
|
-
};
|
|
28
|
-
declare type Keys = keyof typeof keyMap;
|
|
29
|
-
declare type MappedKeys = `press${Keys}`;
|
|
30
|
-
declare type KeyboardAccumulatorType = Record<MappedKeys, () => void>;
|
|
31
|
-
declare const keyboard: KeyboardAccumulatorType;
|
|
32
|
-
declare type KeydownAccumulatorType = Record<MappedKeys, (wrapper: ReactWrapper<any>, options?: {
|
|
33
|
-
shiftKey: boolean;
|
|
34
|
-
}) => void>;
|
|
11
|
+
declare const keyboard: Record<string, () => void>;
|
|
35
12
|
declare const simulate: {
|
|
36
|
-
keydown:
|
|
13
|
+
keydown: Record<string, (target: ReactWrapper<any>, { shiftKey }?: {
|
|
14
|
+
shiftKey: boolean;
|
|
15
|
+
} | undefined) => void>;
|
|
37
16
|
};
|
|
38
17
|
declare const listFrom: (wrapper: ReactWrapper) => ReactWrapper<import("enzyme").HTMLAttributes, any, import("react").Component<{}, {}, any>>;
|
|
39
18
|
declare const childrenFrom: (node: ReactWrapper) => ReactWrapper<any, any, import("react").Component<{}, {}, any>>;
|
|
@@ -50,30 +50,16 @@ exports.makeArrayKeys = makeArrayKeys;
|
|
|
50
50
|
|
|
51
51
|
const dispatchKeyPress = code => {
|
|
52
52
|
const ev = new KeyboardEvent("keydown", {
|
|
53
|
-
|
|
53
|
+
key: code
|
|
54
54
|
});
|
|
55
55
|
document.dispatchEvent(ev);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Enter: 13,
|
|
64
|
-
Tab: 9,
|
|
65
|
-
Space: 32,
|
|
66
|
-
Escape: 27,
|
|
67
|
-
End: 35,
|
|
68
|
-
Home: 36,
|
|
69
|
-
D: 68,
|
|
70
|
-
E: 69,
|
|
71
|
-
P: 80,
|
|
72
|
-
Z: 90,
|
|
73
|
-
1: 49
|
|
74
|
-
};
|
|
75
|
-
const keyboard = Object.keys(keyMap).reduce((acc, key) => {
|
|
76
|
-
acc[`press${key}`] = () => dispatchKeyPress(keyMap[key]);
|
|
58
|
+
const keys = ["ArrowUp", "ArrowDown", "ArrowRight", "ArrowLeft", "Enter", "Tab", " ", "Escape", "End", "Home", "D", "E", "P", "Z", "1"];
|
|
59
|
+
const keyboard = keys.reduce((acc, key) => {
|
|
60
|
+
const methodName = `press${key === " " ? "Space" : key}`;
|
|
61
|
+
|
|
62
|
+
acc[methodName] = () => dispatchKeyPress(key);
|
|
77
63
|
|
|
78
64
|
return acc;
|
|
79
65
|
}, {}); // Build an object of Enzyme simulate helpers
|
|
@@ -81,16 +67,17 @@ const keyboard = Object.keys(keyMap).reduce((acc, key) => {
|
|
|
81
67
|
// e.g. simulate.keydown.pressEscape(target)
|
|
82
68
|
|
|
83
69
|
exports.keyboard = keyboard;
|
|
84
|
-
const keydown =
|
|
85
|
-
|
|
70
|
+
const keydown = keys.reduce((acc, key) => {
|
|
71
|
+
const methodName = `press${key === " " ? "Space" : key}`;
|
|
72
|
+
|
|
73
|
+
acc[methodName] = (target, {
|
|
86
74
|
shiftKey
|
|
87
75
|
} = {
|
|
88
76
|
shiftKey: false
|
|
89
77
|
}) => {
|
|
90
78
|
target.simulate("keydown", {
|
|
91
79
|
shiftKey,
|
|
92
|
-
key
|
|
93
|
-
which: keyMap[key]
|
|
80
|
+
key
|
|
94
81
|
});
|
|
95
82
|
};
|
|
96
83
|
|
|
@@ -146,7 +133,7 @@ const assertCorrectTraversal = method => expect => ({
|
|
|
146
133
|
expect(arraysEqual(validIndexes, indexesThatWereSelected)).toBeTruthy();
|
|
147
134
|
};
|
|
148
135
|
|
|
149
|
-
const assertKeyboardTraversal = assertCorrectTraversal(() => keyboard.
|
|
136
|
+
const assertKeyboardTraversal = assertCorrectTraversal(() => keyboard.pressArrowDown)(expect);
|
|
150
137
|
exports.assertKeyboardTraversal = assertKeyboardTraversal;
|
|
151
138
|
const assertHoverTraversal = assertCorrectTraversal(wrapper => hoverList(wrapper))(expect);
|
|
152
139
|
exports.assertHoverTraversal = assertHoverTraversal;
|
|
@@ -92,8 +92,8 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
92
92
|
e.preventDefault();
|
|
93
93
|
e.stopPropagation();
|
|
94
94
|
setFocusIndex(items.length - 1);
|
|
95
|
-
} else if (
|
|
96
|
-
//
|
|
95
|
+
} else if (e.key.length === 1) {
|
|
96
|
+
// any printable character: focus the next item on the list that starts with that character
|
|
97
97
|
// selection should wrap to the start of the list
|
|
98
98
|
e.stopPropagation();
|
|
99
99
|
let firstMatch;
|