carbon-react 101.3.3 → 101.4.3
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/__internal__/date/date.js +5 -9
- package/lib/__internal__/label/label.component.js +4 -8
- package/lib/__internal__/validations/validation-icon.component.js +2 -1
- package/lib/__internal__/validations/validation-icon.style.js +12 -2
- package/lib/components/date/date.component.js +19 -27
- package/lib/components/help/help.component.js +1 -1
- package/lib/components/help/help.d.ts +1 -1
- package/lib/components/link/link.component.js +5 -1
- package/lib/components/tile-select/tile-select.component.js +3 -1
- package/lib/locales/en-gb.js +3 -0
- package/lib/locales/pl-pl.js +3 -0
- package/package.json +12 -12
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _moment = _interopRequireDefault(require("moment"));
|
|
9
9
|
|
|
10
|
+
require("moment/min/locales");
|
|
11
|
+
|
|
10
12
|
var _lodash = require("lodash");
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -161,14 +163,12 @@ const DateHelper = {
|
|
|
161
163
|
* formats - given accepted formats
|
|
162
164
|
* locale - current locale
|
|
163
165
|
* strict - moment js strict mode
|
|
164
|
-
* sanitize - should value be sanitized before parsing
|
|
165
166
|
*/
|
|
166
167
|
_defaultMomentOptions: (locale, formats) => {
|
|
167
168
|
return {
|
|
168
169
|
locale,
|
|
169
170
|
formats,
|
|
170
|
-
strict: true
|
|
171
|
-
sanitize: true
|
|
171
|
+
strict: true
|
|
172
172
|
};
|
|
173
173
|
},
|
|
174
174
|
|
|
@@ -185,7 +185,7 @@ const DateHelper = {
|
|
|
185
185
|
value,
|
|
186
186
|
options,
|
|
187
187
|
locale,
|
|
188
|
-
formats,
|
|
188
|
+
formats = [],
|
|
189
189
|
format
|
|
190
190
|
}) {
|
|
191
191
|
const opts = (0, _lodash.merge)(DateHelper._defaultMomentOptions(locale, formats), options, {
|
|
@@ -193,8 +193,7 @@ const DateHelper = {
|
|
|
193
193
|
formats,
|
|
194
194
|
format
|
|
195
195
|
});
|
|
196
|
-
|
|
197
|
-
return (0, _moment.default)(val, [format, ...opts.formats], opts.locale, opts.strict);
|
|
196
|
+
return (0, _moment.default)(value, [format, isoDateFormat, ...opts.formats], opts.locale, opts.strict);
|
|
198
197
|
},
|
|
199
198
|
|
|
200
199
|
formatDateToCurrentLocale({
|
|
@@ -206,9 +205,6 @@ const DateHelper = {
|
|
|
206
205
|
return DateHelper.formatValue({
|
|
207
206
|
value,
|
|
208
207
|
formatTo: format,
|
|
209
|
-
options: {
|
|
210
|
-
formats: [format]
|
|
211
|
-
},
|
|
212
208
|
locale,
|
|
213
209
|
formats,
|
|
214
210
|
format
|
|
@@ -65,8 +65,9 @@ const Label = ({
|
|
|
65
65
|
pl,
|
|
66
66
|
isRequired
|
|
67
67
|
}) => {
|
|
68
|
-
const [isFocused, setFocus] = (0, _react.useState)(false);
|
|
69
68
|
const {
|
|
69
|
+
hasFocus,
|
|
70
|
+
hasMouseOver,
|
|
70
71
|
onMouseEnter,
|
|
71
72
|
onMouseLeave
|
|
72
73
|
} = (0, _react.useContext)(_inputBehaviour.InputContext);
|
|
@@ -86,11 +87,6 @@ const Label = ({
|
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
const icon = () => {
|
|
89
|
-
const wrapperProps = {
|
|
90
|
-
onFocus: () => setFocus(true),
|
|
91
|
-
onBlur: () => setFocus(false)
|
|
92
|
-
};
|
|
93
|
-
|
|
94
90
|
if (useValidationIcon && shouldDisplayValidationIcon({
|
|
95
91
|
error,
|
|
96
92
|
warning,
|
|
@@ -113,11 +109,11 @@ const Label = ({
|
|
|
113
109
|
}));
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
return help && /*#__PURE__*/_react.default.createElement(_iconWrapper.default,
|
|
112
|
+
return help && /*#__PURE__*/_react.default.createElement(_iconWrapper.default, null, /*#__PURE__*/_react.default.createElement(_help.default, {
|
|
117
113
|
tooltipId: tooltipId,
|
|
118
114
|
tabIndex: helpTabIndex,
|
|
119
115
|
type: helpIcon,
|
|
120
|
-
isFocused:
|
|
116
|
+
isFocused: hasFocus || hasMouseOver
|
|
121
117
|
}, help));
|
|
122
118
|
};
|
|
123
119
|
|
|
@@ -91,7 +91,8 @@ const ValidationIcon = ({
|
|
|
91
91
|
onBlur: e => {
|
|
92
92
|
setTriggeredByIcon(false);
|
|
93
93
|
if (onBlur) onBlur(e);
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
isPartOfInput: isPartOfInput
|
|
95
96
|
}, (0, _utils.filterStyledSystemMarginProps)(rest)), /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
96
97
|
key: `${validationType}-icon`,
|
|
97
98
|
type: validationType,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _styledComponents =
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
10
|
var _styledSystem = require("styled-system");
|
|
11
11
|
|
|
@@ -15,9 +15,13 @@ var _icon = _interopRequireDefault(require("../../components/icon/icon.style"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
18
22
|
const ValidationIconStyle = _styledComponents.default.span`
|
|
19
23
|
background: none;
|
|
20
|
-
cursor:
|
|
24
|
+
cursor: default;
|
|
21
25
|
display: flex;
|
|
22
26
|
align-items: center;
|
|
23
27
|
margin-top: 0;
|
|
@@ -25,6 +29,12 @@ const ValidationIconStyle = _styledComponents.default.span`
|
|
|
25
29
|
border: 0;
|
|
26
30
|
outline: none;
|
|
27
31
|
|
|
32
|
+
${({
|
|
33
|
+
isPartOfInput
|
|
34
|
+
}) => isPartOfInput && (0, _styledComponents.css)`
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
`}
|
|
37
|
+
|
|
28
38
|
${_icon.default}:before {
|
|
29
39
|
color: ${({
|
|
30
40
|
validationType,
|
|
@@ -167,13 +167,11 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
167
167
|
_this.reformatVisibleDate();
|
|
168
168
|
|
|
169
169
|
if (_this.props.onBlur && !_this.state.isDatePickerOpen) {
|
|
170
|
-
const dateWithSlashes = _date.default.sanitizeDateInput(_this.state.visibleValue);
|
|
171
|
-
|
|
172
170
|
const event = _this.buildCustomEvent({
|
|
173
171
|
target: _this.input,
|
|
174
172
|
type: "blur"
|
|
175
173
|
}, _date.default.formatValue({
|
|
176
|
-
value:
|
|
174
|
+
value: _this.state.visibleValue,
|
|
177
175
|
..._this.localeData
|
|
178
176
|
}));
|
|
179
177
|
|
|
@@ -365,10 +363,8 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
365
363
|
} = _this.props;
|
|
366
364
|
const value = ev.target.value.formattedValue || ev.target.value;
|
|
367
365
|
|
|
368
|
-
const dateWithSlashes = _date.default.sanitizeDateInput(value);
|
|
369
|
-
|
|
370
366
|
const isValidDate = _date.default.isValidDate({
|
|
371
|
-
value
|
|
367
|
+
value,
|
|
372
368
|
..._this.localeData
|
|
373
369
|
});
|
|
374
370
|
|
|
@@ -378,7 +374,7 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
378
374
|
|
|
379
375
|
if (isValidDate || _this.canBeEmptyValues(value)) {
|
|
380
376
|
isoDateString = _date.default.formatValue({
|
|
381
|
-
value
|
|
377
|
+
value,
|
|
382
378
|
..._this.localeData
|
|
383
379
|
});
|
|
384
380
|
|
|
@@ -440,9 +436,6 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
440
436
|
});
|
|
441
437
|
|
|
442
438
|
_defineProperty(_assertThisInitialized(_this), "buildCustomEvent", (ev, isoFormattedValue) => {
|
|
443
|
-
const {
|
|
444
|
-
type
|
|
445
|
-
} = ev;
|
|
446
439
|
const {
|
|
447
440
|
id,
|
|
448
441
|
name,
|
|
@@ -477,7 +470,7 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
477
470
|
...(validRawValue && {
|
|
478
471
|
rawValue: isoFormattedValue
|
|
479
472
|
}),
|
|
480
|
-
...(
|
|
473
|
+
...(!validRawValue && {
|
|
481
474
|
formattedValue: value,
|
|
482
475
|
rawValue: value
|
|
483
476
|
})
|
|
@@ -488,15 +481,19 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
488
481
|
|
|
489
482
|
_defineProperty(_assertThisInitialized(_this), "renderDatePicker", dateRangeProps => {
|
|
490
483
|
if (!_this.state.isDatePickerOpen) return null;
|
|
491
|
-
|
|
484
|
+
const {
|
|
492
485
|
visibleValue
|
|
493
486
|
} = _this.state;
|
|
487
|
+
let isoValue = "";
|
|
494
488
|
|
|
495
|
-
if (
|
|
489
|
+
if (_date.default.isValidDate({
|
|
496
490
|
value: visibleValue,
|
|
497
491
|
..._this.localeData
|
|
498
492
|
})) {
|
|
499
|
-
|
|
493
|
+
isoValue = _date.default.formatValue({
|
|
494
|
+
value: visibleValue,
|
|
495
|
+
..._this.localeData
|
|
496
|
+
});
|
|
500
497
|
}
|
|
501
498
|
|
|
502
499
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -506,7 +503,7 @@ let BaseDateInput = /*#__PURE__*/function (_React$Component) {
|
|
|
506
503
|
inputElement: _this.inputPresentationRef,
|
|
507
504
|
selectedDate: _this.state.selectedDate,
|
|
508
505
|
handleDateSelect: _this.handleDateSelect,
|
|
509
|
-
inputDate:
|
|
506
|
+
inputDate: isoValue,
|
|
510
507
|
disablePortal: _this.props.disablePortal
|
|
511
508
|
}, dateRangeProps)));
|
|
512
509
|
});
|
|
@@ -642,7 +639,7 @@ function generateAdjustedValue({
|
|
|
642
639
|
formats,
|
|
643
640
|
format
|
|
644
641
|
}) {
|
|
645
|
-
if (value !== undefined && canReturnValue(value, allowEmptyValue
|
|
642
|
+
if (value !== undefined && canReturnValue(value, allowEmptyValue)) {
|
|
646
643
|
return _date.default.formatDateToCurrentLocale({
|
|
647
644
|
value,
|
|
648
645
|
locale,
|
|
@@ -651,7 +648,7 @@ function generateAdjustedValue({
|
|
|
651
648
|
});
|
|
652
649
|
}
|
|
653
650
|
|
|
654
|
-
if (canReturnValue(defaultValue, allowEmptyValue
|
|
651
|
+
if (canReturnValue(defaultValue, allowEmptyValue)) {
|
|
655
652
|
return _date.default.formatDateToCurrentLocale({
|
|
656
653
|
value: defaultValue,
|
|
657
654
|
locale,
|
|
@@ -668,25 +665,20 @@ function generateAdjustedValue({
|
|
|
668
665
|
});
|
|
669
666
|
}
|
|
670
667
|
|
|
671
|
-
function isValidInitialFormat(value
|
|
668
|
+
function isValidInitialFormat(value) {
|
|
672
669
|
return _date.default.isValidDate({
|
|
673
670
|
value,
|
|
674
|
-
|
|
675
|
-
defaultValue: hiddenDateFormat
|
|
676
|
-
},
|
|
677
|
-
locale,
|
|
678
|
-
formats,
|
|
679
|
-
format
|
|
671
|
+
format: hiddenDateFormat
|
|
680
672
|
});
|
|
681
673
|
}
|
|
682
674
|
|
|
683
|
-
function canReturnValue(value, allowEmptyValue
|
|
675
|
+
function canReturnValue(value, allowEmptyValue) {
|
|
684
676
|
if (!allowEmptyValue && value && value.length) {
|
|
685
677
|
const message = "The Date component must be initialised with a value in the iso (YYYY-MM-DD) format";
|
|
686
|
-
(0, _invariant.default)(isValidInitialFormat(value
|
|
678
|
+
(0, _invariant.default)(isValidInitialFormat(value), message);
|
|
687
679
|
}
|
|
688
680
|
|
|
689
|
-
return isValidInitialFormat(value
|
|
681
|
+
return isValidInitialFormat(value) || allowEmptyValue && !value;
|
|
690
682
|
}
|
|
691
683
|
|
|
692
684
|
const DateInput = (0, _withUniqueIdProps.default)(BaseDateInput);
|
|
@@ -139,7 +139,7 @@ Help.propTypes = { ...marginPropTypes,
|
|
|
139
139
|
/** A path for the anchor */
|
|
140
140
|
href: _propTypes.default.string,
|
|
141
141
|
|
|
142
|
-
/**
|
|
142
|
+
/** Overrides the visibility of the Tooltip if true */
|
|
143
143
|
isFocused: _propTypes.default.bool,
|
|
144
144
|
|
|
145
145
|
/** <a href="https://brand.sage.com/d/NdbrveWvNheA/foundations#/icons/icons" target="_blank">List of supported icons</a>
|
|
@@ -13,7 +13,7 @@ export interface HelpProps extends MarginProps {
|
|
|
13
13
|
helpId?: string;
|
|
14
14
|
/** A path for the anchor */
|
|
15
15
|
href?: string;
|
|
16
|
-
/**
|
|
16
|
+
/** Overrides the visibility of the Tooltip if true */
|
|
17
17
|
isFocused?: boolean;
|
|
18
18
|
/** Overrides the default tabindex of the component */
|
|
19
19
|
tabIndex?: number | string;
|
|
@@ -21,6 +21,8 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
|
|
|
21
21
|
|
|
22
22
|
var _themes = require("../../style/themes");
|
|
23
23
|
|
|
24
|
+
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
25
|
+
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
27
|
|
|
26
28
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -48,6 +50,8 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
48
50
|
target,
|
|
49
51
|
...rest
|
|
50
52
|
}, ref) => {
|
|
53
|
+
const l = (0, _useLocale.default)();
|
|
54
|
+
|
|
51
55
|
const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
|
|
52
56
|
|
|
53
57
|
const tabIndex = tabbable && !disabled ? "0" : "-1";
|
|
@@ -110,7 +114,7 @@ const Link = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
110
114
|
...(type === "button" && {
|
|
111
115
|
role: "link"
|
|
112
116
|
})
|
|
113
|
-
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLinkIcon(), /*#__PURE__*/_react.default.createElement(_link.StyledContent, null, isSkipLink ?
|
|
117
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderLinkIcon(), /*#__PURE__*/_react.default.createElement(_link.StyledContent, null, isSkipLink ? l.link.skipLinkLabel() : children), renderLinkIcon("right")));
|
|
114
118
|
};
|
|
115
119
|
|
|
116
120
|
return /*#__PURE__*/_react.default.createElement(_link.StyledLink, _extends({
|
|
@@ -140,7 +140,9 @@ const TileSelect = ({
|
|
|
140
140
|
}, titleAdornment)), additionalInformation && /*#__PURE__*/_react.default.createElement("div", null, additionalInformation), /*#__PURE__*/_react.default.createElement(_tileSelect.StyledDescription, checkPropTypeIsNode(description), description), footer && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledFooterWrapper, null, footer), accordionContent && accordionControl && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledAccordionFooterWrapper, {
|
|
141
141
|
accordionExpanded: accordionExpanded
|
|
142
142
|
}, accordionControl(controlId, contentId))), prefixAdornment && /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
143
|
-
|
|
143
|
+
"data-element": "prefix-adornment",
|
|
144
|
+
mr: 3,
|
|
145
|
+
opacity: disabled ? "0.3" : undefined
|
|
144
146
|
}, prefixAdornment))), accordionContent && /*#__PURE__*/_react.default.createElement(_accordion.default, {
|
|
145
147
|
contentId: contentId,
|
|
146
148
|
controlId: controlId,
|
package/lib/locales/en-gb.js
CHANGED
package/lib/locales/pl-pl.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "101.
|
|
3
|
+
"version": "101.4.3",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"@semantic-release/changelog": "^6.0.1",
|
|
63
63
|
"@semantic-release/exec": "^6.0.2",
|
|
64
64
|
"@semantic-release/git": "^10.0.1",
|
|
65
|
-
"@storybook/addon-a11y": "^6.3.
|
|
66
|
-
"@storybook/addon-actions": "^6.3.
|
|
67
|
-
"@storybook/addon-controls": "^6.3.
|
|
68
|
-
"@storybook/addon-docs": "^6.3.
|
|
65
|
+
"@storybook/addon-a11y": "^6.3.12",
|
|
66
|
+
"@storybook/addon-actions": "^6.3.12",
|
|
67
|
+
"@storybook/addon-controls": "^6.3.12",
|
|
68
|
+
"@storybook/addon-docs": "^6.3.12",
|
|
69
69
|
"@storybook/addon-google-analytics": "^6.2.9",
|
|
70
|
-
"@storybook/addon-links": "^6.3.
|
|
71
|
-
"@storybook/addon-toolbars": "^6.3.
|
|
72
|
-
"@storybook/addon-viewport": "^6.3.
|
|
73
|
-
"@storybook/addons": "^6.3.
|
|
74
|
-
"@storybook/components": "^6.3.
|
|
75
|
-
"@storybook/react": "^6.3.
|
|
76
|
-
"@storybook/theming": "^6.3.
|
|
70
|
+
"@storybook/addon-links": "^6.3.12",
|
|
71
|
+
"@storybook/addon-toolbars": "^6.3.12",
|
|
72
|
+
"@storybook/addon-viewport": "^6.3.12",
|
|
73
|
+
"@storybook/addons": "^6.3.12",
|
|
74
|
+
"@storybook/components": "^6.3.12",
|
|
75
|
+
"@storybook/react": "^6.3.12",
|
|
76
|
+
"@storybook/theming": "^6.3.12",
|
|
77
77
|
"@types/enzyme": "^3.10.3",
|
|
78
78
|
"@types/enzyme-adapter-react-16": "^1.0.5",
|
|
79
79
|
"@types/jest": "^26.0.19",
|