@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "24.12.68",
3
+ "version": "24.12.72",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -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="wrapperShown || isCloseAnimationPlaying"
3
+ v-show="showPopupComponent"
17
4
  :class="[`wt-popup--size-${size}`, { 'wt-popup--overflow': overflow }]"
18
5
  class="wt-popup"
19
6
  >
7
+
8
+ <!-- &lt;!&ndash; @slot check source code for scoped bindings :( &ndash;&gt;-->
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
- if (wrapperShown.value) {
128
- closePopup();
129
- } else {
130
- openPopup();
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
 
@@ -1,4 +1,4 @@
1
- export type TableHeader = {
1
+ export type WtTableHeader = {
2
2
  value: string;
3
3
  locale?: string | string[];
4
4
  text?: string;
@@ -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 type { TableHeader } from '../wt-table/types/table-header.js';
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: TableHeader[];
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 }: TableHeader) => {
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: TableHeader) => {
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 setup lang="ts">
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 type { TableHeader } from '../wt-table/types/table-header.ts';
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: TableHeader[];
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
- import type { TableHeader } from '../../components/wt-table/types/table-header.ts';
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<TableHeader[]>(() => {
9
+ const tableHeaders = computed<WtTableHeader[]>(() => {
9
10
  return headers
10
- .filter((header: TableHeader) => header.show === undefined || header.show)
11
- .map((header: TableHeader) => {
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: typeof header.locale === 'string' ? t(header.locale) : t(header.locale[0]),
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
- <wt-loader v-show="isLoading" />
22
+ <div class="table-section__table-wrapper">
23
23
 
24
- <wt-empty
25
- v-show="showEmpty"
26
- :image="imageEmpty"
27
- :text="textEmpty"
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