@carbon/react 1.18.0-rc.0 → 1.19.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/ComboBox/ComboBox.js +20 -5
- package/es/components/Dropdown/Dropdown.js +26 -4
- package/es/components/FluidTimePicker/FluidTimePicker.Skeleton.js +46 -0
- package/es/components/FluidTimePicker/FluidTimePicker.js +110 -0
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +64 -0
- package/es/components/ListBox/next/ListBoxSelection.js +1 -0
- package/es/components/Notification/Notification.js +2 -1
- package/es/components/NumberInput/NumberInput.js +4 -2
- package/es/components/Select/Select.js +2 -2
- package/es/components/TextArea/TextArea.js +10 -16
- package/es/components/TextInput/TextInput.js +6 -1
- package/es/index.js +3 -0
- package/es/internal/useAnnouncer.js +16 -0
- package/es/internal/useNoInteractiveChildren.js +4 -0
- package/lib/components/ComboBox/ComboBox.js +20 -5
- package/lib/components/Dropdown/Dropdown.js +26 -4
- package/lib/components/FluidTimePicker/FluidTimePicker.Skeleton.js +56 -0
- package/lib/components/FluidTimePicker/FluidTimePicker.js +120 -0
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +73 -0
- package/lib/components/ListBox/next/ListBoxSelection.js +1 -0
- package/lib/components/Notification/Notification.js +2 -1
- package/lib/components/NumberInput/NumberInput.js +4 -2
- package/lib/components/Select/Select.js +2 -2
- package/lib/components/TextArea/TextArea.js +9 -15
- package/lib/components/TextInput/TextInput.js +6 -1
- package/lib/index.js +6 -0
- package/lib/internal/useAnnouncer.js +20 -0
- package/lib/internal/useNoInteractiveChildren.js +4 -0
- package/package.json +9 -9
- package/scss/components/fluid-time-picker/_fluid-time-picker.scss +9 -0
- package/scss/components/fluid-time-picker/_index.scss +9 -0
|
@@ -28,7 +28,7 @@ import { Text } from '../Text/Text.js';
|
|
|
28
28
|
import ListBox from '../ListBox/ListBox.js';
|
|
29
29
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
30
30
|
|
|
31
|
-
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
31
|
+
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
32
32
|
|
|
33
33
|
var defaultItemToString = function defaultItemToString(item) {
|
|
34
34
|
if (typeof item === 'string') {
|
|
@@ -102,6 +102,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
102
102
|
onInputChange = props.onInputChange,
|
|
103
103
|
onToggleClick = props.onToggleClick,
|
|
104
104
|
placeholder = props.placeholder,
|
|
105
|
+
readOnly = props.readOnly,
|
|
105
106
|
selectedItem = props.selectedItem,
|
|
106
107
|
shouldFilterItem = props.shouldFilterItem,
|
|
107
108
|
size = props.size,
|
|
@@ -223,7 +224,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
223
224
|
|
|
224
225
|
var enabled = useFeatureFlag('enable-v11-release');
|
|
225
226
|
var showWarning = !invalid && warn;
|
|
226
|
-
var className = cx("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _cx));
|
|
227
|
+
var className = cx("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--combo-box--readonly"), readOnly), _cx));
|
|
227
228
|
var titleClasses = cx("".concat(prefix, "--label"), _defineProperty({}, "".concat(prefix, "--label--disabled"), disabled));
|
|
228
229
|
var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(comboBoxInstanceId);
|
|
229
230
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
@@ -269,7 +270,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
269
270
|
});
|
|
270
271
|
var labelProps = getLabelProps();
|
|
271
272
|
var buttonProps = getToggleButtonProps({
|
|
272
|
-
disabled: disabled,
|
|
273
|
+
disabled: disabled || readOnly,
|
|
273
274
|
onClick: handleToggleClick(isOpen),
|
|
274
275
|
// When we moved the "root node" of Downshift to the <input> for
|
|
275
276
|
// ARIA 1.2 compliance, we unfortunately hit this branch for the
|
|
@@ -313,6 +314,14 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
313
314
|
}
|
|
314
315
|
};
|
|
315
316
|
|
|
317
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
318
|
+
onKeyDown: function onKeyDown(evt) {
|
|
319
|
+
// This prevents the select from opening for the above keys
|
|
320
|
+
if (evt.key !== 'Tab') {
|
|
321
|
+
evt.preventDefault();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} : {};
|
|
316
325
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
317
326
|
className: wrapperClasses
|
|
318
327
|
}, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
|
|
@@ -343,7 +352,8 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
343
352
|
"aria-haspopup": "listbox",
|
|
344
353
|
"aria-controls": inputProps['aria-controls'],
|
|
345
354
|
title: textInput === null || textInput === void 0 ? void 0 : (_textInput$current = textInput.current) === null || _textInput$current === void 0 ? void 0 : _textInput$current.value
|
|
346
|
-
}, inputProps, rest, {
|
|
355
|
+
}, inputProps, rest, readOnlyEventHandlers, {
|
|
356
|
+
readOnly: readOnly,
|
|
347
357
|
ref: mergeRefs(textInput, ref)
|
|
348
358
|
})), invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
349
359
|
className: "".concat(prefix, "--list-box__invalid-icon")
|
|
@@ -352,7 +362,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
352
362
|
}), inputValue && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
353
363
|
clearSelection: clearSelection,
|
|
354
364
|
translateWithId: translateWithId,
|
|
355
|
-
disabled: disabled,
|
|
365
|
+
disabled: disabled || readOnly,
|
|
356
366
|
onClearSelection: handleSelectionClear
|
|
357
367
|
}), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
|
|
358
368
|
isOpen: isOpen,
|
|
@@ -493,6 +503,11 @@ ComboBox.propTypes = {
|
|
|
493
503
|
*/
|
|
494
504
|
placeholder: PropTypes.string,
|
|
495
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Is the ComboBox readonly?
|
|
508
|
+
*/
|
|
509
|
+
readOnly: PropTypes.bool,
|
|
510
|
+
|
|
496
511
|
/**
|
|
497
512
|
* For full control of the selection
|
|
498
513
|
*/
|
|
@@ -21,7 +21,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
21
21
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
22
22
|
import ListBox from '../ListBox/ListBox.js';
|
|
23
23
|
|
|
24
|
-
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps"];
|
|
24
|
+
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps", "readOnly"];
|
|
25
25
|
|
|
26
26
|
var defaultItemToString = function defaultItemToString(item) {
|
|
27
27
|
if (typeof item === 'string') {
|
|
@@ -59,6 +59,7 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
59
59
|
initialSelectedItem = _ref.initialSelectedItem,
|
|
60
60
|
controlledSelectedItem = _ref.selectedItem,
|
|
61
61
|
downshiftProps = _ref.downshiftProps,
|
|
62
|
+
readOnly = _ref.readOnly,
|
|
62
63
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
63
64
|
|
|
64
65
|
var prefix = usePrefix();
|
|
@@ -97,7 +98,7 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
97
98
|
isFocused = _useState2[0],
|
|
98
99
|
setIsFocused = _useState2[1];
|
|
99
100
|
|
|
100
|
-
var className = cx("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
101
|
+
var className = cx("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _defineProperty(_cx, "".concat(prefix, "--dropdown--readonly"), readOnly), _defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
101
102
|
var titleClasses = cx("".concat(prefix, "--label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
|
|
102
103
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
103
104
|
var wrapperClasses = cx("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
@@ -127,6 +128,21 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
127
128
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
128
129
|
};
|
|
129
130
|
|
|
131
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
132
|
+
onClick: function onClick(evt) {
|
|
133
|
+
// NOTE: does not prevent click
|
|
134
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
135
|
+
|
|
136
|
+
evt.target.focus();
|
|
137
|
+
},
|
|
138
|
+
onKeyDown: function onKeyDown(evt) {
|
|
139
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
140
|
+
|
|
141
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
142
|
+
evt.preventDefault();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} : {};
|
|
130
146
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
131
147
|
className: wrapperClasses
|
|
132
148
|
}, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -152,9 +168,10 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
152
168
|
type: "button",
|
|
153
169
|
className: "".concat(prefix, "--list-box__field"),
|
|
154
170
|
disabled: disabled,
|
|
155
|
-
"aria-disabled": disabled
|
|
171
|
+
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
172
|
+
,
|
|
156
173
|
title: selectedItem ? itemToString(selectedItem) : label
|
|
157
|
-
}, toggleButtonProps, {
|
|
174
|
+
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
158
175
|
ref: mergeRefs(toggleButtonProps.ref, ref)
|
|
159
176
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
160
177
|
className: "".concat(prefix, "--list-box__label")
|
|
@@ -278,6 +295,11 @@ Dropdown.propTypes = {
|
|
|
278
295
|
*/
|
|
279
296
|
onChange: PropTypes.func,
|
|
280
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Whether or not the Dropdown is readonly
|
|
300
|
+
*/
|
|
301
|
+
readOnly: PropTypes.bool,
|
|
302
|
+
|
|
281
303
|
/**
|
|
282
304
|
* An optional callback to render the currently selected item as a react element instead of only
|
|
283
305
|
* as a string.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import '../FluidTextInput/FluidTextInput.js';
|
|
14
|
+
import FluidTextInputSkeleton from '../FluidTextInput/FluidTextInput.Skeleton.js';
|
|
15
|
+
import '../FluidSelect/FluidSelect.js';
|
|
16
|
+
import FluidSelectSkeleton from '../FluidSelect/FluidSelect.Skeleton.js';
|
|
17
|
+
|
|
18
|
+
var _FluidTextInputSkelet, _FluidSelectSkeleton, _FluidSelectSkeleton2;
|
|
19
|
+
|
|
20
|
+
var _excluded = ["className", "isOnlyTwo"];
|
|
21
|
+
|
|
22
|
+
var FluidTimePickerSkeleton = function FluidTimePickerSkeleton(_ref) {
|
|
23
|
+
var className = _ref.className,
|
|
24
|
+
isOnlyTwo = _ref.isOnlyTwo,
|
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
|
|
27
|
+
var prefix = usePrefix();
|
|
28
|
+
var wrapperClasses = cx(className, "".concat(prefix, "--time-picker--fluid--skeleton"), _defineProperty({}, "".concat(prefix, "--time-picker--equal-width"), isOnlyTwo));
|
|
29
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
30
|
+
className: wrapperClasses
|
|
31
|
+
}, rest), _FluidTextInputSkelet || (_FluidTextInputSkelet = /*#__PURE__*/React__default.createElement(FluidTextInputSkeleton, null)), _FluidSelectSkeleton || (_FluidSelectSkeleton = /*#__PURE__*/React__default.createElement(FluidSelectSkeleton, null)), !isOnlyTwo ? _FluidSelectSkeleton2 || (_FluidSelectSkeleton2 = /*#__PURE__*/React__default.createElement(FluidSelectSkeleton, null)) : null);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
FluidTimePickerSkeleton.propTypes = {
|
|
35
|
+
/**
|
|
36
|
+
* Specify an optional className to add.
|
|
37
|
+
*/
|
|
38
|
+
className: PropTypes.string,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Specify if there are only two TimePicker elements
|
|
42
|
+
*/
|
|
43
|
+
isOnlyTwo: PropTypes.bool
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { FluidTimePickerSkeleton as default };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import FluidTextInput from '../FluidTextInput/FluidTextInput.js';
|
|
13
|
+
import '../FluidTextInput/FluidTextInput.Skeleton.js';
|
|
14
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
16
|
+
|
|
17
|
+
var _excluded = ["className", "children", "disabled", "invalid", "invalidText", "warn", "warnText"];
|
|
18
|
+
var FluidTimePicker = /*#__PURE__*/React__default.forwardRef(function FluidTimePicker(_ref, ref) {
|
|
19
|
+
var _classnames;
|
|
20
|
+
|
|
21
|
+
var className = _ref.className,
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
disabled = _ref.disabled,
|
|
24
|
+
invalid = _ref.invalid,
|
|
25
|
+
invalidText = _ref.invalidText,
|
|
26
|
+
warn = _ref.warn,
|
|
27
|
+
warnText = _ref.warnText,
|
|
28
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
|
|
30
|
+
var prefix = usePrefix();
|
|
31
|
+
var classNames = cx(className, (_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid"), true), _defineProperty(_classnames, "".concat(prefix, "--time-picker--equal-width"), (children === null || children === void 0 ? void 0 : children.length) !== 2), _defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--disabled"), disabled), _defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--invalid"), invalid), _defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--warning"), warn), _classnames));
|
|
32
|
+
|
|
33
|
+
var errorText = function errorText() {
|
|
34
|
+
if (invalid) {
|
|
35
|
+
return invalidText;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (warn) {
|
|
39
|
+
return warnText;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var error = invalid || warn;
|
|
44
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
45
|
+
className: classNames
|
|
46
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
47
|
+
className: "".concat(prefix, "--time-picker--fluid__wrapper")
|
|
48
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
49
|
+
className: "".concat(prefix, "--time-picker__input")
|
|
50
|
+
}, /*#__PURE__*/React__default.createElement(FluidTextInput, _extends({
|
|
51
|
+
disabled: disabled,
|
|
52
|
+
ref: ref
|
|
53
|
+
}, other))), disabled ? React__default.Children.toArray(children).map(function (child) {
|
|
54
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
55
|
+
disabled: disabled
|
|
56
|
+
});
|
|
57
|
+
}) : children), error && /*#__PURE__*/React__default.createElement("hr", {
|
|
58
|
+
className: "".concat(prefix, "--time-picker__divider")
|
|
59
|
+
}), error && /*#__PURE__*/React__default.createElement("div", {
|
|
60
|
+
className: "".concat(prefix, "--form-requirement")
|
|
61
|
+
}, errorText()), error && invalid ? /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
62
|
+
className: "".concat(prefix, "--time-picker__icon ").concat(prefix, "--time-picker__icon--invalid")
|
|
63
|
+
}) : /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
64
|
+
className: "".concat(prefix, "--time-picker__icon ").concat(prefix, "--time-picker__icon--warn")
|
|
65
|
+
}));
|
|
66
|
+
});
|
|
67
|
+
FluidTimePicker.propTypes = {
|
|
68
|
+
/**
|
|
69
|
+
* The child node(s)
|
|
70
|
+
*/
|
|
71
|
+
children: PropTypes.node,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Specify an optional className to be applied to the outer FluidTimePicker wrapper
|
|
75
|
+
*/
|
|
76
|
+
className: PropTypes.string,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Specify whether the `<input>` should be disabled
|
|
80
|
+
*/
|
|
81
|
+
disabled: PropTypes.bool,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Specify whether or not the control is invalid
|
|
85
|
+
*/
|
|
86
|
+
invalid: PropTypes.bool,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Provide the text that is displayed when the control is in error state
|
|
90
|
+
*/
|
|
91
|
+
invalidText: PropTypes.node,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
95
|
+
* control
|
|
96
|
+
*/
|
|
97
|
+
labelText: PropTypes.node.isRequired,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Specify whether the control is currently in warning state
|
|
101
|
+
*/
|
|
102
|
+
warn: PropTypes.bool,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Provide the text that is displayed when the control is in warning state
|
|
106
|
+
*/
|
|
107
|
+
warnText: PropTypes.node
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export { FluidTimePicker as default };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import FluidSelect from '../FluidSelect/FluidSelect.js';
|
|
12
|
+
import '../FluidSelect/FluidSelect.Skeleton.js';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["children", "className"];
|
|
15
|
+
var FluidTimePickerSelect = /*#__PURE__*/React__default.forwardRef(function FluidTimePickerSelect(_ref, ref) {
|
|
16
|
+
var children = _ref.children,
|
|
17
|
+
className = _ref.className,
|
|
18
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React__default.createElement(FluidSelect, _extends({
|
|
21
|
+
className: className,
|
|
22
|
+
ref: ref
|
|
23
|
+
}, other), children);
|
|
24
|
+
});
|
|
25
|
+
FluidTimePickerSelect.propTypes = {
|
|
26
|
+
/**
|
|
27
|
+
* Provide the contents of your Select
|
|
28
|
+
*/
|
|
29
|
+
children: PropTypes.node,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Specify an optional className to be applied to the node containing the label and the select box
|
|
33
|
+
*/
|
|
34
|
+
className: PropTypes.string,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Optionally provide the default value of the `<select>`
|
|
38
|
+
*/
|
|
39
|
+
defaultValue: PropTypes.any,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Specify whether the control is disabled
|
|
43
|
+
*/
|
|
44
|
+
disabled: PropTypes.bool,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Specify a custom `id` for the `<select>`
|
|
48
|
+
*/
|
|
49
|
+
id: PropTypes.string.isRequired,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Provide label text to be read by screen readers when interacting with the
|
|
53
|
+
* control
|
|
54
|
+
*/
|
|
55
|
+
labelText: PropTypes.node,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Provide an optional `onChange` hook that is called each time the value of
|
|
59
|
+
* the underlying `<input>` changes
|
|
60
|
+
*/
|
|
61
|
+
onChange: PropTypes.func
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { FluidTimePickerSelect as default };
|
|
@@ -90,6 +90,7 @@ function ListBoxSelection(_ref) {
|
|
|
90
90
|
return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
91
91
|
"aria-label": description,
|
|
92
92
|
className: className,
|
|
93
|
+
disabled: disabled,
|
|
93
94
|
onClick: onClick,
|
|
94
95
|
onKeyDown: onKeyDown,
|
|
95
96
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -170,7 +170,8 @@ function NotificationIcon(_ref3) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
return /*#__PURE__*/React__default.createElement(IconForKind, {
|
|
173
|
-
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon")
|
|
173
|
+
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon"),
|
|
174
|
+
size: 20
|
|
174
175
|
}, /*#__PURE__*/React__default.createElement("title", null, iconDescription));
|
|
175
176
|
}
|
|
176
177
|
|
|
@@ -51,8 +51,10 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
51
51
|
_props$invalidText = props.invalidText,
|
|
52
52
|
invalidText = _props$invalidText === void 0 ? enabled ? undefined : 'Provide invalidText' : _props$invalidText,
|
|
53
53
|
light = props.light,
|
|
54
|
-
max = props.max,
|
|
55
|
-
|
|
54
|
+
_props$max = props.max,
|
|
55
|
+
max = _props$max === void 0 ? 100 : _props$max,
|
|
56
|
+
_props$min = props.min,
|
|
57
|
+
min = _props$min === void 0 ? 0 : _props$min,
|
|
56
58
|
onChange = props.onChange,
|
|
57
59
|
_onClick = props.onClick,
|
|
58
60
|
onKeyUp = props.onKeyUp,
|
|
@@ -142,9 +142,9 @@ var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
|
|
|
142
142
|
"data-invalid": invalid || null,
|
|
143
143
|
onFocus: handleFocus,
|
|
144
144
|
onBlur: handleFocus
|
|
145
|
-
}, input
|
|
145
|
+
}, input, isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
146
146
|
className: "".concat(prefix, "--select__divider")
|
|
147
|
-
}), !inline && error ? error : helper));
|
|
147
|
+
}), isFluid && error ? error : null), !inline && !isFluid && error ? error : helper));
|
|
148
148
|
});
|
|
149
149
|
Select.displayName = 'Select';
|
|
150
150
|
Select.propTypes = {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useContext, useState
|
|
10
|
+
import React__default, { useContext, useState } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
13
|
import { WarningFilled } from '@carbon/icons-react';
|
|
@@ -15,6 +15,7 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import '../FluidForm/FluidForm.js';
|
|
17
17
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
18
|
+
import { useAnnouncer } from '../../internal/useAnnouncer.js';
|
|
18
19
|
|
|
19
20
|
var _excluded = ["className", "id", "labelText", "hideLabel", "onChange", "onClick", "invalid", "invalidText", "helperText", "light", "placeholder", "enableCounter", "maxCount"];
|
|
20
21
|
var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, ref) {
|
|
@@ -50,11 +51,6 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
50
51
|
textCount = _useState2[0],
|
|
51
52
|
setTextCount = _useState2[1];
|
|
52
53
|
|
|
53
|
-
var _useState3 = useState(''),
|
|
54
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
-
ariaAnnouncement = _useState4[0],
|
|
56
|
-
setAriaAnnouncement = _useState4[1];
|
|
57
|
-
|
|
58
54
|
var textareaProps = {
|
|
59
55
|
id: id,
|
|
60
56
|
onChange: function onChange(evt) {
|
|
@@ -78,15 +74,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
78
74
|
textareaProps.maxLength = maxCount;
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
var lastTen = maxCount - 10;
|
|
83
|
-
|
|
84
|
-
if (textCount >= lastTen) {
|
|
85
|
-
setAriaAnnouncement("".concat(maxCount - textCount, " characters left."));
|
|
86
|
-
} else {
|
|
87
|
-
setAriaAnnouncement('');
|
|
88
|
-
}
|
|
89
|
-
}, [textCount, maxCount]);
|
|
77
|
+
var ariaAnnouncement = useAnnouncer(textCount, maxCount);
|
|
90
78
|
var labelClasses = cx("".concat(prefix, "--label"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--visually-hidden"), hideLabel && !isFluid), _defineProperty(_classNames, "".concat(prefix, "--label--disabled"), disabled), _classNames));
|
|
91
79
|
var label = labelText ? /*#__PURE__*/React__default.createElement("label", {
|
|
92
80
|
htmlFor: id,
|
|
@@ -115,6 +103,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
115
103
|
"aria-invalid": invalid || null,
|
|
116
104
|
"aria-describedby": invalid ? errorId : null,
|
|
117
105
|
disabled: other.disabled,
|
|
106
|
+
readOnly: other.readOnly,
|
|
118
107
|
style: other.cols ? {} : {
|
|
119
108
|
width: "100%"
|
|
120
109
|
}
|
|
@@ -124,7 +113,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
124
113
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
125
114
|
className: "".concat(prefix, "--text-area__label-wrapper")
|
|
126
115
|
}, label, counter), /*#__PURE__*/React__default.createElement("div", {
|
|
127
|
-
className: "".concat(prefix, "--text-area__wrapper"),
|
|
116
|
+
className: cx("".concat(prefix, "--text-area__wrapper"), _defineProperty({}, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly)),
|
|
128
117
|
"data-invalid": invalid || null
|
|
129
118
|
}, invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
130
119
|
className: "".concat(prefix, "--text-area__invalid-icon")
|
|
@@ -222,6 +211,11 @@ TextArea.propTypes = {
|
|
|
222
211
|
*/
|
|
223
212
|
placeholder: PropTypes.string,
|
|
224
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Whether the textarea should be read-only
|
|
216
|
+
*/
|
|
217
|
+
readOnly: PropTypes.bool,
|
|
218
|
+
|
|
225
219
|
/**
|
|
226
220
|
* Specify the rows attribute for the `<textarea>`
|
|
227
221
|
*/
|
|
@@ -19,6 +19,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
19
19
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
20
20
|
import * as FeatureFlags from '@carbon/feature-flags';
|
|
21
21
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
22
|
+
import { useAnnouncer } from '../../internal/useAnnouncer.js';
|
|
22
23
|
|
|
23
24
|
var _excluded = ["className", "disabled", "helperText", "hideLabel", "id", "inline", "invalid", "invalidText", "labelText", "light", "onChange", "onClick", "placeholder", "readOnly", "size", "type", "warn", "warnText", "enableCounter", "maxCount"];
|
|
24
25
|
var TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref, ref) {
|
|
@@ -137,6 +138,7 @@ var TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref,
|
|
|
137
138
|
var _useContext = useContext(FormContext),
|
|
138
139
|
isFluid = _useContext.isFluid;
|
|
139
140
|
|
|
141
|
+
var ariaAnnouncement = useAnnouncer(textCount, maxCount);
|
|
140
142
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
141
143
|
className: inputWrapperClasses
|
|
142
144
|
}, !inline ? labelWrapper : /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -148,7 +150,10 @@ var TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref,
|
|
|
148
150
|
"data-invalid": normalizedProps.invalid || null
|
|
149
151
|
}, normalizedProps.icon && /*#__PURE__*/React__default.createElement(normalizedProps.icon, {
|
|
150
152
|
className: iconClasses
|
|
151
|
-
}), input,
|
|
153
|
+
}), input, /*#__PURE__*/React__default.createElement("span", {
|
|
154
|
+
className: "".concat(prefix, "--text-input__counter-alert"),
|
|
155
|
+
role: "alert"
|
|
156
|
+
}, ariaAnnouncement), isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
152
157
|
className: "".concat(prefix, "--text-input__divider")
|
|
153
158
|
}), isFluid && !inline && normalizedProps.validation), !isFluid && !inline && (normalizedProps.validation || helper)));
|
|
154
159
|
});
|
package/es/index.js
CHANGED
|
@@ -165,6 +165,9 @@ export { default as unstable__FluidTextArea } from './components/FluidTextArea/F
|
|
|
165
165
|
export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
|
|
166
166
|
export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
|
|
167
167
|
export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
|
|
168
|
+
export { default as unstable__FluidTimePicker } from './components/FluidTimePicker/FluidTimePicker.js';
|
|
169
|
+
export { default as unstable__FluidTimePickerSkeleton } from './components/FluidTimePicker/FluidTimePicker.Skeleton.js';
|
|
170
|
+
export { default as unstable__FluidTimePickerSelect } from './components/FluidTimePickerSelect/FluidTimePickerSelect.js';
|
|
168
171
|
export { Heading, Section } from './components/Heading/index.js';
|
|
169
172
|
export { IconButton } from './components/IconButton/index.js';
|
|
170
173
|
export { Layer, useLayer } from './components/Layer/index.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
function useAnnouncer(textCount, maxCount) {
|
|
9
|
+
var lastTen = maxCount - 10;
|
|
10
|
+
|
|
11
|
+
if (textCount >= lastTen) {
|
|
12
|
+
return "".concat(maxCount - textCount, " characters left.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { useAnnouncer };
|
|
@@ -39,7 +39,7 @@ var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
|
39
39
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
40
40
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
41
41
|
|
|
42
|
-
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
42
|
+
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
43
43
|
|
|
44
44
|
var defaultItemToString = function defaultItemToString(item) {
|
|
45
45
|
if (typeof item === 'string') {
|
|
@@ -113,6 +113,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
113
113
|
onInputChange = props.onInputChange,
|
|
114
114
|
onToggleClick = props.onToggleClick,
|
|
115
115
|
placeholder = props.placeholder,
|
|
116
|
+
readOnly = props.readOnly,
|
|
116
117
|
selectedItem = props.selectedItem,
|
|
117
118
|
shouldFilterItem = props.shouldFilterItem,
|
|
118
119
|
size = props.size,
|
|
@@ -234,7 +235,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
234
235
|
|
|
235
236
|
var enabled = index.useFeatureFlag('enable-v11-release');
|
|
236
237
|
var showWarning = !invalid && warn;
|
|
237
|
-
var className = cx__default["default"]("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _cx));
|
|
238
|
+
var className = cx__default["default"]("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--readonly"), readOnly), _cx));
|
|
238
239
|
var titleClasses = cx__default["default"]("".concat(prefix, "--label"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--label--disabled"), disabled));
|
|
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));
|
|
@@ -280,7 +281,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
280
281
|
});
|
|
281
282
|
var labelProps = getLabelProps();
|
|
282
283
|
var buttonProps = getToggleButtonProps({
|
|
283
|
-
disabled: disabled,
|
|
284
|
+
disabled: disabled || readOnly,
|
|
284
285
|
onClick: handleToggleClick(isOpen),
|
|
285
286
|
// When we moved the "root node" of Downshift to the <input> for
|
|
286
287
|
// ARIA 1.2 compliance, we unfortunately hit this branch for the
|
|
@@ -324,6 +325,14 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
324
325
|
}
|
|
325
326
|
};
|
|
326
327
|
|
|
328
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
329
|
+
onKeyDown: function onKeyDown(evt) {
|
|
330
|
+
// This prevents the select from opening for the above keys
|
|
331
|
+
if (evt.key !== 'Tab') {
|
|
332
|
+
evt.preventDefault();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} : {};
|
|
327
336
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
328
337
|
className: wrapperClasses
|
|
329
338
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -354,7 +363,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
354
363
|
"aria-haspopup": "listbox",
|
|
355
364
|
"aria-controls": inputProps['aria-controls'],
|
|
356
365
|
title: textInput === null || textInput === void 0 ? void 0 : (_textInput$current = textInput.current) === null || _textInput$current === void 0 ? void 0 : _textInput$current.value
|
|
357
|
-
}, inputProps, rest, {
|
|
366
|
+
}, inputProps, rest, readOnlyEventHandlers, {
|
|
367
|
+
readOnly: readOnly,
|
|
358
368
|
ref: mergeRefs["default"](textInput, ref)
|
|
359
369
|
})), invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
360
370
|
className: "".concat(prefix, "--list-box__invalid-icon")
|
|
@@ -363,7 +373,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
363
373
|
}), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
364
374
|
clearSelection: clearSelection,
|
|
365
375
|
translateWithId: translateWithId,
|
|
366
|
-
disabled: disabled,
|
|
376
|
+
disabled: disabled || readOnly,
|
|
367
377
|
onClearSelection: handleSelectionClear
|
|
368
378
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
369
379
|
isOpen: isOpen,
|
|
@@ -504,6 +514,11 @@ ComboBox.propTypes = {
|
|
|
504
514
|
*/
|
|
505
515
|
placeholder: PropTypes__default["default"].string,
|
|
506
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Is the ComboBox readonly?
|
|
519
|
+
*/
|
|
520
|
+
readOnly: PropTypes__default["default"].bool,
|
|
521
|
+
|
|
507
522
|
/**
|
|
508
523
|
* For full control of the selection
|
|
509
524
|
*/
|
|
@@ -31,7 +31,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
31
31
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
32
32
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
33
33
|
|
|
34
|
-
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps"];
|
|
34
|
+
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps", "readOnly"];
|
|
35
35
|
|
|
36
36
|
var defaultItemToString = function defaultItemToString(item) {
|
|
37
37
|
if (typeof item === 'string') {
|
|
@@ -69,6 +69,7 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
69
69
|
initialSelectedItem = _ref.initialSelectedItem,
|
|
70
70
|
controlledSelectedItem = _ref.selectedItem,
|
|
71
71
|
downshiftProps = _ref.downshiftProps,
|
|
72
|
+
readOnly = _ref.readOnly,
|
|
72
73
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
73
74
|
|
|
74
75
|
var prefix = usePrefix.usePrefix();
|
|
@@ -107,7 +108,7 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
107
108
|
isFocused = _useState2[0],
|
|
108
109
|
setIsFocused = _useState2[1];
|
|
109
110
|
|
|
110
|
-
var className = cx__default["default"]("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
111
|
+
var className = cx__default["default"]("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--readonly"), readOnly), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
111
112
|
var titleClasses = cx__default["default"]("".concat(prefix, "--label"), (_cx2 = {}, _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
|
|
112
113
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
113
114
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
@@ -137,6 +138,21 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
137
138
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
138
139
|
};
|
|
139
140
|
|
|
141
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
142
|
+
onClick: function onClick(evt) {
|
|
143
|
+
// NOTE: does not prevent click
|
|
144
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
145
|
+
|
|
146
|
+
evt.target.focus();
|
|
147
|
+
},
|
|
148
|
+
onKeyDown: function onKeyDown(evt) {
|
|
149
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
150
|
+
|
|
151
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
152
|
+
evt.preventDefault();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} : {};
|
|
140
156
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
141
157
|
className: wrapperClasses
|
|
142
158
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -162,9 +178,10 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
162
178
|
type: "button",
|
|
163
179
|
className: "".concat(prefix, "--list-box__field"),
|
|
164
180
|
disabled: disabled,
|
|
165
|
-
"aria-disabled": disabled
|
|
181
|
+
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
182
|
+
,
|
|
166
183
|
title: selectedItem ? itemToString(selectedItem) : label
|
|
167
|
-
}, toggleButtonProps, {
|
|
184
|
+
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
168
185
|
ref: mergeRefs["default"](toggleButtonProps.ref, ref)
|
|
169
186
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
170
187
|
className: "".concat(prefix, "--list-box__label")
|
|
@@ -288,6 +305,11 @@ Dropdown.propTypes = {
|
|
|
288
305
|
*/
|
|
289
306
|
onChange: PropTypes__default["default"].func,
|
|
290
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Whether or not the Dropdown is readonly
|
|
310
|
+
*/
|
|
311
|
+
readOnly: PropTypes__default["default"].bool,
|
|
312
|
+
|
|
291
313
|
/**
|
|
292
314
|
* An optional callback to render the currently selected item as a react element instead of only
|
|
293
315
|
* as a string.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
require('../FluidTextInput/FluidTextInput.js');
|
|
18
|
+
var FluidTextInput_Skeleton = require('../FluidTextInput/FluidTextInput.Skeleton.js');
|
|
19
|
+
require('../FluidSelect/FluidSelect.js');
|
|
20
|
+
var FluidSelect_Skeleton = require('../FluidSelect/FluidSelect.Skeleton.js');
|
|
21
|
+
|
|
22
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
+
|
|
24
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
25
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
27
|
+
|
|
28
|
+
var _FluidTextInputSkelet, _FluidSelectSkeleton, _FluidSelectSkeleton2;
|
|
29
|
+
|
|
30
|
+
var _excluded = ["className", "isOnlyTwo"];
|
|
31
|
+
|
|
32
|
+
var FluidTimePickerSkeleton = function FluidTimePickerSkeleton(_ref) {
|
|
33
|
+
var className = _ref.className,
|
|
34
|
+
isOnlyTwo = _ref.isOnlyTwo,
|
|
35
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
36
|
+
|
|
37
|
+
var prefix = usePrefix.usePrefix();
|
|
38
|
+
var wrapperClasses = cx__default["default"](className, "".concat(prefix, "--time-picker--fluid--skeleton"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--time-picker--equal-width"), isOnlyTwo));
|
|
39
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
40
|
+
className: wrapperClasses
|
|
41
|
+
}, rest), _FluidTextInputSkelet || (_FluidTextInputSkelet = /*#__PURE__*/React__default["default"].createElement(FluidTextInput_Skeleton["default"], null)), _FluidSelectSkeleton || (_FluidSelectSkeleton = /*#__PURE__*/React__default["default"].createElement(FluidSelect_Skeleton["default"], null)), !isOnlyTwo ? _FluidSelectSkeleton2 || (_FluidSelectSkeleton2 = /*#__PURE__*/React__default["default"].createElement(FluidSelect_Skeleton["default"], null)) : null);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
FluidTimePickerSkeleton.propTypes = {
|
|
45
|
+
/**
|
|
46
|
+
* Specify an optional className to add.
|
|
47
|
+
*/
|
|
48
|
+
className: PropTypes__default["default"].string,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Specify if there are only two TimePicker elements
|
|
52
|
+
*/
|
|
53
|
+
isOnlyTwo: PropTypes__default["default"].bool
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports["default"] = FluidTimePickerSkeleton;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var FluidTextInput = require('../FluidTextInput/FluidTextInput.js');
|
|
17
|
+
require('../FluidTextInput/FluidTextInput.Skeleton.js');
|
|
18
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var iconsReact = require('@carbon/icons-react');
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
+
|
|
23
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
|
+
|
|
27
|
+
var _excluded = ["className", "children", "disabled", "invalid", "invalidText", "warn", "warnText"];
|
|
28
|
+
var FluidTimePicker = /*#__PURE__*/React__default["default"].forwardRef(function FluidTimePicker(_ref, ref) {
|
|
29
|
+
var _classnames;
|
|
30
|
+
|
|
31
|
+
var className = _ref.className,
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
disabled = _ref.disabled,
|
|
34
|
+
invalid = _ref.invalid,
|
|
35
|
+
invalidText = _ref.invalidText,
|
|
36
|
+
warn = _ref.warn,
|
|
37
|
+
warnText = _ref.warnText,
|
|
38
|
+
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
|
|
40
|
+
var prefix = usePrefix.usePrefix();
|
|
41
|
+
var classNames = cx__default["default"](className, (_classnames = {}, _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid"), true), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--time-picker--equal-width"), (children === null || children === void 0 ? void 0 : children.length) !== 2), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--time-picker--fluid--warning"), warn), _classnames));
|
|
42
|
+
|
|
43
|
+
var errorText = function errorText() {
|
|
44
|
+
if (invalid) {
|
|
45
|
+
return invalidText;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (warn) {
|
|
49
|
+
return warnText;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var error = invalid || warn;
|
|
54
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
55
|
+
className: classNames
|
|
56
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
57
|
+
className: "".concat(prefix, "--time-picker--fluid__wrapper")
|
|
58
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
59
|
+
className: "".concat(prefix, "--time-picker__input")
|
|
60
|
+
}, /*#__PURE__*/React__default["default"].createElement(FluidTextInput["default"], _rollupPluginBabelHelpers["extends"]({
|
|
61
|
+
disabled: disabled,
|
|
62
|
+
ref: ref
|
|
63
|
+
}, other))), disabled ? React__default["default"].Children.toArray(children).map(function (child) {
|
|
64
|
+
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
65
|
+
disabled: disabled
|
|
66
|
+
});
|
|
67
|
+
}) : children), error && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
68
|
+
className: "".concat(prefix, "--time-picker__divider")
|
|
69
|
+
}), error && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
70
|
+
className: "".concat(prefix, "--form-requirement")
|
|
71
|
+
}, errorText()), error && invalid ? /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
72
|
+
className: "".concat(prefix, "--time-picker__icon ").concat(prefix, "--time-picker__icon--invalid")
|
|
73
|
+
}) : /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
74
|
+
className: "".concat(prefix, "--time-picker__icon ").concat(prefix, "--time-picker__icon--warn")
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
FluidTimePicker.propTypes = {
|
|
78
|
+
/**
|
|
79
|
+
* The child node(s)
|
|
80
|
+
*/
|
|
81
|
+
children: PropTypes__default["default"].node,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Specify an optional className to be applied to the outer FluidTimePicker wrapper
|
|
85
|
+
*/
|
|
86
|
+
className: PropTypes__default["default"].string,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Specify whether the `<input>` should be disabled
|
|
90
|
+
*/
|
|
91
|
+
disabled: PropTypes__default["default"].bool,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Specify whether or not the control is invalid
|
|
95
|
+
*/
|
|
96
|
+
invalid: PropTypes__default["default"].bool,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Provide the text that is displayed when the control is in error state
|
|
100
|
+
*/
|
|
101
|
+
invalidText: PropTypes__default["default"].node,
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
105
|
+
* control
|
|
106
|
+
*/
|
|
107
|
+
labelText: PropTypes__default["default"].node.isRequired,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Specify whether the control is currently in warning state
|
|
111
|
+
*/
|
|
112
|
+
warn: PropTypes__default["default"].bool,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Provide the text that is displayed when the control is in warning state
|
|
116
|
+
*/
|
|
117
|
+
warnText: PropTypes__default["default"].node
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports["default"] = FluidTimePicker;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var PropTypes = require('prop-types');
|
|
15
|
+
var FluidSelect = require('../FluidSelect/FluidSelect.js');
|
|
16
|
+
require('../FluidSelect/FluidSelect.Skeleton.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
22
|
+
|
|
23
|
+
var _excluded = ["children", "className"];
|
|
24
|
+
var FluidTimePickerSelect = /*#__PURE__*/React__default["default"].forwardRef(function FluidTimePickerSelect(_ref, ref) {
|
|
25
|
+
var children = _ref.children,
|
|
26
|
+
className = _ref.className,
|
|
27
|
+
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React__default["default"].createElement(FluidSelect["default"], _rollupPluginBabelHelpers["extends"]({
|
|
30
|
+
className: className,
|
|
31
|
+
ref: ref
|
|
32
|
+
}, other), children);
|
|
33
|
+
});
|
|
34
|
+
FluidTimePickerSelect.propTypes = {
|
|
35
|
+
/**
|
|
36
|
+
* Provide the contents of your Select
|
|
37
|
+
*/
|
|
38
|
+
children: PropTypes__default["default"].node,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Specify an optional className to be applied to the node containing the label and the select box
|
|
42
|
+
*/
|
|
43
|
+
className: PropTypes__default["default"].string,
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Optionally provide the default value of the `<select>`
|
|
47
|
+
*/
|
|
48
|
+
defaultValue: PropTypes__default["default"].any,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Specify whether the control is disabled
|
|
52
|
+
*/
|
|
53
|
+
disabled: PropTypes__default["default"].bool,
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Specify a custom `id` for the `<select>`
|
|
57
|
+
*/
|
|
58
|
+
id: PropTypes__default["default"].string.isRequired,
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Provide label text to be read by screen readers when interacting with the
|
|
62
|
+
* control
|
|
63
|
+
*/
|
|
64
|
+
labelText: PropTypes__default["default"].node,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Provide an optional `onChange` hook that is called each time the value of
|
|
68
|
+
* the underlying `<input>` changes
|
|
69
|
+
*/
|
|
70
|
+
onChange: PropTypes__default["default"].func
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports["default"] = FluidTimePickerSelect;
|
|
@@ -100,6 +100,7 @@ function ListBoxSelection(_ref) {
|
|
|
100
100
|
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
101
101
|
"aria-label": description,
|
|
102
102
|
className: className,
|
|
103
|
+
disabled: disabled,
|
|
103
104
|
onClick: onClick,
|
|
104
105
|
onKeyDown: onKeyDown,
|
|
105
106
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -180,7 +180,8 @@ function NotificationIcon(_ref3) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return /*#__PURE__*/React__default["default"].createElement(IconForKind, {
|
|
183
|
-
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon")
|
|
183
|
+
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon"),
|
|
184
|
+
size: 20
|
|
184
185
|
}, /*#__PURE__*/React__default["default"].createElement("title", null, iconDescription));
|
|
185
186
|
}
|
|
186
187
|
|
|
@@ -61,8 +61,10 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
61
61
|
_props$invalidText = props.invalidText,
|
|
62
62
|
invalidText = _props$invalidText === void 0 ? enabled ? undefined : 'Provide invalidText' : _props$invalidText,
|
|
63
63
|
light = props.light,
|
|
64
|
-
max = props.max,
|
|
65
|
-
|
|
64
|
+
_props$max = props.max,
|
|
65
|
+
max = _props$max === void 0 ? 100 : _props$max,
|
|
66
|
+
_props$min = props.min,
|
|
67
|
+
min = _props$min === void 0 ? 0 : _props$min,
|
|
66
68
|
onChange = props.onChange,
|
|
67
69
|
_onClick = props.onClick,
|
|
68
70
|
onKeyUp = props.onKeyUp,
|
|
@@ -152,9 +152,9 @@ var Select = /*#__PURE__*/React__default["default"].forwardRef(function Select(_
|
|
|
152
152
|
"data-invalid": invalid || null,
|
|
153
153
|
onFocus: handleFocus,
|
|
154
154
|
onBlur: handleFocus
|
|
155
|
-
}, input
|
|
155
|
+
}, input, isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
156
156
|
className: "".concat(prefix, "--select__divider")
|
|
157
|
-
}), !inline && error ? error : helper));
|
|
157
|
+
}), isFluid && error ? error : null), !inline && !isFluid && error ? error : helper));
|
|
158
158
|
});
|
|
159
159
|
Select.displayName = 'Select';
|
|
160
160
|
Select.propTypes = {
|
|
@@ -19,6 +19,7 @@ var index = require('../FeatureFlags/index.js');
|
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
require('../FluidForm/FluidForm.js');
|
|
21
21
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
22
|
+
var useAnnouncer = require('../../internal/useAnnouncer.js');
|
|
22
23
|
|
|
23
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
25
|
|
|
@@ -60,11 +61,6 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
60
61
|
textCount = _useState2[0],
|
|
61
62
|
setTextCount = _useState2[1];
|
|
62
63
|
|
|
63
|
-
var _useState3 = React.useState(''),
|
|
64
|
-
_useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
|
|
65
|
-
ariaAnnouncement = _useState4[0],
|
|
66
|
-
setAriaAnnouncement = _useState4[1];
|
|
67
|
-
|
|
68
64
|
var textareaProps = {
|
|
69
65
|
id: id,
|
|
70
66
|
onChange: function onChange(evt) {
|
|
@@ -88,15 +84,7 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
88
84
|
textareaProps.maxLength = maxCount;
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
var lastTen = maxCount - 10;
|
|
93
|
-
|
|
94
|
-
if (textCount >= lastTen) {
|
|
95
|
-
setAriaAnnouncement("".concat(maxCount - textCount, " characters left."));
|
|
96
|
-
} else {
|
|
97
|
-
setAriaAnnouncement('');
|
|
98
|
-
}
|
|
99
|
-
}, [textCount, maxCount]);
|
|
87
|
+
var ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
|
|
100
88
|
var labelClasses = cx__default["default"]("".concat(prefix, "--label"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--visually-hidden"), hideLabel && !isFluid), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--label--disabled"), disabled), _classNames));
|
|
101
89
|
var label = labelText ? /*#__PURE__*/React__default["default"].createElement("label", {
|
|
102
90
|
htmlFor: id,
|
|
@@ -125,6 +113,7 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
125
113
|
"aria-invalid": invalid || null,
|
|
126
114
|
"aria-describedby": invalid ? errorId : null,
|
|
127
115
|
disabled: other.disabled,
|
|
116
|
+
readOnly: other.readOnly,
|
|
128
117
|
style: other.cols ? {} : {
|
|
129
118
|
width: "100%"
|
|
130
119
|
}
|
|
@@ -134,7 +123,7 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
134
123
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
135
124
|
className: "".concat(prefix, "--text-area__label-wrapper")
|
|
136
125
|
}, label, counter), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
137
|
-
className: "".concat(prefix, "--text-area__wrapper"),
|
|
126
|
+
className: cx__default["default"]("".concat(prefix, "--text-area__wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly)),
|
|
138
127
|
"data-invalid": invalid || null
|
|
139
128
|
}, invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
140
129
|
className: "".concat(prefix, "--text-area__invalid-icon")
|
|
@@ -232,6 +221,11 @@ TextArea.propTypes = {
|
|
|
232
221
|
*/
|
|
233
222
|
placeholder: PropTypes__default["default"].string,
|
|
234
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Whether the textarea should be read-only
|
|
226
|
+
*/
|
|
227
|
+
readOnly: PropTypes__default["default"].bool,
|
|
228
|
+
|
|
235
229
|
/**
|
|
236
230
|
* Specify the rows attribute for the `<textarea>`
|
|
237
231
|
*/
|
|
@@ -23,6 +23,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
23
23
|
var index = require('../FeatureFlags/index.js');
|
|
24
24
|
var FeatureFlags = require('@carbon/feature-flags');
|
|
25
25
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
26
|
+
var useAnnouncer = require('../../internal/useAnnouncer.js');
|
|
26
27
|
|
|
27
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
29
|
|
|
@@ -166,6 +167,7 @@ var TextInput = /*#__PURE__*/React__default["default"].forwardRef(function TextI
|
|
|
166
167
|
var _useContext = React.useContext(FormContext.FormContext),
|
|
167
168
|
isFluid = _useContext.isFluid;
|
|
168
169
|
|
|
170
|
+
var ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
|
|
169
171
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
170
172
|
className: inputWrapperClasses
|
|
171
173
|
}, !inline ? labelWrapper : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -177,7 +179,10 @@ var TextInput = /*#__PURE__*/React__default["default"].forwardRef(function TextI
|
|
|
177
179
|
"data-invalid": normalizedProps.invalid || null
|
|
178
180
|
}, normalizedProps.icon && /*#__PURE__*/React__default["default"].createElement(normalizedProps.icon, {
|
|
179
181
|
className: iconClasses
|
|
180
|
-
}), input,
|
|
182
|
+
}), input, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
183
|
+
className: "".concat(prefix, "--text-input__counter-alert"),
|
|
184
|
+
role: "alert"
|
|
185
|
+
}, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
181
186
|
className: "".concat(prefix, "--text-input__divider")
|
|
182
187
|
}), isFluid && !inline && normalizedProps.validation), !isFluid && !inline && (normalizedProps.validation || helper)));
|
|
183
188
|
});
|
package/lib/index.js
CHANGED
|
@@ -169,6 +169,9 @@ var FluidTextArea = require('./components/FluidTextArea/FluidTextArea.js');
|
|
|
169
169
|
var FluidTextArea_Skeleton = require('./components/FluidTextArea/FluidTextArea.Skeleton.js');
|
|
170
170
|
var FluidTextInput = require('./components/FluidTextInput/FluidTextInput.js');
|
|
171
171
|
var FluidTextInput_Skeleton = require('./components/FluidTextInput/FluidTextInput.Skeleton.js');
|
|
172
|
+
var FluidTimePicker = require('./components/FluidTimePicker/FluidTimePicker.js');
|
|
173
|
+
var FluidTimePicker_Skeleton = require('./components/FluidTimePicker/FluidTimePicker.Skeleton.js');
|
|
174
|
+
var FluidTimePickerSelect = require('./components/FluidTimePickerSelect/FluidTimePickerSelect.js');
|
|
172
175
|
var index$a = require('./components/Heading/index.js');
|
|
173
176
|
var index$b = require('./components/IconButton/index.js');
|
|
174
177
|
var index$c = require('./components/Layer/index.js');
|
|
@@ -406,6 +409,9 @@ exports.unstable__FluidTextArea = FluidTextArea["default"];
|
|
|
406
409
|
exports.unstable__FluidTextAreaSkeleton = FluidTextArea_Skeleton["default"];
|
|
407
410
|
exports.unstable__FluidTextInput = FluidTextInput["default"];
|
|
408
411
|
exports.unstable__FluidTextInputSkeleton = FluidTextInput_Skeleton["default"];
|
|
412
|
+
exports.unstable__FluidTimePicker = FluidTimePicker["default"];
|
|
413
|
+
exports.unstable__FluidTimePickerSkeleton = FluidTimePicker_Skeleton["default"];
|
|
414
|
+
exports.unstable__FluidTimePickerSelect = FluidTimePickerSelect["default"];
|
|
409
415
|
exports.Heading = index$a.Heading;
|
|
410
416
|
exports.Section = index$a.Section;
|
|
411
417
|
exports.IconButton = index$b.IconButton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2022
|
|
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
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
function useAnnouncer(textCount, maxCount) {
|
|
13
|
+
var lastTen = maxCount - 10;
|
|
14
|
+
|
|
15
|
+
if (textCount >= lastTen) {
|
|
16
|
+
return "".concat(maxCount - textCount, " characters left.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.useAnnouncer = useAnnouncer;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.19.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.18.3",
|
|
46
|
-
"@carbon/feature-flags": "^0.
|
|
47
|
-
"@carbon/icons-react": "^11.
|
|
48
|
-
"@carbon/layout": "^11.
|
|
49
|
-
"@carbon/styles": "^1.
|
|
46
|
+
"@carbon/feature-flags": "^0.11.0-rc.0",
|
|
47
|
+
"@carbon/icons-react": "^11.13.0-rc.0",
|
|
48
|
+
"@carbon/layout": "^11.9.0-rc.0",
|
|
49
|
+
"@carbon/styles": "^1.19.0-rc.0",
|
|
50
50
|
"@carbon/telemetry": "0.1.0",
|
|
51
51
|
"classnames": "2.3.2",
|
|
52
52
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@babel/preset-env": "^7.18.2",
|
|
74
74
|
"@babel/preset-react": "^7.17.12",
|
|
75
75
|
"@carbon/test-utils": "^10.26.0",
|
|
76
|
-
"@carbon/themes": "^11.
|
|
77
|
-
"@rollup/plugin-babel": "^
|
|
76
|
+
"@carbon/themes": "^11.14.0-rc.0",
|
|
77
|
+
"@rollup/plugin-babel": "^6.0.0",
|
|
78
78
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
79
79
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
80
80
|
"@rollup/plugin-typescript": "^9.0.0",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
93
93
|
"@typescript-eslint/parser": "^5.38.1",
|
|
94
94
|
"autoprefixer": "^10.4.0",
|
|
95
|
-
"babel-loader": "^
|
|
95
|
+
"babel-loader": "^9.0.0",
|
|
96
96
|
"babel-plugin-dev-expression": "^0.2.3",
|
|
97
97
|
"babel-preset-carbon": "^0.3.0",
|
|
98
98
|
"browserify-zlib": "^0.2.0",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"**/*.scss",
|
|
136
136
|
"**/*.css"
|
|
137
137
|
],
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "a9d6ab5cc79665453f218fd5821c65c399337c15"
|
|
139
139
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Code generated by @carbon/react. DO NOT EDIT.
|
|
2
|
+
//
|
|
3
|
+
// Copyright IBM Corp. 2018, 2018
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
@forward '@carbon/styles/scss/components/fluid-time-picker/fluid-time-picker';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Code generated by @carbon/react. DO NOT EDIT.
|
|
2
|
+
//
|
|
3
|
+
// Copyright IBM Corp. 2018, 2018
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
@forward '@carbon/styles/scss/components/fluid-time-picker';
|