@webitel/ui-sdk 24.10.48 → 24.10.49

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.
Files changed (35) hide show
  1. package/dist/ui-sdk.css +1 -1
  2. package/dist/ui-sdk.js +15643 -15660
  3. package/dist/ui-sdk.umd.cjs +17 -17
  4. package/package.json +7 -3
  5. package/src/components/index.js +2 -0
  6. package/src/components/wt-action-bar/WtActionBarActionsOrder.js +15 -0
  7. package/src/components/wt-action-bar/wt-action-bar.vue +29 -23
  8. package/src/components/wt-empty/_variables.scss +5 -0
  9. package/src/components/wt-empty/wt-empty.vue +232 -29
  10. package/src/components/wt-icon-action/IActionData.js +36 -0
  11. package/src/components/wt-icon-action/wt-icon-action.vue +23 -29
  12. package/src/composables/useAccessControl/useAccessControl.js +33 -0
  13. package/src/composables/useCachedItemInstanceName/useCachedItemInstanceName.js +33 -0
  14. package/src/composables/useCard/useCardComponent.js +88 -0
  15. package/src/composables/useCard/useCardTabs.js +28 -0
  16. package/src/composables/useClose/useClose.js +13 -0
  17. package/src/composables/useValidate/useValidate.js +10 -0
  18. package/src/css/main.scss +2 -5
  19. package/src/css/pages/card-page.scss +47 -0
  20. package/src/css/pages/table-page.scss +67 -0
  21. package/src/enums/ComponentSize/ComponentSize.enum.js +13 -0
  22. package/src/enums/index.js +39 -0
  23. package/src/scripts/compareSize.js +64 -0
  24. package/src/components/wt-icon-action/_internals/__tests__/WtAddIconAction.spec.js +0 -9
  25. package/src/components/wt-icon-action/_internals/__tests__/WtDeleteIconAction.spec.js +0 -9
  26. package/src/components/wt-icon-action/_internals/__tests__/WtDownloadIconAction.spec.js +0 -9
  27. package/src/components/wt-icon-action/_internals/__tests__/WtEditIconAction.spec.js +0 -9
  28. package/src/components/wt-icon-action/_internals/__tests__/WtHistoryIconAction.spec.js +0 -9
  29. package/src/components/wt-icon-action/_internals/__tests__/WtRefreshIconAction.spec.js +0 -9
  30. package/src/components/wt-icon-action/_internals/wt-add-icon-action.vue +0 -27
  31. package/src/components/wt-icon-action/_internals/wt-delete-icon-action.vue +0 -27
  32. package/src/components/wt-icon-action/_internals/wt-download-icon-action.vue +0 -27
  33. package/src/components/wt-icon-action/_internals/wt-edit-icon-action.vue +0 -27
  34. package/src/components/wt-icon-action/_internals/wt-history-icon-action.vue +0 -27
  35. package/src/components/wt-icon-action/_internals/wt-refresh-icon-action.vue +0 -27
@@ -0,0 +1,33 @@
1
+ import get from 'lodash/get.js';
2
+ import { onMounted, ref, watch } from 'vue';
3
+
4
+ export const useCachedItemInstanceName = (itemInstance, { namePath = 'name' } = {}) => {
5
+ const name = ref('');
6
+
7
+ const updateName = () => {
8
+ name.value = get(itemInstance.value, namePath);
9
+ };
10
+
11
+ watch(
12
+ () => itemInstance.value._dirty,
13
+ (value) => {
14
+ if (!value) updateName();
15
+ },
16
+ );
17
+
18
+ onMounted(() => {
19
+ // itemInstance._dirty isn't init as "false",
20
+ // so that we should set up first name representation in other way
21
+ const unwatch = watch(
22
+ () => itemInstance.value.name,
23
+ (name) => {
24
+ updateName();
25
+ if (name) unwatch();
26
+ },
27
+ );
28
+ });
29
+
30
+ return {
31
+ name,
32
+ };
33
+ };
@@ -0,0 +1,88 @@
1
+ import { computed, onMounted, onUnmounted } from 'vue';
2
+ import { useI18n } from 'vue-i18n';
3
+ import { useRoute, useRouter } from 'vue-router';
4
+
5
+ import { useCachedItemInstanceName } from '../useCachedItemInstanceName/useCachedItemInstanceName.js';
6
+
7
+ export const useCardComponent = (params) => {
8
+ const { id,
9
+ itemInstance,
10
+ invalid,
11
+
12
+ loadItem,
13
+ addItem,
14
+ updateItem,
15
+ setId,
16
+ resetState } = params;
17
+
18
+ const router = useRouter();
19
+ const route = useRoute();
20
+ const { t } = useI18n();
21
+
22
+ const { name: pathName } = useCachedItemInstanceName(itemInstance);
23
+
24
+ const isNew = computed(() => route.params.id === 'new');
25
+ const disabledSave = computed(() => {
26
+ return invalid?.value || !itemInstance.value._dirty;
27
+ });
28
+
29
+ const saveText = computed(() => {
30
+ return isNew.value || itemInstance.value._dirty ? t('objects.save') : t('objects.saved');
31
+ });
32
+
33
+ const redirectToEdit = () => {
34
+ return router.replace({
35
+ ...route,
36
+ params: { id },
37
+ });
38
+ };
39
+
40
+ const save = async () => {
41
+ if (disabledSave.value) return;
42
+
43
+ if (isNew.value) {
44
+ await addItem();
45
+ } else {
46
+ await updateItem();
47
+ }
48
+
49
+ if (id.value) {
50
+ await redirectToEdit();
51
+ }
52
+ };
53
+
54
+ async function initializeCard() {
55
+ try {
56
+ const { id } = route.params;
57
+ await setId(id);
58
+ await loadItem();
59
+ } catch (error) {
60
+ console.error(error);
61
+ }
62
+ }
63
+
64
+ function initialize(){
65
+ onMounted(() => {
66
+ initializeCard();
67
+ });
68
+
69
+ onUnmounted(() => {
70
+ resetState();
71
+ });
72
+ }
73
+
74
+
75
+ return {
76
+ id,
77
+ itemInstance,
78
+ isNew,
79
+ pathName,
80
+ disabledSave,
81
+ saveText,
82
+
83
+ save,
84
+ initialize,
85
+ }
86
+ }
87
+
88
+
@@ -0,0 +1,28 @@
1
+ import { computed } from 'vue';
2
+ import { useRoute, useRouter } from 'vue-router';
3
+
4
+ export const useCardTabs = (tabs) => {
5
+ const router = useRouter();
6
+ const route = useRoute();
7
+
8
+ const currentTab = computed(() => {
9
+ return tabs.find(({ pathName }) => route.name === pathName) || tabs[0];
10
+ });
11
+
12
+ function changeTab(tab) {
13
+ const { params, query, hash } = route;
14
+
15
+ return router.push({
16
+ name: tab.pathName,
17
+ params,
18
+ query,
19
+ hash,
20
+ });
21
+ }
22
+
23
+ return {
24
+ currentTab,
25
+
26
+ changeTab,
27
+ }
28
+ }
@@ -0,0 +1,13 @@
1
+ import { useRouter } from 'vue-router';
2
+
3
+ // eslint-disable-next-line import/prefer-default-export
4
+ export const useClose = (name) => {
5
+ const router = useRouter();
6
+
7
+ function close() {
8
+ if (window.history.length === 1) window.close();
9
+ return router.push({ name });
10
+ }
11
+
12
+ return { close };
13
+ };
@@ -0,0 +1,10 @@
1
+ import { useVuelidate } from '@vuelidate/core';
2
+
3
+ export const useValidate = (schema, data) => {
4
+ const v$ = useVuelidate(schema, data, { $autoDirty: true });
5
+
6
+ return {
7
+ v$,
8
+ invalid: v$.$invalid,
9
+ };
10
+ }
package/src/css/main.scss CHANGED
@@ -1,5 +1,7 @@
1
1
  @import 'styleguide/styleguide';
2
2
  @import 'styleguide/display-helpers/display-helpers';
3
+ @import 'pages/card-page';
4
+ @import 'pages/table-page';
3
5
 
4
6
  @include wt-placeholder;
5
7
 
@@ -31,11 +33,6 @@ body {
31
33
  }
32
34
  }
33
35
 
34
- //main {
35
- // min-height: 100%;
36
- // height: 100%;
37
- //}
38
-
39
36
  h1, h2, h3, h4, h5, h6, p {
40
37
  margin: 0;
41
38
  font-weight: normal;
@@ -0,0 +1,47 @@
1
+ .opened-card {
2
+ &.wt-page-wrapper {
3
+ width: 100%;
4
+ }
5
+
6
+ &-header {
7
+ position: relative;
8
+ display: flex;
9
+ align-items: center;
10
+ flex-wrap: wrap;
11
+ justify-content: space-between;
12
+ margin: var(--spacing-sm) 0;
13
+
14
+ &__title {
15
+ @extend %typo-heading-3;
16
+
17
+ + .hint {
18
+ top: -2px;
19
+ }
20
+ }
21
+ }
22
+
23
+ &-form {
24
+ display: flex;
25
+ flex-direction: column;
26
+ width: 100%;
27
+ }
28
+ &-input-grid {
29
+ display: grid;
30
+ align-items: flex-start;
31
+ grid-template-columns: 1fr 1fr;
32
+ grid-auto-rows: minmax(auto, auto);
33
+ grid-column-gap: var(--spacing-sm);
34
+ grid-row-gap: var(--spacing-xs);
35
+
36
+ &--1-col {
37
+ grid-template-columns: 1fr;
38
+ }
39
+
40
+ &--w50 {
41
+ width: 50%;
42
+ }
43
+ &--w100{
44
+ width: 100%;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,67 @@
1
+ .table-page{
2
+
3
+ &.wt-page-wrapper {
4
+ width: 100%;
5
+ height: 100%;
6
+
7
+ &__main {
8
+ min-height: 0;
9
+
10
+ .wt-loader {
11
+ position: absolute;
12
+ top: 50%;
13
+ left: 50%;
14
+ transform: translate(-50%, -50%);
15
+ }
16
+ }
17
+ }
18
+
19
+ .table-section {
20
+ display: flex;
21
+ flex-direction: column;
22
+ width: 100%;
23
+
24
+ &__table-wrapper {
25
+ display: flex;
26
+ flex-direction: column;
27
+ justify-content: space-between;
28
+ flex: 1 1 100%;
29
+ width: 100%;
30
+ gap: var(--spacing-sm);
31
+ min-height: 0;
32
+
33
+ .wt-table__head {
34
+ position: sticky;
35
+ top: 0;
36
+ z-index: 1;
37
+ }
38
+
39
+ .wt-pagination {
40
+ margin-top: auto;
41
+ }
42
+ }
43
+ }
44
+
45
+ .table-title {
46
+ position: relative;
47
+ display: flex;
48
+ flex-wrap: wrap;
49
+ align-items: center;
50
+ justify-content: space-between;
51
+ margin: var(--spacing-sm) 0;
52
+
53
+ &__title {
54
+ @extend %typo-heading-3;
55
+
56
+ + .hint {
57
+ top: -2px;
58
+ }
59
+ }
60
+
61
+ &__actions-wrap {
62
+ display: flex;
63
+ align-items: center;
64
+ gap: var(--table-actions-icon-gap);
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,13 @@
1
+ const ComponentSize = Object.freeze({
2
+ XXXS: '3xs',
3
+ XXS: '2xs',
4
+ XS: 'xs',
5
+ SM: 'sm',
6
+ MD: 'md',
7
+ LG: 'lg',
8
+ XL: 'xl',
9
+ XXL: '2xl',
10
+ XXXL: '3xl',
11
+ });
12
+
13
+ export default ComponentSize;
@@ -0,0 +1,39 @@
1
+ import AbstractUserStatus
2
+ from './AbstractUserStatus/AbstractUserStatus.enum.js';
3
+ import AgentStatus from './AgentStatus/AgentStatus.enum.js';
4
+ import ChatGatewayProvider
5
+ from './ChatGatewayProvider/ChatGatewayProvider.enum.js';
6
+ import ComponentSize from './ComponentSize/ComponentSize.enum.js';
7
+ import IconAction from './IconAction/IconAction.enum.js';
8
+ import QueueType from './QueueType/QueueType.enum.js';
9
+ import TypesExportedSettings
10
+ from './TypesExportedSettings/TypesExportedSettings.enum.js';
11
+
12
+ // Webitel Applications group
13
+ import AdminSections from './WebitelApplications/AdminSections.enum.js';
14
+ import AuditorSections from './WebitelApplications/AuditorSections.enum.js';
15
+ import CrmConfigurationSections
16
+ from './WebitelApplications/CrmConfigurationSections.enum.js';
17
+ import CrmSections from './WebitelApplications/CrmSections.enum.js';
18
+ import SupervisorSections
19
+ from './WebitelApplications/SupervisorSections.enum.js';
20
+ import WebitelApplications
21
+ from './WebitelApplications/WebitelApplications.enum.js';
22
+
23
+ export {
24
+ AbstractUserStatus,
25
+ AgentStatus,
26
+ ChatGatewayProvider,
27
+ ComponentSize,
28
+ IconAction,
29
+ QueueType,
30
+ TypesExportedSettings,
31
+
32
+ // Webitel Applications group
33
+ AdminSections,
34
+ AuditorSections,
35
+ CrmSections,
36
+ CrmConfigurationSections,
37
+ SupervisorSections,
38
+ WebitelApplications,
39
+ };
@@ -0,0 +1,64 @@
1
+ import ComponentSize from '../enums/ComponentSize/ComponentSize.enum.js';
2
+
3
+ const numerics = Object.values(ComponentSize).reduce((nums, size, index) => {
4
+ return {
5
+ ...nums,
6
+ [size]: index,
7
+ };
8
+ }, {});
9
+
10
+ /**
11
+ * Compare two sizes, returning a number indicating the difference between them.
12
+ *
13
+ * @param s1
14
+ * @param s2
15
+ * @returns {number}
16
+ *
17
+ * @example
18
+ * compareSize(ComponentSize.XS, ComponentSize.MD); // true
19
+ * compareSize(ComponentSize.LG, ComponentSize.SM); // false
20
+ */
21
+ export const compareSize = (s1, s2) => {
22
+ return numerics[s1] - numerics[s2];
23
+ };
24
+
25
+ /**
26
+ * Check if s1 is smaller than s2
27
+ * @param s1
28
+ * @param s2
29
+ * @returns {boolean}
30
+ */
31
+
32
+ export const smallerThen = (s1, s2) => {
33
+ return compareSize(s1, s2) < 0;
34
+ };
35
+
36
+ /**
37
+ * Check if s1 is smaller or equal to s2
38
+ * @param s1
39
+ * @param s2
40
+ * @returns {boolean}
41
+ */
42
+ export const smallerOrEqual = (s1, s2) => {
43
+ return compareSize(s1, s2) <= 0;
44
+ };
45
+
46
+ /**
47
+ * Check if s1 is greater than s2
48
+ * @param s1
49
+ * @param s2
50
+ * @returns {boolean}
51
+ */
52
+ export const greaterThen = (s1, s2) => {
53
+ return compareSize(s1, s2) > 0;
54
+ };
55
+
56
+ /**
57
+ * Check if s1 is greater or equal to s2
58
+ * @param s1
59
+ * @param s2
60
+ * @returns {boolean}
61
+ */
62
+ export const greaterOrEqual = (s1, s2) => {
63
+ return compareSize(s1, s2) >= 0;
64
+ };
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtAddIconAction from '../wt-add-icon-action.vue';
3
-
4
- describe('WtAddIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtAddIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtDeleteIconAction from '../wt-delete-icon-action.vue';
3
-
4
- describe('WtDeleteIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtDeleteIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtDownloadIconAction from '../wt-download-icon-action.vue';
3
-
4
- describe('WtDownloadIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtDownloadIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtEditIconAction from '../wt-edit-icon-action.vue';
3
-
4
- describe('WtEditIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtEditIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtHistoryIconAction from '../wt-history-icon-action.vue';
3
-
4
- describe('WtHistoryIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtHistoryIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,9 +0,0 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import WtRefreshIconAction from '../wt-refresh-icon-action.vue';
3
-
4
- describe('WtRefreshIconAction', () => {
5
- it('renders a component', () => {
6
- const wrapper = shallowMount(WtRefreshIconAction);
7
- expect(wrapper.exists()).toBe(true);
8
- });
9
- });
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="plus"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('webitelUI.iconAction.addActionHint') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="bucket"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('webitelUI.iconAction.deleteActionHint') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="download"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('webitelUI.iconAction.downloadActionHint') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="edit"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('webitelUI.iconAction.editActionHint') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="history"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('webitelUI.iconAction.historyActionHint') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>
@@ -1,27 +0,0 @@
1
- <template>
2
- <wt-tooltip>
3
- <template #activator>
4
- <wt-icon-btn
5
- :disabled="disabled"
6
- icon="refresh"
7
- @click="emit('click')"
8
- />
9
- </template>
10
- {{ $t('reusable.refresh') }}
11
- </wt-tooltip>
12
- </template>
13
-
14
- <script setup>
15
- const props = defineProps({
16
- disabled: {
17
- type: Boolean,
18
- default: false,
19
- },
20
- });
21
-
22
- const emit = defineEmits(['click']);
23
- </script>
24
-
25
- <style scoped>
26
-
27
- </style>