@dxc-technology/halstack-react 0.0.0-5aa300b → 0.0.0-5b43b04

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 (59) hide show
  1. package/HalstackContext.js +86 -45
  2. package/accordion/Accordion.stories.tsx +51 -2
  3. package/alert/Alert.stories.tsx +28 -0
  4. package/box/Box.stories.tsx +15 -0
  5. package/button/Button.stories.tsx +100 -9
  6. package/checkbox/Checkbox.stories.tsx +52 -0
  7. package/chip/Chip.js +8 -2
  8. package/chip/Chip.stories.tsx +55 -0
  9. package/common/variables.js +163 -137
  10. package/date-input/Calendar.d.ts +1 -1
  11. package/date-input/Calendar.js +43 -43
  12. package/date-input/DateInput.js +74 -32
  13. package/date-input/DateInput.stories.tsx +183 -30
  14. package/date-input/DateInput.test.js +120 -37
  15. package/date-input/DatePicker.js +38 -52
  16. package/date-input/Icons.d.ts +6 -0
  17. package/date-input/Icons.js +75 -0
  18. package/date-input/YearPicker.d.ts +1 -1
  19. package/date-input/YearPicker.js +23 -12
  20. package/date-input/types.d.ts +6 -8
  21. package/dialog/Dialog.js +1 -3
  22. package/dialog/Dialog.stories.tsx +42 -20
  23. package/dropdown/Dropdown.js +0 -1
  24. package/dropdown/Dropdown.stories.tsx +200 -82
  25. package/dropdown/DropdownMenu.js +8 -18
  26. package/dropdown/DropdownMenuItem.js +4 -15
  27. package/file-input/FileInput.stories.tsx +85 -2
  28. package/footer/Footer.stories.tsx +91 -0
  29. package/header/Header.js +18 -20
  30. package/header/Header.stories.tsx +149 -6
  31. package/link/Link.stories.tsx +60 -0
  32. package/package.json +1 -1
  33. package/paginator/Paginator.stories.tsx +24 -0
  34. package/paginator/Paginator.test.js +17 -10
  35. package/progress-bar/ProgressBar.js +4 -4
  36. package/progress-bar/ProgressBar.stories.jsx +35 -2
  37. package/quick-nav/QuickNav.stories.tsx +14 -0
  38. package/radio-group/RadioGroup.stories.tsx +131 -18
  39. package/resultsetTable/ResultsetTable.test.js +17 -22
  40. package/select/Listbox.d.ts +1 -1
  41. package/select/Listbox.js +5 -34
  42. package/select/Option.js +3 -14
  43. package/select/Select.js +43 -24
  44. package/select/Select.stories.tsx +475 -187
  45. package/select/Select.test.js +17 -22
  46. package/select/types.d.ts +2 -2
  47. package/sidenav/Sidenav.stories.tsx +93 -0
  48. package/slider/Slider.stories.tsx +57 -0
  49. package/spinner/Spinner.stories.jsx +27 -1
  50. package/switch/Switch.stories.tsx +33 -0
  51. package/table/Table.stories.jsx +80 -1
  52. package/tabs/Tabs.stories.tsx +38 -0
  53. package/tabs-nav/NavTabs.js +1 -1
  54. package/tabs-nav/Tab.js +30 -9
  55. package/tag/Tag.stories.tsx +14 -1
  56. package/text-input/TextInput.stories.tsx +69 -0
  57. package/textarea/Textarea.stories.jsx +60 -1
  58. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  59. package/wizard/Wizard.stories.tsx +20 -0
@@ -132,16 +132,10 @@ export declare type CalendarPropsType = {
132
132
  * Function called when a date is selected.
133
133
  */
134
134
  onDaySelect: (date: Dayjs) => void;
135
- };
136
- export declare type MonthPickerPropsType = {
137
135
  /**
138
- * Initial selected date value. If invalid the actual date will be used instead.
136
+ * Current date
139
137
  */
140
- selectedDate: Dayjs;
141
- /**
142
- * Function called when a month is selected.
143
- */
144
- onMonthSelect: (month: number) => void;
138
+ today: Dayjs;
145
139
  };
146
140
  export declare type YearPickerPropsType = {
147
141
  /**
@@ -152,6 +146,10 @@ export declare type YearPickerPropsType = {
152
146
  * Function called when a year is selected.
153
147
  */
154
148
  onYearSelect: (year: number) => void;
149
+ /**
150
+ * Current date
151
+ */
152
+ today: Dayjs;
155
153
  };
156
154
  /**
157
155
  * Reference to the component.
package/dialog/Dialog.js CHANGED
@@ -102,10 +102,8 @@ var BodyStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_te
102
102
 
103
103
  var DialogContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0px;\n height: 100%;\n z-index: 1300;\n"])));
104
104
 
105
- var Overlay = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n position: fixed;\n inset: 0px;\n height: 100%;\n background-color: ", ";\n opacity: ", ";\n"])), function (props) {
105
+ var Overlay = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n position: fixed;\n inset: 0px;\n height: 100%;\n background-color: ", ";\n"])), function (props) {
106
106
  return props.theme.overlayColor;
107
- }, function (props) {
108
- return props.theme.overlayOpacity;
109
107
  });
110
108
 
111
109
  var Dialog = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n z-index: 1300;\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n ", "\n box-sizing: border-box;\n box-shadow: ", ";\n border-radius: 4px;\n position: relative;\n\n @media (min-width: ", "rem) {\n max-width: 80%;\n min-width: 800px;\n }\n\n @media (max-width: ", "rem) {\n //mobile phones\n max-width: 92%;\n min-width: 92%;\n }\n"])), function (props) {
@@ -6,18 +6,26 @@ import DxcFlex from "../flex/Flex";
6
6
  import DxcInset from "../inset/Inset";
7
7
  import Title from "../../.storybook/components/Title";
8
8
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
9
+ import { HalstackProvider } from "../HalstackContext";
9
10
 
10
11
  export default {
11
12
  title: "Dialog ",
12
13
  component: DxcDialog,
13
14
  };
14
15
 
16
+ const opinionatedTheme = {
17
+ dialog: {
18
+ baseColor: "#ffffff",
19
+ closeIconColor: "#000000",
20
+ overlayColor: "#000000b3",
21
+ },
22
+ };
23
+
15
24
  export const DefaultDialog = () => (
16
25
  <>
17
26
  <ExampleContainer expanded={true}>
18
27
  <Title title="Default dialog" theme="light" level={4} />
19
28
  <DxcDialog>
20
- {" "}
21
29
  <p>
22
30
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
23
31
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -28,12 +36,35 @@ export const DefaultDialog = () => (
28
36
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
29
37
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
30
38
  dignissim, pharetra neque molestie, molestie lectus.
31
- </p>{" "}
39
+ </p>
32
40
  </DxcDialog>
33
41
  </ExampleContainer>
34
42
  </>
35
43
  );
36
44
 
45
+ export const DefaultDialogOpinionated = () => (
46
+ <>
47
+ <ExampleContainer expanded={true}>
48
+ <Title title="Default dialog" theme="light" level={4} />
49
+ <HalstackProvider theme={opinionatedTheme}>
50
+ <DxcDialog>
51
+ <p>
52
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
53
+ placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
54
+ elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
55
+ tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
56
+ eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue
57
+ gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare,
58
+ malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam
59
+ sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo.
60
+ Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus.
61
+ </p>
62
+ </DxcDialog>
63
+ </HalstackProvider>
64
+ </ExampleContainer>
65
+ </>
66
+ );
67
+
37
68
  export const DialogWithInputs = () => (
38
69
  <>
39
70
  <ExampleContainer expanded={true}>
@@ -82,7 +113,6 @@ export const DialogWithoutOverlay = () => (
82
113
  <ExampleContainer expanded={true}>
83
114
  <Title title="Dialog Without Overlay" theme="light" level={4} />
84
115
  <DxcDialog overlay={false}>
85
- {" "}
86
116
  <p>
87
117
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
88
118
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -93,7 +123,7 @@ export const DialogWithoutOverlay = () => (
93
123
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
94
124
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
95
125
  dignissim, pharetra neque molestie, molestie lectus.
96
- </p>{" "}
126
+ </p>
97
127
  </DxcDialog>
98
128
  </ExampleContainer>
99
129
  );
@@ -102,7 +132,6 @@ export const DialogCloseVisibleFalse = () => (
102
132
  <ExampleContainer expanded={true}>
103
133
  <Title title="Dialog Close Visible" theme="dark" level={4} />
104
134
  <DxcDialog isCloseVisible={false}>
105
- {" "}
106
135
  <p>
107
136
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
108
137
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -113,7 +142,7 @@ export const DialogCloseVisibleFalse = () => (
113
142
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
114
143
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
115
144
  dignissim, pharetra neque molestie, molestie lectus.
116
- </p>{" "}
145
+ </p>
117
146
  </DxcDialog>
118
147
  </ExampleContainer>
119
148
  );
@@ -122,7 +151,6 @@ export const DialogWithXxsmallPadding = () => (
122
151
  <ExampleContainer expanded={true}>
123
152
  <Title title="Dialog With Xxsmall Padding" theme="light" level={4} />
124
153
  <DxcDialog padding={"xxsmall"}>
125
- {" "}
126
154
  <p>
127
155
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
128
156
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -133,7 +161,7 @@ export const DialogWithXxsmallPadding = () => (
133
161
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
134
162
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
135
163
  dignissim, pharetra neque molestie, molestie lectus.
136
- </p>{" "}
164
+ </p>
137
165
  </DxcDialog>
138
166
  </ExampleContainer>
139
167
  );
@@ -142,7 +170,6 @@ export const DialogWithXsmallPadding = () => (
142
170
  <ExampleContainer expanded={true}>
143
171
  <Title title="Dialog With Xsmall Padding" theme="light" level={4} />
144
172
  <DxcDialog padding={"xsmall"}>
145
- {" "}
146
173
  <p>
147
174
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
148
175
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -153,7 +180,7 @@ export const DialogWithXsmallPadding = () => (
153
180
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
154
181
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
155
182
  dignissim, pharetra neque molestie, molestie lectus.
156
- </p>{" "}
183
+ </p>
157
184
  </DxcDialog>
158
185
  </ExampleContainer>
159
186
  );
@@ -162,7 +189,6 @@ export const DialogWithSmallPadding = () => (
162
189
  <ExampleContainer expanded={true}>
163
190
  <Title title="Dialog With Small Padding" theme="light" level={4} />
164
191
  <DxcDialog padding={"small"}>
165
- {" "}
166
192
  <p>
167
193
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
168
194
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -173,7 +199,7 @@ export const DialogWithSmallPadding = () => (
173
199
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
174
200
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
175
201
  dignissim, pharetra neque molestie, molestie lectus.
176
- </p>{" "}
202
+ </p>
177
203
  </DxcDialog>
178
204
  </ExampleContainer>
179
205
  );
@@ -182,7 +208,6 @@ export const DialogWithMediumPadding = () => (
182
208
  <ExampleContainer expanded={true}>
183
209
  <Title title="Dialog With Medium Padding" theme="light" level={4} />
184
210
  <DxcDialog padding={"medium"}>
185
- {" "}
186
211
  <p>
187
212
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
188
213
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -193,7 +218,7 @@ export const DialogWithMediumPadding = () => (
193
218
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
194
219
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
195
220
  dignissim, pharetra neque molestie, molestie lectus.
196
- </p>{" "}
221
+ </p>
197
222
  </DxcDialog>
198
223
  </ExampleContainer>
199
224
  );
@@ -202,7 +227,6 @@ export const DialogWithLargePadding = () => (
202
227
  <ExampleContainer expanded={true}>
203
228
  <Title title="Dialog With Large Padding" theme="light" level={4} />
204
229
  <DxcDialog padding={"large"}>
205
- {" "}
206
230
  <p>
207
231
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
208
232
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -213,7 +237,7 @@ export const DialogWithLargePadding = () => (
213
237
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
214
238
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
215
239
  dignissim, pharetra neque molestie, molestie lectus.
216
- </p>{" "}
240
+ </p>
217
241
  </DxcDialog>
218
242
  </ExampleContainer>
219
243
  );
@@ -222,7 +246,6 @@ export const DialogWithXlargePadding = () => (
222
246
  <ExampleContainer expanded={true}>
223
247
  <Title title="Dialog With Xlarge Padding" theme="light" level={4} />
224
248
  <DxcDialog padding={"xlarge"}>
225
- {" "}
226
249
  <p>
227
250
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
228
251
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -233,7 +256,7 @@ export const DialogWithXlargePadding = () => (
233
256
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
234
257
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
235
258
  dignissim, pharetra neque molestie, molestie lectus.
236
- </p>{" "}
259
+ </p>
237
260
  </DxcDialog>
238
261
  </ExampleContainer>
239
262
  );
@@ -242,7 +265,6 @@ export const DialogWithXxlargePadding = () => (
242
265
  <ExampleContainer expanded={true}>
243
266
  <Title title="Dialog With Xxlarge Padding" theme="light" level={4} />
244
267
  <DxcDialog padding={"xxlarge"}>
245
- {" "}
246
268
  <p>
247
269
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
248
270
  placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
@@ -253,7 +275,7 @@ export const DialogWithXxlargePadding = () => (
253
275
  fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus
254
276
  augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc
255
277
  dignissim, pharetra neque molestie, molestie lectus.
256
- </p>{" "}
278
+ </p>
257
279
  </DxcDialog>
258
280
  </ExampleContainer>
259
281
  );
@@ -258,7 +258,6 @@ var DxcDropdown = function DxcDropdown(_ref) {
258
258
  asChild: true,
259
259
  type: undefined
260
260
  }, /*#__PURE__*/_react["default"].createElement(DropdownTrigger, {
261
- opened: isOpen,
262
261
  onClick: handleTriggerOnClick,
263
262
  onKeyDown: handleTriggerOnKeyDown,
264
263
  onBlur: function onBlur(event) {
@@ -4,9 +4,11 @@ import DxcDropdown from "./Dropdown";
4
4
  import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
6
  import DropdownMenu from "./DropdownMenu";
7
- import DxcCheckbox from "../checkbox/Checkbox";
8
- import DxcTextInput from "../text-input/TextInput";
9
7
  import { Option } from "./types";
8
+ import useTheme from "../useTheme";
9
+ import DxcFlex from "../flex/Flex";
10
+ import { HalstackProvider } from "../HalstackContext";
11
+ import { ThemeProvider } from "styled-components";
10
12
 
11
13
  export default {
12
14
  title: "Dropdown",
@@ -19,20 +21,14 @@ const hamburguerIcon = (
19
21
  </svg>
20
22
  );
21
23
  const iconSVG = (
22
- <svg viewBox="0 0 24 24" fill="currentColor">
24
+ <svg viewBox="0 0 24 24" height="24" width="24" fill="currentColor">
23
25
  <path d="M0 0h24v24H0z" fill="none" />
24
26
  <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
25
27
  </svg>
26
28
  );
27
29
  const iconSVGLarge = (
28
- <svg enableBackground="new 0 0 24 24" height="48" viewBox="0 0 24 24" width="48" fill="currentColor">
29
- <g>
30
- <path d="M0,0h24v24H0V0z" fill="none" />
31
- <path d="M0,0h24v24H0V0z" fill="none" />
32
- </g>
33
- <g>
34
- <path d="M12,17.27L18.18,21l-1.64-7.03L22,9.24l-7.19-0.61L12,2L9.19,8.63L2,9.24l5.46,4.73L5.82,21L12,17.27z" />
35
- </g>
30
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" height="48" width="48">
31
+ <path d="M11 44q-1.2 0-2.1-.9Q8 42.2 8 41V15q0-1.2.9-2.1.9-.9 2.1-.9h5.5v-.5q0-3.15 2.175-5.325Q20.85 4 24 4q3.15 0 5.325 2.175Q31.5 8.35 31.5 11.5v.5H37q1.2 0 2.1.9.9.9.9 2.1v26q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h26V15h-5.5v4.5q0 .65-.425 1.075Q30.65 21 30 21q-.65 0-1.075-.425-.425-.425-.425-1.075V15h-9v4.5q0 .65-.425 1.075Q18.65 21 18 21q-.65 0-1.075-.425-.425-.425-.425-1.075V15H11v26Zm8.5-29h9v-.5q0-1.9-1.3-3.2Q25.9 7 24 7q-1.9 0-3.2 1.3-1.3 1.3-1.3 3.2ZM11 41V15v26Z" />
36
32
  </svg>
37
33
  );
38
34
  const iconUrl = "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png";
@@ -59,6 +55,18 @@ const defaultOptions: Option[] = [
59
55
  value: "5",
60
56
  label: "Aliexpress",
61
57
  },
58
+ {
59
+ value: "6",
60
+ label: "Etsy",
61
+ },
62
+ {
63
+ value: "7",
64
+ label: "Alibaba",
65
+ },
66
+ {
67
+ value: "8",
68
+ label: "Gearbest shop",
69
+ },
62
70
  ];
63
71
  const options: Option[] = [
64
72
  {
@@ -84,7 +92,15 @@ const optionWithIcon: Option[] = [
84
92
 
85
93
  const optionsIcon: any = options.map((op, i) => ({ ...op, icon: icons[i] }));
86
94
 
87
- export const Chromatic = () => (
95
+ const opinionatedTheme = {
96
+ dropdown: {
97
+ baseColor: "#ffffff",
98
+ fontColor: "#000000",
99
+ optionFontColor: "#000000",
100
+ },
101
+ };
102
+
103
+ const Dropdown = () => (
88
104
  <>
89
105
  <ExampleContainer>
90
106
  <Title title="Default" theme="light" level={4} />
@@ -227,94 +243,196 @@ export const Chromatic = () => (
227
243
  size="fillParent"
228
244
  />
229
245
  </ExampleContainer>
246
+ <ExampleContainer expanded>
247
+ <Title title="Opened menu" theme="light" level={4} />
248
+ <DxcDropdown label="Label" options={options} onSelectOption={(value) => {}} margin={{ top: "xxlarge" }} />
249
+ </ExampleContainer>
230
250
  </>
231
251
  );
232
252
 
233
- const DropdownListStates = () => (
253
+ const DropdownListStates = () => {
254
+ const colorsTheme: any = useTheme();
255
+
256
+ return (
257
+ <>
258
+ <Title title="Dropdown Menu" theme="light" level={2} />
259
+ <ExampleContainer>
260
+ <Title
261
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
262
+ theme="light"
263
+ level={3}
264
+ />
265
+ <div
266
+ style={{
267
+ position: "relative",
268
+ display: "flex",
269
+ flexDirection: "column",
270
+ gap: "20px",
271
+ height: "150px",
272
+ width: "min-content",
273
+ marginBottom: "100px",
274
+ padding: "20px",
275
+ border: "1px solid black",
276
+ borderRadius: "4px",
277
+ overflow: "auto",
278
+ zIndex: "1300",
279
+ }}
280
+ >
281
+ <DxcDropdown
282
+ label="Select a platform"
283
+ options={defaultOptions}
284
+ onSelectOption={(option) => {}}
285
+ size="medium"
286
+ />
287
+ <button style={{ zIndex: "1", width: "100px" }}>Submit</button>
288
+ </div>
289
+ </ExampleContainer>
290
+ <ThemeProvider theme={colorsTheme.dropdown}>
291
+ <Title title="Option states" theme="light" level={3} />
292
+ <ExampleContainer pseudoState="pseudo-hover">
293
+ <Title title="Hovered option" theme="light" level={4} />
294
+ <DropdownMenu
295
+ id="x"
296
+ dropdownTriggerId="dtx"
297
+ iconsPosition="before"
298
+ visualFocusIndex={-1}
299
+ menuItemOnClick={(value) => {}}
300
+ onKeyDown={(e) => {}}
301
+ options={optionWithIcon}
302
+ styles={{ width: 240 }}
303
+ />
304
+ </ExampleContainer>
305
+ <ExampleContainer pseudoState="pseudo-active">
306
+ <Title title="Active option" theme="light" level={4} />
307
+ <DropdownMenu
308
+ id="x"
309
+ dropdownTriggerId="dtx"
310
+ iconsPosition="before"
311
+ visualFocusIndex={-1}
312
+ menuItemOnClick={(value) => {}}
313
+ onKeyDown={(e) => {}}
314
+ options={optionWithIcon}
315
+ styles={{ width: 240 }}
316
+ />
317
+ </ExampleContainer>
318
+ <ExampleContainer>
319
+ <Title title="Focused option" theme="light" level={4} />
320
+ <DropdownMenu
321
+ id="x"
322
+ dropdownTriggerId="dtx"
323
+ iconsPosition="before"
324
+ visualFocusIndex={0}
325
+ menuItemOnClick={(value) => {}}
326
+ onKeyDown={(e) => {}}
327
+ options={options}
328
+ styles={{ width: 240 }}
329
+ />
330
+ </ExampleContainer>
331
+ <Title title="Icons" theme="light" level={3} />
332
+ <ExampleContainer>
333
+ <Title title="Before" theme="light" level={4} />
334
+ <DropdownMenu
335
+ id="x"
336
+ dropdownTriggerId="dtx"
337
+ iconsPosition="before"
338
+ visualFocusIndex={-1}
339
+ menuItemOnClick={(value) => {}}
340
+ onKeyDown={(e) => {}}
341
+ options={optionsIcon}
342
+ styles={{ width: 240 }}
343
+ />
344
+ <Title title="After" theme="light" level={4} />
345
+ <DropdownMenu
346
+ id="x"
347
+ dropdownTriggerId="dtx"
348
+ iconsPosition="after"
349
+ visualFocusIndex={-1}
350
+ menuItemOnClick={(value) => {}}
351
+ onKeyDown={(e) => {}}
352
+ options={optionsIcon}
353
+ styles={{ width: 240 }}
354
+ />
355
+ </ExampleContainer>
356
+ </ThemeProvider>
357
+ </>
358
+ );
359
+ };
360
+
361
+ const DropdownRightAlignment = () => (
362
+ <ExampleContainer expanded>
363
+ <Title title="Dropdown collisions on the right boundary (right)" theme="light" level={4} />
364
+ <DxcFlex justifyContent="flex-end">
365
+ <DxcDropdown label="Label" options={options} onSelectOption={(value) => {}} />
366
+ </DxcFlex>
367
+ </ExampleContainer>
368
+ );
369
+
370
+ const DropdownCenterAlignment = () => (
371
+ <ExampleContainer expanded>
372
+ <Title title="Dropdown collisions on the right boundary (centered)" theme="light" level={4} />
373
+ <DxcFlex justifyContent="flex-end">
374
+ <DxcDropdown label="Label" options={defaultOptions} onSelectOption={(value) => {}} margin="small" />
375
+ </DxcFlex>
376
+ </ExampleContainer>
377
+ );
378
+
379
+ export const Chromatic = Dropdown.bind({});
380
+ Chromatic.play = async ({ canvasElement }) => {
381
+ const canvas = within(canvasElement);
382
+ const buttonList = canvas.getAllByRole("button");
383
+ await userEvent.click(buttonList[buttonList.length - 1]);
384
+ };
385
+
386
+ export const OpinionatedTheme = () => (
234
387
  <>
235
- <Title title="Dropdown Menu" theme="light" level={2} />
236
- <Title title="Default with opened menu" theme="light" level={3} />
388
+ <Title title="Opinionated theme" theme="light" level={2} />
237
389
  <ExampleContainer>
238
- <div style={{ display: "flex", gap: "30px", flexDirection: "column", marginBottom: "80px" }}>
239
- <DxcDropdown label="Select a platform" options={defaultOptions} onSelectOption={(option) => {}} size="medium" />
240
- <DxcTextInput label="Your name" onChange={() => {}} />
241
- <DxcCheckbox
242
- label="You understand the selection and give your consent"
243
- onChange={() => {}}
244
- labelPosition="after"
245
- />
246
- </div>
390
+ <Title title="Default" theme="light" level={4} />
391
+ <HalstackProvider theme={opinionatedTheme}>
392
+ <DxcDropdown label="Default" options={options} onSelectOption={(value) => {}} icon={iconSVG} />
393
+ </HalstackProvider>
247
394
  </ExampleContainer>
248
- <Title title="Option states" theme="light" level={3} />
249
395
  <ExampleContainer pseudoState="pseudo-hover">
250
- <Title title="Hovered option" theme="light" level={4} />
251
- <DropdownMenu
252
- id="x"
253
- dropdownTriggerId="dtx"
254
- iconsPosition="before"
255
- visualFocusIndex={-1}
256
- menuItemOnClick={(value) => {}}
257
- onKeyDown={(e) => {}}
258
- options={optionWithIcon}
259
- styles={{ width: 240 }}
260
- />
396
+ <Title title="Hovered" theme="light" level={4} />
397
+ <HalstackProvider theme={opinionatedTheme}>
398
+ <DxcDropdown label="Hovered" options={options} onSelectOption={(value) => {}} icon={iconSVG} />
399
+ </HalstackProvider>
261
400
  </ExampleContainer>
262
401
  <ExampleContainer pseudoState="pseudo-active">
263
- <Title title="Active option" theme="light" level={4} />
264
- <DropdownMenu
265
- id="x"
266
- dropdownTriggerId="dtx"
267
- iconsPosition="before"
268
- visualFocusIndex={-1}
269
- menuItemOnClick={(value) => {}}
270
- onKeyDown={(e) => {}}
271
- options={optionWithIcon}
272
- styles={{ width: 240 }}
273
- />
402
+ <Title title="Actived" theme="light" level={4} />
403
+ <HalstackProvider theme={opinionatedTheme}>
404
+ <DxcDropdown label="Actived" options={options} onSelectOption={(value) => {}} icon={iconSVG} />
405
+ </HalstackProvider>
274
406
  </ExampleContainer>
275
- <ExampleContainer>
276
- <Title title="Focused option" theme="light" level={4} />
277
- <DropdownMenu
278
- id="x"
279
- dropdownTriggerId="dtx"
280
- iconsPosition="before"
281
- visualFocusIndex={0}
282
- menuItemOnClick={(value) => {}}
283
- onKeyDown={(e) => {}}
284
- options={options}
285
- styles={{ width: 240 }}
286
- />
407
+ <ExampleContainer pseudoState="pseudo-focus">
408
+ <Title title="Focused" theme="light" level={4} />
409
+ <HalstackProvider theme={opinionatedTheme}>
410
+ <DxcDropdown label="Focused" options={options} onSelectOption={(value) => {}} icon={iconSVG} />
411
+ </HalstackProvider>
287
412
  </ExampleContainer>
288
- <Title title="Icons" theme="light" level={3} />
289
413
  <ExampleContainer>
290
- <Title title="Before" theme="light" level={4} />
291
- <DropdownMenu
292
- id="x"
293
- dropdownTriggerId="dtx"
294
- iconsPosition="before"
295
- visualFocusIndex={-1}
296
- menuItemOnClick={(value) => {}}
297
- onKeyDown={(e) => {}}
298
- options={optionsIcon}
299
- styles={{ width: 240 }}
300
- />
301
- <Title title="After" theme="light" level={4} />
302
- <DropdownMenu
303
- id="x"
304
- dropdownTriggerId="dtx"
305
- iconsPosition="after"
306
- visualFocusIndex={-1}
307
- menuItemOnClick={(value) => {}}
308
- onKeyDown={(e) => {}}
309
- options={optionsIcon}
310
- styles={{ width: 240 }}
311
- />
414
+ <Title title="Disabled" theme="light" level={4} />
415
+ <HalstackProvider theme={opinionatedTheme}>
416
+ <DxcDropdown label="Disabled" options={options} onSelectOption={(value) => {}} icon={iconSVG} disabled />
417
+ </HalstackProvider>
312
418
  </ExampleContainer>
313
419
  </>
314
420
  );
315
421
 
316
422
  export const DropdownMenuStates = DropdownListStates.bind({});
317
423
  DropdownMenuStates.play = async ({ canvasElement }) => {
424
+ const canvas = within(canvasElement);
425
+ await userEvent.click(canvas.getAllByRole("button")[0]);
426
+ };
427
+
428
+ export const DropdownMenuAlignedRight = DropdownRightAlignment.bind({});
429
+ DropdownMenuAlignedRight.play = async ({ canvasElement }) => {
430
+ const canvas = within(canvasElement);
431
+ await userEvent.click(canvas.getByRole("button"));
432
+ };
433
+
434
+ export const DropdownMenuAlignedCenter = DropdownCenterAlignment.bind({});
435
+ DropdownMenuAlignedCenter.play = async ({ canvasElement }) => {
318
436
  const canvas = within(canvasElement);
319
437
  await userEvent.click(canvas.getByRole("button"));
320
438
  };