@carbon/react 1.17.0-rc.1 → 1.17.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/DatePicker/DatePicker.js +68 -6
- package/es/components/DatePickerInput/DatePickerInput.js +25 -9
- package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +67 -0
- package/es/components/FluidDatePicker/FluidDatePicker.js +76 -0
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +26 -0
- package/es/components/ListBox/ListBoxSelection.js +11 -4
- package/es/components/MultiSelect/MultiSelect.js +28 -5
- package/es/components/OverflowMenu/index.js +1 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
- package/es/components/SkeletonText/SkeletonText.js +1 -1
- package/es/components/StructuredList/StructuredList.js +89 -54
- package/es/components/TextArea/TextArea.js +4 -2
- package/es/index.js +4 -1
- package/es/internal/FloatingMenu.js +3 -1
- package/lib/components/DatePicker/DatePicker.js +66 -4
- package/lib/components/DatePickerInput/DatePickerInput.js +24 -8
- package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +77 -0
- package/lib/components/FluidDatePicker/FluidDatePicker.js +86 -0
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +34 -0
- package/lib/components/ListBox/ListBoxSelection.js +11 -4
- package/lib/components/MultiSelect/MultiSelect.js +28 -5
- package/lib/components/OverflowMenu/index.js +1 -22
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
- package/lib/components/SkeletonText/SkeletonText.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +87 -52
- package/lib/components/TextArea/TextArea.js +4 -2
- package/lib/index.js +43 -37
- package/lib/internal/FloatingMenu.js +3 -1
- package/package.json +5 -5
- package/scss/components/fluid-date-picker/_fluid-date-picker.scss +9 -0
- package/scss/components/fluid-date-picker/_index.scss +9 -0
- package/es/components/StructuredList/index.js +0 -43
- package/es/components/StructuredList/next/StructuredList.js +0 -342
- package/es/internal/ComponentToggle.js +0 -42
- package/lib/components/StructuredList/index.js +0 -52
- package/lib/components/StructuredList/next/StructuredList.js +0 -357
- package/lib/internal/ComponentToggle.js +0 -50
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, typeof as _typeof, objectSpread2 as _objectSpread2, extends as _extends, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useRef, useEffect } from 'react';
|
|
10
|
+
import React__default, { useContext, useRef, useEffect } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import flatpickr from 'flatpickr';
|
|
13
13
|
import l10n from '../../node_modules/flatpickr/dist/l10n/index.js';
|
|
@@ -18,10 +18,12 @@ import carbonFlatpickrRangePlugin from './plugins/rangePlugin.js';
|
|
|
18
18
|
import deprecate from '../../prop-types/deprecate.js';
|
|
19
19
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
20
20
|
import { useSavedCallback } from '../../internal/useSavedCallback.js';
|
|
21
|
+
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
22
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
21
23
|
import { match } from '../../internal/keyboard/match.js';
|
|
22
|
-
import { ArrowDown } from '../../internal/keyboard/keys.js';
|
|
24
|
+
import { Escape, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
23
25
|
|
|
24
|
-
var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "short", "value"];
|
|
26
|
+
var _excluded = ["allowInput", "appendTo", "children", "className", "closeOnSelect", "dateFormat", "datePickerType", "disable", "enable", "inline", "invalid", "invalidText", "warn", "warnText", "light", "locale", "maxDate", "minDate", "onChange", "onClose", "onOpen", "short", "value"];
|
|
25
27
|
|
|
26
28
|
l10n.en.weekdays.shorthand.forEach(function (_day, index) {
|
|
27
29
|
var currentDay = l10n.en.weekdays.shorthand;
|
|
@@ -161,6 +163,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
161
163
|
disable = _ref.disable,
|
|
162
164
|
enable = _ref.enable,
|
|
163
165
|
inline = _ref.inline,
|
|
166
|
+
invalid = _ref.invalid,
|
|
167
|
+
invalidText = _ref.invalidText,
|
|
168
|
+
warn = _ref.warn,
|
|
169
|
+
warnText = _ref.warnText,
|
|
164
170
|
_ref$light = _ref.light,
|
|
165
171
|
light = _ref$light === void 0 ? false : _ref$light,
|
|
166
172
|
_ref$locale = _ref.locale,
|
|
@@ -176,6 +182,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
176
182
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
177
183
|
|
|
178
184
|
var prefix = usePrefix();
|
|
185
|
+
|
|
186
|
+
var _useContext = useContext(FormContext),
|
|
187
|
+
isFluid = _useContext.isFluid;
|
|
188
|
+
|
|
179
189
|
var startInputField = useRef(null);
|
|
180
190
|
var endInputField = useRef(null);
|
|
181
191
|
var calendarRef = useRef(null);
|
|
@@ -282,6 +292,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
282
292
|
calendarRef.current = calendar;
|
|
283
293
|
|
|
284
294
|
function handleArrowDown(event) {
|
|
295
|
+
if (match(event, Escape)) {
|
|
296
|
+
calendar.calendarContainer.classList.remove('open');
|
|
297
|
+
}
|
|
298
|
+
|
|
285
299
|
if (match(event, ArrowDown)) {
|
|
286
300
|
var calendarContainer = calendar.calendarContainer,
|
|
287
301
|
fpSelectedDateElem = calendar.selectedDateElem,
|
|
@@ -293,6 +307,10 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
293
307
|
}
|
|
294
308
|
|
|
295
309
|
function handleOnChange() {
|
|
310
|
+
if (datePickerType == 'single') {
|
|
311
|
+
calendar.calendarContainer.classList.remove('open');
|
|
312
|
+
}
|
|
313
|
+
|
|
296
314
|
if (start.value !== '') {
|
|
297
315
|
return;
|
|
298
316
|
}
|
|
@@ -364,7 +382,7 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
364
382
|
}, [maxDate]);
|
|
365
383
|
useEffect(function () {
|
|
366
384
|
if (calendarRef.current && disable) {
|
|
367
|
-
calendarRef.current.set('
|
|
385
|
+
calendarRef.current.set('disable', disable);
|
|
368
386
|
}
|
|
369
387
|
}, [disable]);
|
|
370
388
|
useEffect(function () {
|
|
@@ -388,12 +406,36 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
388
406
|
startInputField.current.value = value;
|
|
389
407
|
}
|
|
390
408
|
}, [value, prefix]);
|
|
409
|
+
var fluidError;
|
|
410
|
+
|
|
411
|
+
if (isFluid) {
|
|
412
|
+
if (invalid) {
|
|
413
|
+
fluidError = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
414
|
+
className: "".concat(prefix, "--date-picker__icon ").concat(prefix, "--date-picker__icon--invalid")
|
|
415
|
+
}), /*#__PURE__*/React__default.createElement("hr", {
|
|
416
|
+
className: "".concat(prefix, "--date-picker__divider")
|
|
417
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
418
|
+
className: "".concat(prefix, "--form-requirement")
|
|
419
|
+
}, invalidText));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (warn && !invalid) {
|
|
423
|
+
fluidError = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
424
|
+
className: "".concat(prefix, "--date-picker__icon ").concat(prefix, "--date-picker__icon--warn")
|
|
425
|
+
}), /*#__PURE__*/React__default.createElement("hr", {
|
|
426
|
+
className: "".concat(prefix, "--date-picker__divider")
|
|
427
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
428
|
+
className: "".concat(prefix, "--form-requirement")
|
|
429
|
+
}, warnText));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
391
433
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
392
434
|
className: wrapperClasses,
|
|
393
435
|
ref: ref
|
|
394
436
|
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
395
437
|
className: datePickerClasses
|
|
396
|
-
}, childrenWithProps));
|
|
438
|
+
}, childrenWithProps), fluidError);
|
|
397
439
|
});
|
|
398
440
|
DatePicker.propTypes = {
|
|
399
441
|
/**
|
|
@@ -451,6 +493,16 @@ DatePicker.propTypes = {
|
|
|
451
493
|
*/
|
|
452
494
|
inline: PropTypes.bool,
|
|
453
495
|
|
|
496
|
+
/**
|
|
497
|
+
* Specify whether or not the control is invalid (Fluid only)
|
|
498
|
+
*/
|
|
499
|
+
invalid: PropTypes.bool,
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Provide the text that is displayed when the control is in error state (Fluid Only)
|
|
503
|
+
*/
|
|
504
|
+
invalidText: PropTypes.node,
|
|
505
|
+
|
|
454
506
|
/**
|
|
455
507
|
* `true` to use the light version.
|
|
456
508
|
*/
|
|
@@ -556,7 +608,17 @@ DatePicker.propTypes = {
|
|
|
556
608
|
* The value of the date value provided to flatpickr, could
|
|
557
609
|
* be a date, a date number, a date string, an array of dates.
|
|
558
610
|
*/
|
|
559
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object])), PropTypes.object, PropTypes.number])
|
|
611
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object])), PropTypes.object, PropTypes.number]),
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Specify whether the control is currently in warning state (Fluid only)
|
|
615
|
+
*/
|
|
616
|
+
warn: PropTypes.bool,
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Provide the text that is displayed when the control is in warning state (Fluid only)
|
|
620
|
+
*/
|
|
621
|
+
warnText: PropTypes.node
|
|
560
622
|
};
|
|
561
623
|
var DatePicker$1 = DatePicker;
|
|
562
624
|
|
|
@@ -9,12 +9,13 @@ import { objectWithoutProperties as _objectWithoutProperties, defineProperty as
|
|
|
9
9
|
import { WarningFilled, WarningAltFilled, Calendar } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default from 'react';
|
|
12
|
+
import React__default, { useContext } from 'react';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
14
15
|
|
|
15
16
|
var _excluded = ["datePickerType", "disabled", "helperText", "hideLabel", "id", "invalid", "invalidText", "labelText", "onClick", "onChange", "pattern", "placeholder", "size", "type", "warn", "warnText"];
|
|
16
17
|
var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePickerInput(props, ref) {
|
|
17
|
-
var _cx, _cx2, _cx4;
|
|
18
|
+
var _cx, _cx2, _cx4, _cx5;
|
|
18
19
|
|
|
19
20
|
var datePickerType = props.datePickerType,
|
|
20
21
|
_props$disabled = props.disabled,
|
|
@@ -42,6 +43,10 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
42
43
|
rest = _objectWithoutProperties(props, _excluded);
|
|
43
44
|
|
|
44
45
|
var prefix = usePrefix();
|
|
46
|
+
|
|
47
|
+
var _useContext = useContext(FormContext),
|
|
48
|
+
isFluid = _useContext.isFluid;
|
|
49
|
+
|
|
45
50
|
var datePickerInputProps = {
|
|
46
51
|
id: id,
|
|
47
52
|
onChange: function onChange(event) {
|
|
@@ -61,8 +66,8 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
61
66
|
var wrapperClasses = cx("".concat(prefix, "--date-picker-input__wrapper"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--date-picker-input__wrapper--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--date-picker-input__wrapper--warn"), warn), _cx));
|
|
62
67
|
var labelClasses = cx("".concat(prefix, "--label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _cx2));
|
|
63
68
|
var helperTextClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
64
|
-
var inputClasses = cx("".concat(prefix, "--date-picker__input"), (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--").concat(size), size), _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--invalid"), invalid), _cx4));
|
|
65
|
-
var containerClasses = cx("".concat(prefix, "--date-picker-container"),
|
|
69
|
+
var inputClasses = cx("".concat(prefix, "--date-picker__input"), (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--").concat(size), size), _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--warn"), warn), _cx4));
|
|
70
|
+
var containerClasses = cx("".concat(prefix, "--date-picker-container"), (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--date-picker--nolabel"), !labelText), _defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--invalid"), isFluid && invalid), _defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--warn"), isFluid && warn), _cx5));
|
|
66
71
|
var input = invalid ? /*#__PURE__*/React__default.createElement("input", _extends({}, rest, datePickerInputProps, {
|
|
67
72
|
disabled: disabled,
|
|
68
73
|
ref: ref,
|
|
@@ -80,15 +85,21 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
80
85
|
className: labelClasses
|
|
81
86
|
}, labelText), /*#__PURE__*/React__default.createElement("div", {
|
|
82
87
|
className: wrapperClasses
|
|
83
|
-
}, input, /*#__PURE__*/React__default.createElement(DatePickerIcon, {
|
|
88
|
+
}, input, isFluid && /*#__PURE__*/React__default.createElement(DatePickerIcon, {
|
|
89
|
+
datePickerType: datePickerType
|
|
90
|
+
}), /*#__PURE__*/React__default.createElement(DatePickerIcon, {
|
|
84
91
|
datePickerType: datePickerType,
|
|
85
92
|
invalid: invalid,
|
|
86
93
|
warn: warn
|
|
87
|
-
})), invalid && /*#__PURE__*/React__default.createElement("
|
|
94
|
+
})), invalid && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
95
|
+
className: "".concat(prefix, "--date-picker__divider")
|
|
96
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
88
97
|
className: "".concat(prefix, "--form-requirement")
|
|
89
|
-
}, invalidText), warn && /*#__PURE__*/React__default.createElement("
|
|
98
|
+
}, invalidText)), warn && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
99
|
+
className: "".concat(prefix, "--date-picker__divider")
|
|
100
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
90
101
|
className: "".concat(prefix, "--form-requirement")
|
|
91
|
-
}, warnText), helperText && /*#__PURE__*/React__default.createElement("div", {
|
|
102
|
+
}, warnText)), helperText && /*#__PURE__*/React__default.createElement("div", {
|
|
92
103
|
className: helperTextClasses
|
|
93
104
|
}, helperText));
|
|
94
105
|
});
|
|
@@ -196,8 +207,13 @@ function DatePickerIcon(_ref) {
|
|
|
196
207
|
warn = _ref.warn;
|
|
197
208
|
var prefix = usePrefix();
|
|
198
209
|
|
|
210
|
+
var _useContext2 = useContext(FormContext),
|
|
211
|
+
isFluid = _useContext2.isFluid;
|
|
212
|
+
|
|
199
213
|
if (datePickerType === 'simple' && !invalid && !warn) {
|
|
200
|
-
|
|
214
|
+
if (!isFluid) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
201
217
|
}
|
|
202
218
|
|
|
203
219
|
if (invalid) {
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { FormContext } from '../FluidForm/FormContext.js';
|
|
14
|
+
import { Calendar } from '@carbon/icons-react';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["className", "datePickerType"];
|
|
17
|
+
|
|
18
|
+
function FluidDatePickerSkeleton(_ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
_ref$datePickerType = _ref.datePickerType,
|
|
21
|
+
datePickerType = _ref$datePickerType === void 0 ? 'single' : _ref$datePickerType,
|
|
22
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
|
|
24
|
+
var prefix = usePrefix();
|
|
25
|
+
var classNames = cx(className, "".concat(prefix, "--form-item ").concat(prefix, "--date-picker--fluid__skeleton"), _defineProperty({}, "".concat(prefix, "--date-picker--fluid__skeleton--range"), datePickerType === 'range'));
|
|
26
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
isFluid: true
|
|
29
|
+
}
|
|
30
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
31
|
+
className: classNames
|
|
32
|
+
}, other), /*#__PURE__*/React__default.createElement("div", {
|
|
33
|
+
className: "".concat(prefix, "--date-picker--fluid__skeleton--container")
|
|
34
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
35
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
36
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
37
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
38
|
+
}), datePickerType !== 'simple' && /*#__PURE__*/React__default.createElement(Calendar, {
|
|
39
|
+
className: "".concat(prefix, "--date-picker__icon"),
|
|
40
|
+
role: "img",
|
|
41
|
+
"aria-hidden": "true"
|
|
42
|
+
})), datePickerType === 'range' && /*#__PURE__*/React__default.createElement("div", {
|
|
43
|
+
className: "".concat(prefix, "--date-picker--fluid__skeleton--container")
|
|
44
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
45
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
46
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
47
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
48
|
+
}), /*#__PURE__*/React__default.createElement(Calendar, {
|
|
49
|
+
className: "".concat(prefix, "--date-picker__icon"),
|
|
50
|
+
role: "img",
|
|
51
|
+
"aria-hidden": "true"
|
|
52
|
+
}))));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
FluidDatePickerSkeleton.propTypes = {
|
|
56
|
+
/**
|
|
57
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
58
|
+
*/
|
|
59
|
+
className: PropTypes.string,
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Specify which variant of the DatePicker the skeleton should mimic
|
|
63
|
+
*/
|
|
64
|
+
datePickerType: PropTypes.oneOf(['simple', 'single', 'range'])
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { FluidDatePickerSkeleton as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
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 DatePicker from '../DatePicker/DatePicker.js';
|
|
13
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
15
|
+
|
|
16
|
+
var _excluded = ["className", "children", "invalid", "invalidText", "warn", "warnText"];
|
|
17
|
+
var FluidDatePicker = /*#__PURE__*/React__default.forwardRef(function FluidDatePicker(_ref, ref) {
|
|
18
|
+
var _classnames;
|
|
19
|
+
|
|
20
|
+
var className = _ref.className,
|
|
21
|
+
children = _ref.children,
|
|
22
|
+
invalid = _ref.invalid,
|
|
23
|
+
invalidText = _ref.invalidText,
|
|
24
|
+
warn = _ref.warn,
|
|
25
|
+
warnText = _ref.warnText,
|
|
26
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
|
|
28
|
+
var prefix = usePrefix();
|
|
29
|
+
var classNames = cx(className, (_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid"), true), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--invalid"), invalid), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--warn"), warn), _classnames));
|
|
30
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
isFluid: true
|
|
33
|
+
}
|
|
34
|
+
}, /*#__PURE__*/React__default.createElement(DatePicker, _extends({
|
|
35
|
+
invalid: invalid,
|
|
36
|
+
invalidText: invalidText,
|
|
37
|
+
warn: warn,
|
|
38
|
+
warnText: warnText,
|
|
39
|
+
className: classNames,
|
|
40
|
+
ref: ref
|
|
41
|
+
}, other), children));
|
|
42
|
+
});
|
|
43
|
+
FluidDatePicker.propTypes = {
|
|
44
|
+
/**
|
|
45
|
+
* The child node(s)
|
|
46
|
+
*/
|
|
47
|
+
children: PropTypes.node,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
51
|
+
*/
|
|
52
|
+
className: PropTypes.string,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Specify whether or not the control is invalid
|
|
56
|
+
*/
|
|
57
|
+
invalid: PropTypes.bool,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Provide the text that is displayed when the control is in error state
|
|
61
|
+
*/
|
|
62
|
+
invalidText: PropTypes.node,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Specify whether the control is currently in warning state
|
|
66
|
+
*/
|
|
67
|
+
warn: PropTypes.bool,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Provide the text that is displayed when the control is in warning state
|
|
71
|
+
*/
|
|
72
|
+
warnText: PropTypes.node
|
|
73
|
+
};
|
|
74
|
+
var FluidDatePicker$1 = FluidDatePicker;
|
|
75
|
+
|
|
76
|
+
export { FluidDatePicker$1 as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default from 'react';
|
|
10
|
+
import DatePickerInput from '../DatePickerInput/DatePickerInput.js';
|
|
11
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
12
|
+
|
|
13
|
+
var FluidDatePickerInput = /*#__PURE__*/React__default.forwardRef(function FluidDatePickerInput(_ref, ref) {
|
|
14
|
+
var other = _extends({}, _ref);
|
|
15
|
+
|
|
16
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
17
|
+
value: {
|
|
18
|
+
isFluid: true
|
|
19
|
+
}
|
|
20
|
+
}, /*#__PURE__*/React__default.createElement(DatePickerInput, _extends({
|
|
21
|
+
ref: ref
|
|
22
|
+
}, other)));
|
|
23
|
+
});
|
|
24
|
+
var FluidDatePickerInput$1 = FluidDatePickerInput;
|
|
25
|
+
|
|
26
|
+
export { FluidDatePickerInput$1 as default };
|
|
@@ -28,14 +28,15 @@ function ListBoxSelection(_ref) {
|
|
|
28
28
|
selectionCount = _ref.selectionCount,
|
|
29
29
|
t = _ref.translateWithId,
|
|
30
30
|
disabled = _ref.disabled,
|
|
31
|
-
onClearSelection = _ref.onClearSelection
|
|
31
|
+
onClearSelection = _ref.onClearSelection,
|
|
32
|
+
readOnly = _ref.readOnly;
|
|
32
33
|
var prefix = usePrefix();
|
|
33
34
|
var className = cx("".concat(prefix, "--list-box__selection"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--tag--filter"), selectionCount), _defineProperty(_cx, "".concat(prefix, "--list-box__selection--multi"), selectionCount), _cx));
|
|
34
35
|
|
|
35
36
|
var handleOnClick = function handleOnClick(event) {
|
|
36
37
|
event.stopPropagation();
|
|
37
38
|
|
|
38
|
-
if (disabled) {
|
|
39
|
+
if (disabled || readOnly) {
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -49,7 +50,7 @@ function ListBoxSelection(_ref) {
|
|
|
49
50
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
50
51
|
event.stopPropagation();
|
|
51
52
|
|
|
52
|
-
if (disabled) {
|
|
53
|
+
if (disabled || readOnly) {
|
|
53
54
|
return;
|
|
54
55
|
} // When a user hits ENTER, we'll clear the selection
|
|
55
56
|
|
|
@@ -78,7 +79,8 @@ function ListBoxSelection(_ref) {
|
|
|
78
79
|
onKeyDown: handleOnKeyDown,
|
|
79
80
|
disabled: disabled,
|
|
80
81
|
"aria-label": t('clear.all'),
|
|
81
|
-
title: description
|
|
82
|
+
title: description,
|
|
83
|
+
"aria-disabled": readOnly ? true : undefined
|
|
82
84
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)))) : /*#__PURE__*/React__default.createElement("div", {
|
|
83
85
|
role: "button",
|
|
84
86
|
className: className,
|
|
@@ -125,6 +127,11 @@ ListBoxSelection.propTypes = {
|
|
|
125
127
|
*/
|
|
126
128
|
onKeyDown: PropTypes.func,
|
|
127
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Whether or not the Dropdown is readonly
|
|
132
|
+
*/
|
|
133
|
+
readOnly: PropTypes.bool,
|
|
134
|
+
|
|
128
135
|
/**
|
|
129
136
|
* Specify an optional `selectionCount` value that will be used to determine
|
|
130
137
|
* whether the selection should display a badge or a single clear icon.
|
|
@@ -73,7 +73,8 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
73
73
|
onChange = _ref.onChange,
|
|
74
74
|
onMenuChange = _ref.onMenuChange,
|
|
75
75
|
direction = _ref.direction,
|
|
76
|
-
selected = _ref.selectedItems
|
|
76
|
+
selected = _ref.selectedItems,
|
|
77
|
+
readOnly = _ref.readOnly;
|
|
77
78
|
var prefix = usePrefix();
|
|
78
79
|
|
|
79
80
|
var _useContext = useContext(FormContext),
|
|
@@ -164,7 +165,7 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
164
165
|
var helperId = !helperText ? undefined : "multiselect-helper-text-".concat(multiSelectInstanceId);
|
|
165
166
|
var fieldLabelId = "multiselect-field-label-".concat(multiSelectInstanceId);
|
|
166
167
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
167
|
-
var className = cx("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx4)); // needs to be capitalized for react to render it correctly
|
|
168
|
+
var className = cx("".concat(prefix, "--multi-select"), [enabled ? null : containerClassName], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--multi-select--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--multi-select--warning"), showWarning), _defineProperty(_cx4, "".concat(prefix, "--multi-select--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--multi-select--selected"), selectedItems && selectedItems.length > 0), _defineProperty(_cx4, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx4, "".concat(prefix, "--multi-select--readonly"), readOnly), _cx4)); // needs to be capitalized for react to render it correctly
|
|
168
169
|
|
|
169
170
|
var ItemToElement = itemToElement;
|
|
170
171
|
var sortOptions = {
|
|
@@ -229,6 +230,21 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
229
230
|
evt.target.classList.contains("".concat(prefix, "--tag__close-icon")) ? setIsFocused(false) : setIsFocused(evt.type === 'focus' ? true : false);
|
|
230
231
|
};
|
|
231
232
|
|
|
233
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
234
|
+
onClick: function onClick(evt) {
|
|
235
|
+
// NOTE: does not prevent click
|
|
236
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
237
|
+
|
|
238
|
+
evt.target.focus();
|
|
239
|
+
},
|
|
240
|
+
onKeyDown: function onKeyDown(evt) {
|
|
241
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
242
|
+
|
|
243
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
244
|
+
evt.preventDefault();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} : {};
|
|
232
248
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
233
249
|
className: wrapperClasses
|
|
234
250
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -242,6 +258,7 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
242
258
|
size: size,
|
|
243
259
|
className: className,
|
|
244
260
|
disabled: disabled,
|
|
261
|
+
readOnly: readOnly,
|
|
245
262
|
light: light,
|
|
246
263
|
invalid: invalid,
|
|
247
264
|
invalidText: invalidText,
|
|
@@ -257,12 +274,13 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
257
274
|
type: "button",
|
|
258
275
|
className: "".concat(prefix, "--list-box__field"),
|
|
259
276
|
disabled: disabled,
|
|
260
|
-
"aria-disabled": disabled
|
|
277
|
+
"aria-disabled": disabled || readOnly
|
|
261
278
|
}, toggleButtonProps, {
|
|
262
279
|
ref: mergeRefs(toggleButtonProps.ref, ref),
|
|
263
280
|
onKeyDown: onKeyDown
|
|
264
|
-
}), selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
|
|
265
|
-
|
|
281
|
+
}, readOnlyEventHandlers), selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
|
|
282
|
+
readOnly: readOnly,
|
|
283
|
+
clearSelection: !disabled && !readOnly ? clearSelection : noop,
|
|
266
284
|
selectionCount: selectedItems.length,
|
|
267
285
|
translateWithId: translateWithId,
|
|
268
286
|
disabled: disabled
|
|
@@ -413,6 +431,11 @@ MultiSelect.propTypes = _objectSpread2(_objectSpread2({}, sortingPropTypes), {},
|
|
|
413
431
|
*/
|
|
414
432
|
open: PropTypes.bool,
|
|
415
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Whether or not the Dropdown is readonly
|
|
436
|
+
*/
|
|
437
|
+
readOnly: PropTypes.bool,
|
|
438
|
+
|
|
416
439
|
/**
|
|
417
440
|
* For full control of the selected items
|
|
418
441
|
*/
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import * as FeatureFlags from '@carbon/feature-flags';
|
|
9
8
|
import { OverflowMenu as OverflowMenu$1 } from './OverflowMenu.js';
|
|
10
9
|
import { createClassWrapper } from '../../internal/createClassWrapper.js';
|
|
11
10
|
|
|
12
|
-
var OverflowMenu =
|
|
11
|
+
var OverflowMenu = createClassWrapper(OverflowMenu$1);
|
|
13
12
|
|
|
14
13
|
export { OverflowMenu as default };
|
|
@@ -28,7 +28,8 @@ var SkeletonPlaceholder = function SkeletonPlaceholder(_ref) {
|
|
|
28
28
|
|
|
29
29
|
SkeletonPlaceholder.propTypes = {
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Add a custom class to the component
|
|
32
|
+
* to set the height and width
|
|
32
33
|
*/
|
|
33
34
|
className: PropTypes.string
|
|
34
35
|
};
|