@carbon/react 1.22.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/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/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/components/FileUploader/FileUploaderButton.js +14 -16
- package/es/components/NumberInput/NumberInput.d.ts +132 -0
- package/es/components/NumberInput/NumberInput.js +9 -7
- 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/internal/useNormalizedInputProps.js +3 -3
- 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/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/components/FileUploader/FileUploaderButton.js +14 -16
- package/lib/components/NumberInput/NumberInput.d.ts +132 -0
- package/lib/components/NumberInput/NumberInput.js +9 -7
- 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/internal/useNormalizedInputProps.js +3 -3
- package/package.json +3 -5
- 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
|
@@ -71,7 +71,8 @@ var getInputValue = function getInputValue(_ref) {
|
|
|
71
71
|
|
|
72
72
|
var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
73
73
|
var items = _ref2.items,
|
|
74
|
-
itemToString = _ref2.itemToString
|
|
74
|
+
_ref2$itemToString = _ref2.itemToString,
|
|
75
|
+
itemToString = _ref2$itemToString === void 0 ? defaultItemToString : _ref2$itemToString;
|
|
75
76
|
|
|
76
77
|
if (!inputValue) {
|
|
77
78
|
return -1;
|
|
@@ -80,9 +81,9 @@ var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
|
80
81
|
var searchValue = inputValue.toLowerCase();
|
|
81
82
|
|
|
82
83
|
for (var i = 0; i < items.length; i++) {
|
|
83
|
-
var
|
|
84
|
+
var _item = itemToString(items[i]).toLowerCase();
|
|
84
85
|
|
|
85
|
-
if (
|
|
86
|
+
if (_item.indexOf(searchValue) !== -1) {
|
|
86
87
|
return i;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
@@ -92,7 +93,7 @@ var findHighlightedIndex = function findHighlightedIndex(_ref2, inputValue) {
|
|
|
92
93
|
|
|
93
94
|
var getInstanceId = setupGetInstanceId["default"]();
|
|
94
95
|
var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) {
|
|
95
|
-
var _cx, _ref4, _Text;
|
|
96
|
+
var _cx, _ref4, _cx4, _Text;
|
|
96
97
|
|
|
97
98
|
var ariaLabel = props.ariaLabel,
|
|
98
99
|
containerClassName = props.className,
|
|
@@ -129,7 +130,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
129
130
|
var _useContext = React.useContext(FormContext.FormContext),
|
|
130
131
|
isFluid = _useContext.isFluid;
|
|
131
132
|
|
|
132
|
-
var textInput = React.useRef();
|
|
133
|
+
var textInput = React.useRef(null);
|
|
133
134
|
var comboBoxInstanceId = getInstanceId();
|
|
134
135
|
|
|
135
136
|
var _useState = React.useState(getInputValue({
|
|
@@ -147,12 +148,12 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
147
148
|
isFocused = _useState4[0],
|
|
148
149
|
setIsFocused = _useState4[1];
|
|
149
150
|
|
|
150
|
-
var _useState5 = React.useState(
|
|
151
|
+
var _useState5 = React.useState(),
|
|
151
152
|
_useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
|
|
152
153
|
prevSelectedItem = _useState6[0],
|
|
153
154
|
setPrevSelectedItem = _useState6[1];
|
|
154
155
|
|
|
155
|
-
var _useState7 = React.useState(
|
|
156
|
+
var _useState7 = React.useState(false),
|
|
156
157
|
_useState8 = _rollupPluginBabelHelpers.slicedToArray(_useState7, 2),
|
|
157
158
|
doneInitialSelectedItem = _useState8[0],
|
|
158
159
|
setDoneInitialSelectedItem = _useState8[1];
|
|
@@ -172,11 +173,11 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
172
173
|
|
|
173
174
|
var filterItems = function filterItems(items, itemToString, inputValue) {
|
|
174
175
|
return items.filter(function (item) {
|
|
175
|
-
return shouldFilterItem({
|
|
176
|
+
return shouldFilterItem ? shouldFilterItem({
|
|
176
177
|
item: item,
|
|
177
178
|
itemToString: itemToString,
|
|
178
179
|
inputValue: inputValue
|
|
179
|
-
});
|
|
180
|
+
}) : defaultShouldFilterItem();
|
|
180
181
|
});
|
|
181
182
|
};
|
|
182
183
|
|
|
@@ -239,7 +240,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
239
240
|
var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(comboBoxInstanceId);
|
|
240
241
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
241
242
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null, (_ref4 = {}, _rollupPluginBabelHelpers.defineProperty(_ref4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_ref4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused), _ref4)]);
|
|
242
|
-
var inputClasses = cx__default["default"]("".concat(prefix, "--text-input"), _rollupPluginBabelHelpers.defineProperty(
|
|
243
|
+
var inputClasses = cx__default["default"]("".concat(prefix, "--text-input"), (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--text-input--empty"), !inputValue), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--combo-box--input--focus"), isFocused && !isFluid), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
243
244
|
|
|
244
245
|
var ItemToElement = itemToElement;
|
|
245
246
|
return /*#__PURE__*/React__default["default"].createElement(Downshift__default["default"], _rollupPluginBabelHelpers["extends"]({}, downshiftProps, {
|
|
@@ -275,7 +276,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
275
276
|
highlightedIndex = _ref5.highlightedIndex,
|
|
276
277
|
clearSelection = _ref5.clearSelection,
|
|
277
278
|
toggleMenu = _ref5.toggleMenu;
|
|
278
|
-
var rootProps = getRootProps(
|
|
279
|
+
var rootProps = getRootProps( // @ts-ignore this is not supposed to be a required property
|
|
280
|
+
{}, {
|
|
279
281
|
suppressRefError: true
|
|
280
282
|
});
|
|
281
283
|
var labelProps = getLabelProps();
|
|
@@ -317,11 +319,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
317
319
|
});
|
|
318
320
|
|
|
319
321
|
var handleFocus = function handleFocus(evt) {
|
|
320
|
-
|
|
321
|
-
setIsFocused(false);
|
|
322
|
-
} else {
|
|
323
|
-
setIsFocused(evt.type === 'focus' ? true : false);
|
|
324
|
-
}
|
|
322
|
+
setIsFocused(evt.type === 'focus');
|
|
325
323
|
};
|
|
326
324
|
|
|
327
325
|
var readOnlyEventHandlers = readOnly ? {
|
|
@@ -373,7 +371,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
373
371
|
clearSelection: clearSelection,
|
|
374
372
|
translateWithId: translateWithId,
|
|
375
373
|
disabled: disabled || readOnly,
|
|
376
|
-
onClearSelection: handleSelectionClear
|
|
374
|
+
onClearSelection: handleSelectionClear,
|
|
375
|
+
selectionCount: 0
|
|
377
376
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
378
377
|
isOpen: isOpen,
|
|
379
378
|
translateWithId: translateWithId
|
|
@@ -385,15 +384,18 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
385
384
|
var itemProps = getItemProps((_getItemProps = {
|
|
386
385
|
item: item,
|
|
387
386
|
index: index
|
|
388
|
-
}, _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-current', selectedItem === item ? true :
|
|
387
|
+
}, _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-current', selectedItem === item ? 'true' : 'false'), _rollupPluginBabelHelpers.defineProperty(_getItemProps, 'aria-selected', highlightedIndex === index ? 'true' : 'false'), _rollupPluginBabelHelpers.defineProperty(_getItemProps, "disabled", item.disabled), _getItemProps));
|
|
389
388
|
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
390
389
|
key: itemProps.id,
|
|
391
390
|
isActive: selectedItem === item,
|
|
392
391
|
isHighlighted: highlightedIndex === index || (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id) && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.id) === item.id || false,
|
|
393
|
-
title: itemToElement ? item.text : itemToString(item)
|
|
394
|
-
}, itemProps), itemToElement ?
|
|
392
|
+
title: itemToElement ? item.text : itemToString ? itemToString(item) : undefined
|
|
393
|
+
}, itemProps), itemToElement ?
|
|
394
|
+
/*#__PURE__*/
|
|
395
|
+
// @ts-ignore
|
|
396
|
+
React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
395
397
|
key: itemProps.id
|
|
396
|
-
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
398
|
+
}, item)) : itemToString ? itemToString(item) : defaultItemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
397
399
|
className: "".concat(prefix, "--list-box__menu-item__selected-icon")
|
|
398
400
|
}));
|
|
399
401
|
}) : null)), helperText && !invalid && !warn && !isFluid && (_Text || (_Text = /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
@@ -428,6 +430,7 @@ ComboBox.propTypes = {
|
|
|
428
430
|
/**
|
|
429
431
|
* Additional props passed to Downshift
|
|
430
432
|
*/
|
|
433
|
+
// @ts-ignore
|
|
431
434
|
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
432
435
|
|
|
433
436
|
/**
|
|
@@ -484,6 +487,7 @@ ComboBox.propTypes = {
|
|
|
484
487
|
/**
|
|
485
488
|
* `onChange` is a utility for this controlled component to communicate to a
|
|
486
489
|
* consuming component when a specific dropdown item is selected.
|
|
490
|
+
* `({ selectedItem }) => void`
|
|
487
491
|
* @param {{ selectedItem }}
|
|
488
492
|
*/
|
|
489
493
|
onChange: PropTypes__default["default"].func.isRequired,
|
|
@@ -491,6 +495,7 @@ ComboBox.propTypes = {
|
|
|
491
495
|
/**
|
|
492
496
|
* Callback function to notify consumer when the text input changes.
|
|
493
497
|
* This provides support to change available items based on the text.
|
|
498
|
+
* `(inputText) => void`
|
|
494
499
|
* @param {string} inputText
|
|
495
500
|
*/
|
|
496
501
|
onInputChange: PropTypes__default["default"].func,
|
|
@@ -498,11 +503,13 @@ ComboBox.propTypes = {
|
|
|
498
503
|
/**
|
|
499
504
|
* Helper function passed to Downshift that allows the user to observe internal
|
|
500
505
|
* state changes
|
|
506
|
+
* `(changes, stateAndHelpers) => void`
|
|
501
507
|
*/
|
|
502
508
|
onStateChange: PropTypes__default["default"].func,
|
|
503
509
|
|
|
504
510
|
/**
|
|
505
511
|
* Callback function that fires when the combobox menu toggle is clicked
|
|
512
|
+
* `(evt) => void`
|
|
506
513
|
* @param {MouseEvent} event
|
|
507
514
|
*/
|
|
508
515
|
onToggleClick: PropTypes__default["default"].func,
|
|
@@ -104,7 +104,7 @@ var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
104
104
|
onKeyDown(evt);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function
|
|
107
|
+
function handleMousedown(evt) {
|
|
108
108
|
if (!innerModal.current.contains(evt.target) && preventCloseOnClickOutside) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -204,7 +204,7 @@ var ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
204
204
|
ref: ref,
|
|
205
205
|
"aria-hidden": !open,
|
|
206
206
|
onBlur: handleBlur,
|
|
207
|
-
|
|
207
|
+
onMouseDown: handleMousedown,
|
|
208
208
|
onKeyDown: handleKeyDown,
|
|
209
209
|
className: modalClass,
|
|
210
210
|
tabIndex: "-1"
|
|
@@ -0,0 +1,88 @@
|
|
|
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 React from 'react';
|
|
9
|
+
export interface TableSelectRowProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specify the aria label for the underlying input control
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify whether this row is selected, or not
|
|
16
|
+
*/
|
|
17
|
+
checked: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The CSS class names of the cell that wraps the underlying input control
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Specify whether the control is disabled
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Provide an `id` for the underlying input control
|
|
28
|
+
*/
|
|
29
|
+
id: string;
|
|
30
|
+
/**
|
|
31
|
+
* Provide a `name` for the underlying input control
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Provide an optional hook that is called each time the input is updated
|
|
36
|
+
*/
|
|
37
|
+
onChange?: (value: boolean, name: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Provide a handler to listen to when a user initiates a selection request
|
|
40
|
+
*/
|
|
41
|
+
onSelect: React.MouseEventHandler<HTMLInputElement>;
|
|
42
|
+
/**
|
|
43
|
+
* Specify whether the control should be a radio button or inline checkbox
|
|
44
|
+
*/
|
|
45
|
+
radio?: boolean;
|
|
46
|
+
}
|
|
47
|
+
declare const TableSelectRow: {
|
|
48
|
+
({ ariaLabel, checked, id, name, onSelect, onChange, disabled, radio, className, }: TableSelectRowProps): JSX.Element;
|
|
49
|
+
propTypes: {
|
|
50
|
+
/**
|
|
51
|
+
* Specify the aria label for the underlying input control
|
|
52
|
+
*/
|
|
53
|
+
ariaLabel: PropTypes.Validator<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Specify whether this row is selected, or not
|
|
56
|
+
*/
|
|
57
|
+
checked: PropTypes.Validator<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* The CSS class names of the cell that wraps the underlying input control
|
|
60
|
+
*/
|
|
61
|
+
className: PropTypes.Requireable<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Specify whether the control is disabled
|
|
64
|
+
*/
|
|
65
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Provide an `id` for the underlying input control
|
|
68
|
+
*/
|
|
69
|
+
id: PropTypes.Validator<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Provide a `name` for the underlying input control
|
|
72
|
+
*/
|
|
73
|
+
name: PropTypes.Validator<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Provide an optional hook that is called each time the input is updated
|
|
76
|
+
*/
|
|
77
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
|
+
/**
|
|
79
|
+
* Provide a handler to listen to when a user initiates a selection request
|
|
80
|
+
*/
|
|
81
|
+
onSelect: PropTypes.Validator<(...args: any[]) => any>;
|
|
82
|
+
/**
|
|
83
|
+
* Specify whether the control should be a radio button or inline checkbox
|
|
84
|
+
*/
|
|
85
|
+
radio: PropTypes.Requireable<boolean>;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export default TableSelectRow;
|
|
@@ -24,8 +24,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
25
|
|
|
26
26
|
var TableSelectRow = function TableSelectRow(_ref) {
|
|
27
|
-
var _classNames;
|
|
28
|
-
|
|
29
27
|
var ariaLabel = _ref.ariaLabel,
|
|
30
28
|
checked = _ref.checked,
|
|
31
29
|
id = _ref.id,
|
|
@@ -45,7 +43,7 @@ var TableSelectRow = function TableSelectRow(_ref) {
|
|
|
45
43
|
disabled: disabled
|
|
46
44
|
};
|
|
47
45
|
var InlineInputComponent = radio ? RadioButton["default"] : InlineCheckbox["default"];
|
|
48
|
-
var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), (
|
|
46
|
+
var tableSelectRowClasses = cx__default["default"]("".concat(prefix, "--table-column-checkbox"), _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, className && _rollupPluginBabelHelpers.defineProperty({}, className, true)), {}, _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--table-column-radio"), radio)));
|
|
49
47
|
return /*#__PURE__*/React__default["default"].createElement("td", {
|
|
50
48
|
className: tableSelectRowClasses
|
|
51
49
|
}, /*#__PURE__*/React__default["default"].createElement(InlineInputComponent, _rollupPluginBabelHelpers["extends"]({}, selectionInputProps, radio && {
|
|
@@ -63,7 +61,7 @@ TableSelectRow.propTypes = {
|
|
|
63
61
|
ariaLabel: PropTypes__default["default"].string.isRequired,
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
|
-
* Specify whether
|
|
64
|
+
* Specify whether this row is selected, or not
|
|
67
65
|
*/
|
|
68
66
|
checked: PropTypes__default["default"].bool.isRequired,
|
|
69
67
|
|
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -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 };
|