carbon-react 104.18.1 → 104.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.
@@ -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: ${theme.colors.slate};
36
- color: ${theme.colors.white};
36
+ background-color: var(--colorsUtilityMajor500);
37
+ color: var(--colorsUtilityYang100);
37
38
 
38
39
  ${_icon.default} {
39
- color: ${theme.colors.white};
40
+ color: var(--colorsActionMajorYang100);
40
41
  }
41
42
  `}
42
43
 
43
44
  ${colorTheme === "light" && (0, _styledComponents.css)`
44
- background-color: ${theme.batchSelection.lightTheme};
45
+ background-color: var(--colorsUtilityMajor150);
45
46
  `}
46
47
 
47
48
  ${colorTheme === "white" && (0, _styledComponents.css)`
48
- background-color: ${theme.white};
49
- box-shadow: ${theme.shadows.depth1};
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: ${theme.colors.base};
60
+ background-color: var(--colorsActionMajor500);
60
61
 
61
62
  ${_icon.default} {
62
- color: ${theme.colors.white};
63
+ color: var(--colorsActionMajorYang100);
63
64
  }
64
65
  }
65
66
 
66
67
  ${disabled && (0, _styledComponents.css)`
67
68
  background: transparent;
68
- color: ${theme.disabled.disabled};
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: ${theme.icon.disabled};
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;
@@ -30,7 +30,7 @@ const ButtonToggleGroupStyle = _styledComponents.default.div`
30
30
  ${({
31
31
  info
32
32
  }) => info && (0, _styledComponents.css)`
33
- border-color: var(--colorsActionMinor500);
33
+ border-color: var(--colorsSemanticInfo500);
34
34
  `};
35
35
  ${({
36
36
  warning
@@ -200,20 +200,11 @@ const StyledDayPicker = _styledComponents.default.div`
200
200
  z-index: 1000;
201
201
  top: calc(100% + 1px);
202
202
  left: 0;
203
- background-color: ${({
204
- theme
205
- }) => theme.colors.white};
206
- box-shadow: ${({
207
- theme
208
- }) => theme.shadows.depth1};
209
- color: ${({
210
- theme
211
- }) => theme.text.color};
203
+ background-color: var(--colorsUtilityYang100);
204
+ box-shadow: var(--boxShadow100);
212
205
  display: block;
213
- font-size: 14px;
214
- font-weight: 800;
215
206
  overflow: hidden;
216
- padding: 24px;
207
+ padding: var(--spacing300);
217
208
  text-align: center;
218
209
  user-select: none;
219
210
  }
@@ -234,9 +225,7 @@ const StyledDayPicker = _styledComponents.default.div`
234
225
  .DayPicker-wrapper {
235
226
  padding: 0;
236
227
  &:focus {
237
- outline: ${({
238
- theme
239
- }) => `3px solid ${theme.colors.focus}`};
228
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
240
229
  }
241
230
  }
242
231
 
@@ -250,8 +239,10 @@ const StyledDayPicker = _styledComponents.default.div`
250
239
  }
251
240
 
252
241
  .DayPicker-Caption {
253
- line-height: 40px;
254
- height: 40px;
242
+ color: var(--colorsActionMajorYin090);
243
+ line-height: var(--sizing500);
244
+ height: var(--sizing500);
245
+ //font: var(--typographyDatePickerCalendarMonthM); to be implemented
255
246
  font-size: 16px;
256
247
  font-weight: 800;
257
248
 
@@ -262,28 +253,25 @@ const StyledDayPicker = _styledComponents.default.div`
262
253
  }
263
254
 
264
255
  .DayPicker-Day {
265
- min-width: 40px;
266
- background-color: ${({
267
- theme
268
- }) => theme.colors.white};
256
+ min-width: var(--sizing500);
257
+ height: 36px; //var(--sizing450); to be implemented
258
+ padding: 0;
259
+ background-color: var(--colorsUtilityYang100);
269
260
  cursor: pointer;
270
261
  border: none;
271
- font-weight: 800;
272
- padding: 10px 0;
262
+ //font-family: var(--fontFamiliesDefault); token value to be updated
263
+ //font: var(--typographyDatePickerCalendarDateM); to be implemented
264
+ font-weight: var(--fontWeights700);
265
+ font-size: var(--fontSizes100);
266
+ line-height: var(--lineHeights500);
273
267
 
274
268
  &:hover {
275
- background-color: ${({
276
- theme
277
- }) => theme.disabled.input};
278
- color: ${({
279
- theme
280
- }) => theme.text.color};
269
+ background-color: var(--colorsActionMinor050);
270
+ color: var(--colorsActionMajorYin090);
281
271
  }
282
272
 
283
273
  &:focus {
284
- outline: ${({
285
- theme
286
- }) => `3px solid ${theme.colors.focus}`};
274
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
287
275
  }
288
276
 
289
277
  + * {
@@ -297,52 +285,30 @@ const StyledDayPicker = _styledComponents.default.div`
297
285
 
298
286
  .DayPicker-Day--today,
299
287
  .DayPicker-Day--today.DayPicker-Day--outside {
300
- font-weight: 800;
301
- color: ${({
302
- theme
303
- }) => theme.text.color};
304
- background-color: ${({
305
- theme
306
- }) => theme.disabled.border};
288
+ color: var(--colorsActionMajorYin090);
289
+ background-color: var(--colorsActionMinor200);
307
290
  }
308
291
 
309
292
  .DayPicker-Day--outside {
310
- color: ${({
311
- theme
312
- }) => theme.disabled.disabled};
313
- background-color: ${({
314
- theme
315
- }) => theme.colors.white};
293
+ color: var(--colorsActionMajorYin055);
294
+ background-color: var(--colorsUtilityYang100);
316
295
  }
317
296
 
318
297
  .DayPicker-Day--disabled,
319
298
  .DayPicker-Day--disabled:hover {
320
- color: ${({
321
- theme
322
- }) => theme.disabled.disabled};
323
- background-color: ${({
324
- theme
325
- }) => theme.colors.white};
299
+ color: var(colorsActionMajorYin030);
300
+ background-color: var(--colorsUtilityYang100);
326
301
  cursor: default;
327
302
  }
328
303
 
329
304
  .DayPicker-Day--selected:not(.DayPicker-Day--disabled):not(.DayPicker-Day--outside) {
330
- background-color: ${({
331
- theme
332
- }) => theme.colors.primary};
333
- color: ${({
334
- theme
335
- }) => theme.colors.white};
336
- font-weight: 800;
305
+ background-color: var(--colorsActionMajor500);
306
+ color: var(--colorsUtilityYang100);
337
307
  }
338
308
 
339
309
  .DayPicker-Day--selected.DayPicker-Day--disabled:not(.DayPicker-Day--outside) {
340
- background-color: ${({
341
- theme
342
- }) => theme.colors.primary};
343
- color: ${({
344
- theme
345
- }) => theme.colors.white};
310
+ background-color: var(--colorsActionMajor500);
311
+ color: var(--colorsUtilityYang100);
346
312
  }
347
313
  `;
348
314
  StyledDayPicker.defaultProps = {
@@ -7,30 +7,25 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _base = _interopRequireDefault(require("../../../../style/themes/base"));
11
-
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
14
12
  const StyledButton = _styledComponents.default.button.attrs({
15
13
  type: "button"
16
14
  })`
15
+ justify-content: center;
17
16
  align-items: center;
18
- display: block;
19
- border: none;
17
+ display: flex;
18
+ border: var(--borderWidth200) solid var(--colorsActionMinorTransparent);
20
19
  background: none;
21
20
  box-shadow: none;
22
21
  cursor: pointer;
23
- height: 40px;
24
- width: 40px;
25
- padding: 0;
22
+ height: var(--sizing500);
23
+ width: var(--sizing500);
24
+ padding: var(--spacing150);
25
+ box-sizing: border-box;
26
26
  &:focus {
27
- outline: ${({
28
- theme
29
- }) => `3px solid ${theme.colors.focus}`};
27
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
30
28
  }
31
29
  `;
32
- StyledButton.defaultProps = {
33
- theme: _base.default
34
- };
35
30
  var _default = StyledButton;
36
31
  exports.default = _default;
@@ -7,8 +7,6 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _base = _interopRequireDefault(require("../../../../style/themes/base"));
11
-
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
14
12
  const StyledNavbar = _styledComponents.default.div`
@@ -17,11 +15,8 @@ const StyledNavbar = _styledComponents.default.div`
17
15
  justify-content: space-between;
18
16
  padding: 0;
19
17
  top: 0;
20
- height: 40px;
18
+ height: var(--sizing500);
21
19
  }
22
20
  `;
23
- StyledNavbar.defaultProps = {
24
- theme: _base.default
25
- };
26
21
  var _default = StyledNavbar;
27
22
  exports.default = _default;
@@ -39,7 +39,12 @@ function isDateValid(date) {
39
39
  return date && date.toString() !== "Invalid Date";
40
40
  }
41
41
 
42
- function hasMatchedFormat(formatString, valueString) {
42
+ function hasMatchedFormat(formatString, valueString, fullFormat, fullValue) {
43
+ if (formatString.includes("d")) {
44
+ return formatString.length === valueString.length && (0, _fp.isMatch)(fullFormat.join("."), fullValue.join(".")) // need to check day value with month value
45
+ ;
46
+ }
47
+
43
48
  return formatString.length === valueString.length && (0, _fp.isMatch)(formatString, valueString);
44
49
  }
45
50
 
@@ -66,7 +71,7 @@ function makeSeparatedValues(arr, str) {
66
71
  }
67
72
 
68
73
  function checkForCompleteMatch(formatArray, valueArray) {
69
- return formatArray.every((formatString, i) => hasMatchedFormat(formatString, valueArray[i]));
74
+ return formatArray.every((formatString, i) => hasMatchedFormat(formatString, valueArray[i], formatArray, valueArray));
70
75
  }
71
76
 
72
77
  function findMatchWithNoSeparators(valueString, formatString) {
@@ -7,27 +7,23 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _base = _interopRequireDefault(require("../../../../style/themes/base"));
11
-
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
14
12
  const StyledWeekday = _styledComponents.default.div`
15
13
  &,
16
14
  &.DayPicker-Weekday {
17
15
  border: none;
18
- min-width: 40px;
16
+ height: var(--sizing500);
17
+ min-width: var(--sizing500);
19
18
  font-weight: 800;
20
- color: ${({
21
- theme
22
- }) => theme.colors.border};
19
+ color: var(--colorsActionMinor400);
23
20
  text-transform: uppercase;
24
21
  font-size: 12px;
22
+ //font: var(--typographyDatePickerCalendarDayM) to be implemented
25
23
  text-align: center;
26
24
  padding: 20px 0 5px;
25
+ box-sizing: border-box;
27
26
  }
28
27
  `;
29
- StyledWeekday.defaultProps = {
30
- theme: _base.default
31
- };
32
28
  var _default = StyledWeekday;
33
29
  exports.default = _default;
@@ -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]); // Return previous value before state is changed. Used to compare prevState and newState.
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 isComponentControlled = value !== undefined;
194
- const prevControlledState = usePrevious(isComponentControlled);
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)(prevControlledState !== isComponentControlled, message);
198
- }, [isComponentControlled]);
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 (isComponentControlled) {
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);
@@ -38,7 +38,7 @@ const StyledLink = _styledComponents.default.span`
38
38
  left: -999em;
39
39
  z-index: ${theme.zIndex.aboveAll};
40
40
  box-shadow: inset 0 0 0 2px var(--colorsActionMajor500);
41
- border: 2px solid var(--colorsYang100);
41
+ border: 2px solid var(--colorsUtilityYang100);
42
42
  }
43
43
 
44
44
  a:focus {
@@ -51,7 +51,7 @@ const StyledLink = _styledComponents.default.span`
51
51
  button {
52
52
  font-size: ${isSkipLink ? "16px" : "14px"};
53
53
  text-decoration: underline;
54
- color: ${isSkipLink ? "var(--colorsYin090)" : "var(--colorsActionMajor500)"};
54
+ color: ${isSkipLink ? "var(--colorsUtilityYin090)" : "var(--colorsActionMajor500)"};
55
55
  display: inline-block;
56
56
  ${_icon.default} {
57
57
  display: inline-block;
@@ -68,21 +68,21 @@ const StyledLink = _styledComponents.default.span`
68
68
 
69
69
  &:hover {
70
70
  cursor: pointer;
71
- color: ${isSkipLink ? "var(--colorsYin090)" : "var(--colorsActionMajor600)"};
71
+ color: ${isSkipLink ? "var(--colorsUtilityYin090)" : "var(--colorsActionMajor600)"};
72
72
  }
73
73
 
74
74
  &:focus {
75
- color: var(--colorsYin090);
76
- background-color: ${isSkipLink ? "var(--colorsYang100)" : "var(--colorsSemanticFocus250)"};
75
+ color: var(--colorsActionMajorYin090);
76
+ background-color: ${isSkipLink ? "var(--colorsUtilityYang100)" : "var(--colorsSemanticFocus250)"};
77
77
  outline: none;
78
78
  }
79
79
 
80
80
  ${disabled && (0, _styledComponents.css)`
81
- color: var(--colorsYin065);
81
+ color: var(--colorsActionMajorYin030);
82
82
  &:hover,
83
83
  &:focus {
84
84
  cursor: not-allowed;
85
- color: var(--colorsYin065);
85
+ color: var(--colorsActionMajorYin030);
86
86
  }
87
87
  `}
88
88
  }
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.18.1",
3
+ "version": "104.20.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {