@carbon/react 1.19.0 → 1.20.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/_virtual/_commonjsHelpers.js +15 -2
- package/es/_virtual/index.js +6 -2
- package/es/_virtual/rangePlugin.js +6 -2
- package/es/components/ContainedList/ContainedList.js +8 -1
- package/es/components/DataTable/TableHeader.js +1 -3
- package/es/components/DatePicker/DatePicker.js +14 -3
- package/es/components/FluidNumberInput/FluidNumberInput.Skeleton.js +42 -0
- package/es/components/FluidNumberInput/FluidNumberInput.js +138 -0
- package/es/components/FluidSearch/FluidSearch.Skeleton.js +42 -0
- package/es/components/FluidSearch/FluidSearch.js +114 -0
- package/es/components/NumberInput/NumberInput.js +38 -20
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +86 -125
- package/es/components/ProgressBar/ProgressBar.js +11 -4
- package/es/components/Search/Search.js +8 -2
- package/es/components/SkeletonText/SkeletonText.js +40 -39
- package/es/components/Slider/Slider.js +16 -26
- package/es/components/TextArea/TextArea.js +11 -4
- package/es/components/Tile/Tile.js +7 -5
- package/es/components/TimePickerSelect/TimePickerSelect.js +57 -69
- package/es/components/TimePickerSelect/index.js +2 -3
- package/es/index.js +4 -0
- package/es/node_modules/flatpickr/dist/l10n/index.js +3 -3
- package/es/node_modules/flatpickr/dist/plugins/rangePlugin.js +2 -2
- package/es/node_modules/use-resize-observer/polyfilled.js +0 -1
- package/lib/_virtual/_commonjsHelpers.js +15 -2
- package/lib/_virtual/index.js +6 -2
- package/lib/_virtual/rangePlugin.js +6 -2
- package/lib/components/ContainedList/ContainedList.js +8 -1
- package/lib/components/DataTable/TableHeader.js +1 -3
- package/lib/components/DatePicker/DatePicker.js +13 -2
- package/lib/components/FluidNumberInput/FluidNumberInput.Skeleton.js +52 -0
- package/lib/components/FluidNumberInput/FluidNumberInput.js +148 -0
- package/lib/components/FluidSearch/FluidSearch.Skeleton.js +52 -0
- package/lib/components/FluidSearch/FluidSearch.js +124 -0
- package/lib/components/NumberInput/NumberInput.js +37 -19
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +83 -141
- package/lib/components/ProgressBar/ProgressBar.js +10 -3
- package/lib/components/Search/Search.js +7 -1
- package/lib/components/SkeletonText/SkeletonText.js +38 -37
- package/lib/components/Slider/Slider.js +16 -26
- package/lib/components/TextArea/TextArea.js +10 -3
- package/lib/components/Tile/Tile.js +7 -5
- package/lib/components/TimePickerSelect/TimePickerSelect.js +53 -65
- package/lib/components/TimePickerSelect/index.js +2 -3
- package/lib/index.js +8 -0
- package/lib/node_modules/flatpickr/dist/l10n/index.js +2 -2
- package/lib/node_modules/flatpickr/dist/plugins/rangePlugin.js +2 -2
- package/lib/node_modules/use-resize-observer/polyfilled.js +0 -1
- package/package.json +7 -7
- package/scss/components/fluid-combo-box/_fluid-combo-box.scss +9 -0
- package/scss/components/fluid-combo-box/_index.scss +9 -0
- package/scss/components/fluid-multiselect/_fluid-multiselect.scss +9 -0
- package/scss/components/fluid-multiselect/_index.scss +9 -0
- package/scss/components/fluid-number-input/_fluid-number-input.scss +9 -0
- package/scss/components/fluid-number-input/_index.scss +9 -0
- package/scss/components/fluid-search/_fluid-search.scss +9 -0
- package/scss/components/fluid-search/_index.scss +9 -0
- package/es/components/TimePickerSelect/next/TimePickerSelect.js +0 -70
- package/lib/components/TimePickerSelect/next/TimePickerSelect.js +0 -80
|
@@ -12,8 +12,21 @@ function getDefaultExportFromCjs (x) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function getAugmentedNamespace(n) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (n.__esModule) return n;
|
|
16
|
+
var f = n.default;
|
|
17
|
+
if (typeof f == "function") {
|
|
18
|
+
var a = function a () {
|
|
19
|
+
if (this instanceof a) {
|
|
20
|
+
var args = [null];
|
|
21
|
+
args.push.apply(args, arguments);
|
|
22
|
+
var Ctor = Function.bind.apply(f, args);
|
|
23
|
+
return new Ctor();
|
|
24
|
+
}
|
|
25
|
+
return f.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
a.prototype = f.prototype;
|
|
28
|
+
} else a = {};
|
|
29
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
17
30
|
Object.keys(n).forEach(function (k) {
|
|
18
31
|
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
19
32
|
Object.defineProperty(a, k, d.get ? d : {
|
package/es/_virtual/index.js
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var l10nExports = {};
|
|
9
|
+
var l10n = {
|
|
10
|
+
get exports(){ return l10nExports; },
|
|
11
|
+
set exports(v){ l10nExports = v; },
|
|
12
|
+
};
|
|
9
13
|
|
|
10
|
-
export { l10n as
|
|
14
|
+
export { l10n as __module, l10nExports as exports };
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var rangePluginExports = {};
|
|
9
|
+
var rangePlugin = {
|
|
10
|
+
get exports(){ return rangePluginExports; },
|
|
11
|
+
set exports(v){ rangePluginExports = v; },
|
|
12
|
+
};
|
|
9
13
|
|
|
10
|
-
export { rangePlugin as
|
|
14
|
+
export { rangePlugin as __module, rangePluginExports as exports };
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
8
9
|
import React__default from 'react';
|
|
9
10
|
import PropTypes from 'prop-types';
|
|
10
11
|
import cx from 'classnames';
|
|
@@ -17,6 +18,7 @@ function ContainedList(_ref) {
|
|
|
17
18
|
var action = _ref.action,
|
|
18
19
|
children = _ref.children,
|
|
19
20
|
className = _ref.className,
|
|
21
|
+
isInset = _ref.isInset,
|
|
20
22
|
_ref$kind = _ref.kind,
|
|
21
23
|
kind = _ref$kind === void 0 ? variants[0] : _ref$kind,
|
|
22
24
|
label = _ref.label,
|
|
@@ -24,7 +26,7 @@ function ContainedList(_ref) {
|
|
|
24
26
|
size = _ref$size === void 0 ? 'lg' : _ref$size;
|
|
25
27
|
var labelId = "".concat(useId('contained-list'), "-header");
|
|
26
28
|
var prefix = usePrefix();
|
|
27
|
-
var classes = cx("".concat(prefix, "--contained-list"), "".concat(prefix, "--contained-list--").concat(kind), "".concat(prefix, "--contained-list--").concat(size), className);
|
|
29
|
+
var classes = cx("".concat(prefix, "--contained-list"), _defineProperty({}, "".concat(prefix, "--contained-list--inset-rulers"), isInset), "".concat(prefix, "--contained-list--").concat(kind), "".concat(prefix, "--contained-list--").concat(size), className);
|
|
28
30
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
29
31
|
className: classes
|
|
30
32
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -55,6 +57,11 @@ ContainedList.propTypes = {
|
|
|
55
57
|
*/
|
|
56
58
|
className: PropTypes.string,
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Specify whether the dividing lines in between list items should be inset.
|
|
62
|
+
*/
|
|
63
|
+
isInset: PropTypes.bool,
|
|
64
|
+
|
|
58
65
|
/**
|
|
59
66
|
* The kind of ContainedList you want to display
|
|
60
67
|
*/
|
|
@@ -96,9 +96,7 @@ var TableHeader = /*#__PURE__*/React__default.forwardRef(function TableHeader(_r
|
|
|
96
96
|
ref: ref,
|
|
97
97
|
scope: scope
|
|
98
98
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
99
|
-
|
|
100
|
-
display: 'none'
|
|
101
|
-
},
|
|
99
|
+
className: "".concat(prefix, "--table-sort__description"),
|
|
102
100
|
id: uniqueId
|
|
103
101
|
}, sortDescription), /*#__PURE__*/React__default.createElement("button", _extends({
|
|
104
102
|
type: "button",
|
|
@@ -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, { useContext, useRef, useEffect } from 'react';
|
|
10
|
+
import React__default, { useContext, useRef, useEffect, useImperativeHandle } 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';
|
|
@@ -121,8 +121,8 @@ function isLabelTextEmpty(children) {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
var rightArrowHTML = "<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n <polygon points=\"11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 \"/>\n
|
|
125
|
-
var leftArrowHTML = "<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n <polygon points=\"5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 \"/>\n
|
|
124
|
+
var rightArrowHTML = "<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n <polygon points=\"11,8 6,13 5.3,12.3 9.6,8 5.3,3.7 6,3 \"/>\n</svg>";
|
|
125
|
+
var leftArrowHTML = "<svg width=\"16px\" height=\"16px\" viewBox=\"0 0 16 16\">\n <polygon points=\"5,8 10,3 10.7,3.7 6.4,8 10.7,12.3 10,13 \"/>\n</svg>";
|
|
126
126
|
|
|
127
127
|
function updateClassNames(calendar, prefix) {
|
|
128
128
|
var calendarContainer = calendar.calendarContainer;
|
|
@@ -382,7 +382,18 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
}, [savedOnChange, savedOnClose, savedOnOpen, readOnly]); //eslint-disable-line react-hooks/exhaustive-deps
|
|
385
|
+
// this hook allows consumers to access the flatpickr calendar
|
|
386
|
+
// instance for cases where functions like open() or close()
|
|
387
|
+
// need to be imperatively called on the calendar
|
|
385
388
|
|
|
389
|
+
useImperativeHandle(ref, function () {
|
|
390
|
+
return {
|
|
391
|
+
get calendar() {
|
|
392
|
+
return calendarRef.current;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
};
|
|
396
|
+
});
|
|
386
397
|
useEffect(function () {
|
|
387
398
|
var _calendarRef$current;
|
|
388
399
|
|
|
@@ -0,0 +1,42 @@
|
|
|
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 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
|
+
|
|
15
|
+
var _excluded = ["className"];
|
|
16
|
+
|
|
17
|
+
function FluidNumberInputSkeleton(_ref) {
|
|
18
|
+
var className = _ref.className,
|
|
19
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
|
|
21
|
+
var prefix = usePrefix();
|
|
22
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
isFluid: true
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
27
|
+
className: cx("".concat(prefix, "--form-item ").concat(prefix, "--text-input--fluid__skeleton"), className)
|
|
28
|
+
}, other), /*#__PURE__*/React__default.createElement("span", {
|
|
29
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
30
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
31
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
FluidNumberInputSkeleton.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
38
|
+
*/
|
|
39
|
+
className: PropTypes.string
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { FluidNumberInputSkeleton as default };
|
|
@@ -0,0 +1,138 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import '../NumberInput/NumberInput.Skeleton.js';
|
|
13
|
+
import { NumberInput } from '../NumberInput/NumberInput.js';
|
|
14
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
|
+
|
|
17
|
+
var _excluded = ["className"];
|
|
18
|
+
var FluidNumberInput = /*#__PURE__*/React__default.forwardRef(function FluidNumberInput(_ref, ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
|
|
22
|
+
var prefix = usePrefix();
|
|
23
|
+
var classNames = cx("".concat(prefix, "--number-input--fluid"), className);
|
|
24
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
isFluid: true
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React__default.createElement(NumberInput, _extends({
|
|
29
|
+
ref: ref,
|
|
30
|
+
className: classNames
|
|
31
|
+
}, other)));
|
|
32
|
+
});
|
|
33
|
+
FluidNumberInput.propTypes = {
|
|
34
|
+
/**
|
|
35
|
+
* `true` to allow empty string.
|
|
36
|
+
*/
|
|
37
|
+
allowEmpty: PropTypes.bool,
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Specify an optional className to be applied to the wrapper node
|
|
41
|
+
*/
|
|
42
|
+
className: PropTypes.string,
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Optional starting value for uncontrolled state
|
|
46
|
+
*/
|
|
47
|
+
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Specify if the wheel functionality for the input should be disabled, or not
|
|
51
|
+
*/
|
|
52
|
+
disableWheel: PropTypes.bool,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Specify if the control should be disabled, or not
|
|
56
|
+
*/
|
|
57
|
+
disabled: PropTypes.bool,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Provide a description for up/down icons that can be read by screen readers
|
|
61
|
+
*/
|
|
62
|
+
iconDescription: PropTypes.string,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Specify a custom `id` for the input
|
|
66
|
+
*/
|
|
67
|
+
id: PropTypes.string.isRequired,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Specify if the currently value is invalid.
|
|
71
|
+
*/
|
|
72
|
+
invalid: PropTypes.bool,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Message which is displayed if the value is invalid.
|
|
76
|
+
*/
|
|
77
|
+
invalidText: PropTypes.node,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Generic `label` that will be used as the textual representation of what
|
|
81
|
+
* this field is for
|
|
82
|
+
*/
|
|
83
|
+
label: PropTypes.node,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The maximum value.
|
|
87
|
+
*/
|
|
88
|
+
max: PropTypes.number,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The minimum value.
|
|
92
|
+
*/
|
|
93
|
+
min: PropTypes.number,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Provide an optional handler that is called when the internal state of
|
|
97
|
+
* NumberInput changes. This handler is called with event and state info.
|
|
98
|
+
* `(event, { value, direction }) => void`
|
|
99
|
+
*/
|
|
100
|
+
onChange: PropTypes.func,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Provide an optional function to be called when the up/down button is clicked
|
|
104
|
+
*/
|
|
105
|
+
onClick: PropTypes.func,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Provide an optional function to be called when a key is pressed in the number input
|
|
109
|
+
*/
|
|
110
|
+
onKeyUp: PropTypes.func,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
114
|
+
*/
|
|
115
|
+
step: PropTypes.number,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Provide custom text for the component for each translation id
|
|
119
|
+
*/
|
|
120
|
+
translateWithId: PropTypes.func,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Specify the value of the input
|
|
124
|
+
*/
|
|
125
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Specify whether the control is currently in warning state
|
|
129
|
+
*/
|
|
130
|
+
warn: PropTypes.bool,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Provide the text that is displayed when the control is in warning state
|
|
134
|
+
*/
|
|
135
|
+
warnText: PropTypes.node
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { FluidNumberInput as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
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 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
|
+
|
|
15
|
+
var _excluded = ["className"];
|
|
16
|
+
|
|
17
|
+
function FluidSearchSkeleton(_ref) {
|
|
18
|
+
var className = _ref.className,
|
|
19
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
|
|
21
|
+
var prefix = usePrefix();
|
|
22
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
isFluid: true
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
27
|
+
className: cx("".concat(prefix, "--form-item ").concat(prefix, "--text-input--fluid__skeleton"), className)
|
|
28
|
+
}, other), /*#__PURE__*/React__default.createElement("span", {
|
|
29
|
+
className: "".concat(prefix, "--label ").concat(prefix, "--skeleton")
|
|
30
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
31
|
+
className: "".concat(prefix, "--skeleton ").concat(prefix, "--text-input")
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
FluidSearchSkeleton.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
38
|
+
*/
|
|
39
|
+
className: PropTypes.string
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { FluidSearchSkeleton as default };
|
|
@@ -0,0 +1,114 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import Search from '../Search/Search.js';
|
|
13
|
+
import '../Search/Search.Skeleton.js';
|
|
14
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
|
+
|
|
17
|
+
var _excluded = ["className"];
|
|
18
|
+
var FluidSearch = /*#__PURE__*/React__default.forwardRef(function FluidSearch(_ref, ref) {
|
|
19
|
+
var className = _ref.className,
|
|
20
|
+
other = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
|
|
22
|
+
var prefix = usePrefix();
|
|
23
|
+
var classNames = cx("".concat(prefix, "--search--fluid"), className);
|
|
24
|
+
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
isFluid: true
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React__default.createElement(Search, _extends({
|
|
29
|
+
ref: ref,
|
|
30
|
+
className: classNames
|
|
31
|
+
}, other)));
|
|
32
|
+
});
|
|
33
|
+
FluidSearch.defaultProps = {
|
|
34
|
+
autoComplete: 'off',
|
|
35
|
+
closeButtonLabelText: 'Clear search input',
|
|
36
|
+
role: 'searchbox',
|
|
37
|
+
type: 'text'
|
|
38
|
+
};
|
|
39
|
+
FluidSearch.propTypes = {
|
|
40
|
+
/**
|
|
41
|
+
* Specify an optional value for the `autocomplete` property on the underlying
|
|
42
|
+
* `<input>`, defaults to "off"
|
|
43
|
+
*/
|
|
44
|
+
autoComplete: PropTypes.string,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Specify an optional className to be applied to the container node
|
|
48
|
+
*/
|
|
49
|
+
className: PropTypes.string,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Specify a label to be read by screen readers on the "close" button
|
|
53
|
+
*/
|
|
54
|
+
closeButtonLabelText: PropTypes.string,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Optionally provide the default value of the `<input>`
|
|
58
|
+
*/
|
|
59
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Specify whether the `<input>` should be disabled
|
|
63
|
+
*/
|
|
64
|
+
disabled: PropTypes.bool,
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Specify a custom `id` for the input
|
|
68
|
+
*/
|
|
69
|
+
id: PropTypes.string,
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Provide the label text for the Search icon
|
|
73
|
+
*/
|
|
74
|
+
labelText: PropTypes.node.isRequired,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Optional callback called when the search value changes.
|
|
78
|
+
*/
|
|
79
|
+
onChange: PropTypes.func,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Optional callback called when the search value is cleared.
|
|
83
|
+
*/
|
|
84
|
+
onClear: PropTypes.func,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Provide a handler that is invoked on the key down event for the input
|
|
88
|
+
*/
|
|
89
|
+
onKeyDown: PropTypes.func,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Provide an optional placeholder text for the Search.
|
|
93
|
+
* Note: if the label and placeholder differ,
|
|
94
|
+
* VoiceOver on Mac will read both
|
|
95
|
+
*/
|
|
96
|
+
placeholder: PropTypes.string,
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Specify the role for the underlying `<input>`, defaults to `searchbox`
|
|
100
|
+
*/
|
|
101
|
+
role: PropTypes.string,
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Optional prop to specify the type of the `<input>`
|
|
105
|
+
*/
|
|
106
|
+
type: PropTypes.string,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Specify the value of the `<input>`
|
|
110
|
+
*/
|
|
111
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { FluidSearch as default };
|
|
@@ -9,12 +9,13 @@ import { defineProperty as _defineProperty, objectWithoutProperties as _objectWi
|
|
|
9
9
|
import { Subtract, Add } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default, { useState, useRef } from 'react';
|
|
13
|
-
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
12
|
+
import React__default, { useContext, useState, useRef } from 'react';
|
|
14
13
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
14
|
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
16
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
16
|
import deprecate from '../../prop-types/deprecate.js';
|
|
17
|
+
import '../FluidForm/FluidForm.js';
|
|
18
|
+
import { FormContext } from '../FluidForm/FormContext.js';
|
|
18
19
|
|
|
19
20
|
var _excluded = ["allowEmpty", "className", "disabled", "disableWheel", "defaultValue", "helperText", "hideLabel", "hideSteppers", "iconDescription", "id", "label", "invalid", "invalidText", "light", "max", "min", "onChange", "onClick", "onKeyUp", "readOnly", "size", "step", "translateWithId", "warn", "warnText", "value"];
|
|
20
21
|
|
|
@@ -25,9 +26,7 @@ var translationIds = {
|
|
|
25
26
|
};
|
|
26
27
|
var defaultTranslations = (_defaultTranslations = {}, _defineProperty(_defaultTranslations, translationIds['increment.number'], 'Increment number'), _defineProperty(_defaultTranslations, translationIds['decrement.number'], 'Decrement number'), _defaultTranslations);
|
|
27
28
|
var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(props, forwardRef) {
|
|
28
|
-
var _cx, _cx3;
|
|
29
|
-
|
|
30
|
-
var enabled = useFeatureFlag('enable-v11-release');
|
|
29
|
+
var _cx, _cx3, _cx4;
|
|
31
30
|
|
|
32
31
|
var _props$allowEmpty = props.allowEmpty,
|
|
33
32
|
allowEmpty = _props$allowEmpty === void 0 ? false : _props$allowEmpty,
|
|
@@ -42,14 +41,12 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
42
41
|
_props$hideLabel = props.hideLabel,
|
|
43
42
|
hideLabel = _props$hideLabel === void 0 ? false : _props$hideLabel,
|
|
44
43
|
hideSteppers = props.hideSteppers,
|
|
45
|
-
|
|
46
|
-
iconDescription = _props$iconDescriptio === void 0 ? enabled ? undefined : 'choose a number' : _props$iconDescriptio,
|
|
44
|
+
iconDescription = props.iconDescription,
|
|
47
45
|
id = props.id,
|
|
48
46
|
label = props.label,
|
|
49
47
|
_props$invalid = props.invalid,
|
|
50
48
|
invalid = _props$invalid === void 0 ? false : _props$invalid,
|
|
51
|
-
|
|
52
|
-
invalidText = _props$invalidText === void 0 ? enabled ? undefined : 'Provide invalidText' : _props$invalidText,
|
|
49
|
+
invalidText = props.invalidText,
|
|
53
50
|
light = props.light,
|
|
54
51
|
_props$max = props.max,
|
|
55
52
|
max = _props$max === void 0 ? 100 : _props$max,
|
|
@@ -76,7 +73,15 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
76
73
|
|
|
77
74
|
var prefix = usePrefix();
|
|
78
75
|
|
|
79
|
-
var
|
|
76
|
+
var _useContext = useContext(FormContext),
|
|
77
|
+
isFluid = _useContext.isFluid;
|
|
78
|
+
|
|
79
|
+
var _useState = useState(false),
|
|
80
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
81
|
+
isFocused = _useState2[0],
|
|
82
|
+
setIsFocused = _useState2[1];
|
|
83
|
+
|
|
84
|
+
var _useState3 = useState(function () {
|
|
80
85
|
if (controlledValue !== undefined) {
|
|
81
86
|
return controlledValue;
|
|
82
87
|
}
|
|
@@ -87,18 +92,18 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
87
92
|
|
|
88
93
|
return 0;
|
|
89
94
|
}),
|
|
90
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
91
|
-
value = _useState2[0],
|
|
92
|
-
setValue = _useState2[1];
|
|
93
|
-
|
|
94
|
-
var _useState3 = useState(controlledValue),
|
|
95
95
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
value = _useState4[0],
|
|
97
|
+
setValue = _useState4[1];
|
|
98
|
+
|
|
99
|
+
var _useState5 = useState(controlledValue),
|
|
100
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
101
|
+
prevControlledValue = _useState6[0],
|
|
102
|
+
setPrevControlledValue = _useState6[1];
|
|
98
103
|
|
|
99
104
|
var inputRef = useRef(null);
|
|
100
105
|
var ref = useMergedRefs([forwardRef, inputRef]);
|
|
101
|
-
var numberInputClasses = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--number"), true), _defineProperty(_cx, "".concat(prefix, "--number--helpertext"), true), _defineProperty(_cx, "".concat(prefix, "--number--readonly"), readOnly), _defineProperty(_cx, "".concat(prefix, "--number--light"), light), _defineProperty(_cx, "".concat(prefix, "--number--nolabel"), hideLabel), _defineProperty(_cx, "".concat(prefix, "--number--nosteppers"), hideSteppers), _defineProperty(_cx, "".concat(prefix, "--number--").concat(size), size),
|
|
106
|
+
var numberInputClasses = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--number"), true), _defineProperty(_cx, "".concat(prefix, "--number--helpertext"), true), _defineProperty(_cx, "".concat(prefix, "--number--readonly"), readOnly), _defineProperty(_cx, "".concat(prefix, "--number--light"), light), _defineProperty(_cx, "".concat(prefix, "--number--nolabel"), hideLabel), _defineProperty(_cx, "".concat(prefix, "--number--nosteppers"), hideSteppers), _defineProperty(_cx, "".concat(prefix, "--number--").concat(size), size), _cx));
|
|
102
107
|
var isInputValid = getInputValidity({
|
|
103
108
|
allowEmpty: allowEmpty,
|
|
104
109
|
invalid: invalid,
|
|
@@ -152,8 +157,19 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
|
|
160
|
+
var handleFocus = function handleFocus(evt) {
|
|
161
|
+
if (evt.target.type === 'button') {
|
|
162
|
+
setIsFocused(false);
|
|
163
|
+
} else {
|
|
164
|
+
setIsFocused(evt.type === 'focus' ? true : false);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
var outerElementClasses = cx("".concat(prefix, "--form-item"), (_cx4 = {}, _defineProperty(_cx4, customClassName, !!customClassName), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--invalid"), isFluid && normalizedProps.invalid), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--focus"), isFluid && isFocused), _defineProperty(_cx4, "".concat(prefix, "--number-input--fluid--disabled"), isFluid && disabled), _cx4));
|
|
155
169
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
156
|
-
className:
|
|
170
|
+
className: outerElementClasses,
|
|
171
|
+
onFocus: isFluid ? handleFocus : null,
|
|
172
|
+
onBlur: isFluid ? handleFocus : null
|
|
157
173
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
158
174
|
className: numberInputClasses,
|
|
159
175
|
"data-invalid": normalizedProps.invalid ? true : undefined
|
|
@@ -255,7 +271,9 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
255
271
|
className: "up-icon"
|
|
256
272
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
257
273
|
className: "".concat(prefix, "--number__rule-divider")
|
|
258
|
-
}))),
|
|
274
|
+
}))), isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
275
|
+
className: "".concat(prefix, "--number-input__divider")
|
|
276
|
+
}), normalizedProps.validation ? normalizedProps.validation : /*#__PURE__*/React__default.createElement(HelperText, {
|
|
259
277
|
disabled: disabled,
|
|
260
278
|
description: helperText
|
|
261
279
|
})));
|