@eturnity/eturnity_reusable_components 9.37.3-ATE-87.2 → 9.37.3
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/dist/index.es3.js
CHANGED
|
@@ -815,8 +815,8 @@ const theme = (() => {
|
|
|
815
815
|
iconBackgroundColor: semanticColors.buttonIcon.overlayWhite10
|
|
816
816
|
},
|
|
817
817
|
disabled: {
|
|
818
|
-
textColor: semanticColors.
|
|
819
|
-
backgroundColor:
|
|
818
|
+
textColor: semanticColors.grey[800],
|
|
819
|
+
backgroundColor: semanticColors.transparentTeal[100],
|
|
820
820
|
borderColor: "",
|
|
821
821
|
iconBackgroundColor: semanticColors.buttonIcon.none
|
|
822
822
|
}
|
|
@@ -843,7 +843,7 @@ const theme = (() => {
|
|
|
843
843
|
},
|
|
844
844
|
disabled: {
|
|
845
845
|
backgroundColor: "transparent",
|
|
846
|
-
textColor: semanticColors.
|
|
846
|
+
textColor: semanticColors.transparentRed[500],
|
|
847
847
|
borderColor: "",
|
|
848
848
|
iconBackgroundColor: semanticColors.buttonIcon.none
|
|
849
849
|
}
|
package/package.json
CHANGED
package/src/assets/theme.js
CHANGED
|
@@ -816,8 +816,8 @@ const theme = (() => {
|
|
|
816
816
|
iconBackgroundColor: semanticColors.buttonIcon.overlayWhite10,
|
|
817
817
|
},
|
|
818
818
|
disabled: {
|
|
819
|
-
textColor: semanticColors.
|
|
820
|
-
backgroundColor:
|
|
819
|
+
textColor: semanticColors.grey[800],
|
|
820
|
+
backgroundColor: semanticColors.transparentTeal[100],
|
|
821
821
|
borderColor: '',
|
|
822
822
|
iconBackgroundColor: semanticColors.buttonIcon.none,
|
|
823
823
|
},
|
|
@@ -844,7 +844,7 @@ const theme = (() => {
|
|
|
844
844
|
},
|
|
845
845
|
disabled: {
|
|
846
846
|
backgroundColor: 'transparent',
|
|
847
|
-
textColor: semanticColors.
|
|
847
|
+
textColor: semanticColors.transparentRed[500],
|
|
848
848
|
borderColor: '',
|
|
849
849
|
iconBackgroundColor: semanticColors.buttonIcon.none,
|
|
850
850
|
},
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
<TitleContainer>
|
|
6
6
|
<BoxTitle> {{ numberSelected }} {{ selectedText }} </BoxTitle>
|
|
7
7
|
<IconContainer @click="$emit('on-close')">
|
|
8
|
-
<Icon
|
|
9
|
-
:color="theme.semanticColors.red[500]"
|
|
10
|
-
cursor="pointer"
|
|
11
|
-
name="close"
|
|
12
|
-
size="14px"
|
|
13
|
-
/>
|
|
8
|
+
<Icon color="white" cursor="pointer" name="close" size="14px" />
|
|
14
9
|
</IconContainer>
|
|
15
10
|
</TitleContainer>
|
|
16
11
|
<DividerContainer>
|
|
@@ -20,18 +15,17 @@
|
|
|
20
15
|
<ExpandedListItem
|
|
21
16
|
v-for="item in expandedOptions"
|
|
22
17
|
:key="item.type"
|
|
23
|
-
data-test-id="expanded_option"
|
|
24
18
|
:disabled="item.disabled || false"
|
|
25
19
|
:has-component="!!item?.component"
|
|
26
|
-
:
|
|
20
|
+
:hover-color="item.hoverColor"
|
|
27
21
|
@click="
|
|
28
22
|
!item?.component && !item.disabled && $emit('on-' + item.type)
|
|
29
23
|
"
|
|
30
24
|
>
|
|
31
25
|
<ListItemWrapper
|
|
32
26
|
v-if="item?.component"
|
|
33
|
-
data-test-id="expanded_list_item"
|
|
34
27
|
:has-component="!!item?.component"
|
|
28
|
+
test-data-id="expanded_list_item"
|
|
35
29
|
@click="!item.disabled && toggleElement(item.type)"
|
|
36
30
|
>
|
|
37
31
|
<ListItemTitle>
|
|
@@ -44,6 +38,7 @@
|
|
|
44
38
|
<Icon
|
|
45
39
|
:color="theme.colors.white"
|
|
46
40
|
:cursor="item.disabled ? 'not-allowed' : 'pointer'"
|
|
41
|
+
:hovered-color="theme.colors.white"
|
|
47
42
|
name="arrow_right"
|
|
48
43
|
size="20px"
|
|
49
44
|
/>
|
|
@@ -65,44 +60,42 @@
|
|
|
65
60
|
<SelectedContainer>
|
|
66
61
|
{{ numberSelected }} {{ selectedText }}
|
|
67
62
|
</SelectedContainer>
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<
|
|
95
|
-
{{ noBulkActionsText }}
|
|
96
|
-
</EmptyText>
|
|
97
|
-
<IconContainer data-test-id="close_button" @click="$emit('on-close')">
|
|
63
|
+
<ListContainer v-if="optionsList.length">
|
|
64
|
+
<ListItem
|
|
65
|
+
v-for="item in limitedOptions"
|
|
66
|
+
:key="item.type"
|
|
67
|
+
:disabled="item.disabled || false"
|
|
68
|
+
:hover-color="item.hoverColor"
|
|
69
|
+
@click="$emit('on-' + item.type)"
|
|
70
|
+
>
|
|
71
|
+
{{ item.name }}
|
|
72
|
+
</ListItem>
|
|
73
|
+
<IconContainer
|
|
74
|
+
v-if="optionsList.length > optionLimit || hasComponent"
|
|
75
|
+
test-data-id="more_actions_button_wrapper"
|
|
76
|
+
@click="expandOptions"
|
|
77
|
+
>
|
|
78
|
+
<ButtonContainer name="more_options,_tool_tips">
|
|
79
|
+
<DotItem />
|
|
80
|
+
<DotItem />
|
|
81
|
+
<DotItem />
|
|
82
|
+
</ButtonContainer>
|
|
83
|
+
</IconContainer>
|
|
84
|
+
</ListContainer>
|
|
85
|
+
<EmptyText v-else test-data-id="no_bulk_actions">
|
|
86
|
+
{{ noBulkActionsText }}
|
|
87
|
+
</EmptyText>
|
|
88
|
+
<CloseContainer>
|
|
89
|
+
<IconContainer @click="$emit('on-close')">
|
|
98
90
|
<Icon
|
|
99
|
-
:color="theme.
|
|
91
|
+
:color="theme.colors.white"
|
|
100
92
|
cursor="pointer"
|
|
93
|
+
:hovered-color="theme.colors.white"
|
|
101
94
|
name="close"
|
|
102
95
|
size="14px"
|
|
103
96
|
/>
|
|
104
97
|
</IconContainer>
|
|
105
|
-
</
|
|
98
|
+
</CloseContainer>
|
|
106
99
|
</BoxContainer>
|
|
107
100
|
</PageContainer>
|
|
108
101
|
</PageWrapper>
|
|
@@ -125,8 +118,7 @@
|
|
|
125
118
|
// {
|
|
126
119
|
// type: 'delete',
|
|
127
120
|
// name: 'Delete',
|
|
128
|
-
//
|
|
129
|
-
// dataId: 'button_bulk_delete'
|
|
121
|
+
// hoverColor: 'red' // default is green
|
|
130
122
|
// }
|
|
131
123
|
// ]
|
|
132
124
|
// @on-${type}="function" should $emit the callback for the 'type' in the optionsList
|
|
@@ -145,7 +137,6 @@
|
|
|
145
137
|
// </SelectedOptions>
|
|
146
138
|
import styled from 'vue3-styled-components'
|
|
147
139
|
import InfoText from '../infoText'
|
|
148
|
-
import RCMainButton from '../buttons/mainButton'
|
|
149
140
|
import Icon from '../icon'
|
|
150
141
|
import theme from '../../assets/theme'
|
|
151
142
|
|
|
@@ -158,7 +149,7 @@
|
|
|
158
149
|
`
|
|
159
150
|
|
|
160
151
|
const Divider = styled.div`
|
|
161
|
-
border-bottom: 1px solid
|
|
152
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
|
162
153
|
width: 95%;
|
|
163
154
|
margin: 0 auto;
|
|
164
155
|
`
|
|
@@ -168,6 +159,7 @@
|
|
|
168
159
|
bottom: 30px;
|
|
169
160
|
left: 50%;
|
|
170
161
|
width: auto;
|
|
162
|
+
max-width: 70%;
|
|
171
163
|
transform: translateX(-50%);
|
|
172
164
|
z-index: 999;
|
|
173
165
|
`
|
|
@@ -178,12 +170,13 @@
|
|
|
178
170
|
left: 50%;
|
|
179
171
|
transform: translate(-50%, -50%);
|
|
180
172
|
border-radius: 4px;
|
|
173
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
181
174
|
`
|
|
182
175
|
|
|
183
176
|
const OptionsContainer = styled.div`
|
|
184
177
|
position: absolute;
|
|
185
178
|
left: 101%;
|
|
186
|
-
background-color: ${(props) => props.theme.colors.
|
|
179
|
+
background-color: ${(props) => props.theme.colors.black};
|
|
187
180
|
border-radius: 4px;
|
|
188
181
|
padding: 15px;
|
|
189
182
|
`
|
|
@@ -192,9 +185,9 @@
|
|
|
192
185
|
display: grid;
|
|
193
186
|
align-items: center;
|
|
194
187
|
height: 100%;
|
|
195
|
-
padding:
|
|
188
|
+
padding-right: 20px;
|
|
196
189
|
white-space: nowrap;
|
|
197
|
-
border-right: 1px solid
|
|
190
|
+
border-right: 1px solid rgba(255, 255, 255, 0.2);
|
|
198
191
|
`
|
|
199
192
|
|
|
200
193
|
const TitleContainer = styled.div`
|
|
@@ -217,11 +210,13 @@
|
|
|
217
210
|
const BoxContainer = styled.div`
|
|
218
211
|
display: flex;
|
|
219
212
|
align-items: center;
|
|
220
|
-
background-color: ${(props) => props.theme.colors.
|
|
213
|
+
background-color: ${(props) => props.theme.colors.black};
|
|
214
|
+
opacity: 90%;
|
|
221
215
|
color: ${(props) => props.theme.colors.white};
|
|
222
216
|
border-radius: 4px;
|
|
223
|
-
|
|
224
|
-
|
|
217
|
+
padding: 0px 10px 0px 20px;
|
|
218
|
+
font-size: 13px;
|
|
219
|
+
height: 45px;
|
|
225
220
|
`
|
|
226
221
|
|
|
227
222
|
const CenterBox = styled(BoxContainer)`
|
|
@@ -244,10 +239,14 @@
|
|
|
244
239
|
|
|
245
240
|
div {
|
|
246
241
|
// This is the dot color
|
|
247
|
-
background: ${(props) => props.theme.
|
|
242
|
+
background: ${(props) => props.theme.colors.white};
|
|
248
243
|
}
|
|
249
244
|
`
|
|
250
245
|
|
|
246
|
+
const CloseContainer = styled.div`
|
|
247
|
+
margin-left: 20px;
|
|
248
|
+
`
|
|
249
|
+
|
|
251
250
|
const DotItem = styled.div`
|
|
252
251
|
width: 4px;
|
|
253
252
|
height: 4px;
|
|
@@ -255,15 +254,38 @@
|
|
|
255
254
|
border-radius: 50%;
|
|
256
255
|
`
|
|
257
256
|
|
|
258
|
-
const
|
|
257
|
+
const ListContainer = styled.div`
|
|
259
258
|
height: 100%;
|
|
260
259
|
display: flex;
|
|
261
260
|
align-items: center;
|
|
262
|
-
gap: 8px;
|
|
263
|
-
padding: 0 24px;
|
|
264
261
|
color: ${(props) => props.theme.colors.white};
|
|
265
262
|
`
|
|
266
263
|
|
|
264
|
+
const ListAttrs = {
|
|
265
|
+
disabled: Boolean,
|
|
266
|
+
hoverColor: String,
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const ListItem = styled('div', ListAttrs)`
|
|
270
|
+
width: max-content;
|
|
271
|
+
height: 100%;
|
|
272
|
+
display: flex;
|
|
273
|
+
align-items: center;
|
|
274
|
+
padding: 0 10px;
|
|
275
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
276
|
+
color: ${(props) => props.disabled && props.theme.colors.grey3};
|
|
277
|
+
|
|
278
|
+
&:hover {
|
|
279
|
+
background: rgba(255, 255, 255, 0.1);
|
|
280
|
+
color: ${(props) =>
|
|
281
|
+
props.disabled
|
|
282
|
+
? props.theme.colors.grey3
|
|
283
|
+
: props.hoverColor
|
|
284
|
+
? props.theme.colors[props.hoverColor]
|
|
285
|
+
: props.theme.colors.white};
|
|
286
|
+
}
|
|
287
|
+
`
|
|
288
|
+
|
|
267
289
|
const IconContainer = styled.div`
|
|
268
290
|
display: grid;
|
|
269
291
|
align-items: center;
|
|
@@ -271,9 +293,10 @@
|
|
|
271
293
|
height: 30px;
|
|
272
294
|
width: 30px;
|
|
273
295
|
cursor: pointer;
|
|
296
|
+
margin-left: 8px;
|
|
274
297
|
|
|
275
298
|
&:hover {
|
|
276
|
-
background:
|
|
299
|
+
background: rgba(255, 255, 255, 0.1);
|
|
277
300
|
border-radius: 4px;
|
|
278
301
|
}
|
|
279
302
|
`
|
|
@@ -286,8 +309,8 @@
|
|
|
286
309
|
|
|
287
310
|
const ExpandedListItem = styled('div', {
|
|
288
311
|
disabled: Boolean,
|
|
312
|
+
hoverColor: String,
|
|
289
313
|
hasComponent: Boolean,
|
|
290
|
-
textColor: String,
|
|
291
314
|
})`
|
|
292
315
|
width: 100%;
|
|
293
316
|
display: flex;
|
|
@@ -295,10 +318,12 @@
|
|
|
295
318
|
align-items: center;
|
|
296
319
|
padding: ${(props) => (props.hasComponent ? '0' : '13px 15px')};
|
|
297
320
|
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
298
|
-
color: ${(props) => props.
|
|
321
|
+
color: ${(props) => props.disabled && props.theme.colors.grey3};
|
|
299
322
|
|
|
300
323
|
&:hover {
|
|
301
|
-
background:
|
|
324
|
+
background: rgba(255, 255, 255, 0.1);
|
|
325
|
+
color: ${(props) =>
|
|
326
|
+
props.disabled ? props.theme.colors.grey3 : props.theme.colors.white};
|
|
302
327
|
}
|
|
303
328
|
`
|
|
304
329
|
|
|
@@ -318,7 +343,8 @@
|
|
|
318
343
|
|
|
319
344
|
const EmptyText = styled.div`
|
|
320
345
|
color: ${(props) => props.theme.colors.white};
|
|
321
|
-
font-size:
|
|
346
|
+
font-size: 13px;
|
|
347
|
+
padding-left: 16px;
|
|
322
348
|
`
|
|
323
349
|
|
|
324
350
|
export default {
|
|
@@ -327,10 +353,10 @@
|
|
|
327
353
|
PageContainer,
|
|
328
354
|
BoxContainer,
|
|
329
355
|
SelectedContainer,
|
|
330
|
-
|
|
356
|
+
ListContainer,
|
|
331
357
|
ButtonContainer,
|
|
332
358
|
DotItem,
|
|
333
|
-
|
|
359
|
+
ListItem,
|
|
334
360
|
InfoText,
|
|
335
361
|
CenterBox,
|
|
336
362
|
Icon,
|
|
@@ -347,6 +373,7 @@
|
|
|
347
373
|
Divider,
|
|
348
374
|
DividerContainer,
|
|
349
375
|
ExpandedList,
|
|
376
|
+
CloseContainer,
|
|
350
377
|
},
|
|
351
378
|
props: {
|
|
352
379
|
optionsList: {
|
|
@@ -407,13 +434,6 @@
|
|
|
407
434
|
this.initializeOptions()
|
|
408
435
|
},
|
|
409
436
|
methods: {
|
|
410
|
-
expandedItemColor(item) {
|
|
411
|
-
const ghost = this.theme.mainButton.dark.ghost
|
|
412
|
-
const variant = ghost[item.variant] ?? ghost.main
|
|
413
|
-
const state = item.disabled ? 'disabled' : 'default'
|
|
414
|
-
|
|
415
|
-
return variant[state].textColor
|
|
416
|
-
},
|
|
417
437
|
initializeOptions() {
|
|
418
438
|
this.expandedOptions = [...this.optionsList]
|
|
419
439
|
.map((option, index) => {
|
|
@@ -437,6 +457,17 @@
|
|
|
437
457
|
this.expanded = !this.expanded
|
|
438
458
|
this.expandedOptions = this.optionsList
|
|
439
459
|
},
|
|
460
|
+
handleExpandedOptionClick(item) {
|
|
461
|
+
if (item.disabled) return
|
|
462
|
+
|
|
463
|
+
if (!item.component) {
|
|
464
|
+
this.$emit('on-' + item.type)
|
|
465
|
+
|
|
466
|
+
return
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
this.toggleElement(item.type)
|
|
470
|
+
},
|
|
440
471
|
},
|
|
441
472
|
}
|
|
442
473
|
</script>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import { mount } from '@vue/test-utils'
|
|
3
3
|
import RCSelectedOptions from '@/components/selectedOptions'
|
|
4
|
-
import RCMainButton from '@/components/buttons/mainButton'
|
|
5
|
-
import RCIcon from '@/components/icon/Icon.vue'
|
|
6
4
|
import theme from '@/assets/theme'
|
|
7
5
|
|
|
8
6
|
jest.mock('@/components/icon/iconCache.mjs', () => ({
|
|
@@ -24,7 +22,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
24
22
|
{
|
|
25
23
|
type: 'delete',
|
|
26
24
|
name: 'Delete',
|
|
27
|
-
|
|
25
|
+
hoverColor: 'red',
|
|
28
26
|
},
|
|
29
27
|
],
|
|
30
28
|
}
|
|
@@ -60,7 +58,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
60
58
|
expect(selectedOptions.exists()).toBe(true)
|
|
61
59
|
|
|
62
60
|
const noBulkActions = selectedOptions.find(
|
|
63
|
-
'[data-
|
|
61
|
+
'[test-data-id="no_bulk_actions"]'
|
|
64
62
|
)
|
|
65
63
|
expect(noBulkActions.exists()).toBe(true)
|
|
66
64
|
})
|
|
@@ -80,7 +78,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
80
78
|
|
|
81
79
|
//since we have 2 options, and the limit is 4, we should not see "•••" button
|
|
82
80
|
const moreActionsButton = selectedOptions.find(
|
|
83
|
-
'[data-
|
|
81
|
+
'[test-data-id="more_actions_button_wrapper"]'
|
|
84
82
|
)
|
|
85
83
|
expect(moreActionsButton.exists()).toBe(false)
|
|
86
84
|
})
|
|
@@ -113,7 +111,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
113
111
|
|
|
114
112
|
//since we a component parameter, we should see "•••" button
|
|
115
113
|
const moreActionsButton = selectedOptions.find(
|
|
116
|
-
'[data-
|
|
114
|
+
'[test-data-id="more_actions_button_wrapper"]'
|
|
117
115
|
)
|
|
118
116
|
expect(moreActionsButton.exists()).toBe(true)
|
|
119
117
|
})
|
|
@@ -148,7 +146,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
148
146
|
|
|
149
147
|
//since we a component parameter, we should see "•••" button
|
|
150
148
|
const moreActionsButton = selectedOptions.find(
|
|
151
|
-
'[data-
|
|
149
|
+
'[test-data-id="more_actions_button_wrapper"]'
|
|
152
150
|
)
|
|
153
151
|
expect(moreActionsButton.exists()).toBe(true)
|
|
154
152
|
|
|
@@ -162,7 +160,7 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
162
160
|
|
|
163
161
|
//toggle the element with the component parameter
|
|
164
162
|
const expandedListItems = selectedOptions.findAll(
|
|
165
|
-
'[data-
|
|
163
|
+
'[test-data-id="expanded_list_item"]'
|
|
166
164
|
)
|
|
167
165
|
|
|
168
166
|
//there should be only one since we have only one option with the component parameter
|
|
@@ -175,239 +173,4 @@ describe('RCSelectedOptions.vue', () => {
|
|
|
175
173
|
const setSupplierSlot = wrapper.find('[data-id="set_supplier"]')
|
|
176
174
|
expect(setSupplierSlot.exists()).toBe(true)
|
|
177
175
|
})
|
|
178
|
-
it('renders each collapsed option as a main button', async () => {
|
|
179
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
180
|
-
props: simpleOptionsProps,
|
|
181
|
-
global: {
|
|
182
|
-
provide: {
|
|
183
|
-
theme,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
await wrapper.vm.$nextTick()
|
|
189
|
-
|
|
190
|
-
const optionButtons = wrapper.findAllComponents(RCMainButton)
|
|
191
|
-
expect(optionButtons).toHaveLength(2)
|
|
192
|
-
expect(optionButtons[0].props('text')).toBe('Close')
|
|
193
|
-
expect(optionButtons[1].props('text')).toBe('Delete')
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
it('passes the option data id straight through to the button', async () => {
|
|
197
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
198
|
-
props: {
|
|
199
|
-
...simpleOptionsProps,
|
|
200
|
-
optionsList: [
|
|
201
|
-
{ type: 'delete', name: 'Delete', dataId: 'button_bulk_delete' },
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
global: {
|
|
205
|
-
provide: {
|
|
206
|
-
theme,
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
await wrapper.vm.$nextTick()
|
|
212
|
-
|
|
213
|
-
expect(wrapper.findComponent(RCMainButton).props('dataId')).toBe(
|
|
214
|
-
'button_bulk_delete'
|
|
215
|
-
)
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
it('leaves the button without a data id when the option carries none', async () => {
|
|
219
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
220
|
-
props: simpleOptionsProps,
|
|
221
|
-
global: {
|
|
222
|
-
provide: {
|
|
223
|
-
theme,
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
await wrapper.vm.$nextTick()
|
|
229
|
-
|
|
230
|
-
expect(wrapper.findComponent(RCMainButton).props('dataId')).toBe('')
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
it('passes the option variant straight through to the button', async () => {
|
|
234
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
235
|
-
props: simpleOptionsProps,
|
|
236
|
-
global: {
|
|
237
|
-
provide: {
|
|
238
|
-
theme,
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
await wrapper.vm.$nextTick()
|
|
244
|
-
|
|
245
|
-
const optionButtons = wrapper.findAllComponents(RCMainButton)
|
|
246
|
-
expect(optionButtons[0].props('variant')).toBe('main')
|
|
247
|
-
expect(optionButtons[1].props('variant')).toBe('cancel')
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
it('marks a disabled option as a disabled button and does not emit on click', async () => {
|
|
251
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
252
|
-
props: {
|
|
253
|
-
...simpleOptionsProps,
|
|
254
|
-
optionsList: [
|
|
255
|
-
{
|
|
256
|
-
type: 'delete',
|
|
257
|
-
name: 'Delete',
|
|
258
|
-
disabled: true,
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
},
|
|
262
|
-
global: {
|
|
263
|
-
provide: {
|
|
264
|
-
theme,
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
await wrapper.vm.$nextTick()
|
|
270
|
-
|
|
271
|
-
const deleteButton = wrapper.findComponent(RCMainButton)
|
|
272
|
-
expect(deleteButton.props('isDisabled')).toBe(true)
|
|
273
|
-
|
|
274
|
-
await deleteButton.trigger('click')
|
|
275
|
-
expect(wrapper.emitted('on-delete')).toBeUndefined()
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
it('emits the option event when an enabled option is clicked', async () => {
|
|
279
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
280
|
-
props: simpleOptionsProps,
|
|
281
|
-
global: {
|
|
282
|
-
provide: {
|
|
283
|
-
theme,
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
await wrapper.vm.$nextTick()
|
|
289
|
-
|
|
290
|
-
await wrapper.findAllComponents(RCMainButton)[1].trigger('click')
|
|
291
|
-
expect(wrapper.emitted('on-delete')).toHaveLength(1)
|
|
292
|
-
})
|
|
293
|
-
it('renders the close button and emits on-close even when there are no options', async () => {
|
|
294
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
295
|
-
props: {
|
|
296
|
-
...simpleOptionsProps,
|
|
297
|
-
optionsList: [],
|
|
298
|
-
},
|
|
299
|
-
global: {
|
|
300
|
-
provide: {
|
|
301
|
-
theme,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
await wrapper.vm.$nextTick()
|
|
307
|
-
|
|
308
|
-
const closeButton = wrapper.find('[data-test-id="close_button"]')
|
|
309
|
-
expect(closeButton.exists()).toBe(true)
|
|
310
|
-
|
|
311
|
-
await closeButton.trigger('click')
|
|
312
|
-
expect(wrapper.emitted('on-close')).toHaveLength(1)
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
const expandedItemColors = async (optionsList) => {
|
|
316
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
317
|
-
props: {
|
|
318
|
-
...simpleOptionsProps,
|
|
319
|
-
optionsList,
|
|
320
|
-
},
|
|
321
|
-
global: {
|
|
322
|
-
provide: {
|
|
323
|
-
theme,
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
await wrapper
|
|
329
|
-
.find('[data-test-id="more_actions_button_wrapper"]')
|
|
330
|
-
.trigger('click')
|
|
331
|
-
await wrapper.vm.$nextTick()
|
|
332
|
-
|
|
333
|
-
return wrapper
|
|
334
|
-
.findAllComponents('[data-test-id="expanded_option"]')
|
|
335
|
-
.map((option) => option.props('textColor'))
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
it('styles a cancel option differently from the default options in the expanded list', async () => {
|
|
339
|
-
const [close, archive, remove] = await expandedItemColors([
|
|
340
|
-
{ type: 'close', name: 'Close' },
|
|
341
|
-
{ type: 'archive', name: 'Archive' },
|
|
342
|
-
{ type: 'delete', name: 'Delete', variant: 'cancel' },
|
|
343
|
-
{ type: 'supplier', name: 'Supplier', component: 'set_supplier' },
|
|
344
|
-
])
|
|
345
|
-
|
|
346
|
-
expect(archive).toBe(close)
|
|
347
|
-
expect(remove).not.toBe(close)
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
it('styles disabled options alike whatever the variant in the expanded list', async () => {
|
|
351
|
-
const [close, remove] = await expandedItemColors([
|
|
352
|
-
{ type: 'close', name: 'Close', disabled: true },
|
|
353
|
-
{ type: 'delete', name: 'Delete', variant: 'cancel', disabled: true },
|
|
354
|
-
{ type: 'supplier', name: 'Supplier', component: 'set_supplier' },
|
|
355
|
-
])
|
|
356
|
-
|
|
357
|
-
expect(remove).toBe(close)
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
it('takes expanded option colours from the ghost button theme', async () => {
|
|
361
|
-
const [close, remove, archive, purge] = await expandedItemColors([
|
|
362
|
-
{ type: 'close', name: 'Close' },
|
|
363
|
-
{ type: 'delete', name: 'Delete', variant: 'cancel' },
|
|
364
|
-
{ type: 'archive', name: 'Archive', disabled: true },
|
|
365
|
-
{ type: 'purge', name: 'Purge', variant: 'cancel', disabled: true },
|
|
366
|
-
{ type: 'supplier', name: 'Supplier', component: 'set_supplier' },
|
|
367
|
-
])
|
|
368
|
-
|
|
369
|
-
const ghost = theme.mainButton.dark.ghost
|
|
370
|
-
|
|
371
|
-
expect(close).toBe(ghost.main.default.textColor)
|
|
372
|
-
expect(remove).toBe(ghost.cancel.default.textColor)
|
|
373
|
-
expect(archive).toBe(ghost.main.disabled.textColor)
|
|
374
|
-
expect(purge).toBe(ghost.cancel.disabled.textColor)
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
it('uses the same close colour in the expanded modal as in the collapsed bar', async () => {
|
|
378
|
-
const wrapper = mount(RCSelectedOptions, {
|
|
379
|
-
props: {
|
|
380
|
-
...simpleOptionsProps,
|
|
381
|
-
optionsList: [
|
|
382
|
-
{ type: 'close', name: 'Close' },
|
|
383
|
-
{ type: 'supplier', name: 'Supplier', component: 'set_supplier' },
|
|
384
|
-
],
|
|
385
|
-
},
|
|
386
|
-
global: {
|
|
387
|
-
provide: {
|
|
388
|
-
theme,
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
await wrapper
|
|
394
|
-
.find('[data-test-id="more_actions_button_wrapper"]')
|
|
395
|
-
.trigger('click')
|
|
396
|
-
await wrapper.vm.$nextTick()
|
|
397
|
-
|
|
398
|
-
const closeIcon = wrapper
|
|
399
|
-
.findAllComponents(RCIcon)
|
|
400
|
-
.find((icon) => icon.props('name') === 'close')
|
|
401
|
-
|
|
402
|
-
expect(closeIcon.props('color')).toBe(theme.semanticColors.red[500])
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
it('falls back to the main variant when an option has an unknown variant', async () => {
|
|
406
|
-
const [mystery] = await expandedItemColors([
|
|
407
|
-
{ type: 'mystery', name: 'Mystery', variant: 'not_a_variant' },
|
|
408
|
-
{ type: 'supplier', name: 'Supplier', component: 'set_supplier' },
|
|
409
|
-
])
|
|
410
|
-
|
|
411
|
-
expect(mystery).toBe(theme.mainButton.dark.ghost.main.default.textColor)
|
|
412
|
-
})
|
|
413
176
|
})
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
optionsList: {
|
|
10
10
|
control: 'object',
|
|
11
11
|
description:
|
|
12
|
-
'Array of options to display. Each option should have a type and name, and can optionally have a component, disabled state,
|
|
12
|
+
'Array of options to display. Each option should have a type and name, and can optionally have a component, disabled state, hoverColor, and disabledInfo.',
|
|
13
13
|
},
|
|
14
14
|
numberSelected: {
|
|
15
15
|
control: 'number',
|
|
@@ -49,7 +49,7 @@ Default.args = {
|
|
|
49
49
|
{
|
|
50
50
|
type: 'delete',
|
|
51
51
|
name: 'Delete',
|
|
52
|
-
|
|
52
|
+
hoverColor: 'red',
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
numberSelected: 5,
|
|
@@ -98,7 +98,7 @@ ManyOptions.args = {
|
|
|
98
98
|
{
|
|
99
99
|
type: 'delete',
|
|
100
100
|
name: 'Delete',
|
|
101
|
-
|
|
101
|
+
hoverColor: 'red',
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
type: 'archive',
|
|
@@ -132,7 +132,7 @@ CustomLabels.args = {
|
|
|
132
132
|
{
|
|
133
133
|
type: 'delete',
|
|
134
134
|
name: 'Delete',
|
|
135
|
-
|
|
135
|
+
hoverColor: 'red',
|
|
136
136
|
},
|
|
137
137
|
],
|
|
138
138
|
numberSelected: 1,
|
|
@@ -158,8 +158,7 @@ CustomLabels.args = {
|
|
|
158
158
|
// {
|
|
159
159
|
// type: 'delete',
|
|
160
160
|
// name: 'Delete',
|
|
161
|
-
//
|
|
162
|
-
// dataId: 'button_bulk_delete'
|
|
161
|
+
// hoverColor: 'red' // default is green
|
|
163
162
|
// }
|
|
164
163
|
// ]
|
|
165
164
|
//
|