@dxc-technology/halstack-react 0.0.0-8b5e703 → 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.
- package/HalstackContext.js +1 -4
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +31 -32
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/card/Card.js +34 -36
- package/common/variables.js +3 -18
- package/inline/Inline.d.ts +4 -0
- package/inline/Inline.js +54 -0
- package/inline/Inline.stories.tsx +240 -0
- package/inline/types.d.ts +32 -0
- package/{radio → inline}/types.js +0 -0
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +32 -32
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +4 -3
- package/layout/ApplicationLayout.js +83 -102
- package/layout/ApplicationLayout.stories.tsx +14 -59
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +5 -10
- package/link/Link.js +10 -3
- package/main.d.ts +2 -2
- package/main.js +8 -8
- package/package.json +2 -1
- package/paginator/Paginator.test.js +42 -0
- package/quick-nav/QuickNav.js +2 -2
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +30 -7
- package/select/Select.js +46 -31
- package/select/Select.stories.tsx +130 -98
- package/select/Select.test.js +42 -0
- package/select/types.d.ts +3 -4
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +20 -9
- package/tabs-nav/NavTabs.d.ts +2 -1
- package/tabs-nav/NavTabs.js +35 -16
- package/tabs-nav/Tab.js +26 -11
- package/tabs-nav/types.d.ts +6 -4
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- 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="
|
|
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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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,7 +454,7 @@ const SearchableSelect = () => (
|
|
|
368
454
|
<DxcSelect label="Select Label" searchable options={single_options} placeholder="Choose an option" />
|
|
369
455
|
</ExampleContainer>
|
|
370
456
|
);
|
|
371
|
-
const
|
|
457
|
+
const SearchValue = () => (
|
|
372
458
|
<ExampleContainer expanded>
|
|
373
459
|
<Title title="Searchable select with value" theme="light" level={4} />
|
|
374
460
|
<DxcSelect
|
|
@@ -380,7 +466,6 @@ const SearchableWithValue = () => (
|
|
|
380
466
|
/>
|
|
381
467
|
</ExampleContainer>
|
|
382
468
|
);
|
|
383
|
-
|
|
384
469
|
const MultipleSelect = () => (
|
|
385
470
|
<>
|
|
386
471
|
<ExampleContainer expanded>
|
|
@@ -443,36 +528,7 @@ const MultipleGroupedOptionsSelectWithIcons = () => (
|
|
|
443
528
|
/>
|
|
444
529
|
</ExampleContainer>
|
|
445
530
|
);
|
|
446
|
-
|
|
447
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
448
|
-
<Title title="Hovered Option" theme="light" level={4} />
|
|
449
|
-
<DxcSelect label="Hovered" options={one_option} placeholder="Choose an option" />
|
|
450
|
-
</ExampleContainer>
|
|
451
|
-
);
|
|
452
|
-
const OnlyOneOptionFocused = () => (
|
|
453
|
-
<ExampleContainer pseudoState="pseudo-focus" expanded>
|
|
454
|
-
<Title title="Focused Option" theme="light" level={4} />
|
|
455
|
-
<DxcSelect label="Focused" options={one_option} placeholder="Choose an option" />
|
|
456
|
-
</ExampleContainer>
|
|
457
|
-
);
|
|
458
|
-
const OnlyOneOptionActived = () => (
|
|
459
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
460
|
-
<Title title="Actived Option" theme="light" level={4} />
|
|
461
|
-
<DxcSelect label="Actived" options={one_option} placeholder="Choose an option" />
|
|
462
|
-
</ExampleContainer>
|
|
463
|
-
);
|
|
464
|
-
const SelectedOptionHovered = () => (
|
|
465
|
-
<ExampleContainer pseudoState="pseudo-hover" expanded>
|
|
466
|
-
<Title title="Hovered Selected Option" theme="light" level={4} />
|
|
467
|
-
<DxcSelect label="Hovered" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
468
|
-
</ExampleContainer>
|
|
469
|
-
);
|
|
470
|
-
const SelectedOptionActived = () => (
|
|
471
|
-
<ExampleContainer pseudoState="pseudo-active" expanded>
|
|
472
|
-
<Title title="Actived Selected Option" theme="light" level={4} />
|
|
473
|
-
<DxcSelect label="Actived" defaultValue="1" options={one_option} placeholder="Choose an option" />
|
|
474
|
-
</ExampleContainer>
|
|
475
|
-
);
|
|
531
|
+
|
|
476
532
|
const MultipleSearchable = () => (
|
|
477
533
|
<ExampleContainer expanded>
|
|
478
534
|
<Title title="Searchable multiple select with value" theme="light" level={4} />
|
|
@@ -486,12 +542,20 @@ const MultipleSearchable = () => (
|
|
|
486
542
|
/>
|
|
487
543
|
</ExampleContainer>
|
|
488
544
|
);
|
|
489
|
-
|
|
490
|
-
|
|
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 }) => {
|
|
491
554
|
const canvas = within(canvasElement);
|
|
492
555
|
const select = canvas.getByRole("combobox");
|
|
493
556
|
await userEvent.click(select);
|
|
494
557
|
};
|
|
558
|
+
|
|
495
559
|
export const Searchable = SearchableSelect.bind({});
|
|
496
560
|
Searchable.play = async ({ canvasElement }) => {
|
|
497
561
|
const canvas = within(canvasElement);
|
|
@@ -500,14 +564,15 @@ Searchable.play = async ({ canvasElement }) => {
|
|
|
500
564
|
userEvent.type(canvas.getByRole("combobox"), "r");
|
|
501
565
|
});
|
|
502
566
|
};
|
|
503
|
-
|
|
504
|
-
|
|
567
|
+
|
|
568
|
+
export const SearchableWithValue = SearchValue.bind({});
|
|
569
|
+
SearchableWithValue.play = async ({ canvasElement }) => {
|
|
505
570
|
const canvas = within(canvasElement);
|
|
506
571
|
await userEvent.click(canvas.getByRole("combobox"));
|
|
507
572
|
};
|
|
508
573
|
|
|
509
|
-
export const
|
|
510
|
-
|
|
574
|
+
export const MultipleSearchableWithValue = MultipleSearchable.bind({});
|
|
575
|
+
MultipleSearchableWithValue.play = async ({ canvasElement }) => {
|
|
511
576
|
const canvas = within(canvasElement);
|
|
512
577
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
513
578
|
};
|
|
@@ -519,75 +584,42 @@ GroupOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
|
519
584
|
await userEvent.click(select);
|
|
520
585
|
};
|
|
521
586
|
|
|
522
|
-
export const
|
|
523
|
-
|
|
587
|
+
export const MultipleOptionsDisplayed = MultipleSelect.bind({});
|
|
588
|
+
MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
524
589
|
const canvas = within(canvasElement);
|
|
525
590
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
526
591
|
};
|
|
527
592
|
|
|
528
|
-
export const
|
|
529
|
-
|
|
530
|
-
const canvas = within(canvasElement);
|
|
531
|
-
const select = canvas.getByRole("combobox");
|
|
532
|
-
await userEvent.click(select);
|
|
533
|
-
};
|
|
534
|
-
export const SelectWithIconsDisplayed = SelectWithIcons.bind({});
|
|
535
|
-
SelectWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
593
|
+
export const MultipleGroupedOptionsDisplayed = MultipleGroupedOptionsSelect.bind({});
|
|
594
|
+
MultipleGroupedOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
536
595
|
const canvas = within(canvasElement);
|
|
537
596
|
const select = canvas.getByRole("combobox");
|
|
538
597
|
await userEvent.click(select);
|
|
539
598
|
};
|
|
540
599
|
|
|
541
|
-
export const
|
|
542
|
-
|
|
543
|
-
const canvas = within(canvasElement);
|
|
544
|
-
const select = canvas.getByRole("combobox");
|
|
545
|
-
await userEvent.click(select);
|
|
546
|
-
};
|
|
547
|
-
export const SelectMultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
548
|
-
SelectMultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
600
|
+
export const WithIconsDisplayed = SelectWithIcons.bind({});
|
|
601
|
+
WithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
549
602
|
const canvas = within(canvasElement);
|
|
550
603
|
const select = canvas.getByRole("combobox");
|
|
551
604
|
await userEvent.click(select);
|
|
552
605
|
};
|
|
553
606
|
|
|
554
|
-
export const
|
|
555
|
-
|
|
607
|
+
export const WithRescaledIconsDisplayed = RescaledIcons.bind({});
|
|
608
|
+
WithRescaledIconsDisplayed.play = async ({ canvasElement }) => {
|
|
556
609
|
const canvas = within(canvasElement);
|
|
557
610
|
const select = canvas.getByRole("combobox");
|
|
558
611
|
await userEvent.click(select);
|
|
559
612
|
};
|
|
560
613
|
|
|
561
|
-
export const
|
|
562
|
-
|
|
614
|
+
export const MultipleWithIconsDisplayed = SelectMultipleWithIcons.bind({});
|
|
615
|
+
MultipleWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
563
616
|
const canvas = within(canvasElement);
|
|
564
617
|
const select = canvas.getByRole("combobox");
|
|
565
618
|
await userEvent.click(select);
|
|
566
619
|
};
|
|
567
620
|
|
|
568
|
-
export const
|
|
569
|
-
|
|
570
|
-
const canvas = within(canvasElement);
|
|
571
|
-
const select = canvas.getByRole("combobox");
|
|
572
|
-
await userEvent.click(select);
|
|
573
|
-
await waitFor(async () => {
|
|
574
|
-
fireEvent.keyDown(select, { key: "ArrowDown", code: "ArrowDown", keyCode: 40, charCode: 40 });
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
export const OptionActived = OnlyOneOptionActived.bind({});
|
|
578
|
-
OptionActived.play = async ({ canvasElement }) => {
|
|
579
|
-
const canvas = within(canvasElement);
|
|
580
|
-
const select = canvas.getByRole("combobox");
|
|
581
|
-
await userEvent.click(select);
|
|
582
|
-
};
|
|
583
|
-
export const OptionSelectedHovered = SelectedOptionHovered.bind({});
|
|
584
|
-
OptionSelectedHovered.play = async ({ canvasElement }) => {
|
|
585
|
-
const canvas = within(canvasElement);
|
|
586
|
-
const select = canvas.getByRole("combobox");
|
|
587
|
-
await userEvent.click(select);
|
|
588
|
-
};
|
|
589
|
-
export const OptionSelectedActived = SelectedOptionActived.bind({});
|
|
590
|
-
OptionSelectedActived.play = async ({ canvasElement }) => {
|
|
621
|
+
export const MultipleGroupedWithIconsDisplayed = MultipleGroupedOptionsSelectWithIcons.bind({});
|
|
622
|
+
MultipleGroupedWithIconsDisplayed.play = async ({ canvasElement }) => {
|
|
591
623
|
const canvas = within(canvasElement);
|
|
592
624
|
const select = canvas.getByRole("combobox");
|
|
593
625
|
await userEvent.click(select);
|
package/select/Select.test.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
6
|
+
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
|
|
5
9
|
var _react = _interopRequireDefault(require("react"));
|
|
6
10
|
|
|
7
11
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
@@ -10,6 +14,44 @@ var _react2 = require("@testing-library/react");
|
|
|
10
14
|
|
|
11
15
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
12
16
|
|
|
17
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
18
|
+
global.globalThis = global;
|
|
19
|
+
|
|
20
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
21
|
+
function ResizeObserver(cb) {
|
|
22
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
23
|
+
this.cb = cb;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
27
|
+
key: "observe",
|
|
28
|
+
value: function observe() {
|
|
29
|
+
this.cb([{
|
|
30
|
+
borderBoxSize: {
|
|
31
|
+
inlineSize: 0,
|
|
32
|
+
blockSize: 0
|
|
33
|
+
}
|
|
34
|
+
}]);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "unobserve",
|
|
38
|
+
value: function unobserve() {}
|
|
39
|
+
}]);
|
|
40
|
+
return ResizeObserver;
|
|
41
|
+
}();
|
|
42
|
+
|
|
43
|
+
global.DOMRect = {
|
|
44
|
+
fromRect: function fromRect() {
|
|
45
|
+
return {
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
13
55
|
var single_options = [{
|
|
14
56
|
label: "Option 01",
|
|
15
57
|
value: "1"
|
package/select/types.d.ts
CHANGED
|
@@ -201,11 +201,10 @@ export declare type ListboxProps = {
|
|
|
201
201
|
optionalItem: Option;
|
|
202
202
|
searchable: boolean;
|
|
203
203
|
handleOptionOnClick: (option: Option) => void;
|
|
204
|
+
styles: {
|
|
205
|
+
width: number;
|
|
206
|
+
};
|
|
204
207
|
};
|
|
205
|
-
/**
|
|
206
|
-
* Reference to the listbox component.
|
|
207
|
-
*/
|
|
208
|
-
export declare type ListboxRefType = HTMLUListElement;
|
|
209
208
|
/**
|
|
210
209
|
* Reference to the select component.
|
|
211
210
|
*/
|
package/sidenav/Sidenav.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import SidenavPropsType, { SidenavTitlePropsType, SidenavSubtitlePropsType, SidenavLinkPropsType } from "./types
|
|
2
|
+
import SidenavPropsType, { SidenavTitlePropsType, SidenavSubtitlePropsType, SidenavLinkPropsType } from "./types";
|
|
3
3
|
declare const DxcSidenav: {
|
|
4
4
|
({ padding, children }: SidenavPropsType): JSX.Element;
|
|
5
5
|
Title: ({ children }: SidenavTitlePropsType) => JSX.Element;
|
package/sidenav/Sidenav.js
CHANGED
|
@@ -21,6 +21,8 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
21
21
|
|
|
22
22
|
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
23
23
|
|
|
24
|
+
var _SidenavContext = require("../layout/SidenavContext");
|
|
25
|
+
|
|
24
26
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
25
27
|
|
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -33,7 +35,7 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
33
35
|
var colorsTheme = (0, _useTheme["default"])();
|
|
34
36
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
35
37
|
theme: colorsTheme.sidenav
|
|
36
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
38
|
+
}, /*#__PURE__*/_react["default"].createElement(SidenavContainer, {
|
|
37
39
|
padding: padding
|
|
38
40
|
}, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
|
|
39
41
|
color: colorsTheme.sidenav.backgroundColor
|
|
@@ -42,12 +44,12 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
42
44
|
|
|
43
45
|
var Title = function Title(_ref2) {
|
|
44
46
|
var children = _ref2.children;
|
|
45
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuTitle, null, children);
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
var Subtitle = function Subtitle(_ref3) {
|
|
49
51
|
var children = _ref3.children;
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuSubTitle, null, children);
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
var Link = function Link(_ref4) {
|
|
@@ -56,15 +58,24 @@ var Link = function Link(_ref4) {
|
|
|
56
58
|
href = _ref4.href,
|
|
57
59
|
onClick = _ref4.onClick,
|
|
58
60
|
children = _ref4.children;
|
|
59
|
-
|
|
61
|
+
var setIsSidenavVisibleResponsive = (0, _SidenavContext.useResponsiveSidenavVisibility)();
|
|
62
|
+
|
|
63
|
+
var handleClick = function handleClick() {
|
|
64
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
65
|
+
setIsSidenavVisibleResponsive === null || setIsSidenavVisibleResponsive === void 0 ? void 0 : setIsSidenavVisibleResponsive(false);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return /*#__PURE__*/_react["default"].createElement(SidenavMenuLink, {
|
|
60
69
|
tabIndex: tabIndex,
|
|
61
70
|
href: href,
|
|
62
|
-
onClick:
|
|
71
|
+
onClick: handleClick
|
|
63
72
|
}, children);
|
|
64
73
|
};
|
|
65
74
|
|
|
66
|
-
var
|
|
75
|
+
var SidenavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n background-color: ", ";\n\n @media (max-width: ", "rem) {\n width: ", ";\n }\n\n width: ", ";\n padding: ", ";\n\n overflow-y: auto;\n overflow-x: hidden;\n ::-webkit-scrollbar {\n width: 2px;\n }\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n"])), function (props) {
|
|
67
76
|
return props.theme.backgroundColor;
|
|
77
|
+
}, _variables.responsiveSizes.medium, function (props) {
|
|
78
|
+
return props.padding ? "calc(100vw - ".concat(_variables.spaces[props.padding], " - ").concat(_variables.spaces[props.padding], ")") : "100vw";
|
|
68
79
|
}, function (props) {
|
|
69
80
|
return props.padding ? "calc(300px - ".concat(_variables.spaces[props.padding], " - ").concat(_variables.spaces[props.padding], ")") : "300px";
|
|
70
81
|
}, function (props) {
|
|
@@ -75,7 +86,7 @@ var SideNavContainer = _styledComponents["default"].div(_templateObject || (_tem
|
|
|
75
86
|
return props.theme.scrollBarThumbColor;
|
|
76
87
|
});
|
|
77
88
|
|
|
78
|
-
var
|
|
89
|
+
var SidenavMenuTitle = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n margin-bottom: 16px;\n"])), function (props) {
|
|
79
90
|
return props.theme.titleFontFamily;
|
|
80
91
|
}, function (props) {
|
|
81
92
|
return props.theme.titleFontSize;
|
|
@@ -91,7 +102,7 @@ var SideNavMenuTitle = _styledComponents["default"].div(_templateObject2 || (_te
|
|
|
91
102
|
return props.theme.titleFontTextTransform;
|
|
92
103
|
});
|
|
93
104
|
|
|
94
|
-
var
|
|
105
|
+
var SidenavMenuSubTitle = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n margin-bottom: 4px;\n"])), function (props) {
|
|
95
106
|
return props.theme.subtitleFontFamily;
|
|
96
107
|
}, function (props) {
|
|
97
108
|
return props.theme.subtitleFontSize;
|
|
@@ -107,7 +118,7 @@ var SideNavMenuSubTitle = _styledComponents["default"].div(_templateObject3 || (
|
|
|
107
118
|
return props.theme.subtitleFontTextTransform;
|
|
108
119
|
});
|
|
109
120
|
|
|
110
|
-
var
|
|
121
|
+
var SidenavMenuLink = _styledComponents["default"].a(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n text-decoration: ", ";\n margin: ", ";\n cursor: pointer;\n\n :focus-visible {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n"])), function (props) {
|
|
111
122
|
return props.theme.linkFontFamily;
|
|
112
123
|
}, function (props) {
|
|
113
124
|
return props.theme.linkFontSize;
|
package/tabs-nav/NavTabs.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { NavTabsProps } from "./types";
|
|
2
|
+
import { NavTabsContextProps, NavTabsProps } from "./types";
|
|
3
|
+
export declare const NavTabsContext: React.Context<NavTabsContextProps>;
|
|
3
4
|
declare const DxcNavTabs: {
|
|
4
5
|
({ iconPosition, tabIndex, children }: NavTabsProps): JSX.Element;
|
|
5
6
|
Tab: React.ForwardRefExoticComponent<import("./types").TabProps & React.RefAttributes<HTMLAnchorElement>>;
|
package/tabs-nav/NavTabs.js
CHANGED
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports["default"] = void 0;
|
|
10
|
+
exports["default"] = exports.NavTabsContext = void 0;
|
|
11
11
|
|
|
12
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
13
|
|
|
@@ -27,10 +27,25 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
27
27
|
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
29
|
|
|
30
|
+
var NavTabsContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
31
|
+
exports.NavTabsContext = NavTabsContext;
|
|
32
|
+
|
|
33
|
+
var getPropInChild = function getPropInChild(child, propName) {
|
|
34
|
+
return child.props ? child.props[propName] ? child.props[propName] : child.props.children ? getPropInChild(child.props.children, propName) : undefined : undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var getLabelFromTab = function getLabelFromTab(child) {
|
|
38
|
+
if (typeof child === "string") {
|
|
39
|
+
return child.toString();
|
|
40
|
+
} else if (child.props.children) {
|
|
41
|
+
return Array.isArray(child.props.children) ? getLabelFromTab(child.props.children[0]) : getLabelFromTab(child.props.children);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
30
45
|
var getPreviousTabIndex = function getPreviousTabIndex(array, initialIndex) {
|
|
31
46
|
var index = initialIndex === 0 ? array.length - 1 : initialIndex - 1;
|
|
32
47
|
|
|
33
|
-
while (array[index]
|
|
48
|
+
while (getPropInChild(array[index], "disabled")) {
|
|
34
49
|
index = index === 0 ? array.length - 1 : index - 1;
|
|
35
50
|
}
|
|
36
51
|
|
|
@@ -40,7 +55,7 @@ var getPreviousTabIndex = function getPreviousTabIndex(array, initialIndex) {
|
|
|
40
55
|
var getNextTabIndex = function getNextTabIndex(array, initialIndex) {
|
|
41
56
|
var index = initialIndex === array.length - 1 ? 0 : initialIndex + 1;
|
|
42
57
|
|
|
43
|
-
while (array[index]
|
|
58
|
+
while (getPropInChild(array[index], "disabled")) {
|
|
44
59
|
index = index === array.length - 1 ? 0 : index + 1;
|
|
45
60
|
}
|
|
46
61
|
|
|
@@ -60,22 +75,33 @@ var DxcNavTabs = function DxcNavTabs(_ref) {
|
|
|
60
75
|
innerFocus = _useState2[0],
|
|
61
76
|
setInnerFocus = _useState2[1];
|
|
62
77
|
|
|
78
|
+
var contextValue = (0, _react.useMemo)(function () {
|
|
79
|
+
return {
|
|
80
|
+
iconPosition: iconPosition,
|
|
81
|
+
tabIndex: tabIndex,
|
|
82
|
+
hasIcons: _react["default"].Children.toArray(children).some(function (child) {
|
|
83
|
+
return getPropInChild(child, "icon");
|
|
84
|
+
}),
|
|
85
|
+
focusedLabel: innerFocus === null ? undefined : getLabelFromTab(children[innerFocus])
|
|
86
|
+
};
|
|
87
|
+
}, [iconPosition, tabIndex, innerFocus]);
|
|
88
|
+
|
|
63
89
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
64
90
|
var activeTab = _react["default"].Children.toArray(children).findIndex(function (child) {
|
|
65
|
-
return child
|
|
91
|
+
return getPropInChild(child, "active");
|
|
66
92
|
});
|
|
67
93
|
|
|
68
94
|
switch (event.keyCode) {
|
|
69
95
|
case 37:
|
|
70
96
|
// arrow left
|
|
71
97
|
event.preventDefault();
|
|
72
|
-
setInnerFocus(getPreviousTabIndex(
|
|
98
|
+
setInnerFocus(getPreviousTabIndex(children, innerFocus === null ? activeTab : innerFocus));
|
|
73
99
|
break;
|
|
74
100
|
|
|
75
101
|
case 39:
|
|
76
102
|
// arrow right
|
|
77
103
|
event.preventDefault();
|
|
78
|
-
setInnerFocus(getNextTabIndex(
|
|
104
|
+
setInnerFocus(getNextTabIndex(children, innerFocus === null ? activeTab : innerFocus));
|
|
79
105
|
break;
|
|
80
106
|
}
|
|
81
107
|
};
|
|
@@ -86,16 +112,9 @@ var DxcNavTabs = function DxcNavTabs(_ref) {
|
|
|
86
112
|
onKeyDown: handleOnKeyDown,
|
|
87
113
|
role: "tablist",
|
|
88
114
|
"aria-label": "Navigation tabs"
|
|
89
|
-
}, _react["default"].
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
tabIndex: tabIndex,
|
|
93
|
-
hasIcons: _react["default"].Children.toArray(children).some(function (child) {
|
|
94
|
-
return child.props.icon;
|
|
95
|
-
}),
|
|
96
|
-
focused: index === innerFocus
|
|
97
|
-
});
|
|
98
|
-
})));
|
|
115
|
+
}, /*#__PURE__*/_react["default"].createElement(NavTabsContext.Provider, {
|
|
116
|
+
value: contextValue
|
|
117
|
+
}, children)));
|
|
99
118
|
};
|
|
100
119
|
|
|
101
120
|
DxcNavTabs.Tab = _Tab["default"];
|