@webitel/ui-sdk 24.12.68 → 24.12.72
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/CHANGELOG.md +18 -0
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +2590 -2594
- package/dist/ui-sdk.umd.cjs +14 -14
- package/package.json +1 -1
- package/src/api/types/ApiModule.type.ts +21 -0
- package/src/components/wt-popup/wt-popup.vue +29 -23
- package/src/components/wt-table/types/{table-header.ts → WtTable.type.ts} +1 -1
- package/src/components/wt-tree-table/wt-tree-table.vue +4 -4
- package/src/components/wt-tree-table-row/wt-tree-table-row.vue +10 -10
- package/src/composables/useWtTable/useWtTable.ts +11 -5
- package/src/modules/ObjectPermissions/components/permissions-tab.vue +8 -7
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Id = number | string;
|
|
2
|
+
|
|
3
|
+
export interface ApiModule<Entity> {
|
|
4
|
+
getList?: (
|
|
5
|
+
params?: unknown,
|
|
6
|
+
) => Promise<{ items?: Entity[]; next?: boolean; aggs?: unknown }>;
|
|
7
|
+
getLookup?: (
|
|
8
|
+
params?: unknown,
|
|
9
|
+
) => Promise<{ items?: Entity[]; next?: boolean }>;
|
|
10
|
+
get?: ({ itemId }: { itemId: Id }) => Promise<Entity>;
|
|
11
|
+
add?: ({ itemInstance }: { itemInstance?: Entity }) => Promise<Entity>;
|
|
12
|
+
update?: ({
|
|
13
|
+
itemId,
|
|
14
|
+
itemInstance,
|
|
15
|
+
}: {
|
|
16
|
+
itemId: Id;
|
|
17
|
+
itemInstance?: Entity;
|
|
18
|
+
}) => Promise<Entity>;
|
|
19
|
+
patch?: ({ id, changes }: { id?: Id; changes?: Entity }) => Promise<Entity>;
|
|
20
|
+
delete?: ({ itemId }: { itemId: Id }) => Promise<void>;
|
|
21
|
+
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- @slot check source code for scoped bindings :( -->
|
|
3
|
-
<slot
|
|
4
|
-
class="wt-popup-activator"
|
|
5
|
-
name="activator"
|
|
6
|
-
v-bind="{
|
|
7
|
-
shown: wrapperShown,
|
|
8
|
-
size,
|
|
9
|
-
disabled,
|
|
10
|
-
open: openPopup,
|
|
11
|
-
close: closePopup,
|
|
12
|
-
toggle: togglePopup,
|
|
13
|
-
} as ActivatorSlotScope"
|
|
14
|
-
/>
|
|
15
2
|
<div
|
|
16
|
-
v-show="
|
|
3
|
+
v-show="showPopupComponent"
|
|
17
4
|
:class="[`wt-popup--size-${size}`, { 'wt-popup--overflow': overflow }]"
|
|
18
5
|
class="wt-popup"
|
|
19
6
|
>
|
|
7
|
+
|
|
8
|
+
<!-- <!– @slot check source code for scoped bindings :( –>-->
|
|
9
|
+
<!-- <slot-->
|
|
10
|
+
<!-- class="wt-popup-activator"-->
|
|
11
|
+
<!-- name="activator"-->
|
|
12
|
+
<!-- v-bind="{-->
|
|
13
|
+
<!-- shown: wrapperShown,-->
|
|
14
|
+
<!-- size,-->
|
|
15
|
+
<!-- disabled,-->
|
|
16
|
+
<!-- open: openPopup,-->
|
|
17
|
+
<!-- close: closePopup,-->
|
|
18
|
+
<!-- toggle: togglePopup,-->
|
|
19
|
+
<!-- } as ActivatorSlotScope"-->
|
|
20
|
+
<!-- />-->
|
|
21
|
+
|
|
20
22
|
<transition-slide :offset="[0, -1440 / 2]">
|
|
21
23
|
<aside
|
|
22
24
|
v-if="wrapperShown"
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
|
|
54
56
|
<script lang="ts" setup>
|
|
55
57
|
import {TransitionSlide} from '@morev/vue-transitions';
|
|
56
|
-
import {defineEmits, defineProps, ref, watch} from 'vue';
|
|
58
|
+
import {computed, defineEmits, defineProps, ref, watch} from 'vue';
|
|
57
59
|
|
|
58
60
|
import {ComponentSize} from "../../enums/ComponentSize/ComponentSize.enum.ts";
|
|
59
61
|
|
|
@@ -105,6 +107,7 @@ interface ActivatorSlotScope {
|
|
|
105
107
|
const slots = defineSlots<{
|
|
106
108
|
activator?: ActivatorSlotScope;
|
|
107
109
|
}>();
|
|
110
|
+
const activatorMode = !!slots.activator;
|
|
108
111
|
|
|
109
112
|
const wrapperShown = ref(false);
|
|
110
113
|
const isCloseAnimationPlaying = ref(false);
|
|
@@ -123,13 +126,17 @@ const closePopup = () => {
|
|
|
123
126
|
}, 200); // 200 -> 0.2s css var(--transition); duration
|
|
124
127
|
};
|
|
125
128
|
|
|
126
|
-
const togglePopup = () => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
129
|
+
// const togglePopup = () => {
|
|
130
|
+
// if (wrapperShown.value) {
|
|
131
|
+
// closePopup();
|
|
132
|
+
// } else {
|
|
133
|
+
// openPopup();
|
|
134
|
+
// }
|
|
135
|
+
// };
|
|
136
|
+
|
|
137
|
+
const showPopupComponent = computed(() => {
|
|
138
|
+
return wrapperShown.value || isCloseAnimationPlaying.value;
|
|
139
|
+
});
|
|
133
140
|
|
|
134
141
|
// overlay should be shown before popup to show animation properly
|
|
135
142
|
watch(
|
|
@@ -144,7 +151,6 @@ watch(
|
|
|
144
151
|
* but if that's so, there's no `shown` prop => it's true by default => popup is initially shown
|
|
145
152
|
* so we need to handle initial popup visibility depending on activator slot presence
|
|
146
153
|
*/
|
|
147
|
-
const activatorMode = !!slots.activator;
|
|
148
154
|
if (activatorMode) return;
|
|
149
155
|
|
|
150
156
|
|
|
@@ -94,7 +94,7 @@ import { computed, withDefaults } from 'vue';
|
|
|
94
94
|
|
|
95
95
|
import { useWtTable } from '../../composables/useWtTable/useWtTable.ts';
|
|
96
96
|
import { getNextSortOrder } from '../../scripts/sortQueryAdapters';
|
|
97
|
-
import
|
|
97
|
+
import { WtTableHeader } from '../wt-table/types/WtTable.type.ts';
|
|
98
98
|
import WtTreeTableRow from '../wt-tree-table-row/wt-tree-table-row.vue';
|
|
99
99
|
|
|
100
100
|
const props = withDefaults(
|
|
@@ -102,7 +102,7 @@ const props = withDefaults(
|
|
|
102
102
|
/**
|
|
103
103
|
* 'Accepts list of header objects. Draws text depending on "text" property, looks for data values through "value", "show" boolean controls visibility of a column (if undefined, all visible by default). ' Column width is calculated by "width" param. By default, sets minmax(150px, 1fr). '
|
|
104
104
|
*/
|
|
105
|
-
headers:
|
|
105
|
+
headers: WtTableHeader[];
|
|
106
106
|
/**
|
|
107
107
|
* 'List of data, represented by table. '
|
|
108
108
|
*/
|
|
@@ -193,7 +193,7 @@ const { tableHeaders: dataHeaders } = useWtTable({
|
|
|
193
193
|
headers: props.headers,
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
const isColSortable = ({ sort }:
|
|
196
|
+
const isColSortable = ({ sort }: WtTableHeader) => {
|
|
197
197
|
/* --sortable = sortable && col.sort === undefined cause there may be some columns we don't want to sort
|
|
198
198
|
strict check for === undefined is used because col.sort = null is sort order too (actualu, without sort)
|
|
199
199
|
so we need to check if this property is present
|
|
@@ -201,7 +201,7 @@ const isColSortable = ({ sort }: TableHeader) => {
|
|
|
201
201
|
return props.sortable && sort !== undefined;
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
const sort = (col:
|
|
204
|
+
const sort = (col: WtTableHeader) => {
|
|
205
205
|
if (!isColSortable(col)) return;
|
|
206
206
|
const nextSort = getNextSortOrder(col.sort);
|
|
207
207
|
emit('sort', col, nextSort);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<tr
|
|
3
|
-
class="wt-tree-table-row"
|
|
4
3
|
:class="[{ 'wt-tree-table-row--alternate': rowPosition % 2 }]"
|
|
4
|
+
class="wt-tree-table-row"
|
|
5
5
|
>
|
|
6
6
|
<td
|
|
7
7
|
v-for="(col, headerKey) of dataHeaders"
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
<wt-tree-table-row
|
|
70
70
|
v-for="(child, index) in data[childrenProp]"
|
|
71
71
|
:key="index"
|
|
72
|
-
:row-position="rowPosition"
|
|
73
|
-
:data-headers="dataHeaders"
|
|
74
|
-
:data="child"
|
|
75
|
-
:selectable="selectable"
|
|
76
|
-
:selected-elements="selectedElements"
|
|
77
72
|
:children-prop="childrenProp"
|
|
73
|
+
:data="child"
|
|
74
|
+
:data-headers="dataHeaders"
|
|
78
75
|
:nesting-level="childLevel"
|
|
76
|
+
:row-position="rowPosition"
|
|
79
77
|
:searched-prop="searchedProp"
|
|
78
|
+
:selectable="selectable"
|
|
79
|
+
:selected-elements="selectedElements"
|
|
80
80
|
@expanded-collapse="openCollapse"
|
|
81
81
|
@update:selected="
|
|
82
82
|
$emit('update:selected', {
|
|
@@ -109,12 +109,12 @@
|
|
|
109
109
|
</template>
|
|
110
110
|
</template>
|
|
111
111
|
|
|
112
|
-
<script
|
|
112
|
+
<script lang="ts" setup>
|
|
113
113
|
import { computed, onMounted, ref } from 'vue';
|
|
114
114
|
|
|
115
115
|
import WtCheckbox from '../wt-checkbox/wt-checkbox.vue';
|
|
116
116
|
import WtIconBtn from '../wt-icon-btn/wt-icon-btn.vue';
|
|
117
|
-
import
|
|
117
|
+
import { WtTableHeader } from "../wt-table/types/WtTable.type.ts";
|
|
118
118
|
|
|
119
119
|
const props = withDefaults(
|
|
120
120
|
defineProps<{
|
|
@@ -132,7 +132,7 @@ const props = withDefaults(
|
|
|
132
132
|
childrenProp: string;
|
|
133
133
|
selectable?: boolean;
|
|
134
134
|
selectedElements: Record<string, any>[];
|
|
135
|
-
dataHeaders:
|
|
135
|
+
dataHeaders: WtTableHeader[];
|
|
136
136
|
gridActions?: boolean;
|
|
137
137
|
/**
|
|
138
138
|
* 'It's a nesting level of row. 0 - root row, 1 - first level of nesting, etc.'
|
|
@@ -219,8 +219,8 @@ onMounted(() => {
|
|
|
219
219
|
|
|
220
220
|
&__icon-wrapper {
|
|
221
221
|
display: flex;
|
|
222
|
-
margin-right: var(--spacing-xs);
|
|
223
222
|
align-items: flex-start;
|
|
223
|
+
margin-right: var(--spacing-xs);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
&__content {
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
import { useI18n } from 'vue-i18n';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { WtTableHeader } from '../../components/wt-table/types/WtTable.type.ts';
|
|
4
5
|
|
|
5
6
|
export const useWtTable = ({ headers }) => {
|
|
6
7
|
const { t } = useI18n();
|
|
7
8
|
|
|
8
|
-
const tableHeaders = computed<
|
|
9
|
+
const tableHeaders = computed<WtTableHeader[]>(() => {
|
|
9
10
|
return headers
|
|
10
|
-
.filter(
|
|
11
|
-
|
|
11
|
+
.filter(
|
|
12
|
+
(header: WtTableHeader) => header.show === undefined || header.show,
|
|
13
|
+
)
|
|
14
|
+
.map((header: WtTableHeader) => {
|
|
12
15
|
if (!header.text && header.locale) {
|
|
13
16
|
return {
|
|
14
17
|
...header,
|
|
15
|
-
text:
|
|
18
|
+
text:
|
|
19
|
+
typeof header.locale === 'string'
|
|
20
|
+
? t(header.locale)
|
|
21
|
+
: t(header.locale[0]),
|
|
16
22
|
};
|
|
17
23
|
}
|
|
18
24
|
return header;
|
|
@@ -19,15 +19,16 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
</header>
|
|
21
21
|
|
|
22
|
-
<
|
|
22
|
+
<div class="table-section__table-wrapper">
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
<wt-loader v-show="isLoading" />
|
|
25
|
+
|
|
26
|
+
<wt-empty
|
|
27
|
+
v-show="showEmpty"
|
|
28
|
+
:image="imageEmpty"
|
|
29
|
+
:text="textEmpty"
|
|
30
|
+
/>
|
|
29
31
|
|
|
30
|
-
<div class="table-section__table-wrapper">
|
|
31
32
|
<div class="table-section__visible-scroll-wrapper">
|
|
32
33
|
<wt-table-transition v-if="dataList.length && !isLoading" >
|
|
33
34
|
<wt-table
|