@dxc-technology/halstack-react 0.0.0-1819a7a → 0.0.0-1853afe

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.
Files changed (84) hide show
  1. package/BackgroundColorContext.js +0 -1
  2. package/accordion/Accordion.d.ts +1 -1
  3. package/accordion/Accordion.js +9 -20
  4. package/accordion/Accordion.stories.tsx +9 -2
  5. package/accordion/types.d.ts +3 -7
  6. package/accordion-group/types.d.ts +3 -7
  7. package/bleed/Bleed.d.ts +3 -0
  8. package/bleed/Bleed.js +84 -0
  9. package/bleed/Bleed.stories.tsx +342 -0
  10. package/bleed/types.d.ts +13 -0
  11. package/bleed/types.js +5 -0
  12. package/button/Button.d.ts +1 -1
  13. package/button/Button.js +7 -15
  14. package/button/Button.stories.tsx +6 -8
  15. package/button/types.d.ts +3 -7
  16. package/card/Card.stories.tsx +1 -1
  17. package/checkbox/types.d.ts +1 -1
  18. package/chip/Chip.d.ts +1 -1
  19. package/chip/Chip.js +14 -52
  20. package/chip/Chip.stories.tsx +6 -8
  21. package/chip/types.d.ts +5 -13
  22. package/common/variables.js +38 -1
  23. package/date-input/DateInput.js +6 -6
  24. package/dialog/Dialog.js +2 -1
  25. package/dropdown/Dropdown.stories.tsx +247 -0
  26. package/file-input/FileInput.js +102 -33
  27. package/file-input/FileInput.stories.tsx +507 -0
  28. package/footer/Footer.js +18 -20
  29. package/heading/Heading.stories.tsx +3 -2
  30. package/inset/Inset.d.ts +3 -0
  31. package/inset/Inset.js +84 -0
  32. package/inset/Inset.stories.tsx +229 -0
  33. package/inset/types.d.ts +13 -0
  34. package/inset/types.js +5 -0
  35. package/layout/ApplicationLayout.js +1 -1
  36. package/list/List.d.ts +3 -6
  37. package/list/List.js +17 -7
  38. package/list/List.stories.tsx +25 -0
  39. package/list/types.d.ts +7 -0
  40. package/list/types.js +5 -0
  41. package/package.json +4 -2
  42. package/password-input/PasswordInput.stories.tsx +3 -3
  43. package/progress-bar/ProgressBar.js +2 -2
  44. package/radio-group/Radio.d.ts +4 -0
  45. package/radio-group/Radio.js +140 -0
  46. package/radio-group/RadioGroup.d.ts +4 -0
  47. package/radio-group/RadioGroup.js +273 -0
  48. package/radio-group/RadioGroup.stories.tsx +79 -0
  49. package/radio-group/RadioGroup.test.js +248 -0
  50. package/radio-group/types.d.ts +36 -0
  51. package/radio-group/types.js +5 -0
  52. package/resultsetTable/ResultsetTable.js +1 -1
  53. package/resultsetTable/ResultsetTable.stories.tsx +7 -8
  54. package/row/Row.d.ts +3 -11
  55. package/row/Row.js +12 -9
  56. package/row/Row.stories.tsx +20 -6
  57. package/row/types.d.ts +10 -0
  58. package/row/types.js +5 -0
  59. package/select/Select.d.ts +4 -0
  60. package/select/Select.js +5 -5
  61. package/select/types.d.ts +170 -0
  62. package/select/types.js +5 -0
  63. package/sidenav/Sidenav.stories.tsx +18 -1
  64. package/spinner/Spinner.stories.jsx +1 -0
  65. package/stack/Stack.d.ts +3 -10
  66. package/stack/Stack.js +12 -9
  67. package/stack/Stack.stories.tsx +20 -6
  68. package/stack/types.d.ts +9 -0
  69. package/stack/types.js +5 -0
  70. package/switch/Switch.stories.tsx +1 -1
  71. package/table/Table.stories.jsx +2 -1
  72. package/tabs/Tabs.js +7 -7
  73. package/tabs/Tabs.stories.tsx +7 -8
  74. package/tabs/types.d.ts +23 -15
  75. package/tag/Tag.stories.tsx +1 -1
  76. package/text/Text.js +1 -1
  77. package/text-input/TextInput.js +12 -4
  78. package/text-input/TextInput.stories.tsx +4 -4
  79. package/text-input/types.d.ts +1 -1
  80. package/textarea/Textarea.stories.jsx +4 -3
  81. package/toggle-group/ToggleGroup.js +10 -13
  82. package/toggle-group/ToggleGroup.stories.tsx +23 -28
  83. package/toggle-group/types.d.ts +38 -25
  84. package/select/index.d.ts +0 -131
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _RadioGroup = _interopRequireDefault(require("./RadioGroup"));
8
+
9
+ var _react2 = require("@testing-library/react");
10
+
11
+ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
12
+
13
+ var single_options = [{
14
+ label: "Option 01",
15
+ value: "1"
16
+ }, {
17
+ label: "Option 02",
18
+ value: "2"
19
+ }, {
20
+ label: "Option 03",
21
+ value: "3"
22
+ }, {
23
+ label: "Option 04",
24
+ value: "4"
25
+ }, {
26
+ label: "Option 05",
27
+ value: "5"
28
+ }, {
29
+ label: "Option 06",
30
+ value: "6"
31
+ }, {
32
+ label: "Option 07",
33
+ value: "7"
34
+ }, {
35
+ label: "Option 08",
36
+ value: "8"
37
+ }, {
38
+ label: "Option 09",
39
+ value: "9"
40
+ }, {
41
+ label: "Option 10",
42
+ value: "10"
43
+ }];
44
+ describe("Radio Group component tests", function () {
45
+ test("Controlled - Not optional constraint - undefined", function () {
46
+ var onChange = jest.fn();
47
+ var onBlur = jest.fn();
48
+
49
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
50
+ label: "test-select-label",
51
+ options: single_options,
52
+ onChange: onChange,
53
+ onBlur: onBlur
54
+ })),
55
+ getByRole = _render.getByRole,
56
+ getAllByRole = _render.getAllByRole;
57
+
58
+ var radioGroup = getByRole("radiogroup");
59
+ expect(radioGroup.getAttribute("aria-required")).toBe("true");
60
+
61
+ _react2.fireEvent.focus(radioGroup);
62
+
63
+ _react2.fireEvent.blur(radioGroup);
64
+
65
+ expect(onBlur).toHaveBeenCalled();
66
+ expect(onBlur).toHaveBeenCalledWith({
67
+ error: "This field is required. Please, choose an option."
68
+ });
69
+
70
+ _userEvent["default"].click(radioGroup);
71
+
72
+ _userEvent["default"].click(getAllByRole("radio")[0]);
73
+
74
+ expect(onChange).toHaveBeenCalled();
75
+ expect(onChange).toHaveBeenCalledWith("1");
76
+
77
+ _react2.fireEvent.focus(radioGroup);
78
+
79
+ _react2.fireEvent.blur(radioGroup);
80
+
81
+ expect(onBlur).toHaveBeenCalled();
82
+ expect(onBlur).toHaveBeenCalledWith({
83
+ value: "1"
84
+ });
85
+ });
86
+ test("Controlled - Not optional constraint - empty string", function () {
87
+ var onChange = jest.fn();
88
+ var onBlur = jest.fn();
89
+
90
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
91
+ label: "test-select-label",
92
+ value: "",
93
+ options: single_options,
94
+ onChange: onChange,
95
+ onBlur: onBlur
96
+ })),
97
+ getByRole = _render2.getByRole,
98
+ getAllByRole = _render2.getAllByRole;
99
+
100
+ var radioGroup = getByRole("radiogroup");
101
+ expect(radioGroup.getAttribute("aria-required")).toBe("true");
102
+
103
+ _react2.fireEvent.focus(radioGroup);
104
+
105
+ _react2.fireEvent.blur(radioGroup);
106
+
107
+ expect(onBlur).toHaveBeenCalled();
108
+ expect(onBlur).toHaveBeenCalledWith({
109
+ value: "",
110
+ error: "This field is required. Please, choose an option."
111
+ });
112
+
113
+ _userEvent["default"].click(getAllByRole("radio")[0]);
114
+
115
+ expect(onChange).toHaveBeenCalled();
116
+ expect(onChange).toHaveBeenCalledWith("1");
117
+ });
118
+ test("Controlled - Optional constraint", function () {
119
+ var onChange = jest.fn();
120
+ var onBlur = jest.fn();
121
+
122
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
123
+ label: "test-radio-group-label",
124
+ helperText: "test-radio-group-helper-text",
125
+ options: single_options,
126
+ onChange: onChange,
127
+ onBlur: onBlur,
128
+ optional: true
129
+ })),
130
+ getByRole = _render3.getByRole;
131
+
132
+ var radioGroup = getByRole("radiogroup");
133
+ expect(radioGroup.getAttribute("aria-required")).toBe("false");
134
+
135
+ _react2.fireEvent.focus(radioGroup);
136
+
137
+ _react2.fireEvent.blur(radioGroup);
138
+
139
+ expect(onBlur).toHaveBeenCalled();
140
+ expect(onBlur).toHaveBeenCalledWith({});
141
+ expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
142
+ });
143
+ test("Select an option - Click on radio input label", function () {
144
+ var onChange = jest.fn();
145
+
146
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
147
+ label: "test-radio-group-label",
148
+ helperText: "test-radio-group-helper-text",
149
+ options: single_options,
150
+ onChange: onChange
151
+ })),
152
+ getByText = _render4.getByText,
153
+ getAllByRole = _render4.getAllByRole;
154
+
155
+ var radio = getByText("Option 10");
156
+
157
+ _userEvent["default"].click(radio);
158
+
159
+ expect(onChange).toHaveBeenCalled();
160
+ expect(onChange).toHaveBeenCalledWith("10");
161
+ expect(getAllByRole("radio")[9].getAttribute("aria-checked")).toBe("true");
162
+ });
163
+ test("Select an option - Click on radio input", function () {
164
+ var onChange = jest.fn();
165
+
166
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
167
+ label: "test-radio-group-label",
168
+ helperText: "test-radio-group-helper-text",
169
+ options: single_options,
170
+ onChange: onChange
171
+ })),
172
+ getAllByRole = _render5.getAllByRole;
173
+
174
+ var radio = getAllByRole("radio")[6];
175
+
176
+ _userEvent["default"].click(radio);
177
+
178
+ expect(onChange).toHaveBeenCalled();
179
+ expect(onChange).toHaveBeenCalledWith("7");
180
+ expect(radio.getAttribute("aria-checked")).toBe("true");
181
+ });
182
+ test("Select an option - Tab and Enter key", function () {
183
+ var onChange = jest.fn();
184
+
185
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
186
+ label: "test-radio-group-label",
187
+ helperText: "test-radio-group-helper-text",
188
+ options: single_options,
189
+ onChange: onChange
190
+ })),
191
+ getByRole = _render6.getByRole,
192
+ getAllByRole = _render6.getAllByRole;
193
+
194
+ var radioGroup = getByRole("radiogroup");
195
+ var radio = getAllByRole("radio")[0];
196
+
197
+ _react2.fireEvent.keyDown(radioGroup, {
198
+ key: "Tab",
199
+ code: "Tab",
200
+ keyCode: 9,
201
+ charCode: 9
202
+ });
203
+
204
+ _react2.fireEvent.keyDown(radioGroup, {
205
+ key: "Enter",
206
+ code: "Enter",
207
+ keyCode: 13,
208
+ charCode: 13
209
+ });
210
+
211
+ expect(onChange).toHaveBeenCalled();
212
+ expect(onChange).toHaveBeenCalledWith("1");
213
+ expect(radio.getAttribute("aria-checked")).toBe("true");
214
+ });
215
+ test("Select an option - Tab and Space key", function () {
216
+ var onChange = jest.fn();
217
+
218
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_RadioGroup["default"], {
219
+ label: "test-radio-group-label",
220
+ helperText: "test-radio-group-helper-text",
221
+ options: single_options,
222
+ onChange: onChange
223
+ })),
224
+ getByRole = _render7.getByRole,
225
+ getAllByRole = _render7.getAllByRole;
226
+
227
+ var radioGroup = getByRole("radiogroup");
228
+ var radio = getAllByRole("radio")[0];
229
+
230
+ _react2.fireEvent.keyDown(radioGroup, {
231
+ key: "Tab",
232
+ code: "Tab",
233
+ keyCode: 9,
234
+ charCode: 9
235
+ });
236
+
237
+ _react2.fireEvent.keyDown(radioGroup, {
238
+ key: "Space",
239
+ code: "Space",
240
+ keyCode: 32,
241
+ charCode: 32
242
+ });
243
+
244
+ expect(onChange).toHaveBeenCalled();
245
+ expect(onChange).toHaveBeenCalledWith("1");
246
+ expect(radio.getAttribute("aria-checked")).toBe("true");
247
+ });
248
+ });
@@ -0,0 +1,36 @@
1
+ export declare type Option = {
2
+ value: string;
3
+ label: string;
4
+ disabled?: boolean;
5
+ };
6
+ declare type RadioGroupProps = {
7
+ label: string;
8
+ name?: string;
9
+ helperText?: string;
10
+ options: Option[];
11
+ disabled?: boolean;
12
+ optional?: boolean;
13
+ optionalItemLabel?: string;
14
+ readonly?: boolean;
15
+ stacking?: "row" | "column";
16
+ defaultValue?: string;
17
+ value?: string;
18
+ onChange?: (value?: string) => void;
19
+ onBlur?: (val: {
20
+ value?: string;
21
+ error?: string;
22
+ }) => void;
23
+ error?: string;
24
+ };
25
+ export declare type RefType = HTMLDivElement;
26
+ export declare type RadioProps = {
27
+ option: Option;
28
+ currentValue?: string;
29
+ onClick: () => void;
30
+ onFocus: () => void;
31
+ error?: string;
32
+ disabled: boolean;
33
+ focused: boolean;
34
+ readonly: boolean;
35
+ };
36
+ export default RadioGroupProps;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -227,7 +227,7 @@ var TitleDiv = _styledComponents["default"].div(_templateObject5 || (_templateOb
227
227
 
228
228
  var TableHeader = _styledComponents["default"].th(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])([""])));
229
229
 
230
- var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: 100%;\n"])), function (props) {
230
+ var HeaderContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: ", ";\n width: 100%;\n :focus {\n outline: #0095ff auto 1px;\n }\n"])), function (props) {
231
231
  return props.theme.headerTextAlign === "center" ? "center" : props.theme.headerTextAlign === "right" ? "flex-end" : "flex-start";
232
232
  });
233
233
 
@@ -10,14 +10,12 @@ export default {
10
10
  component: DxcResultsetTable,
11
11
  };
12
12
 
13
- const deleteIcon = () => {
14
- return (
15
- <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
16
- <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
17
- <path d="M0 0h24v24H0z" fill="none" />
18
- </svg>
19
- );
20
- };
13
+ const deleteIcon = (
14
+ <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
15
+ <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
16
+ <path d="M0 0h24v24H0z" fill="none" />
17
+ </svg>
18
+ );
21
19
 
22
20
  const columns = [{ displayValue: "Id" }, { displayValue: "Name" }, { displayValue: "City" }];
23
21
 
@@ -216,6 +214,7 @@ export const Chromatic = () => (
216
214
  <ExampleContainer>
217
215
  <Title title="Xxlarge" theme="light" level={4} />
218
216
  <DxcResultsetTable columns={columns} rows={rows} margin={"xxlarge"}></DxcResultsetTable>
217
+ <hr />
219
218
  </ExampleContainer>
220
219
  </>
221
220
  );
package/row/Row.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- import React from "react";
2
- declare type RowProps = {
3
- gutter?: "none" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
4
- align?: "start" | "center" | "end" | "baseline" | "stretch";
5
- justify?: "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
6
- wrap?: boolean;
7
- reverse?: boolean;
8
- children: React.ReactNode;
9
- };
10
- export default function Row({ gutter, align, justify, wrap, reverse, children }: RowProps): JSX.Element;
11
- export {};
1
+ /// <reference types="react" />
2
+ import RowPropsType from "./types";
3
+ export default function Row({ gutter, align, justify, wrap, reverse, children, }: RowPropsType): JSX.Element;
package/row/Row.js CHANGED
@@ -34,7 +34,7 @@ function Row(_ref) {
34
34
  }, children);
35
35
  }
36
36
 
37
- var StyledRow = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n flex-wrap: ", ";\n align-items: ", "};\n justify-content: ", ";\n gap: ", ";\n"])), function (_ref2) {
37
+ var StyledRow = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n flex-wrap: ", ";\n align-items: ", ";\n justify-content: ", ";\n gap: ", ";\n"])), function (_ref2) {
38
38
  var reverse = _ref2.reverse;
39
39
  return reverse ? "row-reverse" : "row";
40
40
  }, function (_ref3) {
@@ -94,30 +94,33 @@ var StyledRow = _styledComponents["default"].div(_templateObject || (_templateOb
94
94
  case "none":
95
95
  return "0";
96
96
 
97
- case "xxsmall":
97
+ case "xxxsmall":
98
98
  return "0.125rem";
99
99
 
100
- case "xsmall":
100
+ case "xxsmall":
101
101
  return "0.25rem";
102
102
 
103
- case "small":
103
+ case "xsmall":
104
104
  return "0.5rem";
105
105
 
106
- case "medium":
106
+ case "small":
107
107
  return "1rem";
108
108
 
109
- case "large":
109
+ case "medium":
110
110
  return "1.5rem";
111
111
 
112
- case "xlarge":
112
+ case "large":
113
113
  return "2rem";
114
114
 
115
- case "xxlarge":
115
+ case "xlarge":
116
116
  return "3rem";
117
117
 
118
- case "xxxlarge":
118
+ case "xxlarge":
119
119
  return "4rem";
120
120
 
121
+ case "xxxlarge":
122
+ return "5rem";
123
+
121
124
  default:
122
125
  return "0";
123
126
  }
@@ -106,6 +106,14 @@ export const Chromatic = () => (
106
106
  <Placeholder paddingTop={60}></Placeholder>
107
107
  </DxcRow>
108
108
  </Container>
109
+ <Title title="gutter = xxxsmall" theme="light" level={4} />
110
+ <Container>
111
+ <DxcRow gutter="xxxsmall">
112
+ <Placeholder></Placeholder>
113
+ <Placeholder></Placeholder>
114
+ <Placeholder></Placeholder>
115
+ </DxcRow>
116
+ </Container>
109
117
  <Title title="gutter = xxsmall" theme="light" level={4} />
110
118
  <Container>
111
119
  <DxcRow gutter="xxsmall">
@@ -162,6 +170,14 @@ export const Chromatic = () => (
162
170
  <Placeholder></Placeholder>
163
171
  </DxcRow>
164
172
  </Container>
173
+ <Title title="gutter = xxxlarge" theme="light" level={4} />
174
+ <Container>
175
+ <DxcRow gutter="xxxlarge">
176
+ <Placeholder></Placeholder>
177
+ <Placeholder></Placeholder>
178
+ <Placeholder></Placeholder>
179
+ </DxcRow>
180
+ </Container>
165
181
  <Title title="gutter = none" theme="light" level={4} />
166
182
  <Container>
167
183
  <DxcRow gutter="none">
@@ -206,18 +222,16 @@ export const Chromatic = () => (
206
222
  );
207
223
 
208
224
  const Container = styled.div`
209
- background: #d0d0d0;
225
+ background: #f2eafa;
210
226
  padding: 10px;
211
- border-radius: 10px;
212
227
  width: ${({ width }) => (width ? `${width}px` : "unset")};
213
228
  `;
214
229
 
215
230
  const Placeholder = styled.div`
216
- min-height: 80px;
231
+ min-height: 40px;
217
232
  min-width: 120px;
218
- border: 1px solid #fabada;
219
- background-color: #fff7fb;
220
- border-radius: 5px;
233
+ border: 1px solid #a46ede;
234
+ background-color: #e5d5f6;
221
235
  padding-top: ${({ paddingTop }) => `${paddingTop ?? 0}px`};
222
236
  padding-bottom: ${({ paddingBottom }) => `${paddingBottom ?? 0}px`};
223
237
  `;
package/row/types.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ gutter?: "none" | "xxxsmall" | "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "xxxlarge";
4
+ align?: "start" | "center" | "end" | "baseline" | "stretch";
5
+ justify?: "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
6
+ wrap?: boolean;
7
+ reverse?: boolean;
8
+ children: React.ReactNode;
9
+ };
10
+ export default Props;
package/row/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import SelectPropsType from "./types";
3
+ declare const DxcSelect: React.ForwardRefExoticComponent<SelectPropsType & React.RefAttributes<HTMLDivElement>>;
4
+ export default DxcSelect;
package/select/Select.js CHANGED
@@ -153,7 +153,7 @@ var getLastOptionIndex = function getLastOptionIndex(options, filteredOptions, s
153
153
 
154
154
  var getSelectedOption = function getSelectedOption(options, multiple, optional, optionalEmptyOption, value, innerValue) {
155
155
  var val = value !== null && value !== void 0 ? value : innerValue;
156
- var selectedOption = multiple ? [] : "";
156
+ var selectedOption = multiple ? [] : {};
157
157
  var singleSelectionIndex;
158
158
 
159
159
  if (multiple) {
@@ -583,8 +583,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
583
583
  },
584
584
  onClick: handleClearOptionsActionOnClick,
585
585
  tabIndex: -1,
586
- title: "Clear selected options",
587
- "aria-label": "Clear selected options"
586
+ title: "Clear selection",
587
+ "aria-label": "Clear selection"
588
588
  }, selectIcons.clear)), /*#__PURE__*/_react["default"].createElement(SearchableValueContainer, null, /*#__PURE__*/_react["default"].createElement(ValueInput, {
589
589
  name: name,
590
590
  value: multiple ? (value !== null && value !== void 0 ? value : innerValue).join(", ") : value !== null && value !== void 0 ? value : innerValue,
@@ -613,8 +613,8 @@ var DxcSelect = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
613
613
  },
614
614
  onClick: handleClearSearchActionOnClick,
615
615
  tabIndex: -1,
616
- title: "Clear search text",
617
- "aria-label": "Clear search text"
616
+ title: "Clear search",
617
+ "aria-label": "Clear search"
618
618
  }, selectIcons.clear), /*#__PURE__*/_react["default"].createElement(CollapseIndicator, {
619
619
  disabled: disabled
620
620
  }, isOpen ? selectIcons.arrowUp : selectIcons.arrowDown), isOpen && /*#__PURE__*/_react["default"].createElement(OptionsList, {
@@ -0,0 +1,170 @@
1
+ /// <reference types="react" />
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Margin = {
4
+ top?: Space;
5
+ bottom?: Space;
6
+ left?: Space;
7
+ right?: Space;
8
+ };
9
+ declare type SVG = React.SVGProps<SVGSVGElement>;
10
+ declare type OptionGroup = {
11
+ /**
12
+ * Label of the group to be shown in the select's listbox.
13
+ */
14
+ label: string;
15
+ /**
16
+ * List of the grouped options.
17
+ */
18
+ options: Option[];
19
+ };
20
+ declare type Option = {
21
+ /**
22
+ * Element used as the icon that will be placed before the option label.
23
+ * It can be a url of an image or an inline SVG. If the url option
24
+ * is the chosen one, take into account that the component's
25
+ * color styling tokens will not be applied to the image.
26
+ */
27
+ icon?: string | SVG;
28
+ /**
29
+ * Label of the option to be shown in the select's listbox.
30
+ */
31
+ label: string;
32
+ /**
33
+ * Value of the option. It should be unique and
34
+ * not an empty string, which is reserved to the empty option added
35
+ * by optional prop.
36
+ */
37
+ value: string;
38
+ };
39
+ declare type CommonProps = {
40
+ /**
41
+ * Text to be placed above the select.
42
+ */
43
+ label?: string;
44
+ /**
45
+ * Name attribute of the input element. This attribute will allow users
46
+ * to find the component's value during the submit event. In this event,
47
+ * the component's value will always be a regular string, for both single
48
+ * and multiple selection modes, been in the first one a single option
49
+ * value and in the multiple variant more than one option value,
50
+ * separated by commas.
51
+ */
52
+ name?: string;
53
+ /**
54
+ * An array of objects representing the selectable options.
55
+ */
56
+ options?: Option[] | OptionGroup[];
57
+ /**
58
+ * Helper text to be placed above the select.
59
+ */
60
+ helperText?: string;
61
+ /**
62
+ * Text to be put as placeholder of the select.
63
+ */
64
+ placeholder?: string;
65
+ /**
66
+ * If true, the component will be disabled.
67
+ */
68
+ disabled?: boolean;
69
+ /**
70
+ * If true, the select will be optional, showing '(Optional)'
71
+ * next to the label and adding a default first option with an empty string as value,
72
+ * been the placeholder (if defined) its label. Otherwise, the field will be
73
+ * considered required and an error will be passed as a parameter to the
74
+ * OnBlur and onChange functions if an option wasn't selected.
75
+ */
76
+ optional?: boolean;
77
+ /**
78
+ * If true, enables search functionality.
79
+ */
80
+ searchable?: boolean;
81
+ /**
82
+ * If it is defined, the component will change its appearance, showing
83
+ * the error below the select component. If it is not defined, the error
84
+ * messages will be managed internally, but never displayed on its own.
85
+ */
86
+ error?: string;
87
+ /**
88
+ * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
89
+ * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
90
+ */
91
+ margin?: Space | Margin;
92
+ /**
93
+ * Size of the component.
94
+ */
95
+ size?: "small" | "medium" | "large" | "fillParent";
96
+ /**
97
+ * Value of the tabindex attribute.
98
+ */
99
+ tabIndex?: number;
100
+ };
101
+ declare type SingleSelect = CommonProps & {
102
+ /**
103
+ * If true, the select component will support multiple selected options.
104
+ * In that case, value will be an array of strings with each selected
105
+ * option value.
106
+ */
107
+ multiple?: false;
108
+ /**
109
+ * Value of the select. If undefined, the component will be uncontrolled
110
+ * and the value will be managed internally by the component.
111
+ */
112
+ value?: string;
113
+ /**
114
+ * This function will be called when the user selects an option.
115
+ * An object including the current value and the error (if the value entered is not valid)
116
+ * will be passed to this function. If there is no error, error will be null.
117
+ */
118
+ onChange?: (val: {
119
+ value: string;
120
+ error: string;
121
+ }) => void;
122
+ /**
123
+ * This function will be called when the select loses the focus. An
124
+ * object including the value and the error (if the value
125
+ * selected is not valid) will be passed to this function. If there is no error,
126
+ * error will be null.
127
+ */
128
+ onBlur?: (val: {
129
+ value: string;
130
+ error: string;
131
+ }) => void;
132
+ };
133
+ declare type MultipleSelect = CommonProps & {
134
+ /**
135
+ * If true, the select component will support multiple selected options.
136
+ * In that case, value will be an array of strings with each selected
137
+ * option value.
138
+ */
139
+ multiple: true;
140
+ /**
141
+ * Value of the select. If undefined, the component will be uncontrolled
142
+ * and the value will be managed internally by the component.
143
+ */
144
+ value?: string[];
145
+ /**
146
+ * This function will be called when the user selects an option.
147
+ * An object including the current selected values and the error (if the value entered is not valid)
148
+ * will be passed to this function. If there is no error, error will be null.
149
+ */
150
+ onChange?: (val: {
151
+ value: string[];
152
+ error: string;
153
+ }) => void;
154
+ /**
155
+ * This function will be called when the select loses the focus. An
156
+ * object including the selected values and the error (if the value
157
+ * selected is not valid) will be passed to this function. If there is no error,
158
+ * error will be null.
159
+ */
160
+ onBlur?: (val: {
161
+ value: string[];
162
+ error: string;
163
+ }) => void;
164
+ };
165
+ declare type Props = SingleSelect | MultipleSelect;
166
+ /**
167
+ * Reference to the component.
168
+ */
169
+ export declare type RefType = HTMLDivElement;
170
+ export default Props;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });