shared-ritm 1.3.68 → 1.3.70
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.css +1 -1
- package/dist/shared-ritm.es.js +4582 -4433
- package/dist/shared-ritm.umd.js +181 -181
- package/dist/types/api/services/AuthService.d.ts +0 -1
- package/dist/types/api/services/MetricsService.d.ts +2 -1
- package/dist/types/api/services/PhotoService.d.ts +40 -0
- package/dist/types/api/services/UserService.d.ts +1 -2
- package/dist/types/api/settings/ApiService.d.ts +2 -6
- package/dist/types/api/types/Api_Auth.d.ts +0 -15
- package/dist/types/api/types/Api_Metrics.d.ts +18 -0
- package/dist/types/api/types/Api_User.d.ts +0 -9
- package/dist/types/common/app-checkbox/Checkbox.stories.d.ts +5 -1
- package/dist/types/common/app-toggle/Toggle.stories.d.ts +5 -1
- package/dist/types/stories/Button.stories.d.ts +13 -0
- package/dist/types/stories/Checkbox.stories.d.ts +7 -0
- package/dist/types/stories/Confirm.stories.d.ts +8 -0
- package/dist/types/stories/DatePicker.stories.d.ts +8 -0
- package/dist/types/stories/Dropdown.stories.d.ts +8 -0
- package/dist/types/stories/File.stories.d.ts +8 -0
- package/dist/types/stories/Icon.stories.d.ts +7 -0
- package/dist/types/stories/Input.stories.d.ts +11 -0
- package/dist/types/stories/InputNew.stories.d.ts +12 -0
- package/dist/types/stories/InputSearch.stories.d.ts +10 -0
- package/dist/types/stories/Loader.stories.d.ts +8 -0
- package/dist/types/stories/Select.stories.d.ts +7 -0
- package/dist/types/stories/Toggle.stories.d.ts +8 -0
- package/package.json +70 -70
- package/src/App.vue +2461 -2461
- package/src/api/services/AuthService.ts +4 -18
- package/src/api/services/ControlsService.ts +96 -96
- package/src/api/services/EquipmentService.ts +29 -29
- package/src/api/services/GanttService.ts +23 -23
- package/src/api/services/MetricsService.ts +127 -123
- package/src/api/services/RepairsService.ts +111 -111
- package/src/api/services/UserService.ts +0 -6
- package/src/api/services/VideoService.ts +118 -118
- package/src/api/settings/ApiService.ts +10 -70
- package/src/api/types/Api_Auth.ts +0 -16
- package/src/api/types/Api_Metrics.ts +26 -5
- package/src/api/types/Api_Repairs.ts +186 -186
- package/src/api/types/Api_Tasks.ts +376 -376
- package/src/api/types/Api_User.ts +0 -10
- package/src/api/types/Api_Video.ts +244 -244
- package/src/common/app-button/Button.stories.ts +369 -369
- package/src/common/app-checkbox/AppCheckbox.vue +17 -12
- package/src/common/app-checkbox/Checkbox.stories.ts +252 -60
- package/src/common/app-date-picker/DatePicker.stories.ts +66 -66
- package/src/common/app-datepicker/Datepicker.stories.ts +145 -145
- package/src/common/app-dialogs/AppConfirmDialog.vue +109 -109
- package/src/common/app-dialogs/Confirm.stories.ts +93 -93
- package/src/common/app-dropdown/Dropdown.stories.ts +94 -94
- package/src/common/app-file/File.stories.ts +104 -104
- package/src/common/app-icon/AppIcon.vue +108 -108
- package/src/common/app-icon/Icon.stories.ts +91 -91
- package/src/common/app-input/Input.stories.ts +160 -160
- package/src/common/app-input-new/InputNew.stories.ts +240 -240
- package/src/common/app-input-search/InputSearch.stories.ts +149 -149
- package/src/common/app-layout/components/AppLayoutHeader.vue +289 -289
- package/src/common/app-loader/Loader.stories.ts +114 -114
- package/src/common/app-select/AppSelect.vue +159 -159
- package/src/common/app-select/Select.stories.ts +155 -155
- package/src/common/app-sidebar/AppSidebar.vue +174 -174
- package/src/common/app-table/AppTable.vue +313 -313
- package/src/common/app-table/components/ModalSelect.stories.ts +323 -323
- package/src/common/app-table/components/ModalSelect.vue +302 -302
- package/src/common/app-table/components/TableModal.vue +367 -367
- package/src/common/app-table/controllers/useColumnSelector.ts +45 -45
- package/src/common/app-table/controllers/useTableModel.ts +97 -97
- package/src/common/app-toggle/AppToggle.vue +4 -16
- package/src/common/app-toggle/Toggle.stories.ts +245 -69
- package/src/common/app-wrapper/AppWrapper.vue +31 -31
- package/src/configs/storybook.ts +14 -14
- package/src/index.ts +131 -131
- package/src/shared/styles/general.css +140 -140
- package/src/styles/variables.sass +12 -12
- package/src/utils/helpers.ts +59 -59
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { computed, ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
export interface ColumnConfig {
|
|
4
|
-
name: string
|
|
5
|
-
label: string
|
|
6
|
-
[key: string]: any
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function useColumnSelector(allColumns: ColumnConfig[], fixedColumnNames: string[] = []) {
|
|
10
|
-
const selectedColumnNames = ref<string[]>([...new Set([...fixedColumnNames, ...allColumns.map(col => col.name)])])
|
|
11
|
-
|
|
12
|
-
const visibleColumns = computed(() => allColumns.filter(col => selectedColumnNames.value.includes(col.name)))
|
|
13
|
-
|
|
14
|
-
function openColumnSelectorDialog($q: any) {
|
|
15
|
-
$q.dialog({
|
|
16
|
-
title: 'Выберите колонки',
|
|
17
|
-
options: {
|
|
18
|
-
type: 'checkbox',
|
|
19
|
-
model: [...selectedColumnNames.value],
|
|
20
|
-
items: allColumns.map(col => ({
|
|
21
|
-
label: col.label,
|
|
22
|
-
value: col.name,
|
|
23
|
-
disable: fixedColumnNames.includes(col.name),
|
|
24
|
-
})),
|
|
25
|
-
},
|
|
26
|
-
cancel: {
|
|
27
|
-
label: 'Отмена',
|
|
28
|
-
'data-test': 'cancel-button',
|
|
29
|
-
},
|
|
30
|
-
ok: {
|
|
31
|
-
label: 'Ок',
|
|
32
|
-
'data-test': 'ok-button',
|
|
33
|
-
},
|
|
34
|
-
persistent: true,
|
|
35
|
-
}).onOk((val: string[]) => {
|
|
36
|
-
selectedColumnNames.value = Array.from(new Set([...val, ...fixedColumnNames]))
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
selectedColumnNames,
|
|
42
|
-
visibleColumns,
|
|
43
|
-
openColumnSelectorDialog,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import { computed, ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface ColumnConfig {
|
|
4
|
+
name: string
|
|
5
|
+
label: string
|
|
6
|
+
[key: string]: any
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useColumnSelector(allColumns: ColumnConfig[], fixedColumnNames: string[] = []) {
|
|
10
|
+
const selectedColumnNames = ref<string[]>([...new Set([...fixedColumnNames, ...allColumns.map(col => col.name)])])
|
|
11
|
+
|
|
12
|
+
const visibleColumns = computed(() => allColumns.filter(col => selectedColumnNames.value.includes(col.name)))
|
|
13
|
+
|
|
14
|
+
function openColumnSelectorDialog($q: any) {
|
|
15
|
+
$q.dialog({
|
|
16
|
+
title: 'Выберите колонки',
|
|
17
|
+
options: {
|
|
18
|
+
type: 'checkbox',
|
|
19
|
+
model: [...selectedColumnNames.value],
|
|
20
|
+
items: allColumns.map(col => ({
|
|
21
|
+
label: col.label,
|
|
22
|
+
value: col.name,
|
|
23
|
+
disable: fixedColumnNames.includes(col.name),
|
|
24
|
+
})),
|
|
25
|
+
},
|
|
26
|
+
cancel: {
|
|
27
|
+
label: 'Отмена',
|
|
28
|
+
'data-test': 'cancel-button',
|
|
29
|
+
},
|
|
30
|
+
ok: {
|
|
31
|
+
label: 'Ок',
|
|
32
|
+
'data-test': 'ok-button',
|
|
33
|
+
},
|
|
34
|
+
persistent: true,
|
|
35
|
+
}).onOk((val: string[]) => {
|
|
36
|
+
selectedColumnNames.value = Array.from(new Set([...val, ...fixedColumnNames]))
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
selectedColumnNames,
|
|
42
|
+
visibleColumns,
|
|
43
|
+
openColumnSelectorDialog,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { Ref, computed, ref } from 'vue'
|
|
2
|
-
|
|
3
|
-
export interface TableColumn {
|
|
4
|
-
name: string
|
|
5
|
-
label: string
|
|
6
|
-
style?: string
|
|
7
|
-
headerStyle?: string
|
|
8
|
-
field?: string | ((row: any) => any)
|
|
9
|
-
sortable?: boolean
|
|
10
|
-
filterType?: 'single' | 'multi' | null
|
|
11
|
-
align?: 'left' | 'center' | 'right'
|
|
12
|
-
badge?: {
|
|
13
|
-
true?: string
|
|
14
|
-
false?: string
|
|
15
|
-
colorTrue?: string
|
|
16
|
-
colorFalse?: string
|
|
17
|
-
}
|
|
18
|
-
format?: (val: any) => any
|
|
19
|
-
html?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface FilterOption {
|
|
23
|
-
id: string
|
|
24
|
-
name: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface TableModel<T = any> {
|
|
28
|
-
columns: TableColumn[]
|
|
29
|
-
rows: T[] | Ref<T[]>
|
|
30
|
-
filtersOptions?: Ref<Record<string, FilterOption[]>>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const useTableModel = <T = any>(model: TableModel<T>) => {
|
|
34
|
-
const columnFilters = ref<Record<string, string | string[] | undefined>>({})
|
|
35
|
-
const filterMenus = ref<Record<string, boolean>>({})
|
|
36
|
-
|
|
37
|
-
model.columns.forEach(({ name, filterType }) => {
|
|
38
|
-
if (filterType) {
|
|
39
|
-
columnFilters.value[name] = filterType === 'multi' ? [] : undefined
|
|
40
|
-
filterMenus.value[name] = false
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const resolvedRows = computed(() => (Array.isArray(model.rows) ? model.rows : model.rows.value))
|
|
45
|
-
|
|
46
|
-
const toggleFilterValue = (colName: string, value: string) => {
|
|
47
|
-
const col = model.columns.find(c => c.name === colName)
|
|
48
|
-
if (col?.filterType === 'multi') {
|
|
49
|
-
const current = columnFilters.value[colName] as string[]
|
|
50
|
-
const index = current.indexOf(value)
|
|
51
|
-
index > -1 ? current.splice(index, 1) : current.push(value)
|
|
52
|
-
columnFilters.value[colName] = [...current]
|
|
53
|
-
} else {
|
|
54
|
-
columnFilters.value[colName] = value
|
|
55
|
-
filterMenus.value[colName] = false
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const selectedFilters = computed(() => {
|
|
60
|
-
const result: Record<string, string[]> = {}
|
|
61
|
-
for (const col of model.columns) {
|
|
62
|
-
const filter = columnFilters.value[col.name]
|
|
63
|
-
const options = model.filtersOptions?.value[col.name] || []
|
|
64
|
-
|
|
65
|
-
if (filter) {
|
|
66
|
-
let selectedIds: string[] = []
|
|
67
|
-
if (Array.isArray(filter)) {
|
|
68
|
-
selectedIds = options.filter(opt => filter.includes(opt.name)).map(opt => opt.id)
|
|
69
|
-
} else {
|
|
70
|
-
selectedIds = options.filter(opt => opt.name === filter).map(opt => opt.id)
|
|
71
|
-
}
|
|
72
|
-
result[col.name] = Array.from(new Set(selectedIds))
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return result
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
const clearFilter = (colName: string) => {
|
|
79
|
-
const col = model.columns.find(c => c.name === colName)
|
|
80
|
-
columnFilters.value[colName] = col?.filterType === 'multi' ? [] : undefined
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const openFilterMenu = (colName: string, isOpen: boolean) => {
|
|
84
|
-
filterMenus.value[colName] = isOpen
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
rows: resolvedRows,
|
|
89
|
-
columns: computed(() => model.columns),
|
|
90
|
-
columnFilters,
|
|
91
|
-
filterMenus,
|
|
92
|
-
toggleFilterValue,
|
|
93
|
-
clearFilter,
|
|
94
|
-
openFilterMenu,
|
|
95
|
-
selectedFilters,
|
|
96
|
-
}
|
|
97
|
-
}
|
|
1
|
+
import { Ref, computed, ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface TableColumn {
|
|
4
|
+
name: string
|
|
5
|
+
label: string
|
|
6
|
+
style?: string
|
|
7
|
+
headerStyle?: string
|
|
8
|
+
field?: string | ((row: any) => any)
|
|
9
|
+
sortable?: boolean
|
|
10
|
+
filterType?: 'single' | 'multi' | null
|
|
11
|
+
align?: 'left' | 'center' | 'right'
|
|
12
|
+
badge?: {
|
|
13
|
+
true?: string
|
|
14
|
+
false?: string
|
|
15
|
+
colorTrue?: string
|
|
16
|
+
colorFalse?: string
|
|
17
|
+
}
|
|
18
|
+
format?: (val: any) => any
|
|
19
|
+
html?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FilterOption {
|
|
23
|
+
id: string
|
|
24
|
+
name: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TableModel<T = any> {
|
|
28
|
+
columns: TableColumn[]
|
|
29
|
+
rows: T[] | Ref<T[]>
|
|
30
|
+
filtersOptions?: Ref<Record<string, FilterOption[]>>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const useTableModel = <T = any>(model: TableModel<T>) => {
|
|
34
|
+
const columnFilters = ref<Record<string, string | string[] | undefined>>({})
|
|
35
|
+
const filterMenus = ref<Record<string, boolean>>({})
|
|
36
|
+
|
|
37
|
+
model.columns.forEach(({ name, filterType }) => {
|
|
38
|
+
if (filterType) {
|
|
39
|
+
columnFilters.value[name] = filterType === 'multi' ? [] : undefined
|
|
40
|
+
filterMenus.value[name] = false
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const resolvedRows = computed(() => (Array.isArray(model.rows) ? model.rows : model.rows.value))
|
|
45
|
+
|
|
46
|
+
const toggleFilterValue = (colName: string, value: string) => {
|
|
47
|
+
const col = model.columns.find(c => c.name === colName)
|
|
48
|
+
if (col?.filterType === 'multi') {
|
|
49
|
+
const current = columnFilters.value[colName] as string[]
|
|
50
|
+
const index = current.indexOf(value)
|
|
51
|
+
index > -1 ? current.splice(index, 1) : current.push(value)
|
|
52
|
+
columnFilters.value[colName] = [...current]
|
|
53
|
+
} else {
|
|
54
|
+
columnFilters.value[colName] = value
|
|
55
|
+
filterMenus.value[colName] = false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const selectedFilters = computed(() => {
|
|
60
|
+
const result: Record<string, string[]> = {}
|
|
61
|
+
for (const col of model.columns) {
|
|
62
|
+
const filter = columnFilters.value[col.name]
|
|
63
|
+
const options = model.filtersOptions?.value[col.name] || []
|
|
64
|
+
|
|
65
|
+
if (filter) {
|
|
66
|
+
let selectedIds: string[] = []
|
|
67
|
+
if (Array.isArray(filter)) {
|
|
68
|
+
selectedIds = options.filter(opt => filter.includes(opt.name)).map(opt => opt.id)
|
|
69
|
+
} else {
|
|
70
|
+
selectedIds = options.filter(opt => opt.name === filter).map(opt => opt.id)
|
|
71
|
+
}
|
|
72
|
+
result[col.name] = Array.from(new Set(selectedIds))
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const clearFilter = (colName: string) => {
|
|
79
|
+
const col = model.columns.find(c => c.name === colName)
|
|
80
|
+
columnFilters.value[colName] = col?.filterType === 'multi' ? [] : undefined
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const openFilterMenu = (colName: string, isOpen: boolean) => {
|
|
84
|
+
filterMenus.value[colName] = isOpen
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
rows: resolvedRows,
|
|
89
|
+
columns: computed(() => model.columns),
|
|
90
|
+
columnFilters,
|
|
91
|
+
filterMenus,
|
|
92
|
+
toggleFilterValue,
|
|
93
|
+
clearFilter,
|
|
94
|
+
openFilterMenu,
|
|
95
|
+
selectedFilters,
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<q-toggle v-
|
|
3
|
+
<q-toggle v-bind="$props" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import {
|
|
8
|
+
import { defineProps } from 'vue'
|
|
9
|
+
import { QToggleProps } from 'quasar'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
modelValue: any
|
|
12
|
-
disable?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const props = defineProps<Props>()
|
|
16
|
-
const emit = defineEmits(['update:modelValue', 'number'])
|
|
17
|
-
|
|
18
|
-
const value = computed({
|
|
19
|
-
get: () => props.modelValue,
|
|
20
|
-
set: (newValue: any) => emit('update:modelValue', newValue),
|
|
21
|
-
})
|
|
11
|
+
defineProps<QToggleProps>()
|
|
22
12
|
</script>
|
|
23
|
-
|
|
24
|
-
<style module lang="scss"></style>
|
|
@@ -1,69 +1,245 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
-
import AppToggle from '@/common/app-toggle/AppToggle.vue'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import AppToggle from '@/common/app-toggle/AppToggle.vue'
|
|
3
|
+
import { quasarColorOpts } from '@/configs/storybook'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof AppToggle> = {
|
|
6
|
+
title: 'Components/AppToggle',
|
|
7
|
+
component: AppToggle,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {
|
|
10
|
+
modelValue: {
|
|
11
|
+
control: 'text',
|
|
12
|
+
description: 'any | Array - required!',
|
|
13
|
+
table: { category: 'model' },
|
|
14
|
+
},
|
|
15
|
+
val: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
description: 'any | Используется, если model - массив',
|
|
18
|
+
table: { category: 'model' },
|
|
19
|
+
},
|
|
20
|
+
trueValue: {
|
|
21
|
+
control: 'text',
|
|
22
|
+
description: 'any | Какое значение модели следует считать вкл',
|
|
23
|
+
table: { category: 'model' },
|
|
24
|
+
},
|
|
25
|
+
falseValue: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
description: 'any | Какое значение модели следует считать выкл',
|
|
28
|
+
table: { category: 'model' },
|
|
29
|
+
},
|
|
30
|
+
indeterminateValue: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'any | Какое значение модели следует считать неопределённым',
|
|
33
|
+
table: { category: 'model' },
|
|
34
|
+
},
|
|
35
|
+
disable: {
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
name: {
|
|
39
|
+
control: 'text',
|
|
40
|
+
},
|
|
41
|
+
tabindex: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
description: 'number | string',
|
|
44
|
+
},
|
|
45
|
+
label: {
|
|
46
|
+
control: 'text',
|
|
47
|
+
},
|
|
48
|
+
leftLabel: {
|
|
49
|
+
control: 'boolean',
|
|
50
|
+
description: 'Расположить текст слева от переключателя',
|
|
51
|
+
},
|
|
52
|
+
size: {
|
|
53
|
+
control: 'text',
|
|
54
|
+
description: 'CSS или quasar(xs|sm|md|lg|xl)',
|
|
55
|
+
},
|
|
56
|
+
dark: {
|
|
57
|
+
control: 'boolean',
|
|
58
|
+
description: 'Используется для темного фона, чтобы фон переключателя был светлее',
|
|
59
|
+
},
|
|
60
|
+
dense: {
|
|
61
|
+
control: 'boolean',
|
|
62
|
+
},
|
|
63
|
+
color: {
|
|
64
|
+
control: 'select',
|
|
65
|
+
options: quasarColorOpts,
|
|
66
|
+
},
|
|
67
|
+
toggleOrder: {
|
|
68
|
+
control: 'text',
|
|
69
|
+
description:
|
|
70
|
+
'"tf" | "ft". Порядок переключения состояний. t - true, f - false. Если toggle-indeterminate истинно, то порядок следующий: indet -> первое состояние -> второе состояние -> indet (и повторять), в противном случае: indet -> первое состояние -> второе состояние -> первое состояние -> второе состояние -> ...',
|
|
71
|
+
},
|
|
72
|
+
toggleIndeterminate: {
|
|
73
|
+
control: 'boolean',
|
|
74
|
+
description:
|
|
75
|
+
'При взаимодействии пользователя с компонентом исполюзуется не только вкл/выкл, а ещё и неопределенное состояние',
|
|
76
|
+
},
|
|
77
|
+
keepColor: {
|
|
78
|
+
control: 'boolean',
|
|
79
|
+
description: 'Следует ли сохранять значение color, если выкл',
|
|
80
|
+
},
|
|
81
|
+
icon: {
|
|
82
|
+
control: 'text',
|
|
83
|
+
description: 'Если передано "none", иконка не используется',
|
|
84
|
+
table: { category: 'icon' },
|
|
85
|
+
},
|
|
86
|
+
checkedIcon: {
|
|
87
|
+
control: 'text',
|
|
88
|
+
description: 'Иконка для вкл',
|
|
89
|
+
table: { category: 'icon' },
|
|
90
|
+
},
|
|
91
|
+
uncheckedIcon: {
|
|
92
|
+
control: 'text',
|
|
93
|
+
description: 'Иконка для выкл',
|
|
94
|
+
table: { category: 'icon' },
|
|
95
|
+
},
|
|
96
|
+
indeterminateIcon: {
|
|
97
|
+
control: 'text',
|
|
98
|
+
description: 'Иконка для неопределенного состояния',
|
|
99
|
+
table: { category: 'icon' },
|
|
100
|
+
},
|
|
101
|
+
iconColor: {
|
|
102
|
+
control: 'select',
|
|
103
|
+
options: quasarColorOpts,
|
|
104
|
+
description: 'Цвет иконки из палитры quasar(только для вкл)',
|
|
105
|
+
table: { category: 'icon' },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
args: {
|
|
109
|
+
label: 'Toggle',
|
|
110
|
+
modelValue: 'on',
|
|
111
|
+
falseValue: 'off',
|
|
112
|
+
trueValue: 'on',
|
|
113
|
+
indeterminateValue: '',
|
|
114
|
+
disable: false,
|
|
115
|
+
name: 'toggler',
|
|
116
|
+
tabindex: '1',
|
|
117
|
+
leftLabel: false,
|
|
118
|
+
keepColor: false,
|
|
119
|
+
color: 'primary',
|
|
120
|
+
icon: 'none',
|
|
121
|
+
size: 'md',
|
|
122
|
+
dark: false,
|
|
123
|
+
dense: false,
|
|
124
|
+
toggleIndeterminate: false,
|
|
125
|
+
toggleOrder: 'ft',
|
|
126
|
+
val: '',
|
|
127
|
+
checkedIcon: 'none',
|
|
128
|
+
uncheckedIcon: 'none',
|
|
129
|
+
indeterminateIcon: 'none',
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default meta
|
|
134
|
+
|
|
135
|
+
type Story = StoryObj<typeof AppToggle>
|
|
136
|
+
|
|
137
|
+
export const Default: Story = {}
|
|
138
|
+
|
|
139
|
+
export const States: Story = {
|
|
140
|
+
render: () => ({
|
|
141
|
+
components: { AppToggle },
|
|
142
|
+
template: `
|
|
143
|
+
<AppToggle label="Включён" :model-value="true" />
|
|
144
|
+
<AppToggle label="Выключен left label" :model-value="false" left-label />
|
|
145
|
+
<AppToggle label="indeterminate" :model-value="null" indeterminate-value/>
|
|
146
|
+
<AppToggle label="Включён + отключён" :model-value="true" disable />
|
|
147
|
+
<AppToggle label="Выключен + отключён" :model-value="false" disable />
|
|
148
|
+
`,
|
|
149
|
+
}),
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const Sizes: Story = {
|
|
153
|
+
render: () => ({
|
|
154
|
+
components: { AppToggle },
|
|
155
|
+
template: `
|
|
156
|
+
<AppToggle size="xs" v-model="toggleState" val="xs" label="Size 'xs'" />
|
|
157
|
+
<AppToggle size="sm" v-model="toggleState" val="sm" label="Size 'sm'" />
|
|
158
|
+
<AppToggle size="md" v-model="toggleState" val="md" label="Size 'md'" />
|
|
159
|
+
<AppToggle size="lg" v-model="toggleState" val="lg" label="Size 'lg'" />
|
|
160
|
+
<AppToggle size="xl" v-model="toggleState" val="xl" label="Size 'xl'" />
|
|
161
|
+
<AppToggle size="150px" v-model="toggleState" val="150px" label="Size '150px'" />
|
|
162
|
+
`,
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
toggleState: true,
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export const Colors: Story = {
|
|
172
|
+
render: () => ({
|
|
173
|
+
components: { AppToggle },
|
|
174
|
+
template: `
|
|
175
|
+
<AppToggle v-model="toggleState" label="red" color="red"/>
|
|
176
|
+
<AppToggle v-model="toggleState" label="red keep color" color="red" keep-color />
|
|
177
|
+
<AppToggle v-model="toggleState" label="yellow" color="yellow" />
|
|
178
|
+
<AppToggle v-model="toggleState" label="yellow keep color" color="yellow" keep-color />
|
|
179
|
+
<AppToggle v-model="toggleState" label="green" color="green" />
|
|
180
|
+
<AppToggle v-model="toggleState" label="green keep color" color="green" keep-color />
|
|
181
|
+
`,
|
|
182
|
+
data() {
|
|
183
|
+
return {
|
|
184
|
+
toggleState: true,
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export const DarkBg: Story = {
|
|
191
|
+
render: () => ({
|
|
192
|
+
components: { AppToggle },
|
|
193
|
+
template: `
|
|
194
|
+
<div class="bg-secondary rounded-borders">
|
|
195
|
+
<AppToggle v-model="toggleState" label="red" dark class="text-white" color="red" />
|
|
196
|
+
<AppToggle v-model="toggleState" label="red keep color" dark keep-color class="text-white" color="red" />
|
|
197
|
+
<AppToggle v-model="toggleState" label="yellow" dark class="text-white" color="yellow" />
|
|
198
|
+
<AppToggle v-model="toggleState" label="yellow keep color" dark keep-color class="text-white" color="yellow" />
|
|
199
|
+
<AppToggle v-model="toggleState" label="green" dark class="text-white" color="green" />
|
|
200
|
+
<AppToggle v-model="toggleState" label="green keep color" dark keep-color class="text-white" color="green" />
|
|
201
|
+
</div>
|
|
202
|
+
`,
|
|
203
|
+
data() {
|
|
204
|
+
return {
|
|
205
|
+
toggleState: true,
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
}),
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export const Icons: Story = {
|
|
212
|
+
render: () => ({
|
|
213
|
+
components: { AppToggle },
|
|
214
|
+
template: `
|
|
215
|
+
<AppToggle v-model="toggleState" color="pink" icon="mail" label="Same Icon for each state" />
|
|
216
|
+
<AppToggle v-model="toggleState" color="orange" icon="alarm" label="Same Icon for each state" keep-color/>
|
|
217
|
+
<AppToggle v-model="toggleState" label="Different icon for each state" color="green" checked-icon="check" unchecked-icon="clear"/>
|
|
218
|
+
`,
|
|
219
|
+
data() {
|
|
220
|
+
return {
|
|
221
|
+
toggleState: true,
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
}),
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export const ArrayModel: Story = {
|
|
228
|
+
render: () => ({
|
|
229
|
+
components: { AppToggle },
|
|
230
|
+
template: `
|
|
231
|
+
<AppToggle color="blue" label="Blue" v-model="selection" val="blue" />
|
|
232
|
+
<AppToggle color="yellow" label="Yellow" v-model="selection" val="yellow" />
|
|
233
|
+
<AppToggle color="green" label="Green" v-model="selection" val="green" />
|
|
234
|
+
<AppToggle color="red" label="Red" v-model="selection" val="red" />
|
|
235
|
+
<div>
|
|
236
|
+
Model: {{selection}}
|
|
237
|
+
</div>
|
|
238
|
+
`,
|
|
239
|
+
data() {
|
|
240
|
+
return {
|
|
241
|
+
selection: ['yellow', 'red'],
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
}
|