carbon-react 104.18.1 → 104.19.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/lib/components/batch-selection/batch-selection.style.js +14 -16
- package/lib/components/date-range/date-range.component.js +3 -10
- package/lib/components/decimal/decimal.component.js +11 -17
- package/lib/components/drawer/drawer.component.js +3 -10
- package/lib/hooks/__internal__/usePrevious/index.d.ts +1 -0
- package/lib/hooks/__internal__/usePrevious/index.js +16 -0
- package/package.json +1 -1
|
@@ -7,8 +7,6 @@ exports.StyledSelectionCount = exports.StyledBatchSelection = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
|
-
|
|
12
10
|
var _iconButton = _interopRequireDefault(require("../icon-button/icon-button.style"));
|
|
13
11
|
|
|
14
12
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
@@ -23,7 +21,6 @@ const StyledBatchSelection = _styledComponents.default.div`
|
|
|
23
21
|
${({
|
|
24
22
|
disabled,
|
|
25
23
|
colorTheme,
|
|
26
|
-
theme,
|
|
27
24
|
hidden
|
|
28
25
|
}) => (0, _styledComponents.css)`
|
|
29
26
|
align-items: center;
|
|
@@ -31,22 +28,26 @@ const StyledBatchSelection = _styledComponents.default.div`
|
|
|
31
28
|
|
|
32
29
|
${hidden && "opacity: 0;"}
|
|
33
30
|
|
|
31
|
+
${_icon.default} {
|
|
32
|
+
color: var(--colorsActionMajorYin065);
|
|
33
|
+
}
|
|
34
|
+
|
|
34
35
|
${colorTheme === "dark" && (0, _styledComponents.css)`
|
|
35
|
-
background-color:
|
|
36
|
-
color:
|
|
36
|
+
background-color: var(--colorsUtilityMajor500);
|
|
37
|
+
color: var(--colorsUtilityYang100);
|
|
37
38
|
|
|
38
39
|
${_icon.default} {
|
|
39
|
-
color:
|
|
40
|
+
color: var(--colorsActionMajorYang100);
|
|
40
41
|
}
|
|
41
42
|
`}
|
|
42
43
|
|
|
43
44
|
${colorTheme === "light" && (0, _styledComponents.css)`
|
|
44
|
-
background-color:
|
|
45
|
+
background-color: var(--colorsUtilityMajor150);
|
|
45
46
|
`}
|
|
46
47
|
|
|
47
48
|
${colorTheme === "white" && (0, _styledComponents.css)`
|
|
48
|
-
background-color:
|
|
49
|
-
box-shadow:
|
|
49
|
+
background-color: var(--colorsUtilityYang100);
|
|
50
|
+
box-shadow: var(--boxShadow100);
|
|
50
51
|
`}
|
|
51
52
|
|
|
52
53
|
${_iconButton.default} {
|
|
@@ -56,16 +57,16 @@ const StyledBatchSelection = _styledComponents.default.div`
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
${_iconButton.default}:hover {
|
|
59
|
-
background-color:
|
|
60
|
+
background-color: var(--colorsActionMajor500);
|
|
60
61
|
|
|
61
62
|
${_icon.default} {
|
|
62
|
-
color:
|
|
63
|
+
color: var(--colorsActionMajorYang100);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
${disabled && (0, _styledComponents.css)`
|
|
67
68
|
background: transparent;
|
|
68
|
-
color:
|
|
69
|
+
color: var(--colorsUtilityYin030);
|
|
69
70
|
cursor: not-allowed;
|
|
70
71
|
|
|
71
72
|
${_iconButton.default} {
|
|
@@ -73,16 +74,13 @@ const StyledBatchSelection = _styledComponents.default.div`
|
|
|
73
74
|
pointer-events: none;
|
|
74
75
|
|
|
75
76
|
${_icon.default} {
|
|
76
|
-
color:
|
|
77
|
+
color: var(--colorsActionMajorYin030);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
`}
|
|
80
81
|
`}
|
|
81
82
|
`;
|
|
82
83
|
exports.StyledBatchSelection = StyledBatchSelection;
|
|
83
|
-
StyledBatchSelection.defaultProps = {
|
|
84
|
-
theme: _base.default
|
|
85
|
-
};
|
|
86
84
|
const StyledSelectionCount = _styledComponents.default.span`
|
|
87
85
|
display: inline-block;
|
|
88
86
|
padding: 10px 15px;
|
|
@@ -25,6 +25,8 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
|
|
|
25
25
|
|
|
26
26
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
27
27
|
|
|
28
|
+
var _usePrevious = _interopRequireDefault(require("../../hooks/__internal__/usePrevious"));
|
|
29
|
+
|
|
28
30
|
var _dateFormats = _interopRequireDefault(require("../date/__internal__/date-formats"));
|
|
29
31
|
|
|
30
32
|
var _dateRange2 = _interopRequireDefault(require("./date-range.context"));
|
|
@@ -107,16 +109,7 @@ const DateRange = ({
|
|
|
107
109
|
formattedValue: getEndDate(),
|
|
108
110
|
rawValue: isEmptyValue(endDateProps.allowEmptyValue, getEndDate()) ? "" : (0, _utils.formatToISO)(format, getEndDate())
|
|
109
111
|
});
|
|
110
|
-
|
|
111
|
-
function usePrevious(arg) {
|
|
112
|
-
const ref = (0, _react.useRef)();
|
|
113
|
-
(0, _react.useEffect)(() => {
|
|
114
|
-
ref.current = arg;
|
|
115
|
-
});
|
|
116
|
-
return ref.current;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const previousValue = usePrevious(value);
|
|
112
|
+
const previousValue = (0, _usePrevious.default)(value);
|
|
120
113
|
(0, _react.useEffect)(() => {
|
|
121
114
|
const updateValues = () => {
|
|
122
115
|
setStartDateValue({
|
|
@@ -19,6 +19,8 @@ var _utils = require("../../style/utils");
|
|
|
19
19
|
|
|
20
20
|
var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
|
|
21
21
|
|
|
22
|
+
var _usePrevious = _interopRequireDefault(require("../../hooks/__internal__/usePrevious"));
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
26
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -99,27 +101,18 @@ const Decimal = ({
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
return formattedNumber;
|
|
102
|
-
}, [getSeparator, isNaN, l, locale, precision]);
|
|
103
|
-
|
|
104
|
-
function usePrevious(arg) {
|
|
105
|
-
const ref = (0, _react.useRef)();
|
|
106
|
-
(0, _react.useEffect)(() => {
|
|
107
|
-
ref.current = arg;
|
|
108
|
-
});
|
|
109
|
-
return ref.current;
|
|
110
|
-
}
|
|
104
|
+
}, [getSeparator, isNaN, l, locale, precision]);
|
|
111
105
|
/**
|
|
112
106
|
* Determine if the precision value has changed from the previous ref value for precision
|
|
113
107
|
*/
|
|
114
108
|
|
|
115
|
-
|
|
116
|
-
const prevPrecisionValue = usePrevious(precision);
|
|
109
|
+
const prevPrecisionValue = (0, _usePrevious.default)(precision);
|
|
117
110
|
(0, _react.useEffect)(() => {
|
|
118
111
|
if (prevPrecisionValue && prevPrecisionValue !== precision) {
|
|
119
112
|
// eslint-disable-next-line no-console
|
|
120
113
|
console.error("Decimal `precision` prop has changed value. Changing the Decimal `precision` prop has no effect.");
|
|
121
114
|
}
|
|
122
|
-
}, [precision]);
|
|
115
|
+
}, [precision, prevPrecisionValue]);
|
|
123
116
|
const removeDelimiters = (0, _react.useCallback)(valueToFormat => {
|
|
124
117
|
const delimiterMatcher = new RegExp(`[\\${getSeparator("group")} ]*`, "g");
|
|
125
118
|
return valueToFormat.replace(delimiterMatcher, "");
|
|
@@ -190,16 +183,17 @@ const Decimal = ({
|
|
|
190
183
|
if (onBlur) onBlur(event);
|
|
191
184
|
};
|
|
192
185
|
|
|
193
|
-
const
|
|
194
|
-
const
|
|
186
|
+
const isControlled = value !== undefined;
|
|
187
|
+
const prevControlledRef = (0, _react.useRef)();
|
|
195
188
|
(0, _react.useEffect)(() => {
|
|
196
189
|
const message = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
197
|
-
(0, _invariant.default)(
|
|
198
|
-
|
|
190
|
+
(0, _invariant.default)(prevControlledRef.current !== isControlled, message);
|
|
191
|
+
prevControlledRef.current = isControlled;
|
|
192
|
+
}, [isControlled]);
|
|
199
193
|
(0, _react.useEffect)(() => {
|
|
200
194
|
const unformattedValue = toStandardDecimal(stateValue);
|
|
201
195
|
|
|
202
|
-
if (
|
|
196
|
+
if (isControlled) {
|
|
203
197
|
const valueProp = getSafeValueProp(value);
|
|
204
198
|
|
|
205
199
|
if (unformattedValue !== valueProp) {
|
|
@@ -15,6 +15,8 @@ var _invariant = _interopRequireDefault(require("invariant"));
|
|
|
15
15
|
|
|
16
16
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
17
17
|
|
|
18
|
+
var _usePrevious = _interopRequireDefault(require("../../hooks/__internal__/usePrevious"));
|
|
19
|
+
|
|
18
20
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
19
21
|
|
|
20
22
|
var _drawer = require("./drawer.style");
|
|
@@ -88,16 +90,7 @@ const Drawer = ({
|
|
|
88
90
|
}, timeout);
|
|
89
91
|
}
|
|
90
92
|
}, [getAnimationDuration, isExpanded]);
|
|
91
|
-
|
|
92
|
-
function usePrevious(arg) {
|
|
93
|
-
const ref = (0, _react.useRef)();
|
|
94
|
-
(0, _react.useEffect)(() => {
|
|
95
|
-
ref.current = arg;
|
|
96
|
-
});
|
|
97
|
-
return ref.current;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const previousValue = usePrevious(expanded);
|
|
93
|
+
const previousValue = (0, _usePrevious.default)(expanded);
|
|
101
94
|
(0, _react.useEffect)(() => {
|
|
102
95
|
const message = "Drawer should not switch from uncontrolled to controlled" + " (or vice versa). Decide between using a controlled or uncontrolled Drawer element" + " for the lifetime of the component";
|
|
103
96
|
(0, _invariant.default)(isControlled.current === (expanded !== undefined), message);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function usePrevious<T>(value: T): T | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = usePrevious;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function usePrevious(value) {
|
|
11
|
+
const ref = (0, _react.useRef)();
|
|
12
|
+
(0, _react.useEffect)(() => {
|
|
13
|
+
ref.current = value;
|
|
14
|
+
});
|
|
15
|
+
return ref.current;
|
|
16
|
+
}
|