bfg-common 1.4.659 → 1.4.661
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/assets/localization/local_be.json +4 -1
- package/assets/localization/local_en.json +4 -1
- package/assets/localization/local_hy.json +4 -1
- package/assets/localization/local_kk.json +4 -1
- package/assets/localization/local_ru.json +4 -1
- package/assets/localization/local_zh.json +4 -1
- package/components/atoms/table/dataGrid/DataGrid.vue +66 -3
- package/components/atoms/table/dataGrid/lib/config/settingsTable.ts +91 -67
- package/components/atoms/table/dataGrid/lib/utils/export.ts +16 -0
- package/components/common/select/button/ButtonDropdown.vue +108 -102
- package/package.json +1 -1
|
@@ -2281,7 +2281,10 @@
|
|
|
2281
2281
|
"rowsPerPage": "Радкі на старонку",
|
|
2282
2282
|
"unsavedChanges": "Непавераныя змены!",
|
|
2283
2283
|
"unsavedChangesDescription": "Вы ўпэўнены, што хочаце пакінуць гэтую старонку? Непакураны змены будуць страчаны.",
|
|
2284
|
-
"leave": "Пакідаць"
|
|
2284
|
+
"leave": "Пакідаць",
|
|
2285
|
+
"export": "Экспарт",
|
|
2286
|
+
"allRowsCount": "Усе радкі ({0})",
|
|
2287
|
+
"selectedRowsCount": "Выбраныя радкі ({0})"
|
|
2285
2288
|
},
|
|
2286
2289
|
"auth": {
|
|
2287
2290
|
"welcomeTo": "Сардэчна запрашаем у",
|
|
@@ -2285,7 +2285,10 @@
|
|
|
2285
2285
|
"rowsPerPage": "Rows per page",
|
|
2286
2286
|
"unsavedChanges": "Unsaved Changes!",
|
|
2287
2287
|
"unsavedChangesDescription": "Are you sure you want to leave this page? Unsaved changes will be lost.",
|
|
2288
|
-
"leave": "Leave"
|
|
2288
|
+
"leave": "Leave",
|
|
2289
|
+
"export": "Export",
|
|
2290
|
+
"allRowsCount": "All rows ({0})",
|
|
2291
|
+
"selectedRowsCount": "Selected rows ({0})"
|
|
2289
2292
|
},
|
|
2290
2293
|
"auth": {
|
|
2291
2294
|
"welcomeTo": "Welcome to",
|
|
@@ -2285,7 +2285,10 @@
|
|
|
2285
2285
|
"rowsPerPage": "Շարքեր մեկ էջում",
|
|
2286
2286
|
"unsavedChanges": "Չհաստատված փոփոխություններ",
|
|
2287
2287
|
"unsavedChangesDescription": "Համոզված եք, որ ցանկանում եք լքել այս էջը: Չպաշտպանված փոփոխությունները կկորչվեն:",
|
|
2288
|
-
"leave": "Հեռանալ"
|
|
2288
|
+
"leave": "Հեռանալ",
|
|
2289
|
+
"export": "Արտահանում",
|
|
2290
|
+
"allRowsCount": "Բոլոր տողերը ({0})",
|
|
2291
|
+
"selectedRowsCount": "Ընտրված տողերը ({0})"
|
|
2289
2292
|
},
|
|
2290
2293
|
"auth": {
|
|
2291
2294
|
"welcomeTo": "Բարի գալուստ",
|
|
@@ -2284,7 +2284,10 @@
|
|
|
2284
2284
|
"rowsPerPage": "Ағын сызықтары",
|
|
2285
2285
|
"unsavedChanges": "Жетілмеген өзгерістер!",
|
|
2286
2286
|
"unsavedChangesDescription": "Сіз бұл беттен кеткіңіз келе ме? Сақталмаған өзгерістер жоғалады.",
|
|
2287
|
-
"leave": "Тастау"
|
|
2287
|
+
"leave": "Тастау",
|
|
2288
|
+
"export": "Сыртқа шығару",
|
|
2289
|
+
"allRowsCount": "Барлық жолдар ({0})",
|
|
2290
|
+
"selectedRowsCount": "Таңдалған жолдар ({0})"
|
|
2288
2291
|
},
|
|
2289
2292
|
"auth": {
|
|
2290
2293
|
"welcomeTo": "Қош келдіңіз",
|
|
@@ -2286,7 +2286,10 @@
|
|
|
2286
2286
|
"rowsPerPage": "Кол-во строк",
|
|
2287
2287
|
"unsavedChanges": "Несохранённые изменения!",
|
|
2288
2288
|
"unsavedChangesDescription": "Вы уверены, что хотите покинуть эту страницу? Неиседлкие изменения будут потеряны.",
|
|
2289
|
-
"leave": "Покинуть"
|
|
2289
|
+
"leave": "Покинуть",
|
|
2290
|
+
"export": "Экспорт",
|
|
2291
|
+
"allRowsCount": "Все строки ({0})",
|
|
2292
|
+
"selectedRowsCount": "Выбранные строки ({0})"
|
|
2290
2293
|
},
|
|
2291
2294
|
"auth": {
|
|
2292
2295
|
"welcomeTo": "Добро пожаловать в",
|
|
@@ -2283,7 +2283,10 @@
|
|
|
2283
2283
|
"rowsPerPage": "每页行",
|
|
2284
2284
|
"unsavedChanges": "未保存的更改!",
|
|
2285
2285
|
"unsavedChangesDescription": "您确定要离开此页面吗?未保存的更改将丢失。",
|
|
2286
|
-
"leave": "离开"
|
|
2286
|
+
"leave": "离开",
|
|
2287
|
+
"export": "出口",
|
|
2288
|
+
"allRowsCount": "所有行({0})",
|
|
2289
|
+
"selectedRowsCount": "选定的行({0})"
|
|
2287
2290
|
},
|
|
2288
2291
|
"auth": {
|
|
2289
2292
|
"welcomeTo": "欢迎来到",
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
{
|
|
355
355
|
'arrow-selected':
|
|
356
356
|
isShowHiddenInfo &&
|
|
357
|
-
item2.id === selectedRow,
|
|
357
|
+
item2.id === props.selectedRow,
|
|
358
358
|
},
|
|
359
359
|
]"
|
|
360
360
|
@click.prevent.stop="
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
{
|
|
370
370
|
'arrow-selected':
|
|
371
371
|
isShowHiddenInfo &&
|
|
372
|
-
item2.id === selectedRow,
|
|
372
|
+
item2.id === props.selectedRow,
|
|
373
373
|
},
|
|
374
374
|
]"
|
|
375
375
|
/>
|
|
@@ -443,6 +443,25 @@
|
|
|
443
443
|
class="switch-icon"
|
|
444
444
|
/>
|
|
445
445
|
|
|
446
|
+
<template v-if="props.isShowExport && bodyItemsPresent.length">
|
|
447
|
+
<common-select-button-dropdown
|
|
448
|
+
v-if="props.selectedRow?.length"
|
|
449
|
+
:heading="localization.common.export"
|
|
450
|
+
:items="exportItems"
|
|
451
|
+
:test-id="`${props.testId}-export-btn`"
|
|
452
|
+
class="properties__actions"
|
|
453
|
+
is-top
|
|
454
|
+
@click="onExport"
|
|
455
|
+
/>
|
|
456
|
+
<button
|
|
457
|
+
v-else
|
|
458
|
+
class="export-link dropdown-toggle btn btn-sm btn-link"
|
|
459
|
+
@click="onExportAll"
|
|
460
|
+
>
|
|
461
|
+
{{ localization.common.export }}
|
|
462
|
+
</button>
|
|
463
|
+
</template>
|
|
464
|
+
|
|
446
465
|
<div v-if="$slots.action" class="datagrid-footer__action">
|
|
447
466
|
<slot name="action" />
|
|
448
467
|
</div>
|
|
@@ -508,7 +527,10 @@
|
|
|
508
527
|
</template>
|
|
509
528
|
|
|
510
529
|
<script setup lang="ts">
|
|
511
|
-
import type {
|
|
530
|
+
import type {
|
|
531
|
+
UI_I_HTMLSelectElement,
|
|
532
|
+
UI_I_Localization,
|
|
533
|
+
} from '~/lib/models/interfaces'
|
|
512
534
|
import type {
|
|
513
535
|
UI_I_HeadItem,
|
|
514
536
|
UI_I_BodyItem,
|
|
@@ -520,7 +542,10 @@ import type {
|
|
|
520
542
|
UI_T_SelectedRow,
|
|
521
543
|
} from '~/components/atoms/table/dataGrid/lib/models/types'
|
|
522
544
|
import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
|
|
545
|
+
import type { UI_I_DropdownButtonItem } from '~/components/common/select/button/lib/models/interfaces'
|
|
523
546
|
import { itemsPerPage } from '~/components/atoms/table/dataGrid/lib/config/itemsPerPage'
|
|
547
|
+
import { exportItemsFunc } from '~/components/atoms/table/dataGrid/lib/config/settingsTable'
|
|
548
|
+
import { generateCsvAndDownload } from '~/components/atoms/table/dataGrid/lib/utils/export'
|
|
524
549
|
|
|
525
550
|
const props = withDefaults(
|
|
526
551
|
defineProps<{
|
|
@@ -547,6 +572,7 @@ const props = withDefaults(
|
|
|
547
572
|
rowAttributeIdName?: string
|
|
548
573
|
isMainFilter?: boolean
|
|
549
574
|
mainFilterPlaceholder?: string
|
|
575
|
+
isShowExport?: boolean
|
|
550
576
|
}>(),
|
|
551
577
|
{
|
|
552
578
|
columnKeys: undefined,
|
|
@@ -557,6 +583,7 @@ const props = withDefaults(
|
|
|
557
583
|
testId: 'ui-data-grid',
|
|
558
584
|
withInfo: false,
|
|
559
585
|
rowAttributeIdName: 'data-id',
|
|
586
|
+
isShowExport: false,
|
|
560
587
|
}
|
|
561
588
|
)
|
|
562
589
|
|
|
@@ -572,6 +599,8 @@ const emits = defineEmits<{
|
|
|
572
599
|
(event: 'row-detail', value: number): void
|
|
573
600
|
}>()
|
|
574
601
|
|
|
602
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
603
|
+
|
|
575
604
|
const mainFilter = ref<string>('')
|
|
576
605
|
|
|
577
606
|
const mergeOptions = computed<UI_I_OptionItem[]>(
|
|
@@ -766,6 +795,7 @@ const changePageSize = (value: number): void => {
|
|
|
766
795
|
emits('update:page-size', value)
|
|
767
796
|
}
|
|
768
797
|
const changePage = (value: number): void => {
|
|
798
|
+
emits('update:selected-row', [])
|
|
769
799
|
emits('update:page', value)
|
|
770
800
|
}
|
|
771
801
|
|
|
@@ -1003,6 +1033,39 @@ const setResizeObserveWithInfo = (): void => {
|
|
|
1003
1033
|
resizeObserveWithInfo.observe(el)
|
|
1004
1034
|
}
|
|
1005
1035
|
|
|
1036
|
+
// Export
|
|
1037
|
+
const exportItems = computed<UI_I_DropdownButtonItem[]>(
|
|
1038
|
+
exportItemsFunc(
|
|
1039
|
+
localization.value,
|
|
1040
|
+
bodyItemsPresent.value.length || 0,
|
|
1041
|
+
props.selectedRow?.length || 0
|
|
1042
|
+
)
|
|
1043
|
+
)
|
|
1044
|
+
const onExport = (type: '0' | '1'): void => {
|
|
1045
|
+
switch (type) {
|
|
1046
|
+
case '0':
|
|
1047
|
+
onExportAll()
|
|
1048
|
+
break
|
|
1049
|
+
case '1':
|
|
1050
|
+
exportSelected()
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
const onExportAll = (): void => {
|
|
1054
|
+
const rows = document.querySelectorAll(
|
|
1055
|
+
`#${tableWrapperId} .datagrid-row-scrollable`
|
|
1056
|
+
) as NodeListOf<HTMLElement>
|
|
1057
|
+
generateCsvAndDownload(Array.from(rows))
|
|
1058
|
+
}
|
|
1059
|
+
const exportSelected = (): void => {
|
|
1060
|
+
const header = document.querySelectorAll(
|
|
1061
|
+
`#${tableWrapperId} .datagrid-row-scrollable`
|
|
1062
|
+
)[0] as HTMLElement
|
|
1063
|
+
const rows = document.querySelectorAll(
|
|
1064
|
+
`#${tableWrapperId} .datagrid-selected`
|
|
1065
|
+
) as NodeListOf<HTMLElement>
|
|
1066
|
+
generateCsvAndDownload([header, ...Array.from(rows)])
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1006
1069
|
onMounted(() => {
|
|
1007
1070
|
window.addEventListener('mousemove', mousemove)
|
|
1008
1071
|
window.addEventListener('mouseup', mouseup)
|
|
@@ -1,67 +1,91 @@
|
|
|
1
|
-
import type { UI_ColumnSettingsStrategy } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
|
|
2
|
-
import type {
|
|
3
|
-
UI_I_ColumnKey,
|
|
4
|
-
UI_I_HeadItem,
|
|
5
|
-
} from '~/components/atoms/table/dataGrid/lib/models/interfaces'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
item[
|
|
61
|
-
|
|
62
|
-
item[
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
import type { UI_ColumnSettingsStrategy } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
|
|
2
|
+
import type {
|
|
3
|
+
UI_I_ColumnKey,
|
|
4
|
+
UI_I_HeadItem,
|
|
5
|
+
} from '~/components/atoms/table/dataGrid/lib/models/interfaces'
|
|
6
|
+
import type { UI_I_DropdownButtonItem } from '~/components/common/select/button/lib/models/interfaces'
|
|
7
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
8
|
+
import {
|
|
9
|
+
constructColumnKey,
|
|
10
|
+
constructHeadItem,
|
|
11
|
+
} from '~/components/atoms/table/dataGrid/lib/utils/constructDataTable'
|
|
12
|
+
|
|
13
|
+
export const defaultColumnKeys = (
|
|
14
|
+
items: [string, boolean, string, string][],
|
|
15
|
+
strategy?: UI_ColumnSettingsStrategy
|
|
16
|
+
): UI_I_ColumnKey[] => {
|
|
17
|
+
const result: UI_I_ColumnKey[] = []
|
|
18
|
+
items.forEach((item, i) => {
|
|
19
|
+
let col: string = `col${i}` // Стандартное значение по умолчанию
|
|
20
|
+
|
|
21
|
+
if (strategy) {
|
|
22
|
+
// Проходим по ключам объекта и ищем соответствие индекса i в значениях
|
|
23
|
+
for (const key in strategy) {
|
|
24
|
+
if (strategy[key].includes(i)) {
|
|
25
|
+
col = key
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
result.push(
|
|
32
|
+
constructColumnKey(col, item[0], item[1], `show-column-${item[3]}`)
|
|
33
|
+
)
|
|
34
|
+
})
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const defaultHeadItems = (
|
|
39
|
+
items: [string, boolean, string, string][],
|
|
40
|
+
strategy?: UI_ColumnSettingsStrategy
|
|
41
|
+
): UI_I_HeadItem[] => {
|
|
42
|
+
const result: UI_I_HeadItem[] = []
|
|
43
|
+
items.forEach((item, i) => {
|
|
44
|
+
let col: string = `col${i}` // Стандартное значение по умолчанию
|
|
45
|
+
|
|
46
|
+
if (strategy) {
|
|
47
|
+
// Проходим по ключам объекта и ищем соответствие индекса i в значениях
|
|
48
|
+
for (const key in strategy) {
|
|
49
|
+
if (strategy[key].includes(i)) {
|
|
50
|
+
col = key
|
|
51
|
+
break
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
result.push(
|
|
57
|
+
constructHeadItem(
|
|
58
|
+
col,
|
|
59
|
+
item[0],
|
|
60
|
+
item[3],
|
|
61
|
+
false,
|
|
62
|
+
item[2],
|
|
63
|
+
undefined,
|
|
64
|
+
item[3]
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
return result
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const exportItemsFunc = (
|
|
72
|
+
localization: UI_I_Localization,
|
|
73
|
+
rows: number,
|
|
74
|
+
selectedRows: number
|
|
75
|
+
): UI_I_DropdownButtonItem[] => {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
text: localization.common.allRowsCount.replace('{0}', '' + rows),
|
|
79
|
+
type: '0',
|
|
80
|
+
disabled: false,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
text: localization.common.selectedRowsCount.replace(
|
|
84
|
+
'{0}',
|
|
85
|
+
'' + selectedRows
|
|
86
|
+
),
|
|
87
|
+
type: '1',
|
|
88
|
+
disabled: false,
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const generateCsvAndDownload = (rows: HTMLElement[]): void => {
|
|
2
|
+
const content: string[] = []
|
|
3
|
+
rows.forEach((row: HTMLElement) => {
|
|
4
|
+
content.push(row.innerText.replaceAll('\n', ';'))
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
const csvContent = 'data:text/csv;charset=utf-8,' + content.join('\n')
|
|
8
|
+
|
|
9
|
+
const encodedUri = encodeURI(csvContent)
|
|
10
|
+
const link = document.createElement('a')
|
|
11
|
+
link.setAttribute('href', encodedUri)
|
|
12
|
+
link.setAttribute('download', 'my_data.csv')
|
|
13
|
+
document.body.appendChild(link)
|
|
14
|
+
|
|
15
|
+
link.click()
|
|
16
|
+
}
|
|
@@ -1,102 +1,108 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="['dropdown-button dropdown', { open }]">
|
|
3
|
-
<button
|
|
4
|
-
:id="`${props.testId}-heading`"
|
|
5
|
-
:data-id="`${props.testId}-heading`"
|
|
6
|
-
class="btn btn-link dropdown-toggle"
|
|
7
|
-
@click.stop="open = !open"
|
|
8
|
-
>
|
|
9
|
-
{{ heading }}
|
|
10
|
-
<atoms-the-icon name="arrow" class="dropdown-arrow" />
|
|
11
|
-
</button>
|
|
12
|
-
|
|
13
|
-
<div v-show="open" class="dropdown-menu">
|
|
14
|
-
<div v-for="(item, key) in props.items" :key="key">
|
|
15
|
-
<button
|
|
16
|
-
:id="`${props.testId}-item`"
|
|
17
|
-
:data-id="item.testId"
|
|
18
|
-
:disabled="item.disabled"
|
|
19
|
-
class="dropdown-item"
|
|
20
|
-
@click="click(item.type)"
|
|
21
|
-
>
|
|
22
|
-
{{ item.text }}
|
|
23
|
-
</button>
|
|
24
|
-
<div v-if="item.divider" class="dropdown-divider" />
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script setup lang="ts">
|
|
31
|
-
import type { UI_I_DropdownButtonItem } from '~/components/common/select/button/lib/models/interfaces'
|
|
32
|
-
|
|
33
|
-
const props = withDefaults(
|
|
34
|
-
defineProps<{
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
width:
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['dropdown-button dropdown', { open }]">
|
|
3
|
+
<button
|
|
4
|
+
:id="`${props.testId}-heading`"
|
|
5
|
+
:data-id="`${props.testId}-heading`"
|
|
6
|
+
class="btn btn-link dropdown-toggle"
|
|
7
|
+
@click.stop="open = !open"
|
|
8
|
+
>
|
|
9
|
+
{{ heading }}
|
|
10
|
+
<atoms-the-icon name="arrow" class="dropdown-arrow" />
|
|
11
|
+
</button>
|
|
12
|
+
|
|
13
|
+
<div v-show="open" :class="['dropdown-menu', { top: props.isTop }]">
|
|
14
|
+
<div v-for="(item, key) in props.items" :key="key">
|
|
15
|
+
<button
|
|
16
|
+
:id="`${props.testId}-item`"
|
|
17
|
+
:data-id="item.testId"
|
|
18
|
+
:disabled="item.disabled"
|
|
19
|
+
class="dropdown-item"
|
|
20
|
+
@click="click(item.type)"
|
|
21
|
+
>
|
|
22
|
+
{{ item.text }}
|
|
23
|
+
</button>
|
|
24
|
+
<div v-if="item.divider" class="dropdown-divider" />
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import type { UI_I_DropdownButtonItem } from '~/components/common/select/button/lib/models/interfaces'
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(
|
|
34
|
+
defineProps<{
|
|
35
|
+
heading: string
|
|
36
|
+
items: UI_I_DropdownButtonItem[]
|
|
37
|
+
isTop?: boolean
|
|
38
|
+
testId?: string
|
|
39
|
+
}>(),
|
|
40
|
+
{ testId: 'select-dropdown-button' }
|
|
41
|
+
)
|
|
42
|
+
const emits = defineEmits<{
|
|
43
|
+
(event: 'click', value: string): void
|
|
44
|
+
}>()
|
|
45
|
+
const hide = (): void => {
|
|
46
|
+
open.value = false
|
|
47
|
+
}
|
|
48
|
+
const open = ref<boolean>(false)
|
|
49
|
+
|
|
50
|
+
const click = (type: string): void => {
|
|
51
|
+
emits('click', type)
|
|
52
|
+
}
|
|
53
|
+
const windowClick = (): void => {
|
|
54
|
+
hide()
|
|
55
|
+
}
|
|
56
|
+
onMounted(() => {
|
|
57
|
+
window.addEventListener('click', windowClick)
|
|
58
|
+
})
|
|
59
|
+
onUnmounted(() => {
|
|
60
|
+
window.removeEventListener('click', windowClick)
|
|
61
|
+
})
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style scoped lang="scss">
|
|
65
|
+
.dropdown {
|
|
66
|
+
&-menu {
|
|
67
|
+
min-width: 147px;
|
|
68
|
+
width: 260px;
|
|
69
|
+
background-color: var(--dropdown-bg-color);
|
|
70
|
+
border-color: var(--block-border-color);
|
|
71
|
+
|
|
72
|
+
&.top {
|
|
73
|
+
bottom: 100%;
|
|
74
|
+
top: unset;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
&-toggle {
|
|
78
|
+
font-size: 11px;
|
|
79
|
+
|
|
80
|
+
&.btn {
|
|
81
|
+
padding-right: 0.5rem;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
&-item {
|
|
85
|
+
border-bottom: 1px solid transparent;
|
|
86
|
+
color: var(--global-font-color4);
|
|
87
|
+
//text-align: center;
|
|
88
|
+
border-radius: 0;
|
|
89
|
+
&:hover {
|
|
90
|
+
background-color: var(--row-hover-bg-color);
|
|
91
|
+
border-color: var(--row-hover-border-color);
|
|
92
|
+
color: var(--global-font-color4);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
&-divider {
|
|
96
|
+
border-color: var(--block-border-color);
|
|
97
|
+
}
|
|
98
|
+
&-arrow {
|
|
99
|
+
width: 10px;
|
|
100
|
+
height: 10px;
|
|
101
|
+
position: absolute;
|
|
102
|
+
transform: translateY(-50%) rotate(180deg);
|
|
103
|
+
top: 50%;
|
|
104
|
+
right: 0;
|
|
105
|
+
fill: var(--arrows-icon);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</style>
|