@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.
- package/HalstackContext.js +98 -50
- package/accordion/Accordion.js +7 -13
- package/accordion/Accordion.stories.tsx +102 -13
- package/alert/Alert.stories.tsx +28 -0
- package/box/Box.js +1 -3
- package/box/Box.stories.tsx +15 -0
- package/button/Button.js +11 -13
- package/button/Button.stories.tsx +150 -8
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +16 -15
- package/checkbox/Checkbox.stories.tsx +131 -59
- package/checkbox/types.d.ts +4 -0
- package/chip/Chip.js +16 -22
- package/chip/Chip.stories.tsx +96 -9
- package/common/variables.js +286 -290
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.js +60 -73
- package/dialog/Dialog.stories.tsx +211 -159
- package/dialog/Dialog.test.js +301 -2
- package/dropdown/Dropdown.js +35 -35
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +17 -22
- package/dropdown/DropdownMenu.js +8 -18
- package/dropdown/DropdownMenuItem.js +4 -15
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +169 -222
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +12 -53
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +39 -63
- package/file-input/types.d.ts +17 -0
- package/footer/Footer.stories.tsx +91 -0
- package/header/Header.js +18 -20
- package/header/Header.stories.tsx +149 -6
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +60 -0
- package/main.d.ts +1 -1
- package/main.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
- package/{tabs-nav → nav-tabs}/Tab.js +35 -15
- package/number-input/NumberInput.test.js +5 -6
- package/package.json +7 -12
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +5 -11
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +48 -105
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +40 -63
- package/resultsetTable/types.d.ts +2 -2
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +43 -24
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +17 -22
- package/select/types.d.ts +2 -2
- package/sidenav/Sidenav.js +8 -10
- package/sidenav/Sidenav.stories.tsx +148 -46
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +9 -8
- package/slider/Slider.stories.tsx +57 -0
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +27 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +5 -4
- package/switch/Switch.stories.tsx +33 -0
- package/switch/types.d.ts +6 -1
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +1 -1
- package/tabs/Tab.js +3 -5
- package/tabs/Tabs.js +3 -3
- package/tabs/Tabs.stories.tsx +45 -5
- package/tag/Tag.stories.tsx +14 -1
- package/text-input/Suggestion.js +32 -5
- package/text-input/TextInput.js +7 -11
- package/text-input/TextInput.stories.tsx +92 -4
- package/text-input/TextInput.test.js +587 -634
- package/textarea/Textarea.stories.jsx +60 -1
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +139 -0
- package/wizard/Wizard.stories.tsx +20 -0
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/NavTabs.test.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
- /package/{tabs-nav → nav-tabs}/types.js +0 -0
|
@@ -2,14 +2,15 @@ import React from "react";
|
|
|
2
2
|
import DxcFileInput from "./FileInput";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import FileItem from "./FileItem";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
7
|
|
|
6
8
|
export default {
|
|
7
9
|
title: "File input",
|
|
8
10
|
component: DxcFileInput,
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
const picPreview =
|
|
12
|
-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABmJLR0QA/wD/AP+gvaeTAAAEDklEQVRogdXaXaxcUxQH8J/etloajVT1I9qgCbdIUB8PXPeKBJHgsV5ExAuVivBUgtSDxgNBVMVHxEeRUhIhkpJ40BYhoTShaQglQtA2VR+ttjMe1j45c6cztzNnzszc+09Ocs/Za+39/++zzt5rr7l0D1diA35P14b0bMJgAE+g2uR6FpP7xq4NZCL2YjlOSNdt6VkVj/eNXYu4VhD9G+c3aL8gtVWS7bjEsfhRCFk2ht2yZPNT8hl3WCUIfoZJY9gdhY+T7QM94NUWFmEfDuHCFuyXJNv9OL2LvNrGO2KGn2rD55nks6ErjAog+8B3YXYbfrPwR/Lt+4d/NLYLMrcW8F+efL/DtBJ5tY17EpEvxEbYLgawJfVxXxObRZhbiF2LWCjfE4Y66OeS1Mc/OLnm+Uw8ggP4oYP+j4hHxUy+VEJfL6e+3hTL8/X4RZ7W/FvCGE1xOdZp7wNvhvny9CULtSo+1QMhZWImPpQL+A03YbouCpkqXn8ZqA+jg1iD41P7NF0QMiAy2N0ipDrFWUa/hU9wXp1N6UIuEktsNug3HfY3gD2pr4rYTxrlZ6UJmY3n0mBZ7JYhhDi3ZP1+i6sb2HQsZBJuEEfUqljjV+Ic5QkhzifZylTF+xisae9IyBIRr1nnb+PU1DaoXCHkk5blXfvxGGYoKGQWnhbpdZb/XFNn0w0hGebgBXm4fY/rtClkOn6Wz8j96Vk9uikkw5DRm2JLQrKV4hB2pr+niJznuPI5toRN4rx/u1jZiLfUMqZiBf4Ss7Bb7Bu1WW0v3kgt5mA17i7iPB8vymN1Cy5Obb0W0jFm4Fd5jFbEfjJsggl5UBDeiLvk4bZP/4RcJj76W1p1OE2sXAfFBkgcotYrL0UpghF5BfOkVhzeTQ5rGrRdIXbiVWWxaxNvCG6vHckwq4jsFPXa8YYF8gPYVc2MaisiN/eGVyGsEBy3C86H4d5k8LliFZFeYSq+FlwP218WiJWpIpbY8Y5heeXllNqGdcqriPQKrwrO67MHZwh1ezGvT6SKIKu8VLCYWGareKgPZEZECrS5oP/Dgvtq2Jpuzi6FWmuYh7XyfK5asJ9zk++X5EWARuePsjEZd9SM+afOhBwjz9TtSDeDY3mUgBH526/gFRHnnQhZLD9NejLdvG7sn8yKoj6MtuLSmvaiQibJ8781RNl+V3rwEZaKpGxKQeIZ6sNoD+5s0G87QqYkbksT1yydWpQZDMl/kS16bawb9AN5GK3VfGnvZMwd0qEv+w+ETTgTN4rEcRAninSgVdTP6oE2fFvFf6JIuA1v4XmRkXQVk+UFhGoacKXDJ6eTj72nmGt0DWCbONdkmDBCMgzjK6MrmAtNQCGUvyH2HfXhNmGFZBgRNYD3Ou3ofwlpcfptqgzTAAAAAElFTkSuQmCC";
|
|
13
|
+
const picPreview = "https://cdn.mos.cms.futurecdn.net/CAZ6JXi6huSuN4QGE627NR.jpg";
|
|
13
14
|
|
|
14
15
|
const file1 = new File(["file1"], "file.pdf", { type: "text/plain" });
|
|
15
16
|
const file2 = new File(["file2"], "file2.mp3", {
|
|
@@ -21,7 +22,7 @@ const file3 = new File(["file3"], "file3.png", {
|
|
|
21
22
|
const file4 = new File(["file4"], "file4file4file4file4file4file4file4file4file4.mp4", {
|
|
22
23
|
type: "video",
|
|
23
24
|
});
|
|
24
|
-
const file5 = new File(["
|
|
25
|
+
const file5 = new File(["file5"], "file5file5file5file5file5file5file5file5file5.mp4", {
|
|
25
26
|
type: "video",
|
|
26
27
|
});
|
|
27
28
|
|
|
@@ -53,7 +54,7 @@ const filesExamples = [
|
|
|
53
54
|
file: file4,
|
|
54
55
|
},
|
|
55
56
|
{
|
|
56
|
-
error: "
|
|
57
|
+
error: "This error message is a multiline paragraph for testing.",
|
|
57
58
|
file: file5,
|
|
58
59
|
},
|
|
59
60
|
{
|
|
@@ -63,19 +64,53 @@ const filesExamples = [
|
|
|
63
64
|
},
|
|
64
65
|
];
|
|
65
66
|
|
|
67
|
+
const opinionatedTheme = {
|
|
68
|
+
fileInput: {
|
|
69
|
+
fontColor: "#000000",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
66
73
|
export const Chromatic = () => (
|
|
67
74
|
<>
|
|
75
|
+
<Title title="File item states" theme="light" level={2} />
|
|
68
76
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
69
|
-
<Title title="
|
|
70
|
-
<
|
|
77
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
78
|
+
<FileItem
|
|
79
|
+
fileName="file"
|
|
80
|
+
error=""
|
|
81
|
+
singleFileMode={false}
|
|
82
|
+
showPreview={false}
|
|
83
|
+
preview={picPreview}
|
|
84
|
+
type="image/png"
|
|
85
|
+
onDelete={() => {}}
|
|
86
|
+
tabIndex={0}
|
|
87
|
+
/>
|
|
71
88
|
</ExampleContainer>
|
|
72
89
|
<ExampleContainer pseudoState="pseudo-focus">
|
|
73
|
-
<Title title="
|
|
74
|
-
<
|
|
90
|
+
<Title title="Focused" theme="light" level={4} />
|
|
91
|
+
<FileItem
|
|
92
|
+
fileName="file"
|
|
93
|
+
error=""
|
|
94
|
+
singleFileMode={false}
|
|
95
|
+
showPreview={false}
|
|
96
|
+
preview={picPreview}
|
|
97
|
+
type="image/png"
|
|
98
|
+
onDelete={() => {}}
|
|
99
|
+
tabIndex={0}
|
|
100
|
+
/>
|
|
75
101
|
</ExampleContainer>
|
|
76
102
|
<ExampleContainer pseudoState="pseudo-active">
|
|
77
|
-
<Title title="
|
|
78
|
-
<
|
|
103
|
+
<Title title="Actived" theme="light" level={4} />
|
|
104
|
+
<FileItem
|
|
105
|
+
fileName="file"
|
|
106
|
+
error=""
|
|
107
|
+
singleFileMode={false}
|
|
108
|
+
showPreview={false}
|
|
109
|
+
preview={picPreview}
|
|
110
|
+
type="image/png"
|
|
111
|
+
onDelete={() => {}}
|
|
112
|
+
tabIndex={0}
|
|
113
|
+
/>
|
|
79
114
|
</ExampleContainer>
|
|
80
115
|
<Title title="File" theme="light" level={2} />
|
|
81
116
|
<ExampleContainer>
|
|
@@ -501,7 +536,83 @@ export const Chromatic = () => (
|
|
|
501
536
|
mode="dropzone"
|
|
502
537
|
margin="xxlarge"
|
|
503
538
|
/>
|
|
504
|
-
|
|
539
|
+
</ExampleContainer>
|
|
540
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
541
|
+
<ExampleContainer>
|
|
542
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
543
|
+
<Title title="Single file" theme="light" level={4} />
|
|
544
|
+
<DxcFileInput
|
|
545
|
+
label="File input"
|
|
546
|
+
helperText="Please select files"
|
|
547
|
+
value={fileExample}
|
|
548
|
+
multiple={false}
|
|
549
|
+
callbackFile={() => {}}
|
|
550
|
+
/>
|
|
551
|
+
</HalstackProvider>
|
|
552
|
+
</ExampleContainer>
|
|
553
|
+
<ExampleContainer>
|
|
554
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
555
|
+
<Title title="Invalid single file" theme="light" level={4} />
|
|
556
|
+
<DxcFileInput
|
|
557
|
+
label="File input"
|
|
558
|
+
helperText="Please select files"
|
|
559
|
+
value={fileExampleError}
|
|
560
|
+
multiple={false}
|
|
561
|
+
callbackFile={() => {}}
|
|
562
|
+
/>
|
|
563
|
+
</HalstackProvider>
|
|
564
|
+
</ExampleContainer>
|
|
565
|
+
<ExampleContainer>
|
|
566
|
+
<Title title="Single file" theme="light" level={4} />
|
|
567
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
568
|
+
<DxcFileInput
|
|
569
|
+
mode="filedrop"
|
|
570
|
+
label="File input"
|
|
571
|
+
helperText="Please select files"
|
|
572
|
+
value={fileExample}
|
|
573
|
+
multiple={false}
|
|
574
|
+
callbackFile={() => {}}
|
|
575
|
+
/>
|
|
576
|
+
</HalstackProvider>
|
|
577
|
+
</ExampleContainer>
|
|
578
|
+
<ExampleContainer>
|
|
579
|
+
<Title title="Invalid single file" theme="light" level={4} />
|
|
580
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
581
|
+
<DxcFileInput
|
|
582
|
+
mode="filedrop"
|
|
583
|
+
label="File input"
|
|
584
|
+
helperText="Please select files"
|
|
585
|
+
value={fileExampleError}
|
|
586
|
+
multiple={false}
|
|
587
|
+
callbackFile={() => {}}
|
|
588
|
+
/>
|
|
589
|
+
</HalstackProvider>
|
|
590
|
+
</ExampleContainer>
|
|
591
|
+
<ExampleContainer>
|
|
592
|
+
<Title title="Single file" theme="light" level={4} />
|
|
593
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
594
|
+
<DxcFileInput
|
|
595
|
+
label="File input"
|
|
596
|
+
helperText="Please select files"
|
|
597
|
+
mode="dropzone"
|
|
598
|
+
value={fileExample}
|
|
599
|
+
callbackFile={() => {}}
|
|
600
|
+
multiple={false}
|
|
601
|
+
/>
|
|
602
|
+
</HalstackProvider>
|
|
603
|
+
</ExampleContainer>
|
|
604
|
+
<ExampleContainer>
|
|
605
|
+
<Title title="Invalid single file" theme="light" level={4} />{" "}
|
|
606
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
607
|
+
<DxcFileInput
|
|
608
|
+
label="File input"
|
|
609
|
+
helperText="Please select files"
|
|
610
|
+
mode="dropzone"
|
|
611
|
+
value={fileExampleError}
|
|
612
|
+
callbackFile={() => {}}
|
|
613
|
+
multiple={false}
|
|
614
|
+
/>
|
|
615
|
+
</HalstackProvider>
|
|
505
616
|
</ExampleContainer>
|
|
506
617
|
</>
|
|
507
618
|
);
|
|
@@ -14,19 +14,19 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
14
14
|
|
|
15
15
|
var _FileInput = _interopRequireDefault(require("./FileInput"));
|
|
16
16
|
|
|
17
|
+
var file1 = new File(["file1"], "file1.png", {
|
|
18
|
+
type: "image/png"
|
|
19
|
+
});
|
|
20
|
+
var file2 = new File(["file2"], "file2.txt", {
|
|
21
|
+
type: "text/plain"
|
|
22
|
+
});
|
|
23
|
+
var allFiles = [{
|
|
24
|
+
file: file1
|
|
25
|
+
}, {
|
|
26
|
+
error: "Error message",
|
|
27
|
+
file: file2
|
|
28
|
+
}];
|
|
17
29
|
describe("FileInput component tests", function () {
|
|
18
|
-
var file1 = new File(["file1"], "file1.png", {
|
|
19
|
-
type: "image/png"
|
|
20
|
-
});
|
|
21
|
-
var file2 = new File(["file2"], "file2.txt", {
|
|
22
|
-
type: "text/plain"
|
|
23
|
-
});
|
|
24
|
-
var allFiles = [{
|
|
25
|
-
file: file1
|
|
26
|
-
}, {
|
|
27
|
-
error: "Error message",
|
|
28
|
-
file: file2
|
|
29
|
-
}];
|
|
30
30
|
test("Renders with correct labels and helper text in file mode", function () {
|
|
31
31
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_FileInput["default"], {
|
|
32
32
|
label: "File input label",
|
|
@@ -454,45 +454,4 @@ describe("FileInput component tests", function () {
|
|
|
454
454
|
}
|
|
455
455
|
}, _callee6);
|
|
456
456
|
})));
|
|
457
|
-
test("File input sends value when submitted in a form", function () {
|
|
458
|
-
var newFile = new File(["newFile"], "newFile.pdf", {
|
|
459
|
-
type: "pdf"
|
|
460
|
-
});
|
|
461
|
-
var handlerOnSubmit = jest.fn(function (e) {
|
|
462
|
-
e.preventDefault();
|
|
463
|
-
var formData = new FormData(e.target);
|
|
464
|
-
var formProps = Object.fromEntries(formData);
|
|
465
|
-
expect(formProps).toStrictEqual({
|
|
466
|
-
file: newFile
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
471
|
-
onSubmit: handlerOnSubmit
|
|
472
|
-
}, /*#__PURE__*/_react["default"].createElement(_FileInput["default"], {
|
|
473
|
-
label: "File input label",
|
|
474
|
-
name: "file",
|
|
475
|
-
helperText: "File input helper text",
|
|
476
|
-
mode: "filedrop",
|
|
477
|
-
buttonLabel: "Choose",
|
|
478
|
-
dropAreaLabel: "(or drop the files)"
|
|
479
|
-
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
480
|
-
type: "submit"
|
|
481
|
-
}, "Submit"))),
|
|
482
|
-
getByText = _render17.getByText,
|
|
483
|
-
getByLabelText = _render17.getByLabelText;
|
|
484
|
-
|
|
485
|
-
var inputFile = getByLabelText("File input label", {
|
|
486
|
-
hidden: true
|
|
487
|
-
});
|
|
488
|
-
var submit = getByText("Submit");
|
|
489
|
-
|
|
490
|
-
_react2.fireEvent.change(inputFile, {
|
|
491
|
-
target: {
|
|
492
|
-
files: [newFile]
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
_userEvent["default"].click(submit);
|
|
497
|
-
});
|
|
498
457
|
});
|
package/file-input/FileItem.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
name?: string;
|
|
6
|
-
error?: string;
|
|
7
|
-
showPreview: any;
|
|
8
|
-
preview: any;
|
|
9
|
-
type: any;
|
|
10
|
-
numFiles: any;
|
|
11
|
-
onDelete: any;
|
|
12
|
-
tabIndex: any;
|
|
13
|
-
}) => JSX.Element;
|
|
14
|
-
export default FileItem;
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FileItemProps } from "./types";
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ fileName, error, singleFileMode, showPreview, preview, type, onDelete, tabIndex, }: FileItemProps) => JSX.Element>;
|
|
4
|
+
export default _default;
|
package/file-input/FileItem.js
CHANGED
|
@@ -15,9 +15,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
17
|
|
|
18
|
+
var _main = require("../main");
|
|
19
|
+
|
|
18
20
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
23
|
+
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
21
25
|
|
|
22
26
|
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); }
|
|
23
27
|
|
|
@@ -47,103 +51,76 @@ var errorIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
47
51
|
}));
|
|
48
52
|
|
|
49
53
|
var FileItem = function FileItem(_ref) {
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
_ref$name = _ref.name,
|
|
53
|
-
name = _ref$name === void 0 ? "" : _ref$name,
|
|
54
|
+
var _ref$fileName = _ref.fileName,
|
|
55
|
+
fileName = _ref$fileName === void 0 ? "" : _ref$fileName,
|
|
54
56
|
_ref$error = _ref.error,
|
|
55
57
|
error = _ref$error === void 0 ? "" : _ref$error,
|
|
58
|
+
singleFileMode = _ref.singleFileMode,
|
|
56
59
|
showPreview = _ref.showPreview,
|
|
57
60
|
preview = _ref.preview,
|
|
58
61
|
type = _ref.type,
|
|
59
|
-
numFiles = _ref.numFiles,
|
|
60
62
|
onDelete = _ref.onDelete,
|
|
61
63
|
tabIndex = _ref.tabIndex;
|
|
62
64
|
var colorsTheme = (0, _useTheme["default"])();
|
|
63
|
-
var
|
|
65
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
64
66
|
|
|
65
67
|
var getIconAriaLabel = function getIconAriaLabel() {
|
|
66
|
-
if (type.includes("video"))
|
|
67
|
-
return "video";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (type.includes("audio")) {
|
|
71
|
-
return "audio";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return "file";
|
|
68
|
+
if (type.includes("video")) return "video";else if (type.includes("audio")) return "audio";else return "file";
|
|
75
69
|
};
|
|
76
70
|
|
|
77
71
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
78
72
|
theme: colorsTheme.fileInput
|
|
79
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
80
|
-
mode: mode,
|
|
81
|
-
multiple: multiple,
|
|
73
|
+
}, /*#__PURE__*/_react["default"].createElement(MainContainer, {
|
|
82
74
|
error: error,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, showPreview && (
|
|
75
|
+
singleFileMode: singleFileMode,
|
|
76
|
+
showPreview: showPreview
|
|
77
|
+
}, showPreview && (type.includes("image") ? /*#__PURE__*/_react["default"].createElement(ImagePreview, {
|
|
86
78
|
src: preview,
|
|
87
|
-
alt:
|
|
88
|
-
}) : /*#__PURE__*/_react["default"].createElement(
|
|
79
|
+
alt: fileName
|
|
80
|
+
}) : /*#__PURE__*/_react["default"].createElement(IconPreview, {
|
|
89
81
|
error: error,
|
|
90
82
|
"aria-label": getIconAriaLabel()
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
mode: mode,
|
|
95
|
-
multiple: multiple,
|
|
96
|
-
error: error,
|
|
97
|
-
showPreview: showPreview,
|
|
98
|
-
numFiles: numFiles
|
|
99
|
-
}, name), error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
|
|
100
|
-
"aria-label": "Error"
|
|
101
|
-
}, errorIcon), /*#__PURE__*/_react["default"].createElement(DeleteIcon, {
|
|
102
|
-
error: error,
|
|
83
|
+
}, preview)), /*#__PURE__*/_react["default"].createElement(FileItemContent, null, /*#__PURE__*/_react["default"].createElement(FileName, null, fileName), /*#__PURE__*/_react["default"].createElement(_main.DxcFlex, {
|
|
84
|
+
gap: "0.25rem"
|
|
85
|
+
}, error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, null, errorIcon), /*#__PURE__*/_react["default"].createElement(DeleteFileAction, {
|
|
103
86
|
onClick: function onClick() {
|
|
104
|
-
|
|
87
|
+
onDelete(fileName);
|
|
105
88
|
},
|
|
106
|
-
|
|
89
|
+
type: "button",
|
|
90
|
+
title: translatedLabels.fileInput.deleteFileActionTitle,
|
|
91
|
+
"aria-label": translatedLabels.fileInput.deleteFileActionTitle,
|
|
107
92
|
tabIndex: tabIndex
|
|
108
|
-
}, deleteIcon)), error &&
|
|
93
|
+
}, deleteIcon)), error && !singleFileMode && /*#__PURE__*/_react["default"].createElement(ErrorMessage, null, error))));
|
|
109
94
|
};
|
|
110
95
|
|
|
111
|
-
var
|
|
112
|
-
return props.
|
|
113
|
-
}, function (props) {
|
|
114
|
-
return props.error && props.theme.errorFileItemBackgroundColor;
|
|
115
|
-
}, function (props) {
|
|
116
|
-
return props.theme.fileItemBorderRadius;
|
|
96
|
+
var MainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n gap: 0.75rem;\n width: ", ";\n padding: ", ";\n ", ";\n border-color: ", ";\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n"])), function (props) {
|
|
97
|
+
return props.singleFileMode ? "230px" : "320px";
|
|
117
98
|
}, function (props) {
|
|
118
|
-
return props.
|
|
99
|
+
return props.showPreview ? "calc(8px - ".concat(props.theme.fileItemBorderThickness, ")") : "calc(8px - ".concat(props.theme.fileItemBorderThickness, ") calc(8px - ").concat(props.theme.fileItemBorderThickness, ") calc(8px - ").concat(props.theme.fileItemBorderThickness, ") 16px");
|
|
119
100
|
}, function (props) {
|
|
120
|
-
return props.
|
|
101
|
+
return props.error ? "background-color: ".concat(props.theme.errorFileItemBackgroundColor, ";") : "";
|
|
121
102
|
}, function (props) {
|
|
122
103
|
return props.error ? props.theme.errorFileItemBorderColor : props.theme.fileItemBorderColor;
|
|
123
104
|
}, function (props) {
|
|
124
105
|
return props.theme.fileItemBorderThickness;
|
|
125
106
|
}, function (props) {
|
|
126
107
|
return props.theme.fileItemBorderStyle;
|
|
108
|
+
}, function (props) {
|
|
109
|
+
return props.theme.fileItemBorderRadius;
|
|
127
110
|
});
|
|
128
111
|
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
var FileItemContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n align-items: center;\n"])));
|
|
132
|
-
|
|
133
|
-
var ImagePreview = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 48px;\n height: 48px;\n object-fit: contain;\n margin-right: 12px;\n border-radius: 2px;\n"])));
|
|
112
|
+
var ImagePreview = _styledComponents["default"].img(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n width: 48px;\n height: 48px;\n border-radius: 2px;\n object-fit: contain;\n"])));
|
|
134
113
|
|
|
135
|
-
var
|
|
114
|
+
var IconPreview = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ", ";\n width: 48px;\n height: 48px;\n padding: 15px;\n border-radius: 2px;\n color: ", ";\n\n svg {\n height: 18px;\n width: 18px;\n }\n"])), function (props) {
|
|
136
115
|
return props.error ? props.theme.errorFilePreviewBackgroundColor : props.theme.filePreviewBackgroundColor;
|
|
137
116
|
}, function (props) {
|
|
138
117
|
return props.error ? props.theme.errorFilePreviewIconColor : props.theme.filePreviewIconColor;
|
|
139
118
|
});
|
|
140
119
|
|
|
141
|
-
var
|
|
120
|
+
var FileItemContent = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n display: grid;\n grid-template-columns: auto min-content;\n grid-template-rows: min-content auto;\n column-gap: 0.25rem;\n"])));
|
|
142
121
|
|
|
143
|
-
var FileName = _styledComponents["default"].span(
|
|
122
|
+
var FileName = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n align-self: center;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n"])), function (props) {
|
|
144
123
|
return props.theme.fileNameFontColor;
|
|
145
|
-
}, function (props) {
|
|
146
|
-
return props.mode === "file" && !props.multiple && props.error && props.numFiles === 1 ? "calc(230px - 76px)" : props.mode === "file" && !props.multiple && !props.error && props.numFiles === 1 ? "calc(230px - 50px)" : !props.showPreview && !props.error ? "calc(320px - 52px)" : !props.showPreview && props.error ? "calc(320px - 76px)" : props.showPreview && props.error ? "calc(320px - 128px)" : props.showPreview && !props.error && "calc(320px - 102px)";
|
|
147
124
|
}, function (props) {
|
|
148
125
|
return props.theme.fileItemFontFamily;
|
|
149
126
|
}, function (props) {
|
|
@@ -154,9 +131,9 @@ var FileName = _styledComponents["default"].span(_templateObject7 || (_templateO
|
|
|
154
131
|
return props.theme.fileItemLineHeight;
|
|
155
132
|
});
|
|
156
133
|
|
|
157
|
-
var ErrorIcon = _styledComponents["default"].span(
|
|
134
|
+
var ErrorIcon = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n color: #d0011b;\n"])));
|
|
158
135
|
|
|
159
|
-
var
|
|
136
|
+
var DeleteFileAction = _styledComponents["default"].button(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 2px;\n background-color: transparent;\n box-shadow: 0 0 0 2px transparent;\n padding: 3px;\n cursor: pointer;\n color: ", ";\n\n svg {\n line-height: 18px;\n }\n &:hover {\n background-color: ", ";\n }\n &:focus,\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
|
|
160
137
|
return props.theme.fontFamily;
|
|
161
138
|
}, function (props) {
|
|
162
139
|
return props.theme.deleteFileItemColor;
|
|
@@ -164,13 +141,11 @@ var DeleteIcon = _styledComponents["default"].button(_templateObject9 || (_templ
|
|
|
164
141
|
return props.theme.hoverDeleteFileItemBackgroundColor;
|
|
165
142
|
}, function (props) {
|
|
166
143
|
return props.theme.focusDeleteFileItemBorderColor;
|
|
167
|
-
}, function (props) {
|
|
168
|
-
return props.theme.focusDeleteFileItemBorderColor;
|
|
169
144
|
}, function (props) {
|
|
170
145
|
return props.theme.activeDeleteFileItemBackgroundColor;
|
|
171
146
|
});
|
|
172
147
|
|
|
173
|
-
var ErrorMessage = _styledComponents["default"].span(
|
|
148
|
+
var ErrorMessage = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
174
149
|
return props.theme.errorMessageFontColor;
|
|
175
150
|
}, function (props) {
|
|
176
151
|
return props.theme.errorMessageFontFamily;
|
|
@@ -182,5 +157,6 @@ var ErrorMessage = _styledComponents["default"].span(_templateObject10 || (_temp
|
|
|
182
157
|
return props.theme.errorMessageLineHeight;
|
|
183
158
|
});
|
|
184
159
|
|
|
185
|
-
var _default = FileItem;
|
|
160
|
+
var _default = /*#__PURE__*/_react["default"].memo(FileItem);
|
|
161
|
+
|
|
186
162
|
exports["default"] = _default;
|
package/file-input/types.d.ts
CHANGED
|
@@ -108,5 +108,22 @@ declare type FileModeProps = CommonProps & {
|
|
|
108
108
|
*/
|
|
109
109
|
dropAreaLabel?: never;
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Reference to the component.
|
|
113
|
+
*/
|
|
114
|
+
export declare type RefType = HTMLDivElement;
|
|
111
115
|
declare type Props = DropModeProps | FileModeProps;
|
|
116
|
+
/**
|
|
117
|
+
* Single file item preview.
|
|
118
|
+
*/
|
|
119
|
+
export declare type FileItemProps = {
|
|
120
|
+
fileName?: string;
|
|
121
|
+
error?: string;
|
|
122
|
+
showPreview: boolean;
|
|
123
|
+
singleFileMode: boolean;
|
|
124
|
+
preview: string;
|
|
125
|
+
type: string;
|
|
126
|
+
onDelete: (fileName: string) => void;
|
|
127
|
+
tabIndex: number;
|
|
128
|
+
};
|
|
112
129
|
export default Props;
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import DxcFooter from "./Footer";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
5
6
|
|
|
6
7
|
const social = [
|
|
7
8
|
{
|
|
@@ -85,6 +86,86 @@ export default {
|
|
|
85
86
|
component: DxcFooter,
|
|
86
87
|
};
|
|
87
88
|
|
|
89
|
+
const opinionatedTheme = {
|
|
90
|
+
footer: {
|
|
91
|
+
baseColor: "#000000",
|
|
92
|
+
fontColor: "#ffffff",
|
|
93
|
+
accentColor: "#0095ff",
|
|
94
|
+
logo: (
|
|
95
|
+
<svg id="g10" xmlns="http://www.w3.org/2000/svg" width="280.781" height="32" viewBox="0 0 280.781 32">
|
|
96
|
+
<g id="g12">
|
|
97
|
+
<path
|
|
98
|
+
id="path14"
|
|
99
|
+
d="M171.5-54.124v12.539h-3.6V-54.124h-4.973v-3.191h13.54v3.191H171.5"
|
|
100
|
+
transform="translate(-68.528 65.45)"
|
|
101
|
+
fill="#fff"
|
|
102
|
+
/>
|
|
103
|
+
<path
|
|
104
|
+
id="path16"
|
|
105
|
+
d="M189.96-41.585V-57.315h12.326v3.079h-8.753v3.191h7.7v3.078h-7.7v3.3h8.87v3.078H189.96"
|
|
106
|
+
transform="translate(-77.56 65.45)"
|
|
107
|
+
fill="#fff"
|
|
108
|
+
/>
|
|
109
|
+
<path
|
|
110
|
+
id="path18"
|
|
111
|
+
d="M223.558-41.438a8.1,8.1,0,0,1-8.382-8.1v-.045a8.161,8.161,0,0,1,8.522-8.146,8.6,8.6,0,0,1,6.444,2.431l-2.289,2.543a6.133,6.133,0,0,0-4.178-1.778,4.743,4.743,0,0,0-4.738,4.905v.045a4.752,4.752,0,0,0,4.738,4.95,6,6,0,0,0,4.295-1.845l2.288,2.228a8.491,8.491,0,0,1-6.7,2.813"
|
|
112
|
+
transform="translate(-86.019 65.583)"
|
|
113
|
+
fill="#fff"
|
|
114
|
+
/>
|
|
115
|
+
<path
|
|
116
|
+
id="path20"
|
|
117
|
+
d="M254.988-41.585V-47.9h-6.63v6.315h-3.6V-57.315h3.6v6.225h6.63v-6.225h3.594v15.731h-3.594"
|
|
118
|
+
transform="translate(-95.903 65.45)"
|
|
119
|
+
fill="#fff"
|
|
120
|
+
/>
|
|
121
|
+
<path
|
|
122
|
+
id="path22"
|
|
123
|
+
d="M285.991-41.585l-7.914-10v10h-3.549V-57.315h3.316l7.657,9.685v-9.685h3.549v15.731h-3.058"
|
|
124
|
+
transform="translate(-105.869 65.45)"
|
|
125
|
+
fill="#fff"
|
|
126
|
+
/>
|
|
127
|
+
<path
|
|
128
|
+
id="path24"
|
|
129
|
+
d="M317.2-49.583a4.869,4.869,0,0,0-4.949-4.95,4.793,4.793,0,0,0-4.9,4.905v.045a4.869,4.869,0,0,0,4.949,4.95,4.793,4.793,0,0,0,4.9-4.905Zm-4.949,8.145c-5.043,0-8.661-3.623-8.661-8.1v-.045c0-4.478,3.666-8.146,8.708-8.146s8.66,3.623,8.66,8.1v.045c0,4.477-3.664,8.145-8.708,8.145"
|
|
130
|
+
transform="translate(-115.631 65.583)"
|
|
131
|
+
fill="#fff"
|
|
132
|
+
/>
|
|
133
|
+
<path
|
|
134
|
+
id="path26"
|
|
135
|
+
d="M336.786-41.585V-57.315h3.6v12.584h8.148v3.146H336.786"
|
|
136
|
+
transform="translate(-126.654 65.45)"
|
|
137
|
+
fill="#fff"
|
|
138
|
+
/>
|
|
139
|
+
<path
|
|
140
|
+
id="path28"
|
|
141
|
+
d="M372.78-49.583a4.87,4.87,0,0,0-4.949-4.95,4.794,4.794,0,0,0-4.9,4.905v.045a4.869,4.869,0,0,0,4.949,4.95,4.794,4.794,0,0,0,4.9-4.905Zm-4.949,8.145c-5.043,0-8.662-3.623-8.662-8.1v-.045c0-4.478,3.666-8.146,8.708-8.146s8.661,3.623,8.661,8.1v.045c0,4.477-3.666,8.145-8.708,8.145"
|
|
142
|
+
transform="translate(-135.016 65.583)"
|
|
143
|
+
fill="#fff"
|
|
144
|
+
/>
|
|
145
|
+
<path
|
|
146
|
+
id="path30"
|
|
147
|
+
d="M399.735-41.438c-5.09,0-8.592-3.443-8.592-8.1v-.045a8.243,8.243,0,0,1,8.568-8.146,9.18,9.18,0,0,1,6.42,2.16l-2.265,2.634a6.141,6.141,0,0,0-4.272-1.6,4.807,4.807,0,0,0-4.692,4.905v.045a4.8,4.8,0,0,0,4.949,4.995,5.89,5.89,0,0,0,3.384-.945v-2.25h-3.618v-2.992h7.1v6.841a10.837,10.837,0,0,1-6.98,2.5"
|
|
148
|
+
transform="translate(-145.284 65.583)"
|
|
149
|
+
fill="#fff"
|
|
150
|
+
/>
|
|
151
|
+
<path
|
|
152
|
+
id="path32"
|
|
153
|
+
d="M428.664-47.855v6.27h-3.6v-6.2l-6.28-9.528h4.2L426.89-51l3.968-6.315h4.085l-6.28,9.46"
|
|
154
|
+
transform="translate(-154.162 65.45)"
|
|
155
|
+
fill="#fff"
|
|
156
|
+
/>
|
|
157
|
+
<path
|
|
158
|
+
id="path34"
|
|
159
|
+
d="M84.218-55.737a10.063,10.063,0,0,1,2.589-4.4,9.792,9.792,0,0,1,6.985-2.77h11.328V-69.3H93.792a17.041,17.041,0,0,0-11.8,4.759,16.344,16.344,0,0,0-3.547,5.115,13.247,13.247,0,0,0-1.122,3.688Zm0,4.877a10.065,10.065,0,0,0,2.589,4.4,9.793,9.793,0,0,0,6.985,2.77h11.328V-37.3H93.792a17.042,17.042,0,0,1-11.8-4.759,16.339,16.339,0,0,1-3.547-5.114,13.251,13.251,0,0,1-1.122-3.688ZM63.1-47.98,54.45-37.3H45.873l12.957-16-12.957-16H54.45L63.1-58.619l8.65-10.68h8.578l-12.957,16,12.957,16H71.749ZM48.875-55.737a13.212,13.212,0,0,0-1.122-3.688,16.359,16.359,0,0,0-3.546-5.115,17.043,17.043,0,0,0-11.8-4.759H21.08v6.393H32.408a9.79,9.79,0,0,1,6.985,2.77,10.072,10.072,0,0,1,2.59,4.4Zm0,4.877a13.215,13.215,0,0,1-1.122,3.688,16.353,16.353,0,0,1-3.546,5.114,17.044,17.044,0,0,1-11.8,4.759H21.08v-6.393H32.408a9.791,9.791,0,0,0,6.985-2.77,10.074,10.074,0,0,0,2.59-4.4h6.892"
|
|
160
|
+
transform="translate(-21.08 69.298)"
|
|
161
|
+
fill="#fff"
|
|
162
|
+
/>
|
|
163
|
+
</g>
|
|
164
|
+
</svg>
|
|
165
|
+
),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
88
169
|
export const Chromatic = () => (
|
|
89
170
|
<>
|
|
90
171
|
<ExampleContainer>
|
|
@@ -133,5 +214,15 @@ export const Chromatic = () => (
|
|
|
133
214
|
<Title title="Xxlarge padding" theme="light" level={4} />
|
|
134
215
|
<DxcFooter padding="xxlarge"></DxcFooter>
|
|
135
216
|
</ExampleContainer>
|
|
217
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
218
|
+
<ExampleContainer>
|
|
219
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
220
|
+
<DxcFooter copyright="Copyright" socialLinks={social} bottomLinks={bottom}>
|
|
221
|
+
<div>
|
|
222
|
+
<a href="https://www.linkedin.com/company/dxctechnology">Linkedin</a>
|
|
223
|
+
</div>
|
|
224
|
+
</DxcFooter>
|
|
225
|
+
</HalstackProvider>
|
|
226
|
+
</ExampleContainer>
|
|
136
227
|
</>
|
|
137
228
|
);
|