@carbon/react 1.22.0-rc.0 → 1.23.0-rc.0
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/es/{es/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/es/{es/components → components}/Checkbox/Checkbox.d.ts +0 -0
- package/es/{es/components → components}/Checkbox/index.d.ts +0 -0
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- package/es/components/ComboBox/ComboBox.d.ts +151 -0
- package/es/components/ComboBox/ComboBox.js +28 -21
- package/es/components/ComposedModal/ComposedModal.js +2 -2
- package/es/{es/components → components}/DataTable/TableSelectAll.d.ts +0 -0
- package/es/components/DataTable/TableSelectRow.d.ts +88 -0
- package/es/components/DataTable/TableSelectRow.js +3 -5
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/es/components/DatePicker/plugins/rangePlugin.js +1 -1
- package/es/{es/components → components}/Dropdown/Dropdown.d.ts +0 -0
- package/es/{es/components → components}/Dropdown/index.d.ts +0 -0
- package/es/components/FileUploader/FileUploaderButton.js +14 -16
- package/es/{es/components → components}/FluidForm/FluidForm.d.ts +0 -0
- package/es/{es/components → components}/FluidForm/FormContext.d.ts +0 -0
- package/es/{es/components → components}/FluidForm/index.d.ts +0 -0
- package/es/components/FluidSelect/FluidSelect.js +1 -0
- package/es/components/IconButton/index.js +1 -0
- package/es/{es/components → components}/ListBox/ListBox.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxField.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
- package/es/{es/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
- package/es/{es/components → components}/ListBox/index.d.ts +0 -0
- package/es/{es/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
- package/es/components/NumberInput/NumberInput.d.ts +132 -0
- package/es/components/NumberInput/NumberInput.js +9 -7
- package/es/components/OverflowMenu/OverflowMenu.js +28 -34
- package/es/components/Pagination/Pagination.js +1 -0
- package/es/components/Pagination/experimental/PageSelector.js +1 -0
- package/es/components/Pagination/experimental/Pagination.js +1 -0
- package/es/components/Select/Select.Skeleton.d.ts +33 -0
- package/es/components/Select/index.js +1 -0
- package/es/{es/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
- package/es/{es/components → components}/Text/Text.d.ts +0 -0
- package/es/{es/components → components}/Text/TextDirection.d.ts +0 -0
- package/es/{es/components → components}/Text/createTextComponent.d.ts +0 -0
- package/es/{es/components → components}/Text/index.d.ts +0 -0
- package/es/components/TextArea/TextArea.js +1 -0
- package/es/components/Toggle/Toggle.js +54 -33
- package/es/components/Toggletip/index.js +26 -1
- package/es/components/Tooltip/Tooltip.js +33 -4
- package/es/{es/index.d.ts → index.d.ts} +0 -0
- package/es/internal/FloatingMenu.js +1 -4
- package/es/internal/useNormalizedInputProps.js +3 -3
- package/es/{es/internal → internal}/usePrefix.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/Checkbox.d.ts +0 -0
- package/lib/{lib/components → components}/Checkbox/index.d.ts +0 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +4 -3
- package/lib/components/ComboBox/ComboBox.d.ts +151 -0
- package/lib/components/ComboBox/ComboBox.js +28 -21
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/{lib/components → components}/DataTable/TableSelectAll.d.ts +0 -0
- package/lib/components/DataTable/TableSelectRow.d.ts +88 -0
- package/lib/components/DataTable/TableSelectRow.js +2 -4
- package/lib/components/DatePicker/DatePicker.js +9 -8
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +10 -1
- package/lib/components/DatePicker/plugins/rangePlugin.js +6 -2
- package/lib/{lib/components → components}/Dropdown/Dropdown.d.ts +0 -0
- package/lib/{lib/components → components}/Dropdown/index.d.ts +0 -0
- package/lib/components/FileUploader/FileUploaderButton.js +14 -16
- package/lib/{lib/components → components}/FluidForm/FluidForm.d.ts +0 -0
- package/lib/{lib/components → components}/FluidForm/FormContext.d.ts +0 -0
- package/lib/{lib/components → components}/FluidForm/index.d.ts +0 -0
- package/lib/components/FluidSelect/FluidSelect.js +1 -0
- package/lib/components/IconButton/index.js +1 -0
- package/lib/{lib/components → components}/ListBox/ListBox.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxField.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenu.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenuIcon.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxMenuItem.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxPropTypes.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/ListBoxSelection.d.ts +0 -0
- package/lib/{lib/components → components}/ListBox/index.d.ts +0 -0
- package/lib/{lib/components → components}/NumberInput/NumberInput.Skeleton.d.ts +0 -0
- package/lib/components/NumberInput/NumberInput.d.ts +132 -0
- package/lib/components/NumberInput/NumberInput.js +9 -7
- package/lib/components/OverflowMenu/OverflowMenu.js +27 -52
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/experimental/PageSelector.js +1 -0
- package/lib/components/Pagination/experimental/Pagination.js +1 -0
- package/lib/components/Select/Select.Skeleton.d.ts +33 -0
- package/lib/components/Select/index.js +2 -0
- package/lib/{lib/components → components}/Slider/Slider.Skeleton.d.ts +0 -0
- package/lib/{lib/components → components}/Text/Text.d.ts +0 -0
- package/lib/{lib/components → components}/Text/TextDirection.d.ts +0 -0
- package/lib/{lib/components → components}/Text/createTextComponent.d.ts +0 -0
- package/lib/{lib/components → components}/Text/index.d.ts +0 -0
- package/lib/components/TextArea/TextArea.js +1 -0
- package/lib/components/Toggle/Toggle.js +53 -32
- package/lib/components/Toggletip/index.js +26 -1
- package/lib/components/Tooltip/Tooltip.js +31 -2
- package/lib/{lib/index.d.ts → index.d.ts} +0 -0
- package/lib/internal/FloatingMenu.js +1 -4
- package/lib/internal/useNormalizedInputProps.js +3 -3
- package/lib/{lib/internal → internal}/usePrefix.d.ts +0 -0
- package/package.json +4 -6
- package/es/_virtual/ResizeObserver.es.js +0 -13
- package/es/_virtual/_commonjsHelpers.js +0 -42
- package/es/_virtual/index.js +0 -14
- package/es/_virtual/rangePlugin.js +0 -14
- package/es/node_modules/flatpickr/dist/l10n/index.js +0 -1423
- package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -196
- package/es/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1112
- package/es/node_modules/use-resize-observer/polyfilled.js +0 -111
- package/lib/_virtual/ResizeObserver.es.js +0 -17
- package/lib/_virtual/_commonjsHelpers.js +0 -48
- package/lib/_virtual/index.js +0 -18
- package/lib/_virtual/rangePlugin.js +0 -18
- package/lib/node_modules/flatpickr/dist/l10n/index.js +0 -1427
- package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +0 -200
- package/lib/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +0 -1116
- package/lib/node_modules/use-resize-observer/polyfilled.js +0 -119
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
8
|
+
export declare const translationIds: {
|
|
9
|
+
'increment.number': string;
|
|
10
|
+
'decrement.number': string;
|
|
11
|
+
};
|
|
12
|
+
type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
|
|
13
|
+
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
14
|
+
/**
|
|
15
|
+
* `true` to allow empty string.
|
|
16
|
+
*/
|
|
17
|
+
allowEmpty?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Specify an optional className to be applied to the wrapper node
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional starting value for uncontrolled state
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: number | string;
|
|
26
|
+
/**
|
|
27
|
+
* Specify if the wheel functionality for the input should be disabled, or not
|
|
28
|
+
*/
|
|
29
|
+
disableWheel?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Specify if the control should be disabled, or not
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Provide text that is used alongside the control label for additional help
|
|
36
|
+
*/
|
|
37
|
+
helperText?: ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Specify whether you want the underlying label to be visually hidden
|
|
40
|
+
*/
|
|
41
|
+
hideLabel?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify whether you want the steppers to be hidden
|
|
44
|
+
*/
|
|
45
|
+
hideSteppers?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Provide a description for up/down icons that can be read by screen readers
|
|
48
|
+
*/
|
|
49
|
+
iconDescription?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Specify a custom `id` for the input
|
|
52
|
+
*/
|
|
53
|
+
id: string;
|
|
54
|
+
/**
|
|
55
|
+
* Specify if the currently value is invalid.
|
|
56
|
+
*/
|
|
57
|
+
invalid?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Message which is displayed if the value is invalid.
|
|
60
|
+
*/
|
|
61
|
+
invalidText?: ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Generic `label` that will be used as the textual representation of what
|
|
64
|
+
* this field is for
|
|
65
|
+
*/
|
|
66
|
+
label?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* `true` to use the light version.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated The `light` prop for `NumberInput` is no longer needed and has
|
|
71
|
+
* been deprecated in v11 in favor of the new `Layer` component. It will be moved in the next major release.
|
|
72
|
+
*/
|
|
73
|
+
light?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The maximum value.
|
|
76
|
+
*/
|
|
77
|
+
max?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The minimum value.
|
|
80
|
+
*/
|
|
81
|
+
min?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Provide an optional handler that is called when the internal state of
|
|
84
|
+
* NumberInput changes. This handler is called with event and state info.
|
|
85
|
+
* `(event, { value, direction }) => void`
|
|
86
|
+
*/
|
|
87
|
+
onChange?: (event: React.MouseEvent<HTMLButtonElement>, state: {
|
|
88
|
+
value: number | string;
|
|
89
|
+
direction: string;
|
|
90
|
+
}) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Provide an optional function to be called when the up/down button is clicked
|
|
93
|
+
*/
|
|
94
|
+
onClick?: (event: React.MouseEvent<HTMLElement>, state?: {
|
|
95
|
+
value: number | string;
|
|
96
|
+
direction: string;
|
|
97
|
+
}) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Provide an optional function to be called when a key is pressed in the number input
|
|
100
|
+
*/
|
|
101
|
+
onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
102
|
+
/**
|
|
103
|
+
* Specify if the component should be read-only
|
|
104
|
+
*/
|
|
105
|
+
readOnly?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Specify the size of the Number Input.
|
|
108
|
+
*/
|
|
109
|
+
size?: 'sm' | 'md' | 'lg';
|
|
110
|
+
/**
|
|
111
|
+
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
112
|
+
*/
|
|
113
|
+
step?: number;
|
|
114
|
+
/**
|
|
115
|
+
* Provide custom text for the component for each translation id
|
|
116
|
+
*/
|
|
117
|
+
translateWithId?: (id: string) => string;
|
|
118
|
+
/**
|
|
119
|
+
* Specify the value of the input
|
|
120
|
+
*/
|
|
121
|
+
value?: number | string;
|
|
122
|
+
/**
|
|
123
|
+
* Specify whether the control is currently in warning state
|
|
124
|
+
*/
|
|
125
|
+
warn?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Provide the text that is displayed when the control is in warning state
|
|
128
|
+
*/
|
|
129
|
+
warnText?: ReactNode;
|
|
130
|
+
}
|
|
131
|
+
declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<unknown>>;
|
|
132
|
+
export { NumberInput };
|
|
@@ -127,11 +127,12 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
127
127
|
var iconClasses = cx((_cx3 = {}, _defineProperty(_cx3, "".concat(prefix, "--number__invalid"), normalizedProps.invalid || normalizedProps.warn), _defineProperty(_cx3, "".concat(prefix, "--number__invalid--warning"), normalizedProps.warn), _cx3));
|
|
128
128
|
|
|
129
129
|
if (controlledValue !== prevControlledValue) {
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
130
131
|
setValue(controlledValue);
|
|
131
132
|
setPrevControlledValue(controlledValue);
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
var ariaDescribedBy =
|
|
135
|
+
var ariaDescribedBy = undefined;
|
|
135
136
|
|
|
136
137
|
if (normalizedProps.invalid) {
|
|
137
138
|
ariaDescribedBy = normalizedProps.invalidId;
|
|
@@ -158,7 +159,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
var handleFocus = function handleFocus(evt) {
|
|
161
|
-
if (evt.target.type === 'button') {
|
|
162
|
+
if ('type' in evt.target && evt.target.type === 'button') {
|
|
162
163
|
setIsFocused(false);
|
|
163
164
|
} else {
|
|
164
165
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
@@ -166,10 +167,11 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
var outerElementClasses = cx("".concat(prefix, "--form-item"), (_cx4 = {}, _defineProperty(_cx4, customClassName, !!customClassName), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--invalid"), isFluid && normalizedProps.invalid), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--focus"), isFluid && isFocused), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--disabled"), isFluid && disabled), _cx4));
|
|
170
|
+
var Icon = normalizedProps.icon;
|
|
169
171
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
170
172
|
className: outerElementClasses,
|
|
171
|
-
onFocus: isFluid ? handleFocus :
|
|
172
|
-
onBlur: isFluid ? handleFocus :
|
|
173
|
+
onFocus: isFluid ? handleFocus : undefined,
|
|
174
|
+
onBlur: isFluid ? handleFocus : undefined
|
|
173
175
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
174
176
|
className: numberInputClasses,
|
|
175
177
|
"data-invalid": normalizedProps.invalid ? true : undefined
|
|
@@ -215,7 +217,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
215
217
|
step: step,
|
|
216
218
|
type: "number",
|
|
217
219
|
value: value
|
|
218
|
-
})),
|
|
220
|
+
})), Icon ? /*#__PURE__*/React__default.createElement(Icon, {
|
|
219
221
|
className: iconClasses
|
|
220
222
|
}) : null, !hideSteppers && /*#__PURE__*/React__default.createElement("div", {
|
|
221
223
|
className: "".concat(prefix, "--number__controls")
|
|
@@ -238,7 +240,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
238
240
|
_onClick(event, state);
|
|
239
241
|
}
|
|
240
242
|
},
|
|
241
|
-
tabIndex:
|
|
243
|
+
tabIndex: -1,
|
|
242
244
|
title: decrementNumLabel || iconDescription,
|
|
243
245
|
type: "button"
|
|
244
246
|
}, _Subtract || (_Subtract = /*#__PURE__*/React__default.createElement(Subtract, {
|
|
@@ -264,7 +266,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
264
266
|
_onClick(event, state);
|
|
265
267
|
}
|
|
266
268
|
},
|
|
267
|
-
tabIndex:
|
|
269
|
+
tabIndex: -1,
|
|
268
270
|
title: incrementNumLabel || iconDescription,
|
|
269
271
|
type: "button"
|
|
270
272
|
}, _Add || (_Add = /*#__PURE__*/React__default.createElement(Add, {
|
|
@@ -15,10 +15,10 @@ import FloatingMenu, { DIRECTION_TOP, DIRECTION_BOTTOM } from '../../internal/Fl
|
|
|
15
15
|
import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
16
16
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
17
17
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
18
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
19
18
|
import deprecate from '../../prop-types/deprecate.js';
|
|
19
|
+
import { IconButton } from '../IconButton/index.js';
|
|
20
20
|
import { matches } from '../../internal/keyboard/match.js';
|
|
21
|
-
import {
|
|
21
|
+
import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft, Escape } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
23
|
var _excluded = ["id", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
|
|
24
24
|
|
|
@@ -129,14 +129,14 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
133
|
-
|
|
134
|
-
_this.setState({
|
|
135
|
-
open: !_this.state.open
|
|
136
|
-
});
|
|
132
|
+
_defineProperty(_assertThisInitialized(_this), "closeMenuAndFocus", function () {
|
|
133
|
+
var wasOpen = _this.state.open;
|
|
137
134
|
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
_this.closeMenu(function () {
|
|
136
|
+
if (wasOpen) {
|
|
137
|
+
_this.focusMenuEl();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
_defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (evt) {
|
|
@@ -146,13 +146,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
if (matches(evt, [Escape])) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
_this.closeMenu(function () {
|
|
152
|
-
if (wasOpen) {
|
|
153
|
-
_this.focusMenuEl();
|
|
154
|
-
}
|
|
155
|
-
}); // Stop the esc keypress from bubbling out and closing something it shouldn't
|
|
149
|
+
_this.closeMenuAndFocus(); // Stop the esc keypress from bubbling out and closing something it shouldn't
|
|
156
150
|
|
|
157
151
|
|
|
158
152
|
evt.stopPropagation();
|
|
@@ -187,8 +181,6 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
187
181
|
});
|
|
188
182
|
|
|
189
183
|
_defineProperty(_assertThisInitialized(_this), "handleOverflowMenuItemFocus", function (_ref) {
|
|
190
|
-
var _overflowMenuItem$cur;
|
|
191
|
-
|
|
192
184
|
var currentIndex = _ref.currentIndex,
|
|
193
185
|
direction = _ref.direction;
|
|
194
186
|
var enabledIndices = React__default.Children.toArray(_this.props.children).reduce(function (acc, curr, i) {
|
|
@@ -202,7 +194,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
202
194
|
var nextValidIndex = function () {
|
|
203
195
|
var nextIndex = enabledIndices.indexOf(currentIndex) + direction;
|
|
204
196
|
|
|
205
|
-
switch (
|
|
197
|
+
switch (nextIndex) {
|
|
206
198
|
case -1:
|
|
207
199
|
return enabledIndices.length - 1;
|
|
208
200
|
|
|
@@ -214,9 +206,9 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
214
206
|
}
|
|
215
207
|
}();
|
|
216
208
|
|
|
217
|
-
var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])]
|
|
209
|
+
var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])];
|
|
218
210
|
|
|
219
|
-
overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 :
|
|
211
|
+
overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : overflowMenuItem.focus();
|
|
220
212
|
});
|
|
221
213
|
|
|
222
214
|
_defineProperty(_assertThisInitialized(_this), "_bindMenuBody", function (menuBody) {
|
|
@@ -240,7 +232,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
240
232
|
|
|
241
233
|
if (typeof target.matches === 'function') {
|
|
242
234
|
if (!menuBody.contains(target) && triggerEl && !target.matches(".".concat(_this.context, "--overflow-menu,.").concat(_this.context, "--overflow-menu-options"))) {
|
|
243
|
-
_this.
|
|
235
|
+
_this.closeMenuAndFocus();
|
|
244
236
|
}
|
|
245
237
|
}
|
|
246
238
|
}, !hasFocusin);
|
|
@@ -324,7 +316,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
324
316
|
var _child$props;
|
|
325
317
|
|
|
326
318
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
327
|
-
closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.
|
|
319
|
+
closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenuAndFocus,
|
|
328
320
|
handleOverflowMenuItemFocus: _this2.handleOverflowMenuItemFocus,
|
|
329
321
|
ref: function ref(e) {
|
|
330
322
|
_this2["overflowMenuItem".concat(index)] = e;
|
|
@@ -336,7 +328,8 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
336
328
|
className: overflowMenuOptionsClasses,
|
|
337
329
|
tabIndex: "-1",
|
|
338
330
|
role: "menu",
|
|
339
|
-
"aria-label": ariaLabel
|
|
331
|
+
"aria-label": ariaLabel,
|
|
332
|
+
onKeyDown: this.handleKeyPress
|
|
340
333
|
}, childrenWithProps);
|
|
341
334
|
var wrappedMenuBody = /*#__PURE__*/React__default.createElement(FloatingMenu, {
|
|
342
335
|
focusTrap: focusTrap,
|
|
@@ -357,17 +350,18 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
357
350
|
};
|
|
358
351
|
return /*#__PURE__*/React__default.createElement(ClickListener, {
|
|
359
352
|
onClickOutside: this.handleClickOutside
|
|
360
|
-
}, /*#__PURE__*/React__default.createElement("
|
|
353
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
354
|
+
className: "".concat(prefix, "--overflow-menu__wrapper")
|
|
355
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, _extends({}, other, {
|
|
361
356
|
type: "button",
|
|
362
357
|
"aria-haspopup": true,
|
|
363
358
|
"aria-expanded": this.state.open,
|
|
364
359
|
className: overflowMenuClasses,
|
|
365
|
-
onKeyDown: this.handleKeyPress,
|
|
366
360
|
onClick: this.handleClick,
|
|
367
|
-
"aria-label": ariaLabel,
|
|
368
361
|
id: id,
|
|
369
|
-
ref: mergeRefs(this._triggerRef, ref)
|
|
370
|
-
|
|
362
|
+
ref: mergeRefs(this._triggerRef, ref),
|
|
363
|
+
label: iconDescription
|
|
364
|
+
}), /*#__PURE__*/React__default.createElement(IconElement, iconProps)), open && this.state.hasMountedTrigger && wrappedMenuBody));
|
|
371
365
|
}
|
|
372
366
|
}], [{
|
|
373
367
|
key: "getDerivedStateFromProps",
|
|
@@ -388,7 +382,7 @@ _defineProperty(OverflowMenu, "propTypes", {
|
|
|
388
382
|
/**
|
|
389
383
|
* The ARIA label.
|
|
390
384
|
*/
|
|
391
|
-
ariaLabel:
|
|
385
|
+
ariaLabel: PropTypes.string.isRequired,
|
|
392
386
|
|
|
393
387
|
/**
|
|
394
388
|
* The child nodes.
|
|
@@ -434,7 +428,7 @@ _defineProperty(OverflowMenu, "propTypes", {
|
|
|
434
428
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
435
429
|
* Don't use this to make OverflowMenu background color same as container background color.
|
|
436
430
|
*/
|
|
437
|
-
light:
|
|
431
|
+
light: deprecate(PropTypes.bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
438
432
|
|
|
439
433
|
/**
|
|
440
434
|
* The adjustment in position applied to the floating menu.
|
|
@@ -501,14 +495,14 @@ _defineProperty(OverflowMenu, "propTypes", {
|
|
|
501
495
|
/**
|
|
502
496
|
* Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
503
497
|
*/
|
|
504
|
-
size:
|
|
498
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
505
499
|
});
|
|
506
500
|
|
|
507
501
|
_defineProperty(OverflowMenu, "contextType", PrefixContext);
|
|
508
502
|
|
|
509
503
|
_defineProperty(OverflowMenu, "defaultProps", {
|
|
510
|
-
ariaLabel:
|
|
511
|
-
iconDescription: '
|
|
504
|
+
ariaLabel: null,
|
|
505
|
+
iconDescription: 'Options',
|
|
512
506
|
open: false,
|
|
513
507
|
direction: DIRECTION_BOTTOM,
|
|
514
508
|
flipped: false,
|
|
@@ -11,6 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import React__default, { useRef, useState } from 'react';
|
|
13
13
|
import Select from '../Select/Select.js';
|
|
14
|
+
import '../Select/Select.Skeleton.js';
|
|
14
15
|
import SelectItem from '../SelectItem/SelectItem.js';
|
|
15
16
|
import { equals } from '../../tools/array.js';
|
|
16
17
|
import { useFallbackId } from '../../internal/useId.js';
|
|
@@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import setupGetInstanceId from '../../../tools/setupGetInstanceId.js';
|
|
13
13
|
import Select from '../../Select/Select.js';
|
|
14
|
+
import '../../Select/Select.Skeleton.js';
|
|
14
15
|
import SelectItem from '../../SelectItem/SelectItem.js';
|
|
15
16
|
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
16
17
|
|
|
@@ -12,6 +12,7 @@ import cx from 'classnames';
|
|
|
12
12
|
import { CaretLeft, CaretRight } from '@carbon/icons-react';
|
|
13
13
|
import Button from '../../Button/Button.js';
|
|
14
14
|
import Select from '../../Select/Select.js';
|
|
15
|
+
import '../../Select/Select.Skeleton.js';
|
|
15
16
|
import SelectItem from '../../SelectItem/SelectItem.js';
|
|
16
17
|
import { IconButton } from '../../IconButton/index.js';
|
|
17
18
|
import * as FeatureFlags from '@carbon/feature-flags';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2018
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { HTMLAttributes } from 'react';
|
|
9
|
+
export interface SelectSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to add to the form item wrapper.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify whether the label should be hidden, or not
|
|
16
|
+
*/
|
|
17
|
+
hideLabel?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const SelectSkeleton: {
|
|
20
|
+
({ hideLabel, className, ...rest }: SelectSkeletonProps): JSX.Element;
|
|
21
|
+
propTypes: {
|
|
22
|
+
/**
|
|
23
|
+
* Specify an optional className to add to the form item wrapper.
|
|
24
|
+
*/
|
|
25
|
+
className: PropTypes.Requireable<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Specify whether the label should be hidden, or not
|
|
28
|
+
*/
|
|
29
|
+
hideLabel: PropTypes.Requireable<boolean>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default SelectSkeleton;
|
|
33
|
+
export { SelectSkeleton };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -104,6 +104,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, fo
|
|
|
104
104
|
useIsomorphicEffect(function () {
|
|
105
105
|
if (other.cols) {
|
|
106
106
|
textareaRef.current.style.width = null;
|
|
107
|
+
textareaRef.current.style.resize = 'none';
|
|
107
108
|
} else {
|
|
108
109
|
textareaRef.current.style.width = "100%";
|
|
109
110
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { useRef } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
@@ -41,6 +41,7 @@ function Toggle(_ref) {
|
|
|
41
41
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
42
42
|
|
|
43
43
|
var prefix = usePrefix();
|
|
44
|
+
var buttonElement = useRef(null);
|
|
44
45
|
|
|
45
46
|
var _useControllableState = useControllableState({
|
|
46
47
|
value: toggled,
|
|
@@ -69,37 +70,53 @@ function Toggle(_ref) {
|
|
|
69
70
|
var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
70
71
|
var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
|
|
71
72
|
var switchClasses = cx("".concat(prefix, "--toggle__switch"), _defineProperty({}, "".concat(prefix, "--toggle__switch--checked"), checked));
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
73
|
+
return (
|
|
74
|
+
/*#__PURE__*/
|
|
75
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
76
|
+
React__default.createElement("div", {
|
|
77
|
+
className: wrapperClasses,
|
|
78
|
+
onClick: ariaLabelledby ? function (e) {
|
|
79
|
+
// the underlying <button> can only be activated by keyboard as it is visually hidden;
|
|
80
|
+
// therefore, if this event's target is the <button>, it had to be triggered by
|
|
81
|
+
// the keyboard event which already calls handleClick. if we wouldn't catch this, the
|
|
82
|
+
// onClick and onToggle functions would be called twice whenever the user activates the
|
|
83
|
+
// toggle by keyboard and props['aria-labelledby'] is passed.
|
|
84
|
+
if (buttonElement.current && e.target !== buttonElement.current) {
|
|
85
|
+
handleClick(e);
|
|
86
|
+
buttonElement.current.focus();
|
|
87
|
+
}
|
|
88
|
+
} : null
|
|
89
|
+
}, /*#__PURE__*/React__default.createElement("button", _extends({}, other, {
|
|
90
|
+
ref: buttonElement,
|
|
91
|
+
id: id,
|
|
92
|
+
className: "".concat(prefix, "--toggle__button"),
|
|
93
|
+
role: "switch",
|
|
94
|
+
type: "button",
|
|
95
|
+
"aria-checked": checked,
|
|
96
|
+
"aria-labelledby": ariaLabelledby,
|
|
97
|
+
disabled: disabled,
|
|
98
|
+
onClick: handleClick
|
|
99
|
+
})), /*#__PURE__*/React__default.createElement(LabelComponent, {
|
|
100
|
+
htmlFor: ariaLabelledby ? null : id,
|
|
101
|
+
className: "".concat(prefix, "--toggle__label")
|
|
102
|
+
}, labelText && /*#__PURE__*/React__default.createElement("span", {
|
|
103
|
+
className: labelTextClasses
|
|
104
|
+
}, labelText), /*#__PURE__*/React__default.createElement("div", {
|
|
105
|
+
className: appearanceClasses
|
|
106
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
107
|
+
className: switchClasses
|
|
108
|
+
}, isSm && /*#__PURE__*/React__default.createElement("svg", {
|
|
109
|
+
className: "".concat(prefix, "--toggle__check"),
|
|
110
|
+
width: "6px",
|
|
111
|
+
height: "5px",
|
|
112
|
+
viewBox: "0 0 6 5"
|
|
113
|
+
}, _path || (_path = /*#__PURE__*/React__default.createElement("path", {
|
|
114
|
+
d: "M2.2 2.7L5 0 6 1 2.2 5 0 2.7 1 1.5z"
|
|
115
|
+
})))), renderSideLabel && /*#__PURE__*/React__default.createElement("span", {
|
|
116
|
+
className: "".concat(prefix, "--toggle__text"),
|
|
117
|
+
"aria-hidden": "true"
|
|
118
|
+
}, sideLabel))))
|
|
119
|
+
);
|
|
103
120
|
}
|
|
104
121
|
Toggle.propTypes = {
|
|
105
122
|
/**
|
|
@@ -123,7 +140,11 @@ Toggle.propTypes = {
|
|
|
123
140
|
disabled: PropTypes.bool,
|
|
124
141
|
|
|
125
142
|
/**
|
|
126
|
-
*
|
|
143
|
+
* If true, the side labels (props.labelA and props.labelB) will be replaced by
|
|
144
|
+
* props.labelText, so that the toggle doesn't render a top label. In order to fully
|
|
145
|
+
* hide any labels, you can use props['aria-labelledby'] to refer to another element
|
|
146
|
+
* that labels the toggle. props.labelText would no longer be required in that case
|
|
147
|
+
* and can therefore be omitted.
|
|
127
148
|
*/
|
|
128
149
|
hideLabel: PropTypes.bool,
|
|
129
150
|
|
|
@@ -102,10 +102,34 @@ function Toggletip(_ref2) {
|
|
|
102
102
|
|
|
103
103
|
function onKeyDown(event) {
|
|
104
104
|
if (open && match(event, Escape)) {
|
|
105
|
-
actions.close();
|
|
105
|
+
actions.close(); // If the menu is closed while focus is still inside the menu, it should return to the trigger button (#12922)
|
|
106
|
+
|
|
107
|
+
var button = ref.current.children[0];
|
|
108
|
+
|
|
109
|
+
if (button && button.type === 'button') {
|
|
110
|
+
button.focus();
|
|
111
|
+
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
|
|
115
|
+
function handleBlur(event) {
|
|
116
|
+
// Do not close if the menu itself is clicked, should only close on focus out
|
|
117
|
+
if (open && event.relatedTarget === null) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
122
|
+
// The menu should be closed when focus leaves the `Toggletip` (#12922)
|
|
123
|
+
actions.close();
|
|
124
|
+
}
|
|
125
|
+
} // If the `Toggletip` is the last focusable item in the tab order, it shoudl also close when the browser window loses focus (#12922)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
useWindowEvent('blur', function () {
|
|
129
|
+
if (open) {
|
|
130
|
+
actions.close();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
109
133
|
useWindowEvent('click', function (event) {
|
|
110
134
|
if (open && !ref.current.contains(event.target)) {
|
|
111
135
|
actions.close();
|
|
@@ -122,6 +146,7 @@ function Toggletip(_ref2) {
|
|
|
122
146
|
highContrast: true,
|
|
123
147
|
open: open,
|
|
124
148
|
onKeyDown: onKeyDown,
|
|
149
|
+
onBlur: handleBlur,
|
|
125
150
|
ref: ref
|
|
126
151
|
}, children));
|
|
127
152
|
}
|