@dxc-technology/halstack-react 0.0.0-8aa8e6b → 0.0.0-8c10296

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 (97) hide show
  1. package/HalstackContext.d.ts +4 -2
  2. package/HalstackContext.js +110 -58
  3. package/alert/Alert.js +4 -1
  4. package/badge/Badge.d.ts +1 -1
  5. package/badge/Badge.js +5 -3
  6. package/badge/types.d.ts +1 -0
  7. package/bleed/Bleed.js +1 -34
  8. package/bleed/Bleed.stories.tsx +31 -32
  9. package/bleed/types.d.ts +1 -1
  10. package/box/Box.js +22 -32
  11. package/button/Button.js +3 -1
  12. package/card/Card.js +34 -36
  13. package/checkbox/Checkbox.js +4 -1
  14. package/common/variables.js +176 -78
  15. package/date-input/DateInput.js +5 -2
  16. package/file-input/FileInput.js +9 -6
  17. package/file-input/FileItem.js +7 -5
  18. package/footer/Footer.js +7 -5
  19. package/header/Header.js +7 -4
  20. package/inline/Inline.d.ts +4 -0
  21. package/inline/Inline.js +54 -0
  22. package/inline/Inline.stories.tsx +240 -0
  23. package/inline/types.d.ts +32 -0
  24. package/{quick-nav-container → inline}/types.js +0 -0
  25. package/inset/Inset.js +1 -34
  26. package/inset/Inset.stories.tsx +32 -32
  27. package/inset/types.d.ts +1 -1
  28. package/layout/ApplicationLayout.d.ts +4 -3
  29. package/layout/ApplicationLayout.js +83 -102
  30. package/layout/ApplicationLayout.stories.tsx +14 -59
  31. package/layout/Icons.d.ts +5 -0
  32. package/layout/Icons.js +13 -2
  33. package/layout/SidenavContext.d.ts +5 -0
  34. package/layout/SidenavContext.js +19 -0
  35. package/layout/types.d.ts +5 -10
  36. package/link/Link.d.ts +3 -2
  37. package/link/Link.js +57 -70
  38. package/link/Link.stories.tsx +87 -52
  39. package/link/Link.test.js +7 -15
  40. package/link/types.d.ts +7 -23
  41. package/main.d.ts +5 -4
  42. package/main.js +25 -11
  43. package/number-input/types.d.ts +1 -1
  44. package/package.json +2 -1
  45. package/paginator/Paginator.js +17 -38
  46. package/paginator/Paginator.test.js +42 -0
  47. package/password-input/PasswordInput.js +7 -4
  48. package/password-input/PasswordInput.test.js +1 -2
  49. package/password-input/types.d.ts +1 -1
  50. package/progress-bar/ProgressBar.js +1 -1
  51. package/progress-bar/ProgressBar.stories.jsx +11 -11
  52. package/quick-nav/QuickNav.js +65 -17
  53. package/quick-nav/QuickNav.stories.tsx +2 -2
  54. package/quick-nav/types.d.ts +1 -1
  55. package/radio-group/Radio.js +1 -1
  56. package/radio-group/RadioGroup.js +8 -6
  57. package/resultsetTable/ResultsetTable.test.js +42 -0
  58. package/select/Listbox.d.ts +1 -1
  59. package/select/Listbox.js +35 -8
  60. package/select/Select.js +83 -78
  61. package/select/Select.stories.tsx +144 -100
  62. package/select/Select.test.js +299 -194
  63. package/select/types.d.ts +3 -4
  64. package/sidenav/Sidenav.d.ts +1 -1
  65. package/sidenav/Sidenav.js +20 -9
  66. package/spinner/Spinner.js +1 -1
  67. package/switch/Switch.js +4 -1
  68. package/tabs-nav/NavTabs.d.ts +8 -0
  69. package/tabs-nav/NavTabs.js +125 -0
  70. package/tabs-nav/NavTabs.stories.tsx +170 -0
  71. package/tabs-nav/NavTabs.test.js +82 -0
  72. package/tabs-nav/Tab.d.ts +4 -0
  73. package/tabs-nav/Tab.js +132 -0
  74. package/tabs-nav/types.d.ts +53 -0
  75. package/{radio → tabs-nav}/types.js +0 -0
  76. package/text-input/Suggestion.d.ts +4 -0
  77. package/text-input/Suggestion.js +55 -0
  78. package/text-input/TextInput.js +46 -72
  79. package/text-input/TextInput.test.js +1 -1
  80. package/text-input/types.d.ts +14 -2
  81. package/textarea/Textarea.js +10 -19
  82. package/textarea/types.d.ts +1 -1
  83. package/useTranslatedLabels.d.ts +2 -0
  84. package/useTranslatedLabels.js +20 -0
  85. package/wizard/Wizard.js +27 -25
  86. package/quick-nav-container/HeadingLink.d.ts +0 -8
  87. package/quick-nav-container/HeadingLink.js +0 -58
  88. package/quick-nav-container/QuickNavContainer.d.ts +0 -4
  89. package/quick-nav-container/QuickNavContainer.js +0 -69
  90. package/quick-nav-container/Section.d.ts +0 -9
  91. package/quick-nav-container/Section.js +0 -37
  92. package/quick-nav-container/types.d.ts +0 -34
  93. package/radio/Radio.d.ts +0 -4
  94. package/radio/Radio.js +0 -173
  95. package/radio/Radio.stories.tsx +0 -192
  96. package/radio/Radio.test.js +0 -71
  97. package/radio/types.d.ts +0 -54
@@ -1,12 +1,11 @@
1
1
  import React from "react";
2
-
3
2
  import { userEvent, within, waitFor } from "@storybook/testing-library";
4
- import { fireEvent } from "@testing-library/react";
5
-
6
3
  import Title from "../../.storybook/components/Title";
7
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
8
-
9
5
  import DxcSelect from "./Select";
6
+ import Listbox from "./Listbox";
7
+ import DxcButton from "../button/Button";
8
+ import DxcCheckbox from "../checkbox/Checkbox";
10
9
 
11
10
  export default {
12
11
  title: "Select",
@@ -340,7 +339,7 @@ const Select = () => (
340
339
  <DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
341
340
  <Title title="Value with ellipsis" theme="light" level={4} />
342
341
  <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
343
- <Title title="Option with ellipsis" theme="light" level={4} />
342
+ <Title title="Options with ellipsis" theme="light" level={4} />
344
343
  <DxcSelect
345
344
  label="Label"
346
345
  placeholder="Choose an option"
@@ -351,16 +350,103 @@ const Select = () => (
351
350
  </ExampleContainer>
352
351
  </>
353
352
  );
354
- export const Chromatic = Select.bind({});
355
- Chromatic.play = async ({ canvasElement }) => {
356
- const canvas = within(canvasElement);
357
- await userEvent.click(canvas.getAllByRole("combobox")[24]);
358
- };
359
- const DefaultSelect = () => (
360
- <ExampleContainer expanded>
361
- <Title title="Default select" theme="light" level={4} />
362
- <DxcSelect label="Select label" options={single_options} optional placeholder="Choose an option" />
363
- </ExampleContainer>
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} />
369
+ <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
+ styles={{ width: 360 }}
383
+ />
384
+ </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
+ styles={{ width: 360 }}
399
+ />
400
+ </ExampleContainer>
401
+ <ExampleContainer>
402
+ <Title title="Focused option" theme="light" level={4} />
403
+ <Listbox
404
+ id="x"
405
+ currentValue=""
406
+ options={one_option}
407
+ visualFocusIndex={0}
408
+ lastOptionIndex={0}
409
+ multiple={false}
410
+ optional={false}
411
+ optionalItem={{ label: "Empty", value: "" }}
412
+ searchable={false}
413
+ handleOptionOnClick={() => {}}
414
+ styles={{ width: 360 }}
415
+ />
416
+ </ExampleContainer>
417
+ <ExampleContainer pseudoState="pseudo-hover">
418
+ <Title title="Hovered selected option" theme="light" level={4} />
419
+ <Listbox
420
+ id="x"
421
+ currentValue="1"
422
+ options={single_options}
423
+ visualFocusIndex={-1}
424
+ lastOptionIndex={3}
425
+ multiple={false}
426
+ optional={false}
427
+ optionalItem={{ label: "Empty", value: "" }}
428
+ searchable={false}
429
+ handleOptionOnClick={() => {}}
430
+ styles={{ width: 360 }}
431
+ />
432
+ </ExampleContainer>
433
+ <ExampleContainer pseudoState="pseudo-active">
434
+ <Title title="Active selected option" theme="light" level={4} />
435
+ <Listbox
436
+ id="x"
437
+ currentValue="2"
438
+ options={single_options}
439
+ visualFocusIndex={0}
440
+ lastOptionIndex={3}
441
+ multiple={false}
442
+ optional={false}
443
+ optionalItem={{ label: "Empty", value: "" }}
444
+ searchable={false}
445
+ handleOptionOnClick={() => {}}
446
+ styles={{ width: 360 }}
447
+ />
448
+ </ExampleContainer>
449
+ </>
364
450
  );
365
451
  const SearchableSelect = () => (
366
452
  <ExampleContainer expanded>
@@ -368,13 +454,18 @@ const SearchableSelect = () => (
368
454
  <DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
369
455
  </ExampleContainer>
370
456
  );
371
- const SearchableWithValue = () => (
457
+ const SearchValue = () => (
372
458
  <ExampleContainer expanded>
373
459
  <Title title="Searchable select with value" theme="light" level={4} />
374
- <DxcSelect label="Select Label" searchable defaultValue="1" options={single_options} placeholder="Choose an option" />
460
+ <DxcSelect
461
+ label="Select Label"
462
+ searchable
463
+ defaultValue="1"
464
+ options={single_options}
465
+ placeholder="Choose an option"
466
+ />
375
467
  </ExampleContainer>
376
468
  );
377
-
378
469
  const MultipleSelect = () => (
379
470
  <>
380
471
  <ExampleContainer expanded>
@@ -398,7 +489,13 @@ const DefaultGroupedOptionsSelect = () => (
398
489
  const MultipleGroupedOptionsSelect = () => (
399
490
  <ExampleContainer expanded>
400
491
  <Title title="Grouped options multiple select" theme="light" level={4} />
401
- <DxcSelect label="Label" options={group_options} defaultValue={["0", "2"]} multiple placeholder="Choose an option" />
492
+ <DxcSelect
493
+ label="Label"
494
+ options={group_options}
495
+ defaultValue={["0", "2"]}
496
+ multiple
497
+ placeholder="Choose an option"
498
+ />
402
499
  </ExampleContainer>
403
500
  );
404
501
  const RescaledIcons = () => (
@@ -431,36 +528,7 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
431
528
  />
432
529
  </ExampleContainer>
433
530
  );
434
- const OnlyOneOptionHovered = () => (
435
- <ExampleContainer pseudoState="pseudo-hover" expanded>
436
- <Title title="Hovered Option" theme="light" level={4} />
437
- <DxcSelect label="Hovered" options={one_option} placeholder="Choose an option" />
438
- </ExampleContainer>
439
- );
440
- const OnlyOneOptionFocused = () => (
441
- <ExampleContainer pseudoState="pseudo-focus" expanded>
442
- <Title title="Focused Option" theme="light" level={4} />
443
- <DxcSelect label="Focused" options={one_option} placeholder="Choose an option" />
444
- </ExampleContainer>
445
- );
446
- const OnlyOneOptionActived = () => (
447
- <ExampleContainer pseudoState="pseudo-active" expanded>
448
- <Title title="Actived Option" theme="light" level={4} />
449
- <DxcSelect label="Actived" options={one_option} placeholder="Choose an option" />
450
- </ExampleContainer>
451
- );
452
- const SelectedOptionHovered = () => (
453
- <ExampleContainer pseudoState="pseudo-hover" expanded>
454
- <Title title="Hovered Selected Option" theme="light" level={4} />
455
- <DxcSelect label="Hovered" defaultValue="1" options={one_option} placeholder="Choose an option" />
456
- </ExampleContainer>
457
- );
458
- const SelectedOptionActived = () => (
459
- <ExampleContainer pseudoState="pseudo-active" expanded>
460
- <Title title="Actived Selected Option" theme="light" level={4} />
461
- <DxcSelect label="Actived" defaultValue="1" options={one_option} placeholder="Choose an option" />
462
- </ExampleContainer>
463
- );
531
+
464
532
  const MultipleSearchable = () => (
465
533
  <ExampleContainer expanded>
466
534
  <Title title="Searchable multiple select with value" theme="light" level={4} />
@@ -474,12 +542,20 @@ const MultipleSearchable = () => (
474
542
  />
475
543
  </ExampleContainer>
476
544
  );
477
- export const OptionsDisplayed = DefaultSelect.bind({});
478
- OptionsDisplayed.play = async ({ canvasElement }) => {
545
+
546
+ export const Chromatic = Select.bind({});
547
+ Chromatic.play = async ({ canvasElement }) => {
548
+ const canvas = within(canvasElement);
549
+ await userEvent.click(canvas.getAllByRole("combobox")[24]);
550
+ };
551
+
552
+ export const ListboxStates = SelectListbox.bind({});
553
+ ListboxStates.play = async ({ canvasElement }) => {
479
554
  const canvas = within(canvasElement);
480
555
  const select = canvas.getByRole("combobox");
481
556
  await userEvent.click(select);
482
557
  };
558
+
483
559
  export const Searchable = SearchableSelect.bind({});
484
560
  Searchable.play = async ({ canvasElement }) => {
485
561
  const canvas = within(canvasElement);
@@ -488,14 +564,15 @@ Searchable.play = async ({ canvasElement }) => {
488
564
  userEvent.type(canvas.getByRole("combobox"), "r");
489
565
  });
490
566
  };
491
- export const SelectSearchableWithValue = SearchableWithValue.bind({});
492
- SelectSearchableWithValue.play = async ({ canvasElement }) => {
567
+
568
+ export const SearchableWithValue = SearchValue.bind({});
569
+ SearchableWithValue.play = async ({ canvasElement }) => {
493
570
  const canvas = within(canvasElement);
494
571
  await userEvent.click(canvas.getByRole("combobox"));
495
572
  };
496
573
 
497
- export const SelectMultipleSearchableWithValue = MultipleSearchable.bind({});
498
- SelectMultipleSearchableWithValue.play = async ({ canvasElement }) => {
574
+ export const MultipleSearchableWithValue = MultipleSearchable.bind({});
575
+ MultipleSearchableWithValue.play = async ({ canvasElement }) => {
499
576
  const canvas = within(canvasElement);
500
577
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
501
578
  };
@@ -507,75 +584,42 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
507
584
  await userEvent.click(select);
508
585
  };
509
586
 
510
- export const SelectMultipleOptionsDisplayed = MultipleSelect.bind({});
511
- SelectMultipleOptionsDisplayed.play = async ({ canvasElement }) => {
587
+ export const MultipleOptionsDisplayed = MultipleSelect.bind({});
588
+ MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
512
589
  const canvas = within(canvasElement);
513
590
  await userEvent.click(canvas.getAllByRole("combobox")[0]);
514
591
  };
515
592
 
516
- export const SelectMultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
517
- SelectMultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
518
- const canvas = within(canvasElement);
519
- const select = canvas.getByRole("combobox");
520
- await userEvent.click(select);
521
- };
522
- export const SelectWithIconsDisplayed = SelectWithIcons.bind({});
523
- SelectWithIconsDisplayed.play = async ({ canvasElement }) => {
593
+ export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
594
+ MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
524
595
  const canvas = within(canvasElement);
525
596
  const select = canvas.getByRole("combobox");
526
597
  await userEvent.click(select);
527
598
  };
528
599
 
529
- export const SelectWithRescaledIconsDisplayed = RescaledIcons.bind({});
530
- SelectWithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
531
- const canvas = within(canvasElement);
532
- const select = canvas.getByRole("combobox");
533
- await userEvent.click(select);
534
- };
535
- export const SelectMultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
536
- SelectMultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
600
+ export const WithIconsDisplayed = SelectWithIcons.bind({});
601
+ WithIconsDisplayed.play = async ({ canvasElement }) => {
537
602
  const canvas = within(canvasElement);
538
603
  const select = canvas.getByRole("combobox");
539
604
  await userEvent.click(select);
540
605
  };
541
606
 
542
- export const SelectMultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
543
- SelectMultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
607
+ export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
608
+ WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
544
609
  const canvas = within(canvasElement);
545
610
  const select = canvas.getByRole("combobox");
546
611
  await userEvent.click(select);
547
612
  };
548
613
 
549
- export const OptionHovered = OnlyOneOptionHovered.bind({});
550
- OptionHovered.play = async ({ canvasElement }) => {
614
+ export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
615
+ MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
551
616
  const canvas = within(canvasElement);
552
617
  const select = canvas.getByRole("combobox");
553
618
  await userEvent.click(select);
554
619
  };
555
620
 
556
- export const OptionFocused = OnlyOneOptionFocused.bind({});
557
- OptionFocused.play = async ({ canvasElement }) => {
558
- const canvas = within(canvasElement);
559
- const select = canvas.getByRole("combobox");
560
- await userEvent.click(select);
561
- await waitFor(async () => {
562
- fireEvent.keyDown(select, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
563
- });
564
- };
565
- export const OptionActived = OnlyOneOptionActived.bind({});
566
- OptionActived.play = async ({ canvasElement }) => {
567
- const canvas = within(canvasElement);
568
- const select = canvas.getByRole("combobox");
569
- await userEvent.click(select);
570
- };
571
- export const OptionSelectedHovered = SelectedOptionHovered.bind({});
572
- OptionSelectedHovered.play = async ({ canvasElement }) => {
573
- const canvas = within(canvasElement);
574
- const select = canvas.getByRole("combobox");
575
- await userEvent.click(select);
576
- };
577
- export const OptionSelectedActived = SelectedOptionActived.bind({});
578
- OptionSelectedActived.play = async ({ canvasElement }) => {
621
+ export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
622
+ MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
579
623
  const canvas = within(canvasElement);
580
624
  const select = canvas.getByRole("combobox");
581
625
  await userEvent.click(select);