@dxc-technology/halstack-react 0.0.0-63ee6f9 → 0.0.0-64ec938
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.d.ts +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +7 -28
- package/accordion/Accordion.stories.tsx +12 -12
- package/accordion/Accordion.test.js +19 -4
- package/accordion/types.d.ts +4 -0
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +14 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +24 -6
- package/accordion-group/types.d.ts +4 -0
- package/alert/Alert.js +4 -1
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +14 -11
- package/card/Card.js +24 -27
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +38 -28
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/types.d.ts +3 -3
- package/common/variables.js +197 -84
- package/date-input/DateInput.js +38 -20
- package/date-input/DateInput.test.js +9 -22
- package/date-input/types.d.ts +12 -9
- package/dialog/Dialog.js +4 -32
- package/dropdown/Dropdown.js +13 -17
- package/dropdown/Dropdown.stories.tsx +1 -1
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +3 -0
- package/flex/Flex.js +74 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +15 -88
- package/footer/Icons.js +1 -1
- package/header/Header.js +27 -48
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +4 -3
- package/layout/ApplicationLayout.js +68 -113
- 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.d.ts +3 -2
- package/link/Link.js +57 -74
- package/link/Link.stories.tsx +88 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -5
- package/main.js +51 -21
- package/number-input/NumberInput.test.js +2 -4
- package/number-input/types.d.ts +13 -10
- package/package.json +7 -5
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +3 -6
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.js +1 -1
- package/progress-bar/ProgressBar.stories.jsx +11 -11
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +118 -0
- package/quick-nav/QuickNav.stories.tsx +264 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +10 -7
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +175 -0
- package/select/Option.js +1 -1
- package/select/Select.js +106 -186
- package/select/Select.stories.tsx +144 -100
- package/select/Select.test.js +377 -231
- package/select/types.d.ts +32 -11
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +20 -9
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +31 -10
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +1 -1
- package/stack/Stack.d.ts +2 -1
- package/stack/Stack.js +29 -70
- package/stack/Stack.stories.tsx +189 -90
- package/stack/types.d.ts +15 -7
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +35 -19
- package/switch/Switch.stories.tsx +14 -14
- package/switch/Switch.test.js +25 -0
- package/switch/types.d.ts +6 -2
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +26 -9
- package/tabs/types.d.ts +4 -0
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +132 -0
- package/tabs-nav/types.d.ts +53 -0
- package/tabs-nav/types.js +5 -0
- package/tag/Tag.js +5 -8
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +48 -76
- package/text-input/TextInput.test.js +22 -35
- package/text-input/types.d.ts +27 -12
- package/textarea/Textarea.js +12 -23
- package/textarea/Textarea.test.js +10 -20
- package/textarea/types.d.ts +14 -11
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +8 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +35 -29
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
package/stack/Stack.stories.tsx
CHANGED
|
@@ -13,152 +13,251 @@ export const Chromatic = () => (
|
|
|
13
13
|
<Title title="Default" theme="light" level={4} />
|
|
14
14
|
<Container>
|
|
15
15
|
<DxcStack>
|
|
16
|
-
<Placeholder
|
|
17
|
-
<Placeholder
|
|
18
|
-
<Placeholder
|
|
16
|
+
<Placeholder height="small" width="small" />
|
|
17
|
+
<Placeholder height="medium" width="medium" />
|
|
18
|
+
<Placeholder height="large" width="large" />
|
|
19
|
+
<Placeholder height="small" width="large" />
|
|
19
20
|
</DxcStack>
|
|
20
21
|
</Container>
|
|
21
|
-
<Title title="
|
|
22
|
+
<Title title="Default with divider" theme="light" level={4} />
|
|
22
23
|
<Container>
|
|
23
|
-
<DxcStack
|
|
24
|
-
<Placeholder
|
|
25
|
-
<Placeholder
|
|
26
|
-
<Placeholder
|
|
24
|
+
<DxcStack divider>
|
|
25
|
+
<Placeholder height="medium" width="medium" />
|
|
26
|
+
<Placeholder height="large" width="large" />
|
|
27
|
+
<Placeholder height="small" width="large" />
|
|
27
28
|
</DxcStack>
|
|
28
29
|
</Container>
|
|
29
|
-
<Title title="
|
|
30
|
+
<Title title="Alignment with divider" theme="light" level={4} />
|
|
30
31
|
<Container>
|
|
31
|
-
<DxcStack
|
|
32
|
-
<Placeholder
|
|
33
|
-
<Placeholder
|
|
34
|
-
<Placeholder
|
|
32
|
+
<DxcStack alignX="end" divider>
|
|
33
|
+
<Placeholder height="small" width="small" />
|
|
34
|
+
<Placeholder height="small" width="medium" />
|
|
35
|
+
<Placeholder height="medium" width="small" />
|
|
35
36
|
</DxcStack>
|
|
36
37
|
</Container>
|
|
37
|
-
<Title title="
|
|
38
|
+
<Title title="Default with one child" theme="light" level={4} />
|
|
38
39
|
<Container>
|
|
39
|
-
<DxcStack
|
|
40
|
-
<Placeholder
|
|
41
|
-
<Placeholder></Placeholder>
|
|
42
|
-
<Placeholder paddingLeft={60}></Placeholder>
|
|
40
|
+
<DxcStack divider>
|
|
41
|
+
<Placeholder height="large" width="xlarge" />
|
|
43
42
|
</DxcStack>
|
|
44
43
|
</Container>
|
|
45
|
-
<Title title="
|
|
44
|
+
<Title title="Wrap" theme="light" level={4} />
|
|
45
|
+
<FlexContainer customHeight>
|
|
46
|
+
<DxcStack wrap>
|
|
47
|
+
<Placeholder height="small" width="small" />
|
|
48
|
+
<Placeholder height="large" width="medium" />
|
|
49
|
+
<Placeholder height="medium" width="small" />
|
|
50
|
+
<Placeholder height="large" width="medium" />
|
|
51
|
+
</DxcStack>
|
|
52
|
+
</FlexContainer>
|
|
53
|
+
<Title title="No wrap in a flex container" theme="light" level={4} />
|
|
54
|
+
<FlexContainer customHeight>
|
|
55
|
+
<DxcStack>
|
|
56
|
+
<Placeholder height="small" width="small" />
|
|
57
|
+
<Placeholder height="medium" width="small" />
|
|
58
|
+
<Placeholder height="small" width="medium" />
|
|
59
|
+
</DxcStack>
|
|
60
|
+
</FlexContainer>
|
|
61
|
+
<Title title="No wrap (default)" theme="light" level={4} />
|
|
62
|
+
<Container customHeight>
|
|
63
|
+
<DxcStack>
|
|
64
|
+
<Placeholder height="small" width="medium" />
|
|
65
|
+
<Placeholder height="small" width="small" />
|
|
66
|
+
</DxcStack>
|
|
67
|
+
</Container>
|
|
68
|
+
<Title title="AlignX = start" theme="light" level={4} />
|
|
46
69
|
<Container>
|
|
47
|
-
<DxcStack
|
|
48
|
-
<Placeholder
|
|
49
|
-
<Placeholder
|
|
50
|
-
<Placeholder
|
|
70
|
+
<DxcStack alignX="start">
|
|
71
|
+
<Placeholder height="small" width="small" />
|
|
72
|
+
<Placeholder height="large" width="medium" />
|
|
73
|
+
<Placeholder height="medium" width="small" />
|
|
74
|
+
<Placeholder height="large" width="medium" />
|
|
51
75
|
</DxcStack>
|
|
52
76
|
</Container>
|
|
53
|
-
<Title title="
|
|
77
|
+
<Title title="AlignX = end" theme="light" level={4} />
|
|
54
78
|
<Container>
|
|
55
|
-
<DxcStack
|
|
56
|
-
<Placeholder
|
|
57
|
-
<Placeholder
|
|
58
|
-
<Placeholder
|
|
79
|
+
<DxcStack alignX="end">
|
|
80
|
+
<Placeholder height="small" width="small" />
|
|
81
|
+
<Placeholder height="large" width="medium" />
|
|
82
|
+
<Placeholder height="medium" width="small" />
|
|
59
83
|
</DxcStack>
|
|
60
84
|
</Container>
|
|
61
|
-
<Title title="
|
|
85
|
+
<Title title="AlignX = center" theme="light" level={4} />
|
|
62
86
|
<Container>
|
|
63
|
-
<DxcStack
|
|
64
|
-
<Placeholder
|
|
65
|
-
<Placeholder
|
|
66
|
-
<Placeholder
|
|
87
|
+
<DxcStack alignX="center">
|
|
88
|
+
<Placeholder height="small" width="small" />
|
|
89
|
+
<Placeholder height="large" width="medium" />
|
|
90
|
+
<Placeholder height="medium" width="small" />
|
|
91
|
+
<Placeholder height="large" width="medium" />
|
|
67
92
|
</DxcStack>
|
|
68
93
|
</Container>
|
|
69
|
-
<Title title="
|
|
94
|
+
<Title title="AlignX = baseline" theme="light" level={4} />
|
|
70
95
|
<Container>
|
|
71
|
-
<DxcStack
|
|
72
|
-
<Placeholder
|
|
73
|
-
<Placeholder
|
|
74
|
-
<Placeholder
|
|
96
|
+
<DxcStack alignX="baseline">
|
|
97
|
+
<Placeholder height="small" width="small" />
|
|
98
|
+
<Placeholder height="large" width="medium" />
|
|
99
|
+
<Placeholder height="medium" width="small" />
|
|
75
100
|
</DxcStack>
|
|
76
101
|
</Container>
|
|
77
|
-
<Title title="
|
|
102
|
+
<Title title="AlignX with wrapped items" theme="light" level={4} />
|
|
103
|
+
<Container customHeight>
|
|
104
|
+
<DxcStack alignX="center" wrap>
|
|
105
|
+
<Placeholder height="small" width="medium" />
|
|
106
|
+
<Placeholder height="small" width="small" />
|
|
107
|
+
</DxcStack>
|
|
108
|
+
</Container>
|
|
109
|
+
<Title title="Gutter = 0rem" theme="light" level={4} />
|
|
110
|
+
<Container>
|
|
111
|
+
<DxcStack gutter="0rem">
|
|
112
|
+
<Placeholder height="small" width="medium" />
|
|
113
|
+
<Placeholder height="large" width="small" />
|
|
114
|
+
<Placeholder height="medium" width="medium" />
|
|
115
|
+
<Placeholder height="large" width="small" />
|
|
116
|
+
<Placeholder height="small" width="medium" />
|
|
117
|
+
</DxcStack>
|
|
118
|
+
</Container>
|
|
119
|
+
<Title title="Gutter = 0.125rem" theme="light" level={4} />
|
|
78
120
|
<Container>
|
|
79
|
-
<DxcStack gutter="
|
|
80
|
-
<Placeholder
|
|
81
|
-
<Placeholder
|
|
82
|
-
<Placeholder
|
|
121
|
+
<DxcStack gutter="0.125rem">
|
|
122
|
+
<Placeholder height="small" width="small" />
|
|
123
|
+
<Placeholder height="large" width="medium" />
|
|
124
|
+
<Placeholder height="medium" width="small" />
|
|
83
125
|
</DxcStack>
|
|
84
126
|
</Container>
|
|
85
|
-
<Title title="
|
|
127
|
+
<Title title="Gutter = 0.25rem" theme="light" level={4} />
|
|
86
128
|
<Container>
|
|
87
|
-
<DxcStack gutter="
|
|
88
|
-
<Placeholder
|
|
89
|
-
<Placeholder
|
|
90
|
-
<Placeholder
|
|
129
|
+
<DxcStack gutter="0.25rem">
|
|
130
|
+
<Placeholder height="small" width="medium" />
|
|
131
|
+
<Placeholder height="large" width="small" />
|
|
132
|
+
<Placeholder height="medium" width="medium" />
|
|
133
|
+
<Placeholder height="large" width="small" />
|
|
134
|
+
<Placeholder height="small" width="medium" />
|
|
91
135
|
</DxcStack>
|
|
92
136
|
</Container>
|
|
93
|
-
<Title title="
|
|
137
|
+
<Title title="Gutter = 0.5rem" theme="light" level={4} />
|
|
94
138
|
<Container>
|
|
95
|
-
<DxcStack gutter="
|
|
96
|
-
<Placeholder
|
|
97
|
-
<Placeholder
|
|
98
|
-
<Placeholder
|
|
139
|
+
<DxcStack gutter="0.5rem">
|
|
140
|
+
<Placeholder height="small" width="small" />
|
|
141
|
+
<Placeholder height="large" width="medium" />
|
|
142
|
+
<Placeholder height="medium" width="small" />
|
|
99
143
|
</DxcStack>
|
|
100
144
|
</Container>
|
|
101
|
-
<Title title="
|
|
145
|
+
<Title title="Gutter = 0.75rem" theme="light" level={4} />
|
|
102
146
|
<Container>
|
|
103
|
-
<DxcStack gutter="
|
|
104
|
-
<Placeholder
|
|
105
|
-
<Placeholder
|
|
106
|
-
<Placeholder
|
|
147
|
+
<DxcStack gutter="0.75rem">
|
|
148
|
+
<Placeholder height="small" width="medium" />
|
|
149
|
+
<Placeholder height="large" width="small" />
|
|
150
|
+
<Placeholder height="medium" width="medium" />
|
|
151
|
+
<Placeholder height="large" width="small" />
|
|
152
|
+
<Placeholder height="small" width="medium" />
|
|
107
153
|
</DxcStack>
|
|
108
154
|
</Container>
|
|
109
|
-
<Title title="
|
|
155
|
+
<Title title="Gutter = 1rem" theme="light" level={4} />
|
|
110
156
|
<Container>
|
|
111
|
-
<DxcStack gutter="
|
|
112
|
-
<Placeholder
|
|
113
|
-
<Placeholder
|
|
114
|
-
<Placeholder
|
|
157
|
+
<DxcStack gutter="1rem">
|
|
158
|
+
<Placeholder height="small" width="small" />
|
|
159
|
+
<Placeholder height="large" width="medium" />
|
|
160
|
+
<Placeholder height="medium" width="small" />
|
|
115
161
|
</DxcStack>
|
|
116
162
|
</Container>
|
|
117
|
-
<Title title="
|
|
163
|
+
<Title title="Gutter = 1.5rem" theme="light" level={4} />
|
|
118
164
|
<Container>
|
|
119
|
-
<DxcStack gutter="
|
|
120
|
-
<Placeholder
|
|
121
|
-
<Placeholder
|
|
122
|
-
<Placeholder
|
|
165
|
+
<DxcStack gutter="1.5rem">
|
|
166
|
+
<Placeholder height="small" width="medium" />
|
|
167
|
+
<Placeholder height="large" width="small" />
|
|
168
|
+
<Placeholder height="medium" width="medium" />
|
|
169
|
+
<Placeholder height="large" width="small" />
|
|
170
|
+
<Placeholder height="small" width="medium" />
|
|
123
171
|
</DxcStack>
|
|
124
172
|
</Container>
|
|
125
|
-
<Title title="
|
|
173
|
+
<Title title="Gutter = 2rem & divider" theme="light" level={4} />
|
|
126
174
|
<Container>
|
|
127
|
-
<DxcStack gutter="
|
|
128
|
-
<Placeholder
|
|
129
|
-
<Placeholder
|
|
130
|
-
<Placeholder
|
|
175
|
+
<DxcStack gutter="2rem" divider>
|
|
176
|
+
<Placeholder height="small" width="small" />
|
|
177
|
+
<Placeholder height="large" width="medium" />
|
|
178
|
+
<Placeholder height="medium" width="small" />
|
|
131
179
|
</DxcStack>
|
|
132
180
|
</Container>
|
|
133
|
-
<Title title="
|
|
181
|
+
<Title title="Gutter = 3rem" theme="light" level={4} />
|
|
134
182
|
<Container>
|
|
135
|
-
<DxcStack gutter="
|
|
136
|
-
<Placeholder
|
|
137
|
-
<Placeholder
|
|
138
|
-
<Placeholder
|
|
183
|
+
<DxcStack gutter="3rem">
|
|
184
|
+
<Placeholder height="small" width="small" />
|
|
185
|
+
<Placeholder height="large" width="medium" />
|
|
186
|
+
<Placeholder height="medium" width="small" />
|
|
139
187
|
</DxcStack>
|
|
140
188
|
</Container>
|
|
141
|
-
<Title title="
|
|
189
|
+
<Title title="Gutter = 4rem" theme="light" level={4} />
|
|
142
190
|
<Container>
|
|
143
|
-
<DxcStack gutter="
|
|
144
|
-
<Placeholder
|
|
145
|
-
<Placeholder
|
|
146
|
-
<Placeholder></Placeholder>
|
|
191
|
+
<DxcStack gutter="4rem">
|
|
192
|
+
<Placeholder height="large" width="medium" />
|
|
193
|
+
<Placeholder height="medium" width="small" />
|
|
147
194
|
</DxcStack>
|
|
148
195
|
</Container>
|
|
196
|
+
<Title title="Gutter = 5rem" theme="light" level={4} />
|
|
197
|
+
<Container>
|
|
198
|
+
<DxcStack gutter="5rem">
|
|
199
|
+
<Placeholder height="small" width="small" />
|
|
200
|
+
<Placeholder height="medium" width="small" />
|
|
201
|
+
</DxcStack>
|
|
202
|
+
</Container>
|
|
203
|
+
<Title title="Reverse" theme="light" level={4} />
|
|
204
|
+
<Container>
|
|
205
|
+
<DxcStack reverse>
|
|
206
|
+
<Placeholder height="small" width="medium">
|
|
207
|
+
1
|
|
208
|
+
</Placeholder>
|
|
209
|
+
<Placeholder height="large" width="small">
|
|
210
|
+
2
|
|
211
|
+
</Placeholder>
|
|
212
|
+
<Placeholder height="medium" width="medium">
|
|
213
|
+
3
|
|
214
|
+
</Placeholder>
|
|
215
|
+
<Placeholder height="large" width="small">
|
|
216
|
+
4
|
|
217
|
+
</Placeholder>
|
|
218
|
+
</DxcStack>
|
|
219
|
+
</Container>
|
|
220
|
+
<Title title="Wrapped and reversed children" theme="light" level={4} />
|
|
221
|
+
<FlexContainer customHeight>
|
|
222
|
+
<DxcStack reverse wrap>
|
|
223
|
+
<Placeholder height="small" width="medium">
|
|
224
|
+
1
|
|
225
|
+
</Placeholder>
|
|
226
|
+
<Placeholder height="large" width="small">
|
|
227
|
+
2
|
|
228
|
+
</Placeholder>
|
|
229
|
+
<Placeholder height="medium" width="medium">
|
|
230
|
+
3
|
|
231
|
+
</Placeholder>
|
|
232
|
+
<Placeholder height="large" width="small">
|
|
233
|
+
4
|
|
234
|
+
</Placeholder>
|
|
235
|
+
</DxcStack>
|
|
236
|
+
</FlexContainer>
|
|
149
237
|
</>
|
|
150
238
|
);
|
|
151
239
|
|
|
152
|
-
const
|
|
240
|
+
const FlexContainer = styled.div<{ customHeight?: boolean }>`
|
|
241
|
+
display: flex;
|
|
242
|
+
${({ customHeight }) => customHeight && `height: 100px;`};
|
|
153
243
|
background: #f2eafa;
|
|
154
|
-
padding: 10px;
|
|
155
244
|
`;
|
|
156
245
|
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
246
|
+
const Container = styled.div<{ customHeight?: boolean }>`
|
|
247
|
+
background: #f2eafa;
|
|
248
|
+
${({ customHeight }) => customHeight && `height: 100px;`};
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
type PlaceholderProps = {
|
|
252
|
+
width?: "xlarge" | "large" | "medium" | "small" | "auto";
|
|
253
|
+
height?: "large" | "medium" | "small" | "auto";
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const Placeholder = styled.div<PlaceholderProps>`
|
|
257
|
+
${({ width }) =>
|
|
258
|
+
width &&
|
|
259
|
+
`width: ${width === "xlarge" ? "350px" : width === "large" ? "150px" : width === "medium" ? "100px" : "50px"};`};
|
|
260
|
+
${({ height }) => height && `height: ${height === "large" ? "100px" : height === "medium" ? "80px" : "50px"};`};
|
|
160
261
|
border: 1px solid #a46ede;
|
|
161
262
|
background-color: #e5d5f6;
|
|
162
|
-
padding-left: ${({ paddingLeft }) => `${paddingLeft ?? 0}px`};
|
|
163
|
-
padding-right: ${({ paddingRight }) => `${paddingRight ?? 0}px`};
|
|
164
263
|
`;
|
package/stack/types.d.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare type Props = {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Alignment applied to children in the main axis.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
alignX?: "start" | "end" | "center" | "baseline" | "stretch";
|
|
7
|
+
/**
|
|
8
|
+
* Specifies the HTML tag or component that is rendered as the wrapper element.
|
|
9
|
+
*/
|
|
10
|
+
as?: React.ElementType;
|
|
7
11
|
/**
|
|
8
12
|
* If true, a divider is shown between children.
|
|
9
13
|
*/
|
|
10
14
|
divider?: boolean;
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
16
|
+
* Space applied between each child.
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
gutter?: "0rem" | "0.125rem" | "0.25rem" | "0.5rem" | "0.75rem" | "1rem" | "1.5rem" | "2rem" | "3rem" | "4rem" | "5rem";
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
20
|
+
* Change the direction of the stack to reverse.
|
|
17
21
|
*/
|
|
18
|
-
|
|
22
|
+
reverse?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Sets whether the children are forced onto one column or can wrap onto multiple columns.
|
|
25
|
+
*/
|
|
26
|
+
wrap?: boolean;
|
|
19
27
|
/**
|
|
20
28
|
* Custom content inside the stack.
|
|
21
29
|
*/
|
|
22
|
-
children: React.ReactNode;
|
|
30
|
+
children: React.ReactNode[] | React.ReactNode;
|
|
23
31
|
};
|
|
24
32
|
export default Props;
|
package/switch/Switch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import SwitchPropsType from "./types";
|
|
3
|
-
declare const DxcSwitch: ({ checked, value, label, labelPosition, name, disabled,
|
|
3
|
+
declare const DxcSwitch: ({ defaultChecked, checked, value, label, labelPosition, name, disabled, optional, onChange, margin, size, tabIndex, }: SwitchPropsType) => JSX.Element;
|
|
4
4
|
export default DxcSwitch;
|
package/switch/Switch.js
CHANGED
|
@@ -21,7 +21,7 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _core = require("@material-ui/core");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _uuid = require("uuid");
|
|
25
25
|
|
|
26
26
|
var _variables = require("../common/variables.js");
|
|
27
27
|
|
|
@@ -29,6 +29,8 @@ var _utils = require("../common/utils.js");
|
|
|
29
29
|
|
|
30
30
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
31
|
|
|
32
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
33
|
+
|
|
32
34
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
35
|
|
|
34
36
|
var _templateObject, _templateObject2;
|
|
@@ -38,7 +40,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
38
40
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
39
41
|
|
|
40
42
|
var DxcSwitch = function DxcSwitch(_ref) {
|
|
41
|
-
var
|
|
43
|
+
var defaultChecked = _ref.defaultChecked,
|
|
44
|
+
checked = _ref.checked,
|
|
42
45
|
value = _ref.value,
|
|
43
46
|
_ref$label = _ref.label,
|
|
44
47
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -48,21 +51,28 @@ var DxcSwitch = function DxcSwitch(_ref) {
|
|
|
48
51
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
49
52
|
_ref$disabled = _ref.disabled,
|
|
50
53
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
54
|
+
_ref$optional = _ref.optional,
|
|
55
|
+
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
51
56
|
onChange = _ref.onChange,
|
|
52
|
-
_ref$required = _ref.required,
|
|
53
|
-
required = _ref$required === void 0 ? false : _ref$required,
|
|
54
57
|
margin = _ref.margin,
|
|
55
58
|
_ref$size = _ref.size,
|
|
56
59
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
57
60
|
_ref$tabIndex = _ref.tabIndex,
|
|
58
61
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
59
62
|
|
|
60
|
-
var _useState = (0, _react.useState)(
|
|
61
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState,
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
var _useState = (0, _react.useState)("switch-".concat((0, _uuid.v4)())),
|
|
64
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
65
|
+
switchId = _useState2[0];
|
|
66
|
+
|
|
67
|
+
var labelId = "label-".concat(switchId);
|
|
68
|
+
|
|
69
|
+
var _useState3 = (0, _react.useState)(defaultChecked !== null && defaultChecked !== void 0 ? defaultChecked : false),
|
|
70
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
71
|
+
innerChecked = _useState4[0],
|
|
72
|
+
setInnerChecked = _useState4[1];
|
|
64
73
|
|
|
65
74
|
var colorsTheme = (0, _useTheme["default"])();
|
|
75
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
66
76
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
67
77
|
|
|
68
78
|
var handlerSwitchChange = function handlerSwitchChange(event) {
|
|
@@ -75,6 +85,14 @@ var DxcSwitch = function DxcSwitch(_ref) {
|
|
|
75
85
|
} else onChange === null || onChange === void 0 ? void 0 : onChange(!checked);
|
|
76
86
|
};
|
|
77
87
|
|
|
88
|
+
var labelComponent = /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
89
|
+
id: labelId,
|
|
90
|
+
labelPosition: labelPosition,
|
|
91
|
+
onClick: !disabled && handlerSwitchChange,
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
backgroundType: backgroundType
|
|
94
|
+
}, labelPosition === "before" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label, " ", optional && /*#__PURE__*/_react["default"].createElement("span", null, translatedLabels.formFields.optionalLabel)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, optional && /*#__PURE__*/_react["default"].createElement("span", null, translatedLabels.formFields.optionalLabel), " ", label));
|
|
95
|
+
|
|
78
96
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
79
97
|
theme: colorsTheme["switch"]
|
|
80
98
|
}, /*#__PURE__*/_react["default"].createElement(SwitchContainer, {
|
|
@@ -83,22 +101,20 @@ var DxcSwitch = function DxcSwitch(_ref) {
|
|
|
83
101
|
labelPosition: labelPosition,
|
|
84
102
|
size: size,
|
|
85
103
|
backgroundType: backgroundType
|
|
86
|
-
}, /*#__PURE__*/_react["default"].createElement(_core.Switch, {
|
|
104
|
+
}, labelPosition === "before" && labelComponent, /*#__PURE__*/_react["default"].createElement(_core.Switch, {
|
|
87
105
|
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
88
106
|
inputProps: {
|
|
89
107
|
name: name,
|
|
108
|
+
"aria-labelledby": labelId,
|
|
109
|
+
role: "switch",
|
|
110
|
+
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
90
111
|
tabIndex: tabIndex
|
|
91
112
|
},
|
|
92
113
|
onChange: handlerSwitchChange,
|
|
93
114
|
value: value,
|
|
94
115
|
disabled: disabled,
|
|
95
116
|
disableRipple: true
|
|
96
|
-
}),
|
|
97
|
-
labelPosition: labelPosition,
|
|
98
|
-
onClick: !disabled && handlerSwitchChange,
|
|
99
|
-
disabled: disabled,
|
|
100
|
-
backgroundType: backgroundType
|
|
101
|
-
}, required && /*#__PURE__*/_react["default"].createElement(_RequiredComponent["default"], null), label)));
|
|
117
|
+
}), labelPosition === "after" && labelComponent));
|
|
102
118
|
};
|
|
103
119
|
|
|
104
120
|
var sizes = {
|
|
@@ -113,10 +129,8 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
113
129
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
114
130
|
};
|
|
115
131
|
|
|
116
|
-
var SwitchContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n display: inline-flex;\n align-items: center;\n
|
|
132
|
+
var SwitchContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n display: inline-flex;\n align-items: center;\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n\n .MuiSwitch-root {\n align-items: center;\n width: ", ";\n height: 45px;\n margin: 3px;\n\n .Mui-focusVisible {\n outline: ", ";\n outline-offset: -3px;\n }\n\n .MuiSwitch-track {\n /*Enabled and unchecked bar*/\n background-color: ", ";\n height: ", ";\n }\n\n .MuiSwitch-switchBase + .MuiSwitch-track {\n opacity: 1;\n }\n\n .MuiIconButton-root {\n /*Enabled and unchecked*/\n top: unset;\n .MuiSwitch-thumb {\n /*Only for thumb in all states*/\n width: ", ";\n height: ", ";\n }\n color: ", ";\n &:hover {\n background-color: transparent;\n }\n &.Mui-disabled {\n /*Disabled and unchecked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and unchecked bar*/\n background-color: ", ";\n }\n }\n &.Mui-disabled.Mui-checked {\n /*Disabled and checked*/\n color: ", ";\n + .MuiSwitch-track {\n /*Disabled and checked bar*/\n background-color: ", ";\n }\n }\n &.Mui-checked {\n /*Enabled and checked*/\n color: ", ";\n transform: translateX(", ");\n &:hover {\n background-color: transparent;\n }\n + .MuiSwitch-track {\n /*Enabled and checked bar*/\n background-color: ", ";\n }\n }\n }\n }\n"])), function (props) {
|
|
117
133
|
return calculateWidth(props.margin, props.size);
|
|
118
|
-
}, function (props) {
|
|
119
|
-
return props.labelPosition === "after" ? "row" : "row-reverse";
|
|
120
134
|
}, function (props) {
|
|
121
135
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
122
136
|
}, function (props) {
|
|
@@ -159,7 +173,7 @@ var SwitchContainer = _styledComponents["default"].div(_templateObject || (_temp
|
|
|
159
173
|
return props.backgroundType === "dark" ? props.theme.checkedTrackBackgroundColorOnDark : props.theme.checkedTrackBackgroundColor;
|
|
160
174
|
});
|
|
161
175
|
|
|
162
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n cursor: ", ";\n ", "\n"])), function (props) {
|
|
176
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n cursor: ", ";\n ", "\n\n ", "\n"])), function (props) {
|
|
163
177
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
164
178
|
}, function (props) {
|
|
165
179
|
return props.theme.labelFontFamily;
|
|
@@ -173,6 +187,8 @@ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_tem
|
|
|
173
187
|
return props.disabled === true ? "not-allowed" : "pointer";
|
|
174
188
|
}, function (props) {
|
|
175
189
|
return props.labelPosition === "after" ? "margin-left: ".concat(props.theme.spaceBetweenLabelSwitch, ";") : "margin-right: ".concat(props.theme.spaceBetweenLabelSwitch, ";");
|
|
190
|
+
}, function (props) {
|
|
191
|
+
return props.labelPosition === "before" && "order: -1";
|
|
176
192
|
});
|
|
177
193
|
|
|
178
194
|
var _default = DxcSwitch;
|
|
@@ -23,23 +23,23 @@ export const Chromatic = () => (
|
|
|
23
23
|
</ExampleContainer>
|
|
24
24
|
<ExampleContainer>
|
|
25
25
|
<Title title="Checked" theme="light" level={4} />
|
|
26
|
-
<DxcSwitch label="Switch"
|
|
26
|
+
<DxcSwitch label="Switch" defaultChecked />
|
|
27
27
|
</ExampleContainer>
|
|
28
28
|
<ExampleContainer>
|
|
29
|
-
<Title title="
|
|
30
|
-
<DxcSwitch label="Switch"
|
|
29
|
+
<Title title="Optional" theme="light" level={4} />
|
|
30
|
+
<DxcSwitch label="Switch" optional />
|
|
31
31
|
</ExampleContainer>
|
|
32
32
|
<ExampleContainer>
|
|
33
33
|
<Title title="Disabled" theme="light" level={4} />
|
|
34
34
|
<DxcSwitch label="Switch" disabled />
|
|
35
35
|
</ExampleContainer>
|
|
36
36
|
<ExampleContainer>
|
|
37
|
-
<Title title="Disabled
|
|
38
|
-
<DxcSwitch label="Switch" disabled
|
|
37
|
+
<Title title="Disabled optional" theme="light" level={4} />
|
|
38
|
+
<DxcSwitch label="Switch" disabled optional labelPosition="after" />
|
|
39
39
|
</ExampleContainer>
|
|
40
40
|
<ExampleContainer>
|
|
41
41
|
<Title title="Disabled checked" theme="light" level={4} />
|
|
42
|
-
<DxcSwitch label="Switch" disabled
|
|
42
|
+
<DxcSwitch label="Switch" disabled defaultChecked labelPosition="after" />
|
|
43
43
|
</ExampleContainer>
|
|
44
44
|
<BackgroundColorProvider color="#333333">
|
|
45
45
|
<DarkContainer>
|
|
@@ -49,23 +49,23 @@ export const Chromatic = () => (
|
|
|
49
49
|
</ExampleContainer>
|
|
50
50
|
<ExampleContainer>
|
|
51
51
|
<Title title="Checked" theme="dark" level={4} />
|
|
52
|
-
<DxcSwitch label="Switch"
|
|
52
|
+
<DxcSwitch label="Switch" defaultChecked />
|
|
53
53
|
</ExampleContainer>
|
|
54
54
|
<ExampleContainer>
|
|
55
|
-
<Title title="
|
|
56
|
-
<DxcSwitch label="Switch"
|
|
55
|
+
<Title title="Optional" theme="dark" level={4} />
|
|
56
|
+
<DxcSwitch label="Switch" optional />
|
|
57
57
|
</ExampleContainer>
|
|
58
58
|
<ExampleContainer>
|
|
59
59
|
<Title title="Disabled" theme="dark" level={4} />
|
|
60
60
|
<DxcSwitch label="Switch" disabled />
|
|
61
61
|
</ExampleContainer>
|
|
62
62
|
<ExampleContainer>
|
|
63
|
-
<Title title="Disabled
|
|
64
|
-
<DxcSwitch label="Switch" disabled
|
|
63
|
+
<Title title="Disabled optional" theme="dark" level={4} />
|
|
64
|
+
<DxcSwitch label="Switch" disabled optional labelPosition="after" />
|
|
65
65
|
</ExampleContainer>
|
|
66
66
|
<ExampleContainer>
|
|
67
67
|
<Title title="Disabled checked" theme="dark" level={4} />
|
|
68
|
-
<DxcSwitch label="Switch" disabled
|
|
68
|
+
<DxcSwitch label="Switch" disabled defaultChecked labelPosition="after" />
|
|
69
69
|
</ExampleContainer>
|
|
70
70
|
</DarkContainer>
|
|
71
71
|
</BackgroundColorProvider>
|
|
@@ -139,7 +139,7 @@ const Switch = () => (
|
|
|
139
139
|
export const FocusedSwitch = Switch.bind({});
|
|
140
140
|
FocusedSwitch.play = async ({ canvasElement }) => {
|
|
141
141
|
const canvas = within(canvasElement);
|
|
142
|
-
canvas.getByRole("
|
|
142
|
+
canvas.getByRole("switch").focus();
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
const DarkSwitch = () => (
|
|
@@ -156,5 +156,5 @@ const DarkSwitch = () => (
|
|
|
156
156
|
export const FocusedSwitchOnDark = DarkSwitch.bind({});
|
|
157
157
|
FocusedSwitchOnDark.play = async ({ canvasElement }) => {
|
|
158
158
|
const canvas = within(canvasElement);
|
|
159
|
-
canvas.getByRole("
|
|
159
|
+
canvas.getByRole("switch").focus();
|
|
160
160
|
};
|
package/switch/Switch.test.js
CHANGED
|
@@ -70,4 +70,29 @@ describe("Switch component tests", function () {
|
|
|
70
70
|
expect(onChange.mock.calls[0][0]).toBe(true);
|
|
71
71
|
expect(onChange.mock.calls[1][0]).toBe(false);
|
|
72
72
|
});
|
|
73
|
+
test("Renders with correct initial value and initial state when it is uncontrolled", function () {
|
|
74
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
75
|
+
label: "Default label",
|
|
76
|
+
defaultChecked: true,
|
|
77
|
+
value: "test-defaultChecked"
|
|
78
|
+
})),
|
|
79
|
+
getByRole = _render5.getByRole;
|
|
80
|
+
|
|
81
|
+
var inputEl = getByRole("switch");
|
|
82
|
+
expect(inputEl.checked).toBe(true);
|
|
83
|
+
expect(inputEl.value).toBe("test-defaultChecked");
|
|
84
|
+
expect(inputEl.getAttribute("aria-checked")).toBe("true");
|
|
85
|
+
});
|
|
86
|
+
test("Renders with correct aria attributes", function () {
|
|
87
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
88
|
+
label: "Default label"
|
|
89
|
+
})),
|
|
90
|
+
getByRole = _render6.getByRole,
|
|
91
|
+
getByText = _render6.getByText;
|
|
92
|
+
|
|
93
|
+
var inputEl = getByRole("switch");
|
|
94
|
+
var label = getByText("Default label");
|
|
95
|
+
expect(inputEl.getAttribute("aria-labelledby")).toBe(label.id);
|
|
96
|
+
expect(inputEl.getAttribute("aria-checked")).toBe("false");
|
|
97
|
+
});
|
|
73
98
|
});
|