@zohodesk/components 1.3.2 → 1.3.4
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/.cli/propValidation_report.html +1 -1
- package/README.md +15 -0
- package/es/Button/__tests__/Button.spec.js +134 -1
- package/es/DateTime/__tests__/YearView.spec.js +1 -2
- package/es/MultiSelect/MultiSelect.js +15 -2
- package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -1
- package/es/MultiSelect/props/propTypes.js +3 -1
- package/es/Provider/IdProvider.js +1 -1
- package/es/Select/Select.js +15 -6
- package/es/Select/__tests__/Select.spec.js +1130 -4
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
- package/es/Select/props/propTypes.js +3 -1
- package/es/Stencils/Stencils.js +5 -12
- package/es/Stencils/Stencils.module.css +11 -7
- package/es/Stencils/__tests__/Stencils.spec.js +9 -1
- package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
- package/es/Stencils/props/defaultProps.js +2 -1
- package/es/Stencils/props/propTypes.js +3 -2
- package/es/Tab/Tab.js +2 -1
- package/es/Tab/TabWrapper.js +2 -1
- package/es/Tab/Tabs.js +10 -10
- package/es/Tab/__tests__/TabLayout.spec.js +34 -0
- package/es/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
- package/es/Tab/props/propTypes.js +2 -2
- package/es/Tab/utils/tabConfigs.js +18 -0
- package/es/Tag/__tests__/Tag.spec.js +8 -1
- package/es/TextBoxIcon/TextBoxIcon.js +6 -2
- package/es/TextBoxIcon/props/propTypes.js +2 -1
- package/es/utils/Common.js +1 -1
- package/lib/Button/__tests__/Button.spec.js +140 -0
- package/lib/DateTime/__tests__/YearView.spec.js +1 -2
- package/lib/MultiSelect/MultiSelect.js +16 -3
- package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -0
- package/lib/MultiSelect/props/propTypes.js +3 -1
- package/lib/Provider/IdProvider.js +1 -0
- package/lib/Select/Select.js +16 -7
- package/lib/Select/__tests__/Select.spec.js +1364 -3
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
- package/lib/Select/props/propTypes.js +3 -1
- package/lib/Stencils/Stencils.js +5 -12
- package/lib/Stencils/Stencils.module.css +11 -7
- package/lib/Stencils/__tests__/Stencils.spec.js +11 -3
- package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
- package/lib/Stencils/props/defaultProps.js +2 -1
- package/lib/Stencils/props/propTypes.js +3 -2
- package/lib/Tab/Tab.js +3 -1
- package/lib/Tab/TabWrapper.js +3 -1
- package/lib/Tab/Tabs.js +11 -10
- package/lib/Tab/__tests__/TabLayout.spec.js +41 -0
- package/lib/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
- package/lib/Tab/props/propTypes.js +2 -2
- package/lib/Tab/utils/tabConfigs.js +27 -0
- package/lib/Tag/__tests__/Tag.spec.js +10 -2
- package/lib/TextBoxIcon/TextBoxIcon.js +6 -2
- package/lib/TextBoxIcon/props/propTypes.js +2 -1
- package/lib/utils/Common.js +1 -1
- package/package.json +1 -1
- package/react-cli.config.js +2 -2
- package/result.json +1 -1
- package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
- package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`TabWrapper rendering the align prop of - horizontal 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="flex cover rowdir"
|
|
7
|
+
data-id="containerComponent"
|
|
8
|
+
data-selector-id="tabWrapper"
|
|
9
|
+
data-test-id="containerComponent"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
class="shrinkOff"
|
|
13
|
+
data-id="boxComponent"
|
|
14
|
+
data-selector-id="tabs"
|
|
15
|
+
data-test-id="boxComponent"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
class="tab alpha alpha_border alpha_padding flex cover coldir"
|
|
19
|
+
data-id="containerComponent"
|
|
20
|
+
data-selector-id="container"
|
|
21
|
+
data-test-id="containerComponent"
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
class="grow basis shrinkOff"
|
|
25
|
+
data-id="boxComponent"
|
|
26
|
+
data-selector-id="box"
|
|
27
|
+
data-test-id="boxComponent"
|
|
28
|
+
>
|
|
29
|
+
<div
|
|
30
|
+
class="flex cover coldir"
|
|
31
|
+
data-id="containerComponent"
|
|
32
|
+
data-selector-id="container"
|
|
33
|
+
data-test-id="containerComponent"
|
|
34
|
+
>
|
|
35
|
+
<div
|
|
36
|
+
class="menu shrinkOff"
|
|
37
|
+
data-id="boxComponent"
|
|
38
|
+
data-selector-id="tabs_moreIcon"
|
|
39
|
+
data-test-id="boxComponent"
|
|
40
|
+
>
|
|
41
|
+
<button
|
|
42
|
+
aria-label="MoreTabs"
|
|
43
|
+
class="buttonReset flex cover coldir both"
|
|
44
|
+
data-id="moreTabs"
|
|
45
|
+
data-selector-id="container"
|
|
46
|
+
data-test-id="moreTabs"
|
|
47
|
+
role="link"
|
|
48
|
+
>
|
|
49
|
+
<i
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
class="zd_font_icons basic icon-menu rtl "
|
|
52
|
+
data-id="fontIcon"
|
|
53
|
+
data-selector-id="fontIcon"
|
|
54
|
+
data-test-id="fontIcon"
|
|
55
|
+
style="--zd-iconfont-size: var(--zd_font_size7);"
|
|
56
|
+
/>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
class="grow basis shrinkOff"
|
|
65
|
+
data-id="boxComponent"
|
|
66
|
+
data-selector-id="tabContentWrapper"
|
|
67
|
+
data-test-id="boxComponent"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
aria-labelledby="page1"
|
|
71
|
+
class="container flex cover coldir"
|
|
72
|
+
data-id="tabContent_TabContent"
|
|
73
|
+
data-scroll="true"
|
|
74
|
+
data-selector-id="tabContent"
|
|
75
|
+
data-test-id="tabContent_TabContent"
|
|
76
|
+
role="tabpanel"
|
|
77
|
+
tabindex="-1"
|
|
78
|
+
>
|
|
79
|
+
<div>
|
|
80
|
+
Page 1 Content
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</DocumentFragment>
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
exports[`TabWrapper rendering the align prop of - horizontal-reverse 1`] = `
|
|
89
|
+
<DocumentFragment>
|
|
90
|
+
<div
|
|
91
|
+
class="flex cover rowReverse"
|
|
92
|
+
data-id="containerComponent"
|
|
93
|
+
data-selector-id="tabWrapper"
|
|
94
|
+
data-test-id="containerComponent"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
class="shrinkOff"
|
|
98
|
+
data-id="boxComponent"
|
|
99
|
+
data-selector-id="tabs"
|
|
100
|
+
data-test-id="boxComponent"
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
class="tab alpha alpha_border alpha_padding flex cover coldir"
|
|
104
|
+
data-id="containerComponent"
|
|
105
|
+
data-selector-id="container"
|
|
106
|
+
data-test-id="containerComponent"
|
|
107
|
+
>
|
|
108
|
+
<div
|
|
109
|
+
class="grow basis shrinkOff"
|
|
110
|
+
data-id="boxComponent"
|
|
111
|
+
data-selector-id="box"
|
|
112
|
+
data-test-id="boxComponent"
|
|
113
|
+
>
|
|
114
|
+
<div
|
|
115
|
+
class="flex cover coldir"
|
|
116
|
+
data-id="containerComponent"
|
|
117
|
+
data-selector-id="container"
|
|
118
|
+
data-test-id="containerComponent"
|
|
119
|
+
>
|
|
120
|
+
<div
|
|
121
|
+
class="menu shrinkOff"
|
|
122
|
+
data-id="boxComponent"
|
|
123
|
+
data-selector-id="tabs_moreIcon"
|
|
124
|
+
data-test-id="boxComponent"
|
|
125
|
+
>
|
|
126
|
+
<button
|
|
127
|
+
aria-label="MoreTabs"
|
|
128
|
+
class="buttonReset flex cover coldir both"
|
|
129
|
+
data-id="moreTabs"
|
|
130
|
+
data-selector-id="container"
|
|
131
|
+
data-test-id="moreTabs"
|
|
132
|
+
role="link"
|
|
133
|
+
>
|
|
134
|
+
<i
|
|
135
|
+
aria-hidden="true"
|
|
136
|
+
class="zd_font_icons basic icon-menu rtl "
|
|
137
|
+
data-id="fontIcon"
|
|
138
|
+
data-selector-id="fontIcon"
|
|
139
|
+
data-test-id="fontIcon"
|
|
140
|
+
style="--zd-iconfont-size: var(--zd_font_size7);"
|
|
141
|
+
/>
|
|
142
|
+
</button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
<div
|
|
149
|
+
class="grow basis shrinkOff"
|
|
150
|
+
data-id="boxComponent"
|
|
151
|
+
data-selector-id="tabContentWrapper"
|
|
152
|
+
data-test-id="boxComponent"
|
|
153
|
+
>
|
|
154
|
+
<div
|
|
155
|
+
aria-labelledby="page1"
|
|
156
|
+
class="container flex cover coldir"
|
|
157
|
+
data-id="tabContent_TabContent"
|
|
158
|
+
data-scroll="true"
|
|
159
|
+
data-selector-id="tabContent"
|
|
160
|
+
data-test-id="tabContent_TabContent"
|
|
161
|
+
role="tabpanel"
|
|
162
|
+
tabindex="-1"
|
|
163
|
+
>
|
|
164
|
+
<div>
|
|
165
|
+
Page 1 Content
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</DocumentFragment>
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
exports[`TabWrapper rendering the align prop of - vertical 1`] = `
|
|
174
|
+
<DocumentFragment>
|
|
175
|
+
<div
|
|
176
|
+
class="flex cover coldir"
|
|
177
|
+
data-id="containerComponent"
|
|
178
|
+
data-selector-id="tabWrapper"
|
|
179
|
+
data-test-id="containerComponent"
|
|
180
|
+
>
|
|
181
|
+
<div
|
|
182
|
+
class="shrinkOff"
|
|
183
|
+
data-id="boxComponent"
|
|
184
|
+
data-selector-id="tabs"
|
|
185
|
+
data-test-id="boxComponent"
|
|
186
|
+
>
|
|
187
|
+
<div
|
|
188
|
+
class="tab alpha alpha_border alpha_padding flex cover rowdir"
|
|
189
|
+
data-id="containerComponent"
|
|
190
|
+
data-selector-id="container"
|
|
191
|
+
data-test-id="containerComponent"
|
|
192
|
+
>
|
|
193
|
+
<div
|
|
194
|
+
class="grow basis shrinkOff"
|
|
195
|
+
data-id="boxComponent"
|
|
196
|
+
data-selector-id="box"
|
|
197
|
+
data-test-id="boxComponent"
|
|
198
|
+
>
|
|
199
|
+
<div
|
|
200
|
+
class="flex cover rowdir"
|
|
201
|
+
data-id="containerComponent"
|
|
202
|
+
data-selector-id="container"
|
|
203
|
+
data-test-id="containerComponent"
|
|
204
|
+
>
|
|
205
|
+
<div
|
|
206
|
+
class="menu shrinkOff"
|
|
207
|
+
data-id="boxComponent"
|
|
208
|
+
data-selector-id="tabs_moreIcon"
|
|
209
|
+
data-test-id="boxComponent"
|
|
210
|
+
>
|
|
211
|
+
<button
|
|
212
|
+
aria-label="MoreTabs"
|
|
213
|
+
class="buttonReset flex cover coldir both"
|
|
214
|
+
data-id="moreTabs"
|
|
215
|
+
data-selector-id="container"
|
|
216
|
+
data-test-id="moreTabs"
|
|
217
|
+
role="link"
|
|
218
|
+
>
|
|
219
|
+
<i
|
|
220
|
+
aria-hidden="true"
|
|
221
|
+
class="zd_font_icons basic icon-menu rtl "
|
|
222
|
+
data-id="fontIcon"
|
|
223
|
+
data-selector-id="fontIcon"
|
|
224
|
+
data-test-id="fontIcon"
|
|
225
|
+
style="--zd-iconfont-size: var(--zd_font_size7);"
|
|
226
|
+
/>
|
|
227
|
+
</button>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
<div
|
|
234
|
+
class="grow basis shrinkOff"
|
|
235
|
+
data-id="boxComponent"
|
|
236
|
+
data-selector-id="tabContentWrapper"
|
|
237
|
+
data-test-id="boxComponent"
|
|
238
|
+
>
|
|
239
|
+
<div
|
|
240
|
+
aria-labelledby="page1"
|
|
241
|
+
class="container flex cover coldir"
|
|
242
|
+
data-id="tabContent_TabContent"
|
|
243
|
+
data-scroll="true"
|
|
244
|
+
data-selector-id="tabContent"
|
|
245
|
+
data-test-id="tabContent_TabContent"
|
|
246
|
+
role="tabpanel"
|
|
247
|
+
tabindex="-1"
|
|
248
|
+
>
|
|
249
|
+
<div>
|
|
250
|
+
Page 1 Content
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</DocumentFragment>
|
|
256
|
+
`;
|
|
257
|
+
|
|
258
|
+
exports[`TabWrapper rendering the align prop of - vertical-reverse 1`] = `
|
|
259
|
+
<DocumentFragment>
|
|
260
|
+
<div
|
|
261
|
+
class="flex cover colReverse"
|
|
262
|
+
data-id="containerComponent"
|
|
263
|
+
data-selector-id="tabWrapper"
|
|
264
|
+
data-test-id="containerComponent"
|
|
265
|
+
>
|
|
266
|
+
<div
|
|
267
|
+
class="shrinkOff"
|
|
268
|
+
data-id="boxComponent"
|
|
269
|
+
data-selector-id="tabs"
|
|
270
|
+
data-test-id="boxComponent"
|
|
271
|
+
>
|
|
272
|
+
<div
|
|
273
|
+
class="tab alpha alpha_border alpha_padding flex cover rowdir"
|
|
274
|
+
data-id="containerComponent"
|
|
275
|
+
data-selector-id="container"
|
|
276
|
+
data-test-id="containerComponent"
|
|
277
|
+
>
|
|
278
|
+
<div
|
|
279
|
+
class="grow basis shrinkOff"
|
|
280
|
+
data-id="boxComponent"
|
|
281
|
+
data-selector-id="box"
|
|
282
|
+
data-test-id="boxComponent"
|
|
283
|
+
>
|
|
284
|
+
<div
|
|
285
|
+
class="flex cover rowdir"
|
|
286
|
+
data-id="containerComponent"
|
|
287
|
+
data-selector-id="container"
|
|
288
|
+
data-test-id="containerComponent"
|
|
289
|
+
>
|
|
290
|
+
<div
|
|
291
|
+
class="menu shrinkOff"
|
|
292
|
+
data-id="boxComponent"
|
|
293
|
+
data-selector-id="tabs_moreIcon"
|
|
294
|
+
data-test-id="boxComponent"
|
|
295
|
+
>
|
|
296
|
+
<button
|
|
297
|
+
aria-label="MoreTabs"
|
|
298
|
+
class="buttonReset flex cover coldir both"
|
|
299
|
+
data-id="moreTabs"
|
|
300
|
+
data-selector-id="container"
|
|
301
|
+
data-test-id="moreTabs"
|
|
302
|
+
role="link"
|
|
303
|
+
>
|
|
304
|
+
<i
|
|
305
|
+
aria-hidden="true"
|
|
306
|
+
class="zd_font_icons basic icon-menu rtl "
|
|
307
|
+
data-id="fontIcon"
|
|
308
|
+
data-selector-id="fontIcon"
|
|
309
|
+
data-test-id="fontIcon"
|
|
310
|
+
style="--zd-iconfont-size: var(--zd_font_size7);"
|
|
311
|
+
/>
|
|
312
|
+
</button>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
<div
|
|
319
|
+
class="grow basis shrinkOff"
|
|
320
|
+
data-id="boxComponent"
|
|
321
|
+
data-selector-id="tabContentWrapper"
|
|
322
|
+
data-test-id="boxComponent"
|
|
323
|
+
>
|
|
324
|
+
<div
|
|
325
|
+
aria-labelledby="page1"
|
|
326
|
+
class="container flex cover coldir"
|
|
327
|
+
data-id="tabContent_TabContent"
|
|
328
|
+
data-scroll="true"
|
|
329
|
+
data-selector-id="tabContent"
|
|
330
|
+
data-test-id="tabContent_TabContent"
|
|
331
|
+
role="tabpanel"
|
|
332
|
+
tabindex="-1"
|
|
333
|
+
>
|
|
334
|
+
<div>
|
|
335
|
+
Page 1 Content
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
</DocumentFragment>
|
|
341
|
+
`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
export const Tab_propTypes = {
|
|
3
3
|
activeClass: PropTypes.string,
|
|
4
|
-
align: PropTypes.
|
|
4
|
+
align: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
5
5
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
|
|
6
6
|
className: PropTypes.string,
|
|
7
7
|
dataId: PropTypes.string,
|
|
@@ -101,7 +101,7 @@ export const Tabs_propTypes = {
|
|
|
101
101
|
targetOffset: PropTypes.object
|
|
102
102
|
};
|
|
103
103
|
export const TabWrapper_propTypes = {
|
|
104
|
-
align: PropTypes.oneOf(['vertical', 'horizontal']),
|
|
104
|
+
align: PropTypes.oneOf(['vertical', 'horizontal', 'vertical-reverse', 'horizontal-reverse']),
|
|
105
105
|
children: PropTypes.node,
|
|
106
106
|
dataId: PropTypes.string,
|
|
107
107
|
defaultTab: PropTypes.string,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const TAB_ALIGN_MAPPING = {
|
|
2
|
+
vertical: 'column',
|
|
3
|
+
horizontal: 'row',
|
|
4
|
+
'vertical-reverse': 'column-reverse',
|
|
5
|
+
'horizontal-reverse': 'row-reverse'
|
|
6
|
+
};
|
|
7
|
+
export const TAB_DIRECTION_MAPPING = {
|
|
8
|
+
vertical: 'column',
|
|
9
|
+
horizontal: 'row',
|
|
10
|
+
'vertical-reverse': 'column',
|
|
11
|
+
'horizontal-reverse': 'row'
|
|
12
|
+
};
|
|
13
|
+
export const TAB_POPUP_POSITION_MAPPING = {
|
|
14
|
+
vertical: 'bottomLeft',
|
|
15
|
+
horizontal: 'rightTop',
|
|
16
|
+
'vertical-reverse': 'topLeft',
|
|
17
|
+
'horizontal-reverse': 'leftTop'
|
|
18
|
+
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { render, cleanup } from "@testing-library/react";
|
|
3
|
+
import { setGlobalId } from "../../Provider/IdProvider";
|
|
2
4
|
import Tag from "../Tag";
|
|
3
|
-
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
setGlobalId(0);
|
|
7
|
+
});
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
cleanup();
|
|
10
|
+
});
|
|
4
11
|
describe('Tag component', () => {
|
|
5
12
|
const size = ['small', 'medium'];
|
|
6
13
|
const palette = ['default', 'danger', 'secondary', 'pureDotted', 'primaryDotted', 'dark', 'pureDarkDotted', 'darkPrimaryDotted', 'defaultLink'];
|
|
@@ -109,7 +109,8 @@ export default class TextBoxIcon extends React.Component {
|
|
|
109
109
|
isScrollPrevent,
|
|
110
110
|
customProps,
|
|
111
111
|
needInputFocusOnWrapperClick,
|
|
112
|
-
renderRightPlaceholderNode
|
|
112
|
+
renderRightPlaceholderNode,
|
|
113
|
+
renderCustomClearComponent
|
|
113
114
|
} = this.props;
|
|
114
115
|
const {
|
|
115
116
|
isActive
|
|
@@ -167,7 +168,10 @@ export default class TextBoxIcon extends React.Component {
|
|
|
167
168
|
className: `${style.iconContainer} ${customTBoxIcon}`
|
|
168
169
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
169
170
|
alignBox: "row"
|
|
170
|
-
}, value && onClear && value.length > 1 && !isDisabled && !isReadOnly || showClearIcon ?
|
|
171
|
+
}, value && onClear && value.length > 1 && !isDisabled && !isReadOnly || showClearIcon ? typeof renderCustomClearComponent == 'function' ? renderCustomClearComponent({
|
|
172
|
+
clearText,
|
|
173
|
+
handleClear: this.handleClear
|
|
174
|
+
}) : /*#__PURE__*/React.createElement(Box, {
|
|
171
175
|
className: `${btnStyle.buttonReset} ${style.icon}`,
|
|
172
176
|
onClick: this.handleClear,
|
|
173
177
|
dataId: `${dataId}_ClearIcon`,
|
|
@@ -50,5 +50,6 @@ export const propTypes = { ...TextBox_propTypes,
|
|
|
50
50
|
customProps: PropTypes.shape({
|
|
51
51
|
TextBoxProps: PropTypes.object
|
|
52
52
|
}),
|
|
53
|
-
renderRightPlaceholderNode: PropTypes.node
|
|
53
|
+
renderRightPlaceholderNode: PropTypes.node,
|
|
54
|
+
renderCustomClearComponent: PropTypes.func
|
|
54
55
|
};
|
package/es/utils/Common.js
CHANGED
|
@@ -7,7 +7,7 @@ export const cs = classArr => classArr.filter(name => name).join(' ');
|
|
|
7
7
|
export const parseDecimal = val => val ? parseFloat(val) : 0;
|
|
8
8
|
export const getTotalDimension = (elem, align) => {
|
|
9
9
|
const style = window.getComputedStyle(elem);
|
|
10
|
-
return align === 'vertical' ? elem.offsetWidth + parseDecimal(style.marginLeft) + parseDecimal(style.marginRight) : elem.offsetHeight + parseDecimal(style.marginTop) + parseDecimal(style.marginBottom);
|
|
10
|
+
return align === 'vertical-reverse' || align === 'vertical' ? elem.offsetWidth + parseDecimal(style.marginLeft) + parseDecimal(style.marginRight) : elem.offsetHeight + parseDecimal(style.marginTop) + parseDecimal(style.marginBottom);
|
|
11
11
|
};
|
|
12
12
|
export function stopPropagation(e) {
|
|
13
13
|
e && e.stopPropagation && e.stopPropagation();
|
|
@@ -6,8 +6,15 @@ var _Button = _interopRequireDefault(require("../Button"));
|
|
|
6
6
|
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
|
|
9
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
+
|
|
11
|
+
require("@testing-library/jest-dom");
|
|
12
|
+
|
|
9
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
14
|
|
|
15
|
+
afterEach(function () {
|
|
16
|
+
(0, _react2.cleanup)();
|
|
17
|
+
});
|
|
11
18
|
describe('Button component', function () {
|
|
12
19
|
test('Should be render with the basic set of default props', function () {
|
|
13
20
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], null)),
|
|
@@ -113,4 +120,137 @@ describe('Button component', function () {
|
|
|
113
120
|
// const { asFragment } = render(<Button customStyle={{$medium: "buttonMedium"}} />);
|
|
114
121
|
// expect(asFragment()).toMatchSnapshot();
|
|
115
122
|
// });
|
|
123
|
+
});
|
|
124
|
+
describe('Button - Unit Testing', function () {
|
|
125
|
+
test('Should render with text prop', function () {
|
|
126
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
127
|
+
text: "Click Me"
|
|
128
|
+
})),
|
|
129
|
+
getByText = _render12.getByText;
|
|
130
|
+
|
|
131
|
+
expect(getByText('Click Me')).toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
test('Should render with children prop', function () {
|
|
134
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], null, "Click Me")),
|
|
135
|
+
getByText = _render13.getByText;
|
|
136
|
+
|
|
137
|
+
expect(getByText('Click Me')).toBeInTheDocument();
|
|
138
|
+
});
|
|
139
|
+
test('Should apply custom styles from customStyle prop', function () {
|
|
140
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
141
|
+
customStyle: {
|
|
142
|
+
bold: 'customBoldClass'
|
|
143
|
+
}
|
|
144
|
+
})),
|
|
145
|
+
getByRole = _render14.getByRole; // expect(getByRole('button').getAttribute('class')).toContain('customBoldClass');
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
expect(getByRole('button')).toHaveClass('customBoldClass');
|
|
149
|
+
});
|
|
150
|
+
test('Should apply custom classes from customClass prop', function () {
|
|
151
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
152
|
+
customClass: {
|
|
153
|
+
customButton: 'customButtonClass'
|
|
154
|
+
}
|
|
155
|
+
})),
|
|
156
|
+
getByRole = _render15.getByRole;
|
|
157
|
+
|
|
158
|
+
expect(getByRole('button')).toHaveClass('customButtonClass');
|
|
159
|
+
});
|
|
160
|
+
test('Should be disabled when disabled prop is true', function () {
|
|
161
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
162
|
+
disabled: true
|
|
163
|
+
})),
|
|
164
|
+
getByRole = _render16.getByRole;
|
|
165
|
+
|
|
166
|
+
expect(getByRole('button')).toBeDisabled();
|
|
167
|
+
});
|
|
168
|
+
test('Should expose element with getRef prop', function () {
|
|
169
|
+
var getRef = jest.fn();
|
|
170
|
+
|
|
171
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
172
|
+
getRef: getRef
|
|
173
|
+
})),
|
|
174
|
+
getByRole = _render17.getByRole;
|
|
175
|
+
|
|
176
|
+
expect(getRef).toHaveBeenCalledWith(getByRole('button'));
|
|
177
|
+
});
|
|
178
|
+
test('Should trigger onClick function', function () {
|
|
179
|
+
var onClick = jest.fn();
|
|
180
|
+
|
|
181
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
182
|
+
onClick: onClick
|
|
183
|
+
})),
|
|
184
|
+
getByRole = _render18.getByRole; // fireEvent.click(getByRole('button'));
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
_userEvent["default"].click(getByRole('button'));
|
|
188
|
+
|
|
189
|
+
expect(onClick).toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
test('Should not trigger onClick when disabled', function () {
|
|
192
|
+
var onClick = jest.fn();
|
|
193
|
+
|
|
194
|
+
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
195
|
+
disabled: true,
|
|
196
|
+
onClick: onClick
|
|
197
|
+
})),
|
|
198
|
+
getByRole = _render19.getByRole;
|
|
199
|
+
|
|
200
|
+
_userEvent["default"].click(getByRole('button'));
|
|
201
|
+
|
|
202
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
203
|
+
});
|
|
204
|
+
test('Should render with correct data-id attribute', function () {
|
|
205
|
+
var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
206
|
+
dataId: "testButton"
|
|
207
|
+
})),
|
|
208
|
+
getByRole = _render20.getByRole;
|
|
209
|
+
|
|
210
|
+
expect(getByRole('button')).toHaveAttribute('data-id', 'testButton');
|
|
211
|
+
});
|
|
212
|
+
test('Should render with correct data-selector-id attribute', function () {
|
|
213
|
+
var _render21 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
214
|
+
dataSelectorId: "testSelector"
|
|
215
|
+
})),
|
|
216
|
+
getByRole = _render21.getByRole;
|
|
217
|
+
|
|
218
|
+
expect(getByRole('button')).toHaveAttribute('data-selector-id', 'testSelector');
|
|
219
|
+
});
|
|
220
|
+
test('Should render with correct title attribute', function () {
|
|
221
|
+
var _render22 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
222
|
+
title: "Test Title"
|
|
223
|
+
})),
|
|
224
|
+
getByRole = _render22.getByRole;
|
|
225
|
+
|
|
226
|
+
expect(getByRole('button')).toHaveAttribute('data-title', 'Test Title');
|
|
227
|
+
});
|
|
228
|
+
test('Should render with correct id attribute', function () {
|
|
229
|
+
var _render23 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
230
|
+
id: "buttonElement"
|
|
231
|
+
})),
|
|
232
|
+
getByRole = _render23.getByRole;
|
|
233
|
+
|
|
234
|
+
expect(getByRole('button')).toHaveAttribute('id', 'buttonElement');
|
|
235
|
+
});
|
|
236
|
+
test('Should apply a11y props correctly', function () {
|
|
237
|
+
var _render24 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
238
|
+
a11y: {
|
|
239
|
+
'aria-label': 'test'
|
|
240
|
+
}
|
|
241
|
+
})),
|
|
242
|
+
getByRole = _render24.getByRole;
|
|
243
|
+
|
|
244
|
+
expect(getByRole('button')).toHaveAttribute('aria-label', 'test');
|
|
245
|
+
});
|
|
246
|
+
test('Should apply customProps correctly', function () {
|
|
247
|
+
var _render25 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
248
|
+
customProps: {
|
|
249
|
+
'data-custom-attr': 'true'
|
|
250
|
+
}
|
|
251
|
+
})),
|
|
252
|
+
getByRole = _render25.getByRole;
|
|
253
|
+
|
|
254
|
+
expect(getByRole('button')).toHaveAttribute('data-custom-attr', 'true');
|
|
255
|
+
});
|
|
116
256
|
});
|
|
@@ -11,8 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
11
11
|
describe('YearView', function () {
|
|
12
12
|
test('rendering the defult props', function () {
|
|
13
13
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_YearView["default"], null)),
|
|
14
|
-
asFragment = _render.asFragment;
|
|
14
|
+
asFragment = _render.asFragment; // expect(asFragment()).toMatchSnapshot();
|
|
15
15
|
|
|
16
|
-
expect(asFragment()).toMatchSnapshot();
|
|
17
16
|
});
|
|
18
17
|
});
|
|
@@ -963,7 +963,10 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
963
963
|
isPopupOpen = _this$props14.isPopupOpen,
|
|
964
964
|
ariaErrorId = _this$props14.ariaErrorId,
|
|
965
965
|
customProps = _this$props14.customProps,
|
|
966
|
-
isFocus = _this$props14.isFocus
|
|
966
|
+
isFocus = _this$props14.isFocus,
|
|
967
|
+
isPopupReady = _this$props14.isPopupReady,
|
|
968
|
+
renderCustomClearComponent = _this$props14.renderCustomClearComponent,
|
|
969
|
+
renderCustomToggleIndicator = _this$props14.renderCustomToggleIndicator;
|
|
967
970
|
var _this$state8 = this.state,
|
|
968
971
|
isActive = _this$state8.isActive,
|
|
969
972
|
selectedOptions = _this$state8.selectedOptions,
|
|
@@ -1039,14 +1042,24 @@ var MultiSelectComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
1039
1042
|
ariaDescribedby: ariaErrorId,
|
|
1040
1043
|
ariaLabelledby: ariaLabelledby
|
|
1041
1044
|
},
|
|
1042
|
-
autoComplete: autoComplete
|
|
1045
|
+
autoComplete: autoComplete,
|
|
1046
|
+
renderRightPlaceholderNode: typeof renderCustomToggleIndicator == 'function' ? renderCustomToggleIndicator({
|
|
1047
|
+
togglePopup: this.togglePopup,
|
|
1048
|
+
isPopupOpened: isPopupReady,
|
|
1049
|
+
isReadOnly: isReadOnly,
|
|
1050
|
+
isDisabled: isDisabled
|
|
1051
|
+
}) : renderCustomToggleIndicator
|
|
1043
1052
|
}, TextBoxIconProps), /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
1044
1053
|
isInline: true,
|
|
1045
1054
|
isCover: false,
|
|
1046
1055
|
alignBox: "row",
|
|
1047
1056
|
align: "vertical",
|
|
1048
1057
|
className: _MultiSelectModule["default"].rightPlaceholder
|
|
1049
|
-
}, isShowClearIcon ?
|
|
1058
|
+
}, isShowClearIcon ? typeof renderCustomClearComponent === 'function' ? renderCustomClearComponent({
|
|
1059
|
+
clearText: clearText,
|
|
1060
|
+
isPopupOpened: isPopupReady,
|
|
1061
|
+
handleClearAll: this.handleDeselectAll
|
|
1062
|
+
}) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
1050
1063
|
className: "".concat(_MultiSelectModule["default"]["delete"], " ").concat(_MultiSelectModule["default"]["".concat(palette, "Delete")]),
|
|
1051
1064
|
dataId: "".concat(dataId, "_clearIcon"),
|
|
1052
1065
|
"data-title": clearText,
|
|
@@ -4,10 +4,18 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
4
4
|
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
6
|
|
|
7
|
+
var _IdProvider = require("../../Provider/IdProvider");
|
|
8
|
+
|
|
7
9
|
var _AdvancedMultiSelect = _interopRequireDefault(require("../AdvancedMultiSelect"));
|
|
8
10
|
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
12
|
|
|
13
|
+
beforeEach(function () {
|
|
14
|
+
(0, _IdProvider.setGlobalId)(0);
|
|
15
|
+
});
|
|
16
|
+
afterEach(function () {
|
|
17
|
+
(0, _react2.cleanup)();
|
|
18
|
+
});
|
|
11
19
|
describe('AdvancedMultiSelect', function () {
|
|
12
20
|
test('rendering the defult props', function () {
|
|
13
21
|
var mockOnChange = jest.fn();
|
|
@@ -133,7 +133,9 @@ var MultiSelect_propTypes = {
|
|
|
133
133
|
TextBoxIconProps: _propTypes["default"].object
|
|
134
134
|
}),
|
|
135
135
|
isFocus: _propTypes["default"].bool,
|
|
136
|
-
allowValueFallback: _propTypes["default"].bool
|
|
136
|
+
allowValueFallback: _propTypes["default"].bool,
|
|
137
|
+
renderCustomClearComponent: _propTypes["default"].func,
|
|
138
|
+
renderCustomToggleIndicator: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].node])
|
|
137
139
|
};
|
|
138
140
|
exports.MultiSelect_propTypes = MultiSelect_propTypes;
|
|
139
141
|
var MultiSelectHeader_propTypes = {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getUniqueId = getUniqueId;
|
|
7
7
|
exports.removeGlobalIdPrefix = removeGlobalIdPrefix;
|
|
8
|
+
exports.setGlobalId = setGlobalId;
|
|
8
9
|
exports.setGlobalIdPrefix = setGlobalIdPrefix;
|
|
9
10
|
exports.useUniqueId = useUniqueId;
|
|
10
11
|
|