@eturnity/eturnity_reusable_components 1.2.84 → 1.2.85-EPDM-3013.1
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/package.json +6 -3
- package/postcss.config.js +6 -0
- package/src/components/filter/filterSettings.vue +551 -0
- package/src/components/filter/filterViews.vue +63 -0
- package/src/components/filter/index.vue +132 -0
- package/src/components/filter/parentDropdown.vue +98 -0
- package/src/components/iconWrapper/index.vue +125 -107
- package/src/components/inputs/inputNumber/index.vue +2 -1
- package/src/components/inputs/searchInput/index.vue +20 -10
- package/src/components/inputs/select/index.vue +3 -2
- package/src/components/inputs/select/option/index.vue +57 -48
- package/src/components/tables/mainTable/index.vue +1 -0
- package/src/helpers/translateLang.js +2 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eturnity/eturnity_reusable_components",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.85-EPDM-3013.1",
|
4
4
|
"private": false,
|
5
5
|
"scripts": {
|
6
6
|
"dev": "vue-cli-service serve",
|
@@ -11,10 +11,13 @@
|
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"@vueform/slider": "1.0.5",
|
14
|
+
"html-loader": "0.5.5",
|
15
|
+
"postcss": "^8.4.25",
|
16
|
+
"v-click-outside": "2.1.4",
|
14
17
|
"vue": "2.6.11",
|
15
18
|
"vue-styled-components": "1.6.0",
|
16
|
-
"
|
17
|
-
"
|
19
|
+
"vue2-datepicker": "3.11.1",
|
20
|
+
"vuedraggable": "2.24.3"
|
18
21
|
},
|
19
22
|
"devDependencies": {
|
20
23
|
"@storybook/addon-actions": "6.2.8",
|
@@ -0,0 +1,551 @@
|
|
1
|
+
<template>
|
2
|
+
<container-wrapper>
|
3
|
+
<column-wrapper :numCols="filterData.length">
|
4
|
+
<column-container v-for="(item, idx) in filterData" :key="idx">
|
5
|
+
<column-title :showBorder="idx + 1 !== filterData.length">
|
6
|
+
{{ item.columnName }}
|
7
|
+
</column-title>
|
8
|
+
<row-container v-if="item.type === 'columns'">
|
9
|
+
<checkbox-container>
|
10
|
+
<draggable
|
11
|
+
@change="onDragChange({ data: item.dataOptions })"
|
12
|
+
handle=".drag-container"
|
13
|
+
style="display: contents"
|
14
|
+
ghost-class="ghost"
|
15
|
+
:setData="modifyDragItem"
|
16
|
+
v-model="item.dataOptions"
|
17
|
+
>
|
18
|
+
<checkbox-wrapper
|
19
|
+
v-for="column in item.dataOptions"
|
20
|
+
:key="column.choice"
|
21
|
+
>
|
22
|
+
<drag-container class="drag-container">
|
23
|
+
<icon :name="'duplicate-1'" size="12px" />
|
24
|
+
</drag-container>
|
25
|
+
<checkbox
|
26
|
+
:label="column.text"
|
27
|
+
:isChecked="column.selected"
|
28
|
+
@on-event-handler="
|
29
|
+
onChange({
|
30
|
+
dataType: item.type,
|
31
|
+
value: $event,
|
32
|
+
choice: column.choice
|
33
|
+
})
|
34
|
+
"
|
35
|
+
size="small"
|
36
|
+
:isDisabled="column.selected && isCheckboxDisabled"
|
37
|
+
/>
|
38
|
+
</checkbox-wrapper>
|
39
|
+
</draggable>
|
40
|
+
</checkbox-container>
|
41
|
+
</row-container>
|
42
|
+
<row-container v-if="item.type === 'filter'">
|
43
|
+
<row-wrapper v-for="filter in item.dataOptions" :key="filter.field">
|
44
|
+
<select-component
|
45
|
+
v-if="isMultipleSelector(filter.filter_type)"
|
46
|
+
selectWidth="100%"
|
47
|
+
selectHeight="36px"
|
48
|
+
fontSize="13px"
|
49
|
+
:label="filter.label"
|
50
|
+
alignItems="vertical"
|
51
|
+
:disabled="!filter.choices.length"
|
52
|
+
>
|
53
|
+
<template #selector>
|
54
|
+
<option-title>
|
55
|
+
{{ filter.selectedText }}
|
56
|
+
</option-title>
|
57
|
+
</template>
|
58
|
+
<template #dropdown>
|
59
|
+
<dropdown-checkbox-container @click.stop>
|
60
|
+
<checkbox
|
61
|
+
v-for="filterOption in filter.choices"
|
62
|
+
:key="filterOption.choice"
|
63
|
+
:label="filterOption.text"
|
64
|
+
:isChecked="filterOption.selected"
|
65
|
+
@on-event-handler="
|
66
|
+
onChange({
|
67
|
+
dataType: item.type,
|
68
|
+
value: $event,
|
69
|
+
choice: filterOption.choice,
|
70
|
+
field: filter.field
|
71
|
+
})
|
72
|
+
"
|
73
|
+
size="small"
|
74
|
+
/>
|
75
|
+
</dropdown-checkbox-container>
|
76
|
+
</template>
|
77
|
+
</select-component>
|
78
|
+
<select-component
|
79
|
+
v-else-if="isRangeSelector(filter.filter_type)"
|
80
|
+
selectWidth="100%"
|
81
|
+
selectHeight="36px"
|
82
|
+
fontSize="13px"
|
83
|
+
:label="filter.label"
|
84
|
+
alignItems="vertical"
|
85
|
+
>
|
86
|
+
<template #selector>
|
87
|
+
<option-title>
|
88
|
+
{{ filter.selectedText }}
|
89
|
+
</option-title>
|
90
|
+
</template>
|
91
|
+
<template #dropdown>
|
92
|
+
<dropdown-checkbox-container @click.stop>
|
93
|
+
<input-number
|
94
|
+
:placeholder="settingsTranslations.start"
|
95
|
+
:numberPrecision="0"
|
96
|
+
:value="filter.range.start"
|
97
|
+
@input-change="
|
98
|
+
onChange({
|
99
|
+
dataType: item.type,
|
100
|
+
value: $event,
|
101
|
+
choice: 'start',
|
102
|
+
field: filter.field
|
103
|
+
})
|
104
|
+
"
|
105
|
+
fontSize="13px"
|
106
|
+
:labelText="settingsTranslations.start"
|
107
|
+
/>
|
108
|
+
<input-number
|
109
|
+
:placeholder="settingsTranslations.end"
|
110
|
+
:numberPrecision="0"
|
111
|
+
:value="filter.range.end"
|
112
|
+
@input-change="
|
113
|
+
onChange({
|
114
|
+
dataType: item.type,
|
115
|
+
value: $event,
|
116
|
+
choice: 'end',
|
117
|
+
field: filter.field
|
118
|
+
})
|
119
|
+
"
|
120
|
+
fontSize="13px"
|
121
|
+
:labelText="settingsTranslations.end"
|
122
|
+
/>
|
123
|
+
</dropdown-checkbox-container>
|
124
|
+
</template>
|
125
|
+
</select-component>
|
126
|
+
<calendar-container v-else-if="isDateSelector(filter.filter_type)">
|
127
|
+
<row-label
|
128
|
+
v-if="settingsTranslations && settingsTranslations.start"
|
129
|
+
>{{ settingsTranslations.start }}</row-label
|
130
|
+
>
|
131
|
+
<date-picker-input
|
132
|
+
:placeholder="'-'"
|
133
|
+
:lang="getDatePickerLanguage()"
|
134
|
+
type="date"
|
135
|
+
:value="filter.range.start"
|
136
|
+
@change="
|
137
|
+
onChange({
|
138
|
+
dataType: item.type,
|
139
|
+
value: $event,
|
140
|
+
choice: 'start',
|
141
|
+
field: filter.field
|
142
|
+
})
|
143
|
+
"
|
144
|
+
@focus="onDatepickerFocus(filter.range)"
|
145
|
+
@close="onDatepickerBlur()"
|
146
|
+
format="YYYY-MM-DD"
|
147
|
+
valueType="format"
|
148
|
+
:disabled-date="disableFutureDates"
|
149
|
+
/>
|
150
|
+
<row-label
|
151
|
+
:marginTop="true"
|
152
|
+
v-if="settingsTranslations && settingsTranslations.end"
|
153
|
+
>{{ settingsTranslations.end }}</row-label
|
154
|
+
>
|
155
|
+
<date-picker-input
|
156
|
+
:placeholder="'-'"
|
157
|
+
:lang="getDatePickerLanguage()"
|
158
|
+
type="date"
|
159
|
+
:value="filter.range.end"
|
160
|
+
@change="
|
161
|
+
onChange({
|
162
|
+
dataType: item.type,
|
163
|
+
value: $event,
|
164
|
+
choice: 'end',
|
165
|
+
field: filter.field
|
166
|
+
})
|
167
|
+
"
|
168
|
+
@focus="onDatepickerFocus(filter.range)"
|
169
|
+
@close="onDatepickerBlur()"
|
170
|
+
format="YYYY-MM-DD"
|
171
|
+
valueType="format"
|
172
|
+
:disabled-date="disablePastDates"
|
173
|
+
/>
|
174
|
+
</calendar-container>
|
175
|
+
<select-component
|
176
|
+
v-else
|
177
|
+
selectWidth="100%"
|
178
|
+
selectHeight="36px"
|
179
|
+
fontSize="13px"
|
180
|
+
:label="filter.label"
|
181
|
+
alignItems="vertical"
|
182
|
+
:disabled="!filter.choices.length"
|
183
|
+
>
|
184
|
+
<template #selector="{ selectedValue }">
|
185
|
+
<option-title>
|
186
|
+
{{
|
187
|
+
getSelectedValue({
|
188
|
+
value: selectedValue,
|
189
|
+
options: filter.choices,
|
190
|
+
filter
|
191
|
+
})
|
192
|
+
}}
|
193
|
+
</option-title>
|
194
|
+
</template>
|
195
|
+
<template #dropdown>
|
196
|
+
<Option
|
197
|
+
v-for="filterOption in filter.choices"
|
198
|
+
:key="filterOption.choice"
|
199
|
+
:value="filterOption.choice"
|
200
|
+
>{{ filterOption.text }}</Option
|
201
|
+
>
|
202
|
+
</template>
|
203
|
+
</select-component>
|
204
|
+
</row-wrapper>
|
205
|
+
</row-container>
|
206
|
+
</column-container>
|
207
|
+
</column-wrapper>
|
208
|
+
<button-container>
|
209
|
+
<main-button
|
210
|
+
v-if="buttonText.save_view && hasActiveView"
|
211
|
+
type="primary"
|
212
|
+
:text="buttonText.save_view"
|
213
|
+
@click.native="$emit('on-save-current-view')"
|
214
|
+
/>
|
215
|
+
<main-button
|
216
|
+
type="secondary"
|
217
|
+
v-if="buttonText.save_new_view"
|
218
|
+
:text="buttonText.save_new_view"
|
219
|
+
@click.native="$emit('on-save-new-view')"
|
220
|
+
/>
|
221
|
+
<main-button
|
222
|
+
type="cancel"
|
223
|
+
v-if="buttonText.cancel"
|
224
|
+
:text="buttonText.cancel"
|
225
|
+
@click.native="$emit('on-cancel-view')"
|
226
|
+
/>
|
227
|
+
</button-container>
|
228
|
+
</container-wrapper>
|
229
|
+
</template>
|
230
|
+
|
231
|
+
<script>
|
232
|
+
import styled from 'vue-styled-components'
|
233
|
+
import DatePicker from 'vue2-datepicker'
|
234
|
+
import SelectComponent from '../inputs/select'
|
235
|
+
import Option from '../inputs/select/option'
|
236
|
+
import InputNumber from '../inputs/inputNumber'
|
237
|
+
import MainButton from '../buttons/mainButton'
|
238
|
+
import Checkbox from '../inputs/checkbox'
|
239
|
+
import draggable from 'vuedraggable'
|
240
|
+
import Icon from '../icon'
|
241
|
+
import { datePickerLang } from '../../helpers/translateLang'
|
242
|
+
import 'vue2-datepicker/index.css'
|
243
|
+
import 'vue2-datepicker/locale/de'
|
244
|
+
import 'vue2-datepicker/locale/en'
|
245
|
+
import 'vue2-datepicker/locale/es'
|
246
|
+
import 'vue2-datepicker/locale/fr'
|
247
|
+
import 'vue2-datepicker/locale/it'
|
248
|
+
|
249
|
+
const ContainerWrapper = styled.div`
|
250
|
+
position: absolute;
|
251
|
+
margin-top: 4px;
|
252
|
+
background-color: ${(props) => props.theme.colors.white};
|
253
|
+
min-width: 100%;
|
254
|
+
width: max-content;
|
255
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
256
|
+
border-radius: 4px;
|
257
|
+
z-index: 9999;
|
258
|
+
font-size: 13px;
|
259
|
+
`
|
260
|
+
|
261
|
+
const ColAttrs = { numCols: Number }
|
262
|
+
const ColumnWrapper = styled('div', ColAttrs)`
|
263
|
+
display: grid;
|
264
|
+
grid-template-columns: repeat(${(props) => props.numCols}, auto);
|
265
|
+
`
|
266
|
+
|
267
|
+
const TitleAttrs = { showBorder: Boolean }
|
268
|
+
const ColumnTitle = styled('div', TitleAttrs)`
|
269
|
+
font-size: 14px;
|
270
|
+
font-weight: 700;
|
271
|
+
color: ${(props) => props.theme.colors.eturnityGrey};
|
272
|
+
padding: 14px;
|
273
|
+
border-bottom: 1px solid ${(props) => props.theme.colors.grey4};
|
274
|
+
${({ showBorder, theme }) =>
|
275
|
+
showBorder &&
|
276
|
+
`
|
277
|
+
border-right: 1px solid ${theme.colors.grey4};
|
278
|
+
`}
|
279
|
+
`
|
280
|
+
|
281
|
+
const ButtonContainer = styled.div`
|
282
|
+
display: flex;
|
283
|
+
gap: 10px;
|
284
|
+
padding: 15px;
|
285
|
+
`
|
286
|
+
|
287
|
+
const ColumnContainer = styled.div``
|
288
|
+
|
289
|
+
const DragContainer = styled.div`
|
290
|
+
cursor: grab;
|
291
|
+
|
292
|
+
&:active {
|
293
|
+
cursor: grabbing;
|
294
|
+
}
|
295
|
+
`
|
296
|
+
|
297
|
+
const RowContainer = styled.div`
|
298
|
+
padding: 15px;
|
299
|
+
width: 260px;
|
300
|
+
|
301
|
+
.ghost {
|
302
|
+
opacity: 0.5;
|
303
|
+
background-color: #e5fcb4;
|
304
|
+
}
|
305
|
+
`
|
306
|
+
|
307
|
+
const OptionTitle = styled.div`
|
308
|
+
cursor: pointer !important;
|
309
|
+
`
|
310
|
+
|
311
|
+
const CheckboxContainer = styled.div`
|
312
|
+
display: grid;
|
313
|
+
gap: 6px;
|
314
|
+
`
|
315
|
+
|
316
|
+
const CheckboxWrapper = styled.div`
|
317
|
+
display: grid;
|
318
|
+
grid-template-columns: auto 1fr;
|
319
|
+
gap: 6px;
|
320
|
+
padding: 2px;
|
321
|
+
align-items: center;
|
322
|
+
`
|
323
|
+
|
324
|
+
const DropdownCheckboxContainer = styled.div`
|
325
|
+
display: grid;
|
326
|
+
gap: 6px;
|
327
|
+
width: 100%;
|
328
|
+
padding: 12px 10px;
|
329
|
+
`
|
330
|
+
|
331
|
+
const RowWrapper = styled.div`
|
332
|
+
margin-bottom: 12px;
|
333
|
+
`
|
334
|
+
|
335
|
+
const DatePickerInput = styled(DatePicker)`
|
336
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
337
|
+
border-radius: 4px;
|
338
|
+
padding: 7px 12px 7px 15px;
|
339
|
+
width: 100%;
|
340
|
+
position: relative;
|
341
|
+
|
342
|
+
&.mx-datepicker {
|
343
|
+
width: 100% !important;
|
344
|
+
max-width: 100%;
|
345
|
+
height: 36px;
|
346
|
+
align-self: flex-end;
|
347
|
+
}
|
348
|
+
|
349
|
+
.mx-input-wrapper {
|
350
|
+
position: unset;
|
351
|
+
|
352
|
+
input {
|
353
|
+
border: none;
|
354
|
+
height: auto;
|
355
|
+
padding: 0;
|
356
|
+
font-size: 13px;
|
357
|
+
box-shadow: none;
|
358
|
+
/* font-family: ${(props) => props.theme.fonts.mainFont}; */
|
359
|
+
color: #393939;
|
360
|
+
vertical-align: bottom;
|
361
|
+
}
|
362
|
+
|
363
|
+
.mx-input-append {
|
364
|
+
top: 1px;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
.mx-input-append {
|
369
|
+
left: 0;
|
370
|
+
top: 5px;
|
371
|
+
height: auto;
|
372
|
+
cursor: pointer;
|
373
|
+
}
|
374
|
+
`
|
375
|
+
|
376
|
+
const LabelAttrs = {
|
377
|
+
marginTop: Boolean
|
378
|
+
}
|
379
|
+
const RowLabel = styled('div', LabelAttrs)`
|
380
|
+
font-weight: 700;
|
381
|
+
font-size: 13px;
|
382
|
+
margin-bottom: 8px;
|
383
|
+
margin-top: ${(props) => (props.marginTop ? '12px' : '0')};
|
384
|
+
`
|
385
|
+
|
386
|
+
export default {
|
387
|
+
name: 'filter-settings',
|
388
|
+
components: {
|
389
|
+
ContainerWrapper,
|
390
|
+
ColumnWrapper,
|
391
|
+
ColumnTitle,
|
392
|
+
ColumnContainer,
|
393
|
+
SelectComponent,
|
394
|
+
RowContainer,
|
395
|
+
OptionTitle,
|
396
|
+
Option,
|
397
|
+
ButtonContainer,
|
398
|
+
MainButton,
|
399
|
+
CheckboxContainer,
|
400
|
+
CheckboxWrapper,
|
401
|
+
Checkbox,
|
402
|
+
RowWrapper,
|
403
|
+
DropdownCheckboxContainer,
|
404
|
+
draggable,
|
405
|
+
Icon,
|
406
|
+
DragContainer,
|
407
|
+
InputNumber,
|
408
|
+
DatePickerInput,
|
409
|
+
RowLabel
|
410
|
+
},
|
411
|
+
props: {
|
412
|
+
filterData: {
|
413
|
+
required: true
|
414
|
+
},
|
415
|
+
hasActiveView: {
|
416
|
+
required: false
|
417
|
+
},
|
418
|
+
buttonText: {
|
419
|
+
required: true
|
420
|
+
// example:
|
421
|
+
// {
|
422
|
+
// 'save_new_view': '$gettext("save_new_view")',
|
423
|
+
// 'cancel': '$gettext("cancel")',
|
424
|
+
// 'save_view': '$gettext("save_view")'
|
425
|
+
// }
|
426
|
+
},
|
427
|
+
activeLanguage: {
|
428
|
+
required: false
|
429
|
+
},
|
430
|
+
settingsTranslations: {
|
431
|
+
required: false
|
432
|
+
}
|
433
|
+
},
|
434
|
+
data() {
|
435
|
+
return {
|
436
|
+
selectedDates: null,
|
437
|
+
value1: null,
|
438
|
+
dateStart: null,
|
439
|
+
dateEnd: null
|
440
|
+
}
|
441
|
+
},
|
442
|
+
methods: {
|
443
|
+
onChange({ dataType, value, choice, field }) {
|
444
|
+
if (
|
445
|
+
dataType === 'columns' &&
|
446
|
+
this.isCheckboxDisabled &&
|
447
|
+
value === false
|
448
|
+
) {
|
449
|
+
return
|
450
|
+
}
|
451
|
+
const data = { dataType, value, choice, field }
|
452
|
+
this.$emit('on-filter-change', data)
|
453
|
+
},
|
454
|
+
onDatepickerFocus(range) {
|
455
|
+
this.dateStart = range.start
|
456
|
+
this.dateEnd = range.end
|
457
|
+
this.$emit('on-prevent-close', true)
|
458
|
+
},
|
459
|
+
onDatepickerBlur() {
|
460
|
+
this.$emit('on-prevent-close', false)
|
461
|
+
},
|
462
|
+
disablePastDates(date) {
|
463
|
+
const dateString = this.dateStart
|
464
|
+
if (!dateString) {
|
465
|
+
return
|
466
|
+
}
|
467
|
+
const dateParts = dateString.split('-')
|
468
|
+
|
469
|
+
const year = parseInt(dateParts[0])
|
470
|
+
const month = parseInt(dateParts[1]) - 1 // Subtract 1 since January is month 0
|
471
|
+
const day = parseInt(dateParts[2])
|
472
|
+
|
473
|
+
const currentDate = new Date(year, month, day)
|
474
|
+
const selectedDate = new Date(date)
|
475
|
+
|
476
|
+
// Disable dates that are greater than or equal to the current date
|
477
|
+
return selectedDate <= currentDate
|
478
|
+
},
|
479
|
+
disableFutureDates(date) {
|
480
|
+
const dateString = this.dateEnd
|
481
|
+
if (!dateString) {
|
482
|
+
return
|
483
|
+
}
|
484
|
+
const dateParts = dateString.split('-')
|
485
|
+
|
486
|
+
const year = parseInt(dateParts[0])
|
487
|
+
const month = parseInt(dateParts[1]) - 1 // Subtract 1 since January is month 0
|
488
|
+
const day = parseInt(dateParts[2])
|
489
|
+
|
490
|
+
const currentDate = new Date(year, month, day)
|
491
|
+
const selectedDate = new Date(date)
|
492
|
+
|
493
|
+
// Disable dates that are greater than or equal to the current date
|
494
|
+
return selectedDate >= currentDate
|
495
|
+
},
|
496
|
+
getDatePickerLanguage() {
|
497
|
+
return datePickerLang(this.activeLanguage)
|
498
|
+
},
|
499
|
+
onDragChange({ data }) {
|
500
|
+
this.$emit('on-drag-change', data)
|
501
|
+
},
|
502
|
+
modifyDragItem(dataTransfer) {
|
503
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(
|
504
|
+
navigator.userAgent
|
505
|
+
)
|
506
|
+
// prevents the dragged element from dragging the whole row as a "ghost"
|
507
|
+
// Safari fix because this does not work on Safari
|
508
|
+
let img = new Image()
|
509
|
+
if (!isSafari) {
|
510
|
+
dataTransfer.setDragImage(img, 0, 0)
|
511
|
+
} else {
|
512
|
+
img.src =
|
513
|
+
'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
|
514
|
+
dataTransfer.setDragImage(img, 0, 0)
|
515
|
+
}
|
516
|
+
},
|
517
|
+
getSelectedValue({ value, options, filter }) {
|
518
|
+
const foundItem = options.find((item) => item.choice === value)
|
519
|
+
return foundItem ? foundItem.text : value ? value : filter.selectedText
|
520
|
+
},
|
521
|
+
isMultipleSelector(type) {
|
522
|
+
return type === 'multi_select_integer' || type === 'multi_select_string'
|
523
|
+
},
|
524
|
+
isRangeSelector(type) {
|
525
|
+
return type === 'integer_range'
|
526
|
+
},
|
527
|
+
isDateSelector(type) {
|
528
|
+
return type === 'datetime'
|
529
|
+
}
|
530
|
+
},
|
531
|
+
computed: {
|
532
|
+
isCheckboxDisabled() {
|
533
|
+
// if only 1 item left, disable checkbox
|
534
|
+
let isDisabled = false
|
535
|
+
let columnsData = this.filterData.filter(
|
536
|
+
(item) => item.type === 'columns'
|
537
|
+
)
|
538
|
+
if (columnsData.length) {
|
539
|
+
columnsData = columnsData[0]
|
540
|
+
const filteredColumns = columnsData.dataOptions.filter(
|
541
|
+
(item) => item.selected
|
542
|
+
)
|
543
|
+
if (filteredColumns.length === 1) {
|
544
|
+
isDisabled = true
|
545
|
+
}
|
546
|
+
}
|
547
|
+
return isDisabled
|
548
|
+
}
|
549
|
+
}
|
550
|
+
}
|
551
|
+
</script>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<template>
|
2
|
+
<container-wrapper>
|
3
|
+
<list-item
|
4
|
+
v-for="(item, idx) in filterData"
|
5
|
+
:key="idx"
|
6
|
+
@click="$emit('on-select', item)"
|
7
|
+
>
|
8
|
+
<list-text>{{ item.name }}</list-text>
|
9
|
+
<delete-icon @click.native.stop="$emit('on-delete', item)" />
|
10
|
+
</list-item>
|
11
|
+
</container-wrapper>
|
12
|
+
</template>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
import styled from 'vue-styled-components'
|
16
|
+
import DeleteIcon from '../deleteIcon'
|
17
|
+
|
18
|
+
const ContainerWrapper = styled.div`
|
19
|
+
position: absolute;
|
20
|
+
margin-top: 4px;
|
21
|
+
background-color: ${(props) => props.theme.colors.white};
|
22
|
+
min-width: 100%;
|
23
|
+
width: max-content;
|
24
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
25
|
+
border-radius: 4px;
|
26
|
+
z-index: 9999;
|
27
|
+
font-size: 13px;
|
28
|
+
`
|
29
|
+
|
30
|
+
const ListItem = styled.div`
|
31
|
+
display: grid;
|
32
|
+
grid-template-columns: 1fr auto;
|
33
|
+
align-items: center;
|
34
|
+
padding: 8px 14px;
|
35
|
+
gap: 6px;
|
36
|
+
font-size: 13px;
|
37
|
+
cursor: pointer;
|
38
|
+
|
39
|
+
&:hover {
|
40
|
+
background-color: ${(props) => props.theme.colors.grey5};
|
41
|
+
}
|
42
|
+
`
|
43
|
+
|
44
|
+
const ListText = styled.div``
|
45
|
+
|
46
|
+
export default {
|
47
|
+
name: 'filter-views',
|
48
|
+
components: {
|
49
|
+
ContainerWrapper,
|
50
|
+
ListItem,
|
51
|
+
ListText,
|
52
|
+
DeleteIcon
|
53
|
+
},
|
54
|
+
props: {
|
55
|
+
filterData: {
|
56
|
+
required: false,
|
57
|
+
default: () => {
|
58
|
+
'[]'
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
</script>
|
@@ -0,0 +1,132 @@
|
|
1
|
+
<template>
|
2
|
+
<page-wrapper ref="dropdown">
|
3
|
+
<parent-dropdown
|
4
|
+
@on-toggle="onToggleDropdown()"
|
5
|
+
:isOpen="isDropdownOpen"
|
6
|
+
:dropdownText="activeView ? activeView : 'Default view'"
|
7
|
+
:type="filterType"
|
8
|
+
/>
|
9
|
+
<filter-views
|
10
|
+
v-if="
|
11
|
+
filterType === 'views' &&
|
12
|
+
isDropdownOpen &&
|
13
|
+
filterData &&
|
14
|
+
filterData.length
|
15
|
+
"
|
16
|
+
:filterData="filterData"
|
17
|
+
@on-select="onViewSelect($event)"
|
18
|
+
@on-delete="onViewDelete($event)"
|
19
|
+
/>
|
20
|
+
<filter-settings
|
21
|
+
v-if="filterType === 'settings' && isDropdownOpen"
|
22
|
+
:filterData="filterData"
|
23
|
+
:buttonText="buttonText"
|
24
|
+
@on-save-new-view="$emit('on-save-new-view')"
|
25
|
+
@on-filter-change="onFilterChange($event)"
|
26
|
+
@on-cancel-view="onCancelSettings()"
|
27
|
+
@on-drag-change="$emit('on-drag-change', $event)"
|
28
|
+
@on-save-current-view="onSaveCurrentView()"
|
29
|
+
@on-prevent-close="onPreventClose($event)"
|
30
|
+
:hasActiveView="hasActiveView"
|
31
|
+
:activeLanguage="activeLanguage"
|
32
|
+
:settingsTranslations="settingsTranslations"
|
33
|
+
/>
|
34
|
+
</page-wrapper>
|
35
|
+
</template>
|
36
|
+
|
37
|
+
<script>
|
38
|
+
import styled from 'vue-styled-components'
|
39
|
+
import parentDropdown from './parentDropdown'
|
40
|
+
import filterViews from './filterViews'
|
41
|
+
import filterSettings from './filterSettings'
|
42
|
+
|
43
|
+
const PageWrapper = styled.div`
|
44
|
+
position: relative;
|
45
|
+
`
|
46
|
+
|
47
|
+
export default {
|
48
|
+
name: 'filter-component',
|
49
|
+
components: {
|
50
|
+
parentDropdown,
|
51
|
+
PageWrapper,
|
52
|
+
filterViews,
|
53
|
+
filterSettings
|
54
|
+
},
|
55
|
+
props: {
|
56
|
+
filterType: {
|
57
|
+
required: false,
|
58
|
+
default: 'settings' // 'settings', 'views'
|
59
|
+
},
|
60
|
+
filterData: {
|
61
|
+
required: true
|
62
|
+
},
|
63
|
+
activeView: {
|
64
|
+
required: false,
|
65
|
+
default: null
|
66
|
+
},
|
67
|
+
buttonText: {
|
68
|
+
required: false
|
69
|
+
},
|
70
|
+
hasActiveView: {
|
71
|
+
required: false
|
72
|
+
},
|
73
|
+
activeLanguage: {
|
74
|
+
required: false,
|
75
|
+
default: 'en-us'
|
76
|
+
},
|
77
|
+
settingsTranslations: {
|
78
|
+
required: false
|
79
|
+
}
|
80
|
+
},
|
81
|
+
data() {
|
82
|
+
return {
|
83
|
+
isDropdownOpen: false,
|
84
|
+
activeFilter: null,
|
85
|
+
preventOutsideClick: false
|
86
|
+
}
|
87
|
+
},
|
88
|
+
methods: {
|
89
|
+
onToggleDropdown() {
|
90
|
+
this.isDropdownOpen = !this.isDropdownOpen
|
91
|
+
},
|
92
|
+
clickOutside(event) {
|
93
|
+
if (
|
94
|
+
!this.$refs.dropdown.$el.contains(event.target) &&
|
95
|
+
!this.preventOutsideClick
|
96
|
+
) {
|
97
|
+
this.isDropdownOpen = false
|
98
|
+
}
|
99
|
+
},
|
100
|
+
onPreventClose(value) {
|
101
|
+
setTimeout(() => {
|
102
|
+
this.preventOutsideClick = value
|
103
|
+
}, 100)
|
104
|
+
},
|
105
|
+
onFilterChange(data) {
|
106
|
+
this.$emit('on-filter-settings-change', data)
|
107
|
+
},
|
108
|
+
onCancelSettings() {
|
109
|
+
this.onToggleDropdown()
|
110
|
+
this.$emit('on-cancel-view')
|
111
|
+
},
|
112
|
+
onViewSelect(item) {
|
113
|
+
this.onToggleDropdown()
|
114
|
+
this.$emit('on-filter-view-select', item)
|
115
|
+
},
|
116
|
+
onViewDelete(item) {
|
117
|
+
this.onToggleDropdown()
|
118
|
+
this.$emit('on-filter-view-delete', item)
|
119
|
+
},
|
120
|
+
onSaveCurrentView() {
|
121
|
+
this.onToggleDropdown()
|
122
|
+
this.$emit('on-save-current-view')
|
123
|
+
}
|
124
|
+
},
|
125
|
+
mounted() {
|
126
|
+
document.addEventListener('click', this.clickOutside)
|
127
|
+
},
|
128
|
+
beforeDestroy() {
|
129
|
+
document.removeEventListener('click', this.clickOutside)
|
130
|
+
}
|
131
|
+
}
|
132
|
+
</script>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
<template>
|
2
|
+
<page-wrapper @click="$emit('on-toggle')">
|
3
|
+
<icon-wrapper>
|
4
|
+
<icon
|
5
|
+
:name="type === 'settings' ? 'settings' : 'show_in_a_new_tab'"
|
6
|
+
size="18px"
|
7
|
+
/>
|
8
|
+
</icon-wrapper>
|
9
|
+
<title-wrapper :isOpen="isOpen">
|
10
|
+
<title-text>
|
11
|
+
{{ dropdownText }}
|
12
|
+
</title-text>
|
13
|
+
<arrow-wrapper>
|
14
|
+
<icon
|
15
|
+
@click.native.stop="$emit('on-toggle')"
|
16
|
+
:name="isOpen ? 'arrow_up' : 'arrow_down'"
|
17
|
+
size="12px"
|
18
|
+
/>
|
19
|
+
</arrow-wrapper>
|
20
|
+
</title-wrapper>
|
21
|
+
</page-wrapper>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<script>
|
25
|
+
import styled from 'vue-styled-components'
|
26
|
+
import Icon from '../icon'
|
27
|
+
|
28
|
+
const PageWrapper = styled.div`
|
29
|
+
display: grid;
|
30
|
+
grid-template-columns: auto auto;
|
31
|
+
cursor: pointer;
|
32
|
+
`
|
33
|
+
|
34
|
+
const IconWrapper = styled.div`
|
35
|
+
display: grid;
|
36
|
+
align-items: center;
|
37
|
+
justify-items: center;
|
38
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
39
|
+
border-radius: 4px 0px 0px 4px;
|
40
|
+
padding: 6px;
|
41
|
+
`
|
42
|
+
|
43
|
+
const TitleAttrs = { isOpen: Boolean }
|
44
|
+
const TitleWrapper = styled('div', TitleAttrs)`
|
45
|
+
display: grid;
|
46
|
+
grid-template-columns: auto auto;
|
47
|
+
align-items: center;
|
48
|
+
justify-items: center;
|
49
|
+
grid-gap: 10px;
|
50
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
51
|
+
background-color: ${(props) =>
|
52
|
+
props.isOpen ? props.theme.colors.grey5 : props.theme.colors.white};
|
53
|
+
border-left: none;
|
54
|
+
border-radius: 0px 4px 4px 0px;
|
55
|
+
padding: 6px 14px;
|
56
|
+
user-select: none;
|
57
|
+
`
|
58
|
+
|
59
|
+
const TitleText = styled.div`
|
60
|
+
font-size: 13px;
|
61
|
+
`
|
62
|
+
|
63
|
+
const ArrowWrapper = styled.div`
|
64
|
+
display: grid;
|
65
|
+
align-items: center;
|
66
|
+
|
67
|
+
div {
|
68
|
+
height: auto !important;
|
69
|
+
min-height: unset;
|
70
|
+
}
|
71
|
+
`
|
72
|
+
|
73
|
+
export default {
|
74
|
+
name: 'parent-dropdown',
|
75
|
+
components: {
|
76
|
+
PageWrapper,
|
77
|
+
Icon,
|
78
|
+
IconWrapper,
|
79
|
+
TitleWrapper,
|
80
|
+
TitleText,
|
81
|
+
ArrowWrapper
|
82
|
+
},
|
83
|
+
props: {
|
84
|
+
type: {
|
85
|
+
required: false,
|
86
|
+
default: 'settings' // 'settings', 'views'
|
87
|
+
},
|
88
|
+
isOpen: {
|
89
|
+
required: true,
|
90
|
+
default: false
|
91
|
+
},
|
92
|
+
dropdownText: {
|
93
|
+
required: true,
|
94
|
+
default: 'View'
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
</script>
|
@@ -1,116 +1,134 @@
|
|
1
1
|
<template>
|
2
|
-
|
3
|
-
:disabled="disabled"
|
4
|
-
:size="size"
|
5
|
-
:backgroundColor="backgroundColor"
|
2
|
+
<Wrapper
|
3
|
+
:disabled="disabled"
|
4
|
+
:size="size"
|
5
|
+
:backgroundColor="backgroundColor"
|
6
6
|
:borderRadius="borderRadius"
|
7
7
|
:hoveredBackgroundColor="hoveredBackgroundColor"
|
8
8
|
:isHovered="isHovered"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
9
|
+
>
|
10
|
+
<icon
|
11
|
+
:disabled="disabled"
|
12
|
+
:size="iconSize"
|
13
|
+
:name="name"
|
14
|
+
:color="iconColor"
|
15
|
+
:hoveredColor="hoveredIconColor"
|
16
|
+
/>
|
17
|
+
<caret v-if="hasCaret">
|
18
|
+
<iconWrapper
|
19
|
+
:disabled="disabled"
|
20
|
+
size="10px"
|
21
|
+
name="arrow_down"
|
22
|
+
:iconColor="iconColor"
|
23
|
+
:hoveredBackgroundColor="hoveredIconColor"
|
24
|
+
borderRadius="1px"
|
25
|
+
/>
|
26
|
+
</caret>
|
27
|
+
</Wrapper>
|
28
|
+
</template>
|
29
|
+
|
30
|
+
<script>
|
31
|
+
// import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
|
32
|
+
// How to use:
|
33
|
+
//<icon
|
34
|
+
// name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
|
35
|
+
// color="red"
|
36
|
+
// hoveredColor="blue"
|
37
|
+
// size="60px" by default, this is 30px
|
38
|
+
// />
|
39
|
+
|
40
|
+
import styled from 'vue-styled-components'
|
41
|
+
import icon from '../icon'
|
42
|
+
const wrapperAttrs = {
|
43
|
+
isHovered: Boolean,
|
44
|
+
borderRadius: String,
|
45
|
+
disabled: Boolean,
|
46
|
+
size: String,
|
47
|
+
backgroundColor: String,
|
48
|
+
hoveredBackgroundColor: String
|
49
|
+
}
|
50
|
+
const Wrapper = styled('div', wrapperAttrs)`
|
51
|
+
position: relative;
|
52
|
+
display: inline-flex;
|
53
|
+
width: ${(props) => props.size};
|
54
|
+
height: ${(props) => props.size};
|
55
|
+
justify-content: center;
|
56
|
+
align-items: center;
|
57
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
58
|
+
background-color: ${(props) =>
|
59
|
+
props.theme.colors[props.backgroundColor] || props.backgroundColor};
|
60
|
+
border-radius: ${(props) => props.borderRadius};
|
61
|
+
${(props) =>
|
62
|
+
props.isHovered
|
63
|
+
? 'background-color:' +
|
64
|
+
props.theme.colors[props.hoveredBackgroundColor] ||
|
65
|
+
props.hoveredBackgroundColor
|
66
|
+
: ''};
|
67
|
+
&:hover {
|
68
|
+
background-color: ${(props) =>
|
69
|
+
props.theme.colors[props.hoveredBackgroundColor] ||
|
70
|
+
props.hoveredBackgroundColor};
|
71
|
+
}
|
72
|
+
`
|
73
|
+
const caret = styled.div`
|
74
|
+
position: absolute;
|
75
|
+
bottom: 3px;
|
76
|
+
right: 2px;
|
77
|
+
height: 10px;
|
78
|
+
`
|
61
79
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
80
|
+
export default {
|
81
|
+
name: 'iconWrapper',
|
82
|
+
components: {
|
83
|
+
Wrapper,
|
84
|
+
icon,
|
85
|
+
caret
|
86
|
+
},
|
87
|
+
props: {
|
88
|
+
disabled: {
|
89
|
+
required: false,
|
90
|
+
default: false
|
91
|
+
},
|
92
|
+
name: {
|
93
|
+
required: true
|
94
|
+
},
|
95
|
+
iconColor: {
|
96
|
+
required: false,
|
97
|
+
default: 'white'
|
98
|
+
},
|
99
|
+
hoveredIconColor: {
|
100
|
+
required: false
|
101
|
+
},
|
102
|
+
backgroundColor: {
|
103
|
+
required: false
|
104
|
+
},
|
105
|
+
hoveredBackgroundColor: {
|
106
|
+
required: false,
|
107
|
+
default: 'transparentWhite1'
|
108
|
+
},
|
109
|
+
size: {
|
110
|
+
required: false,
|
111
|
+
default: '32px'
|
112
|
+
},
|
113
|
+
iconSize: {
|
114
|
+
required: false,
|
115
|
+
default: '18px'
|
116
|
+
},
|
117
|
+
hasCaret: {
|
118
|
+
required: false,
|
119
|
+
default: false
|
68
120
|
},
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
default: false
|
73
|
-
},
|
74
|
-
name: {
|
75
|
-
required: true
|
76
|
-
},
|
77
|
-
iconColor: {
|
78
|
-
required: false,
|
79
|
-
default: 'white'
|
80
|
-
},
|
81
|
-
hoveredIconColor: {
|
82
|
-
required: false
|
83
|
-
},
|
84
|
-
backgroundColor: {
|
85
|
-
required: false,
|
86
|
-
},
|
87
|
-
hoveredBackgroundColor: {
|
88
|
-
required: false,
|
89
|
-
default:"transparentWhite1"
|
90
|
-
},
|
91
|
-
size: {
|
92
|
-
required: false,
|
93
|
-
default: '32px'
|
94
|
-
},
|
95
|
-
iconSize:{
|
96
|
-
required: false,
|
97
|
-
default:'18px'
|
98
|
-
},
|
99
|
-
hasCaret:{
|
100
|
-
required: false,
|
101
|
-
default: false
|
102
|
-
},
|
103
|
-
borderRadius:{
|
104
|
-
required:false,
|
105
|
-
default:'6px'
|
106
|
-
},
|
107
|
-
isHovered:{
|
108
|
-
required:false,
|
109
|
-
default:false
|
110
|
-
}
|
121
|
+
borderRadius: {
|
122
|
+
required: false,
|
123
|
+
default: '6px'
|
111
124
|
},
|
112
|
-
|
113
|
-
|
125
|
+
isHovered: {
|
126
|
+
required: false,
|
127
|
+
default: false
|
114
128
|
}
|
129
|
+
},
|
130
|
+
data() {
|
131
|
+
return {}
|
115
132
|
}
|
116
|
-
|
133
|
+
}
|
134
|
+
</script>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<template>
|
2
|
-
<container>
|
2
|
+
<container :inputWidth="inputWidth">
|
3
3
|
<input-wrapper>
|
4
4
|
<input-container
|
5
5
|
ref="inputElement"
|
@@ -9,6 +9,7 @@
|
|
9
9
|
:disabled="disabled"
|
10
10
|
:isDisabled="disabled"
|
11
11
|
:inputWidth="inputWidth"
|
12
|
+
:isFilter="isFilter"
|
12
13
|
:hasFocus="hasFocus"
|
13
14
|
/>
|
14
15
|
<img
|
@@ -28,18 +29,24 @@
|
|
28
29
|
// :disabled="true"
|
29
30
|
// inputWidth="250px"
|
30
31
|
// @on-change="function($event)"
|
32
|
+
// :isFilter="true" // to set the height at 30px
|
31
33
|
// />
|
32
34
|
import styled from 'vue-styled-components'
|
33
35
|
|
34
|
-
const
|
35
|
-
|
36
|
+
const inputAttrs = {
|
37
|
+
isDisabled: Boolean,
|
38
|
+
inputWidth: String,
|
39
|
+
isFilter: Boolean
|
40
|
+
}
|
41
|
+
const Container = styled('div', inputAttrs)`
|
42
|
+
width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
|
36
43
|
position: relative;
|
37
44
|
`
|
38
45
|
|
39
|
-
const inputAttrs = { isDisabled: Boolean, inputWidth: String }
|
40
46
|
const InputContainer = styled('input', inputAttrs)`
|
41
|
-
border: 1px solid ${(props) => props.theme.colors.
|
42
|
-
padding:
|
47
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
48
|
+
padding: ${(props) =>
|
49
|
+
props.isFilter ? '7px 30px 7px 10px' : '11px 30px 11px 10px'};
|
43
50
|
border-radius: 4px;
|
44
51
|
font-size: 13px;
|
45
52
|
color: ${(props) => props.theme.colors.black};
|
@@ -90,6 +97,10 @@ export default {
|
|
90
97
|
required: false,
|
91
98
|
default: null
|
92
99
|
},
|
100
|
+
isFilter: {
|
101
|
+
required: false,
|
102
|
+
default: false
|
103
|
+
},
|
93
104
|
hasFocus: {
|
94
105
|
required: false,
|
95
106
|
default: false
|
@@ -99,10 +110,10 @@ export default {
|
|
99
110
|
onChangeHandler(event) {
|
100
111
|
this.$emit('on-change', event)
|
101
112
|
},
|
102
|
-
focusInputElement(){
|
113
|
+
focusInputElement() {
|
103
114
|
this.$nextTick(() => {
|
104
|
-
this.$refs.inputElement.$el.focus()
|
105
|
-
})
|
115
|
+
this.$refs.inputElement.$el.focus()
|
116
|
+
})
|
106
117
|
}
|
107
118
|
},
|
108
119
|
watch: {
|
@@ -112,6 +123,5 @@ export default {
|
|
112
123
|
}
|
113
124
|
}
|
114
125
|
}
|
115
|
-
|
116
126
|
}
|
117
127
|
</script>
|
@@ -247,8 +247,9 @@ const selectDropdown = styled('div', selectDropdownAttrs)`
|
|
247
247
|
props.theme.colors[props.fontColor]
|
248
248
|
? props.theme.colors[props.fontColor]
|
249
249
|
: props.fontColor};
|
250
|
-
max-height:300px;
|
251
|
-
|
250
|
+
max-height: 300px;
|
251
|
+
min-height: 39px;
|
252
|
+
overflow-y: auto;
|
252
253
|
& [data-value="${(props) => props.selectedValue}"]{
|
253
254
|
backdrop-filter: brightness(1.4);
|
254
255
|
}
|
@@ -1,59 +1,68 @@
|
|
1
1
|
<template>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
<optionContainer
|
3
|
+
:data-value="value"
|
4
|
+
:hoveredBgColor="
|
5
|
+
hoveredBgColor || colorMode == 'dark' ? '#000000' : 'grey5'
|
6
|
+
"
|
7
|
+
@click="clickHandler"
|
8
|
+
@mouseover="hoverHandler"
|
9
|
+
>
|
10
|
+
<slot></slot>
|
11
|
+
</optionContainer>
|
12
|
+
</template>
|
6
13
|
|
7
|
-
|
14
|
+
<script>
|
8
15
|
// import selectButton from './selectButton'
|
9
16
|
// import selectDropdown from './selectDropDown'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
import styled from 'vue-styled-components'
|
18
|
+
const optionProps = { hoveredBgColor: String }
|
19
|
+
const optionContainer = styled('div', optionProps)`
|
20
|
+
display: flex;
|
21
|
+
cursor: pointer;
|
22
|
+
flex-direction: row;
|
23
|
+
justify-content: space-between;
|
24
|
+
align-items: center;
|
25
|
+
padding: 12px 10px;
|
26
|
+
gap: 14px;
|
27
|
+
width: 100%;
|
28
|
+
box-sizing: inherit;
|
29
|
+
&:hover {
|
30
|
+
background-color: ${(props) =>
|
31
|
+
props.theme.colors[props.hoveredBgColor]
|
32
|
+
? props.theme.colors[props.hoveredBgColor]
|
33
|
+
: props.hoveredBgColor};
|
34
|
+
}
|
35
|
+
`
|
26
36
|
|
27
|
-
|
28
|
-
|
37
|
+
export default {
|
38
|
+
name: 'RCoption',
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
},
|
37
|
-
colorMode:{
|
38
|
-
required:false,
|
39
|
-
default:'light'
|
40
|
-
}
|
40
|
+
props: {
|
41
|
+
value: {
|
42
|
+
required: true
|
43
|
+
},
|
44
|
+
hoveredBgColor: {
|
45
|
+
required: false
|
41
46
|
},
|
47
|
+
colorMode: {
|
48
|
+
required: false,
|
49
|
+
default: 'light'
|
50
|
+
}
|
51
|
+
},
|
42
52
|
|
43
|
-
|
53
|
+
components: { optionContainer },
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
},
|
52
|
-
hoverHandler(){
|
53
|
-
this.$parent.$emit('option-hovered',this.value)
|
54
|
-
}
|
55
|
+
data() {
|
56
|
+
return {}
|
57
|
+
},
|
58
|
+
methods: {
|
59
|
+
clickHandler() {
|
60
|
+
this.$parent.$emit('option-selected', this.value)
|
55
61
|
},
|
56
|
-
|
62
|
+
hoverHandler() {
|
63
|
+
this.$parent.$emit('option-hovered', this.value)
|
57
64
|
}
|
58
|
-
}
|
59
|
-
|
65
|
+
},
|
66
|
+
computed: {}
|
67
|
+
}
|
68
|
+
</script>
|