@telus-uds/components-web 2.32.1 → 2.33.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/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Tue, 19 Mar 2024 18:37:02 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 05 Apr 2024 17:10:34 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.33.0
8
+
9
+ Fri, 05 Apr 2024 17:10:34 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Bump @telus-uds/components-base to v1.82.0
14
+ - Bump @telus-uds/system-theme-tokens to v2.54.0
15
+
16
+ ### Patches
17
+
18
+ - `Breadcrumbs`: fix text wrapping error (guillermo.peitzner@telus.com)
19
+
20
+ ## 2.32.2
21
+
22
+ Wed, 27 Mar 2024 21:13:10 GMT
23
+
24
+ ### Patches
25
+
26
+ - validation added to the datepicker input and input cleaned after the content is deleted (35577399+JoshHC@users.noreply.github.com)
27
+ - Bump @telus-uds/components-base to v1.81.0
28
+
7
29
  ## 2.32.1
8
30
 
9
- Tue, 19 Mar 2024 18:37:02 GMT
31
+ Tue, 19 Mar 2024 18:39:50 GMT
10
32
 
11
33
  ### Patches
12
34
 
@@ -11,7 +11,7 @@ var _componentsBase = require("@telus-uds/components-base");
11
11
  var _utils = require("../utils");
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- const [, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
14
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
15
15
  const BadgeContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
16
16
  displayName: "Badge__BadgeContainer",
17
17
  componentId: "components-web__sc-tsiuo2-0"
@@ -48,6 +48,11 @@ const BadgeContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
48
48
  ${gradient && '-webkit-text-fill-color: transparent;'}
49
49
  }`;
50
50
  });
51
+ const fontSizeMapping = {
52
+ 12: 'micro',
53
+ 14: 'small',
54
+ 16: 'h6'
55
+ };
51
56
  const Badge = _ref6 => {
52
57
  let {
53
58
  children,
@@ -61,10 +66,14 @@ const Badge = _ref6 => {
61
66
  borderColor,
62
67
  borderRadius,
63
68
  borderWidth,
69
+ color,
64
70
  paddingLeft,
65
71
  paddingRight,
66
72
  paddingTop,
67
- paddingBottom
73
+ paddingBottom,
74
+ fontName,
75
+ fontWeight,
76
+ fontSize
68
77
  } = (0, _componentsBase.useThemeTokens)('Badge', tokens, variant);
69
78
  const semanticGradient = gradient && (0, _utils.transformGradient)(gradient);
70
79
  const {
@@ -85,12 +94,20 @@ const Badge = _ref6 => {
85
94
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
86
95
  radius: `${borderRadius}px`,
87
96
  background: background,
97
+ fontName: fontName,
98
+ fontWeight: fontWeight,
88
99
  gradient: semanticGradient,
89
100
  border: `${borderWidth}px solid ${borderColor}`,
90
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Badge, {
91
- tokens: tokens,
92
- variant: variant,
93
- ...rest,
101
+ ...selectProps(rest),
102
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
103
+ tokens: {
104
+ fontName,
105
+ fontWeight,
106
+ color
107
+ },
108
+ variant: {
109
+ size: fontSizeMapping[fontSize]
110
+ },
94
111
  children: children
95
112
  })
96
113
  });
@@ -27,15 +27,9 @@ const StyledList = /*#__PURE__*/_styledComponents.default.ol.withConfig({
27
27
  listStylePosition: 'inside',
28
28
  margin: 0,
29
29
  padding: 0,
30
- alignItems: 'baseline',
31
- height: _ref => {
32
- let {
33
- iconContainerSize
34
- } = _ref;
35
- return `${iconContainerSize}px`;
36
- }
30
+ alignItems: 'baseline'
37
31
  });
38
- const omitProps = _ref2 => {
32
+ const omitProps = _ref => {
39
33
  let {
40
34
  current,
41
35
  path,
@@ -44,7 +38,7 @@ const omitProps = _ref2 => {
44
38
  childRoutes,
45
39
  component,
46
40
  ...props
47
- } = _ref2;
41
+ } = _ref;
48
42
  return props;
49
43
  };
50
44
  const getBreadcrumbName = (item, params) => {
@@ -107,7 +101,7 @@ const getStructuredData = (items, baseUrl) => {
107
101
  /**
108
102
  * Display a hierarchy of links, commonly used for navigation.
109
103
  */
110
- const Breadcrumbs = _ref3 => {
104
+ const Breadcrumbs = _ref2 => {
111
105
  let {
112
106
  baseUrl,
113
107
  children,
@@ -118,7 +112,7 @@ const Breadcrumbs = _ref3 => {
118
112
  variant,
119
113
  LinkRouter,
120
114
  ...rest
121
- } = _ref3;
115
+ } = _ref2;
122
116
  // React Helmet can cause a memory leak in SSR if not properly configured.
123
117
  // Only run it in SSR if theme options tells us to.
124
118
  /* const {
@@ -128,7 +122,7 @@ const Breadcrumbs = _ref3 => {
128
122
  // const isSSR = typeof window === 'undefined' || isHydrating
129
123
  // const hasMetadata = isSSR ? enableHelmetSSR : true
130
124
  const helmetContext = {};
131
- const activeRoutes = children ? _react.default.Children.map((0, _componentsBase.unpackFragment)(children), _ref4 => {
125
+ const activeRoutes = children ? _react.default.Children.map((0, _componentsBase.unpackFragment)(children), _ref3 => {
132
126
  let {
133
127
  props: {
134
128
  href,
@@ -136,7 +130,7 @@ const Breadcrumbs = _ref3 => {
136
130
  ...itemRest
137
131
  },
138
132
  ref
139
- } = _ref4;
133
+ } = _ref3;
140
134
  return {
141
135
  path: href,
142
136
  breadcrumbName,
@@ -166,7 +160,7 @@ const Breadcrumbs = _ref3 => {
166
160
  ...selectProps(rest),
167
161
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(StyledList, {
168
162
  iconContainerSize: themeTokens.iconContainerSize,
169
- children: items.map(_ref5 => {
163
+ children: items.map(_ref4 => {
170
164
  let {
171
165
  href,
172
166
  current,
@@ -174,7 +168,7 @@ const Breadcrumbs = _ref3 => {
174
168
  LinkRouter: ItemLinkRouter = LinkRouter,
175
169
  linkRouterProps: itemLinkRouterProps,
176
170
  ...itemRest
177
- } = _ref5;
171
+ } = _ref4;
178
172
  return /*#__PURE__*/(0, _react.createElement)(_Item.default, {
179
173
  ...itemRest,
180
174
  current: current,
@@ -37,7 +37,8 @@ const StyledItemContainer = /*#__PURE__*/_styledComponents.default.li.withConfig
37
37
  iconContainerSize
38
38
  } = _ref3;
39
39
  return `${iconContainerSize}px`;
40
- }
40
+ },
41
+ marginBottom: '8px'
41
42
  });
42
43
  const IconContainer = /*#__PURE__*/_styledComponents.default.span.withConfig({
43
44
  displayName: "Item__IconContainer",
@@ -72,6 +72,7 @@ const PortalPositionedContainer = /*#__PURE__*/_styledComponents.default.div.wit
72
72
  return `${top}px`;
73
73
  }
74
74
  });
75
+ const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/;
75
76
 
76
77
  /**
77
78
  * Use DatePicker to select a date on a calendar.
@@ -193,14 +194,34 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
193
194
  if (onDateChange) onDateChange(value);
194
195
  };
195
196
  const onChangeInput = value => {
196
- if ((0, _moment.default)(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
197
- setInputDate((0, _moment.default)(value, dateFormat));
198
- if (onDateChange) onDateChange((0, _moment.default)(value, dateFormat));
199
- setInputText((0, _moment.default)(value, dateFormatWithoutSpaces).format(dateFormat));
197
+ if (value === '' || (0, _moment.default)(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
198
+ if (value === '') {
199
+ setInputDate(undefined); // Set inputDate to undefined if input is empty
200
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(undefined);
201
+ } else {
202
+ setInputDate((0, _moment.default)(value, dateFormat));
203
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange((0, _moment.default)(value, dateFormat));
204
+ }
205
+ setInputText(value === '' ? '' : (0, _moment.default)(value, dateFormatWithoutSpaces).format(dateFormat));
200
206
  } else {
201
207
  setInputText(value);
202
208
  }
203
209
  };
210
+ const handleOnKeyPress = event => {
211
+ if (event.key === 'Backspace' && inputText === '') {
212
+ setInputDate(undefined);
213
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(undefined);
214
+ }
215
+ };
216
+ const handleValidation = inputValidation => {
217
+ if (validDatePattern.test(inputText.replace(/\s+/g, '')) === false && inputText !== '') {
218
+ return 'error';
219
+ }
220
+ if (inputValidation === 'error' || inputValidation === 'success') {
221
+ return inputValidation;
222
+ }
223
+ return inputValidation;
224
+ };
204
225
  const viewport = (0, _componentsBase.useViewport)();
205
226
  const daySize = getResponsiveDaySize(inline, viewport);
206
227
  const circleSize = getResponsiveCircleSize(inline, viewport);
@@ -321,11 +342,12 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
321
342
  hint: hint,
322
343
  placeholder: "DD / MM / YYYY",
323
344
  onChange: onChangeInput,
345
+ onKeyPress: handleOnKeyPress,
324
346
  tooltip: tooltip,
325
347
  hintPosition: hintPosition,
326
348
  label: label ?? ((_dictionary$copy = _dictionary.default[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription),
327
349
  value: inputText,
328
- validation: validation,
350
+ validation: handleValidation(validation),
329
351
  inactive: disabled,
330
352
  ref: textInputRef,
331
353
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Portal, {
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import PropTypes from 'prop-types';
4
- import { selectSystemProps, getTokensPropType, useThemeTokens, Badge as BaseBadge } from '@telus-uds/components-base';
4
+ import { selectSystemProps, Typography, getTokensPropType, useThemeTokens } from '@telus-uds/components-base';
5
5
  import { htmlAttrs, transformGradient } from '../utils';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- const [, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
7
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
8
8
  const BadgeContainer = /*#__PURE__*/styled.div.withConfig({
9
9
  displayName: "Badge__BadgeContainer",
10
10
  componentId: "components-web__sc-tsiuo2-0"
@@ -41,6 +41,11 @@ const BadgeContainer = /*#__PURE__*/styled.div.withConfig({
41
41
  ${gradient && '-webkit-text-fill-color: transparent;'}
42
42
  }`;
43
43
  });
44
+ const fontSizeMapping = {
45
+ 12: 'micro',
46
+ 14: 'small',
47
+ 16: 'h6'
48
+ };
44
49
  const Badge = _ref6 => {
45
50
  let {
46
51
  children,
@@ -54,10 +59,14 @@ const Badge = _ref6 => {
54
59
  borderColor,
55
60
  borderRadius,
56
61
  borderWidth,
62
+ color,
57
63
  paddingLeft,
58
64
  paddingRight,
59
65
  paddingTop,
60
- paddingBottom
66
+ paddingBottom,
67
+ fontName,
68
+ fontWeight,
69
+ fontSize
61
70
  } = useThemeTokens('Badge', tokens, variant);
62
71
  const semanticGradient = gradient && transformGradient(gradient);
63
72
  const {
@@ -78,12 +87,20 @@ const Badge = _ref6 => {
78
87
  padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
79
88
  radius: `${borderRadius}px`,
80
89
  background: background,
90
+ fontName: fontName,
91
+ fontWeight: fontWeight,
81
92
  gradient: semanticGradient,
82
93
  border: `${borderWidth}px solid ${borderColor}`,
83
- children: /*#__PURE__*/_jsx(BaseBadge, {
84
- tokens: tokens,
85
- variant: variant,
86
- ...rest,
94
+ ...selectProps(rest),
95
+ children: /*#__PURE__*/_jsx(Typography, {
96
+ tokens: {
97
+ fontName,
98
+ fontWeight,
99
+ color
100
+ },
101
+ variant: {
102
+ size: fontSizeMapping[fontSize]
103
+ },
87
104
  children: children
88
105
  })
89
106
  });
@@ -20,15 +20,9 @@ const StyledList = /*#__PURE__*/styled.ol.withConfig({
20
20
  listStylePosition: 'inside',
21
21
  margin: 0,
22
22
  padding: 0,
23
- alignItems: 'baseline',
24
- height: _ref => {
25
- let {
26
- iconContainerSize
27
- } = _ref;
28
- return `${iconContainerSize}px`;
29
- }
23
+ alignItems: 'baseline'
30
24
  });
31
- const omitProps = _ref2 => {
25
+ const omitProps = _ref => {
32
26
  let {
33
27
  current,
34
28
  path,
@@ -37,7 +31,7 @@ const omitProps = _ref2 => {
37
31
  childRoutes,
38
32
  component,
39
33
  ...props
40
- } = _ref2;
34
+ } = _ref;
41
35
  return props;
42
36
  };
43
37
  const getBreadcrumbName = (item, params) => {
@@ -100,7 +94,7 @@ const getStructuredData = (items, baseUrl) => {
100
94
  /**
101
95
  * Display a hierarchy of links, commonly used for navigation.
102
96
  */
103
- const Breadcrumbs = _ref3 => {
97
+ const Breadcrumbs = _ref2 => {
104
98
  let {
105
99
  baseUrl,
106
100
  children,
@@ -111,7 +105,7 @@ const Breadcrumbs = _ref3 => {
111
105
  variant,
112
106
  LinkRouter,
113
107
  ...rest
114
- } = _ref3;
108
+ } = _ref2;
115
109
  // React Helmet can cause a memory leak in SSR if not properly configured.
116
110
  // Only run it in SSR if theme options tells us to.
117
111
  /* const {
@@ -121,7 +115,7 @@ const Breadcrumbs = _ref3 => {
121
115
  // const isSSR = typeof window === 'undefined' || isHydrating
122
116
  // const hasMetadata = isSSR ? enableHelmetSSR : true
123
117
  const helmetContext = {};
124
- const activeRoutes = children ? React.Children.map(unpackFragment(children), _ref4 => {
118
+ const activeRoutes = children ? React.Children.map(unpackFragment(children), _ref3 => {
125
119
  let {
126
120
  props: {
127
121
  href,
@@ -129,7 +123,7 @@ const Breadcrumbs = _ref3 => {
129
123
  ...itemRest
130
124
  },
131
125
  ref
132
- } = _ref4;
126
+ } = _ref3;
133
127
  return {
134
128
  path: href,
135
129
  breadcrumbName,
@@ -159,7 +153,7 @@ const Breadcrumbs = _ref3 => {
159
153
  ...selectProps(rest),
160
154
  children: [/*#__PURE__*/_jsx(StyledList, {
161
155
  iconContainerSize: themeTokens.iconContainerSize,
162
- children: items.map(_ref5 => {
156
+ children: items.map(_ref4 => {
163
157
  let {
164
158
  href,
165
159
  current,
@@ -167,7 +161,7 @@ const Breadcrumbs = _ref3 => {
167
161
  LinkRouter: ItemLinkRouter = LinkRouter,
168
162
  linkRouterProps: itemLinkRouterProps,
169
163
  ...itemRest
170
- } = _ref5;
164
+ } = _ref4;
171
165
  return /*#__PURE__*/_createElement(Item, {
172
166
  ...itemRest,
173
167
  current: current,
@@ -30,7 +30,8 @@ const StyledItemContainer = /*#__PURE__*/styled.li.withConfig({
30
30
  iconContainerSize
31
31
  } = _ref3;
32
32
  return `${iconContainerSize}px`;
33
- }
33
+ },
34
+ marginBottom: '8px'
34
35
  });
35
36
  const IconContainer = /*#__PURE__*/styled.span.withConfig({
36
37
  displayName: "Item__IconContainer",
@@ -65,6 +65,7 @@ const PortalPositionedContainer = /*#__PURE__*/styled.div.withConfig({
65
65
  return `${top}px`;
66
66
  }
67
67
  });
68
+ const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/;
68
69
 
69
70
  /**
70
71
  * Use DatePicker to select a date on a calendar.
@@ -186,14 +187,34 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
186
187
  if (onDateChange) onDateChange(value);
187
188
  };
188
189
  const onChangeInput = value => {
189
- if (moment(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
190
- setInputDate(moment(value, dateFormat));
191
- if (onDateChange) onDateChange(moment(value, dateFormat));
192
- setInputText(moment(value, dateFormatWithoutSpaces).format(dateFormat));
190
+ if (value === '' || moment(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
191
+ if (value === '') {
192
+ setInputDate(undefined); // Set inputDate to undefined if input is empty
193
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(undefined);
194
+ } else {
195
+ setInputDate(moment(value, dateFormat));
196
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(moment(value, dateFormat));
197
+ }
198
+ setInputText(value === '' ? '' : moment(value, dateFormatWithoutSpaces).format(dateFormat));
193
199
  } else {
194
200
  setInputText(value);
195
201
  }
196
202
  };
203
+ const handleOnKeyPress = event => {
204
+ if (event.key === 'Backspace' && inputText === '') {
205
+ setInputDate(undefined);
206
+ onDateChange === null || onDateChange === void 0 ? void 0 : onDateChange(undefined);
207
+ }
208
+ };
209
+ const handleValidation = inputValidation => {
210
+ if (validDatePattern.test(inputText.replace(/\s+/g, '')) === false && inputText !== '') {
211
+ return 'error';
212
+ }
213
+ if (inputValidation === 'error' || inputValidation === 'success') {
214
+ return inputValidation;
215
+ }
216
+ return inputValidation;
217
+ };
197
218
  const viewport = useViewport();
198
219
  const daySize = getResponsiveDaySize(inline, viewport);
199
220
  const circleSize = getResponsiveCircleSize(inline, viewport);
@@ -314,11 +335,12 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
314
335
  hint: hint,
315
336
  placeholder: "DD / MM / YYYY",
316
337
  onChange: onChangeInput,
338
+ onKeyPress: handleOnKeyPress,
317
339
  tooltip: tooltip,
318
340
  hintPosition: hintPosition,
319
341
  label: label ?? ((_dictionary$copy = dictionary[copy]) === null || _dictionary$copy === void 0 ? void 0 : _dictionary$copy.roleDescription),
320
342
  value: inputText,
321
- validation: validation,
343
+ validation: handleValidation(validation),
322
344
  inactive: disabled,
323
345
  ref: textInputRef,
324
346
  children: /*#__PURE__*/_jsx(Portal, {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.80.1",
8
+ "@telus-uds/components-base": "1.82.0",
9
9
  "@telus-uds/system-constants": "^1.3.0",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
@@ -13,7 +13,7 @@
13
13
  "react-dates": "^21.8.0",
14
14
  "react-helmet-async": "^1.3.0",
15
15
  "react-moment-proptypes": "^1.8.1",
16
- "@telus-uds/system-theme-tokens": "^2.53.0",
16
+ "@telus-uds/system-theme-tokens": "^2.54.0",
17
17
  "prop-types": "^15.7.2",
18
18
  "lodash.throttle": "^4.1.1",
19
19
  "react-youtube": "^10.1.0",
@@ -83,5 +83,5 @@
83
83
  "skip": true
84
84
  },
85
85
  "types": "types/index.d.ts",
86
- "version": "2.32.1"
86
+ "version": "2.33.0"
87
87
  }
@@ -3,13 +3,13 @@ import styled from 'styled-components'
3
3
  import PropTypes from 'prop-types'
4
4
  import {
5
5
  selectSystemProps,
6
+ Typography,
6
7
  getTokensPropType,
7
- useThemeTokens,
8
- Badge as BaseBadge
8
+ useThemeTokens
9
9
  } from '@telus-uds/components-base'
10
10
  import { htmlAttrs, transformGradient } from '../utils'
11
11
 
12
- const [, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
12
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
13
13
 
14
14
  const BadgeContainer = styled.div`
15
15
  background: ${({ background }) => background};
@@ -29,6 +29,12 @@ const BadgeContainer = styled.div`
29
29
  }`}
30
30
  `
31
31
 
32
+ const fontSizeMapping = {
33
+ 12: 'micro',
34
+ 14: 'small',
35
+ 16: 'h6'
36
+ }
37
+
32
38
  const Badge = ({ children, tokens, variant = {}, ...rest }) => {
33
39
  const {
34
40
  backgroundColor,
@@ -36,10 +42,14 @@ const Badge = ({ children, tokens, variant = {}, ...rest }) => {
36
42
  borderColor,
37
43
  borderRadius,
38
44
  borderWidth,
45
+ color,
39
46
  paddingLeft,
40
47
  paddingRight,
41
48
  paddingTop,
42
- paddingBottom
49
+ paddingBottom,
50
+ fontName,
51
+ fontWeight,
52
+ fontSize
43
53
  } = useThemeTokens('Badge', tokens, variant)
44
54
 
45
55
  const semanticGradient = gradient && transformGradient(gradient)
@@ -60,12 +70,18 @@ const Badge = ({ children, tokens, variant = {}, ...rest }) => {
60
70
  padding={`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`}
61
71
  radius={`${borderRadius}px`}
62
72
  background={background}
73
+ fontName={fontName}
74
+ fontWeight={fontWeight}
63
75
  gradient={semanticGradient}
64
76
  border={`${borderWidth}px solid ${borderColor}`}
77
+ {...selectProps(rest)}
65
78
  >
66
- <BaseBadge tokens={tokens} variant={variant} {...rest}>
79
+ <Typography
80
+ tokens={{ fontName, fontWeight, color }}
81
+ variant={{ size: fontSizeMapping[fontSize] }}
82
+ >
67
83
  {children}
68
- </BaseBadge>
84
+ </Typography>
69
85
  </BadgeContainer>
70
86
  )
71
87
  }
@@ -25,8 +25,7 @@ const StyledList = styled.ol({
25
25
  listStylePosition: 'inside',
26
26
  margin: 0,
27
27
  padding: 0,
28
- alignItems: 'baseline',
29
- height: ({ iconContainerSize }) => `${iconContainerSize}px`
28
+ alignItems: 'baseline'
30
29
  })
31
30
 
32
31
  const omitProps = ({
@@ -17,7 +17,8 @@ const StyledItemContainer = styled.li({
17
17
  display: 'flex',
18
18
  paddingLeft: ({ listItemPadding }) => `${listItemPadding}px`,
19
19
  lineHeight: ({ lineHeight, fontSize }) => `${Math.ceil(lineHeight * fontSize)}px`,
20
- height: ({ iconContainerSize }) => `${iconContainerSize}px`
20
+ height: ({ iconContainerSize }) => `${iconContainerSize}px`,
21
+ marginBottom: '8px'
21
22
  })
22
23
 
23
24
  const IconContainer = styled.span({
@@ -56,6 +56,8 @@ const PortalPositionedContainer = styled.div({
56
56
  top: ({ top }) => `${top}px`
57
57
  })
58
58
 
59
+ const validDatePattern = /^([0-2][0-9]|3[0-1])(\/)(0[1-9]|1[0-2])\2(\d{4})$/
60
+
59
61
  /**
60
62
  * Use DatePicker to select a date on a calendar.
61
63
  *
@@ -168,14 +170,42 @@ const DatePicker = forwardRef(
168
170
  if (onDateChange) onDateChange(value)
169
171
  }
170
172
  const onChangeInput = (value) => {
171
- if (moment(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()) {
172
- setInputDate(moment(value, dateFormat))
173
- if (onDateChange) onDateChange(moment(value, dateFormat))
174
- setInputText(moment(value, dateFormatWithoutSpaces).format(dateFormat))
173
+ if (
174
+ value === '' ||
175
+ moment(value.replace(/\s/g, ''), dateFormatWithoutSpaces, true).isValid()
176
+ ) {
177
+ if (value === '') {
178
+ setInputDate(undefined) // Set inputDate to undefined if input is empty
179
+ onDateChange?.(undefined)
180
+ } else {
181
+ setInputDate(moment(value, dateFormat))
182
+ onDateChange?.(moment(value, dateFormat))
183
+ }
184
+ setInputText(value === '' ? '' : moment(value, dateFormatWithoutSpaces).format(dateFormat))
175
185
  } else {
176
186
  setInputText(value)
177
187
  }
178
188
  }
189
+
190
+ const handleOnKeyPress = (event) => {
191
+ if (event.key === 'Backspace' && inputText === '') {
192
+ setInputDate(undefined)
193
+ onDateChange?.(undefined)
194
+ }
195
+ }
196
+
197
+ const handleValidation = (inputValidation) => {
198
+ if (validDatePattern.test(inputText.replace(/\s+/g, '')) === false && inputText !== '') {
199
+ return 'error'
200
+ }
201
+
202
+ if (inputValidation === 'error' || inputValidation === 'success') {
203
+ return inputValidation
204
+ }
205
+
206
+ return inputValidation
207
+ }
208
+
179
209
  const viewport = useViewport()
180
210
  const daySize = getResponsiveDaySize(inline, viewport)
181
211
  const circleSize = getResponsiveCircleSize(inline, viewport)
@@ -286,11 +316,12 @@ const DatePicker = forwardRef(
286
316
  hint={hint}
287
317
  placeholder="DD / MM / YYYY"
288
318
  onChange={onChangeInput}
319
+ onKeyPress={handleOnKeyPress}
289
320
  tooltip={tooltip}
290
321
  hintPosition={hintPosition}
291
322
  label={label ?? dictionary[copy]?.roleDescription}
292
323
  value={inputText}
293
- validation={validation}
324
+ validation={handleValidation(validation)}
294
325
  inactive={disabled}
295
326
  ref={textInputRef}
296
327
  >