@dxc-technology/halstack-react 0.0.0-090152f → 0.0.0-0a9608a

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 (95) hide show
  1. package/HalstackContext.js +7 -8
  2. package/accordion/Accordion.js +7 -13
  3. package/accordion/Accordion.stories.tsx +52 -12
  4. package/accordion/types.d.ts +1 -0
  5. package/accordion-group/types.d.ts +1 -0
  6. package/box/types.d.ts +1 -0
  7. package/button/Button.js +11 -13
  8. package/button/Button.stories.tsx +58 -1
  9. package/card/types.d.ts +1 -0
  10. package/checkbox/Checkbox.d.ts +2 -2
  11. package/checkbox/Checkbox.js +16 -15
  12. package/checkbox/Checkbox.stories.tsx +79 -59
  13. package/checkbox/types.d.ts +4 -0
  14. package/chip/Chip.js +11 -23
  15. package/chip/Chip.stories.tsx +41 -9
  16. package/common/variables.js +130 -126
  17. package/date-input/Calendar.d.ts +4 -0
  18. package/date-input/Calendar.js +246 -0
  19. package/date-input/DateInput.js +134 -237
  20. package/date-input/DateInput.stories.tsx +137 -38
  21. package/date-input/DateInput.test.js +494 -138
  22. package/date-input/DatePicker.d.ts +4 -0
  23. package/date-input/DatePicker.js +132 -0
  24. package/date-input/Icons.d.ts +6 -0
  25. package/date-input/Icons.js +75 -0
  26. package/date-input/YearPicker.d.ts +4 -0
  27. package/date-input/YearPicker.js +116 -0
  28. package/date-input/types.d.ts +51 -0
  29. package/dialog/types.d.ts +1 -0
  30. package/dropdown/Dropdown.js +38 -37
  31. package/dropdown/Dropdown.stories.tsx +175 -94
  32. package/dropdown/Dropdown.test.js +18 -24
  33. package/dropdown/DropdownMenu.js +8 -18
  34. package/dropdown/DropdownMenuItem.js +4 -15
  35. package/file-input/FileInput.d.ts +2 -2
  36. package/file-input/FileInput.js +177 -219
  37. package/file-input/FileInput.stories.tsx +38 -10
  38. package/file-input/FileInput.test.js +53 -12
  39. package/file-input/FileItem.d.ts +4 -14
  40. package/file-input/FileItem.js +38 -63
  41. package/file-input/types.d.ts +17 -0
  42. package/flex/Flex.d.ts +1 -1
  43. package/flex/Flex.js +31 -19
  44. package/flex/types.d.ts +14 -3
  45. package/footer/types.d.ts +1 -0
  46. package/header/Header.js +18 -20
  47. package/header/Header.stories.tsx +34 -1
  48. package/header/types.d.ts +1 -0
  49. package/link/Link.js +1 -1
  50. package/number-input/NumberInput.test.js +43 -7
  51. package/package.json +7 -12
  52. package/paginator/Icons.d.ts +5 -0
  53. package/paginator/Icons.js +16 -28
  54. package/paginator/Paginator.js +6 -12
  55. package/paginator/Paginator.test.js +18 -11
  56. package/password-input/PasswordInput.test.js +13 -12
  57. package/quick-nav/QuickNav.js +11 -12
  58. package/quick-nav/QuickNav.stories.tsx +97 -19
  59. package/radio-group/RadioGroup.js +9 -5
  60. package/radio-group/RadioGroup.test.js +116 -59
  61. package/resultsetTable/Icons.d.ts +7 -0
  62. package/resultsetTable/Icons.js +51 -0
  63. package/resultsetTable/ResultsetTable.js +48 -107
  64. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  65. package/resultsetTable/ResultsetTable.test.js +40 -63
  66. package/resultsetTable/types.d.ts +2 -2
  67. package/select/Listbox.d.ts +1 -1
  68. package/select/Listbox.js +5 -34
  69. package/select/Option.js +11 -24
  70. package/select/Select.js +46 -25
  71. package/select/Select.stories.tsx +209 -167
  72. package/select/Select.test.js +284 -231
  73. package/select/types.d.ts +2 -2
  74. package/sidenav/Sidenav.js +8 -10
  75. package/sidenav/Sidenav.stories.tsx +59 -50
  76. package/slider/Slider.d.ts +2 -2
  77. package/slider/Slider.js +15 -11
  78. package/slider/types.d.ts +4 -0
  79. package/spinner/Spinner.js +2 -2
  80. package/switch/Switch.d.ts +3 -3
  81. package/switch/Switch.js +5 -4
  82. package/switch/types.d.ts +6 -1
  83. package/table/Table.js +1 -1
  84. package/table/Table.test.js +1 -1
  85. package/tabs/Tab.js +3 -5
  86. package/tabs/Tabs.js +3 -3
  87. package/tabs/Tabs.stories.tsx +7 -5
  88. package/tabs-nav/NavTabs.stories.tsx +8 -6
  89. package/tabs-nav/Tab.js +5 -7
  90. package/text-input/Suggestion.js +32 -5
  91. package/text-input/TextInput.js +172 -162
  92. package/text-input/TextInput.stories.tsx +24 -4
  93. package/text-input/TextInput.test.js +658 -647
  94. package/text-input/types.d.ts +5 -0
  95. package/common/RequiredComponent.js +0 -32
@@ -1,11 +1,11 @@
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
9
 
10
10
  export default {
11
11
  title: "Select",
@@ -189,7 +189,29 @@ const url_options = [
189
189
  {
190
190
  label: "Facebook",
191
191
  value: "facebook",
192
- icon: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b8/2021_Facebook_icon.svg/2048px-2021_Facebook_icon.svg.png",
192
+ icon: (
193
+ <svg
194
+ version="1.1"
195
+ id="Capa_1"
196
+ x="0px"
197
+ y="0px"
198
+ width="438.536px"
199
+ height="438.536px"
200
+ viewBox="0 0 438.536 438.536"
201
+ fill="#4267B2"
202
+ >
203
+ <g>
204
+ <path
205
+ 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
206
+ 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
207
+ h274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225
208
+ 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
209
+ 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
210
+ 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"
211
+ />
212
+ </g>
213
+ </svg>
214
+ ),
193
215
  },
194
216
  {
195
217
  label: "Pinterest",
@@ -223,7 +245,6 @@ const optionsWithEllipsisMedium = [
223
245
  { label: "Optiond1234567890123456789012345678901234", value: "1" },
224
246
  { label: "Optiond12345678901234567890123456789012345", value: "2" },
225
247
  { label: "Option 031111111111111111111111111111222", value: "3" },
226
- { label: "Option 03111111111111111111111111111222", value: "4" },
227
248
  ];
228
249
 
229
250
  const Select = () => (
@@ -338,117 +359,200 @@ const Select = () => (
338
359
  <Title title="Multiple selection with ellipsis" theme="light" level={4} />
339
360
  <DxcSelect label="Label" options={single_options} multiple defaultValue={["1", "2", "3", "4"]} />
340
361
  <Title title="Value with ellipsis" theme="light" level={4} />
341
- <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" size="medium" />
362
+ <DxcSelect label="Label" options={optionsWithEllipsisMedium} defaultValue="1" />
342
363
  <Title title="Options with ellipsis" theme="light" level={4} />
343
364
  <DxcSelect
344
365
  label="Label"
345
366
  placeholder="Choose an option"
346
367
  defaultValue="1"
347
368
  options={optionsWithEllipsisMedium}
348
- size="medium"
369
+ margin={{ top: "xxlarge" }}
349
370
  />
350
371
  </ExampleContainer>
351
372
  </>
352
373
  );
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"
374
+ const SelectListbox = () => {
375
+ const colorsTheme: any = useTheme();
376
+
377
+ return (
378
+ <ThemeProvider theme={colorsTheme.select}>
379
+ <Title title="Listbox" theme="light" level={2} />
380
+ <ExampleContainer>
381
+ <Title
382
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
383
+ theme="light"
384
+ level={3}
364
385
  />
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
- getSelectWidth={() => 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
- getSelectWidth={() => 360}
386
+ <div
387
+ style={{
388
+ position: "relative",
389
+ display: "flex",
390
+ flexDirection: "column",
391
+ gap: "20px",
392
+ height: "150px",
393
+ width: "min-content",
394
+ marginBottom: "100px",
395
+ padding: "20px",
396
+ border: "1px solid black",
397
+ borderRadius: "4px",
398
+ overflow: "auto",
399
+ zIndex: "1300",
400
+ }}
401
+ >
402
+ <DxcSelect label="Label" options={single_options} optional placeholder="Choose an option" />
403
+ <button style={{ zIndex: "1", width: "100px" }}>Submit</button>
404
+ </div>
405
+ </ExampleContainer>
406
+ <Title title="Listbox option states" theme="light" level={3} />
407
+ <ExampleContainer pseudoState="pseudo-hover">
408
+ <Title title="Hovered option" theme="light" level={4} />
409
+ <Listbox
410
+ id="x"
411
+ currentValue=""
412
+ options={one_option}
413
+ visualFocusIndex={-1}
414
+ lastOptionIndex={0}
415
+ multiple={false}
416
+ optional={false}
417
+ optionalItem={{ label: "Empty", value: "" }}
418
+ searchable={false}
419
+ handleOptionOnClick={() => {}}
420
+ styles={{ width: 360 }}
421
+ />
422
+ </ExampleContainer>
423
+ <ExampleContainer pseudoState="pseudo-active">
424
+ <Title title="Active option" theme="light" level={4} />
425
+ <Listbox
426
+ id="x"
427
+ currentValue=""
428
+ options={one_option}
429
+ visualFocusIndex={-1}
430
+ lastOptionIndex={0}
431
+ multiple={false}
432
+ optional={false}
433
+ optionalItem={{ label: "Empty", value: "" }}
434
+ searchable={false}
435
+ handleOptionOnClick={() => {}}
436
+ styles={{ width: 360 }}
437
+ />
438
+ </ExampleContainer>
439
+ <ExampleContainer>
440
+ <Title title="Focused option" theme="light" level={4} />
441
+ <Listbox
442
+ id="x"
443
+ currentValue=""
444
+ options={one_option}
445
+ visualFocusIndex={0}
446
+ lastOptionIndex={0}
447
+ multiple={false}
448
+ optional={false}
449
+ optionalItem={{ label: "Empty", value: "" }}
450
+ searchable={false}
451
+ handleOptionOnClick={() => {}}
452
+ styles={{ width: 360 }}
453
+ />
454
+ </ExampleContainer>
455
+ <ExampleContainer pseudoState="pseudo-hover">
456
+ <Title title="Hovered selected option" theme="light" level={4} />
457
+ <Listbox
458
+ id="x"
459
+ currentValue="1"
460
+ options={single_options}
461
+ visualFocusIndex={-1}
462
+ lastOptionIndex={3}
463
+ multiple={false}
464
+ optional={false}
465
+ optionalItem={{ label: "Empty", value: "" }}
466
+ searchable={false}
467
+ handleOptionOnClick={() => {}}
468
+ styles={{ width: 360 }}
469
+ />
470
+ </ExampleContainer>
471
+ <ExampleContainer pseudoState="pseudo-active">
472
+ <Title title="Active selected option" theme="light" level={4} />
473
+ <Listbox
474
+ id="x"
475
+ currentValue="2"
476
+ options={single_options}
477
+ visualFocusIndex={0}
478
+ lastOptionIndex={3}
479
+ multiple={false}
480
+ optional={false}
481
+ optionalItem={{ label: "Empty", value: "" }}
482
+ searchable={false}
483
+ handleOptionOnClick={() => {}}
484
+ styles={{ width: 360 }}
485
+ />
486
+ </ExampleContainer>
487
+ <Title title="Listbox with icons" theme="light" level={3} />
488
+ <ExampleContainer>
489
+ <Title title="Icons (SVGs)" theme="light" level={4} />
490
+ <Listbox
491
+ id="x"
492
+ currentValue="3"
493
+ options={icon_options}
494
+ visualFocusIndex={-1}
495
+ lastOptionIndex={3}
496
+ multiple={false}
497
+ optional={false}
498
+ optionalItem={{ label: "Empty", value: "" }}
499
+ searchable={false}
500
+ handleOptionOnClick={() => {}}
501
+ styles={{ width: 360 }}
502
+ />
503
+ </ExampleContainer>
504
+ <ExampleContainer>
505
+ <Title title="Icons (Images)" theme="light" level={4} />
506
+ <Listbox
507
+ id="x"
508
+ currentValue="facebook"
509
+ options={url_options}
510
+ visualFocusIndex={-1}
511
+ lastOptionIndex={6}
512
+ multiple={false}
513
+ optional={false}
514
+ optionalItem={{ label: "Empty", value: "" }}
515
+ searchable={false}
516
+ handleOptionOnClick={() => {}}
517
+ styles={{ width: 360 }}
518
+ />
519
+ </ExampleContainer>
520
+ <ExampleContainer>
521
+ <Title title="Grouped icons (SVGs)" theme="light" level={4} />
522
+ <Listbox
523
+ id="x"
524
+ currentValue={["0", "3"]}
525
+ options={icon_options_grouped}
526
+ visualFocusIndex={-1}
527
+ lastOptionIndex={3}
528
+ multiple={false}
529
+ optional={false}
530
+ optionalItem={{ label: "Empty", value: "" }}
531
+ searchable={false}
532
+ handleOptionOnClick={() => {}}
533
+ styles={{ width: 360 }}
534
+ />
535
+ </ExampleContainer>
536
+ <ExampleContainer>
537
+ <Title title="Grouped icons (Images)" theme="light" level={4} />
538
+ <Listbox
539
+ id="x"
540
+ currentValue={["facebook", "figma"]}
541
+ options={url_options}
542
+ visualFocusIndex={-1}
543
+ lastOptionIndex={6}
544
+ multiple={true}
545
+ optional={false}
546
+ optionalItem={{ label: "Empty", value: "" }}
547
+ searchable={false}
548
+ handleOptionOnClick={() => {}}
549
+ styles={{ width: 360 }}
550
+ />
551
+ </ExampleContainer>
552
+ </ThemeProvider>
553
+ );
554
+ };
399
555
 
400
- />
401
- </ExampleContainer>
402
- <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
- />
417
- </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
- />
433
- </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
- />
449
- </ExampleContainer>
450
- </>
451
- );
452
556
  const SearchableSelect = () => (
453
557
  <ExampleContainer expanded>
454
558
  <Title title="Searchable select" theme="light" level={4} />
@@ -499,37 +603,6 @@ const MultipleGroupedOptionsSelect = () => (
499
603
  />
500
604
  </ExampleContainer>
501
605
  );
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 = () => (
521
- <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
- />
530
- </ExampleContainer>
531
- );
532
-
533
606
  const MultipleSearchable = () => (
534
607
  <ExampleContainer expanded>
535
608
  <Title title="Searchable multiple select with value" theme="light" level={4} />
@@ -560,10 +633,7 @@ ListboxStates.play = async ({ canvasElement }) => {
560
633
  export const Searchable = SearchableSelect.bind({});
561
634
  Searchable.play = async ({ canvasElement }) => {
562
635
  const canvas = within(canvasElement);
563
- await userEvent.click(canvas.getByRole("combobox"));
564
- await waitFor(async () => {
565
- userEvent.type(canvas.getByRole("combobox"), "r");
566
- });
636
+ await userEvent.type(canvas.getByRole("combobox"), "r");
567
637
  };
568
638
 
569
639
  export const SearchableWithValue = SearchValue.bind({});
@@ -597,31 +667,3 @@ MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
597
667
  const select = canvas.getByRole("combobox");
598
668
  await userEvent.click(select);
599
669
  };
600
-
601
- export const WithIconsDisplayed = SelectWithIcons.bind({});
602
- WithIconsDisplayed.play = async ({ canvasElement }) => {
603
- const canvas = within(canvasElement);
604
- const select = canvas.getByRole("combobox");
605
- await userEvent.click(select);
606
- };
607
-
608
- export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
609
- WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
610
- const canvas = within(canvasElement);
611
- const select = canvas.getByRole("combobox");
612
- await userEvent.click(select);
613
- };
614
-
615
- export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
616
- MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
617
- const canvas = within(canvasElement);
618
- const select = canvas.getByRole("combobox");
619
- await userEvent.click(select);
620
- };
621
-
622
- export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
623
- MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
624
- const canvas = within(canvasElement);
625
- const select = canvas.getByRole("combobox");
626
- await userEvent.click(select);
627
- };