@dxc-technology/halstack-react 0.0.0-ee92231 → 0.0.0-eefd559
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/BackgroundColorContext.d.ts +10 -0
- package/BackgroundColorContext.js +1 -4
- package/ThemeContext.d.ts +15 -0
- package/ThemeContext.js +5 -8
- package/V3Select/V3Select.js +2 -2
- package/V3Textarea/V3Textarea.js +2 -2
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +11 -22
- package/accordion/Accordion.stories.tsx +307 -0
- package/accordion/types.d.ts +4 -8
- package/accordion-group/AccordionGroup.js +2 -2
- package/accordion-group/AccordionGroup.stories.tsx +225 -0
- package/accordion-group/types.d.ts +4 -8
- package/alert/Alert.js +2 -2
- package/alert/Alert.stories.tsx +170 -0
- package/alert/types.d.ts +1 -1
- package/badge/Badge.js +1 -1
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +84 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +13 -0
- package/bleed/types.js +5 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +4 -7
- package/box/types.d.ts +0 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +13 -19
- package/button/Button.stories.tsx +222 -241
- package/button/types.d.ts +5 -9
- package/card/Card.js +5 -6
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/Checkbox.js +2 -2
- package/checkbox/types.d.ts +2 -2
- package/chip/Chip.d.ts +4 -0
- package/chip/Chip.js +16 -76
- package/chip/Chip.stories.tsx +119 -0
- package/chip/types.d.ts +45 -0
- package/chip/types.js +5 -0
- package/common/variables.js +70 -28
- package/date/Date.js +1 -1
- package/date-input/DateInput.js +10 -13
- package/date-input/DateInput.stories.tsx +138 -0
- package/dialog/Dialog.js +4 -3
- package/dialog/Dialog.stories.tsx +212 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +13 -35
- package/dropdown/Dropdown.stories.tsx +249 -0
- package/dropdown/types.d.ts +6 -15
- package/file-input/FileInput.d.ts +4 -0
- package/file-input/FileInput.js +167 -109
- package/file-input/FileInput.stories.tsx +507 -0
- package/file-input/FileItem.d.ts +14 -0
- package/file-input/FileItem.js +12 -21
- package/file-input/types.d.ts +112 -0
- package/file-input/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +28 -36
- package/footer/{Footer.stories.jsx → Footer.stories.tsx} +1 -22
- package/footer/Icons.d.ts +2 -0
- package/footer/Icons.js +3 -3
- package/footer/types.d.ts +22 -18
- package/header/Header.js +2 -2
- package/header/Header.stories.tsx +162 -0
- package/header/Icons.d.ts +2 -0
- package/header/types.d.ts +4 -2
- package/heading/Heading.d.ts +4 -0
- package/heading/Heading.js +7 -24
- package/heading/Heading.stories.tsx +54 -0
- package/heading/types.d.ts +33 -0
- package/heading/types.js +5 -0
- package/input-text/InputText.js +2 -2
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +84 -0
- package/inset/Inset.stories.tsx +229 -0
- package/inset/types.d.ts +13 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +10 -0
- package/layout/ApplicationLayout.js +9 -19
- package/layout/ApplicationLayout.stories.tsx +171 -0
- package/layout/types.d.ts +57 -0
- package/layout/types.js +5 -0
- package/link/Link.js +3 -3
- package/link/Link.stories.tsx +146 -0
- package/list/List.d.ts +4 -0
- package/list/List.js +47 -0
- package/list/List.stories.tsx +95 -0
- package/list/types.d.ts +7 -0
- package/list/types.js +5 -0
- package/main.d.ts +7 -3
- package/main.js +34 -2
- package/number-input/NumberInput.d.ts +4 -0
- package/number-input/NumberInput.js +5 -50
- package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +0 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/number-input/types.d.ts +117 -0
- package/number-input/types.js +5 -0
- package/package.json +4 -2
- package/paginator/Paginator.js +2 -8
- package/password-input/PasswordInput.js +19 -18
- package/password-input/PasswordInput.stories.tsx +3 -3
- package/password-input/types.d.ts +17 -10
- package/progress-bar/ProgressBar.js +4 -4
- package/radio/Radio.js +2 -2
- package/radio/types.d.ts +2 -2
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +140 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +273 -0
- package/radio-group/RadioGroup.stories.tsx +79 -0
- package/radio-group/RadioGroup.test.js +248 -0
- package/radio-group/types.d.ts +36 -0
- package/radio-group/types.js +5 -0
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +5 -28
- package/resultsetTable/ResultsetTable.stories.tsx +275 -0
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/row/Row.d.ts +3 -0
- package/row/Row.js +127 -0
- package/row/Row.stories.tsx +237 -0
- package/row/types.d.ts +10 -0
- package/row/types.js +5 -0
- package/select/Select.d.ts +4 -0
- package/select/Select.js +20 -22
- package/select/Select.stories.tsx +572 -0
- package/select/types.d.ts +170 -0
- package/select/types.js +5 -0
- package/sidenav/Sidenav.d.ts +9 -0
- package/sidenav/Sidenav.js +6 -15
- package/sidenav/Sidenav.stories.tsx +182 -0
- package/sidenav/types.d.ts +50 -0
- package/sidenav/types.js +5 -0
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +43 -32
- package/slider/Slider.stories.tsx +177 -0
- package/slider/types.d.ts +2 -7
- package/spinner/Spinner.js +2 -2
- package/spinner/Spinner.stories.jsx +1 -0
- package/stack/Stack.d.ts +3 -0
- package/stack/Stack.js +97 -0
- package/stack/Stack.stories.tsx +164 -0
- package/stack/types.d.ts +9 -0
- package/stack/types.js +5 -0
- package/switch/Switch.js +2 -2
- package/switch/Switch.stories.tsx +1 -1
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +2 -1
- package/tabs/Tabs.js +11 -9
- package/tabs/Tabs.stories.tsx +120 -0
- package/tabs/types.d.ts +25 -18
- package/tag/Tag.d.ts +4 -0
- package/tag/Tag.js +9 -35
- package/tag/{Tag.stories.jsx → Tag.stories.tsx} +15 -22
- package/tag/types.d.ts +69 -0
- package/tag/types.js +5 -0
- package/text/Text.d.ts +7 -0
- package/text/Text.js +30 -0
- package/text/Text.stories.tsx +19 -0
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +54 -85
- package/text-input/TextInput.stories.tsx +456 -0
- package/text-input/types.d.ts +159 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.d.ts +4 -0
- package/textarea/Textarea.js +27 -60
- package/textarea/Textarea.stories.jsx +4 -3
- package/textarea/types.d.ts +130 -0
- package/textarea/types.js +5 -0
- package/toggle/Toggle.js +1 -1
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +16 -45
- package/toggle-group/ToggleGroup.stories.tsx +173 -0
- package/toggle-group/types.d.ts +97 -0
- package/toggle-group/types.js +5 -0
- package/upload/buttons-upload/ButtonsUpload.js +2 -2
- package/upload/dragAndDropArea/DragAndDropArea.js +2 -2
- package/upload/file-upload/FileToUpload.js +1 -1
- package/upload/files-upload/FilesToUpload.js +1 -1
- package/upload/transaction/Transaction.js +2 -2
- package/upload/transactions/Transactions.js +1 -1
- package/useTheme.d.ts +2 -0
- package/useTheme.js +1 -1
- package/wizard/Wizard.d.ts +4 -0
- package/wizard/Wizard.js +69 -59
- package/wizard/Wizard.stories.tsx +224 -0
- package/wizard/types.d.ts +60 -0
- package/wizard/types.js +5 -0
- package/chip/index.d.ts +0 -22
- package/file-input/index.d.ts +0 -81
- package/heading/index.d.ts +0 -17
- package/number-input/index.d.ts +0 -113
- package/resultsetTable/index.d.ts +0 -19
- package/select/index.d.ts +0 -131
- package/sidenav/index.d.ts +0 -13
- package/tag/index.d.ts +0 -24
- package/text-input/index.d.ts +0 -135
- package/textarea/index.d.ts +0 -117
- package/toggle-group/index.d.ts +0 -21
- package/wizard/Icons.js +0 -65
- package/wizard/index.d.ts +0 -18
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
|
+
import DxcCard from "./Card";
|
|
5
|
+
import imagePath from "./ice-cream.jpg";
|
|
6
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Card",
|
|
10
|
+
component: DxcCard,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Card = () => (
|
|
14
|
+
<>
|
|
15
|
+
<Title title="Default" theme="light" level={4} />
|
|
16
|
+
<ExampleContainer>
|
|
17
|
+
<DxcCard>Default</DxcCard>
|
|
18
|
+
</ExampleContainer>
|
|
19
|
+
<Title title="Not outlined" theme="light" level={4} />
|
|
20
|
+
<ExampleContainer>
|
|
21
|
+
<DxcCard outlined={false}>Not outlined</DxcCard>
|
|
22
|
+
</ExampleContainer>
|
|
23
|
+
<Title title="Default with link" theme="light" level={4} />
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<DxcCard linkHref="https://www.dxc.com">Default with link</DxcCard>
|
|
26
|
+
</ExampleContainer>
|
|
27
|
+
<Title title="Focused default with link" theme="light" level={4} />
|
|
28
|
+
<ExampleContainer>
|
|
29
|
+
<DxcCard linkHref="https://www.dxc.com">Focused default with link</DxcCard>
|
|
30
|
+
</ExampleContainer>
|
|
31
|
+
<Title title="Hovered default with link" theme="light" level={4} />
|
|
32
|
+
<ExampleContainer>
|
|
33
|
+
<DxcCard linkHref="https://www.dxc.com">Hovered default with link</DxcCard>
|
|
34
|
+
</ExampleContainer>
|
|
35
|
+
<Title title="Default with action" theme="light" level={4} />
|
|
36
|
+
<ExampleContainer>
|
|
37
|
+
<DxcCard onClick={() => {}}>Default with action</DxcCard>
|
|
38
|
+
</ExampleContainer>
|
|
39
|
+
<Title title="Default with image" theme="light" level={4} />
|
|
40
|
+
<ExampleContainer>
|
|
41
|
+
<DxcCard imageSrc={imagePath}>Default</DxcCard>
|
|
42
|
+
</ExampleContainer>
|
|
43
|
+
<Title title="Default image with background color" theme="light" level={4} />
|
|
44
|
+
<ExampleContainer>
|
|
45
|
+
<DxcCard imageSrc={imagePath} imageBgColor="yellow">
|
|
46
|
+
Background color
|
|
47
|
+
</DxcCard>
|
|
48
|
+
</ExampleContainer>
|
|
49
|
+
<Title title="Default image with position after" theme="light" level={4} />
|
|
50
|
+
<ExampleContainer>
|
|
51
|
+
<DxcCard imageSrc={imagePath} imagePosition="after">
|
|
52
|
+
Position after
|
|
53
|
+
</DxcCard>
|
|
54
|
+
</ExampleContainer>
|
|
55
|
+
<Title title="Image cover" theme="light" level={4} />
|
|
56
|
+
<ExampleContainer>
|
|
57
|
+
<DxcCard imageSrc={imagePath} imageCover>
|
|
58
|
+
Image cover
|
|
59
|
+
</DxcCard>
|
|
60
|
+
</ExampleContainer>
|
|
61
|
+
<Title title="Image cover with position after" theme="light" level={4} />
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<DxcCard imageSrc={imagePath} imageCover imagePosition="after">
|
|
64
|
+
Image cover with position after
|
|
65
|
+
</DxcCard>
|
|
66
|
+
</ExampleContainer>
|
|
67
|
+
<Title title="Image padding" theme="light" level={2} />
|
|
68
|
+
<ExampleContainer>
|
|
69
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
70
|
+
<DxcCard imageSrc={imagePath} imagePadding="xxsmall" imageCover>
|
|
71
|
+
Xxsmall
|
|
72
|
+
</DxcCard>
|
|
73
|
+
</ExampleContainer>
|
|
74
|
+
<ExampleContainer>
|
|
75
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
76
|
+
<DxcCard imageSrc={imagePath} imagePadding="xsmall" imageCover>
|
|
77
|
+
Xsmall
|
|
78
|
+
</DxcCard>
|
|
79
|
+
</ExampleContainer>
|
|
80
|
+
<ExampleContainer>
|
|
81
|
+
<Title title="Small" theme="light" level={4} />
|
|
82
|
+
<DxcCard imageSrc={imagePath} imagePadding="small" imageCover>
|
|
83
|
+
Small
|
|
84
|
+
</DxcCard>
|
|
85
|
+
</ExampleContainer>
|
|
86
|
+
<ExampleContainer>
|
|
87
|
+
<Title title="Medium" theme="light" level={4} />
|
|
88
|
+
<DxcCard imageSrc={imagePath} imagePadding="medium" imageCover>
|
|
89
|
+
Medium
|
|
90
|
+
</DxcCard>
|
|
91
|
+
</ExampleContainer>
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Large" theme="light" level={4} />
|
|
94
|
+
<DxcCard imageSrc={imagePath} imagePadding="large" imageCover>
|
|
95
|
+
Large
|
|
96
|
+
</DxcCard>
|
|
97
|
+
</ExampleContainer>
|
|
98
|
+
<ExampleContainer>
|
|
99
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
100
|
+
<DxcCard imageSrc={imagePath} imagePadding="xlarge" imageCover>
|
|
101
|
+
Xlarge
|
|
102
|
+
</DxcCard>
|
|
103
|
+
</ExampleContainer>
|
|
104
|
+
<ExampleContainer>
|
|
105
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
106
|
+
<DxcCard imageSrc={imagePath} imagePadding="xxlarge" imageCover>
|
|
107
|
+
Xxlarge
|
|
108
|
+
</DxcCard>
|
|
109
|
+
</ExampleContainer>
|
|
110
|
+
<Title title="Content padding" theme="light" level={2} />
|
|
111
|
+
<ExampleContainer>
|
|
112
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
113
|
+
<DxcCard contentPadding="xxsmall">Xxsmall</DxcCard>
|
|
114
|
+
</ExampleContainer>
|
|
115
|
+
<ExampleContainer>
|
|
116
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
117
|
+
<DxcCard contentPadding="xsmall">Xsmall</DxcCard>
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
<ExampleContainer>
|
|
120
|
+
<Title title="Small" theme="light" level={4} />
|
|
121
|
+
<DxcCard contentPadding="small">Small</DxcCard>
|
|
122
|
+
</ExampleContainer>
|
|
123
|
+
<ExampleContainer>
|
|
124
|
+
<Title title="Medium" theme="light" level={4} />
|
|
125
|
+
<DxcCard contentPadding="medium">Medium</DxcCard>
|
|
126
|
+
</ExampleContainer>
|
|
127
|
+
<ExampleContainer>
|
|
128
|
+
<Title title="Large" theme="light" level={4} />
|
|
129
|
+
<DxcCard contentPadding="large">Large</DxcCard>
|
|
130
|
+
</ExampleContainer>
|
|
131
|
+
<ExampleContainer>
|
|
132
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
133
|
+
<DxcCard contentPadding="xlarge">Xlarge</DxcCard>
|
|
134
|
+
</ExampleContainer>
|
|
135
|
+
<ExampleContainer>
|
|
136
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
137
|
+
<DxcCard contentPadding="xxlarge">Xxlarge</DxcCard>
|
|
138
|
+
</ExampleContainer>
|
|
139
|
+
<Title title="Margin" theme="light" level={2} />
|
|
140
|
+
<ExampleContainer>
|
|
141
|
+
<Title title="Xxsmall" theme="light" level={4} />
|
|
142
|
+
<DxcCard margin="xxsmall">Xxsmall</DxcCard>
|
|
143
|
+
</ExampleContainer>
|
|
144
|
+
<ExampleContainer>
|
|
145
|
+
<Title title="Xsmall" theme="light" level={4} />
|
|
146
|
+
<DxcCard margin="xsmall">Xsmall</DxcCard>
|
|
147
|
+
</ExampleContainer>
|
|
148
|
+
<ExampleContainer>
|
|
149
|
+
<Title title="Small" theme="light" level={4} />
|
|
150
|
+
<DxcCard margin="small">Small</DxcCard>
|
|
151
|
+
</ExampleContainer>
|
|
152
|
+
<ExampleContainer>
|
|
153
|
+
<Title title="Medium" theme="light" level={4} />
|
|
154
|
+
<DxcCard margin="medium">Medium</DxcCard>
|
|
155
|
+
</ExampleContainer>
|
|
156
|
+
<ExampleContainer>
|
|
157
|
+
<Title title="Large" theme="light" level={4} />
|
|
158
|
+
<DxcCard margin="large">Large</DxcCard>
|
|
159
|
+
</ExampleContainer>
|
|
160
|
+
<ExampleContainer>
|
|
161
|
+
<Title title="Xlarge" theme="light" level={4} />
|
|
162
|
+
<DxcCard margin="xlarge">Xlarge</DxcCard>
|
|
163
|
+
</ExampleContainer>
|
|
164
|
+
<ExampleContainer>
|
|
165
|
+
<Title title="Xxlarge" theme="light" level={4} />
|
|
166
|
+
<DxcCard margin="xxlarge">Xxlarge</DxcCard>
|
|
167
|
+
</ExampleContainer>
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const actionCard = () => (
|
|
172
|
+
<>
|
|
173
|
+
<ExampleContainer>
|
|
174
|
+
<Title title="Focused default with action" theme="light" level={4} />
|
|
175
|
+
<DxcCard onClick={() => {}}>Focused default with action</DxcCard>
|
|
176
|
+
</ExampleContainer>
|
|
177
|
+
<ExampleContainer expanded>
|
|
178
|
+
<Title title="Hovered default with action" theme="light" level={4} />
|
|
179
|
+
<DxcCard onClick={() => {}}>Hovered default with action</DxcCard>
|
|
180
|
+
</ExampleContainer>
|
|
181
|
+
</>
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const linkStates = async (focusCard, hoverCard) => {
|
|
185
|
+
await focusCard.focus();
|
|
186
|
+
await userEvent.hover(hoverCard);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const ActionCardStates = actionCard.bind({});
|
|
190
|
+
ActionCardStates.play = async ({ canvasElement }) => {
|
|
191
|
+
const canvas = within(canvasElement);
|
|
192
|
+
await userEvent.tab();
|
|
193
|
+
await userEvent.hover(canvas.getAllByText("Hovered default with action")[1]);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const Chromatic = Card.bind({});
|
|
197
|
+
Chromatic.play = async ({ canvasElement }) => {
|
|
198
|
+
const canvas = within(canvasElement);
|
|
199
|
+
const linkCards = canvas.getAllByRole("link");
|
|
200
|
+
await linkStates(linkCards[1], linkCards[2]);
|
|
201
|
+
};
|
|
Binary file
|
package/card/types.d.ts
CHANGED
|
@@ -42,15 +42,13 @@ declare type Props = {
|
|
|
42
42
|
*/
|
|
43
43
|
imageCover?: boolean;
|
|
44
44
|
/**
|
|
45
|
-
* Size of the margin to be applied to the component
|
|
46
|
-
* an object with 'top', 'bottom', 'left' and 'right' properties
|
|
47
|
-
* in order to specify different margin sizes.
|
|
45
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
46
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
48
47
|
*/
|
|
49
48
|
margin?: Space | Size;
|
|
50
49
|
/**
|
|
51
|
-
* Size of the padding to be applied to the content area
|
|
52
|
-
* an object with 'top', 'bottom', 'left' and 'right' properties in
|
|
53
|
-
* order to specify different padding sizes.
|
|
50
|
+
* Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
51
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
54
52
|
*/
|
|
55
53
|
contentPadding?: Space | Size;
|
|
56
54
|
/**
|
package/checkbox/Checkbox.js
CHANGED
|
@@ -27,9 +27,9 @@ var _variables = require("../common/variables.js");
|
|
|
27
27
|
|
|
28
28
|
var _utils = require("../common/utils.js");
|
|
29
29
|
|
|
30
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
30
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
31
|
|
|
32
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext
|
|
32
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
33
|
|
|
34
34
|
var _templateObject, _templateObject2, _templateObject3;
|
|
35
35
|
|
package/checkbox/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare type Props = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Text to be placed next to the checkbox.
|
|
21
21
|
*/
|
|
22
|
-
label
|
|
22
|
+
label?: string;
|
|
23
23
|
/**
|
|
24
24
|
* Whether the label should appear after or before the checkbox.
|
|
25
25
|
*/
|
|
@@ -49,7 +49,7 @@ declare type Props = {
|
|
|
49
49
|
*/
|
|
50
50
|
margin?: Space | Margin;
|
|
51
51
|
/**
|
|
52
|
-
* Size of the component
|
|
52
|
+
* Size of the component.
|
|
53
53
|
*/
|
|
54
54
|
size?: "small" | "medium" | "large" | "fillParent" | "fitContent";
|
|
55
55
|
/**
|
package/chip/Chip.d.ts
ADDED
package/chip/Chip.js
CHANGED
|
@@ -9,23 +9,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
13
|
|
|
14
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
15
|
|
|
16
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
17
|
-
|
|
18
16
|
var _react = _interopRequireDefault(require("react"));
|
|
19
17
|
|
|
20
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
19
|
|
|
22
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
|
-
|
|
24
20
|
var _variables = require("../common/variables.js");
|
|
25
21
|
|
|
26
22
|
var _utils = require("../common/utils.js");
|
|
27
23
|
|
|
28
|
-
var _useTheme = _interopRequireDefault(require("../useTheme
|
|
24
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
29
25
|
|
|
30
26
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
31
27
|
|
|
@@ -37,9 +33,7 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
37
33
|
var label = _ref.label,
|
|
38
34
|
suffixIcon = _ref.suffixIcon,
|
|
39
35
|
prefixIcon = _ref.prefixIcon,
|
|
40
|
-
suffixIconSrc = _ref.suffixIconSrc,
|
|
41
36
|
onClickSuffix = _ref.onClickSuffix,
|
|
42
|
-
prefixIconSrc = _ref.prefixIconSrc,
|
|
43
37
|
onClickPrefix = _ref.onClickPrefix,
|
|
44
38
|
disabled = _ref.disabled,
|
|
45
39
|
margin = _ref.margin,
|
|
@@ -51,49 +45,33 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
51
45
|
}, /*#__PURE__*/_react["default"].createElement(StyledDxcChip, {
|
|
52
46
|
disabled: disabled,
|
|
53
47
|
margin: margin
|
|
54
|
-
}, prefixIcon
|
|
48
|
+
}, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
55
49
|
disabled: disabled,
|
|
56
50
|
prefixIcon: true,
|
|
57
51
|
label: label,
|
|
58
52
|
mode: "prefix",
|
|
59
53
|
tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
|
|
60
54
|
onClick: function onClick() {
|
|
61
|
-
return onClickPrefix && !disabled && onClickPrefix(
|
|
62
|
-
},
|
|
63
|
-
interactuable: typeof onClickPrefix === "function" && !disabled
|
|
64
|
-
}, (0, _typeof2["default"])(prefixIcon) === "object" ? prefixIcon : /*#__PURE__*/_react["default"].createElement(prefixIcon)) : prefixIconSrc && /*#__PURE__*/_react["default"].createElement(PrefixIconContainer, {
|
|
65
|
-
disabled: disabled,
|
|
66
|
-
src: prefixIconSrc,
|
|
67
|
-
label: label,
|
|
68
|
-
tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
|
|
69
|
-
onClick: function onClick() {
|
|
70
|
-
return onClickPrefix && !disabled && onClickPrefix(label);
|
|
55
|
+
return onClickPrefix && !disabled && onClickPrefix();
|
|
71
56
|
},
|
|
72
57
|
interactuable: typeof onClickPrefix === "function" && !disabled
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, label), suffixIcon
|
|
58
|
+
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(PrefixIconContainer, {
|
|
59
|
+
src: prefixIcon
|
|
60
|
+
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(ChipTextContainer, {
|
|
61
|
+
disabled: disabled
|
|
62
|
+
}, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
78
63
|
disabled: disabled,
|
|
79
64
|
suffixIcon: true,
|
|
80
65
|
mode: "suffix",
|
|
81
66
|
label: label,
|
|
82
67
|
tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
|
|
83
68
|
onClick: function onClick() {
|
|
84
|
-
return onClickSuffix && !disabled && onClickSuffix(
|
|
69
|
+
return onClickSuffix && !disabled && onClickSuffix();
|
|
85
70
|
},
|
|
86
71
|
interactuable: typeof onClickSuffix === "function" && !disabled
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
label: label,
|
|
91
|
-
tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
|
|
92
|
-
onClick: function onClick() {
|
|
93
|
-
return onClickSuffix && !disabled && onClickSuffix(label);
|
|
94
|
-
},
|
|
95
|
-
interactuable: typeof onClickSuffix === "function" && !disabled
|
|
96
|
-
})));
|
|
72
|
+
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(SuffixIconContainer, {
|
|
73
|
+
src: suffixIcon
|
|
74
|
+
}) : suffixIcon)));
|
|
97
75
|
};
|
|
98
76
|
|
|
99
77
|
var getCursor = function getCursor(interactuable, disabled) {
|
|
@@ -159,34 +137,14 @@ var ChipTextContainer = _styledComponents["default"].span(_templateObject2 || (_
|
|
|
159
137
|
return disabled && "not-allowed" || "default";
|
|
160
138
|
});
|
|
161
139
|
|
|
162
|
-
var SuffixIconContainer = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["
|
|
163
|
-
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
164
|
-
}, function (props) {
|
|
165
|
-
return getCursor(props.interactuable, props.disabled);
|
|
166
|
-
}, function (props) {
|
|
167
|
-
return (props.label || props.suffixIconSrc) && props.theme.iconSpacing || props.prefixIconSrc && "5px";
|
|
168
|
-
}, function (props) {
|
|
169
|
-
return props.theme.iconSize;
|
|
170
|
-
}, function (props) {
|
|
171
|
-
return props.theme.iconSize;
|
|
172
|
-
});
|
|
140
|
+
var SuffixIconContainer = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
173
141
|
|
|
174
|
-
var PrefixIconContainer = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["
|
|
175
|
-
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
176
|
-
}, function (props) {
|
|
177
|
-
return getCursor(props.interactuable, props.disabled);
|
|
178
|
-
}, function (props) {
|
|
179
|
-
return (props.label || props.suffixIconSrc) && props.theme.iconSpacing || props.prefixIconSrc && "5px";
|
|
180
|
-
}, function (props) {
|
|
181
|
-
return props.theme.iconSize;
|
|
182
|
-
}, function (props) {
|
|
183
|
-
return props.theme.iconSize;
|
|
184
|
-
});
|
|
142
|
+
var PrefixIconContainer = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
185
143
|
|
|
186
144
|
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n ", "\n ", "\n width: ", ";\n height: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n &:focus {\n outline-color: ", ";\n outline-width: 2px;\n ", "\n }\n"])), function (props) {
|
|
187
145
|
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
188
146
|
}, function (props) {
|
|
189
|
-
return props.prefixIcon ? "margin-right: ".concat((props.label || props.suffixIcon
|
|
147
|
+
return props.prefixIcon ? "margin-right: ".concat((props.label || props.suffixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";") : "margin-left: ".concat((props.label || props.prefixIcon) && props.theme.iconSpacing || props.prefixIcon && "0", ";");
|
|
190
148
|
}, function (props) {
|
|
191
149
|
return getCursor(props.interactuable, props.disabled);
|
|
192
150
|
}, function (props) {
|
|
@@ -199,23 +157,5 @@ var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templ
|
|
|
199
157
|
return props.disabled && "outline: none;";
|
|
200
158
|
});
|
|
201
159
|
|
|
202
|
-
DxcChip.propTypes = {
|
|
203
|
-
label: _propTypes["default"].string,
|
|
204
|
-
disabled: _propTypes["default"].bool,
|
|
205
|
-
theme: _propTypes["default"].oneOf(["dark", "light"]),
|
|
206
|
-
suffixIcon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
207
|
-
prefixIcon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
|
|
208
|
-
suffixIconSrc: _propTypes["default"].string,
|
|
209
|
-
prefixIconSrc: _propTypes["default"].string,
|
|
210
|
-
onClickSuffix: _propTypes["default"].func,
|
|
211
|
-
onClickPrefix: _propTypes["default"].func,
|
|
212
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
213
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
214
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
215
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
216
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
217
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
218
|
-
tabIndex: _propTypes["default"].number
|
|
219
|
-
};
|
|
220
160
|
var _default = DxcChip;
|
|
221
161
|
exports["default"] = _default;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcChip from "./Chip";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Chip",
|
|
9
|
+
component: DxcChip,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const iconSVG = (
|
|
13
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
14
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
15
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const Chromatic = () => (
|
|
20
|
+
<>
|
|
21
|
+
<ExampleContainer>
|
|
22
|
+
<Title title="Basic chip" theme="light" level={4} />
|
|
23
|
+
<DxcChip label="Default Chip" />
|
|
24
|
+
</ExampleContainer>
|
|
25
|
+
<ExampleContainer>
|
|
26
|
+
<Title title="Chip with prefix" theme="light" level={4} />
|
|
27
|
+
<DxcChip label="Chip with prefix" prefixIcon={iconSVG} />
|
|
28
|
+
</ExampleContainer>
|
|
29
|
+
<ExampleContainer>
|
|
30
|
+
<Title title="Chip with suffix" theme="light" level={4} />
|
|
31
|
+
<DxcChip label="Chip with suffix" suffixIcon={iconSVG} />
|
|
32
|
+
</ExampleContainer>
|
|
33
|
+
<ExampleContainer>
|
|
34
|
+
<Title title="Chip with prefix and suffix" theme="light" level={4} />
|
|
35
|
+
<DxcChip label="Chip with prefix and suffix" prefixIcon={iconSVG} suffixIcon={iconSVG} />
|
|
36
|
+
</ExampleContainer>
|
|
37
|
+
<ExampleContainer>
|
|
38
|
+
<Title title="Disabled chip" theme="light" level={4} />
|
|
39
|
+
<DxcChip label="Disabled" disabled prefixIcon={iconSVG} suffixIcon={iconSVG} />
|
|
40
|
+
</ExampleContainer>
|
|
41
|
+
<ExampleContainer>
|
|
42
|
+
<Title title="Chip with ellipsis" theme="light" level={4} />
|
|
43
|
+
<DxcChip label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fg ssssssssssss ssss" />
|
|
44
|
+
</ExampleContainer>
|
|
45
|
+
<ExampleContainer>
|
|
46
|
+
<Title title="Chip with ellipsis and suffix" theme="light" level={4} />
|
|
47
|
+
<DxcChip
|
|
48
|
+
suffixIcon={iconSVG}
|
|
49
|
+
label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fgsss"
|
|
50
|
+
/>
|
|
51
|
+
</ExampleContainer>
|
|
52
|
+
<ExampleContainer>
|
|
53
|
+
<Title title="Chip with ellipsis and prefix" theme="light" level={4} />
|
|
54
|
+
<DxcChip
|
|
55
|
+
prefixIcon={iconSVG}
|
|
56
|
+
label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fgsss"
|
|
57
|
+
/>
|
|
58
|
+
</ExampleContainer>
|
|
59
|
+
<ExampleContainer>
|
|
60
|
+
<Title title="Chip with ellipsis, suffix and prefix" theme="light" level={4} />
|
|
61
|
+
<DxcChip
|
|
62
|
+
prefixIcon={iconSVG}
|
|
63
|
+
suffixIcon={iconSVG}
|
|
64
|
+
label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasdf"
|
|
65
|
+
/>
|
|
66
|
+
</ExampleContainer>
|
|
67
|
+
<Title title="Margins" theme="light" level={2} />
|
|
68
|
+
<ExampleContainer>
|
|
69
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
70
|
+
<DxcChip label="xxsmall" margin="xxsmall" />
|
|
71
|
+
</ExampleContainer>
|
|
72
|
+
<ExampleContainer>
|
|
73
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
74
|
+
<DxcChip label="xsmall" margin="xsmall" />
|
|
75
|
+
</ExampleContainer>
|
|
76
|
+
<ExampleContainer>
|
|
77
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
78
|
+
<DxcChip label="small" margin="small" />
|
|
79
|
+
</ExampleContainer>
|
|
80
|
+
<ExampleContainer>
|
|
81
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
82
|
+
<DxcChip label="medium" margin="medium" />
|
|
83
|
+
</ExampleContainer>
|
|
84
|
+
<ExampleContainer>
|
|
85
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
86
|
+
<DxcChip label="large" margin="large" />
|
|
87
|
+
</ExampleContainer>
|
|
88
|
+
<ExampleContainer>
|
|
89
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
90
|
+
<DxcChip label="xlarge" margin="xlarge" />
|
|
91
|
+
</ExampleContainer>
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
94
|
+
<DxcChip label="xxlarge" margin="xxlarge" />
|
|
95
|
+
</ExampleContainer>
|
|
96
|
+
</>
|
|
97
|
+
);
|
|
98
|
+
const ChipPrefixFocused = () => (
|
|
99
|
+
<ExampleContainer>
|
|
100
|
+
<Title title="Chip with prefix" theme="light" level={4} />
|
|
101
|
+
<DxcChip label="Chip with prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
|
|
102
|
+
</ExampleContainer>
|
|
103
|
+
);
|
|
104
|
+
const ChipSuffixFocused = () => (
|
|
105
|
+
<ExampleContainer>
|
|
106
|
+
<Title title="Chip with suffix" theme="light" level={4} />
|
|
107
|
+
<DxcChip label="Chip with suffix" suffixIcon={iconSVG} onClickSuffix={() => {}} />
|
|
108
|
+
</ExampleContainer>
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
export const PrefixFocused = ChipPrefixFocused.bind({});
|
|
112
|
+
PrefixFocused.play = async ({ canvasElement }) => {
|
|
113
|
+
await userEvent.tab();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const SuffixFocused = ChipSuffixFocused.bind({});
|
|
117
|
+
SuffixFocused.play = async ({ canvasElement }) => {
|
|
118
|
+
await userEvent.tab();
|
|
119
|
+
};
|
package/chip/types.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
10
|
+
declare type Props = {
|
|
11
|
+
/**
|
|
12
|
+
* Text to be placed on the chip.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Element or path used as icon to be placed after the chip label.
|
|
17
|
+
*/
|
|
18
|
+
suffixIcon?: string | SVG;
|
|
19
|
+
/**
|
|
20
|
+
* Element or path used as icon to be placed before the chip label.
|
|
21
|
+
*/
|
|
22
|
+
prefixIcon?: string | SVG;
|
|
23
|
+
/**
|
|
24
|
+
* This function will be called when the suffix is clicked.
|
|
25
|
+
*/
|
|
26
|
+
onClickSuffix?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* This function will be called when the prefix is clicked.
|
|
29
|
+
*/
|
|
30
|
+
onClickPrefix?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the component will be disabled.
|
|
33
|
+
*/
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
37
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
38
|
+
*/
|
|
39
|
+
margin?: Space | Margin;
|
|
40
|
+
/**
|
|
41
|
+
* Value of the tabindex attribute.
|
|
42
|
+
*/
|
|
43
|
+
tabIndex?: number;
|
|
44
|
+
};
|
|
45
|
+
export default Props;
|