@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
|
@@ -14,7 +14,7 @@ var PropTypes = require('prop-types');
|
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var flatpickr = require('flatpickr');
|
|
17
|
-
var
|
|
17
|
+
var l10n = require('flatpickr/dist/l10n/index');
|
|
18
18
|
var DatePickerInput = require('../DatePickerInput/DatePickerInput.js');
|
|
19
19
|
var appendToPlugin = require('./plugins/appendToPlugin.js');
|
|
20
20
|
var fixEventsPlugin = require('./plugins/fixEventsPlugin.js');
|
|
@@ -34,16 +34,17 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
34
34
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
35
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
36
36
|
var flatpickr__default = /*#__PURE__*/_interopDefaultLegacy(flatpickr);
|
|
37
|
+
var l10n__default = /*#__PURE__*/_interopDefaultLegacy(l10n);
|
|
37
38
|
|
|
38
39
|
var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "invalid", "invalidText", "warn", "warnText", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "readOnly", "short", "value"];
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
var currentDay =
|
|
41
|
+
l10n__default["default"].en.weekdays.shorthand.forEach(function (_day, index) {
|
|
42
|
+
var currentDay = l10n__default["default"].en.weekdays.shorthand;
|
|
42
43
|
|
|
43
|
-
if (currentDay[index
|
|
44
|
-
currentDay[index
|
|
44
|
+
if (currentDay[index] === 'Thu' || currentDay[index] === 'Th') {
|
|
45
|
+
currentDay[index] = 'Th';
|
|
45
46
|
} else {
|
|
46
|
-
currentDay[index
|
|
47
|
+
currentDay[index] = currentDay[index].charAt(0);
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
var forEach = Array.prototype.forEach;
|
|
@@ -291,9 +292,9 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
291
292
|
|
|
292
293
|
if (_rollupPluginBabelHelpers["typeof"](locale) === 'object') {
|
|
293
294
|
var location = locale.locale ? locale.locale : 'en';
|
|
294
|
-
localeData = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({},
|
|
295
|
+
localeData = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, l10n__default["default"][location]), locale);
|
|
295
296
|
} else {
|
|
296
|
-
localeData =
|
|
297
|
+
localeData = l10n__default["default"][locale];
|
|
297
298
|
}
|
|
298
299
|
|
|
299
300
|
var start = startInputField.current;
|
|
@@ -69,7 +69,16 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
|
|
|
69
69
|
|
|
70
70
|
if (selectedToDate && currentValueToDate && selectedToDate !== currentValueToDate) {
|
|
71
71
|
// Update the calendar with the value of the `to` date input
|
|
72
|
-
fp.setDate([inputFrom.value, inputTo && inputTo.value],
|
|
72
|
+
fp.setDate([inputFrom.value, inputTo && inputTo.value], true, fp.config.dateFormat);
|
|
73
|
+
}
|
|
74
|
+
} // save end date in calendar inmediately after it's been written down
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if (inputTo === target && fp.selectedDates.length === 1 && inputTo.value) {
|
|
78
|
+
var currentEndDate = new Date(inputTo.value);
|
|
79
|
+
|
|
80
|
+
if (currentEndDate.toString() !== 'Invalid Date') {
|
|
81
|
+
fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
84
|
};
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
-
var rangePlugin = require('
|
|
12
|
+
var rangePlugin = require('flatpickr/dist/plugins/rangePlugin');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var rangePlugin__default = /*#__PURE__*/_interopDefaultLegacy(rangePlugin);
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @param {object} config Plugin configuration.
|
|
@@ -20,7 +24,7 @@ var rangePlugin = require('../../../node_modules/flatpickr/dist/plugins/rangePlu
|
|
|
20
24
|
*/
|
|
21
25
|
|
|
22
26
|
var carbonFlatpickrRangePlugin = (function (config) {
|
|
23
|
-
var factory =
|
|
27
|
+
var factory = rangePlugin__default["default"](Object.assign({
|
|
24
28
|
position: 'left'
|
|
25
29
|
}, config));
|
|
26
30
|
return function (fp) {
|
|
File without changes
|
|
File without changes
|
|
@@ -17,6 +17,7 @@ var types = require('../../prop-types/types.js');
|
|
|
17
17
|
var uniqueId = require('../../tools/uniqueId.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
19
|
var FeatureFlags = require('@carbon/feature-flags');
|
|
20
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
20
21
|
var match = require('../../internal/keyboard/match.js');
|
|
21
22
|
var keys = require('../../internal/keyboard/keys.js');
|
|
22
23
|
|
|
@@ -45,7 +46,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
45
46
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
46
47
|
var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
|
|
47
48
|
|
|
48
|
-
var _excluded = ["accept", "buttonKind", "className", "disabled", "disableLabelChanges", "id", "labelText", "multiple", "onChange", "
|
|
49
|
+
var _excluded = ["accept", "buttonKind", "className", "disabled", "disableLabelChanges", "id", "labelText", "multiple", "onChange", "name", "size", "innerRef"];
|
|
49
50
|
|
|
50
51
|
function noop() {}
|
|
51
52
|
|
|
@@ -67,13 +68,9 @@ function FileUploaderButton(_ref) {
|
|
|
67
68
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple,
|
|
68
69
|
_ref$onChange = _ref.onChange,
|
|
69
70
|
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
70
|
-
_ref$role = _ref.role,
|
|
71
|
-
role = _ref$role === void 0 ? 'button' : _ref$role,
|
|
72
71
|
name = _ref.name,
|
|
73
72
|
_ref$size = _ref.size,
|
|
74
73
|
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
75
|
-
_ref$tabIndex = _ref.tabIndex,
|
|
76
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex,
|
|
77
74
|
innerRef = _ref.innerRef,
|
|
78
75
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
79
76
|
|
|
@@ -102,6 +99,7 @@ function FileUploaderButton(_ref) {
|
|
|
102
99
|
|
|
103
100
|
function onClick(event) {
|
|
104
101
|
event.target.value = null;
|
|
102
|
+
inputNode.current.click();
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
function onKeyDown(event) {
|
|
@@ -125,16 +123,17 @@ function FileUploaderButton(_ref) {
|
|
|
125
123
|
onChange(event);
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
|
|
127
|
+
type: "button",
|
|
128
|
+
disabled: disabled,
|
|
131
129
|
className: classes,
|
|
132
|
-
|
|
130
|
+
onClick: onClick,
|
|
131
|
+
onKeyDown: onKeyDown
|
|
132
|
+
}, other), labelText), /*#__PURE__*/React__default["default"].createElement("label", {
|
|
133
|
+
className: "".concat(prefix, "--visually-hidden"),
|
|
134
|
+
ref: innerRef,
|
|
133
135
|
htmlFor: inputId
|
|
134
|
-
},
|
|
135
|
-
role: role,
|
|
136
|
-
"aria-disabled": disabled
|
|
137
|
-
}, labelText)), /*#__PURE__*/React__default["default"].createElement("input", {
|
|
136
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", null, labelText)), /*#__PURE__*/React__default["default"].createElement("input", {
|
|
138
137
|
className: "".concat(prefix, "--visually-hidden"),
|
|
139
138
|
ref: inputNode,
|
|
140
139
|
id: inputId,
|
|
@@ -144,8 +143,7 @@ function FileUploaderButton(_ref) {
|
|
|
144
143
|
multiple: multiple,
|
|
145
144
|
accept: accept,
|
|
146
145
|
name: name,
|
|
147
|
-
onChange: handleOnChange
|
|
148
|
-
onClick: onClick
|
|
146
|
+
onChange: handleOnChange
|
|
149
147
|
}));
|
|
150
148
|
}
|
|
151
149
|
|
|
@@ -223,7 +221,7 @@ FileUploaderButton.propTypes = {
|
|
|
223
221
|
/**
|
|
224
222
|
* Provide a custom tabIndex value for the `<FileUploaderButton>`
|
|
225
223
|
*/
|
|
226
|
-
tabIndex: PropTypes__default["default"].number
|
|
224
|
+
tabIndex: deprecate["default"](PropTypes__default["default"].number, 'The `tabIndex` prop for `FileUploaderButton` has ' + 'been deprecated since it now renders a button element by default.')
|
|
227
225
|
};
|
|
228
226
|
|
|
229
227
|
exports["default"] = FileUploaderButton;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
|
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var Select = require('../Select/Select.js');
|
|
17
|
+
require('../Select/Select.Skeleton.js');
|
|
17
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
19
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
19
20
|
|
|
@@ -42,6 +42,7 @@ var IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Icon
|
|
|
42
42
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
43
43
|
align: align,
|
|
44
44
|
className: "".concat(prefix, "--icon-tooltip"),
|
|
45
|
+
closeOnActivation: true,
|
|
45
46
|
defaultOpen: defaultOpen,
|
|
46
47
|
enterDelayMs: enterDelayMs,
|
|
47
48
|
label: label,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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 };
|
|
@@ -137,11 +137,12 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
137
137
|
var iconClasses = cx__default["default"]((_cx3 = {}, _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--number__invalid"), normalizedProps.invalid || normalizedProps.warn), _rollupPluginBabelHelpers.defineProperty(_cx3, "".concat(prefix, "--number__invalid--warning"), normalizedProps.warn), _cx3));
|
|
138
138
|
|
|
139
139
|
if (controlledValue !== prevControlledValue) {
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
140
141
|
setValue(controlledValue);
|
|
141
142
|
setPrevControlledValue(controlledValue);
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
var ariaDescribedBy =
|
|
145
|
+
var ariaDescribedBy = undefined;
|
|
145
146
|
|
|
146
147
|
if (normalizedProps.invalid) {
|
|
147
148
|
ariaDescribedBy = normalizedProps.invalidId;
|
|
@@ -168,7 +169,7 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
var handleFocus = function handleFocus(evt) {
|
|
171
|
-
if (evt.target.type === 'button') {
|
|
172
|
+
if ('type' in evt.target && evt.target.type === 'button') {
|
|
172
173
|
setIsFocused(false);
|
|
173
174
|
} else {
|
|
174
175
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
@@ -176,10 +177,11 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
176
177
|
};
|
|
177
178
|
|
|
178
179
|
var outerElementClasses = cx__default["default"]("".concat(prefix, "--form-item"), (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, customClassName, !!customClassName), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--invalid"), isFluid && normalizedProps.invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--focus"), isFluid && isFocused), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--disabled"), isFluid && disabled), _cx4));
|
|
180
|
+
var Icon = normalizedProps.icon;
|
|
179
181
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
180
182
|
className: outerElementClasses,
|
|
181
|
-
onFocus: isFluid ? handleFocus :
|
|
182
|
-
onBlur: isFluid ? handleFocus :
|
|
183
|
+
onFocus: isFluid ? handleFocus : undefined,
|
|
184
|
+
onBlur: isFluid ? handleFocus : undefined
|
|
183
185
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
184
186
|
className: numberInputClasses,
|
|
185
187
|
"data-invalid": normalizedProps.invalid ? true : undefined
|
|
@@ -225,7 +227,7 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
225
227
|
step: step,
|
|
226
228
|
type: "number",
|
|
227
229
|
value: value
|
|
228
|
-
})),
|
|
230
|
+
})), Icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
229
231
|
className: iconClasses
|
|
230
232
|
}) : null, !hideSteppers && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
231
233
|
className: "".concat(prefix, "--number__controls")
|
|
@@ -248,7 +250,7 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
248
250
|
_onClick(event, state);
|
|
249
251
|
}
|
|
250
252
|
},
|
|
251
|
-
tabIndex:
|
|
253
|
+
tabIndex: -1,
|
|
252
254
|
title: decrementNumLabel || iconDescription,
|
|
253
255
|
type: "button"
|
|
254
256
|
}, _Subtract || (_Subtract = /*#__PURE__*/React__default["default"].createElement(iconsReact.Subtract, {
|
|
@@ -274,7 +276,7 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
274
276
|
_onClick(event, state);
|
|
275
277
|
}
|
|
276
278
|
},
|
|
277
|
-
tabIndex:
|
|
279
|
+
tabIndex: -1,
|
|
278
280
|
title: incrementNumLabel || iconDescription,
|
|
279
281
|
type: "button"
|
|
280
282
|
}, _Add || (_Add = /*#__PURE__*/React__default["default"].createElement(iconsReact.Add, {
|
|
@@ -19,36 +19,17 @@ var FloatingMenu = require('../../internal/FloatingMenu.js');
|
|
|
19
19
|
var iconsReact = require('@carbon/icons-react');
|
|
20
20
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
22
|
-
var FeatureFlags = require('@carbon/feature-flags');
|
|
23
22
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
23
|
+
var index = require('../IconButton/index.js');
|
|
24
24
|
var match = require('../../internal/keyboard/match.js');
|
|
25
25
|
var keys = require('../../internal/keyboard/keys.js');
|
|
26
26
|
|
|
27
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
28
|
|
|
29
|
-
function _interopNamespace(e) {
|
|
30
|
-
if (e && e.__esModule) return e;
|
|
31
|
-
var n = Object.create(null);
|
|
32
|
-
if (e) {
|
|
33
|
-
Object.keys(e).forEach(function (k) {
|
|
34
|
-
if (k !== 'default') {
|
|
35
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
36
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () { return e[k]; }
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
n["default"] = e;
|
|
44
|
-
return Object.freeze(n);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
29
|
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
|
|
48
30
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
49
31
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
50
32
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
51
|
-
var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
|
|
52
33
|
|
|
53
34
|
var _excluded = ["id", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
|
|
54
35
|
|
|
@@ -159,14 +140,14 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
159
140
|
}
|
|
160
141
|
});
|
|
161
142
|
|
|
162
|
-
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "
|
|
163
|
-
|
|
164
|
-
_this.setState({
|
|
165
|
-
open: !_this.state.open
|
|
166
|
-
});
|
|
143
|
+
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "closeMenuAndFocus", function () {
|
|
144
|
+
var wasOpen = _this.state.open;
|
|
167
145
|
|
|
168
|
-
|
|
169
|
-
|
|
146
|
+
_this.closeMenu(function () {
|
|
147
|
+
if (wasOpen) {
|
|
148
|
+
_this.focusMenuEl();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
170
151
|
});
|
|
171
152
|
|
|
172
153
|
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleKeyPress", function (evt) {
|
|
@@ -176,13 +157,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
176
157
|
|
|
177
158
|
|
|
178
159
|
if (match.matches(evt, [keys.Escape])) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
_this.closeMenu(function () {
|
|
182
|
-
if (wasOpen) {
|
|
183
|
-
_this.focusMenuEl();
|
|
184
|
-
}
|
|
185
|
-
}); // Stop the esc keypress from bubbling out and closing something it shouldn't
|
|
160
|
+
_this.closeMenuAndFocus(); // Stop the esc keypress from bubbling out and closing something it shouldn't
|
|
186
161
|
|
|
187
162
|
|
|
188
163
|
evt.stopPropagation();
|
|
@@ -217,8 +192,6 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
217
192
|
});
|
|
218
193
|
|
|
219
194
|
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "handleOverflowMenuItemFocus", function (_ref) {
|
|
220
|
-
var _overflowMenuItem$cur;
|
|
221
|
-
|
|
222
195
|
var currentIndex = _ref.currentIndex,
|
|
223
196
|
direction = _ref.direction;
|
|
224
197
|
var enabledIndices = React__default["default"].Children.toArray(_this.props.children).reduce(function (acc, curr, i) {
|
|
@@ -232,7 +205,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
232
205
|
var nextValidIndex = function () {
|
|
233
206
|
var nextIndex = enabledIndices.indexOf(currentIndex) + direction;
|
|
234
207
|
|
|
235
|
-
switch (
|
|
208
|
+
switch (nextIndex) {
|
|
236
209
|
case -1:
|
|
237
210
|
return enabledIndices.length - 1;
|
|
238
211
|
|
|
@@ -244,9 +217,9 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
244
217
|
}
|
|
245
218
|
}();
|
|
246
219
|
|
|
247
|
-
var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])]
|
|
220
|
+
var overflowMenuItem = _this["overflowMenuItem".concat(enabledIndices[nextValidIndex])];
|
|
248
221
|
|
|
249
|
-
overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 :
|
|
222
|
+
overflowMenuItem === null || overflowMenuItem === void 0 ? void 0 : overflowMenuItem.focus();
|
|
250
223
|
});
|
|
251
224
|
|
|
252
225
|
_rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.assertThisInitialized(_this), "_bindMenuBody", function (menuBody) {
|
|
@@ -270,7 +243,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
270
243
|
|
|
271
244
|
if (typeof target.matches === 'function') {
|
|
272
245
|
if (!menuBody.contains(target) && triggerEl && !target.matches(".".concat(_this.context, "--overflow-menu,.").concat(_this.context, "--overflow-menu-options"))) {
|
|
273
|
-
_this.
|
|
246
|
+
_this.closeMenuAndFocus();
|
|
274
247
|
}
|
|
275
248
|
}
|
|
276
249
|
}, !hasFocusin);
|
|
@@ -354,7 +327,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
354
327
|
var _child$props;
|
|
355
328
|
|
|
356
329
|
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
357
|
-
closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.
|
|
330
|
+
closeMenu: (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.closeMenu) || _this2.closeMenuAndFocus,
|
|
358
331
|
handleOverflowMenuItemFocus: _this2.handleOverflowMenuItemFocus,
|
|
359
332
|
ref: function ref(e) {
|
|
360
333
|
_this2["overflowMenuItem".concat(index)] = e;
|
|
@@ -366,7 +339,8 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
366
339
|
className: overflowMenuOptionsClasses,
|
|
367
340
|
tabIndex: "-1",
|
|
368
341
|
role: "menu",
|
|
369
|
-
"aria-label": ariaLabel
|
|
342
|
+
"aria-label": ariaLabel,
|
|
343
|
+
onKeyDown: this.handleKeyPress
|
|
370
344
|
}, childrenWithProps);
|
|
371
345
|
var wrappedMenuBody = /*#__PURE__*/React__default["default"].createElement(FloatingMenu["default"], {
|
|
372
346
|
focusTrap: focusTrap,
|
|
@@ -387,17 +361,18 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
387
361
|
};
|
|
388
362
|
return /*#__PURE__*/React__default["default"].createElement(ClickListener["default"], {
|
|
389
363
|
onClickOutside: this.handleClickOutside
|
|
390
|
-
}, /*#__PURE__*/React__default["default"].createElement("
|
|
364
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
365
|
+
className: "".concat(prefix, "--overflow-menu__wrapper")
|
|
366
|
+
}, /*#__PURE__*/React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
391
367
|
type: "button",
|
|
392
368
|
"aria-haspopup": true,
|
|
393
369
|
"aria-expanded": this.state.open,
|
|
394
370
|
className: overflowMenuClasses,
|
|
395
|
-
onKeyDown: this.handleKeyPress,
|
|
396
371
|
onClick: this.handleClick,
|
|
397
|
-
"aria-label": ariaLabel,
|
|
398
372
|
id: id,
|
|
399
|
-
ref: mergeRefs["default"](this._triggerRef, ref)
|
|
400
|
-
|
|
373
|
+
ref: mergeRefs["default"](this._triggerRef, ref),
|
|
374
|
+
label: iconDescription
|
|
375
|
+
}), /*#__PURE__*/React__default["default"].createElement(IconElement, iconProps)), open && this.state.hasMountedTrigger && wrappedMenuBody));
|
|
401
376
|
}
|
|
402
377
|
}], [{
|
|
403
378
|
key: "getDerivedStateFromProps",
|
|
@@ -418,7 +393,7 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
|
|
|
418
393
|
/**
|
|
419
394
|
* The ARIA label.
|
|
420
395
|
*/
|
|
421
|
-
ariaLabel:
|
|
396
|
+
ariaLabel: PropTypes__default["default"].string.isRequired,
|
|
422
397
|
|
|
423
398
|
/**
|
|
424
399
|
* The child nodes.
|
|
@@ -464,7 +439,7 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
|
|
|
464
439
|
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
465
440
|
* Don't use this to make OverflowMenu background color same as container background color.
|
|
466
441
|
*/
|
|
467
|
-
light:
|
|
442
|
+
light: deprecate["default"](PropTypes__default["default"].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.'),
|
|
468
443
|
|
|
469
444
|
/**
|
|
470
445
|
* The adjustment in position applied to the floating menu.
|
|
@@ -531,14 +506,14 @@ _rollupPluginBabelHelpers.defineProperty(OverflowMenu, "propTypes", {
|
|
|
531
506
|
/**
|
|
532
507
|
* Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
533
508
|
*/
|
|
534
|
-
size:
|
|
509
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
535
510
|
});
|
|
536
511
|
|
|
537
512
|
_rollupPluginBabelHelpers.defineProperty(OverflowMenu, "contextType", usePrefix.PrefixContext);
|
|
538
513
|
|
|
539
514
|
_rollupPluginBabelHelpers.defineProperty(OverflowMenu, "defaultProps", {
|
|
540
|
-
ariaLabel:
|
|
541
|
-
iconDescription: '
|
|
515
|
+
ariaLabel: null,
|
|
516
|
+
iconDescription: 'Options',
|
|
542
517
|
open: false,
|
|
543
518
|
direction: FloatingMenu.DIRECTION_BOTTOM,
|
|
544
519
|
flipped: false,
|
|
@@ -15,6 +15,7 @@ var cx = require('classnames');
|
|
|
15
15
|
var PropTypes = require('prop-types');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
var Select = require('../Select/Select.js');
|
|
18
|
+
require('../Select/Select.Skeleton.js');
|
|
18
19
|
var SelectItem = require('../SelectItem/SelectItem.js');
|
|
19
20
|
var array = require('../../tools/array.js');
|
|
20
21
|
var useId = require('../../internal/useId.js');
|
|
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var setupGetInstanceId = require('../../../tools/setupGetInstanceId.js');
|
|
17
17
|
var Select = require('../../Select/Select.js');
|
|
18
|
+
require('../../Select/Select.Skeleton.js');
|
|
18
19
|
var SelectItem = require('../../SelectItem/SelectItem.js');
|
|
19
20
|
var usePrefix = require('../../../internal/usePrefix.js');
|
|
20
21
|
|
|
@@ -16,6 +16,7 @@ var cx = require('classnames');
|
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
17
|
var Button = require('../../Button/Button.js');
|
|
18
18
|
var Select = require('../../Select/Select.js');
|
|
19
|
+
require('../../Select/Select.Skeleton.js');
|
|
19
20
|
var SelectItem = require('../../SelectItem/SelectItem.js');
|
|
20
21
|
var index = require('../../IconButton/index.js');
|
|
21
22
|
var FeatureFlags = require('@carbon/feature-flags');
|