@dxc-technology/halstack-react 12.0.1 → 12.0.2

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.
@@ -193,11 +193,13 @@ declare const HalstackContext: React.Context<DeepPartial<{
193
193
  };
194
194
  chip: {
195
195
  backgroundColor: string;
196
+ disabledBackgroundColor: string;
196
197
  fontFamily: string;
197
198
  fontSize: string;
198
199
  fontStyle: string;
199
200
  fontWeight: string;
200
201
  fontColor: string;
202
+ disabledFontColor: string;
201
203
  borderColor: string;
202
204
  borderRadius: string;
203
205
  borderThickness: string;
@@ -215,6 +217,7 @@ declare const HalstackContext: React.Context<DeepPartial<{
215
217
  focusColor: string;
216
218
  focusBorderStyle: string;
217
219
  focusBorderThickness: string;
220
+ focusBorderRadius: string;
218
221
  };
219
222
  dateInput: {
220
223
  pickerBackgroundColor: string;
@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = exports.HalstackProvider = exports.HalstackLanguageContext = void 0;
9
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
10
  var _react = _interopRequireWildcard(require("react"));
10
11
  var _color = _interopRequireDefault(require("color"));
12
+ var _styledComponents = require("styled-components");
11
13
  var _variables = require("./common/variables");
14
+ var _templateObject;
12
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
14
17
  var HalstackContext = /*#__PURE__*/_react["default"].createContext(null);
@@ -299,8 +302,9 @@ var HalstackProvider = exports.HalstackProvider = function HalstackProvider(_ref
299
302
  }, [labels]);
300
303
  return /*#__PURE__*/_react["default"].createElement(HalstackContext.Provider, {
301
304
  value: parsedTheme
302
- }, /*#__PURE__*/_react["default"].createElement(HalstackLanguageContext.Provider, {
305
+ }, /*#__PURE__*/_react["default"].createElement(GlobalStyle, null), /*#__PURE__*/_react["default"].createElement(HalstackLanguageContext.Provider, {
303
306
  value: parsedLabels
304
307
  }, children));
305
308
  };
309
+ var GlobalStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n @import url(\"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap\");\n"])));
306
310
  var _default = exports["default"] = HalstackContext;
@@ -27,7 +27,6 @@ describe("Chip component accessibility tests", function () {
27
27
  _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
28
28
  margin: "small",
29
29
  prefixIcon: iconSVG,
30
- onClickPrefix: function onClickPrefix() {},
31
30
  suffixIcon: iconSVG,
32
31
  label: "Chip"
33
32
  })), container = _render.container;
@@ -50,7 +49,6 @@ describe("Chip component accessibility tests", function () {
50
49
  _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
51
50
  margin: "small",
52
51
  prefixIcon: iconSVG,
53
- onClickPrefix: function onClickPrefix() {},
54
52
  suffixIcon: iconSVG,
55
53
  label: "Chip",
56
54
  disabled: true
package/chip/Chip.js CHANGED
@@ -31,6 +31,7 @@ var DxcChip = function DxcChip(_ref) {
31
31
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
32
32
  theme: colorsTheme.chip
33
33
  }, /*#__PURE__*/_react["default"].createElement(Chip, {
34
+ disabled: disabled,
34
35
  margin: margin
35
36
  }, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
36
37
  role: typeof onClickPrefix === "function" ? "button" : undefined,
@@ -38,16 +39,22 @@ var DxcChip = function DxcChip(_ref) {
38
39
  disabled: disabled,
39
40
  interactuable: typeof onClickPrefix === "function" && !disabled,
40
41
  tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
41
- onClick: onClickPrefix
42
+ onClick: function onClick() {
43
+ return onClickPrefix && !disabled && onClickPrefix();
44
+ }
42
45
  }, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
43
46
  icon: prefixIcon
44
- }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
47
+ }) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
48
+ disabled: disabled
49
+ }, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
45
50
  role: typeof onClickSuffix === "function" ? "button" : undefined,
46
51
  "aria-label": typeof onClickSuffix === "function" ? "Suffix Action" : undefined,
47
52
  disabled: disabled,
48
53
  interactuable: typeof onClickSuffix === "function" && !disabled,
49
54
  tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
50
- onClick: onClickSuffix
55
+ onClick: function onClick() {
56
+ return !disabled && (onClickSuffix === null || onClickSuffix === void 0 ? void 0 : onClickSuffix());
57
+ }
51
58
  }, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
52
59
  icon: suffixIcon
53
60
  }) : suffixIcon)));
@@ -55,12 +62,12 @@ var DxcChip = function DxcChip(_ref) {
55
62
  var calculateWidth = function calculateWidth(margin) {
56
63
  return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
57
64
  };
58
- var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
65
+ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (props) {
59
66
  return props.theme.iconSpacing;
60
67
  }, function (props) {
61
68
  return calculateWidth(props.margin);
62
69
  }, function (props) {
63
- return props.theme.backgroundColor;
70
+ return props.disabled && props.theme.disabledBackgroundColor || props.theme.backgroundColor;
64
71
  }, function (props) {
65
72
  return props.theme.borderRadius;
66
73
  }, function (props) {
@@ -87,6 +94,9 @@ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject
87
94
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
88
95
  }, function (props) {
89
96
  return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
97
+ }, function (_ref2) {
98
+ var disabled = _ref2.disabled;
99
+ return disabled && "not-allowed";
90
100
  });
91
101
  var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
92
102
  return props.theme.fontSize;
@@ -97,12 +107,13 @@ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_tem
97
107
  }, function (props) {
98
108
  return props.theme.fontStyle;
99
109
  }, function (props) {
100
- return props.theme.fontColor;
110
+ return props.disabled ? props.theme.disabledFontColor : props.theme.fontColor;
101
111
  });
102
- var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n cursor: ", ";\n ", "\n\n font-size: ", ";\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
103
- return props.disabled && (props.onClick || props.onClick) ? props.theme.disabledIconColor : props.theme.iconColor;
104
- }, function (props) {
105
- return props.disabled && (props.onClick || props.onClick) ? "not-allowed" : props.interactuable ? "pointer" : "";
112
+ var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n ", "\n\n ", "\n\n font-size: ", ";\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
113
+ return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
114
+ }, function (_ref3) {
115
+ var interactuable = _ref3.interactuable;
116
+ return interactuable && "cursor: pointer;";
106
117
  }, function (props) {
107
118
  return props.interactuable && "\n &:hover {\n color: ".concat(props.theme.hoverIconColor, ";\n }\n &:focus,\n &:focus-visible {\n outline: ").concat(props.theme.focusBorderThickness, " ").concat(props.theme.focusBorderStyle, " ").concat(props.theme.focusColor, ";\n }\n &:active {\n color: ").concat(props.theme.activeIconColor, ";\n }\n ");
108
119
  }, function (props) {
@@ -33,6 +33,12 @@ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.11
33
33
  </svg>
34
34
  );
35
35
 
36
+ const smallIconSVG = (
37
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20">
38
+ <path d="m10 17-1.042-.938q-2.083-1.854-3.437-3.177-1.354-1.323-2.136-2.354Q2.604 9.5 2.302 8.646 2 7.792 2 6.896q0-1.854 1.271-3.125T6.396 2.5q1.021 0 1.979.438.958.437 1.625 1.229.667-.792 1.625-1.229.958-.438 1.979-.438 1.854 0 3.125 1.271T18 6.896q0 .896-.292 1.729-.291.833-1.073 1.854-.781 1.021-2.145 2.365-1.365 1.344-3.49 3.26Zm0-2.021q1.938-1.729 3.188-2.948 1.25-1.219 1.989-2.125.74-.906 1.031-1.614.292-.709.292-1.396 0-1.229-.833-2.063Q14.833 4 13.604 4q-.729 0-1.364.302-.636.302-1.094.844L10.417 6h-.834l-.729-.854q-.458-.542-1.114-.844Q7.083 4 6.396 4q-1.229 0-2.063.833-.833.834-.833 2.063 0 .687.271 1.364.271.678.989 1.573.719.896 1.98 2.125Q8 13.188 10 14.979Zm0-5.5Z" />
39
+ </svg>
40
+ );
41
+
36
42
  const opinionatedTheme = {
37
43
  chip: {
38
44
  baseColor: "#e6e6e6",
@@ -44,79 +50,33 @@ const opinionatedTheme = {
44
50
  export const Chromatic = () => (
45
51
  <>
46
52
  <ExampleContainer>
47
- <Title title="Default" theme="light" level={4} />
48
- <DxcChip label="Default" />
49
- </ExampleContainer>
50
- <ExampleContainer>
51
- <Title title="With prefix (SVG)" theme="light" level={4} />
52
- <DxcChip label="Prefix" prefixIcon={iconSVG} />
53
+ <Title title="Basic chip" theme="light" level={4} />
54
+ <DxcChip label="Default Chip" />
53
55
  </ExampleContainer>
54
56
  <ExampleContainer>
55
- <Title title="With action prefix (SVG)" theme="light" level={4} />
56
- <DxcChip label="Action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
57
+ <Title title="Chip with prefix SVG (small icon)" theme="light" level={4} />
58
+ <DxcChip label="Chip with prefix" prefixIcon={smallIconSVG} />
57
59
  </ExampleContainer>
58
60
  <ExampleContainer>
59
- <Title title="Disabled action prefix (SVG)" theme="light" level={4} />
60
- <DxcChip label="Disabled action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} disabled />
61
+ <Title title="Chip with suffix SVG (large icon)" theme="light" level={4} />
62
+ <DxcChip label="Chip with suffix" suffixIcon={iconSVG} />
61
63
  </ExampleContainer>
62
64
  <ExampleContainer>
63
- <Title title="With suffix (Material icon)" theme="light" level={4} />
64
- <DxcChip label="Suffix" suffixIcon="filled_check_circle" />
65
- </ExampleContainer>
66
- <ExampleContainer>
67
- <Title title="With action suffix (Material icon)" theme="light" level={4} />
68
- <DxcChip label="Action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} />
69
- </ExampleContainer>
70
- <ExampleContainer>
71
- <Title title="Action prefix and suffix" theme="light" level={4} />
72
- <DxcChip
73
- label="Action prefix and suffix"
74
- prefixIcon="filled_check_circle"
75
- onClickPrefix={() => {}}
76
- suffixIcon={iconSVG}
77
- />
65
+ <Title title="Chip with prefix (SVG) and suffix (URL)" theme="light" level={4} />
66
+ <DxcChip label="Chip with prefix and suffix" prefixIcon={iconSVG} suffixIcon="filled_check_circle" />
78
67
  </ExampleContainer>
79
68
  <ExampleContainer>
80
- <Title title="Prefix and action suffix" theme="light" level={4} />
81
- <DxcChip
82
- label="Prefix and action suffix"
83
- prefixIcon="filled_check_circle"
84
- suffixIcon={iconSVG}
85
- onClickSuffix={() => {}}
86
- />
87
- </ExampleContainer>
88
- <ExampleContainer>
89
- <Title title="Disabled action suffix (Material icon)" theme="light" level={4} />
90
- <DxcChip label="Disabled action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} disabled />
91
- </ExampleContainer>
92
- <ExampleContainer>
93
- <Title title="Disabled action prefix and suffix" theme="light" level={4} />
94
- <DxcChip
95
- label="Disabled action prefix"
96
- disabled
97
- prefixIcon={iconSVG}
98
- onClickPrefix={() => {}}
99
- suffixIcon="filled_check_circle"
100
- />
101
- </ExampleContainer>
102
- <ExampleContainer>
103
- <Title title="Prefix and disabled action suffix" theme="light" level={4} />
104
- <DxcChip
105
- label="Disabled action suffix"
106
- disabled
107
- prefixIcon={iconSVG}
108
- suffixIcon="filled_check_circle"
109
- onClickSuffix={() => {}}
110
- />
69
+ <Title title="Disabled chip" theme="light" level={4} />
70
+ <DxcChip label="Disabled" disabled prefixIcon={iconSVG} suffixIcon="filled_check_circle" />
111
71
  </ExampleContainer>
112
72
  <ExampleContainer>
113
- <Title title="With ellipsis" theme="light" level={4} />
73
+ <Title title="Chip with ellipsis" theme="light" level={4} />
114
74
  <div style={{ width: "200px" }}>
115
75
  <DxcChip label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fg ssssssssssss ssss" />
116
76
  </div>
117
77
  </ExampleContainer>
118
78
  <ExampleContainer>
119
- <Title title="With ellipsis and suffix" theme="light" level={4} />
79
+ <Title title="Chip with ellipsis and suffix" theme="light" level={4} />
120
80
  <div style={{ width: "200px" }}>
121
81
  <DxcChip
122
82
  suffixIcon={iconSVG}
@@ -125,7 +85,7 @@ export const Chromatic = () => (
125
85
  </div>
126
86
  </ExampleContainer>
127
87
  <ExampleContainer>
128
- <Title title="With ellipsis and prefix" theme="light" level={4} />
88
+ <Title title="Chip with ellipsis and prefix" theme="light" level={4} />
129
89
  <div style={{ width: "200px" }}>
130
90
  <DxcChip
131
91
  prefixIcon={iconSVG}
@@ -134,11 +94,10 @@ export const Chromatic = () => (
134
94
  </div>
135
95
  </ExampleContainer>
136
96
  <ExampleContainer>
137
- <Title title="With ellipsis, action prefix and suffix" theme="light" level={4} />
97
+ <Title title="Chip with ellipsis, suffix and prefix" theme="light" level={4} />
138
98
  <div style={{ width: "200px" }}>
139
99
  <DxcChip
140
100
  prefixIcon={iconSVG}
141
- onClickPrefix={() => {}}
142
101
  suffixIcon={iconSVG}
143
102
  label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasdf"
144
103
  />
@@ -175,48 +134,57 @@ export const Chromatic = () => (
175
134
  </ExampleContainer>
176
135
  <Title title="Opinionated theme" theme="light" level={2} />
177
136
  <ExampleContainer>
178
- <Title title="With prefix and suffix" theme="light" level={4} />
137
+ <Title title="Chip with prefix and suffix" theme="light" level={4} />
179
138
  <HalstackProvider theme={opinionatedTheme}>
180
- <DxcChip label="Chip" prefixIcon={iconSVG} onClickPrefix={() => {}} suffixIcon="filled_check_circle" />
139
+ <DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon="filled_check_circle" />
181
140
  </HalstackProvider>
182
141
  </ExampleContainer>
183
142
  <ExampleContainer>
184
- <Title title="With prefix and suffix" theme="light" level={4} />
143
+ <Title title="Chip with prefix and suffix" theme="light" level={4} />
185
144
  <HalstackProvider theme={opinionatedTheme}>
186
- <DxcChip
187
- label="Disabled"
188
- disabled
189
- prefixIcon={iconSVG}
190
- suffixIcon="filled_check_circle"
191
- onClickSuffix={() => {}}
192
- />
145
+ <DxcChip label="Chip" disabled prefixIcon={iconSVG} suffixIcon="filled_check_circle" />
193
146
  </HalstackProvider>
194
147
  </ExampleContainer>
195
148
  <ExampleContainer pseudoState="pseudo-hover">
196
149
  <Title title="Hovered" theme="light" level={4} />
197
150
  <HalstackProvider theme={opinionatedTheme}>
198
- <DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
151
+ <DxcChip
152
+ label="Chip"
153
+ prefixIcon={iconSVG}
154
+ suffixIcon={iconSVG}
155
+ onClickPrefix={() => {}}
156
+ onClickSuffix={() => {}}
157
+ />
199
158
  </HalstackProvider>
200
159
  </ExampleContainer>
201
160
  <ExampleContainer pseudoState="pseudo-active">
202
161
  <Title title="Actived" theme="light" level={4} />
203
162
  <HalstackProvider theme={opinionatedTheme}>
204
- <DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
163
+ <DxcChip
164
+ label="Chip"
165
+ prefixIcon={iconSVG}
166
+ suffixIcon={iconSVG}
167
+ onClickPrefix={() => {}}
168
+ onClickSuffix={() => {}}
169
+ />
205
170
  </HalstackProvider>
206
171
  </ExampleContainer>
207
172
  </>
208
173
  );
209
-
210
174
  const ChipPrefixFocused = () => (
211
175
  <ExampleContainer>
212
- <Title title="With prefix" theme="light" level={4} />
213
- <DxcChip label="Prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
176
+ <Title title="Chip with prefix" theme="light" level={4} />
177
+ <DxcChip
178
+ label="Chip with prefix"
179
+ prefixIcon={iconSVG}
180
+ onClickPrefix={() => {}}
181
+ />
214
182
  </ExampleContainer>
215
183
  );
216
184
  const ChipSuffixFocused = () => (
217
185
  <ExampleContainer>
218
- <Title title="With suffix" theme="light" level={4} />
219
- <DxcChip label="Suffix" suffixIcon="filled_delete" onClickSuffix={() => {}} />
186
+ <Title title="Chip with suffix" theme="light" level={4} />
187
+ <DxcChip label="Chip with suffix" suffixIcon="filled_delete" onClickSuffix={() => {}} />
220
188
  </ExampleContainer>
221
189
  );
222
190
 
package/chip/types.d.ts CHANGED
@@ -7,53 +7,31 @@ type Margin = {
7
7
  right?: Space;
8
8
  };
9
9
  type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
- type Icon = string | SVG;
11
- type PrefixIconProps = {
10
+ type Props = {
12
11
  /**
13
- * Element or path used as icon to be placed before the chip label.
12
+ * Text to be placed on the chip.
14
13
  */
15
- prefixIcon: Icon;
14
+ label?: string;
16
15
  /**
17
- * This function will be called when the prefix is clicked.
16
+ * Element or path used as icon to be placed after the chip label.
18
17
  */
19
- onClickPrefix: () => void;
18
+ suffixIcon?: string | SVG;
20
19
  /**
21
- * Element or path used as icon to be placed after the chip label.
20
+ * Element or path used as icon to be placed before the chip label.
22
21
  */
23
- suffixIcon?: Icon;
22
+ prefixIcon?: string | SVG;
24
23
  /**
25
24
  * This function will be called when the suffix is clicked.
26
25
  */
27
- onClickSuffix?: never;
26
+ onClickSuffix?: () => void;
28
27
  /**
29
- * If true, the action icon will be disabled.
28
+ * This function will be called when the prefix is clicked.
30
29
  */
31
- disabled?: boolean;
32
- } | {
33
- prefixIcon?: Icon;
34
- onClickPrefix?: never;
35
- suffixIcon?: never;
36
- onClickSuffix?: never;
37
- disabled?: never;
38
- };
39
- type SuffixIconProps = {
40
- suffixIcon: Icon;
41
- onClickSuffix: () => void;
42
- prefixIcon?: Icon;
43
- onClickPrefix?: never;
44
- disabled?: boolean;
45
- } | {
46
- suffixIcon?: Icon;
47
- onClickSuffix?: never;
48
- prefixIcon?: never;
49
- onClickPrefix?: never;
50
- disabled?: never;
51
- };
52
- type CommonProps = {
30
+ onClickPrefix?: () => void;
53
31
  /**
54
- * Text to be placed on the chip.
32
+ * If true, the component will be disabled.
55
33
  */
56
- label?: string;
34
+ disabled?: boolean;
57
35
  /**
58
36
  * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
59
37
  * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
@@ -64,5 +42,4 @@ type CommonProps = {
64
42
  */
65
43
  tabIndex?: number;
66
44
  };
67
- type Props = (PrefixIconProps | SuffixIconProps) & CommonProps;
68
45
  export default Props;
@@ -191,11 +191,13 @@ export declare const componentTokens: {
191
191
  };
192
192
  chip: {
193
193
  backgroundColor: string;
194
+ disabledBackgroundColor: string;
194
195
  fontFamily: string;
195
196
  fontSize: string;
196
197
  fontStyle: string;
197
198
  fontWeight: string;
198
199
  fontColor: string;
200
+ disabledFontColor: string;
199
201
  borderColor: string;
200
202
  borderRadius: string;
201
203
  borderThickness: string;
@@ -213,6 +215,7 @@ export declare const componentTokens: {
213
215
  focusColor: string;
214
216
  focusBorderStyle: string;
215
217
  focusBorderThickness: string;
218
+ focusBorderRadius: string;
216
219
  };
217
220
  dateInput: {
218
221
  pickerBackgroundColor: string;
@@ -199,11 +199,13 @@ var componentTokens = exports.componentTokens = {
199
199
  },
200
200
  chip: {
201
201
  backgroundColor: _coreTokens["default"].color_grey_200,
202
+ disabledBackgroundColor: _coreTokens["default"].color_grey_100,
202
203
  fontFamily: _coreTokens["default"].type_sans,
203
204
  fontSize: _coreTokens["default"].type_scale_03,
204
205
  fontStyle: _coreTokens["default"].type_normal,
205
206
  fontWeight: _coreTokens["default"].type_regular,
206
207
  fontColor: _coreTokens["default"].color_black,
208
+ disabledFontColor: _coreTokens["default"].color_grey_500,
207
209
  borderColor: _coreTokens["default"].color_transparent,
208
210
  borderRadius: "80px",
209
211
  borderThickness: _coreTokens["default"].border_width_0,
@@ -220,7 +222,8 @@ var componentTokens = exports.componentTokens = {
220
222
  disabledIconColor: _coreTokens["default"].color_grey_500,
221
223
  focusColor: _coreTokens["default"].color_blue_600,
222
224
  focusBorderStyle: _coreTokens["default"].border_solid,
223
- focusBorderThickness: _coreTokens["default"].border_width_2
225
+ focusBorderThickness: _coreTokens["default"].border_width_2,
226
+ focusBorderRadius: _coreTokens["default"].border_radius_medium
224
227
  },
225
228
  dateInput: {
226
229
  pickerBackgroundColor: _coreTokens["default"].color_white,
package/icon/Icon.js CHANGED
@@ -25,7 +25,7 @@ var DxcIcon = function DxcIcon(_ref) {
25
25
  "aria-hidden": "true"
26
26
  });
27
27
  };
28
- var IconContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n font-family: \"Material Symbols Outlined\";\n font-weight: normal;\n font-style: normal;\n line-height: 1;\n letter-spacing: normal;\n text-transform: none;\n display: inline-block;\n white-space: nowrap;\n word-wrap: normal;\n direction: ltr;\n -webkit-font-feature-settings: \"liga\";\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n -moz-osx-font-smoothing: grayscale;\n font-variation-settings: ", ";\n ::before {\n content: \"", "\";\n }\n"])), function (props) {
28
+ var IconContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n @import url(\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL@0..1\");\n font-family: \"Material Symbols Outlined\";\n font-weight: normal;\n font-style: normal;\n line-height: 1;\n letter-spacing: normal;\n text-transform: none;\n display: inline-block;\n white-space: nowrap;\n word-wrap: normal;\n direction: ltr;\n -webkit-font-feature-settings: \"liga\";\n -webkit-font-smoothing: antialiased;\n text-rendering: optimizeLegibility;\n -moz-osx-font-smoothing: grayscale;\n font-variation-settings: ", ";\n ::before {\n content: \"", "\";\n }\n"])), function (props) {
29
29
  return props.filled ? "'FILL' 1" : "'FILL' 0";
30
30
  }, function (props) {
31
31
  return props.icon;
package/main.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import "./common/fonts.css";
2
1
  import DxcAlert from "./alert/Alert";
3
2
  import DxcAccordion from "./accordion/Accordion";
4
3
  import DxcButton from "./button/Button";
package/main.js CHANGED
@@ -311,7 +311,6 @@ Object.defineProperty(exports, "HalstackProvider", {
311
311
  return _HalstackContext.HalstackProvider;
312
312
  }
313
313
  });
314
- require("./common/fonts.css");
315
314
  var _Alert = _interopRequireDefault(require("./alert/Alert"));
316
315
  var _Accordion = _interopRequireDefault(require("./accordion/Accordion"));
317
316
  var _Button = _interopRequireDefault(require("./button/Button"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxc-technology/halstack-react",
3
- "version": "12.0.1",
3
+ "version": "12.0.2",
4
4
  "description": "DXC Halstack React components library",
5
5
  "repository": "dxc-technology/halstack-react",
6
6
  "homepage": "https://developer.dxc.com/halstack",
@@ -62,6 +62,7 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
62
62
  var colorsTheme = (0, _useTheme["default"])();
63
63
  var translatedLabels = (0, _useTranslatedLabels["default"])();
64
64
  var textareaRef = (0, _react.useRef)(null);
65
+ var prevValueRef = (0, _react.useRef)(null);
65
66
  var errorId = "error-".concat(textareaId);
66
67
  var isNotOptional = function isNotOptional(value) {
67
68
  return value === "" && !optional;
@@ -84,13 +85,6 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
84
85
  value: newValue
85
86
  });
86
87
  };
87
- var autoVerticalGrow = function autoVerticalGrow() {
88
- var textareaLineHeight = parseInt(window.getComputedStyle(textareaRef.current)["line-height"]);
89
- var textareaPaddingTopBottom = parseInt(window.getComputedStyle(textareaRef.current)["padding-top"]) * 2;
90
- textareaRef.current.style.height = "".concat(textareaLineHeight * rows, "px");
91
- var newHeight = textareaRef.current.scrollHeight - textareaPaddingTopBottom;
92
- textareaRef.current.style.height = "".concat(newHeight, "px");
93
- };
94
88
  var handleOnBlur = function handleOnBlur(event) {
95
89
  if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
96
90
  value: event.target.value,
@@ -107,8 +101,17 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
107
101
  };
108
102
  var handleOnChange = function handleOnChange(event) {
109
103
  changeValue(event.target.value);
110
- verticalGrow === "auto" && autoVerticalGrow();
111
104
  };
105
+ (0, _react.useEffect)(function () {
106
+ if (verticalGrow === "auto" && prevValueRef.current !== (value !== null && value !== void 0 ? value : innerValue)) {
107
+ var textareaLineHeight = parseInt(window.getComputedStyle(textareaRef.current)["line-height"]);
108
+ var textareaPaddingTopBottom = parseInt(window.getComputedStyle(textareaRef.current)["padding-top"]) * 2;
109
+ textareaRef.current.style.height = "".concat(textareaLineHeight * rows, "px");
110
+ var newHeight = textareaRef.current.scrollHeight - textareaPaddingTopBottom;
111
+ textareaRef.current.style.height = "".concat(newHeight, "px");
112
+ prevValueRef.current = value !== null && value !== void 0 ? value : innerValue;
113
+ }
114
+ }, [verticalGrow, value, innerValue, rows]);
112
115
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
113
116
  theme: colorsTheme.textarea
114
117
  }, /*#__PURE__*/_react["default"].createElement(TextareaContainer, {
package/useTheme.d.ts CHANGED
@@ -191,11 +191,13 @@ declare const useTheme: () => {
191
191
  }>;
192
192
  chip?: Partial<{
193
193
  backgroundColor: string;
194
+ disabledBackgroundColor: string;
194
195
  fontFamily: string;
195
196
  fontSize: string;
196
197
  fontStyle: string;
197
198
  fontWeight: string;
198
199
  fontColor: string;
200
+ disabledFontColor: string;
199
201
  borderColor: string;
200
202
  borderRadius: string;
201
203
  borderThickness: string;
@@ -213,6 +215,7 @@ declare const useTheme: () => {
213
215
  focusColor: string;
214
216
  focusBorderStyle: string;
215
217
  focusBorderThickness: string;
218
+ focusBorderRadius: string;
216
219
  }>;
217
220
  dateInput?: Partial<{
218
221
  pickerBackgroundColor: string;
package/common/fonts.css DELETED
@@ -1,2 +0,0 @@
1
- @import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:FILL@0..1");
2
- @import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap");