@dxc-technology/halstack-react 7.0.0 → 9.0.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.
Files changed (109) hide show
  1. package/HalstackContext.js +98 -50
  2. package/accordion/Accordion.js +7 -13
  3. package/accordion/Accordion.stories.tsx +102 -13
  4. package/alert/Alert.stories.tsx +28 -0
  5. package/box/Box.js +1 -3
  6. package/box/Box.stories.tsx +15 -0
  7. package/button/Button.js +11 -13
  8. package/button/Button.stories.tsx +150 -8
  9. package/checkbox/Checkbox.d.ts +2 -2
  10. package/checkbox/Checkbox.js +16 -15
  11. package/checkbox/Checkbox.stories.tsx +131 -59
  12. package/checkbox/types.d.ts +4 -0
  13. package/chip/Chip.js +16 -22
  14. package/chip/Chip.stories.tsx +96 -9
  15. package/common/variables.js +286 -290
  16. package/date-input/Calendar.d.ts +4 -0
  17. package/date-input/Calendar.js +258 -0
  18. package/date-input/DateInput.js +134 -237
  19. package/date-input/DateInput.stories.tsx +199 -33
  20. package/date-input/DateInput.test.js +494 -138
  21. package/date-input/DatePicker.d.ts +4 -0
  22. package/date-input/DatePicker.js +146 -0
  23. package/date-input/Icons.d.ts +6 -0
  24. package/date-input/Icons.js +75 -0
  25. package/date-input/YearPicker.d.ts +4 -0
  26. package/date-input/YearPicker.js +126 -0
  27. package/date-input/types.d.ts +51 -0
  28. package/dialog/Dialog.js +60 -73
  29. package/dialog/Dialog.stories.tsx +211 -159
  30. package/dialog/Dialog.test.js +301 -2
  31. package/dropdown/Dropdown.js +35 -35
  32. package/dropdown/Dropdown.stories.tsx +210 -84
  33. package/dropdown/Dropdown.test.js +17 -22
  34. package/dropdown/DropdownMenu.js +8 -18
  35. package/dropdown/DropdownMenuItem.js +4 -15
  36. package/file-input/FileInput.d.ts +2 -2
  37. package/file-input/FileInput.js +169 -222
  38. package/file-input/FileInput.stories.tsx +122 -11
  39. package/file-input/FileInput.test.js +12 -53
  40. package/file-input/FileItem.d.ts +4 -14
  41. package/file-input/FileItem.js +39 -63
  42. package/file-input/types.d.ts +17 -0
  43. package/footer/Footer.stories.tsx +91 -0
  44. package/header/Header.js +18 -20
  45. package/header/Header.stories.tsx +149 -6
  46. package/link/Link.js +1 -1
  47. package/link/Link.stories.tsx +60 -0
  48. package/main.d.ts +1 -1
  49. package/main.js +1 -1
  50. package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
  51. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
  52. package/{tabs-nav → nav-tabs}/Tab.js +35 -15
  53. package/number-input/NumberInput.test.js +5 -6
  54. package/package.json +7 -12
  55. package/paginator/Icons.d.ts +5 -0
  56. package/paginator/Icons.js +16 -28
  57. package/paginator/Paginator.js +5 -11
  58. package/paginator/Paginator.stories.tsx +24 -0
  59. package/paginator/Paginator.test.js +17 -10
  60. package/progress-bar/ProgressBar.js +4 -4
  61. package/progress-bar/ProgressBar.stories.jsx +35 -2
  62. package/quick-nav/QuickNav.stories.tsx +14 -0
  63. package/radio-group/RadioGroup.stories.tsx +131 -18
  64. package/resultsetTable/Icons.d.ts +7 -0
  65. package/resultsetTable/Icons.js +51 -0
  66. package/resultsetTable/ResultsetTable.js +48 -105
  67. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  68. package/resultsetTable/ResultsetTable.test.js +40 -63
  69. package/resultsetTable/types.d.ts +2 -2
  70. package/select/Listbox.d.ts +1 -1
  71. package/select/Listbox.js +5 -34
  72. package/select/Option.js +11 -24
  73. package/select/Select.js +43 -24
  74. package/select/Select.stories.tsx +494 -150
  75. package/select/Select.test.js +17 -22
  76. package/select/types.d.ts +2 -2
  77. package/sidenav/Sidenav.js +8 -10
  78. package/sidenav/Sidenav.stories.tsx +148 -46
  79. package/slider/Slider.d.ts +2 -2
  80. package/slider/Slider.js +9 -8
  81. package/slider/Slider.stories.tsx +57 -0
  82. package/slider/types.d.ts +4 -0
  83. package/spinner/Spinner.js +2 -2
  84. package/spinner/Spinner.stories.jsx +27 -1
  85. package/switch/Switch.d.ts +3 -3
  86. package/switch/Switch.js +5 -4
  87. package/switch/Switch.stories.tsx +33 -0
  88. package/switch/types.d.ts +6 -1
  89. package/table/Table.stories.jsx +80 -1
  90. package/table/Table.test.js +1 -1
  91. package/tabs/Tab.js +3 -5
  92. package/tabs/Tabs.js +3 -3
  93. package/tabs/Tabs.stories.tsx +45 -5
  94. package/tag/Tag.stories.tsx +14 -1
  95. package/text-input/Suggestion.js +32 -5
  96. package/text-input/TextInput.js +7 -11
  97. package/text-input/TextInput.stories.tsx +92 -4
  98. package/text-input/TextInput.test.js +587 -634
  99. package/textarea/Textarea.stories.jsx +60 -1
  100. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  101. package/utils/FocusLock.d.ts +13 -0
  102. package/utils/FocusLock.js +139 -0
  103. package/wizard/Wizard.stories.tsx +20 -0
  104. package/common/RequiredComponent.js +0 -32
  105. /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
  106. /package/{tabs-nav → nav-tabs}/NavTabs.test.js +0 -0
  107. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
  108. /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
  109. /package/{tabs-nav → nav-tabs}/types.js +0 -0
@@ -1,11 +1,12 @@
1
1
  import React from "react";
2
- import { userEvent, within, waitFor } from "@storybook/testing-library";
2
+ import { userEvent, within } from "@storybook/testing-library";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
5
  import DxcSelect from "./Select";
6
6
  import Listbox from "./Listbox";
7
- import DxcButton from "../button/Button";
8
- import DxcCheckbox from "../checkbox/Checkbox";
7
+ import { ThemeProvider } from "styled-components";
8
+ import useTheme from "../useTheme";
9
+ import { HalstackProvider } from "../HalstackContext";
9
10
 
10
11
  export default {
11
12
  title: "Select",
@@ -13,12 +14,14 @@ export default {
13
14
  };
14
15
 
15
16
  const one_option = [{ label: "Option 01", value: "1" }];
17
+
16
18
  const single_options = [
17
19
  { label: "Option 01", value: "1" },
18
20
  { label: "Option 02", value: "2" },
19
21
  { label: "Option 03", value: "3" },
20
22
  { label: "Option 04", value: "4" },
21
23
  ];
24
+
22
25
  const group_options = [
23
26
  {
24
27
  label: "Group 001",
@@ -61,6 +64,7 @@ const group_options = [
61
64
  ],
62
65
  },
63
66
  ];
67
+
64
68
  const icon_options_grouped = [
65
69
  {
66
70
  label: "Group 001",
@@ -124,6 +128,7 @@ const icon_options_grouped = [
124
128
  ],
125
129
  },
126
130
  ];
131
+
127
132
  const icon_options = [
128
133
  {
129
134
  label: "3G Mobile",
@@ -172,6 +177,7 @@ const icon_options = [
172
177
  ),
173
178
  },
174
179
  ];
180
+
175
181
  const url_options = [
176
182
  {
177
183
  label: "Social Media",
@@ -189,7 +195,29 @@ const url_options = [
189
195
  {
190
196
  label: "Facebook",
191
197
  value: "facebook",
192
- icon: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/2021_Facebook_icon.svg/2048px-2021_Facebook_icon.svg.png",
198
+ icon: (
199
+ <svg
200
+ version="1.1"
201
+ id="Capa_1"
202
+ x="0px"
203
+ y="0px"
204
+ width="438.536px"
205
+ height="438.536px"
206
+ viewBox="0 0 438.536 438.536"
207
+ fill="#4267B2"
208
+ >
209
+ <g>
210
+ <path
211
+ d="M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123
212
+ C8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126
213
+ h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
214
+ C438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402
215
+ c0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401
216
+ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
217
+ />
218
+ </g>
219
+ </svg>
220
+ ),
193
221
  },
194
222
  {
195
223
  label: "Pinterest",
@@ -219,13 +247,22 @@ const url_options = [
219
247
  ],
220
248
  },
221
249
  ];
250
+
222
251
  const optionsWithEllipsisMedium = [
223
252
  { label: "Optiond1234567890123456789012345678901234", value: "1" },
224
253
  { label: "Optiond12345678901234567890123456789012345", value: "2" },
225
254
  { label: "Option 031111111111111111111111111111222", value: "3" },
226
- { label: "Option 03111111111111111111111111111222", value: "4" },
227
255
  ];
228
256
 
257
+ const opinionatedTheme = {
258
+ select: {
259
+ selectedOptionBackgroundColor: "#e6f4ff",
260
+ fontColor: "#000000",
261
+ optionFontColor: "#000000",
262
+ hoverBorderColor: "#a46ede",
263
+ },
264
+ };
265
+
229
266
  const Select = () => (
230
267
  <>
231
268
  <Title title="States" theme="light" level={2} />
@@ -338,123 +375,380 @@ const Select = () => (
338
375
  <Title title="Multiple selection with ellipsis" theme="light" level={4} />
339
376
  <DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
340
377
  <Title title="Value with ellipsis" theme="light" level={4} />
341
- <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
378
+ <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" />
342
379
  <Title title="Options with ellipsis" theme="light" level={4} />
343
380
  <DxcSelect
344
381
  label="Label"
345
382
  placeholder="Choose an option"
346
383
  defaultValue="1"
347
384
  options={optionsWithEllipsisMedium}
348
- size="medium"
385
+ margin={{ top: "xxlarge" }}
349
386
  />
350
387
  </ExampleContainer>
351
- </>
352
- );
353
- const SelectListbox = () => (
354
- <>
355
- <Title title="Listbox" theme="light" level={2} />
356
- <Title title="Default with opened listbox" theme="light" level={3} />
357
- <ExampleContainer>
358
- <div style={{ display: "flex", gap: "30px", flexDirection: "column", marginBottom: "80px" }}>
359
- <DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
360
- <DxcCheckbox
361
- label="You understand the selection and give your consent"
362
- onChange={() => {}}
363
- labelPosition="after"
364
- />
365
- <DxcButton label="Submit" onClick={() => {}} size="medium" />
366
- </div>
367
- </ExampleContainer>
368
- <Title title="Listbox option states" theme="light" level={3} />
388
+ <Title title="Opinionated theme" theme="light" level={2} />
369
389
  <ExampleContainer pseudoState="pseudo-hover">
370
- <Title title="Hovered option" theme="light" level={4} />
371
- <Listbox
372
- id="x"
373
- currentValue=""
374
- options={one_option}
375
- visualFocusIndex={-1}
376
- lastOptionIndex={0}
377
- multiple={false}
378
- optional={false}
379
- optionalItem={{ label: "Empty", value: "" }}
380
- searchable={false}
381
- handleOptionOnClick={() => {}}
382
- getSelectWidth={() => 360}
383
- />
390
+ <Title title="Hovered" theme="light" level={4} />
391
+ <HalstackProvider theme={opinionatedTheme}>
392
+ <DxcSelect label="Hovered" options={single_options} />
393
+ </HalstackProvider>
384
394
  </ExampleContainer>
385
- <ExampleContainer pseudoState="pseudo-active">
386
- <Title title="Active option" theme="light" level={4} />
387
- <Listbox
388
- id="x"
389
- currentValue=""
390
- options={one_option}
391
- visualFocusIndex={-1}
392
- lastOptionIndex={0}
393
- multiple={false}
394
- optional={false}
395
- optionalItem={{ label: "Empty", value: "" }}
396
- searchable={false}
397
- handleOptionOnClick={() => {}}
398
- getSelectWidth={() => 360}
399
-
400
- />
395
+ <ExampleContainer pseudoState="pseudo-focus-within">
396
+ <Title title="Focused" theme="light" level={4} />
397
+ <HalstackProvider theme={opinionatedTheme}>
398
+ <DxcSelect label="Focused" options={single_options} />
399
+ </HalstackProvider>
401
400
  </ExampleContainer>
402
401
  <ExampleContainer>
403
- <Title title="Focused option" theme="light" level={4} />
404
- <Listbox
405
- id="x"
406
- currentValue=""
407
- options={one_option}
408
- visualFocusIndex={0}
409
- lastOptionIndex={0}
410
- multiple={false}
411
- optional={false}
412
- optionalItem={{ label: "Empty", value: "" }}
413
- searchable={false}
414
- handleOptionOnClick={() => {}}
415
- getSelectWidth={() => 360}
416
- />
402
+ <Title title="Disabled" theme="light" level={4} />
403
+ <HalstackProvider theme={opinionatedTheme}>
404
+ <DxcSelect label="Disabled" placeholder="Placeholder" disabled options={single_options} />
405
+ </HalstackProvider>
417
406
  </ExampleContainer>
418
- <ExampleContainer pseudoState="pseudo-hover">
419
- <Title title="Hovered selected option" theme="light" level={4} />
420
- <Listbox
421
- id="x"
422
- currentValue="1"
423
- options={single_options}
424
- visualFocusIndex={-1}
425
- lastOptionIndex={3}
426
- multiple={false}
427
- optional={false}
428
- optionalItem={{ label: "Empty", value: "" }}
429
- searchable={false}
430
- handleOptionOnClick={() => {}}
431
- getSelectWidth={() => 360}
432
- />
407
+ <ExampleContainer>
408
+ <Title title="Disabled with value" theme="light" level={4} />
409
+ <HalstackProvider theme={opinionatedTheme}>
410
+ <DxcSelect label="Disabled with value" disabled options={single_options} defaultValue="1" />
411
+ </HalstackProvider>
433
412
  </ExampleContainer>
434
- <ExampleContainer pseudoState="pseudo-active">
435
- <Title title="Active selected option" theme="light" level={4} />
436
- <Listbox
437
- id="x"
438
- currentValue="2"
439
- options={single_options}
440
- visualFocusIndex={0}
441
- lastOptionIndex={3}
442
- multiple={false}
443
- optional={false}
444
- optionalItem={{ label: "Empty", value: "" }}
445
- searchable={false}
446
- handleOptionOnClick={() => {}}
447
- getSelectWidth={() => 360}
448
- />
413
+ <ExampleContainer>
414
+ <Title title="Error" theme="light" level={4} />
415
+ <HalstackProvider theme={opinionatedTheme}>
416
+ <DxcSelect
417
+ label="Label"
418
+ options={single_options}
419
+ error="Error message."
420
+ helperText="Helper text"
421
+ placeholder="Placeholder"
422
+ />
423
+ <ExampleContainer>
424
+ <Title title="Multiple selection" theme="light" level={4} />
425
+ <DxcSelect label="Multiple select" searchable options={single_options} multiple defaultValue={["1", "2"]} />
426
+ </ExampleContainer>
427
+ <ExampleContainer pseudoState="pseudo-hover">
428
+ <Title title="Multiple clear hovered" theme="light" level={4} />
429
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
430
+ </ExampleContainer>
431
+ <ExampleContainer pseudoState="pseudo-active">
432
+ <Title title="Multiple clear actived" theme="light" level={4} />
433
+ <DxcSelect label="Multiple select" options={single_options} multiple defaultValue={["1", "2"]} />
434
+ </ExampleContainer>
435
+ </HalstackProvider>
449
436
  </ExampleContainer>
450
437
  </>
451
438
  );
439
+
440
+ const SelectListbox = () => {
441
+ const colorsTheme: any = useTheme();
442
+
443
+ return (
444
+ <>
445
+ <ThemeProvider theme={colorsTheme.select}>
446
+ <Title title="Listbox" theme="light" level={2} />
447
+ <ExampleContainer>
448
+ <Title
449
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
450
+ theme="light"
451
+ level={3}
452
+ />
453
+ <div
454
+ style={{
455
+ position: "relative",
456
+ display: "flex",
457
+ flexDirection: "column",
458
+ gap: "20px",
459
+ height: "150px",
460
+ width: "min-content",
461
+ marginBottom: "100px",
462
+ padding: "20px",
463
+ border: "1px solid black",
464
+ borderRadius: "4px",
465
+ overflow: "auto",
466
+ zIndex: "1300",
467
+ }}
468
+ >
469
+ <DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
470
+ <button style={{ zIndex: "1", width: "100px" }}>Submit</button>
471
+ </div>
472
+ </ExampleContainer>
473
+ <Title title="Listbox option states" theme="light" level={3} />
474
+ <ExampleContainer pseudoState="pseudo-hover">
475
+ <Title title="Hovered option" theme="light" level={4} />
476
+ <Listbox
477
+ id="x"
478
+ currentValue=""
479
+ options={one_option}
480
+ visualFocusIndex={-1}
481
+ lastOptionIndex={0}
482
+ multiple={false}
483
+ optional={false}
484
+ optionalItem={{ label: "Empty", value: "" }}
485
+ searchable={false}
486
+ handleOptionOnClick={() => {}}
487
+ styles={{ width: 360 }}
488
+ />
489
+ </ExampleContainer>
490
+ <ExampleContainer pseudoState="pseudo-active">
491
+ <Title title="Active option" theme="light" level={4} />
492
+ <Listbox
493
+ id="x"
494
+ currentValue=""
495
+ options={one_option}
496
+ visualFocusIndex={-1}
497
+ lastOptionIndex={0}
498
+ multiple={false}
499
+ optional={false}
500
+ optionalItem={{ label: "Empty", value: "" }}
501
+ searchable={false}
502
+ handleOptionOnClick={() => {}}
503
+ styles={{ width: 360 }}
504
+ />
505
+ </ExampleContainer>
506
+ <ExampleContainer>
507
+ <Title title="Focused option" theme="light" level={4} />
508
+ <Listbox
509
+ id="x"
510
+ currentValue=""
511
+ options={one_option}
512
+ visualFocusIndex={0}
513
+ lastOptionIndex={0}
514
+ multiple={false}
515
+ optional={false}
516
+ optionalItem={{ label: "Empty", value: "" }}
517
+ searchable={false}
518
+ handleOptionOnClick={() => {}}
519
+ styles={{ width: 360 }}
520
+ />
521
+ </ExampleContainer>
522
+ <ExampleContainer pseudoState="pseudo-hover">
523
+ <Title title="Hovered selected option" theme="light" level={4} />
524
+ <Listbox
525
+ id="x"
526
+ currentValue="1"
527
+ options={single_options}
528
+ visualFocusIndex={-1}
529
+ lastOptionIndex={3}
530
+ multiple={false}
531
+ optional={false}
532
+ optionalItem={{ label: "Empty", value: "" }}
533
+ searchable={false}
534
+ handleOptionOnClick={() => {}}
535
+ styles={{ width: 360 }}
536
+ />
537
+ </ExampleContainer>
538
+ <ExampleContainer pseudoState="pseudo-active">
539
+ <Title title="Active selected option" theme="light" level={4} />
540
+ <Listbox
541
+ id="x"
542
+ currentValue="2"
543
+ options={single_options}
544
+ visualFocusIndex={0}
545
+ lastOptionIndex={3}
546
+ multiple={false}
547
+ optional={false}
548
+ optionalItem={{ label: "Empty", value: "" }}
549
+ searchable={false}
550
+ handleOptionOnClick={() => {}}
551
+ styles={{ width: 360 }}
552
+ />
553
+ </ExampleContainer>
554
+ <Title title="Listbox with icons" theme="light" level={3} />
555
+ <ExampleContainer>
556
+ <Title title="Icons (SVGs)" theme="light" level={4} />
557
+ <Listbox
558
+ id="x"
559
+ currentValue="3"
560
+ options={icon_options}
561
+ visualFocusIndex={-1}
562
+ lastOptionIndex={3}
563
+ multiple={false}
564
+ optional={false}
565
+ optionalItem={{ label: "Empty", value: "" }}
566
+ searchable={false}
567
+ handleOptionOnClick={() => {}}
568
+ styles={{ width: 360 }}
569
+ />
570
+ </ExampleContainer>
571
+ <ExampleContainer>
572
+ <Title title="Icons (Images)" theme="light" level={4} />
573
+ <Listbox
574
+ id="x"
575
+ currentValue="facebook"
576
+ options={url_options}
577
+ visualFocusIndex={-1}
578
+ lastOptionIndex={6}
579
+ multiple={false}
580
+ optional={false}
581
+ optionalItem={{ label: "Empty", value: "" }}
582
+ searchable={false}
583
+ handleOptionOnClick={() => {}}
584
+ styles={{ width: 360 }}
585
+ />
586
+ </ExampleContainer>
587
+ <ExampleContainer>
588
+ <Title title="Grouped icons (SVGs)" theme="light" level={4} />
589
+ <Listbox
590
+ id="x"
591
+ currentValue={["0", "3"]}
592
+ options={icon_options_grouped}
593
+ visualFocusIndex={-1}
594
+ lastOptionIndex={3}
595
+ multiple={false}
596
+ optional={false}
597
+ optionalItem={{ label: "Empty", value: "" }}
598
+ searchable={false}
599
+ handleOptionOnClick={() => {}}
600
+ styles={{ width: 360 }}
601
+ />
602
+ </ExampleContainer>
603
+ <ExampleContainer>
604
+ <Title title="Grouped icons (Images)" theme="light" level={4} />
605
+ <Listbox
606
+ id="x"
607
+ currentValue={["facebook", "figma"]}
608
+ options={url_options}
609
+ visualFocusIndex={-1}
610
+ lastOptionIndex={6}
611
+ multiple={true}
612
+ optional={false}
613
+ optionalItem={{ label: "Empty", value: "" }}
614
+ searchable={false}
615
+ handleOptionOnClick={() => {}}
616
+ styles={{ width: 360 }}
617
+ />
618
+ </ExampleContainer>
619
+ </ThemeProvider>
620
+ <ThemeProvider theme={colorsTheme.select}>
621
+ <Title title="Opinionated theme" theme="light" level={2} />
622
+ <ExampleContainer pseudoState="pseudo-hover">
623
+ <Title title="Hovered option" theme="light" level={4} />
624
+ <HalstackProvider theme={opinionatedTheme}>
625
+ <Listbox
626
+ id="x"
627
+ currentValue=""
628
+ options={one_option}
629
+ visualFocusIndex={-1}
630
+ lastOptionIndex={0}
631
+ multiple={false}
632
+ optional={false}
633
+ optionalItem={{ label: "Empty", value: "" }}
634
+ searchable={false}
635
+ handleOptionOnClick={() => {}}
636
+ styles={{ width: 360 }}
637
+ />
638
+ </HalstackProvider>
639
+ </ExampleContainer>
640
+ <ExampleContainer pseudoState="pseudo-active">
641
+ <Title title="Active option" theme="light" level={4} />{" "}
642
+ <HalstackProvider theme={opinionatedTheme}>
643
+ <Listbox
644
+ id="x"
645
+ currentValue=""
646
+ options={one_option}
647
+ visualFocusIndex={-1}
648
+ lastOptionIndex={0}
649
+ multiple={false}
650
+ optional={false}
651
+ optionalItem={{ label: "Empty", value: "" }}
652
+ searchable={false}
653
+ handleOptionOnClick={() => {}}
654
+ styles={{ width: 360 }}
655
+ />
656
+ </HalstackProvider>
657
+ </ExampleContainer>
658
+ <ExampleContainer>
659
+ <Title title="Focused option" theme="light" level={4} />{" "}
660
+ <HalstackProvider theme={opinionatedTheme}>
661
+ <Listbox
662
+ id="x"
663
+ currentValue=""
664
+ options={one_option}
665
+ visualFocusIndex={0}
666
+ lastOptionIndex={0}
667
+ multiple={false}
668
+ optional={false}
669
+ optionalItem={{ label: "Empty", value: "" }}
670
+ searchable={false}
671
+ handleOptionOnClick={() => {}}
672
+ styles={{ width: 360 }}
673
+ />
674
+ </HalstackProvider>
675
+ </ExampleContainer>
676
+ <ExampleContainer pseudoState="pseudo-hover">
677
+ <Title title="Hovered selected option" theme="light" level={4} />{" "}
678
+ <HalstackProvider theme={opinionatedTheme}>
679
+ <Listbox
680
+ id="x"
681
+ currentValue="1"
682
+ options={single_options}
683
+ visualFocusIndex={-1}
684
+ lastOptionIndex={3}
685
+ multiple={false}
686
+ optional={false}
687
+ optionalItem={{ label: "Empty", value: "" }}
688
+ searchable={false}
689
+ handleOptionOnClick={() => {}}
690
+ styles={{ width: 360 }}
691
+ />
692
+ </HalstackProvider>
693
+ </ExampleContainer>
694
+ <ExampleContainer pseudoState="pseudo-active">
695
+ <Title title="Active selected option" theme="light" level={4} />{" "}
696
+ <HalstackProvider theme={opinionatedTheme}>
697
+ <Listbox
698
+ id="x"
699
+ currentValue="2"
700
+ options={single_options}
701
+ visualFocusIndex={0}
702
+ lastOptionIndex={3}
703
+ multiple={false}
704
+ optional={false}
705
+ optionalItem={{ label: "Empty", value: "" }}
706
+ searchable={false}
707
+ handleOptionOnClick={() => {}}
708
+ styles={{ width: 360 }}
709
+ />
710
+ </HalstackProvider>
711
+ </ExampleContainer>
712
+ <Title title="Listbox with icons" theme="light" level={3} />
713
+ <ExampleContainer>
714
+ <Title title="Icons (SVGs)" theme="light" level={4} />{" "}
715
+ <HalstackProvider theme={opinionatedTheme}>
716
+ <Listbox
717
+ id="x"
718
+ currentValue="3"
719
+ options={icon_options}
720
+ visualFocusIndex={-1}
721
+ lastOptionIndex={3}
722
+ multiple={false}
723
+ optional={false}
724
+ optionalItem={{ label: "Empty", value: "" }}
725
+ searchable={false}
726
+ handleOptionOnClick={() => {}}
727
+ styles={{ width: 360 }}
728
+ />
729
+ </HalstackProvider>
730
+ </ExampleContainer>
731
+ </ThemeProvider>
732
+ </>
733
+ );
734
+ };
735
+
452
736
  const SearchableSelect = () => (
453
737
  <ExampleContainer expanded>
454
738
  <Title title="Searchable select" theme="light" level={4} />
455
739
  <DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
456
740
  </ExampleContainer>
457
741
  );
742
+
743
+ const SearchableSelectOpinionated = () => (
744
+ <ExampleContainer expanded>
745
+ <Title title="Searchable select" theme="light" level={4} />
746
+ <HalstackProvider theme={opinionatedTheme}>
747
+ <DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
748
+ </HalstackProvider>
749
+ </ExampleContainer>
750
+ );
751
+
458
752
  const SearchValue = () => (
459
753
  <ExampleContainer expanded>
460
754
  <Title title="Searchable select with value" theme="light" level={4} />
@@ -467,6 +761,22 @@ const SearchValue = () => (
467
761
  />
468
762
  </ExampleContainer>
469
763
  );
764
+
765
+ const SearchValueOpinionated = () => (
766
+ <ExampleContainer expanded>
767
+ <Title title="Searchable select with value" theme="light" level={4} />
768
+ <HalstackProvider theme={opinionatedTheme}>
769
+ <DxcSelect
770
+ label="Select Label"
771
+ searchable
772
+ defaultValue="1"
773
+ options={single_options}
774
+ placeholder="Choose an option"
775
+ />
776
+ </HalstackProvider>
777
+ </ExampleContainer>
778
+ );
779
+
470
780
  const MultipleSelect = () => (
471
781
  <>
472
782
  <ExampleContainer expanded>
@@ -481,12 +791,38 @@ const MultipleSelect = () => (
481
791
  </ExampleContainer>
482
792
  </>
483
793
  );
794
+
795
+ const MultipleSelectOpinioated = () => (
796
+ <ExampleContainer expanded>
797
+ <Title title="Multiple select" theme="light" level={4} />
798
+ <HalstackProvider theme={opinionatedTheme}>
799
+ <DxcSelect
800
+ label="Select label"
801
+ options={single_options}
802
+ defaultValue={["1", "4"]}
803
+ multiple
804
+ placeholder="Choose an option"
805
+ />
806
+ </HalstackProvider>
807
+ </ExampleContainer>
808
+ );
809
+
484
810
  const DefaultGroupedOptionsSelect = () => (
485
811
  <ExampleContainer expanded>
486
812
  <Title title="Grouped options simple select" theme="light" level={4} />
487
813
  <DxcSelect label="Label" options={group_options} defaultValue="9" placeholder="Choose an option" />
488
814
  </ExampleContainer>
489
815
  );
816
+
817
+ const DefaultGroupedOptionsSelectOpinionated = () => (
818
+ <ExampleContainer expanded>
819
+ <Title title="Grouped options simple select" theme="light" level={4} />
820
+ <HalstackProvider theme={opinionatedTheme}>
821
+ <DxcSelect label="Label" options={group_options} defaultValue="9" placeholder="Choose an option" />
822
+ </HalstackProvider>
823
+ </ExampleContainer>
824
+ );
825
+
490
826
  const MultipleGroupedOptionsSelect = () => (
491
827
  <ExampleContainer expanded>
492
828
  <Title title="Grouped options multiple select" theme="light" level={4} />
@@ -499,34 +835,19 @@ const MultipleGroupedOptionsSelect = () => (
499
835
  />
500
836
  </ExampleContainer>
501
837
  );
502
- const RescaledIcons = () => (
503
- <ExampleContainer expanded>
504
- <Title title="Rescaled icons displayed" theme="light" level={4} />
505
- <DxcSelect label="Label" options={url_options} defaultValue="facebook" placeholder="Choose an option" />
506
- </ExampleContainer>
507
- );
508
- const SelectWithIcons = () => (
509
- <ExampleContainer expanded>
510
- <Title title="Normal icons displayed" theme="light" level={4} />
511
- <DxcSelect label="Label" options={icon_options} defaultValue="3" placeholder="Choose an option" />
512
- </ExampleContainer>
513
- );
514
- const SelectMultipleWithIcons = () => (
515
- <ExampleContainer expanded>
516
- <Title title="Multiple select with icons" theme="light" level={4} />
517
- <DxcSelect label="Label" options={icon_options} multiple defaultValue={["1", "3"]} placeholder="Choose an option" />
518
- </ExampleContainer>
519
- );
520
- const MultipleGroupedOptionsSelectWithIcons = () => (
838
+
839
+ const MultipleGroupedOptionsSelectOpinionated = () => (
521
840
  <ExampleContainer expanded>
522
- <Title title="Multiple grouped options with icons" theme="light" level={4} />
523
- <DxcSelect
524
- label="Label"
525
- options={icon_options_grouped}
526
- multiple
527
- defaultValue={["3", "2"]}
528
- placeholder="Choose an option"
529
- />
841
+ <Title title="Grouped options multiple select" theme="light" level={4} />
842
+ <HalstackProvider theme={opinionatedTheme}>
843
+ <DxcSelect
844
+ label="Label"
845
+ options={group_options}
846
+ defaultValue={["0", "2"]}
847
+ multiple
848
+ placeholder="Choose an option"
849
+ />
850
+ </HalstackProvider>
530
851
  </ExampleContainer>
531
852
  );
532
853
 
@@ -544,6 +865,22 @@ const MultipleSearchable = () => (
544
865
  </ExampleContainer>
545
866
  );
546
867
 
868
+ const MultipleSearchableOpinionated = () => (
869
+ <ExampleContainer expanded>
870
+ <Title title="Searchable multiple select with value" theme="light" level={4} />
871
+ <HalstackProvider theme={opinionatedTheme}>
872
+ <DxcSelect
873
+ label="Select Label"
874
+ searchable
875
+ multiple
876
+ defaultValue={["1", "4"]}
877
+ options={single_options}
878
+ placeholder="Choose an option"
879
+ />
880
+ </HalstackProvider>
881
+ </ExampleContainer>
882
+ );
883
+
547
884
  export const Chromatic = Select.bind({});
548
885
  Chromatic.play = async ({ canvasElement }) => {
549
886
  const canvas = within(canvasElement);
@@ -560,10 +897,13 @@ ListboxStates.play = async ({ canvasElement }) => {
560
897
  export const Searchable = SearchableSelect.bind({});
561
898
  Searchable.play = async ({ canvasElement }) => {
562
899
  const canvas = within(canvasElement);
563
- await userEvent.click(canvas.getByRole("combobox"));
564
- await waitFor(async () => {
565
- userEvent.type(canvas.getByRole("combobox"), "r");
566
- });
900
+ await userEvent.type(canvas.getByRole("combobox"), "r");
901
+ };
902
+
903
+ export const SearchableOpinionated = SearchableSelectOpinionated.bind({});
904
+ SearchableOpinionated.play = async ({ canvasElement }) => {
905
+ const canvas = within(canvasElement);
906
+ await userEvent.type(canvas.getByRole("combobox"), "r");
567
907
  };
568
908
 
569
909
  export const SearchableWithValue = SearchValue.bind({});
@@ -572,12 +912,24 @@ SearchableWithValue.play = async ({ canvasElement }) => {
572
912
  await userEvent.click(canvas.getByRole("combobox"));
573
913
  };
574
914
 
915
+ export const SearchableWithValueOpinionated = SearchValueOpinionated.bind({});
916
+ SearchableWithValueOpinionated.play = async ({ canvasElement }) => {
917
+ const canvas = within(canvasElement);
918
+ await userEvent.click(canvas.getByRole("combobox"));
919
+ };
920
+
575
921
  export const MultipleSearchableWithValue = MultipleSearchable.bind({});
576
922
  MultipleSearchableWithValue.play = async ({ canvasElement }) => {
577
923
  const canvas = within(canvasElement);
578
924
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
579
925
  };
580
926
 
927
+ export const MultipleSearchableWithValueOpinionated = MultipleSearchableOpinionated.bind({});
928
+ MultipleSearchableWithValueOpinionated.play = async ({ canvasElement }) => {
929
+ const canvas = within(canvasElement);
930
+ await userEvent.click(canvas.getAllByRole("combobox")[0]);
931
+ };
932
+
581
933
  export const GroupOptionsDisplayed = DefaultGroupedOptionsSelect.bind({});
582
934
  GroupOptionsDisplayed.play = async ({ canvasElement }) => {
583
935
  const canvas = within(canvasElement);
@@ -585,42 +937,34 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
585
937
  await userEvent.click(select);
586
938
  };
587
939
 
588
- export const MultipleOptionsDisplayed = MultipleSelect.bind({});
589
- MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
590
- const canvas = within(canvasElement);
591
- await userEvent.click(canvas.getAllByRole("combobox")[0]);
592
- };
593
-
594
- export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
595
- MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
940
+ export const GroupOptionsDisplayedOpinionated = DefaultGroupedOptionsSelectOpinionated.bind({});
941
+ GroupOptionsDisplayedOpinionated.play = async ({ canvasElement }) => {
596
942
  const canvas = within(canvasElement);
597
943
  const select = canvas.getByRole("combobox");
598
944
  await userEvent.click(select);
599
945
  };
600
946
 
601
- export const WithIconsDisplayed = SelectWithIcons.bind({});
602
- WithIconsDisplayed.play = async ({ canvasElement }) => {
947
+ export const MultipleOptionsDisplayed = MultipleSelect.bind({});
948
+ MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
603
949
  const canvas = within(canvasElement);
604
- const select = canvas.getByRole("combobox");
605
- await userEvent.click(select);
950
+ await userEvent.click(canvas.getAllByRole("combobox")[0]);
606
951
  };
607
952
 
608
- export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
609
- WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
953
+ export const MultipleOptionsDisplayedOpinionated = MultipleSelectOpinioated.bind({});
954
+ MultipleOptionsDisplayedOpinionated.play = async ({ canvasElement }) => {
610
955
  const canvas = within(canvasElement);
611
- const select = canvas.getByRole("combobox");
612
- await userEvent.click(select);
956
+ await userEvent.click(canvas.getAllByRole("combobox")[0]);
613
957
  };
614
958
 
615
- export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
616
- MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
959
+ export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
960
+ MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
617
961
  const canvas = within(canvasElement);
618
962
  const select = canvas.getByRole("combobox");
619
963
  await userEvent.click(select);
620
964
  };
621
965
 
622
- export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
623
- MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
966
+ export const MultipleGroupedOptionsDisplayedOpinionated = MultipleGroupedOptionsSelectOpinionated.bind({});
967
+ MultipleGroupedOptionsDisplayedOpinionated.play = async ({ canvasElement }) => {
624
968
  const canvas = within(canvasElement);
625
969
  const select = canvas.getByRole("combobox");
626
970
  await userEvent.click(select);